Re: [edk2-devel] [PATCH v2 2/6] AlderlakeOpenBoardPkg: Add modules

2023-08-04 Thread Chuang, Rosen
Reviewed-by: Rosen Chuang < rosen.chu...@intel.com>


-Original Message-
From: Kasbekar, Saloni  
Sent: Wednesday, August 2, 2023 6:18 AM
To: devel@edk2.groups.io
Cc: Kasbekar, Saloni ; Chaganty, Rangasai V 
; Desimone, Nathaniel L 
; Oram, Isaac W ; 
Chuang, Rosen 
Subject: [PATCH v2 2/6] AlderlakeOpenBoardPkg: Add modules

Adds the following modules:
-BiosInfo
-OpenBoardPlatformInit
-SBCVpdStructurePcd

Cc: Sai Chaganty 
Cc: Nate DeSimone 
Cc: Isaac Oram 
Cc: Rosen Chuang 
Signed-off-by: Saloni Kasbekar 
---
 .../AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c | 196 +++
 .../BiosInfo/BiosInfo.inf |  84 +++
 .../OpenBoardPlatformInitPostMem.c| 233 ++
 .../OpenBoardPlatformInitPostMem.inf  |  75 ++
 .../SBCVpdStructurePcd/AllStructPCD.dsc   |  19 ++
 .../GpioTableAdlPPostMem.dsc  |  40 +++
 .../GpioTableAdlPPreMem.dsc   |  29 +++
 .../MrcDqDqsSPD/AdlPSpdMap.dsc| 138 +++
 .../PcieClocks/AdlPPcieClocks.dsc |  31 +++
 9 files changed, 845 insertions(+)
 create mode 100644 Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c
 create mode 100644 Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.inf
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/OpenBoardPlatformInit/OpenBoardPlatformInitPei/OpenBoardPlatformInitPostMem.c
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/OpenBoardPlatformInit/OpenBoardPlatformInitPei/OpenBoardPlatformInitPostMem.inf
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/AllStructPCD.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/GpioTableAdlPPostMem.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/GpioTableAdlPPreMem.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/MrcDqDqsSPD/AdlPSpdMap.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/PcieClocks/AdlPPcieClocks.dsc

