From nobody Tue Feb 10 01:15:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80511+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1631311894915220.49678562875852; Fri, 10 Sep 2021 15:11:34 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UK6zYY1788612xX5fBi93drr; Fri, 10 Sep 2021 15:11:34 -0700 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.42]) by mx.groups.io with SMTP id smtpd.web12.64.1631311893425720120 for ; Fri, 10 Sep 2021 15:11:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eEk4ohSAYL0PBjGXidJg3M2C5gnqWF1wMmUBPJgvuuIpikajI7imU8DNobc8liivEdiV9BiVYgcpPKpM4BjeyK+Kr5q47FO6mSSMRLRwSNlpCzec6mHg8COGy1DpMSI7/P5E47Htts0xh195iHSqH/vjppWXTEjAG6pP+ioOUKmZLSkpAHpkZuzGHHpUs/7RZvBtZ5/QLDytY3DanJZN8HwsmGQ3Tc9XXUH3EXHNNDODwh1WnRuLaQigTy9l0hg373qEyNQmnhx/4YRsNi063vjzcoWyNtKKEYLZI5iqIfhMCgYkJHGsAznBU3KmgQzf3HdeIYPRmL2PhPSf/yN2SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=VlMlp77t03RusEQCklH2SFeFCKSXYzdex+iWtVb1ooo=; b=e3Lb3dnmp+QOUJVDOk28LjIqI2HcsazbVnFBI69zVs7Y7FjjiDr5KqdBqGvhXOzT58IHaxxyqbTHqUNQVDVvDwEaBts29JaNKedRKOUa8VZD2Xz+s56K8S27adEhOzngSTsK96NQL4pnp4Lx4Pn52oJEpWgqIrhT+ajhRNzj3njtCYEPi9EhdR8gqjp0sZNYAk7DM40i+z/D0B1OG8jd8tIsJH8ZCAbQMXmOkOYD6/Zj+oA8UrA8AlQXyr4EqZfYE6Kw4fdJ8o+4z8EAIihmyzynlLWAkj3RRTQRNaIcrAxVFPQeGAe5idlY7kBT4z/6vX7slDgLUwDtGRRnZoFRxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.35) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from MW2PR2101CA0026.namprd21.prod.outlook.com (2603:10b6:302:1::39) by BN9PR12MB5209.namprd12.prod.outlook.com (2603:10b6:408:11a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.17; Fri, 10 Sep 2021 22:11:32 +0000 X-Received: from CO1NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:302:1:cafe::22) by MW2PR2101CA0026.outlook.office365.com (2603:10b6:302:1::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.0 via Frontend Transport; Fri, 10 Sep 2021 22:11:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.35) smtp.mailfrom=nvidia.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+80511+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.35 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.35; helo=mail.nvidia.com; X-Received: from mail.nvidia.com (216.228.112.35) by CO1NAM11FT063.mail.protection.outlook.com (10.13.175.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 22:11:31 +0000 X-Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 10 Sep 2021 22:11:31 +0000 X-Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 10 Sep 2021 22:11:30 +0000 X-Received: from build-jbrasen-20210819T103534360.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Fri, 10 Sep 2021 15:11:30 -0700 From: "Jeff Brasen via groups.io" To: CC: , Jeff Brasen Subject: [edk2-devel] [PATCH v3 1/2] Ext4Pkg: Improve Ext4IsBindingSupported() behavior Date: Fri, 10 Sep 2021 22:11:27 +0000 Message-ID: <7631e4dcf3c01613ca24d3acd9b4bd5d09fa8126.1631311760.git.jbrasen@nvidia.com> MIME-Version: 1.0 In-Reply-To: References: X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2540866b-fa01-4264-a58d-08d974a7f1f4 X-MS-TrafficTypeDiagnostic: BN9PR12MB5209: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:486; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: kYQCklEnwl190MF6iPoKQ1LD6t9Y2wwqYropAVPsdUhwlGz4HdkWtaQE62eWEB2C4PMNYvDR4CrSEDlrKb5iPRpWALBJ0jz6Eln3lllM0i6JMBjkMpLPfSoeo/JHyI6HSv/0ml1p4zEHvubO9OZN0T5QppTZpWahxAoAEEE13USz6nGWp2Vn20dIcoueCsWAi/BZw1bsSyOqVnXss8LbESkvasHobO+hgv7KPqquGuuXw2s4Z4NzJIISVDMsAR8LLHZY2KgMiG+Mvxdst6aGyiTAj19pZwMepmPnemuvkHs5XirbMQPNJdORTc7uSygx2ewzoyuFVDx7tFK15o6VucdQfkTg1PFV+6G5wfh4ao4nv92aF6o2kghsEO8frkp0OfXiBawLwkfAqFGF2rXBhGdFvzFIDCycpvg7U4OdJpKgONBUYzLDfCGjen8rd49B2tQiAWj9kElX/3MxpteBTwQwVo4M7z396I1zOAQ27WWktge/dDnG2/Q0htDBZJSQvSeZ59OOBrCdhFiynBmCEY2gWVyMYqwlyrn0O5+zMTARYYP/HQ65e9+9vFs5GWCYLFcSKfBwRJghtj+OAX0sh6u5botXpEHTUv2tVeNrqIWR6fr6L7jpmolbbwNcOh7AWSHk7hte2Fvtnb8UOQ1h3GGsma0y1fBIgLVwWAqIM1sFd2TJZ6CpXbySOHGRQyYiUoVYTEfLnod9XFdRIs2s2Seyr6cQ6+hC1QUoAofV49w= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 22:11:31.6199 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2540866b-fa01-4264-a58d-08d974a7f1f4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.35];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5209 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jbrasen@nvidia.com X-Gm-Message-State: ipJ6heEM5JUQkeYDrRjJwZ6vx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1631311894; bh=exelQ3VZ3oGsK2YCVYCrWvBbXSth7guFr+2xalvsi0A=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=oW9xPBbZ8uQdl95a7TAC+A9K9vBytf+IGaSGmBMJefWJtxNZeuuATxfjfQ7lhfatdjS ZzpaCS7+YMyaPpiBpuVhzUUjmwH1xG7UtdwoKJr0oK5oWnwAqj+38lB9lPwwII+4iSzzz YILl/iLYuhnWooAQrrdAx4vAPS7u2i3roRc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1631311895521100004 Content-Type: text/plain; charset="utf-8" A couple of improvements to improve performance. Add check to return ACCESS_DENIED if already connected Add check to verify superblock magic during supported to reduce start calls Signed-off-by: Jeff Brasen --- Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 14 +++++++ Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c | 54 +++++++++++++++++++++------ Features/Ext4Pkg/Ext4Dxe/Superblock.c | 35 +++++++++++++++++ 3 files changed, 92 insertions(+), 11 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.h index 64eab455db..a9b932ed52 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h @@ -1117,4 +1117,18 @@ Ext4GetVolumeName ( OUT UINTN *VolNameLen ); =20 +/** + Checks the superblock's magic value. + + @param[in] DiskIo Pointer to the DiskIo. + @param[in] BlockIo Pointer to the BlockIo. + + @returns Whether the partition has a valid EXT4 superblock magic value. +**/ +BOOLEAN +Ext4SuperblockCheckMagic ( + IN EFI_DISK_IO_PROTOCOL *DiskIo, + IN EFI_BLOCK_IO_PROTOCOL *BlockIo + ); + #endif diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.c index ea2e048d77..d9fbe9ea78 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c @@ -631,7 +631,6 @@ Ext4Unload ( @retval EFI_ACCESS_DENIED The device specified by ControllerHandl= e and RemainingDevicePath is already being ma= naged by a different driver or an application that requires = exclusive access. - Currently not implemented. @retval EFI_UNSUPPORTED The device specified by ControllerHandl= e and RemainingDevicePath is not supported by= the driver specified by This. **/ @@ -643,32 +642,65 @@ Ext4IsBindingSupported ( IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL ) { - // Note to self: EFI_OPEN_PROTOCOL_TEST_PROTOCOL lets us not close the - // protocol and ignore the output argument entirely + EFI_STATUS Status; + EFI_DISK_IO_PROTOCOL *DiskIo; + EFI_BLOCK_IO_PROTOCOL *BlockIo; =20 - EFI_STATUS Status; + DiskIo =3D NULL; + BlockIo =3D NULL; =20 + // + // Open the IO Abstraction(s) needed to perform the supported test + // Status =3D gBS->OpenProtocol ( ControllerHandle, &gEfiDiskIoProtocolGuid, - NULL, - BindingProtocol->ImageHandle, + (VOID **) &DiskIo, + BindingProtocol->DriverBindingHandle, ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL + EFI_OPEN_PROTOCOL_BY_DRIVER ); =20 if (EFI_ERROR (Status)) { return Status; } - + // + // Open the IO Abstraction(s) needed to perform the supported test + // Status =3D gBS->OpenProtocol ( ControllerHandle, &gEfiBlockIoProtocolGuid, - NULL, - BindingProtocol->ImageHandle, + (VOID **) &BlockIo, + BindingProtocol->DriverBindingHandle, ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL + EFI_OPEN_PROTOCOL_GET_PROTOCOL ); + + if (!EFI_ERROR (Status)) { + if (!Ext4SuperblockCheckMagic (DiskIo, BlockIo)) { + Status =3D EFI_UNSUPPORTED; + } + } + + // + // Close the I/O Abstraction(s) used to perform the supported test + // + if (DiskIo !=3D NULL) { + gBS->CloseProtocol ( + ControllerHandle, + &gEfiDiskIoProtocolGuid, + BindingProtocol->DriverBindingHandle, + ControllerHandle + ); + } + if (BlockIo !=3D NULL) { + gBS->CloseProtocol ( + ControllerHandle, + &gEfiBlockIoProtocolGuid, + BindingProtocol->DriverBindingHandle, + ControllerHandle + ); + } return Status; } =20 diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4D= xe/Superblock.c index c321d8c3d8..0c965415c5 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c @@ -34,6 +34,41 @@ STATIC CONST UINT32 gSupportedIncompatFeat =3D // this is desired, it's fairly trivial to look for EFI_VOLUME_CORRUPTED // references and add some Ext4SignalCorruption function + function call. =20 +/** + Checks the superblock's magic value. + + @param[in] DiskIo Pointer to the DiskIo. + @param[in] BlockIo Pointer to the BlockIo. + + @returns Whether the partition has a valid EXT4 superblock magic value. +**/ +BOOLEAN +Ext4SuperblockCheckMagic ( + IN EFI_DISK_IO_PROTOCOL *DiskIo, + IN EFI_BLOCK_IO_PROTOCOL *BlockIo + ) +{ + UINT16 Magic; + EFI_STATUS Status; + + Status =3D DiskIo->ReadDisk ( + DiskIo, + BlockIo->Media->MediaId, + EXT4_SUPERBLOCK_OFFSET + OFFSET_OF (EXT4_SUPERBLOCK, = s_magic), + sizeof (Magic), + &Magic + ); + if (EFI_ERROR (Status)) { + return FALSE; + } + + if (Magic !=3D EXT4_SIGNATURE) { + return FALSE; + } + + return TRUE; +} + /** Does brief validation of the ext4 superblock. =20 --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#80511): https://edk2.groups.io/g/devel/message/80511 Mute This Topic: https://groups.io/mt/85521568/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-