From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 910DC8036B for ; Tue, 14 Mar 2017 07:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489501753; x=1521037753; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=sFcXinFabVa1fQNsnobKg9D1nrcHNlPpu/Y54JKSoEI=; b=kXh1Ne9UNwF/yS/kIZ+waAExRMuf9gtAiMA7cfxuuYdo/H61NsniaTF3 c0avcPdse+cAiHyFTje3tDNtnz8Pkw==; Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Mar 2017 07:29:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,164,1486454400"; d="scan'208";a="75273870" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga005.jf.intel.com with ESMTP; 14 Mar 2017 07:29:13 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 14 Mar 2017 07:29:12 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.132]) with mapi id 14.03.0248.002; Tue, 14 Mar 2017 22:29:10 +0800 From: "Gao, Liming" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , "Tian, Feng" Thread-Topic: [PATCH] MdeModulePkg PCD: Allow SkuId to be changed only once Thread-Index: AQHSnLpLFsDqOQyG7k6wY/agKCg2m6GUZTew Date: Tue, 14 Mar 2017 14:29:09 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D6EFAFE@shsmsx102.ccr.corp.intel.com> References: <1489492688-95040-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1489492688-95040-1-git-send-email-star.zeng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg PCD: Allow SkuId to be changed only once X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Mar 2017 14:29:13 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Zeng, Star > Sent: Tuesday, March 14, 2017 7:58 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Gao, Liming ;= Kinney, Michael D ; Tian, > Feng > Subject: [PATCH] MdeModulePkg PCD: Allow SkuId to be changed only once >=20 > Current PI spec has no clear description about whether the > SkuId could be changed multiple times or not during one boot. >=20 > If the SkuId could be changed multiple times during one boot, > different modules may get inconsistent PCD values. > And DynamicHii PCD maps to UEFI variable, once one DynamicHii > PCD(UEFI variable) is set for one SkuId, then the PCD value > will be always from UEFI variable but not PCD database, even > the SkuId is set to other value. >=20 > This patch is to update PCD drivers to allow SkuId to be > changed only once during one boot. >=20 > Cc: Liming Gao > Cc: Michael Kinney > Cc: Feng Tian > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Star Zeng > --- > MdeModulePkg/Universal/PCD/Dxe/Pcd.c | 27 +++++++++++++++++++++++---- > MdeModulePkg/Universal/PCD/Pei/Pcd.c | 28 ++++++++++++++++++++++++---- > 2 files changed, 47 insertions(+), 8 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c b/MdeModulePkg/Universa= l/PCD/Dxe/Pcd.c > index 1bb9098c04cf..9d710bbf1fb7 100644 > --- a/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > +++ b/MdeModulePkg/Universal/PCD/Dxe/Pcd.c > @@ -3,7 +3,7 @@ > produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL= defined in > PI 1.4a Vol3. >=20 > -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D License > which accompanies this distribution. The full text of the license may b= e found at > @@ -272,19 +272,38 @@ DxePcdSetSku ( > SKU_ID *SkuIdTable; > UINTN Index; >=20 > + if (SkuId =3D=3D mPcdDatabase.DxeDb->SystemSkuId) { > + // > + // The input SKU Id is equal to current SKU Id, return directly. > + // > + return; > + } > + > + if (mPcdDatabase.DxeDb->SystemSkuId !=3D (SKU_ID) 0) { > + DEBUG ((DEBUG_ERROR, "PcdDxe - The SKU Id could be changed only once= .")); > + DEBUG (( > + DEBUG_ERROR, > + "PcdDxe - The SKU Id was set to 0x%lx already, it could not be set= to 0x%lx any more.", > + mPcdDatabase.DxeDb->SystemSkuId, > + (SKU_ID) SkuId > + )); > + ASSERT (FALSE); > + return; > + } > + > SkuIdTable =3D (SKU_ID *) ((UINT8 *) mPcdDatabase.DxeDb + mPcdDatabase= .DxeDb->SkuIdTableOffset); > for (Index =3D 0; Index < SkuIdTable[0]; Index++) { > if (SkuId =3D=3D SkuIdTable[Index + 1]) { > + DEBUG ((EFI_D_INFO, "PcdDxe - Set current SKU Id to 0x%lx.\n", (SK= U_ID) SkuId)); > mPcdDatabase.DxeDb->SystemSkuId =3D (SKU_ID) SkuId; > return; > } > } >=20 > // > - // Invalid input SkuId, the default SKU Id will be used for the system= . > + // Invalid input SkuId, the default SKU Id will be still used for the = system. > // > - DEBUG ((EFI_D_INFO, "PcdDxe - Invalid input SkuId, the default SKU Id = will be used.\n")); > - mPcdDatabase.DxeDb->SystemSkuId =3D (SKU_ID) 0; > + DEBUG ((EFI_D_INFO, "PcdDxe - Invalid input SkuId, the default SKU Id = will be still used.\n")); > return; > } >=20 > diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c b/MdeModulePkg/Universa= l/PCD/Pei/Pcd.c > index 668860b61c6c..a3f7337ceca3 100644 > --- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c > +++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c > @@ -1,7 +1,7 @@ > /** @file > All Pcd Ppi services are implemented here. >=20 > -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
> (C) Copyright 2016 Hewlett Packard Enterprise Development LP
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D License > @@ -262,19 +262,39 @@ PeiPcdSetSku ( > UINTN Index; >=20 > PeiPcdDb =3D GetPcdDatabase(); > + > + if (SkuId =3D=3D PeiPcdDb->SystemSkuId) { > + // > + // The input SKU Id is equal to current SKU Id, return directly. > + // > + return; > + } > + > + if (PeiPcdDb->SystemSkuId !=3D (SKU_ID) 0) { > + DEBUG ((DEBUG_ERROR, "PcdPei - The SKU Id could be changed only once= .")); > + DEBUG (( > + DEBUG_ERROR, > + "PcdPei - The SKU Id was set to 0x%lx already, it could not be set= to 0x%lx any more.", > + PeiPcdDb->SystemSkuId, > + (SKU_ID) SkuId > + )); > + ASSERT (FALSE); > + return; > + } > + > SkuIdTable =3D (SKU_ID *) ((UINT8 *) PeiPcdDb + PeiPcdDb->SkuIdTableOf= fset); > for (Index =3D 0; Index < SkuIdTable[0]; Index++) { > if (SkuId =3D=3D SkuIdTable[Index + 1]) { > + DEBUG ((EFI_D_INFO, "PcdPei - Set current SKU Id to 0x%lx.\n", (SK= U_ID) SkuId)); > PeiPcdDb->SystemSkuId =3D (SKU_ID) SkuId; > return; > } > } >=20 > // > - // Invalid input SkuId, the default SKU Id will be used for the system= . > + // Invalid input SkuId, the default SKU Id will be still used for the = system. > // > - DEBUG ((EFI_D_INFO, "PcdPei - Invalid input SkuId, the default SKU Id = will be used.\n")); > - PeiPcdDb->SystemSkuId =3D (SKU_ID) 0; > + DEBUG ((EFI_D_INFO, "PcdPei - Invalid input SkuId, the default SKU Id = will be still used.\n")); > return; > } >=20 > -- > 2.7.0.windows.1