From nobody Sun May 19 09:42:25 2024 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+98905+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 1674149767826947.478732738964; Thu, 19 Jan 2023 09:36:07 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id VCPAYY1788612xYYytmGrAo5; Thu, 19 Jan 2023 09:36:07 -0800 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.41]) by mx.groups.io with SMTP id smtpd.web11.52080.1674149765892891345 for ; Thu, 19 Jan 2023 09:36:06 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OfipYmz7s6C1DKQlGcqYnxYUMHLk/7vC0YvMaHimFuedNLBCn41OFjgQChXLvE0DWC5tDafVafHNYqZq8yGB0SXukGY2Q3JNPA0rx5tVC4nIi5QqqSr3DVGLqnkPKUgynpLSq4qo0uu8TadYPaZee6yM4CfsQrHyti5lPtf33CJ5tU9b6T898MlqJ1GvTMQiBNJyskJcCZKqD7Mkrn+bQL4cu6XDyhLAva+Uoijkm5MRngfhLmghyT7cSuLxbQSZ7CiVdGFewe+n0Sae16v3ZjV48Wnm1fISrgrVuoUmf5UAFRe8MLe82FStKFwDeRzNPdXkfdXCI6TRH4KJ3H1a6Q== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+34G/hRp7+wHcgnHygKh8RtDwGmNaLu1YmQRbww5c/k=; b=WtBbRSq99CkG1V/3h/CzA9qUF7LMlQ3d0zoF6dzVbHKce/mgMNt+bFJ5buRTt0zqXBkIFoWnpv3xcU+0NA7rmW9J2hERJWgfGgd/CodI5tYLbUhPSa1Q+wpmh0njIqMwnpP815v5R+gwtMVPU5n5Xva416Xqj422jbeFkO7bBJBTFC30hAzy/qjurc8yExJO2OtgotIOgAo4jkQDhdvqE9HJwaLPbvbqsKsHxvDTNYf0zFEGA9IZfd+CdP2ZkuhtFTTHs2AZzdDiNd5W0VCxjAExN3NHBxPYnUrZ4DJNQca+/CvKkMyg8TRdMyY9HnF473ZGjLe/Wnw05Ok9fq8Elw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from DS7PR03CA0181.namprd03.prod.outlook.com (2603:10b6:5:3b6::6) by CH0PR12MB5041.namprd12.prod.outlook.com (2603:10b6:610:e0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.26; Thu, 19 Jan 2023 17:36:03 +0000 X-Received: from DM6NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b6:cafe::ab) by DS7PR03CA0181.outlook.office365.com (2603:10b6:5:3b6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Thu, 19 Jan 2023 17:36:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;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+98905+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT050.mail.protection.outlook.com (10.13.173.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6023.16 via Frontend Transport; Thu, 19 Jan 2023 17:36:03 +0000 X-Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 19 Jan 2023 09:35:51 -0800 X-Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 19 Jan 2023 09:35:51 -0800 X-Received: from build-jeshuas-20221215T071333555.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 19 Jan 2023 09:35:50 -0800 From: "Jeshua Smith via groups.io" To: CC: , , , , Jeshua Smith Subject: [edk2-devel] [PATCH] MdeModulePkg: allow PlatformBootManagerLib to use BootNext Date: Thu, 19 Jan 2023 17:35:33 +0000 Message-ID: <35e417f3ded0035bb51371bed3627393672a57d2.1674149644.git.jeshuas@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT050:EE_|CH0PR12MB5041:EE_ X-MS-Office365-Filtering-Correlation-Id: 90fb738e-eb48-46f3-2400-08dafa43a317 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: tXYGyF/sOvERMlTywGVshJLsX+0UILk+qbQdjeUCm3gk9c5xNbIXf4TzsFeAE1Zyfa4pJ3bMMEJuKccXSdXFrDTqekrZbhrfBj/jkyifq8UxA5hl+y5CgBJHnr5PIU3yWdOOhHkN11pzgkGkETV2NCzvSzPPj5Rsl9UZY2U3eGlarGf99Nzv7EVqjY8SNXVReAboLUPr3sbpnyrO55dZVkJPO7+ZeLHmKb5DpQvUUJRVanmh54r9SlPwi/+9RZdIzuZVEpagIDuO+9GAQv9nMoh3g1sAecySmq0b/ASJ01VfVU+QGMOx86LHzKGJXXC0SCrYLYS30ivST76Ow1B5k60jdhx5a2UCk9vBDQKwUebIxb1kLXU7dyp3LoEDP6uR5btgD6og4TLyTD18096+1Mn6Pj4LHP46hS0xAN+q3PX7wtfnOGRR2YKA5YD3NS3mju4tpdVnb04Qh7e5FfsBigDg6MxR0TekZFUHqpJimnnBl+LaAm6fzJIsg5CxxnuxecLFLUiuRkMpyfFrMGGcvBHA5SVYEEgV1J9vMeETRqjOJR5iMFpxsSM3cbuJDhEVwg8Fzv06AIn6SWdIJ6uqbB7rlEX3cVqV7IOocbJBzNtx9a4YGIxgQV/NhXcYgqy2k4F/0ypE4UbG5Fgin/PnUPg+UNzb3CTpuYdj+lXTsnlBPXvSe9pKcL1Kqtkmk/+/xWn0YrA9n1biNZpNlVziWA== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 17:36:03.0739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90fb738e-eb48-46f3-2400-08dafa43a317 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5041 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,jeshuas@nvidia.com X-Gm-Message-State: 4491JxAseUNIJhAT7O7zI3Bzx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1674149767; bh=0SalZvxWjthfGYB78lWziDoxmbHScnaRkyCb/A9ooHY=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=JTwDsCCpM+mqILLdz25VrJWHMM7bc5zisrT1XO+xKSFNDdurZLRgBH5vU6CW2PUF5+g d7iz+sTXF7+lrIyYTS2rI1bfRtUJAGJ3KBTSCQOFNuJQU6nt7Myd37PBc3Xn7NMmIm9T9 Rf35pEp+kk7nlWATV1/BN90C6nzqbKzN1TE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1674149769281100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently BdsEntry caches BootNext before calling PlatformBootManagerLib APIs, with the result that: - If BootNext is already set, a BootNext value written by the APIs will be ignored and deleted, and the current boot will use the cached BootNext value. - If BootNext is not present, a BootNext value written by the APIs will have no effect on the current boot, but will be used by the next boot. This patch adds PcdAllowBootNextFromPlatformBootManagerLib so that a platform can enable PlatformBootManagerLib API calls to set BootNext to control the current boot. - If the PCD is FALSE (default), there is no change. - If the PCD is TRUE, then a BootNext value written by the PlatformBootManagerLib APIs will affect the current boot. Signed-off-by: Jeshua Smith --- MdeModulePkg/MdeModulePkg.dec | 7 +++++ MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 27 ++++++++++--------- MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 34 ++++++++++++++++++------ 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 9605c617b7..0e74131712 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1093,6 +1093,13 @@ # @Prompt Enable UEFI Stack Guard. gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055 =20 + ## Indicates whether PlatformBootManagerLib code can set BootNext for th= e current boot. + # If enabled, setting BootNext in PlatformBootManagerLib controls the c= urrent boot.

+ # TRUE - BootNext value from PlatformBootManagerLib will affect the c= urrent boot.
+ # FALSE - BootNext value from PlatformBootManagerLib will affect the s= ubsequent boot (or be ignored if already set).
+ # @Prompt Allow PlatformBootManagerLib to set BootNext for the current b= oot. + gEfiMdeModulePkgTokenSpaceGuid.PcdAllowBootNextFromPlatformBootManagerLi= b|FALSE|BOOLEAN|0x30001056 + [PcdsFixedAtBuild, PcdsPatchableInModule] ## Dynamic type PCD can be registered callback function for Pcd setting = action. # PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of= callback function diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf b/MdeModulePkg/Univer= sal/BdsDxe/BdsDxe.inf index 5bac635def..b7a3560f5f 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf +++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf @@ -85,19 +85,20 @@ gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ## CONSU= MES =20 [Pcd] - gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangCodes ## C= ONSUMES - gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLang ## S= OMETIMES_CONSUMES - gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLangCodes ## C= ONSUMES - gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang ## C= ONSUMES - gEfiMdePkgTokenSpaceGuid.PcdHardwareErrorRecordLevel ## C= ONSUMES - gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut ## C= ONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor ## C= ONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision ## C= ONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ## C= ONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## S= OMETIMES_CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## C= ONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleOnDiskSupport ## C= ONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformRecoverySupport ## C= ONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangCodes = ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLang = ## SOMETIMES_CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLangCodes = ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang = ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdHardwareErrorRecordLevel = ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable = ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleOnDiskSupport = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformRecoverySupport = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdAllowBootNextFromPlatformBootManagerLi= b ## CONSUMES =20 [Depex] TRUE diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Univer= sal/BdsDxe/BdsEntry.c index 766dde3aae..6450406cce 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -787,15 +787,19 @@ BdsEntry ( =20 // // Cache the "BootNext" NV variable before calling any PlatformBootManag= erLib APIs - // This could avoid the "BootNext" set by PlatformBootManagerLib be cons= umed in this boot. - // - GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **)&BootNext, = &DataSize); - if (DataSize !=3D sizeof (UINT16)) { - if (BootNext !=3D NULL) { - FreePool (BootNext); - } + // if the Platform isn't allowed to override BootNext. + // If "BootNext" was already set, a "BootNext" value set in PlatformBoot= ManagerLib APIs + // will be ignored; otherwise it will not take effect until the next boo= t. + // + if (!PcdGetBool (PcdAllowBootNextFromPlatformBootManagerLib)) { + GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **)&BootNext= , &DataSize); + if (DataSize !=3D sizeof (UINT16)) { + if (BootNext !=3D NULL) { + FreePool (BootNext); + } =20 - BootNext =3D NULL; + BootNext =3D NULL; + } } =20 // @@ -1048,6 +1052,20 @@ BdsEntry ( =20 EfiBootManagerHotkeyBoot (); =20 + // + // If PlatformBootManagerLib APIs are allowed to override BootNext, re= ad it just before use + // + if (PcdGetBool (PcdAllowBootNextFromPlatformBootManagerLib)) { + GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **)&BootNe= xt, &DataSize); + if (DataSize !=3D sizeof (UINT16)) { + if (BootNext !=3D NULL) { + FreePool (BootNext); + } + + BootNext =3D NULL; + } + } + if (BootNext !=3D NULL) { // // Delete "BootNext" NV variable before transferring control to it t= o prevent loops. --=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 (#98905): https://edk2.groups.io/g/devel/message/98905 Mute This Topic: https://groups.io/mt/96382214/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-