From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.26499.1678727912836852482 for ; Mon, 13 Mar 2023 10:18:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i0FjRGSp; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5DFF861314; Mon, 13 Mar 2023 17:18:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B26AC4339C; Mon, 13 Mar 2023 17:18:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678727911; bh=6790+lqVlVs4ziQGuztqY8DyefwYLbjK8B1C3CdUw1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i0FjRGSpZ9Urj6JKbeXXqzHij+E18MCiiZ7/3uzkXpl+ANrr83AThdPFDZvJYsf7F syGjLZdyAsDhUujGYw8czTwB65UiyjUbU3gujpWF6LJUdk7jq+f3sCCeuTJ2VrcfMO 2qwJ6/5OZPUF/hqlCB3dCy5Fxa9NBLZ9BBUmdZRTZfQM8MzGQ64hd4acnJ/alXcNCq DdUiG9BWYd13dU389RslXsZbkMBMHvfazIMwFZBpRqJhDPGWeAqXfmNY1Q7nu4s6jt QHIzxYkYkbynj80yxkIQk860nHwBAo85dgGeKtUI+/sA7oXLPhUxJ/rZeh+onpJe29 NeqXz9tjPrtSg== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Leif Lindholm , Sami Mujawar , Taylor Beebe Subject: [PATCH v5 22/38] MdeModulePkg/PcdPeim: Permit unshadowed execution Date: Mon, 13 Mar 2023 18:16:58 +0100 Message-Id: <20230313171714.3866151-23-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313171714.3866151-1-ardb@kernel.org> References: <20230313171714.3866151-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable PEIM shadowing is optional, but the PCD PEIM does so explicitly, seemingly without a functional need. So make this behavior dependent on the existing PCD, which is generally (and by default) set to TRUE, whereas some systems (such as ARM virtual machines) may prefer to disable shadowing. Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Universal/PCD/Pei/Pcd.c | 112 ++++++++++---------- MdeModulePkg/Universal/PCD/Pei/Pcd.inf | 1 + 2 files changed, 58 insertions(+), 55 deletions(-) diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c b/MdeModulePkg/Universal/= PCD/Pei/Pcd.c index c51ac96a32e3..632254f1c5fa 100644 --- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c +++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c @@ -346,73 +346,75 @@ PcdPeimInit ( {=0D EFI_STATUS Status;=0D =0D - Status =3D PeiServicesRegisterForShadow (FileHandle);=0D - if (Status =3D=3D EFI_ALREADY_STARTED) {=0D - //=0D - // This is now starting in memory, the second time starting.=0D - //=0D - EFI_PEI_PPI_DESCRIPTOR *OldPpiList;=0D - EFI_PEI_PPI_DESCRIPTOR *OldPpiList2;=0D - VOID *Ppi;=0D - VOID *Ppi2;=0D + if (PcdGetBool (PcdShadowPeimOnBoot)) {=0D + Status =3D PeiServicesRegisterForShadow (FileHandle);=0D + if (Status =3D=3D EFI_ALREADY_STARTED) {=0D + //=0D + // This is now starting in memory, the second time starting.=0D + //=0D + EFI_PEI_PPI_DESCRIPTOR *OldPpiList;=0D + EFI_PEI_PPI_DESCRIPTOR *OldPpiList2;=0D + VOID *Ppi;=0D + VOID *Ppi2;=0D =0D - OldPpiList =3D NULL;=0D - Status =3D PeiServicesLocatePpi (=0D - &gPcdPpiGuid,=0D - 0,=0D - &OldPpiList,=0D - &Ppi=0D - );=0D - ASSERT_EFI_ERROR (Status);=0D -=0D - if (OldPpiList !=3D NULL) {=0D - Status =3D PeiServicesReInstallPpi (OldPpiList, &mPpiList[0]);=0D + OldPpiList =3D NULL;=0D + Status =3D PeiServicesLocatePpi (=0D + &gPcdPpiGuid,=0D + 0,=0D + &OldPpiList,=0D + &Ppi=0D + );=0D ASSERT_EFI_ERROR (Status);=0D - }=0D =0D - OldPpiList2 =3D NULL;=0D - Status =3D PeiServicesLocatePpi (=0D - &gGetPcdInfoPpiGuid,=0D - 0,=0D - &OldPpiList2,=0D - &Ppi2=0D - );=0D - ASSERT_EFI_ERROR (Status);=0D + if (OldPpiList !=3D NULL) {=0D + Status =3D PeiServicesReInstallPpi (OldPpiList, &mPpiList[0]);=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D =0D - if (OldPpiList2 !=3D NULL) {=0D - Status =3D PeiServicesReInstallPpi (OldPpiList2, &mPpiList2[0]);=0D + OldPpiList2 =3D NULL;=0D + Status =3D PeiServicesLocatePpi (=0D + &gGetPcdInfoPpiGuid,=0D + 0,=0D + &OldPpiList2,=0D + &Ppi2=0D + );=0D ASSERT_EFI_ERROR (Status);=0D - }=0D =0D - OldPpiList =3D NULL;=0D - Status =3D PeiServicesLocatePpi (=0D - &gEfiPeiPcdPpiGuid,=0D - 0,=0D - &OldPpiList,=0D - &Ppi=0D - );=0D - ASSERT_EFI_ERROR (Status);=0D + if (OldPpiList2 !=3D NULL) {=0D + Status =3D PeiServicesReInstallPpi (OldPpiList2, &mPpiList2[0]);=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D =0D - if (OldPpiList !=3D NULL) {=0D - Status =3D PeiServicesReInstallPpi (OldPpiList, &mPpiList[1]);=0D + OldPpiList =3D NULL;=0D + Status =3D PeiServicesLocatePpi (=0D + &gEfiPeiPcdPpiGuid,=0D + 0,=0D + &OldPpiList,=0D + &Ppi=0D + );=0D ASSERT_EFI_ERROR (Status);=0D - }=0D =0D - OldPpiList2 =3D NULL;=0D - Status =3D PeiServicesLocatePpi (=0D - &gEfiGetPcdInfoPpiGuid,=0D - 0,=0D - &OldPpiList2,=0D - &Ppi2=0D - );=0D - ASSERT_EFI_ERROR (Status);=0D + if (OldPpiList !=3D NULL) {=0D + Status =3D PeiServicesReInstallPpi (OldPpiList, &mPpiList[1]);=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D =0D - if (OldPpiList2 !=3D NULL) {=0D - Status =3D PeiServicesReInstallPpi (OldPpiList2, &mPpiList2[1]);=0D + OldPpiList2 =3D NULL;=0D + Status =3D PeiServicesLocatePpi (=0D + &gEfiGetPcdInfoPpiGuid,=0D + 0,=0D + &OldPpiList2,=0D + &Ppi2=0D + );=0D ASSERT_EFI_ERROR (Status);=0D - }=0D =0D - return Status;=0D + if (OldPpiList2 !=3D NULL) {=0D + Status =3D PeiServicesReInstallPpi (OldPpiList2, &mPpiList2[1]);=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D +=0D + return Status;=0D + }=0D }=0D =0D BuildPcdDatabase (FileHandle);=0D diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.inf b/MdeModulePkg/Universa= l/PCD/Pei/Pcd.inf index 7152a7d53b7d..a820ace70ec2 100644 --- a/MdeModulePkg/Universal/PCD/Pei/Pcd.inf +++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.inf @@ -343,6 +343,7 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPcdCallBackNumberPerPcdEntry ## = SOMETIMES_CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdNvStoreDefaultValueBuffer ## SOMETIMES= _CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdSetNvStoreDefaultId ## CONSUMES= =0D + gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot ## CONSUMES= =0D =0D [Depex]=0D TRUE=0D --=20 2.39.2