From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (NAM02-DM3-obe.outbound.protection.outlook.com [40.107.95.75]) by mx.groups.io with SMTP id smtpd.web12.8.1631220071946194191 for ; Thu, 09 Sep 2021 13:41:12 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=owurXEsM; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.95.75, mailfrom: jbrasen@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EsPBlKbTez3Omunt1+hieEhN83RAKwPRvpBUZptLAi8n0TU6mZx8VZmmCYuonKEi3RemiPxYdTUMCoOE/nrylR4YISGtpXP/LXcHolL82VDqBCmrKkkyEkvDTsokaONpQ6OFkEyINOGbdwvcRXKVQZM4/bTFztJlf3MqFqcUE6mzuSCFT1Te8X+PtAPXCcqbo1Uf8v872DGHssfpmiUoxR49n/RgvGEEXpde03T+ErqHgzeqULGdXeiU5+peh1PoMqvp+1V8rlxkn8z+vEovQDmqKAf0XWu6lUtZewf84V97ZOs1tNRl2E6xBNmrkDMGch+BwGOED3a8TjdJgBQTNg== 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=c1krpIyho/Fi3loiFE3/oT9/ZC2rtvsxoxydyBJqMVQ=; b=e/85DQCiWvJHaqEjIbx1XWzBL+DUrfmpLJLFC6KuUV9Jp9ChUhavo65jxS9p+/yZKVmc0CYQXXDGdVEioZv6diFWeg69Ir/CUnKIavwWxkN8k6tGrlTrg6uIzMhq5SYAydahES6tYpDSXOiwPvvrYuuPjeyaiTDZLweFgw094t/9uxVf41Uv1LflSCqIlUGoY15qCimHo5g1CCYWgb7UYgfR4/HB/d85T1BNrMBsDcAedvWqfPOWPTfVbXA442M9rhcy4R58cr+G1HsK9eOzm9srByLJUcKogQC1e4vE8zfM/z1XwulhjePJjIXLZz2peqIxkG5nnhc8ANoawpoLbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=gmail.com 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c1krpIyho/Fi3loiFE3/oT9/ZC2rtvsxoxydyBJqMVQ=; b=owurXEsML2RVk1i9s4ba0ZyOSvqytNUuy3gwEq4YzeoOjQJf3MdpuAyNvujbxGrWyelg1sqGyIHa+cMsQS9ouoFZDldNWgE6Tqgao/2IC6wjFyG5LNMfyAej76qt2cdazdCFvQB+Cd/Bf73vfllS0ao0GqareQtgnvZw4+PnAlbu7+xkiYAtdD/twUG8Tc1BNc62m4ak9i+R89vfEBFzke6PZ7AwL4omuKlXgRiphBAb707nO+DzmOQZogZBnZWwWy8vVS/e3xyYrJ23NVOl4nfJ0J00yFzyG85XH4k0rcZgHdlFv9NZlkULuAoVEKsas7YnuhOCxAJg9REQ5AUP8g== Received: from MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) by BN8PR12MB3441.namprd12.prod.outlook.com (2603:10b6:408:49::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.21; Thu, 9 Sep 2021 20:41:10 +0000 Received: from CO1NAM11FT043.eop-nam11.prod.protection.outlook.com (2603:10b6:301:0:cafe::50) by MWHPR10CA0017.outlook.office365.com (2603:10b6:301::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Thu, 9 Sep 2021 20:41:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT043.mail.protection.outlook.com (10.13.174.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4500.14 via Frontend Transport; Thu, 9 Sep 2021 20:41:09 +0000 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 9 Sep 2021 20:41:09 +0000 Received: from build-jbrasen-20210819T103534360.nvidia.com (172.20.187.6) by mail.nvidia.com (172.20.187.13) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 9 Sep 2021 20:41:09 +0000 From: "Jeff Brasen" To: CC: , Jeff Brasen Subject: [PATCH 1/2] Ext4Pkg: Improve Binding support behavior Date: Thu, 9 Sep 2021 20:41:00 +0000 Message-ID: <9c6ac428e55f3584295bd490502532ba456b4d3f.1631219610.git.jbrasen@nvidia.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 In-Reply-To: References: X-NVConfidentiality: public Return-Path: jbrasen@nvidia.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9eb23aa1-7560-4ddf-76a9-08d973d227cc X-MS-TrafficTypeDiagnostic: BN8PR12MB3441: 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: BCL:0; X-Microsoft-Antispam-Message-Info: c6E91knjOHv2U+tfHiCiUjwLyAf1nbC3fR57A4oTGR57VYg5r0PR8fJ3DRH8aAvtkKf1NYdZLC/wxloABrrfw8Bl2QC605QrtBuhO4N297nXpPclxRvMzkvyVdFPLc9PoN30PTv6s8GSk7rNTZOoRpDBN75fOsiy7XGbnJ03HhctMX628s2H7FevG9Aafz2zyq+LNLvGGk2HBkgLo3Yt9O1pN7R7RDqqAAd1ji5RRV3atI9Cfj6KrTEhi4i0wY9a3a89lTX6duxNGBtUCJx6IU0ofm/kwrU18mXAt4dHgGMx/XKP5gHK3rl3ZyaqN8DjUbbWpRcyrSUKKfqBE5gtafLyLRp9tvtOt9ogaJfc3M6VDxk5LU/mEdQLUrB6vrzbhScSbGEyvfV1an8v0v8OSbFXiqiGZbIMn3wE3b3i2Vi09ifuw2aAnvrCHpXLXm8AUMOhcObz/o+zc35KEX2fb36ZcazOXimVlD7mus5f56LfLdMaox+ct2IBApvEZsOEr8qFj2P0buQ78gs1t4uFnUNFd0SDTgrT1WzlNskrQpyYBm7C73RdWbtZeB8TwWSP4O139+t4w6/m5Jrt3neU1bZ0U6uR7MCeSMeU00TkmqXO5i23ZF8ObbQtTQXWnrrLfRV8IZilcLH2xiViso//Fmg0cjGCaZQtlLoMws6O6sZUWp0blqqXhrC68RjL7kPiCV+voLdjz1NkHIr6lScZixQZqdoOCBG6UUaBgIHx1bo= X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(39860400002)(136003)(346002)(376002)(396003)(46966006)(36840700001)(426003)(8676002)(26005)(70206006)(70586007)(186003)(7696005)(5660300002)(107886003)(4326008)(8936002)(2616005)(19627235002)(336012)(7636003)(82310400003)(36860700001)(47076005)(356005)(86362001)(2906002)(83380400001)(54906003)(82740400003)(6916009)(6666004)(478600001)(316002)(36756003)(36906005)(32563001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2021 20:41:09.6584 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9eb23aa1-7560-4ddf-76a9-08d973d227cc 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.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT043.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3441 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain A couple improvements to improve performance. Add check to return ACCESS_DENIED if already connected Add check to verify superblock magic during supported to deduce start calls Signed-off-by: Jeff Brasen --- Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 14 +++++++ Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c | 57 +++++++++++++++++++++------ Features/Ext4Pkg/Ext4Dxe/Superblock.c | 34 ++++++++++++++++ 3 files changed, 92 insertions(+), 13 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.h index 64eab455db..9a3938e671 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h @@ -1117,4 +1117,18 @@ Ext4GetVolumeName ( OUT UINTN *VolNameLen ); =20 +/** + Checks only superblock magic value. + + @param[in] DiskIo Pointer to the DiskIo. + @param[in] BlockIo Pointer to the BlockIo. + + @return TRUE if a valid ext4 superblock, else FALSE. +**/ +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..cb1e6d532a 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,64 @@ 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_STATUS Status; + EFI_DISK_IO_PROTOCOL *DiskIo =3D NULL; + EFI_BLOCK_IO_PROTOCOL *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; + goto Exit; } - + // + // 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)) { + goto Exit; + } + + if (!Ext4SuperblockCheckMagic (DiskIo, BlockIo)) { + Status =3D EFI_UNSUPPORTED; + } + +Exit: + // + // 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..1f8cdd3705 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c @@ -34,6 +34,40 @@ 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 only superblock magic value. + + @param[in] DiskIo Pointer to the DiskIo. + @param[in] BlockIo Pointer to the BlockIo. + + @return TRUE if a valid ext4 superblock, else FALSE. +**/ +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_SUPE= RBLOCK, 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