diff --git a/Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c 
b/Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c
new file mode 100644
index 00..64462900de
--- /dev/null
+++ b/Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c
@@ -0,0 +1,196 @@
+/** @file
+  PEIM to provide BiosInfo structure listing up all firmware volume's 
+base addresses, sizes,
+  attributes, and information associated to the firmware volume.
+  Primarily the structure is used on FIT table creation and Bpm.
+
+   Copyright (c) 2022, Intel Corporation. All rights reserved.
+   SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define BASE_FV_SIZE 10
+
+#define FSP_WRAPPER_FV_SIZE 3
+
+#define TSN_MAC_ADDRESS_FV_SIZE 0
+
+#define BIOS_INFO_STRUCT_SIZE (BASE_FV_SIZE + FSP_WRAPPER_FV_SIZE + 
+TSN_MAC_ADDRESS_FV_SIZE)
+
+
+/*
+  BIOS_INFO structure is the base of the firmware volume layout for 
+Intel platform BIOS implementation
+  so security checker module can run based on the structure and throw 
+warnings, error or deadloop
+  when any unexpected firmware volumes are detected.
+
+  BIOS_INFO is recommended to support full entries of firmware volumes 
+present in a flash
+  with right type, attribute, version, flash map base address and size,
+  all associated information which is defined by BIOS_INFO_STRUCT structure.
+  - IBB firmware volumes, which are expected to be measured or/and verified
+by hardware base security solution to meet SecureBoot chain of trust
+(Intel BootGuard for example), have attribute 0x0.
+  - Post IBB firmware volumes, which are expected to be measured or/and 
verified
+by BIOS (TCG code for measurement, RSA2048SHA256Sign algorithm for 
verification for example),
+have attribute BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB.
+  - Else, follows Firmware Interface Table specification.
+*/
+#pragma pack (1)
+typedef struct {
+  BIOS_INFO_HEADER  Header;
+  BIOS_INFO_STRUCT  Entry[BIOS_INFO_STRUCT_SIZE]; } BIOS_INFO; #pragma 
+pack ()
+
+GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
+  {
+BIOS_INFO_SIGNATURE,
+BIOS_INFO_STRUCT_SIZE,
+0,
+  },
+  {
+{
+  FIT_TYPE_07_BIOS_STARTUP_MODULE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT,
+  0x0100,
+  FixedPcdGet32 (PcdFlashNvStorageVariableSize) + FixedPcdGet32 
(PcdFlashNvStorageFtwWorkingSize) + FixedPcdGet32 
(PcdFlashNvStorageFtwSpareSize),
+  FixedPcdGet32 (PcdFlashNvStorageVariableBase)
+},
+{
+  FIT_TYPE_07_BIOS_STARTUP_MODULE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+  0x0100,
+  FixedPcdGet32 (PcdFlashFvAdvancedSize),
+  FixedPcdGet32 (PcdFlashFvAdvancedBase)
+},
+{
+  FIT_TYPE_07_BIOS_STARTUP_MODULE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+  0x0100,
+  FixedPcdGet32 

Re: [edk2-devel] [PATCH v2 2/6] AlderlakeOpenBoardPkg: Add modules

2023-08-02 Thread Chaganty, Rangasai V
Reviewed-by: Sai Chaganty 

-Original Message-
From: Kasbekar, Saloni  
Sent: Tuesday, August 01, 2023 3:18 PM
To: devel@edk2.groups.io
Cc: Kasbekar, Saloni ; Chaganty, Rangasai V 
; Desimone, Nathaniel L 
; Oram, Isaac W ; 
Chuang, Rosen 
Subject: [PATCH v2 2/6] AlderlakeOpenBoardPkg: Add modules

Adds the following modules:
-BiosInfo
-OpenBoardPlatformInit
-SBCVpdStructurePcd

Cc: Sai Chaganty 
Cc: Nate DeSimone 
Cc: Isaac Oram 
Cc: Rosen Chuang 
Signed-off-by: Saloni Kasbekar 
---
 .../AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c | 196 +++
 .../BiosInfo/BiosInfo.inf |  84 +++
 .../OpenBoardPlatformInitPostMem.c| 233 ++
 .../OpenBoardPlatformInitPostMem.inf  |  75 ++
 .../SBCVpdStructurePcd/AllStructPCD.dsc   |  19 ++
 .../GpioTableAdlPPostMem.dsc  |  40 +++
 .../GpioTableAdlPPreMem.dsc   |  29 +++
 .../MrcDqDqsSPD/AdlPSpdMap.dsc| 138 +++
 .../PcieClocks/AdlPPcieClocks.dsc |  31 +++
 9 files changed, 845 insertions(+)
 create mode 100644 Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c
 create mode 100644 Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.inf
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/OpenBoardPlatformInit/OpenBoardPlatformInitPei/OpenBoardPlatformInitPostMem.c
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/OpenBoardPlatformInit/OpenBoardPlatformInitPei/OpenBoardPlatformInitPostMem.inf
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/AllStructPCD.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/GpioTableAdlPPostMem.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/GpioTableAdlPPreMem.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/MrcDqDqsSPD/AdlPSpdMap.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/PcieClocks/AdlPPcieClocks.dsc

diff --git a/Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c 
b/Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c
new file mode 100644
index 00..64462900de
--- /dev/null
+++ b/Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c
@@ -0,0 +1,196 @@
+/** @file
+  PEIM to provide BiosInfo structure listing up all firmware volume's 
+base addresses, sizes,
+  attributes, and information associated to the firmware volume.
+  Primarily the structure is used on FIT table creation and Bpm.
+
+   Copyright (c) 2022, Intel Corporation. All rights reserved.
+   SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define BASE_FV_SIZE 10
+
+#define FSP_WRAPPER_FV_SIZE 3
+
+#define TSN_MAC_ADDRESS_FV_SIZE 0
+
+#define BIOS_INFO_STRUCT_SIZE (BASE_FV_SIZE + FSP_WRAPPER_FV_SIZE + 
+TSN_MAC_ADDRESS_FV_SIZE)
+
+
+/*
+  BIOS_INFO structure is the base of the firmware volume layout for 
+Intel platform BIOS implementation
+  so security checker module can run based on the structure and throw 
+warnings, error or deadloop
+  when any unexpected firmware volumes are detected.
+
+  BIOS_INFO is recommended to support full entries of firmware volumes 
+present in a flash
+  with right type, attribute, version, flash map base address and size,
+  all associated information which is defined by BIOS_INFO_STRUCT structure.
+  - IBB firmware volumes, which are expected to be measured or/and verified
+by hardware base security solution to meet SecureBoot chain of trust
+(Intel BootGuard for example), have attribute 0x0.
+  - Post IBB firmware volumes, which are expected to be measured or/and 
verified
+by BIOS (TCG code for measurement, RSA2048SHA256Sign algorithm for 
verification for example),
+have attribute BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB.
+  - Else, follows Firmware Interface Table specification.
+*/
+#pragma pack (1)
+typedef struct {
+  BIOS_INFO_HEADER  Header;
+  BIOS_INFO_STRUCT  Entry[BIOS_INFO_STRUCT_SIZE]; } BIOS_INFO; #pragma 
+pack ()
+
+GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
+  {
+BIOS_INFO_SIGNATURE,
+BIOS_INFO_STRUCT_SIZE,
+0,
+  },
+  {
+{
+  FIT_TYPE_07_BIOS_STARTUP_MODULE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT,
+  0x0100,
+  FixedPcdGet32 (PcdFlashNvStorageVariableSize) + FixedPcdGet32 
(PcdFlashNvStorageFtwWorkingSize) + FixedPcdGet32 
(PcdFlashNvStorageFtwSpareSize),
+  FixedPcdGet32 (PcdFlashNvStorageVariableBase)
+},
+{
+  FIT_TYPE_07_BIOS_STARTUP_MODULE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+  0x0100,
+  FixedPcdGet32 (PcdFlashFvAdvancedSize),
+  FixedPcdGet32 (PcdFlashFvAdvancedBase)
+},
+{
+  FIT_TYPE_07_BIOS_STARTUP_MODULE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+  0x0100,
+  FixedPcdGet32 (PcdFlashFvOptionalSize),
+  

[edk2-devel] [PATCH v2 2/6] AlderlakeOpenBoardPkg: Add modules

2023-08-01 Thread Saloni Kasbekar
Adds the following modules:
-BiosInfo
-OpenBoardPlatformInit
-SBCVpdStructurePcd

Cc: Sai Chaganty 
Cc: Nate DeSimone 
Cc: Isaac Oram 
Cc: Rosen Chuang 
Signed-off-by: Saloni Kasbekar 
---
 .../AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c | 196 +++
 .../BiosInfo/BiosInfo.inf |  84 +++
 .../OpenBoardPlatformInitPostMem.c| 233 ++
 .../OpenBoardPlatformInitPostMem.inf  |  75 ++
 .../SBCVpdStructurePcd/AllStructPCD.dsc   |  19 ++
 .../GpioTableAdlPPostMem.dsc  |  40 +++
 .../GpioTableAdlPPreMem.dsc   |  29 +++
 .../MrcDqDqsSPD/AdlPSpdMap.dsc| 138 +++
 .../PcieClocks/AdlPPcieClocks.dsc |  31 +++
 9 files changed, 845 insertions(+)
 create mode 100644 Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c
 create mode 100644 Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.inf
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/OpenBoardPlatformInit/OpenBoardPlatformInitPei/OpenBoardPlatformInitPostMem.c
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/OpenBoardPlatformInit/OpenBoardPlatformInitPei/OpenBoardPlatformInitPostMem.inf
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/AllStructPCD.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/GpioTableAdlPPostMem.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/GpioTableAdlPPreMem.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/MrcDqDqsSPD/AdlPSpdMap.dsc
 create mode 100644 
Platform/Intel/AlderlakeOpenBoardPkg/SBCVpdStructurePcd/PcieClocks/AdlPPcieClocks.dsc

diff --git a/Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c 
b/Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c
new file mode 100644
index 00..64462900de
--- /dev/null
+++ b/Platform/Intel/AlderlakeOpenBoardPkg/BiosInfo/BiosInfo.c
@@ -0,0 +1,196 @@
+/** @file
+  PEIM to provide BiosInfo structure listing up all firmware volume's base 
addresses, sizes,
+  attributes, and information associated to the firmware volume.
+  Primarily the structure is used on FIT table creation and Bpm.
+
+   Copyright (c) 2022, Intel Corporation. All rights reserved.
+   SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define BASE_FV_SIZE 10
+
+#define FSP_WRAPPER_FV_SIZE 3
+
+#define TSN_MAC_ADDRESS_FV_SIZE 0
+
+#define BIOS_INFO_STRUCT_SIZE (BASE_FV_SIZE + FSP_WRAPPER_FV_SIZE + 
TSN_MAC_ADDRESS_FV_SIZE)
+
+
+/*
+  BIOS_INFO structure is the base of the firmware volume layout for Intel 
platform BIOS implementation
+  so security checker module can run based on the structure and throw 
warnings, error or deadloop
+  when any unexpected firmware volumes are detected.
+
+  BIOS_INFO is recommended to support full entries of firmware volumes present 
in a flash
+  with right type, attribute, version, flash map base address and size,
+  all associated information which is defined by BIOS_INFO_STRUCT structure.
+  - IBB firmware volumes, which are expected to be measured or/and verified
+by hardware base security solution to meet SecureBoot chain of trust
+(Intel BootGuard for example), have attribute 0x0.
+  - Post IBB firmware volumes, which are expected to be measured or/and 
verified
+by BIOS (TCG code for measurement, RSA2048SHA256Sign algorithm for 
verification for example),
+have attribute BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB.
+  - Else, follows Firmware Interface Table specification.
+*/
+#pragma pack (1)
+typedef struct {
+  BIOS_INFO_HEADER  Header;
+  BIOS_INFO_STRUCT  Entry[BIOS_INFO_STRUCT_SIZE];
+} BIOS_INFO;
+#pragma pack ()
+
+GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
+  {
+BIOS_INFO_SIGNATURE,
+BIOS_INFO_STRUCT_SIZE,
+0,
+  },
+  {
+{
+  FIT_TYPE_07_BIOS_STARTUP_MODULE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT,
+  0x0100,
+  FixedPcdGet32 (PcdFlashNvStorageVariableSize) + FixedPcdGet32 
(PcdFlashNvStorageFtwWorkingSize) + FixedPcdGet32 
(PcdFlashNvStorageFtwSpareSize),
+  FixedPcdGet32 (PcdFlashNvStorageVariableBase)
+},
+{
+  FIT_TYPE_07_BIOS_STARTUP_MODULE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+  0x0100,
+  FixedPcdGet32 (PcdFlashFvAdvancedSize),
+  FixedPcdGet32 (PcdFlashFvAdvancedBase)
+},
+{
+  FIT_TYPE_07_BIOS_STARTUP_MODULE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+  0x0100,
+  FixedPcdGet32 (PcdFlashFvOptionalSize),
+  FixedPcdGet32 (PcdFlashFvOptionalBase)
+},
+{
+  FIT_TYPE_07_BIOS_STARTUP_MODULE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
+  0x0100,
+  FixedPcdGet32 (PcdFlashFvSecuritySize),
+  FixedPcdGet32 (PcdFlashFvSecurityBase)
+},
+{
+  FIT_TYPE_07_BIOS_STARTUP_MODULE,
+