Date   

Re: [PATCH V2 1/3] UefiCpuPkg/SmmCpuFeaturesLib: Rename the common C file

Chang, Abner
 

[AMD Official Use Only - General]

Thanks for catching this!. V3 patch sent.

Abner

-----Original Message-----
From: Ni, Ray <ray.ni@...>
Sent: Monday, October 31, 2022 9:59 AM
To: devel@edk2.groups.io; Chang, Abner <Abner.Chang@...>
Cc: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@...>;
Kirkendall, Garrett <Garrett.Kirkendall@...>; Grimes, Paul
<Paul.Grimes@...>; Dong, Eric <eric.dong@...>; Kumar, Rahul
R <rahul.r.kumar@...>
Subject: RE: [edk2-devel] [PATCH V2 1/3] UefiCpuPkg/SmmCpuFeaturesLib:
Rename the common C file

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


This patch will cause build failure because the INF file is not updated after
rename.

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang,
Abner via groups.io
Sent: Sunday, October 30, 2022 9:02 PM
To: devel@edk2.groups.io
Cc: Abdul Lateef Attar <abdattar@...>; Garrett Kirkendall
<garrett.kirkendall@...>; Paul Grimes <paul.grimes@...>;
Dong,
Eric <eric.dong@...>; Ni, Ray <ray.ni@...>; Kumar, Rahul R
<rahul.r.kumar@...>
Subject: [edk2-devel] [PATCH V2 1/3] UefiCpuPkg/SmmCpuFeaturesLib:
Rename the common C file

From: Abner Chang <abner.chang@...>

BZ# 4093: Abstract SmmCpuFeaturesLib for sharing common code

Rename SmmCpuFeaturesLiCommon.c to
IntelSmmCpuFeaturesLib, because it was developed specifically for
Intel implementation. The code that can be shared by other archs or
vendors will be stripped away and put in the common file in the next
patch.

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Abdul Lateef Attar <abdattar@...>
Cc: Garrett Kirkendall <garrett.kirkendall@...>
Cc: Paul Grimes <paul.grimes@...>
Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rahul Kumar <rahul1.kumar@...>
---
.../{SmmCpuFeaturesLibCommon.c => IntelSmmCpuFeaturesLib.c} | 0
1 file changed, 0 insertions(+), 0 deletions(-) rename
UefiCpuPkg/Library/SmmCpuFeaturesLib/{SmmCpuFeaturesLibCommon.c
=>
IntelSmmCpuFeaturesLib.c} (100%)

diff --git
a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
similarity index 100%
rename from
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c
rename to
UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
--
2.37.1.windows.1





Re: [PATCH v2] MdeModulePkg/ScsiDiskDxe: Update proper device name for ScsiDisk drive

Wu, Hao A
 

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu, Hao A
Sent: Friday, October 28, 2022 10:26 AM
To: devel@edk2.groups.io; gopic@...
Cc: Selvaraj, Sundaresan <sundaresans@...>; Sambandan, Vasudevan
<vasudevans@...>
Subject: Re: [edk2-devel] [PATCH v2] MdeModulePkg/ScsiDiskDxe: Update
proper device name for ScsiDisk drive

Thanks.
Reviewed-by: Hao A Wu <hao.a.wu@...>

Will wait a couple of days before merging to see if comments from other
reviewers.

Best Regards,
Hao Wu

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
Cheripally Gopi via groups.io
Sent: Thursday, October 27, 2022 3:07 PM
To: devel@edk2.groups.io
Cc: Selvaraj, Sundaresan <sundaresans@...>; Sambandan, Vasudevan
<vasudevans@...>; Cheripally Gopi <gopic@...>
Subject: [edk2-devel] [PATCH v2] MdeModulePkg/ScsiDiskDxe: Update
proper device name for ScsiDisk drive

ScsiDiskDxe driver updates ControllerNameTable with common string
"SCSI Disk Device" for all SCSI disks. Due to this, when multiple SCSI
disk devices connected, facing difficulty in identifying correct SCSI
disk device. As per SCSI spec, standard Inquiry Data is having the
fields to know Vendor and Product information. Updated
"ControllerNameTable" with Vendor and Product information. So that,
device specific name can be retrieved using ComponentName protocol.

Cc: Vasudevan Sambandan <vasudevans@...>
Cc: Sundaresan Selvaraj <sundaresans@...>
Signed-off-by: Cheripally Gopi <gopic@...>
---
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 53
++++++++++++++++++- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h | 9
++++
.../Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf | 2 +
3 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
index 98e84b4ea8..0928605dc4 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
@@ -2,6 +2,7 @@
SCSI disk driver that layers on every SCSI IO protocol in the system.



Copyright (c) 2006 - 2019, Intel Corporation. All rights
reserved.<BR>

+Copyright (c) 1985 - 2022, American Megatrends International LLC.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent



**/

@@ -67,6 +68,33 @@ FreeAlignedBuffer (
}

}



+/**

+ Remove trailing spaces from the string.

+

+ @param String The ASCII string to remove the trailing spaces.

+

+ @retval the new length of the string.

+**/

+UINTN

+RemoveTrailingSpaces (

+ IN OUT CHAR8 *String

+ )

+{

+ UINTN Length;

+

+ Length = AsciiStrLen (String);

+ if (Length == 0) {

+ return 0;

+ }

+

+ while ((Length > 0) && (String[Length-1] == ' ')) {

+ Length--;

+ }

+

+ String[Length] = '\0';

+ return Length;

+}

+

/**

The user Entry Point for module ScsiDisk.



@@ -203,6 +231,9 @@ ScsiDiskDriverBindingStart (
UINT8 MaxRetry;

BOOLEAN NeedRetry;

BOOLEAN MustReadCapacity;

+ CHAR8 VendorStr[VENDOR_IDENTIFICATION_LENGTH + 1];

+ CHAR8 ProductStr[PRODUCT_IDENTIFICATION_LENGTH + 1];

+ CHAR16 DeviceStr[VENDOR_IDENTIFICATION_LENGTH +
PRODUCT_IDENTIFICATION_LENGTH + 2];



MustReadCapacity = TRUE;



@@ -354,19 +385,37 @@ ScsiDiskDriverBindingStart (
}

}



+ CopyMem (

+ VendorStr,

+ &ScsiDiskDevice-
InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSET],
+ VENDOR_IDENTIFICATION_LENGTH

+ );

+ VendorStr[VENDOR_IDENTIFICATION_LENGTH] = 0;

+ RemoveTrailingSpaces (VendorStr);

+

+ CopyMem (

+ ProductStr,

+ &ScsiDiskDevice-
InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFSET],
+ PRODUCT_IDENTIFICATION_LENGTH

+ );

+ ProductStr[PRODUCT_IDENTIFICATION_LENGTH] = 0;

+ RemoveTrailingSpaces (ProductStr);

+

+ UnicodeSPrint (DeviceStr, sizeof (DeviceStr), L"%a %a",
+ VendorStr,
ProductStr);

+

ScsiDiskDevice->ControllerNameTable = NULL;

AddUnicodeString2 (

"eng",

gScsiDiskComponentName.SupportedLanguages,

&ScsiDiskDevice->ControllerNameTable,

- L"SCSI Disk Device",

+ DeviceStr,

TRUE

);

AddUnicodeString2 (

"en",

gScsiDiskComponentName2.SupportedLanguages,

&ScsiDiskDevice->ControllerNameTable,

- L"SCSI Disk Device",

+ DeviceStr,

FALSE

);

return EFI_SUCCESS;

diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
index d54282df5f..5b4047e1db 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
@@ -2,6 +2,7 @@
Header file for SCSI Disk Driver.



Copyright (c) 2004 - 2019, Intel Corporation. All rights
reserved.<BR>

+Copyright (c) 1985 - 2022, American Megatrends International LLC.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent



**/

@@ -30,6 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiScsiLib.h>

#include <Library/UefiBootServicesTableLib.h>

#include <Library/DevicePathLib.h>

+#include <Library/PrintLib.h>



#include <IndustryStandard/Scsi.h>

#include <IndustryStandard/Atapi.h>

@@ -179,6 +181,13 @@ extern EFI_COMPONENT_NAME2_PROTOCOL
gScsiDiskComponentName2; #define SCSI_COMMAND_VERSION_2 0x02

#define SCSI_COMMAND_VERSION_3 0x03



+// Per SCSI spec, EFI_SCSI_INQUIRY_DATA.Reserved_5_95[3 - 10] has the
Vendor identification

+// EFI_SCSI_INQUIRY_DATA.Reserved_5_95[11 - 26] has the product
identification

+#define VENDOR_IDENTIFICATION_OFFSET 3

+#define VENDOR_IDENTIFICATION_LENGTH 8

+#define PRODUCT_IDENTIFICATION_OFFSET 11

+#define PRODUCT_IDENTIFICATION_LENGTH 16

+

//

// SCSI Disk Timeout Experience Value

//

diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
index 40818e669b..26227132e8 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
@@ -4,6 +4,7 @@
# the device handle.

#

# Copyright (c) 2006 - 2019, Intel Corporation. All rights
reserved.<BR>

+# Copyright (c) 1985 - 2022, American Megatrends International
+LLC.<BR>

# SPDX-License-Identifier: BSD-2-Clause-Patent

#

##

@@ -46,6 +47,7 @@
UefiDriverEntryPoint

DebugLib

DevicePathLib

+ PrintLib



[Protocols]

gEfiDiskInfoProtocolGuid ## BY_START

--
2.33.0.windows.2
-The information contained in this message may be confidential and
proprietary to American Megatrends (AMI). This communication is
intended to be read only by the individual or entity to whom it is
addressed or by their designee. If the reader of this message is not
the intended recipient, you are on notice that any distribution of this message,
in any form, is strictly prohibited.
Please promptly notify the sender by reply e-mail or by telephone at
770-246- 8600, and then delete or destroy all copies of the transmission.







[PATCH V3 3/3] UefiCpuPkg/SmmCpuFeaturesLib: Clean up header file inclusion in SmmStm.c

Chang, Abner
 

From: Abner Chang <abner.chang@...>

BZ# 4093: Abstract SmmCpuFeaturesLib for sharing common code

Remove the header files those are already included in
CpuFeatureLib.h.

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Abdul Lateef Attar <abdattar@...>
Cc: Garrett Kirkendall <garrett.kirkendall@...>
Cc: Paul Grimes <paul.grimes@...>
Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rahul Kumar <rahul1.kumar@...>
---
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
index 4e8f897f5e9..3cf162ada01 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
@@ -7,11 +7,8 @@
**/

#include <PiMm.h>
-#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
#include <Library/HobLib.h>
-#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/SmmServicesTableLib.h>
#include <Library/TpmMeasurementLib.h>
--
2.37.1.windows.1


[PATCH V3 2/3] UefiCpuPkg/SmmCpuFeaturesLib: Abstract arch dependent code

Chang, Abner
 

From: Abner Chang <abner.chang@...>

BZ# 4093: Abstract SmmCpuFeaturesLib for sharing common code

This change stripped away the code that can be
shared with other archs or vendors from Intel
implementation and put in to the common file,
leaves the Intel X86 implementation in the
IntelSmmCpuFeatureLib. Also updates the header
file and INF file.

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Abdul Lateef Attar <abdattar@...>
Cc: Garrett Kirkendall <garrett.kirkendall@...>
Cc: Paul Grimes <paul.grimes@...>
Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rahul Kumar <rahul1.kumar@...>
---
.../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 1 +
.../SmmCpuFeaturesLibStm.inf | 1 +
.../StandaloneMmCpuFeaturesLib.inf | 1 +
.../SmmCpuFeaturesLib/CpuFeaturesLib.h | 6 +
.../IntelSmmCpuFeaturesLib.c | 206 +----------------
.../SmmCpuFeaturesLibCommon.c | 216 ++++++++++++++++++
6 files changed, 227 insertions(+), 204 deletions(-)
create mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
index 6254a14698a..9ac7dde78f8 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
@@ -20,6 +20,7 @@
CpuFeaturesLib.h
IntelSmmCpuFeaturesLib.c
SmmCpuFeaturesLib.c
+ SmmCpuFeaturesLibCommon.c
SmmCpuFeaturesLibNoStm.c
TraditionalMmCpuFeaturesLib.c

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
index d64d8e66b38..86d367e0a09 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
@@ -20,6 +20,7 @@
[Sources]
CpuFeaturesLib.h
IntelSmmCpuFeaturesLib.c
+ SmmCpuFeaturesLibCommon.c
SmmStm.c
SmmStm.h
TraditionalMmCpuFeaturesLib.c
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf
index 5935b3e1fd6..b1f60a55055 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf
@@ -21,6 +21,7 @@
[Sources]
CpuFeaturesLib.h
IntelSmmCpuFeaturesLib.c
+ SmmCpuFeaturesLibCommon.c
StandaloneMmCpuFeaturesLib.c
SmmCpuFeaturesLibNoStm.c

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h
index 8a1c2adc5c4..fd3e902547c 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h
@@ -9,6 +9,12 @@
#ifndef CPU_FEATURES_LIB_H_
#define CPU_FEATURES_LIB_H_

+#include <Library/SmmCpuFeaturesLib.h>
+#include <Library/BaseLib.h>
+#include <Library/PcdLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/DebugLib.h>
+
/**
Performs library initialization.

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
index 75a0ec8e948..cb4897b21e3 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
@@ -7,16 +7,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

**/

-#include <PiMm.h>
-#include <Library/SmmCpuFeaturesLib.h>
-#include <Library/BaseLib.h>
+#include "CpuFeaturesLib.h"
+
#include <Library/MtrrLib.h>
-#include <Library/PcdLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
#include <Register/Intel/Cpuid.h>
#include <Register/Intel/SmramSaveStateMap.h>
-#include "CpuFeaturesLib.h"

//
// Machine Specific Registers (MSRs)
@@ -287,64 +282,6 @@ SmmCpuFeaturesInitializeProcessor (
FinishSmmCpuFeaturesInitializeProcessor ();
}

-/**
- This function updates the SMRAM save state on the currently executing CPU
- to resume execution at a specific address after an RSM instruction. This
- function must evaluate the SMRAM save state to determine the execution mode
- the RSM instruction resumes and update the resume execution address with
- either NewInstructionPointer32 or NewInstructionPoint. The auto HALT restart
- flag in the SMRAM save state must always be cleared. This function returns
- the value of the instruction pointer from the SMRAM save state that was
- replaced. If this function returns 0, then the SMRAM save state was not
- modified.
-
- This function is called during the very first SMI on each CPU after
- SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution mode
- to signal that the SMBASE of each CPU has been updated before the default
- SMBASE address is used for the first SMI to the next CPU.
-
- @param[in] CpuIndex The index of the CPU to hook. The value
- must be between 0 and the NumberOfCpus
- field in the System Management System Table
- (SMST).
- @param[in] CpuState Pointer to SMRAM Save State Map for the
- currently executing CPU.
- @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to
- 32-bit execution mode from 64-bit SMM.
- @param[in] NewInstructionPointer Instruction pointer to use if resuming to
- same execution mode as SMM.
-
- @retval 0 This function did modify the SMRAM save state.
- @retval > 0 The original instruction pointer value from the SMRAM save state
- before it was replaced.
-**/
-UINT64
-EFIAPI
-SmmCpuFeaturesHookReturnFromSmm (
- IN UINTN CpuIndex,
- IN SMRAM_SAVE_STATE_MAP *CpuState,
- IN UINT64 NewInstructionPointer32,
- IN UINT64 NewInstructionPointer
- )
-{
- return 0;
-}
-
-/**
- Hook point in normal execution mode that allows the one CPU that was elected
- as monarch during System Management Mode initialization to perform additional
- initialization actions immediately after all of the CPUs have processed their
- first SMI and called SmmCpuFeaturesInitializeProcessor() relocating SMBASE
- into a buffer in SMRAM and called SmmCpuFeaturesHookReturnFromSmm().
-**/
-VOID
-EFIAPI
-SmmCpuFeaturesSmmRelocationComplete (
- VOID
- )
-{
-}
-
/**
Determines if MTRR registers must be configured to set SMRAM cache-ability
when executing in System Management Mode.
@@ -414,48 +351,6 @@ SmmCpuFeaturesRendezvousEntry (
}
}

-/**
- Processor specific hook point each time a CPU exits System Management Mode.
-
- @param[in] CpuIndex The index of the CPU that is exiting SMM. The value must
- be between 0 and the NumberOfCpus field in the System
- Management System Table (SMST).
-**/
-VOID
-EFIAPI
-SmmCpuFeaturesRendezvousExit (
- IN UINTN CpuIndex
- )
-{
-}
-
-/**
- Check to see if an SMM register is supported by a specified CPU.
-
- @param[in] CpuIndex The index of the CPU to check for SMM register support.
- The value must be between 0 and the NumberOfCpus field
- in the System Management System Table (SMST).
- @param[in] RegName Identifies the SMM register to check for support.
-
- @retval TRUE The SMM register specified by RegName is supported by the CPU
- specified by CpuIndex.
- @retval FALSE The SMM register specified by RegName is not supported by the
- CPU specified by CpuIndex.
-**/
-BOOLEAN
-EFIAPI
-SmmCpuFeaturesIsSmmRegisterSupported (
- IN UINTN CpuIndex,
- IN SMM_REG_NAME RegName
- )
-{
- if (FeaturePcdGet (PcdSmmFeatureControlEnable) && (RegName == SmmRegFeatureControl)) {
- return TRUE;
- }
-
- return FALSE;
-}
-
/**
Returns the current value of the SMM register for the specified CPU.
If the SMM register is not supported, then 0 is returned.
@@ -506,100 +401,3 @@ SmmCpuFeaturesSetSmmRegister (
}
}

-/**
- Read an SMM Save State register on the target processor. If this function
- returns EFI_UNSUPPORTED, then the caller is responsible for reading the
- SMM Save Sate register.
-
- @param[in] CpuIndex The index of the CPU to read the SMM Save State. The
- value must be between 0 and the NumberOfCpus field in
- the System Management System Table (SMST).
- @param[in] Register The SMM Save State register to read.
- @param[in] Width The number of bytes to read from the CPU save state.
- @param[out] Buffer Upon return, this holds the CPU register value read
- from the save state.
-
- @retval EFI_SUCCESS The register was read from Save State.
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
- @retval EFI_UNSUPPORTED This function does not support reading Register.
-
-**/
-EFI_STATUS
-EFIAPI
-SmmCpuFeaturesReadSaveStateRegister (
- IN UINTN CpuIndex,
- IN EFI_SMM_SAVE_STATE_REGISTER Register,
- IN UINTN Width,
- OUT VOID *Buffer
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-/**
- Writes an SMM Save State register on the target processor. If this function
- returns EFI_UNSUPPORTED, then the caller is responsible for writing the
- SMM Save Sate register.
-
- @param[in] CpuIndex The index of the CPU to write the SMM Save State. The
- value must be between 0 and the NumberOfCpus field in
- the System Management System Table (SMST).
- @param[in] Register The SMM Save State register to write.
- @param[in] Width The number of bytes to write to the CPU save state.
- @param[in] Buffer Upon entry, this holds the new CPU register value.
-
- @retval EFI_SUCCESS The register was written to Save State.
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
- @retval EFI_UNSUPPORTED This function does not support writing Register.
-**/
-EFI_STATUS
-EFIAPI
-SmmCpuFeaturesWriteSaveStateRegister (
- IN UINTN CpuIndex,
- IN EFI_SMM_SAVE_STATE_REGISTER Register,
- IN UINTN Width,
- IN CONST VOID *Buffer
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-/**
- This function is hook point called after the gEfiSmmReadyToLockProtocolGuid
- notification is completely processed.
-**/
-VOID
-EFIAPI
-SmmCpuFeaturesCompleteSmmReadyToLock (
- VOID
- )
-{
-}
-
-/**
- This API provides a method for a CPU to allocate a specific region for storing page tables.
-
- This API can be called more once to allocate memory for page tables.
-
- Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
- allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
- is returned. If there is not enough memory remaining to satisfy the request, then NULL is
- returned.
-
- This function can also return NULL if there is no preference on where the page tables are allocated in SMRAM.
-
- @param Pages The number of 4 KB pages to allocate.
-
- @return A pointer to the allocated buffer for page tables.
- @retval NULL Fail to allocate a specific region for storing page tables,
- Or there is no preference on where the page tables are allocated in SMRAM.
-
-**/
-VOID *
-EFIAPI
-SmmCpuFeaturesAllocatePageTableMemory (
- IN UINTN Pages
- )
-{
- return NULL;
-}
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c
new file mode 100644
index 00000000000..7777e52740e
--- /dev/null
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c
@@ -0,0 +1,216 @@
+/** @file
+Implementation shared across all library instances.
+
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiMm.h>
+#include <Library/SmmCpuFeaturesLib.h>
+#include <Library/BaseLib.h>
+#include <Library/MtrrLib.h>
+#include <Library/PcdLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/DebugLib.h>
+
+#include "CpuFeaturesLib.h"
+
+/**
+ This function updates the SMRAM save state on the currently executing CPU
+ to resume execution at a specific address after an RSM instruction. This
+ function must evaluate the SMRAM save state to determine the execution mode
+ the RSM instruction resumes and update the resume execution address with
+ either NewInstructionPointer32 or NewInstructionPoint. The auto HALT restart
+ flag in the SMRAM save state must always be cleared. This function returns
+ the value of the instruction pointer from the SMRAM save state that was
+ replaced. If this function returns 0, then the SMRAM save state was not
+ modified.
+
+ This function is called during the very first SMI on each CPU after
+ SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution mode
+ to signal that the SMBASE of each CPU has been updated before the default
+ SMBASE address is used for the first SMI to the next CPU.
+
+ @param[in] CpuIndex The index of the CPU to hook. The value
+ must be between 0 and the NumberOfCpus
+ field in the System Management System Table
+ (SMST).
+ @param[in] CpuState Pointer to SMRAM Save State Map for the
+ currently executing CPU.
+ @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to
+ 32-bit execution mode from 64-bit SMM.
+ @param[in] NewInstructionPointer Instruction pointer to use if resuming to
+ same execution mode as SMM.
+
+ @retval 0 This function did modify the SMRAM save state.
+ @retval > 0 The original instruction pointer value from the SMRAM save state
+ before it was replaced.
+**/
+UINT64
+EFIAPI
+SmmCpuFeaturesHookReturnFromSmm (
+ IN UINTN CpuIndex,
+ IN SMRAM_SAVE_STATE_MAP *CpuState,
+ IN UINT64 NewInstructionPointer32,
+ IN UINT64 NewInstructionPointer
+ )
+{
+ return 0;
+}
+
+/**
+ Hook point in normal execution mode that allows the one CPU that was elected
+ as monarch during System Management Mode initialization to perform additional
+ initialization actions immediately after all of the CPUs have processed their
+ first SMI and called SmmCpuFeaturesInitializeProcessor() relocating SMBASE
+ into a buffer in SMRAM and called SmmCpuFeaturesHookReturnFromSmm().
+**/
+VOID
+EFIAPI
+SmmCpuFeaturesSmmRelocationComplete (
+ VOID
+ )
+{
+}
+
+/**
+ Processor specific hook point each time a CPU exits System Management Mode.
+
+ @param[in] CpuIndex The index of the CPU that is exiting SMM. The value must
+ be between 0 and the NumberOfCpus field in the System
+ Management System Table (SMST).
+**/
+VOID
+EFIAPI
+SmmCpuFeaturesRendezvousExit (
+ IN UINTN CpuIndex
+ )
+{
+}
+
+/**
+ Check to see if an SMM register is supported by a specified CPU.
+
+ @param[in] CpuIndex The index of the CPU to check for SMM register support.
+ The value must be between 0 and the NumberOfCpus field
+ in the System Management System Table (SMST).
+ @param[in] RegName Identifies the SMM register to check for support.
+
+ @retval TRUE The SMM register specified by RegName is supported by the CPU
+ specified by CpuIndex.
+ @retval FALSE The SMM register specified by RegName is not supported by the
+ CPU specified by CpuIndex.
+**/
+BOOLEAN
+EFIAPI
+SmmCpuFeaturesIsSmmRegisterSupported (
+ IN UINTN CpuIndex,
+ IN SMM_REG_NAME RegName
+ )
+{
+ if (FeaturePcdGet (PcdSmmFeatureControlEnable) && (RegName == SmmRegFeatureControl)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ Read an SMM Save State register on the target processor. If this function
+ returns EFI_UNSUPPORTED, then the caller is responsible for reading the
+ SMM Save Sate register.
+
+ @param[in] CpuIndex The index of the CPU to read the SMM Save State. The
+ value must be between 0 and the NumberOfCpus field in
+ the System Management System Table (SMST).
+ @param[in] Register The SMM Save State register to read.
+ @param[in] Width The number of bytes to read from the CPU save state.
+ @param[out] Buffer Upon return, this holds the CPU register value read
+ from the save state.
+
+ @retval EFI_SUCCESS The register was read from Save State.
+ @retval EFI_INVALID_PARAMETER Buffer is NULL.
+ @retval EFI_UNSUPPORTED This function does not support reading Register.
+
+**/
+EFI_STATUS
+EFIAPI
+SmmCpuFeaturesReadSaveStateRegister (
+ IN UINTN CpuIndex,
+ IN EFI_SMM_SAVE_STATE_REGISTER Register,
+ IN UINTN Width,
+ OUT VOID *Buffer
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ Writes an SMM Save State register on the target processor. If this function
+ returns EFI_UNSUPPORTED, then the caller is responsible for writing the
+ SMM Save Sate register.
+
+ @param[in] CpuIndex The index of the CPU to write the SMM Save State. The
+ value must be between 0 and the NumberOfCpus field in
+ the System Management System Table (SMST).
+ @param[in] Register The SMM Save State register to write.
+ @param[in] Width The number of bytes to write to the CPU save state.
+ @param[in] Buffer Upon entry, this holds the new CPU register value.
+
+ @retval EFI_SUCCESS The register was written to Save State.
+ @retval EFI_INVALID_PARAMETER Buffer is NULL.
+ @retval EFI_UNSUPPORTED This function does not support writing Register.
+**/
+EFI_STATUS
+EFIAPI
+SmmCpuFeaturesWriteSaveStateRegister (
+ IN UINTN CpuIndex,
+ IN EFI_SMM_SAVE_STATE_REGISTER Register,
+ IN UINTN Width,
+ IN CONST VOID *Buffer
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ This function is hook point called after the gEfiSmmReadyToLockProtocolGuid
+ notification is completely processed.
+**/
+VOID
+EFIAPI
+SmmCpuFeaturesCompleteSmmReadyToLock (
+ VOID
+ )
+{
+}
+
+/**
+ This API provides a method for a CPU to allocate a specific region for storing page tables.
+
+ This API can be called more once to allocate memory for page tables.
+
+ Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is
+ returned.
+
+ This function can also return NULL if there is no preference on where the page tables are allocated in SMRAM.
+
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer for page tables.
+ @retval NULL Fail to allocate a specific region for storing page tables,
+ Or there is no preference on where the page tables are allocated in SMRAM.
+
+**/
+VOID *
+EFIAPI
+SmmCpuFeaturesAllocatePageTableMemory (
+ IN UINTN Pages
+ )
+{
+ return NULL;
+}
--
2.37.1.windows.1


[PATCH V3 1/3] UefiCpuPkg/SmmCpuFeaturesLib: Rename the common C file

Chang, Abner
 

From: Abner Chang <abner.chang@...>

BZ# 4093: Abstract SmmCpuFeaturesLib for sharing common code

Rename SmmCpuFeaturesLiCommon.c to
IntelSmmCpuFeaturesLib, because it was developed
specifically for Intel implementation. The code
that can be shared by other archs or vendors
will be stripped away and put in the common
file in the next patch.

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Abdul Lateef Attar <abdattar@...>
Cc: Garrett Kirkendall <garrett.kirkendall@...>
Cc: Paul Grimes <paul.grimes@...>
Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rahul Kumar <rahul1.kumar@...>
---
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 2 +-
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf | 2 +-
.../Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf | 2 +-
.../{SmmCpuFeaturesLibCommon.c => IntelSmmCpuFeaturesLib.c} | 0
4 files changed, 3 insertions(+), 3 deletions(-)
rename UefiCpuPkg/Library/SmmCpuFeaturesLib/{SmmCpuFeaturesLibCommon.c => IntelSmmCpuFeaturesLib.c} (100%)

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
index 7b5cef97008..6254a14698a 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
@@ -18,8 +18,8 @@

[Sources]
CpuFeaturesLib.h
+ IntelSmmCpuFeaturesLib.c
SmmCpuFeaturesLib.c
- SmmCpuFeaturesLibCommon.c
SmmCpuFeaturesLibNoStm.c
TraditionalMmCpuFeaturesLib.c

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
index 85214ee31cd..d64d8e66b38 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
@@ -19,7 +19,7 @@

[Sources]
CpuFeaturesLib.h
- SmmCpuFeaturesLibCommon.c
+ IntelSmmCpuFeaturesLib.c
SmmStm.c
SmmStm.h
TraditionalMmCpuFeaturesLib.c
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf
index 3eacab48db3..5935b3e1fd6 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf
@@ -20,8 +20,8 @@

[Sources]
CpuFeaturesLib.h
+ IntelSmmCpuFeaturesLib.c
StandaloneMmCpuFeaturesLib.c
- SmmCpuFeaturesLibCommon.c
SmmCpuFeaturesLibNoStm.c

[Packages]
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
similarity index 100%
rename from UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c
rename to UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
--
2.37.1.windows.1


Re: [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

Chang, Abner
 

[AMD Official Use Only - General]

 

Hi Igor,

My response in below,

 

From: Igor Kulchytskyy <igork@...>
Sent: Monday, October 31, 2022 2:56 AM
To: Chang, Abner <Abner.Chang@...>; Nickle Wang <nicklew@...>; devel@edk2.groups.io
Cc: Nick Ramirez <nramirez@...>
Subject: Re: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

 

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

 

Hi Abner,

"redfish/v1" does not require any authentication. But "redfish/v1" json response contains the links to high level resources - systems, chassis etc.

My point was to get the URI to systems from that json response, rather than have it hard coded.

[Chang, Abner]

Ah I see. I remember we do have the code on RedfishClinetPkg to determine the version under Redfish/. Then concatenate those to Redfish/{version}.

Another way is: We do the authentication check only if the HTTP transfer to Redfish service gets 401. Means the upper layer driver (RedfishConfigHandler driver? I have to check) invokes RedfishCrendtialLib to create the Basic authorization or session Token when the HTTP action to Redfish service returns 401.

 

If both auth methods supported, we should go with more secured one - session authentication. In this case we do not need to send username and password within each request.

 

[Chang, Abner]

Ok, this make sense to me. So we don’t need to provide a BIOS setup option or PCD  to the platform for selecting the auth method. We will determine it automatically.

Then we can preserve this token secured for each request, but delete it at End of DXE.

 

Abner

 

Thank you,

Igor

 


From: Chang, Abner <Abner.Chang@...>
Sent: Sunday, October 30, 2022 11:33:26 AM
To: Nickle Wang <nicklew@...>; Igor Kulchytskyy <igork@...>; devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Nick Ramirez <nramirez@...>
Subject: RE: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

 

[AMD Official Use Only - General]

 

Does "/redfish/v1” require authentication? I think this solution is ok if "/redfish/v1” requires the authentication.

Another thing is how do we determine to use Basic authentication or the session token?

 

Abner

 

From: Nickle Wang <nicklew@...>
Sent: Saturday, October 29, 2022 7:29 AM
To: Igor Kulchytskyy <igork@...>; Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io
Cc: Nick Ramirez <nramirez@...>
Subject: Re: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

 

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

 

Hi Igor,

 

Yes, we should get the URI to computer system collection by parsing "/redfish/v1".

 

Hi Abner,

 

What do you think about this? And if we like to select authentication method for Redfish communication in this way, we need to update RedfishCredentialLib.h because now the authentication method is not decided by this low-level library.

 

Thanks,

Nickle


From: Igor Kulchytskyy <igork@...>
Sent: Saturday, October 29, 2022 12:03 AM
To: Nickle Wang <nicklew@...>; Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Nick Ramirez <nramirez@...>
Subject: RE: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

 

External email: Use caution opening links or attachments


Hi Nickle,
I think this is a good idea to send a request to the URI which requires the authentication and then analyze the header of response.
The only thing I would like to discuss is a hardcoded URI - "/redfish/v1/Systems".
Shouldn't we parse "redfish/v1" json response and get the URI from "Systems" attribute.
That, I think, would be more universal method.
And that is what Redfish specification said, that user should be able to iterate from Redfish service root "redfish/v1" to any redfish resource.
Thank you,
Igor



-----Original Message-----
From: Nickle Wang <nicklew@...>
Sent: Friday, October 28, 2022 10:53 AM
To: Igor Kulchytskyy <igork@...>; Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io
Cc: Nick Ramirez <nramirez@...>
Subject: RE: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

Hi Igor, Abner,

Thanks for your comments. A quick summary as below:

- BIOS is not supported to disable bootstrap credential service. For security purposes, BIOS should shutdown credential service with its internal control mechanism.
- Credential libraries need a cache mechanism to prevent multiple queries to BMC. All applications in BIOS share the same credentials.
- The storage of keeping credentials should be deleted before the end of the DXE event. So that the credential will not be retrieved by unauthorized user or application. (e.g. user can read variable under UEFI shell with dmpstore command)

There is one thing remained and I like to have further discussion. For the authentication method, do we think that client user can decide what authentication method to use regardless of the requirement from server? I am thinking a detection mechanism as below:

Issue HTTP GET to "/redfish/v1/Systems" (which normally require authentication) without authentication method.
a) if client receive 200 OK, "No Auth" is used and we don't need to get credentials
b) if client receive 401 Unauthorized, check the "WWW-Authenticate" field in returned HTTP header. "Basic realm" or "X-Auh-Token realm" or both two methods will be specified. Then client can know what method to use. Two methods all require credential.

Above mechanism can be placed in RedfishCredentailDxe driver so driver will know if it needs to call credential lib or not.

Thanks,
Nickle

-----Original Message-----
From: Igor Kulchytskyy <igork@...>
Sent: Friday, October 28, 2022 9:54 PM
To: Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io; Nickle Wang <nicklew@...>
Cc: Nick Ramirez <nramirez@...>
Subject: RE: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

External email: Use caution opening links or attachments


Hi Abner,
Yes, you are right that NVRAM variables were deprecated by DMTF.
But we can use our own boot time NVRAM variable to keep FW credentials. That variable will not be accessible from OS, but since we agreed not to disable bootstrap credentials service on exit boot event, then OS may get its own credentials.
Or we can save the credentials in memory variable. But in this case if we have several instances of the library linked with different modules they will have to send their own IPMI command to get credentials.
So, I think it is better to use our own NVRAM boot time variable.
Thank you,
Igor


-----Original Message-----
From: Chang, Abner <Abner.Chang@...>
Sent: Friday, October 28, 2022 3:48 AM
To: devel@edk2.groups.io; Igor Kulchytskyy <igork@...>; nicklew@...
Cc: Nick Ramirez <nramirez@...>
Subject: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

[AMD Official Use Only - General]



> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Igor
> Kulchytskyy via groups.io
> Sent: Thursday, October 27, 2022 10:42 PM
> To: devel@edk2.groups.io; nicklew@...; Chang, Abner
> <Abner.Chang@...>
> Cc: Nick Ramirez <nramirez@...>
> Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib:
> IPMI implementation
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> Hi Nickle,
> Pleased, see my comments on your questions below.
>
> Another point I missed in my previous mail.
> You have that function in the library to get credentials and it is
> used by RedfishCredentialsDxe driver to create the protocol which in
> its turn will be used by other Redfish modules.
> We do not know how many modules and how many times will call this
> function during boot. Right?
> And on each call of this function you call IPMI command. That command
> will create new Redfish account on BMC side according to Redfish HI specification:
>
> " If the Get Bootstrap Account Credentials command has been issued and
> responds with the completion code 00h, a bootstrap account shall be
> added to the manager's account collection and enabled. If the Get
> Bootstrap Account Credentials command is sent subsequent times and
> responds with the completion code 00h, a new account shall be created
> based on the newly generated credentials. Any existing bootstrap accounts shall remain active."
>
> As I know BMC may have some restrictions on the number of Redfish
> accounts they can support.
> And because of that BOS may hit this limit. Which is not good.
> On the other hand I'm not sure we need to have different credentials
> for different modules? All those modules are part of FW. And all of
> them will be associated with the same RoleID (FW role) on BMC side.
> So, all of them may use the same credentials.
> Could we cash the credentials on first call of that
Yes, this is something we have to avoid. Many accounts will be created while each of Redfish client module requests a credential. FW can save it in EFI variable and delete it at proper timing. Unfortunately the credential delivering via EFI variable section was deprecated, otherwise we can deliver the credential to OS through EFI variable with disabling the bootstrap credential at exit boot service.

Abner

> RedfishCredentialGetAuthInfo and then use those cashed credentials on
> subsequential calls?
> It will also may save a boot time, since there is no need to send IPMI
> command.
>
> Thank you,
> Igor
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Nickle
> Wang via groups.io
> Sent: Thursday, October 27, 2022 9:26 AM
> To: devel@edk2.groups.io; Igor Kulchytskyy <igork@...>;
> abner.chang@...
> Cc: Nick Ramirez <nramirez@...>
> Subject: [EXTERNAL] Re: [edk2-devel] [PATCH]
> RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation
>
>
> **CAUTION: The e-mail below is from an external source. Please
> exercise caution before opening attachments, clicking links, or
> following guidance.**
>
> Hi Igor,
>
> Thank you for your help to review my changes.
>
> > And it will be blocked by our IPMI call.
>
> I see your point. So, BIOS should never be the person to shutdown
> credential service because BIOS always get executed prior to OS, right?
>
> Igor: Yes, my point is that we should not shutdown credential service
> from BIOS. Even if OS sends that IPMI command, new account will be
> created and BIOS credentials will not be compromised.
>
> > Should it be configured with some PCD? Maybe user may select in
> > Setup
> what method should be used? Or it could be build time configuration?
>
> I have below assumption while I implemented the library. I admit this
> is not always true.
>
> No Auth: I think this is rare case for Redfish service which gives
> anonymous privilege to change BIOS settings.
> Basic Auth: this is the authentication method which uses username and
> password to build base64 encoded string.
> Session Auth: I assume that client must have a session token first and
> then use this authentication method. Can we use username and password
> to generate session token on our own? If my memory serves me
> correctly, client has to do a login with username and password first
> and then client can receive session token from server.
>
> Igor: BIOS will use the credentials to create session. It should send
> POST request to the session URI with user name and password to create session.
> If a session created successfully then on response BMC returns header
> "X- Auth-Token" which then used for the subsequential calls.
>
> If we really like to know what authentication method that Redfish
> service used, we can issue a HTTP query to "/redfish/v1/Systems" with "No Auth".
> Then we can know what authentication method is required by reading the
> "WWW-Authenticate " filed in returned HTTP header.
>
> Igor: As my understanding, even if you include authentication header
> (Base64 encoded) in the request to BMC and BMC has NoAuth
> configuration, then that authentication header would be just ignored by BMC.
>
> Thanks,
> Nickle
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Igor
> Kulchytskyy via groups.io
> Sent: Wednesday, October 26, 2022 11:26 PM
> To: Nickle Wang <nicklew@...>; devel@edk2.groups.io;
> abner.chang@...
> Cc: Nick Ramirez <nramirez@...>
> Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib:
> IPMI implementation
>
> External email: Use caution opening links or attachments
>
>
> Hi Nickle,
> I would like to discuss that DisableBootstrapControl flag and how it
> is used in our implementation.
> According to Redfish HI specification we can use this flag to disable
> credential bootstrapping control.
> It can be disabled permanently or till next reboot of the host or
> service. That depend on the  EnableAfterReset  setting on BMC side:
> CredentialBootstrapping (v1.3+)
> { object The credential bootstrapping settings for this interface.
>         EnableAfterReset (v1.3+) Boolean read-write (null) An
> indication of whether credential bootstrapping is enabled after a reset for this interface.
>         Enabled (v1.3+) Boolean read-write (null) An indication of
> whether credential bootstrapping is enabled for this interface.
>         RoleId (v1.3+) string read-write The role used for the
> bootstrap account created for this interface.
> }
> So, if EnableAfterReset set to false, that means BMC will response
> with 0x80 error and will not return any credentials after reboot. And
> BIOS BMC communication will fail.
> Another concern with  disabling credential bootstrapping control is
> that we do it on Exit Boot event before passing a control to OS.
> But OS may also need to communicate to BMC through Redfish Host
> Interface to post some information. And it will be blocked by our IPMI call.
> We create that SMBIOS Type 42 table with Redfish Host Interface
> settings which can be used by OS to communicate with BMC. But without
> the credentials it will not be possible.
>
> Another question is AuthMethod parameter you initialize in this library:
> *AuthMethod = AuthMethodHttpBasic;
> According to Redfish HI specification 3 methods may be used - No Auth,
> Basic Auth and Session Auth.
> Basic Auth and Session Auth methods are required the credentials to be
> used by BIOS. And both of them should be supported by BMC.
> And your high level function RedfishCreateLibredfishService also
> supports of creation Basic or Session Auth service.
> I'm not sure why low level library which is created to get credentials
> from BMC should decide what Authentication method should be used?
> Should it be configured with some PCD? Maybe user may select in Setup
> what method should be used? Or it could be build time configuration?
>
> Thank you,
> Igor
>
> -----Original Message-----
> From: Nickle Wang <nicklew@...>
> Sent: Tuesday, October 25, 2022 4:24 AM
> To: devel@edk2.groups.io; abner.chang@...
> Cc: Nick Ramirez <nramirez@...>; Igor Kulchytskyy
> <igork@...>
> Subject: [EXTERNAL] RE: [edk2-devel] [PATCH]
> RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation
>
>
> **CAUTION: The e-mail below is from an external source. Please
> exercise caution before opening attachments, clicking links, or
> following guidance.**
>
> Thanks for your review comments, Abner! I will update new version
> patch later. The CI build error will be handled together.
>
> > please add Igor as reviewer too
> Sure!
>
>
> > +  *UserId = AllocateZeroPool (sizeof (CHAR8) * USERNAME_MAX_SIZE);
> > + if
> [Chang, Abner]
> Allocation memory with the size (USERNAME_MAX_LENGTH + 1)  for both
> BootUsername and BootstrapPassword?   Because the maximum number of
> characters defined in the spec is USERNAME_MAX_LENGTH for the
> user/password.
>
> Yes, the additional one byte is for NULL terminator.
> USERNAME_MAX_LENGTH is defined as 16 and follow host interface
> specification.
>
> Regards,
> Nickle
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang,
> Abner via groups.io
> Sent: Saturday, October 22, 2022 3:01 PM
> To: Nickle Wang <nicklew@...>; devel@edk2.groups.io
> Cc: Nick Ramirez <nramirez@...>; Igor Kulchytskyy
> <igork@...>
> Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib:
> IPMI implementation
>
> External email: Use caution opening links or attachments
>
>
> [AMD Official Use Only - General]
>
> Hi Nickle, please add Igor as reviewer too. My comments is in below,
>
> > -----Original Message-----
> > From: Nickle Wang <nicklew@...>
> > Sent: Thursday, October 20, 2022 10:55 AM
> > To: devel@edk2.groups.io
> > Cc: Chang, Abner <Abner.Chang@...>; Nick Ramirez
> > <nramirez@...>
> > Subject: [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI
> > implementation
> >
> > Caution: This message originated from an External Source. Use proper
> > caution when opening attachments, clicking links, or responding.
> >
> >
> > This library follows Redfish Host Interface specification and use
> > IPMI command to get bootstrap account credential(NetFn 2Ch, Command
> > 02h)
> from BMC.
> > RedfishHostInterfaceDxe will use this credential for the following
> > communication between BIOS and BMC.
> >
> > Cc: Abner Chang <abner.chang@...>
> > Cc: Nick Ramirez <nramirez@...>
> > Signed-off-by: Nickle Wang <nicklew@...>
> > ---
> >  .../RedfishPlatformCredentialLib.c            | 273 ++++++++++++++++++
> >  .../RedfishPlatformCredentialLib.h            |  75 +++++
> >  .../RedfishPlatformCredentialLib.inf          |  37 +++
> [Chang, Abner]
> Could we name this library RedfishPlatformCredentialIpmi so the naming
> style is consistent with RedfishPlatformCredentialNull?
>
> >  3 files changed, 385 insertions(+)
> >  create mode 100644
> >
> RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredent
> ial
> Lib.
> > c
> >  create mode 100644
> >
> RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredent
> ial
> Lib.
> > h
> >  create mode 100644
> > RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCrede
> > nt
> > ialLib.i
> > nf
> >
> > diff --git
> > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.c
> > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.c
> > new file mode 100644
> > index 0000000000..23a15ab1fa
> > --- /dev/null
> > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatfor
> > +++ mC
> > +++ re
> > +++ dentialLib.c
> > @@ -0,0 +1,273 @@
> > +/** @file
> > +*
> > +*  Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> > +*
> > +*  SPDX-License-Identifier: BSD-2-Clause-Patent
> [Chang, Abner]
> We can have "@par Revision Reference:"  in the file header to point
> out the spec.
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fnam12.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fnam1&amp;data=05%7C01%7Cnicklew%40nvidia.com%7C3f7c98d402b8471f95d408dab8fdeb00%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638025697967855556%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=90NlFqDGaEtk5kMibeuQ3%2FzQNn3ANJn1LcF6RNqsJJ0%3D&amp;reserved=0
> 1.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fnam1
> &amp;data=05%7C01%7Cigork%40ami.com%7C224e78526d7d45a7b31108dab8f42ac1
> %7C27e97857e15f486cb58e86c2b3040f93%7C1%7C0%7C638025656093102767%7CUnk
> nown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWw
> iLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=YN52FOx%2F%2F1YYG8Nl86vu7zlz
> M%2BpLMk3Ym0RNPLxLKqw%3D&amp;reserved=0
> 2.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fnam1
> &amp;data=05%7C01%7Cnicklew%40nvidia.com%7C90696ea8811e49e371a708dab8e
> be2d8%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638025620543993279%
> 7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik
> 1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=CyvRgMZREOk5Yf0hU3CmH%2
> B08ktxMYw%2Bixr4UVywfrAQ%3D&amp;reserved=0
> 1.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fww&a
> mp;data=05%7C01%7Cigork%40ami.com%7C2b5b562c02c04c90d51208dab8b8c0fd%7
> C27e97857e15f486cb58e86c2b3040f93%7C1%7C0%7C638025400915295621%7CUnkno
> wn%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiL
> CJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=Uy%2B3HS336N3rgNSESPcyOPGX3eOR
> 48hekdz08nLtJU4%3D&amp;reserved=0
> w.dmtf.org%2Fsites%2Fdefault%2Ffiles%2Fstandards%2Fdocuments%2FDSP
> 0270_1.3.0.pdf&amp;data=05%7C01%7Cabner.chang%40amd.com%7C074aa
> e162fba49409af408dab8297c03%7C3dd8961fe4884e608e11a82d994e183d%7C
> 0%7C0%7C638024786060127888%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiM
> C4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000
> %7C%7C%7C&amp;sdata=yY6hhKjQfVqmNuufbeDNk%2B2FKrebHyIAyS9Ya4
> szE3Y%3D&amp;reserved=0
>
> > +*
> > +**/
> > +
> > +#include "RedfishPlatformCredentialLib.h"
> > +
> > +//
> > +// Global flag of controlling credential service // BOOLEAN
> > +mRedfishServiceStopped = FALSE;
> > +
> > +/**
> > +  Notify the Redfish service provide to stop provide configuration
> > +service to this
> > platform.
> > +
> > +  This function should be called when the platfrom is about to
> > + leave the safe
> > environment.
> > +  It will notify the Redfish service provider to abort all logined
> > + session, and prohibit  further login with original auth info.
> > + GetAuthInfo() will return EFI_UNSUPPORTED once this  function is
> returned.
> > +
> > +  @param[in]   This                Pointer to
> > EDKII_REDFISH_CREDENTIAL_PROTOCOL instance.
> > +  @param[in]   ServiceStopType     Reason of stopping Redfish service.
> > +
> > +  @retval EFI_SUCCESS              Service has been stoped successfully.
> > +  @retval EFI_INVALID_PARAMETER    This is NULL.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +LibStopRedfishService (
> > +  IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL           *This,
> > +  IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE
> ServiceStopType
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +
> > +  if ((ServiceStopType <= ServiceStopTypeNone) || (ServiceStopType
> > + >=
> > ServiceStopTypeMax)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  //
> > +  // Raise flag first
> > +  //
> > +  mRedfishServiceStopped = TRUE;
> > +
> > +  //
> > +  // Notify BMC to disable credential bootstrapping support.
> > +  //
> > +  Status = GetBootstrapAccountCredentials (TRUE, NULL, NULL);  if
> > + (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: fail to disable bootstrap credential:
> > + %r\n",
> > __FUNCTION__, Status));
> > +    return Status;
> > +  }
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +/**
> > +  Notification of Exit Boot Service.
> > +
> > +  @param[in]  This    Pointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL.
> > +**/
> > +VOID
> > +EFIAPI
> > +LibCredentialExitBootServicesNotify (
> > +  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
> > +  )
> > +{
> > +  //
> > +  // Stop the credential support when system is about to enter OS.
> > +  //
> > +  LibStopRedfishService (This, ServiceStopTypeExitBootService); }
> > +
> > +/**
> > +  Notification of End of DXe.
> > +
> > +  @param[in]  This    Pointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL.
> > +**/
> > +VOID
> > +EFIAPI
> > +LibCredentialEndOfDxeNotify (
> > +  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
> > +  )
> > +{
> > +  //
> > +  // Do nothing now.
> > +  // We can stop credential support when system reach end-of-dxe
> > +for security
> > reason.
> > +  //
> > +}
> > +
> > +/**
> > +  Function to retrieve temporary use credentials for the UEFI
> > +redfish client
> [Chang, Abner]
> We miss the functionality to disable bootstrap credential service in
> the function description.
>
> > +
> > +  @param[in]  DisableBootstrapControl
> > +                                      TRUE - Tell the BMC to disable the bootstrap credential
> > +                                             service to ensure no one else gains credentials
> > +                                      FALSE  Allow the bootstrap
> > + credential service to continue  @param[out] BootstrapUsername
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential
> > username
> > +                                      When DisableBootstrapControl
> > + is TRUE, this pointer can be NULL
> > +
> > +  @param[out] BootstrapPassword
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential
> > password
> > +                                      When DisableBootstrapControl
> > + is TRUE, this pointer can be NULL
> > +
> > +  @retval  EFI_SUCCESS                Credentials were successfully fetched and
> > returned
> > +  @retval  EFI_INVALID_PARAMETER      BootstrapUsername or
> > BootstrapPassword is NULL when DisableBootstrapControl
> > +                                      is set to FALSE
> > +  @retval  EFI_DEVICE_ERROR           An IPMI failure occurred
> [Chang, Abner]
> The return status should also include the status of disabling
> bootstrap credential.
>
>
> > +**/
> > +EFI_STATUS
> > +GetBootstrapAccountCredentials (
> > +  IN BOOLEAN DisableBootstrapControl,
> > +  IN OUT CHAR8 *BootstrapUsername, OPTIONAL
> > +  IN OUT CHAR8  *BootstrapPassword    OPTIONAL
> > +  )
> > +{
> > +  EFI_STATUS                                  Status;
> > +  IPMI_BOOTSTRAP_CREDENTIALS_COMMAND_DATA     CommandData;
> > +  IPMI_BOOTSTRAP_CREDENTIALS_RESULT_RESPONSE  ResponseData;
> > +  UINT32                                      ResponseSize;
> > +
> > +  if (!PcdGetBool (PcdIpmiFeatureEnable)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: IPMI is not enabled! Unable to fetch
> > + Redfish
> > credentials\n", __FUNCTION__));
> > +    return EFI_UNSUPPORTED;
> > +  }
> > +
> > +  //
> > +  // NULL buffer check
> > +  //
> > +  if (!DisableBootstrapControl && ((BootstrapUsername == NULL) ||
> > (BootstrapPassword == NULL))) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  DEBUG ((DEBUG_VERBOSE, "%a: Disable bootstrap control: 0x%x\n",
> > + __FUNCTION__, DisableBootstrapControl));
> > +
> > +  //
> > +  // IPMI callout to NetFn 2C, command 02
> > +  //    Request data:
> > +  //      Byte 1: REDFISH_IPMI_GROUP_EXTENSION
> > +  //      Byte 2: DisableBootstrapControl
> > +  //
> > +  CommandData.GroupExtensionId        =
> REDFISH_IPMI_GROUP_EXTENSION;
> > +  CommandData.DisableBootstrapControl = (DisableBootstrapControl ?
> > + REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_DISABLE :
> > + REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_ENABLE);
> > +
> > +  ResponseSize = sizeof (ResponseData);
> > +
> > +  //
> > +  //    Response data:
> > +  //      Byte 1    : Completion code
> > +  //      Byte 2    : REDFISH_IPMI_GROUP_EXTENSION
> > +  //      Byte 3-18 : Username
> > +  //      Byte 19-34: Password
> > +  //
> > +  Status = IpmiSubmitCommand (
> > +             IPMI_NETFN_GROUP_EXT,
> > +             REDFISH_IPMI_GET_BOOTSTRAP_CREDENTIALS_CMD,
> > +             (UINT8 *)&CommandData,
> > +             sizeof (CommandData),
> > +             (UINT8 *)&ResponseData,
> > +             &ResponseSize
> > +             );
> > +
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: IPMI transaction failure.
> > + Returning\n",
> > __FUNCTION__));
> > +    ASSERT_EFI_ERROR (Status);
> > +    return Status;
> > +  } else {
> > +    if (ResponseData.CompletionCode != IPMI_COMP_CODE_NORMAL) {
> > +      if (ResponseData.CompletionCode ==
> > REDFISH_IPMI_COMP_CODE_BOOTSTRAP_CREDENTIAL_DISABLED) {
> > +        DEBUG ((DEBUG_ERROR, "%a: bootstrap credential support was
> > disabled\n", __FUNCTION__));
> > +        return EFI_ACCESS_DENIED;
> > +      }
> > +
> > +      DEBUG ((DEBUG_ERROR, "%a: Completion code = 0x%x.
> > + Returning\n",
> > __FUNCTION__, ResponseData.CompletionCode));
> > +      return EFI_PROTOCOL_ERROR;
> > +    } else if (ResponseData.GroupExtensionId !=
> > REDFISH_IPMI_GROUP_EXTENSION) {
> > +      DEBUG ((DEBUG_ERROR, "%a: Group Extension Response = 0x%x.
> > Returning\n", __FUNCTION__, ResponseData.GroupExtensionId));
> > +      return EFI_DEVICE_ERROR;
> > +    } else {
> > +      if (BootstrapUsername != NULL) {
> > +        CopyMem (BootstrapUsername, ResponseData.Username,
> > USERNAME_MAX_LENGTH);
> > +        //
> > +        // Manually append null-terminator in case 16 characters
> > + username
> > returned.
> > +        //
> > +        BootstrapUsername[USERNAME_MAX_LENGTH] = '\0';
> > +      }
> > +
> > +      if (BootstrapPassword != NULL) {
> > +        CopyMem (BootstrapPassword, ResponseData.Password,
> > PASSWORD_MAX_LENGTH);
> > +        //
> > +        // Manually append null-terminator in case 16 characters
> > + password
> > returned.
> > +        //
> > +        BootstrapPassword[PASSWORD_MAX_LENGTH] = '\0';
> > +      }
> > +    }
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +/**
> > +  Retrieve platform's Redfish authentication information.
> > +
> > +  This functions returns the Redfish authentication method together
> > + with the user Id and  password.
> > +  - For AuthMethodNone, the UserId and Password could be used for
> > + HTTP
> > header authentication
> > +    as defined by RFC7235.
> > +  - For AuthMethodRedfishSession, the UserId and Password could be
> > + used for
> > Redfish
> > +    session login as defined by  Redfish API specification (DSP0266).
> > +
> > +  Callers are responsible for and freeing the returned string storage.
> > +
> > +  @param[in]   This                Pointer to
> > EDKII_REDFISH_CREDENTIAL_PROTOCOL instance.
> > +  @param[out]  AuthMethod          Type of Redfish authentication method.
> > +  @param[out]  UserId              The pointer to store the returned UserId
> string.
> > +  @param[out]  Password            The pointer to store the returned
> Password
> > string.
> > +
> > +  @retval EFI_SUCCESS              Get the authentication information
> successfully.
> > +  @retval EFI_ACCESS_DENIED        SecureBoot is disabled after EndOfDxe.
> > +  @retval EFI_INVALID_PARAMETER    This or AuthMethod or UserId or
> > Password is NULL.
> > +  @retval EFI_OUT_OF_RESOURCES     There are not enough memory
> resources.
> > +  @retval EFI_UNSUPPORTED          Unsupported authentication method is
> > found.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +LibCredentialGetAuthInfo (
> > +  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This,
> > +  OUT EDKII_REDFISH_AUTH_METHOD          *AuthMethod,
> > +  OUT CHAR8                              **UserId,
> > +  OUT CHAR8                              **Password
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +
> > +  if ((AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  *UserId   = NULL;
> > +  *Password = NULL;
> > +
> > +  if (mRedfishServiceStopped) {
> > +    DEBUG ((DEBUG_ERROR, "%a: credential service is stopped due to
> > + security
> > reason\n", __FUNCTION__));
> > +    return EFI_ACCESS_DENIED;
> > +  }
> > +
> > +  *AuthMethod = AuthMethodHttpBasic;
> > +
> > +  *UserId = AllocateZeroPool (sizeof (CHAR8) * USERNAME_MAX_SIZE);
> > + if
> [Chang, Abner]
> Allocation memory with the size (USERNAME_MAX_LENGTH + 1)  for both
> BootUsername and BootstrapPassword?   Because the maximum number of
> characters defined in the spec is USERNAME_MAX_LENGTH for the
> user/password.
>
>
> > + (*UserId == NULL) {
> > +    return EFI_OUT_OF_RESOURCES;
> > +  }
> > +
> > +  *Password = AllocateZeroPool (sizeof (CHAR8) *
> > + PASSWORD_MAX_SIZE); if (*Password == NULL) {
> > +    return EFI_OUT_OF_RESOURCES;
> > +  }
> > +
> > +  Status = GetBootstrapAccountCredentials (FALSE, *UserId,
> > + *Password); if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: fail to get bootstrap credential:
> > + %r\n",
> > __FUNCTION__, Status));
> > +    return Status;
> > +  }
> > +
> > +  return EFI_SUCCESS;
> > +}
> > diff --git
> > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.h
> > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.h
> > new file mode 100644
> > index 0000000000..5b448e01be
> > --- /dev/null
> > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatfor
> > +++ mC
> > +++ re
> > +++ dentialLib.h
> > @@ -0,0 +1,75 @@
> > +/** @file
> > +*
> > +*  Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> > +*
> > +*  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +*
> > +**/
> > +#include <Uefi.h>
> > +#include <IndustryStandard/Ipmi.h>
> > +#include <Protocol/EdkIIRedfishCredential.h>
> > +#include <Library/BaseLib.h>
> > +#include <Library/BaseMemoryLib.h>
> > +#include <Library/DebugLib.h>
> > +#include <Library/IpmiBaseLib.h>
> > +#include <Library/MemoryAllocationLib.h> #include
> > +<Library/RedfishCredentialLib.h>
> > +
> > +#define REDFISH_IPMI_GROUP_EXTENSION                          0x52
> > +#define REDFISH_IPMI_GET_BOOTSTRAP_CREDENTIALS_CMD            0x02
> > +#define REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_ENABLE              0xA5
> > +#define REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_DISABLE             0x00
> > +#define
> REDFISH_IPMI_COMP_CODE_BOOTSTRAP_CREDENTIAL_DISABLED
> > 0x80
> > +
> > +//
> > +// Per Redfish Host Interface Specification 1.3, The maximum lenght
> > +of // username and password is 16 characters long.
> > +//
> > +#define USERNAME_MAX_LENGTH  16
> > +#define PASSWORD_MAX_LENGTH  16
> > +#define USERNAME_MAX_SIZE    (USERNAME_MAX_LENGTH + 1)  //
> NULL
> > terminator
> > +#define PASSWORD_MAX_SIZE    (PASSWORD_MAX_LENGTH + 1)  //
> NULL
> > terminator
> > +
> > +#pragma pack(1)
> > +///
> > +/// The definition of IPMI command to get bootstrap account
> > +credentials /// typedef struct {
> > +  UINT8    GroupExtensionId;
> > +  UINT8    DisableBootstrapControl;
> > +} IPMI_BOOTSTRAP_CREDENTIALS_COMMAND_DATA;
> > +
> > +///
> > +/// The response data of getting bootstrap credential /// typedef
> > +struct {
> > +  UINT8    CompletionCode;
> > +  UINT8    GroupExtensionId;
> > +  CHAR8    Username[USERNAME_MAX_LENGTH];
> > +  CHAR8    Password[PASSWORD_MAX_LENGTH];
> > +} IPMI_BOOTSTRAP_CREDENTIALS_RESULT_RESPONSE;
> > +
> > +#pragma pack()
> > +
> > +/**
> > +  Function to retrieve temporary use credentials for the UEFI
> > +redfish client
> [Chang, Abner]
> We miss the functionality to disable bootstrap credential service in
> the function description.
>
> > +
> > +  @param[in]  DisableBootstrapControl
> > +                                      TRUE - Tell the BMC to disable the bootstrap credential
> > +                                             service to ensure no one else gains credentials
> > +                                      FALSE  Allow the bootstrap
> > + credential service to continue  @param[out] BootstrapUsername
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential username
> > +
> > +  @param[out] BootstrapPassword
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential password
> > +
> > +  @retval  EFI_SUCCESS                Credentials were successfully fetched and
> > returned
> [Chang, Abner]
> Or the bootstrap credential service is disabled successfully, right?
>
> > +  @retval  EFI_DEVICE_ERROR           An IPMI failure occurred
> > +**/
> > +EFI_STATUS
> > +GetBootstrapAccountCredentials (
> > +  IN BOOLEAN    DisableBootstrapControl,
> > +  IN OUT CHAR8  *BootstrapUsername,
> > +  IN OUT CHAR8  *BootstrapPassword
> > +  );
> > diff --git
> > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.inf
> > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.inf
> > new file mode 100644
> > index 0000000000..a990d28363
> > --- /dev/null
> > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatfor
> > +++ mC
> > +++ re
> > +++ dentialLib.inf
> > @@ -0,0 +1,37 @@
> > +## @file
> > +#
> > +# Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> > +#
> > +#  SPDX-License-Identifier: BSD-2-Clause-Patent # ##
> > +
> > +[Defines]
> > +  INF_VERSION                    = 0x0001000b
> > +  BASE_NAME                      = RedfishPlatformCredentialLib
> > +  FILE_GUID                      = 9C45D622-4C66-417F-814C-F76246D97233
> > +  MODULE_TYPE                    = DXE_DRIVER
> > +  VERSION_STRING                 = 1.0
> > +  LIBRARY_CLASS                  = RedfishPlatformCredentialLib
> > +
> > +[Sources]
> > +  RedfishPlatformCredentialLib.c
> > +
> > +[Packages]
> > +  MdePkg/MdePkg.dec
> > +  MdeModulePkg/MdeModulePkg.dec
> > +  RedfishPkg/RedfishPkg.dec
> > +  IpmiFeaturePkg/IpmiFeaturePkg.dec
> [Chang, Abner]
> Could you please add a comment to the reference  of IpmiFeaturePkg? We
> have to give customers a notice that the dependence of "edk2-
> platforms/Features/Intel/OutOfBandManagement/". They have to add the
> path to PACKAGES_PATH. You also have to skip this dependence in the
> RedfishPkg.yaml to avoid the CI error.
>
> Another thing is I propose to move out IpmiFeaturePkg from edk2-
> platforms/Features/Intel/OutOfBandManagement to edk2-
> platforms/Features/ManageabilityPkg  that also provides the
> implementation of PLDM/MCTP/IPMI/KCS.  I had an initial talk with
> IpmiFeaturePkg owner and get the positive response on this proposal. I
> will kick off the discussion on the dev mailing list. That is to say
> this module may need a little bit change later, however that is good
> to me having this implementation now.
> Thanks
> Abner
> > +
> > +[LibraryClasses]
> > +  UefiLib
> > +  DebugLib
> > +  IpmiBaseLib
> > +  MemoryAllocationLib
> > +  BaseMemoryLib
> > +
> > +[Pcd]
> > +  gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable
> > +
> > +[Depex]
> > +  TRUE
> > --
> > 2.17.1
>
>
>
>
>
> -The information contained in this message may be confidential and
> proprietary to American Megatrends (AMI). This communication is
> intended to be read only by the individual or entity to whom it is
> addressed or by their designee. If the reader of this message is not
> the intended recipient, you are on notice that any distribution of
> this message, in any form, is strictly prohibited. Please promptly
> notify the sender by reply e-mail or by telephone at 770-246-8600, and
> then delete or destroy all copies of the transmission.
>
>
>
>
>
>
>
>
>
>
> -The information contained in this message may be confidential and
> proprietary to American Megatrends (AMI). This communication is
> intended to be read only by the individual or entity to whom it is
> addressed or by their designee. If the reader of this message is not
> the intended recipient, you are on notice that any distribution of
> this message, in any form, is strictly prohibited. Please promptly
> notify the sender by reply e-mail or by telephone at 770-246-8600, and
> then delete or destroy all copies of the transmission.
>
>
>
>
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


Re: [PATCH V2 1/3] UefiCpuPkg/SmmCpuFeaturesLib: Rename the common C file

Ni, Ray
 

This patch will cause build failure because the INF file is not updated after rename.

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang,
Abner via groups.io
Sent: Sunday, October 30, 2022 9:02 PM
To: devel@edk2.groups.io
Cc: Abdul Lateef Attar <abdattar@...>; Garrett Kirkendall
<garrett.kirkendall@...>; Paul Grimes <paul.grimes@...>; Dong,
Eric <eric.dong@...>; Ni, Ray <ray.ni@...>; Kumar, Rahul R
<rahul.r.kumar@...>
Subject: [edk2-devel] [PATCH V2 1/3] UefiCpuPkg/SmmCpuFeaturesLib:
Rename the common C file

From: Abner Chang <abner.chang@...>

BZ# 4093: Abstract SmmCpuFeaturesLib for sharing common code

Rename SmmCpuFeaturesLiCommon.c to
IntelSmmCpuFeaturesLib, because it was developed
specifically for Intel implementation. The code
that can be shared by other archs or vendors
will be stripped away and put in the common
file in the next patch.

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Abdul Lateef Attar <abdattar@...>
Cc: Garrett Kirkendall <garrett.kirkendall@...>
Cc: Paul Grimes <paul.grimes@...>
Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rahul Kumar <rahul1.kumar@...>
---
.../{SmmCpuFeaturesLibCommon.c => IntelSmmCpuFeaturesLib.c} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename
UefiCpuPkg/Library/SmmCpuFeaturesLib/{SmmCpuFeaturesLibCommon.c =>
IntelSmmCpuFeaturesLib.c} (100%)

diff --git
a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
similarity index 100%
rename from
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c
rename to
UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
--
2.37.1.windows.1





Re: [PATCH EDK2 v1 1/1] ArmPlatformPkg/Drivers/NorFlashDxe:avoid index out of bound

wenyi,xie
 

On 2022/10/30 18:06, Ard Biesheuvel wrote:
On Sat, 29 Oct 2022 at 11:29, Wenyi Xie <xiewenyi2@...> wrote:

The size of array BlockMap is 1 in struct FirmwareVolumeHeader, but in
function InitializeFvAndVariableStoreHeaders, BlockMap[1] is been written.
The size of BlockMap[] is not 1. BlockMap is a flexible array declared
in an old fashioned way, and because the type definition is covered by
the spec, we can not change it. Given that this is established idiom,
compilers don't tend to warn about this.

The memory of BlockMap[1] is already allocated, so the code is OK. But
it is better to use a new point to assign this memory.

Cc: Leif Lindholm <quic_llindhol@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Signed-off-by: Wenyi Xie <xiewenyi2@...>
Thanks for the patch but this driver is going to be deleted soon so no point.

There is new version of this driver in OvmfPkg/ but given the above, I
don't think there is anything that needs fixing here.
Thank you for your answering, I got your point and so it seems no necessary to change.

Best Regards
Wenyi

---
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c
index 0767581308d2..2130e2e76344 100644
--- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c
+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c
@@ -47,6 +47,7 @@ InitializeFvAndVariableStoreHeaders (
VOID *Headers;
UINTN HeadersLength;
EFI_FIRMWARE_VOLUME_HEADER *FirmwareVolumeHeader;
+ EFI_FV_BLOCK_MAP_ENTRY *BlockMapEntry;
VARIABLE_STORE_HEADER *VariableStoreHeader;
UINT32 NvStorageFtwSpareSize;
UINT32 NvStorageFtwWorkingSize;
@@ -151,10 +152,15 @@ InitializeFvAndVariableStoreHeaders (
FirmwareVolumeHeader->Revision = EFI_FVH_REVISION;
FirmwareVolumeHeader->BlockMap[0].NumBlocks = Instance->Media.LastBlock + 1;
FirmwareVolumeHeader->BlockMap[0].Length = Instance->Media.BlockSize;
- FirmwareVolumeHeader->BlockMap[1].NumBlocks = 0;
- FirmwareVolumeHeader->BlockMap[1].Length = 0;
FirmwareVolumeHeader->Checksum = CalculateCheckSum16 ((UINT16 *)FirmwareVolumeHeader, FirmwareVolumeHeader->HeaderLength);

+ //
+ // EFI_FV_BLOCK_MAP_ENTRY
+ //
+ BlockMapEntry = (EFI_FV_BLOCK_MAP_ENTRY *)((UINTN)Headers + sizeof (EFI_FIRMWARE_VOLUME_HEADER));
+ BlockMapEntry->NumBlocks = 0;
+ BlockMapEntry->Length = 0;
+
//
// VARIABLE_STORE_HEADER
//
--
2.20.1.windows.1
.


Event: Tools, CI, Code base construction meeting series - 10/31/2022 #cal-reminder

Group Notification <noreply@...>
 

Reminder: Tools, CI, Code base construction meeting series

When:
10/31/2022
4:30pm to 5:30pm
(UTC-07:00) America/Los Angeles

Where:
https://github.com/tianocore/edk2/discussions/2614

View Event

Description:

TianoCore community,

Microsoft and Intel will be hosting a series of open meetings to discuss build, CI, tools, and other related topics. If you are interested, have ideas/opinions please join us. These meetings will be Monday 4:30pm Pacific Time on Microsoft Teams.

MS Teams Link in following discussion: * https://github.com/tianocore/edk2/discussions/2614

Anyone is welcome to join.

MS Teams Browser Clients * https://docs.microsoft.com/en-us/microsoftteams/get-clients?tabs=Windows#browser-client


Re: [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

Igor Kulchytskyy
 

Hi Abner,
"redfish/v1" does not require any authentication. But "redfish/v1" json response contains the links to high level resources - systems, chassis etc.
My point was to get the URI to systems from that json response, rather than have it hard coded.

If both auth methods supported, we should go with more secured one - session authentication. In this case we do not need to send username and password within each request.

Thank you,
Igor


From: Chang, Abner <Abner.Chang@...>
Sent: Sunday, October 30, 2022 11:33:26 AM
To: Nickle Wang <nicklew@...>; Igor Kulchytskyy <igork@...>; devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Nick Ramirez <nramirez@...>
Subject: RE: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation
 

[AMD Official Use Only - General]

 

Does "/redfish/v1” require authentication? I think this solution is ok if "/redfish/v1” requires the authentication.

Another thing is how do we determine to use Basic authentication or the session token?

 

Abner

 

From: Nickle Wang <nicklew@...>
Sent: Saturday, October 29, 2022 7:29 AM
To: Igor Kulchytskyy <igork@...>; Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io
Cc: Nick Ramirez <nramirez@...>
Subject: Re: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

 

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

 

Hi Igor,

 

Yes, we should get the URI to computer system collection by parsing "/redfish/v1".

 

Hi Abner,

 

What do you think about this? And if we like to select authentication method for Redfish communication in this way, we need to update RedfishCredentialLib.h because now the authentication method is not decided by this low-level library.

 

Thanks,

Nickle


From: Igor Kulchytskyy <igork@...>
Sent: Saturday, October 29, 2022 12:03 AM
To: Nickle Wang <nicklew@...>; Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Nick Ramirez <nramirez@...>
Subject: RE: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

 

External email: Use caution opening links or attachments


Hi Nickle,
I think this is a good idea to send a request to the URI which requires the authentication and then analyze the header of response.
The only thing I would like to discuss is a hardcoded URI - "/redfish/v1/Systems".
Shouldn't we parse "redfish/v1" json response and get the URI from "Systems" attribute.
That, I think, would be more universal method.
And that is what Redfish specification said, that user should be able to iterate from Redfish service root "redfish/v1" to any redfish resource.
Thank you,
Igor



-----Original Message-----
From: Nickle Wang <nicklew@...>
Sent: Friday, October 28, 2022 10:53 AM
To: Igor Kulchytskyy <igork@...>; Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io
Cc: Nick Ramirez <nramirez@...>
Subject: RE: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

Hi Igor, Abner,

Thanks for your comments. A quick summary as below:

- BIOS is not supported to disable bootstrap credential service. For security purposes, BIOS should shutdown credential service with its internal control mechanism.
- Credential libraries need a cache mechanism to prevent multiple queries to BMC. All applications in BIOS share the same credentials.
- The storage of keeping credentials should be deleted before the end of the DXE event. So that the credential will not be retrieved by unauthorized user or application. (e.g. user can read variable under UEFI shell with dmpstore command)

There is one thing remained and I like to have further discussion. For the authentication method, do we think that client user can decide what authentication method to use regardless of the requirement from server? I am thinking a detection mechanism as below:

Issue HTTP GET to "/redfish/v1/Systems" (which normally require authentication) without authentication method.
a) if client receive 200 OK, "No Auth" is used and we don't need to get credentials
b) if client receive 401 Unauthorized, check the "WWW-Authenticate" field in returned HTTP header. "Basic realm" or "X-Auh-Token realm" or both two methods will be specified. Then client can know what method to use. Two methods all require credential.

Above mechanism can be placed in RedfishCredentailDxe driver so driver will know if it needs to call credential lib or not.

Thanks,
Nickle

-----Original Message-----
From: Igor Kulchytskyy <igork@...>
Sent: Friday, October 28, 2022 9:54 PM
To: Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io; Nickle Wang <nicklew@...>
Cc: Nick Ramirez <nramirez@...>
Subject: RE: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

External email: Use caution opening links or attachments


Hi Abner,
Yes, you are right that NVRAM variables were deprecated by DMTF.
But we can use our own boot time NVRAM variable to keep FW credentials. That variable will not be accessible from OS, but since we agreed not to disable bootstrap credentials service on exit boot event, then OS may get its own credentials.
Or we can save the credentials in memory variable. But in this case if we have several instances of the library linked with different modules they will have to send their own IPMI command to get credentials.
So, I think it is better to use our own NVRAM boot time variable.
Thank you,
Igor


-----Original Message-----
From: Chang, Abner <Abner.Chang@...>
Sent: Friday, October 28, 2022 3:48 AM
To: devel@edk2.groups.io; Igor Kulchytskyy <igork@...>; nicklew@...
Cc: Nick Ramirez <nramirez@...>
Subject: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

[AMD Official Use Only - General]



> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Igor
> Kulchytskyy via groups.io
> Sent: Thursday, October 27, 2022 10:42 PM
> To: devel@edk2.groups.io; nicklew@...; Chang, Abner
> <Abner.Chang@...>
> Cc: Nick Ramirez <nramirez@...>
> Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib:
> IPMI implementation
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> Hi Nickle,
> Pleased, see my comments on your questions below.
>
> Another point I missed in my previous mail.
> You have that function in the library to get credentials and it is
> used by RedfishCredentialsDxe driver to create the protocol which in
> its turn will be used by other Redfish modules.
> We do not know how many modules and how many times will call this
> function during boot. Right?
> And on each call of this function you call IPMI command. That command
> will create new Redfish account on BMC side according to Redfish HI specification:
>
> " If the Get Bootstrap Account Credentials command has been issued and
> responds with the completion code 00h, a bootstrap account shall be
> added to the manager's account collection and enabled. If the Get
> Bootstrap Account Credentials command is sent subsequent times and
> responds with the completion code 00h, a new account shall be created
> based on the newly generated credentials. Any existing bootstrap accounts shall remain active."
>
> As I know BMC may have some restrictions on the number of Redfish
> accounts they can support.
> And because of that BOS may hit this limit. Which is not good.
> On the other hand I'm not sure we need to have different credentials
> for different modules? All those modules are part of FW. And all of
> them will be associated with the same RoleID (FW role) on BMC side.
> So, all of them may use the same credentials.
> Could we cash the credentials on first call of that
Yes, this is something we have to avoid. Many accounts will be created while each of Redfish client module requests a credential. FW can save it in EFI variable and delete it at proper timing. Unfortunately the credential delivering via EFI variable section was deprecated, otherwise we can deliver the credential to OS through EFI variable with disabling the bootstrap credential at exit boot service.

Abner

> RedfishCredentialGetAuthInfo and then use those cashed credentials on
> subsequential calls?
> It will also may save a boot time, since there is no need to send IPMI
> command.
>
> Thank you,
> Igor
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Nickle
> Wang via groups.io
> Sent: Thursday, October 27, 2022 9:26 AM
> To: devel@edk2.groups.io; Igor Kulchytskyy <igork@...>;
> abner.chang@...
> Cc: Nick Ramirez <nramirez@...>
> Subject: [EXTERNAL] Re: [edk2-devel] [PATCH]
> RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation
>
>
> **CAUTION: The e-mail below is from an external source. Please
> exercise caution before opening attachments, clicking links, or
> following guidance.**
>
> Hi Igor,
>
> Thank you for your help to review my changes.
>
> > And it will be blocked by our IPMI call.
>
> I see your point. So, BIOS should never be the person to shutdown
> credential service because BIOS always get executed prior to OS, right?
>
> Igor: Yes, my point is that we should not shutdown credential service
> from BIOS. Even if OS sends that IPMI command, new account will be
> created and BIOS credentials will not be compromised.
>
> > Should it be configured with some PCD? Maybe user may select in
> > Setup
> what method should be used? Or it could be build time configuration?
>
> I have below assumption while I implemented the library. I admit this
> is not always true.
>
> No Auth: I think this is rare case for Redfish service which gives
> anonymous privilege to change BIOS settings.
> Basic Auth: this is the authentication method which uses username and
> password to build base64 encoded string.
> Session Auth: I assume that client must have a session token first and
> then use this authentication method. Can we use username and password
> to generate session token on our own? If my memory serves me
> correctly, client has to do a login with username and password first
> and then client can receive session token from server.
>
> Igor: BIOS will use the credentials to create session. It should send
> POST request to the session URI with user name and password to create session.
> If a session created successfully then on response BMC returns header
> "X- Auth-Token" which then used for the subsequential calls.
>
> If we really like to know what authentication method that Redfish
> service used, we can issue a HTTP query to "/redfish/v1/Systems" with "No Auth".
> Then we can know what authentication method is required by reading the
> "WWW-Authenticate " filed in returned HTTP header.
>
> Igor: As my understanding, even if you include authentication header
> (Base64 encoded) in the request to BMC and BMC has NoAuth
> configuration, then that authentication header would be just ignored by BMC.
>
> Thanks,
> Nickle
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Igor
> Kulchytskyy via groups.io
> Sent: Wednesday, October 26, 2022 11:26 PM
> To: Nickle Wang <nicklew@...>; devel@edk2.groups.io;
> abner.chang@...
> Cc: Nick Ramirez <nramirez@...>
> Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib:
> IPMI implementation
>
> External email: Use caution opening links or attachments
>
>
> Hi Nickle,
> I would like to discuss that DisableBootstrapControl flag and how it
> is used in our implementation.
> According to Redfish HI specification we can use this flag to disable
> credential bootstrapping control.
> It can be disabled permanently or till next reboot of the host or
> service. That depend on the  EnableAfterReset  setting on BMC side:
> CredentialBootstrapping (v1.3+)
> { object The credential bootstrapping settings for this interface.
>         EnableAfterReset (v1.3+) Boolean read-write (null) An
> indication of whether credential bootstrapping is enabled after a reset for this interface.
>         Enabled (v1.3+) Boolean read-write (null) An indication of
> whether credential bootstrapping is enabled for this interface.
>         RoleId (v1.3+) string read-write The role used for the
> bootstrap account created for this interface.
> }
> So, if EnableAfterReset set to false, that means BMC will response
> with 0x80 error and will not return any credentials after reboot. And
> BIOS BMC communication will fail.
> Another concern with  disabling credential bootstrapping control is
> that we do it on Exit Boot event before passing a control to OS.
> But OS may also need to communicate to BMC through Redfish Host
> Interface to post some information. And it will be blocked by our IPMI call.
> We create that SMBIOS Type 42 table with Redfish Host Interface
> settings which can be used by OS to communicate with BMC. But without
> the credentials it will not be possible.
>
> Another question is AuthMethod parameter you initialize in this library:
> *AuthMethod = AuthMethodHttpBasic;
> According to Redfish HI specification 3 methods may be used - No Auth,
> Basic Auth and Session Auth.
> Basic Auth and Session Auth methods are required the credentials to be
> used by BIOS. And both of them should be supported by BMC.
> And your high level function RedfishCreateLibredfishService also
> supports of creation Basic or Session Auth service.
> I'm not sure why low level library which is created to get credentials
> from BMC should decide what Authentication method should be used?
> Should it be configured with some PCD? Maybe user may select in Setup
> what method should be used? Or it could be build time configuration?
>
> Thank you,
> Igor
>
> -----Original Message-----
> From: Nickle Wang <nicklew@...>
> Sent: Tuesday, October 25, 2022 4:24 AM
> To: devel@edk2.groups.io; abner.chang@...
> Cc: Nick Ramirez <nramirez@...>; Igor Kulchytskyy
> <igork@...>
> Subject: [EXTERNAL] RE: [edk2-devel] [PATCH]
> RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation
>
>
> **CAUTION: The e-mail below is from an external source. Please
> exercise caution before opening attachments, clicking links, or
> following guidance.**
>
> Thanks for your review comments, Abner! I will update new version
> patch later. The CI build error will be handled together.
>
> > please add Igor as reviewer too
> Sure!
>
>
> > +  *UserId = AllocateZeroPool (sizeof (CHAR8) * USERNAME_MAX_SIZE);
> > + if
> [Chang, Abner]
> Allocation memory with the size (USERNAME_MAX_LENGTH + 1)  for both
> BootUsername and BootstrapPassword?   Because the maximum number of
> characters defined in the spec is USERNAME_MAX_LENGTH for the
> user/password.
>
> Yes, the additional one byte is for NULL terminator.
> USERNAME_MAX_LENGTH is defined as 16 and follow host interface
> specification.
>
> Regards,
> Nickle
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang,
> Abner via groups.io
> Sent: Saturday, October 22, 2022 3:01 PM
> To: Nickle Wang <nicklew@...>; devel@edk2.groups.io
> Cc: Nick Ramirez <nramirez@...>; Igor Kulchytskyy
> <igork@...>
> Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib:
> IPMI implementation
>
> External email: Use caution opening links or attachments
>
>
> [AMD Official Use Only - General]
>
> Hi Nickle, please add Igor as reviewer too. My comments is in below,
>
> > -----Original Message-----
> > From: Nickle Wang <nicklew@...>
> > Sent: Thursday, October 20, 2022 10:55 AM
> > To: devel@edk2.groups.io
> > Cc: Chang, Abner <Abner.Chang@...>; Nick Ramirez
> > <nramirez@...>
> > Subject: [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI
> > implementation
> >
> > Caution: This message originated from an External Source. Use proper
> > caution when opening attachments, clicking links, or responding.
> >
> >
> > This library follows Redfish Host Interface specification and use
> > IPMI command to get bootstrap account credential(NetFn 2Ch, Command
> > 02h)
> from BMC.
> > RedfishHostInterfaceDxe will use this credential for the following
> > communication between BIOS and BMC.
> >
> > Cc: Abner Chang <abner.chang@...>
> > Cc: Nick Ramirez <nramirez@...>
> > Signed-off-by: Nickle Wang <nicklew@...>
> > ---
> >  .../RedfishPlatformCredentialLib.c            | 273 ++++++++++++++++++
> >  .../RedfishPlatformCredentialLib.h            |  75 +++++
> >  .../RedfishPlatformCredentialLib.inf          |  37 +++
> [Chang, Abner]
> Could we name this library RedfishPlatformCredentialIpmi so the naming
> style is consistent with RedfishPlatformCredentialNull?
>
> >  3 files changed, 385 insertions(+)
> >  create mode 100644
> >
> RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredent
> ial
> Lib.
> > c
> >  create mode 100644
> >
> RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredent
> ial
> Lib.
> > h
> >  create mode 100644
> > RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCrede
> > nt
> > ialLib.i
> > nf
> >
> > diff --git
> > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.c
> > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.c
> > new file mode 100644
> > index 0000000000..23a15ab1fa
> > --- /dev/null
> > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatfor
> > +++ mC
> > +++ re
> > +++ dentialLib.c
> > @@ -0,0 +1,273 @@
> > +/** @file
> > +*
> > +*  Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> > +*
> > +*  SPDX-License-Identifier: BSD-2-Clause-Patent
> [Chang, Abner]
> We can have "@par Revision Reference:"  in the file header to point
> out the spec.
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fnam12.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fnam1&amp;data=05%7C01%7Cnicklew%40nvidia.com%7C3f7c98d402b8471f95d408dab8fdeb00%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638025697967855556%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=90NlFqDGaEtk5kMibeuQ3%2FzQNn3ANJn1LcF6RNqsJJ0%3D&amp;reserved=0
> 1.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fnam1
> &amp;data=05%7C01%7Cigork%40ami.com%7C224e78526d7d45a7b31108dab8f42ac1
> %7C27e97857e15f486cb58e86c2b3040f93%7C1%7C0%7C638025656093102767%7CUnk
> nown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWw
> iLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=YN52FOx%2F%2F1YYG8Nl86vu7zlz
> M%2BpLMk3Ym0RNPLxLKqw%3D&amp;reserved=0
> 2.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fnam1
> &amp;data=05%7C01%7Cnicklew%40nvidia.com%7C90696ea8811e49e371a708dab8e
> be2d8%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638025620543993279%
> 7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik
> 1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=CyvRgMZREOk5Yf0hU3CmH%2
> B08ktxMYw%2Bixr4UVywfrAQ%3D&amp;reserved=0
> 1.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fww&a
> mp;data=05%7C01%7Cigork%40ami.com%7C2b5b562c02c04c90d51208dab8b8c0fd%7
> C27e97857e15f486cb58e86c2b3040f93%7C1%7C0%7C638025400915295621%7CUnkno
> wn%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiL
> CJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=Uy%2B3HS336N3rgNSESPcyOPGX3eOR
> 48hekdz08nLtJU4%3D&amp;reserved=0
> w.dmtf.org%2Fsites%2Fdefault%2Ffiles%2Fstandards%2Fdocuments%2FDSP
> 0270_1.3.0.pdf&amp;data=05%7C01%7Cabner.chang%40amd.com%7C074aa
> e162fba49409af408dab8297c03%7C3dd8961fe4884e608e11a82d994e183d%7C
> 0%7C0%7C638024786060127888%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiM
> C4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000
> %7C%7C%7C&amp;sdata=yY6hhKjQfVqmNuufbeDNk%2B2FKrebHyIAyS9Ya4
> szE3Y%3D&amp;reserved=0
>
> > +*
> > +**/
> > +
> > +#include "RedfishPlatformCredentialLib.h"
> > +
> > +//
> > +// Global flag of controlling credential service // BOOLEAN
> > +mRedfishServiceStopped = FALSE;
> > +
> > +/**
> > +  Notify the Redfish service provide to stop provide configuration
> > +service to this
> > platform.
> > +
> > +  This function should be called when the platfrom is about to
> > + leave the safe
> > environment.
> > +  It will notify the Redfish service provider to abort all logined
> > + session, and prohibit  further login with original auth info.
> > + GetAuthInfo() will return EFI_UNSUPPORTED once this  function is
> returned.
> > +
> > +  @param[in]   This                Pointer to
> > EDKII_REDFISH_CREDENTIAL_PROTOCOL instance.
> > +  @param[in]   ServiceStopType     Reason of stopping Redfish service.
> > +
> > +  @retval EFI_SUCCESS              Service has been stoped successfully.
> > +  @retval EFI_INVALID_PARAMETER    This is NULL.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +LibStopRedfishService (
> > +  IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL           *This,
> > +  IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE
> ServiceStopType
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +
> > +  if ((ServiceStopType <= ServiceStopTypeNone) || (ServiceStopType
> > + >=
> > ServiceStopTypeMax)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  //
> > +  // Raise flag first
> > +  //
> > +  mRedfishServiceStopped = TRUE;
> > +
> > +  //
> > +  // Notify BMC to disable credential bootstrapping support.
> > +  //
> > +  Status = GetBootstrapAccountCredentials (TRUE, NULL, NULL);  if
> > + (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: fail to disable bootstrap credential:
> > + %r\n",
> > __FUNCTION__, Status));
> > +    return Status;
> > +  }
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +/**
> > +  Notification of Exit Boot Service.
> > +
> > +  @param[in]  This    Pointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL.
> > +**/
> > +VOID
> > +EFIAPI
> > +LibCredentialExitBootServicesNotify (
> > +  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
> > +  )
> > +{
> > +  //
> > +  // Stop the credential support when system is about to enter OS.
> > +  //
> > +  LibStopRedfishService (This, ServiceStopTypeExitBootService); }
> > +
> > +/**
> > +  Notification of End of DXe.
> > +
> > +  @param[in]  This    Pointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL.
> > +**/
> > +VOID
> > +EFIAPI
> > +LibCredentialEndOfDxeNotify (
> > +  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
> > +  )
> > +{
> > +  //
> > +  // Do nothing now.
> > +  // We can stop credential support when system reach end-of-dxe
> > +for security
> > reason.
> > +  //
> > +}
> > +
> > +/**
> > +  Function to retrieve temporary use credentials for the UEFI
> > +redfish client
> [Chang, Abner]
> We miss the functionality to disable bootstrap credential service in
> the function description.
>
> > +
> > +  @param[in]  DisableBootstrapControl
> > +                                      TRUE - Tell the BMC to disable the bootstrap credential
> > +                                             service to ensure no one else gains credentials
> > +                                      FALSE  Allow the bootstrap
> > + credential service to continue  @param[out] BootstrapUsername
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential
> > username
> > +                                      When DisableBootstrapControl
> > + is TRUE, this pointer can be NULL
> > +
> > +  @param[out] BootstrapPassword
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential
> > password
> > +                                      When DisableBootstrapControl
> > + is TRUE, this pointer can be NULL
> > +
> > +  @retval  EFI_SUCCESS                Credentials were successfully fetched and
> > returned
> > +  @retval  EFI_INVALID_PARAMETER      BootstrapUsername or
> > BootstrapPassword is NULL when DisableBootstrapControl
> > +                                      is set to FALSE
> > +  @retval  EFI_DEVICE_ERROR           An IPMI failure occurred
> [Chang, Abner]
> The return status should also include the status of disabling
> bootstrap credential.
>
>
> > +**/
> > +EFI_STATUS
> > +GetBootstrapAccountCredentials (
> > +  IN BOOLEAN DisableBootstrapControl,
> > +  IN OUT CHAR8 *BootstrapUsername, OPTIONAL
> > +  IN OUT CHAR8  *BootstrapPassword    OPTIONAL
> > +  )
> > +{
> > +  EFI_STATUS                                  Status;
> > +  IPMI_BOOTSTRAP_CREDENTIALS_COMMAND_DATA     CommandData;
> > +  IPMI_BOOTSTRAP_CREDENTIALS_RESULT_RESPONSE  ResponseData;
> > +  UINT32                                      ResponseSize;
> > +
> > +  if (!PcdGetBool (PcdIpmiFeatureEnable)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: IPMI is not enabled! Unable to fetch
> > + Redfish
> > credentials\n", __FUNCTION__));
> > +    return EFI_UNSUPPORTED;
> > +  }
> > +
> > +  //
> > +  // NULL buffer check
> > +  //
> > +  if (!DisableBootstrapControl && ((BootstrapUsername == NULL) ||
> > (BootstrapPassword == NULL))) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  DEBUG ((DEBUG_VERBOSE, "%a: Disable bootstrap control: 0x%x\n",
> > + __FUNCTION__, DisableBootstrapControl));
> > +
> > +  //
> > +  // IPMI callout to NetFn 2C, command 02
> > +  //    Request data:
> > +  //      Byte 1: REDFISH_IPMI_GROUP_EXTENSION
> > +  //      Byte 2: DisableBootstrapControl
> > +  //
> > +  CommandData.GroupExtensionId        =
> REDFISH_IPMI_GROUP_EXTENSION;
> > +  CommandData.DisableBootstrapControl = (DisableBootstrapControl ?
> > + REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_DISABLE :
> > + REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_ENABLE);
> > +
> > +  ResponseSize = sizeof (ResponseData);
> > +
> > +  //
> > +  //    Response data:
> > +  //      Byte 1    : Completion code
> > +  //      Byte 2    : REDFISH_IPMI_GROUP_EXTENSION
> > +  //      Byte 3-18 : Username
> > +  //      Byte 19-34: Password
> > +  //
> > +  Status = IpmiSubmitCommand (
> > +             IPMI_NETFN_GROUP_EXT,
> > +             REDFISH_IPMI_GET_BOOTSTRAP_CREDENTIALS_CMD,
> > +             (UINT8 *)&CommandData,
> > +             sizeof (CommandData),
> > +             (UINT8 *)&ResponseData,
> > +             &ResponseSize
> > +             );
> > +
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: IPMI transaction failure.
> > + Returning\n",
> > __FUNCTION__));
> > +    ASSERT_EFI_ERROR (Status);
> > +    return Status;
> > +  } else {
> > +    if (ResponseData.CompletionCode != IPMI_COMP_CODE_NORMAL) {
> > +      if (ResponseData.CompletionCode ==
> > REDFISH_IPMI_COMP_CODE_BOOTSTRAP_CREDENTIAL_DISABLED) {
> > +        DEBUG ((DEBUG_ERROR, "%a: bootstrap credential support was
> > disabled\n", __FUNCTION__));
> > +        return EFI_ACCESS_DENIED;
> > +      }
> > +
> > +      DEBUG ((DEBUG_ERROR, "%a: Completion code = 0x%x.
> > + Returning\n",
> > __FUNCTION__, ResponseData.CompletionCode));
> > +      return EFI_PROTOCOL_ERROR;
> > +    } else if (ResponseData.GroupExtensionId !=
> > REDFISH_IPMI_GROUP_EXTENSION) {
> > +      DEBUG ((DEBUG_ERROR, "%a: Group Extension Response = 0x%x.
> > Returning\n", __FUNCTION__, ResponseData.GroupExtensionId));
> > +      return EFI_DEVICE_ERROR;
> > +    } else {
> > +      if (BootstrapUsername != NULL) {
> > +        CopyMem (BootstrapUsername, ResponseData.Username,
> > USERNAME_MAX_LENGTH);
> > +        //
> > +        // Manually append null-terminator in case 16 characters
> > + username
> > returned.
> > +        //
> > +        BootstrapUsername[USERNAME_MAX_LENGTH] = '\0';
> > +      }
> > +
> > +      if (BootstrapPassword != NULL) {
> > +        CopyMem (BootstrapPassword, ResponseData.Password,
> > PASSWORD_MAX_LENGTH);
> > +        //
> > +        // Manually append null-terminator in case 16 characters
> > + password
> > returned.
> > +        //
> > +        BootstrapPassword[PASSWORD_MAX_LENGTH] = '\0';
> > +      }
> > +    }
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +/**
> > +  Retrieve platform's Redfish authentication information.
> > +
> > +  This functions returns the Redfish authentication method together
> > + with the user Id and  password.
> > +  - For AuthMethodNone, the UserId and Password could be used for
> > + HTTP
> > header authentication
> > +    as defined by RFC7235.
> > +  - For AuthMethodRedfishSession, the UserId and Password could be
> > + used for
> > Redfish
> > +    session login as defined by  Redfish API specification (DSP0266).
> > +
> > +  Callers are responsible for and freeing the returned string storage.
> > +
> > +  @param[in]   This                Pointer to
> > EDKII_REDFISH_CREDENTIAL_PROTOCOL instance.
> > +  @param[out]  AuthMethod          Type of Redfish authentication method.
> > +  @param[out]  UserId              The pointer to store the returned UserId
> string.
> > +  @param[out]  Password            The pointer to store the returned
> Password
> > string.
> > +
> > +  @retval EFI_SUCCESS              Get the authentication information
> successfully.
> > +  @retval EFI_ACCESS_DENIED        SecureBoot is disabled after EndOfDxe.
> > +  @retval EFI_INVALID_PARAMETER    This or AuthMethod or UserId or
> > Password is NULL.
> > +  @retval EFI_OUT_OF_RESOURCES     There are not enough memory
> resources.
> > +  @retval EFI_UNSUPPORTED          Unsupported authentication method is
> > found.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +LibCredentialGetAuthInfo (
> > +  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This,
> > +  OUT EDKII_REDFISH_AUTH_METHOD          *AuthMethod,
> > +  OUT CHAR8                              **UserId,
> > +  OUT CHAR8                              **Password
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +
> > +  if ((AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  *UserId   = NULL;
> > +  *Password = NULL;
> > +
> > +  if (mRedfishServiceStopped) {
> > +    DEBUG ((DEBUG_ERROR, "%a: credential service is stopped due to
> > + security
> > reason\n", __FUNCTION__));
> > +    return EFI_ACCESS_DENIED;
> > +  }
> > +
> > +  *AuthMethod = AuthMethodHttpBasic;
> > +
> > +  *UserId = AllocateZeroPool (sizeof (CHAR8) * USERNAME_MAX_SIZE);
> > + if
> [Chang, Abner]
> Allocation memory with the size (USERNAME_MAX_LENGTH + 1)  for both
> BootUsername and BootstrapPassword?   Because the maximum number of
> characters defined in the spec is USERNAME_MAX_LENGTH for the
> user/password.
>
>
> > + (*UserId == NULL) {
> > +    return EFI_OUT_OF_RESOURCES;
> > +  }
> > +
> > +  *Password = AllocateZeroPool (sizeof (CHAR8) *
> > + PASSWORD_MAX_SIZE); if (*Password == NULL) {
> > +    return EFI_OUT_OF_RESOURCES;
> > +  }
> > +
> > +  Status = GetBootstrapAccountCredentials (FALSE, *UserId,
> > + *Password); if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: fail to get bootstrap credential:
> > + %r\n",
> > __FUNCTION__, Status));
> > +    return Status;
> > +  }
> > +
> > +  return EFI_SUCCESS;
> > +}
> > diff --git
> > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.h
> > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.h
> > new file mode 100644
> > index 0000000000..5b448e01be
> > --- /dev/null
> > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatfor
> > +++ mC
> > +++ re
> > +++ dentialLib.h
> > @@ -0,0 +1,75 @@
> > +/** @file
> > +*
> > +*  Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> > +*
> > +*  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +*
> > +**/
> > +#include <Uefi.h>
> > +#include <IndustryStandard/Ipmi.h>
> > +#include <Protocol/EdkIIRedfishCredential.h>
> > +#include <Library/BaseLib.h>
> > +#include <Library/BaseMemoryLib.h>
> > +#include <Library/DebugLib.h>
> > +#include <Library/IpmiBaseLib.h>
> > +#include <Library/MemoryAllocationLib.h> #include
> > +<Library/RedfishCredentialLib.h>
> > +
> > +#define REDFISH_IPMI_GROUP_EXTENSION                          0x52
> > +#define REDFISH_IPMI_GET_BOOTSTRAP_CREDENTIALS_CMD            0x02
> > +#define REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_ENABLE              0xA5
> > +#define REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_DISABLE             0x00
> > +#define
> REDFISH_IPMI_COMP_CODE_BOOTSTRAP_CREDENTIAL_DISABLED
> > 0x80
> > +
> > +//
> > +// Per Redfish Host Interface Specification 1.3, The maximum lenght
> > +of // username and password is 16 characters long.
> > +//
> > +#define USERNAME_MAX_LENGTH  16
> > +#define PASSWORD_MAX_LENGTH  16
> > +#define USERNAME_MAX_SIZE    (USERNAME_MAX_LENGTH + 1)  //
> NULL
> > terminator
> > +#define PASSWORD_MAX_SIZE    (PASSWORD_MAX_LENGTH + 1)  //
> NULL
> > terminator
> > +
> > +#pragma pack(1)
> > +///
> > +/// The definition of IPMI command to get bootstrap account
> > +credentials /// typedef struct {
> > +  UINT8    GroupExtensionId;
> > +  UINT8    DisableBootstrapControl;
> > +} IPMI_BOOTSTRAP_CREDENTIALS_COMMAND_DATA;
> > +
> > +///
> > +/// The response data of getting bootstrap credential /// typedef
> > +struct {
> > +  UINT8    CompletionCode;
> > +  UINT8    GroupExtensionId;
> > +  CHAR8    Username[USERNAME_MAX_LENGTH];
> > +  CHAR8    Password[PASSWORD_MAX_LENGTH];
> > +} IPMI_BOOTSTRAP_CREDENTIALS_RESULT_RESPONSE;
> > +
> > +#pragma pack()
> > +
> > +/**
> > +  Function to retrieve temporary use credentials for the UEFI
> > +redfish client
> [Chang, Abner]
> We miss the functionality to disable bootstrap credential service in
> the function description.
>
> > +
> > +  @param[in]  DisableBootstrapControl
> > +                                      TRUE - Tell the BMC to disable the bootstrap credential
> > +                                             service to ensure no one else gains credentials
> > +                                      FALSE  Allow the bootstrap
> > + credential service to continue  @param[out] BootstrapUsername
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential username
> > +
> > +  @param[out] BootstrapPassword
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential password
> > +
> > +  @retval  EFI_SUCCESS                Credentials were successfully fetched and
> > returned
> [Chang, Abner]
> Or the bootstrap credential service is disabled successfully, right?
>
> > +  @retval  EFI_DEVICE_ERROR           An IPMI failure occurred
> > +**/
> > +EFI_STATUS
> > +GetBootstrapAccountCredentials (
> > +  IN BOOLEAN    DisableBootstrapControl,
> > +  IN OUT CHAR8  *BootstrapUsername,
> > +  IN OUT CHAR8  *BootstrapPassword
> > +  );
> > diff --git
> > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.inf
> > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.inf
> > new file mode 100644
> > index 0000000000..a990d28363
> > --- /dev/null
> > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatfor
> > +++ mC
> > +++ re
> > +++ dentialLib.inf
> > @@ -0,0 +1,37 @@
> > +## @file
> > +#
> > +# Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> > +#
> > +#  SPDX-License-Identifier: BSD-2-Clause-Patent # ##
> > +
> > +[Defines]
> > +  INF_VERSION                    = 0x0001000b
> > +  BASE_NAME                      = RedfishPlatformCredentialLib
> > +  FILE_GUID                      = 9C45D622-4C66-417F-814C-F76246D97233
> > +  MODULE_TYPE                    = DXE_DRIVER
> > +  VERSION_STRING                 = 1.0
> > +  LIBRARY_CLASS                  = RedfishPlatformCredentialLib
> > +
> > +[Sources]
> > +  RedfishPlatformCredentialLib.c
> > +
> > +[Packages]
> > +  MdePkg/MdePkg.dec
> > +  MdeModulePkg/MdeModulePkg.dec
> > +  RedfishPkg/RedfishPkg.dec
> > +  IpmiFeaturePkg/IpmiFeaturePkg.dec
> [Chang, Abner]
> Could you please add a comment to the reference  of IpmiFeaturePkg? We
> have to give customers a notice that the dependence of "edk2-
> platforms/Features/Intel/OutOfBandManagement/". They have to add the
> path to PACKAGES_PATH. You also have to skip this dependence in the
> RedfishPkg.yaml to avoid the CI error.
>
> Another thing is I propose to move out IpmiFeaturePkg from edk2-
> platforms/Features/Intel/OutOfBandManagement to edk2-
> platforms/Features/ManageabilityPkg  that also provides the
> implementation of PLDM/MCTP/IPMI/KCS.  I had an initial talk with
> IpmiFeaturePkg owner and get the positive response on this proposal. I
> will kick off the discussion on the dev mailing list. That is to say
> this module may need a little bit change later, however that is good
> to me having this implementation now.
> Thanks
> Abner
> > +
> > +[LibraryClasses]
> > +  UefiLib
> > +  DebugLib
> > +  IpmiBaseLib
> > +  MemoryAllocationLib
> > +  BaseMemoryLib
> > +
> > +[Pcd]
> > +  gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable
> > +
> > +[Depex]
> > +  TRUE
> > --
> > 2.17.1
>
>
>
>
>
> -The information contained in this message may be confidential and
> proprietary to American Megatrends (AMI). This communication is
> intended to be read only by the individual or entity to whom it is
> addressed or by their designee. If the reader of this message is not
> the intended recipient, you are on notice that any distribution of
> this message, in any form, is strictly prohibited. Please promptly
> notify the sender by reply e-mail or by telephone at 770-246-8600, and
> then delete or destroy all copies of the transmission.
>
>
>
>
>
>
>
>
>
>
> -The information contained in this message may be confidential and
> proprietary to American Megatrends (AMI). This communication is
> intended to be read only by the individual or entity to whom it is
> addressed or by their designee. If the reader of this message is not
> the intended recipient, you are on notice that any distribution of
> this message, in any form, is strictly prohibited. Please promptly
> notify the sender by reply e-mail or by telephone at 770-246-8600, and
> then delete or destroy all copies of the transmission.
>
>
>
>
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


Re: [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

Chang, Abner
 

[AMD Official Use Only - General]

 

Does "/redfish/v1” require authentication? I think this solution is ok if "/redfish/v1” requires the authentication.

Another thing is how do we determine to use Basic authentication or the session token?

 

Abner

 

From: Nickle Wang <nicklew@...>
Sent: Saturday, October 29, 2022 7:29 AM
To: Igor Kulchytskyy <igork@...>; Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io
Cc: Nick Ramirez <nramirez@...>
Subject: Re: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

 

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

 

Hi Igor,

 

Yes, we should get the URI to computer system collection by parsing "/redfish/v1".

 

Hi Abner,

 

What do you think about this? And if we like to select authentication method for Redfish communication in this way, we need to update RedfishCredentialLib.h because now the authentication method is not decided by this low-level library.

 

Thanks,

Nickle


From: Igor Kulchytskyy <igork@...>
Sent: Saturday, October 29, 2022 12:03 AM
To: Nickle Wang <nicklew@...>; Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Nick Ramirez <nramirez@...>
Subject: RE: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

 

External email: Use caution opening links or attachments


Hi Nickle,
I think this is a good idea to send a request to the URI which requires the authentication and then analyze the header of response.
The only thing I would like to discuss is a hardcoded URI - "/redfish/v1/Systems".
Shouldn't we parse "redfish/v1" json response and get the URI from "Systems" attribute.
That, I think, would be more universal method.
And that is what Redfish specification said, that user should be able to iterate from Redfish service root "redfish/v1" to any redfish resource.
Thank you,
Igor



-----Original Message-----
From: Nickle Wang <nicklew@...>
Sent: Friday, October 28, 2022 10:53 AM
To: Igor Kulchytskyy <igork@...>; Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io
Cc: Nick Ramirez <nramirez@...>
Subject: RE: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

Hi Igor, Abner,

Thanks for your comments. A quick summary as below:

- BIOS is not supported to disable bootstrap credential service. For security purposes, BIOS should shutdown credential service with its internal control mechanism.
- Credential libraries need a cache mechanism to prevent multiple queries to BMC. All applications in BIOS share the same credentials.
- The storage of keeping credentials should be deleted before the end of the DXE event. So that the credential will not be retrieved by unauthorized user or application. (e.g. user can read variable under UEFI shell with dmpstore command)

There is one thing remained and I like to have further discussion. For the authentication method, do we think that client user can decide what authentication method to use regardless of the requirement from server? I am thinking a detection mechanism as below:

Issue HTTP GET to "/redfish/v1/Systems" (which normally require authentication) without authentication method.
a) if client receive 200 OK, "No Auth" is used and we don't need to get credentials
b) if client receive 401 Unauthorized, check the "WWW-Authenticate" field in returned HTTP header. "Basic realm" or "X-Auh-Token realm" or both two methods will be specified. Then client can know what method to use. Two methods all require credential.

Above mechanism can be placed in RedfishCredentailDxe driver so driver will know if it needs to call credential lib or not.

Thanks,
Nickle

-----Original Message-----
From: Igor Kulchytskyy <igork@...>
Sent: Friday, October 28, 2022 9:54 PM
To: Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io; Nickle Wang <nicklew@...>
Cc: Nick Ramirez <nramirez@...>
Subject: RE: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation

External email: Use caution opening links or attachments


Hi Abner,
Yes, you are right that NVRAM variables were deprecated by DMTF.
But we can use our own boot time NVRAM variable to keep FW credentials. That variable will not be accessible from OS, but since we agreed not to disable bootstrap credentials service on exit boot event, then OS may get its own credentials.
Or we can save the credentials in memory variable. But in this case if we have several instances of the library linked with different modules they will have to send their own IPMI command to get credentials.
So, I think it is better to use our own NVRAM boot time variable.
Thank you,
Igor


-----Original Message-----
From: Chang, Abner <Abner.Chang@...>
Sent: Friday, October 28, 2022 3:48 AM
To: devel@edk2.groups.io; Igor Kulchytskyy <igork@...>; nicklew@...
Cc: Nick Ramirez <nramirez@...>
Subject: [EXTERNAL] RE: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

[AMD Official Use Only - General]



> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Igor
> Kulchytskyy via groups.io
> Sent: Thursday, October 27, 2022 10:42 PM
> To: devel@edk2.groups.io; nicklew@...; Chang, Abner
> <Abner.Chang@...>
> Cc: Nick Ramirez <nramirez@...>
> Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib:
> IPMI implementation
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> Hi Nickle,
> Pleased, see my comments on your questions below.
>
> Another point I missed in my previous mail.
> You have that function in the library to get credentials and it is
> used by RedfishCredentialsDxe driver to create the protocol which in
> its turn will be used by other Redfish modules.
> We do not know how many modules and how many times will call this
> function during boot. Right?
> And on each call of this function you call IPMI command. That command
> will create new Redfish account on BMC side according to Redfish HI specification:
>
> " If the Get Bootstrap Account Credentials command has been issued and
> responds with the completion code 00h, a bootstrap account shall be
> added to the manager's account collection and enabled. If the Get
> Bootstrap Account Credentials command is sent subsequent times and
> responds with the completion code 00h, a new account shall be created
> based on the newly generated credentials. Any existing bootstrap accounts shall remain active."
>
> As I know BMC may have some restrictions on the number of Redfish
> accounts they can support.
> And because of that BOS may hit this limit. Which is not good.
> On the other hand I'm not sure we need to have different credentials
> for different modules? All those modules are part of FW. And all of
> them will be associated with the same RoleID (FW role) on BMC side.
> So, all of them may use the same credentials.
> Could we cash the credentials on first call of that
Yes, this is something we have to avoid. Many accounts will be created while each of Redfish client module requests a credential. FW can save it in EFI variable and delete it at proper timing. Unfortunately the credential delivering via EFI variable section was deprecated, otherwise we can deliver the credential to OS through EFI variable with disabling the bootstrap credential at exit boot service.

Abner

> RedfishCredentialGetAuthInfo and then use those cashed credentials on
> subsequential calls?
> It will also may save a boot time, since there is no need to send IPMI
> command.
>
> Thank you,
> Igor
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Nickle
> Wang via groups.io
> Sent: Thursday, October 27, 2022 9:26 AM
> To: devel@edk2.groups.io; Igor Kulchytskyy <igork@...>;
> abner.chang@...
> Cc: Nick Ramirez <nramirez@...>
> Subject: [EXTERNAL] Re: [edk2-devel] [PATCH]
> RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation
>
>
> **CAUTION: The e-mail below is from an external source. Please
> exercise caution before opening attachments, clicking links, or
> following guidance.**
>
> Hi Igor,
>
> Thank you for your help to review my changes.
>
> > And it will be blocked by our IPMI call.
>
> I see your point. So, BIOS should never be the person to shutdown
> credential service because BIOS always get executed prior to OS, right?
>
> Igor: Yes, my point is that we should not shutdown credential service
> from BIOS. Even if OS sends that IPMI command, new account will be
> created and BIOS credentials will not be compromised.
>
> > Should it be configured with some PCD? Maybe user may select in
> > Setup
> what method should be used? Or it could be build time configuration?
>
> I have below assumption while I implemented the library. I admit this
> is not always true.
>
> No Auth: I think this is rare case for Redfish service which gives
> anonymous privilege to change BIOS settings.
> Basic Auth: this is the authentication method which uses username and
> password to build base64 encoded string.
> Session Auth: I assume that client must have a session token first and
> then use this authentication method. Can we use username and password
> to generate session token on our own? If my memory serves me
> correctly, client has to do a login with username and password first
> and then client can receive session token from server.
>
> Igor: BIOS will use the credentials to create session. It should send
> POST request to the session URI with user name and password to create session.
> If a session created successfully then on response BMC returns header
> "X- Auth-Token" which then used for the subsequential calls.
>
> If we really like to know what authentication method that Redfish
> service used, we can issue a HTTP query to "/redfish/v1/Systems" with "No Auth".
> Then we can know what authentication method is required by reading the
> "WWW-Authenticate " filed in returned HTTP header.
>
> Igor: As my understanding, even if you include authentication header
> (Base64 encoded) in the request to BMC and BMC has NoAuth
> configuration, then that authentication header would be just ignored by BMC.
>
> Thanks,
> Nickle
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Igor
> Kulchytskyy via groups.io
> Sent: Wednesday, October 26, 2022 11:26 PM
> To: Nickle Wang <nicklew@...>; devel@edk2.groups.io;
> abner.chang@...
> Cc: Nick Ramirez <nramirez@...>
> Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib:
> IPMI implementation
>
> External email: Use caution opening links or attachments
>
>
> Hi Nickle,
> I would like to discuss that DisableBootstrapControl flag and how it
> is used in our implementation.
> According to Redfish HI specification we can use this flag to disable
> credential bootstrapping control.
> It can be disabled permanently or till next reboot of the host or
> service. That depend on the  EnableAfterReset  setting on BMC side:
> CredentialBootstrapping (v1.3+)
> { object The credential bootstrapping settings for this interface.
>         EnableAfterReset (v1.3+) Boolean read-write (null) An
> indication of whether credential bootstrapping is enabled after a reset for this interface.
>         Enabled (v1.3+) Boolean read-write (null) An indication of
> whether credential bootstrapping is enabled for this interface.
>         RoleId (v1.3+) string read-write The role used for the
> bootstrap account created for this interface.
> }
> So, if EnableAfterReset set to false, that means BMC will response
> with 0x80 error and will not return any credentials after reboot. And
> BIOS BMC communication will fail.
> Another concern with  disabling credential bootstrapping control is
> that we do it on Exit Boot event before passing a control to OS.
> But OS may also need to communicate to BMC through Redfish Host
> Interface to post some information. And it will be blocked by our IPMI call.
> We create that SMBIOS Type 42 table with Redfish Host Interface
> settings which can be used by OS to communicate with BMC. But without
> the credentials it will not be possible.
>
> Another question is AuthMethod parameter you initialize in this library:
> *AuthMethod = AuthMethodHttpBasic;
> According to Redfish HI specification 3 methods may be used - No Auth,
> Basic Auth and Session Auth.
> Basic Auth and Session Auth methods are required the credentials to be
> used by BIOS. And both of them should be supported by BMC.
> And your high level function RedfishCreateLibredfishService also
> supports of creation Basic or Session Auth service.
> I'm not sure why low level library which is created to get credentials
> from BMC should decide what Authentication method should be used?
> Should it be configured with some PCD? Maybe user may select in Setup
> what method should be used? Or it could be build time configuration?
>
> Thank you,
> Igor
>
> -----Original Message-----
> From: Nickle Wang <nicklew@...>
> Sent: Tuesday, October 25, 2022 4:24 AM
> To: devel@edk2.groups.io; abner.chang@...
> Cc: Nick Ramirez <nramirez@...>; Igor Kulchytskyy
> <igork@...>
> Subject: [EXTERNAL] RE: [edk2-devel] [PATCH]
> RedfishPkg/RedfishPlatformCredentialLib: IPMI implementation
>
>
> **CAUTION: The e-mail below is from an external source. Please
> exercise caution before opening attachments, clicking links, or
> following guidance.**
>
> Thanks for your review comments, Abner! I will update new version
> patch later. The CI build error will be handled together.
>
> > please add Igor as reviewer too
> Sure!
>
>
> > +  *UserId = AllocateZeroPool (sizeof (CHAR8) * USERNAME_MAX_SIZE);
> > + if
> [Chang, Abner]
> Allocation memory with the size (USERNAME_MAX_LENGTH + 1)  for both
> BootUsername and BootstrapPassword?   Because the maximum number of
> characters defined in the spec is USERNAME_MAX_LENGTH for the
> user/password.
>
> Yes, the additional one byte is for NULL terminator.
> USERNAME_MAX_LENGTH is defined as 16 and follow host interface
> specification.
>
> Regards,
> Nickle
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang,
> Abner via groups.io
> Sent: Saturday, October 22, 2022 3:01 PM
> To: Nickle Wang <nicklew@...>; devel@edk2.groups.io
> Cc: Nick Ramirez <nramirez@...>; Igor Kulchytskyy
> <igork@...>
> Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformCredentialLib:
> IPMI implementation
>
> External email: Use caution opening links or attachments
>
>
> [AMD Official Use Only - General]
>
> Hi Nickle, please add Igor as reviewer too. My comments is in below,
>
> > -----Original Message-----
> > From: Nickle Wang <nicklew@...>
> > Sent: Thursday, October 20, 2022 10:55 AM
> > To: devel@edk2.groups.io
> > Cc: Chang, Abner <Abner.Chang@...>; Nick Ramirez
> > <nramirez@...>
> > Subject: [PATCH] RedfishPkg/RedfishPlatformCredentialLib: IPMI
> > implementation
> >
> > Caution: This message originated from an External Source. Use proper
> > caution when opening attachments, clicking links, or responding.
> >
> >
> > This library follows Redfish Host Interface specification and use
> > IPMI command to get bootstrap account credential(NetFn 2Ch, Command
> > 02h)
> from BMC.
> > RedfishHostInterfaceDxe will use this credential for the following
> > communication between BIOS and BMC.
> >
> > Cc: Abner Chang <abner.chang@...>
> > Cc: Nick Ramirez <nramirez@...>
> > Signed-off-by: Nickle Wang <nicklew@...>
> > ---
> >  .../RedfishPlatformCredentialLib.c            | 273 ++++++++++++++++++
> >  .../RedfishPlatformCredentialLib.h            |  75 +++++
> >  .../RedfishPlatformCredentialLib.inf          |  37 +++
> [Chang, Abner]
> Could we name this library RedfishPlatformCredentialIpmi so the naming
> style is consistent with RedfishPlatformCredentialNull?
>
> >  3 files changed, 385 insertions(+)
> >  create mode 100644
> >
> RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredent
> ial
> Lib.
> > c
> >  create mode 100644
> >
> RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredent
> ial
> Lib.
> > h
> >  create mode 100644
> > RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCrede
> > nt
> > ialLib.i
> > nf
> >
> > diff --git
> > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.c
> > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.c
> > new file mode 100644
> > index 0000000000..23a15ab1fa
> > --- /dev/null
> > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatfor
> > +++ mC
> > +++ re
> > +++ dentialLib.c
> > @@ -0,0 +1,273 @@
> > +/** @file
> > +*
> > +*  Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> > +*
> > +*  SPDX-License-Identifier: BSD-2-Clause-Patent
> [Chang, Abner]
> We can have "@par Revision Reference:"  in the file header to point
> out the spec.
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fnam12.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fnam1&amp;data=05%7C01%7Cnicklew%40nvidia.com%7C3f7c98d402b8471f95d408dab8fdeb00%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638025697967855556%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=90NlFqDGaEtk5kMibeuQ3%2FzQNn3ANJn1LcF6RNqsJJ0%3D&amp;reserved=0
> 1.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fnam1
> &amp;data=05%7C01%7Cigork%40ami.com%7C224e78526d7d45a7b31108dab8f42ac1
> %7C27e97857e15f486cb58e86c2b3040f93%7C1%7C0%7C638025656093102767%7CUnk
> nown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWw
> iLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=YN52FOx%2F%2F1YYG8Nl86vu7zlz
> M%2BpLMk3Ym0RNPLxLKqw%3D&amp;reserved=0
> 2.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fnam1
> &amp;data=05%7C01%7Cnicklew%40nvidia.com%7C90696ea8811e49e371a708dab8e
> be2d8%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638025620543993279%
> 7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik
> 1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=CyvRgMZREOk5Yf0hU3CmH%2
> B08ktxMYw%2Bixr4UVywfrAQ%3D&amp;reserved=0
> 1.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fww&a
> mp;data=05%7C01%7Cigork%40ami.com%7C2b5b562c02c04c90d51208dab8b8c0fd%7
> C27e97857e15f486cb58e86c2b3040f93%7C1%7C0%7C638025400915295621%7CUnkno
> wn%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiL
> CJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=Uy%2B3HS336N3rgNSESPcyOPGX3eOR
> 48hekdz08nLtJU4%3D&amp;reserved=0
> w.dmtf.org%2Fsites%2Fdefault%2Ffiles%2Fstandards%2Fdocuments%2FDSP
> 0270_1.3.0.pdf&amp;data=05%7C01%7Cabner.chang%40amd.com%7C074aa
> e162fba49409af408dab8297c03%7C3dd8961fe4884e608e11a82d994e183d%7C
> 0%7C0%7C638024786060127888%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiM
> C4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000
> %7C%7C%7C&amp;sdata=yY6hhKjQfVqmNuufbeDNk%2B2FKrebHyIAyS9Ya4
> szE3Y%3D&amp;reserved=0
>
> > +*
> > +**/
> > +
> > +#include "RedfishPlatformCredentialLib.h"
> > +
> > +//
> > +// Global flag of controlling credential service // BOOLEAN
> > +mRedfishServiceStopped = FALSE;
> > +
> > +/**
> > +  Notify the Redfish service provide to stop provide configuration
> > +service to this
> > platform.
> > +
> > +  This function should be called when the platfrom is about to
> > + leave the safe
> > environment.
> > +  It will notify the Redfish service provider to abort all logined
> > + session, and prohibit  further login with original auth info.
> > + GetAuthInfo() will return EFI_UNSUPPORTED once this  function is
> returned.
> > +
> > +  @param[in]   This                Pointer to
> > EDKII_REDFISH_CREDENTIAL_PROTOCOL instance.
> > +  @param[in]   ServiceStopType     Reason of stopping Redfish service.
> > +
> > +  @retval EFI_SUCCESS              Service has been stoped successfully.
> > +  @retval EFI_INVALID_PARAMETER    This is NULL.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +LibStopRedfishService (
> > +  IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL           *This,
> > +  IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE
> ServiceStopType
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +
> > +  if ((ServiceStopType <= ServiceStopTypeNone) || (ServiceStopType
> > + >=
> > ServiceStopTypeMax)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  //
> > +  // Raise flag first
> > +  //
> > +  mRedfishServiceStopped = TRUE;
> > +
> > +  //
> > +  // Notify BMC to disable credential bootstrapping support.
> > +  //
> > +  Status = GetBootstrapAccountCredentials (TRUE, NULL, NULL);  if
> > + (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: fail to disable bootstrap credential:
> > + %r\n",
> > __FUNCTION__, Status));
> > +    return Status;
> > +  }
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +/**
> > +  Notification of Exit Boot Service.
> > +
> > +  @param[in]  This    Pointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL.
> > +**/
> > +VOID
> > +EFIAPI
> > +LibCredentialExitBootServicesNotify (
> > +  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
> > +  )
> > +{
> > +  //
> > +  // Stop the credential support when system is about to enter OS.
> > +  //
> > +  LibStopRedfishService (This, ServiceStopTypeExitBootService); }
> > +
> > +/**
> > +  Notification of End of DXe.
> > +
> > +  @param[in]  This    Pointer to EDKII_REDFISH_CREDENTIAL_PROTOCOL.
> > +**/
> > +VOID
> > +EFIAPI
> > +LibCredentialEndOfDxeNotify (
> > +  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
> > +  )
> > +{
> > +  //
> > +  // Do nothing now.
> > +  // We can stop credential support when system reach end-of-dxe
> > +for security
> > reason.
> > +  //
> > +}
> > +
> > +/**
> > +  Function to retrieve temporary use credentials for the UEFI
> > +redfish client
> [Chang, Abner]
> We miss the functionality to disable bootstrap credential service in
> the function description.
>
> > +
> > +  @param[in]  DisableBootstrapControl
> > +                                      TRUE - Tell the BMC to disable the bootstrap credential
> > +                                             service to ensure no one else gains credentials
> > +                                      FALSE  Allow the bootstrap
> > + credential service to continue  @param[out] BootstrapUsername
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential
> > username
> > +                                      When DisableBootstrapControl
> > + is TRUE, this pointer can be NULL
> > +
> > +  @param[out] BootstrapPassword
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential
> > password
> > +                                      When DisableBootstrapControl
> > + is TRUE, this pointer can be NULL
> > +
> > +  @retval  EFI_SUCCESS                Credentials were successfully fetched and
> > returned
> > +  @retval  EFI_INVALID_PARAMETER      BootstrapUsername or
> > BootstrapPassword is NULL when DisableBootstrapControl
> > +                                      is set to FALSE
> > +  @retval  EFI_DEVICE_ERROR           An IPMI failure occurred
> [Chang, Abner]
> The return status should also include the status of disabling
> bootstrap credential.
>
>
> > +**/
> > +EFI_STATUS
> > +GetBootstrapAccountCredentials (
> > +  IN BOOLEAN DisableBootstrapControl,
> > +  IN OUT CHAR8 *BootstrapUsername, OPTIONAL
> > +  IN OUT CHAR8  *BootstrapPassword    OPTIONAL
> > +  )
> > +{
> > +  EFI_STATUS                                  Status;
> > +  IPMI_BOOTSTRAP_CREDENTIALS_COMMAND_DATA     CommandData;
> > +  IPMI_BOOTSTRAP_CREDENTIALS_RESULT_RESPONSE  ResponseData;
> > +  UINT32                                      ResponseSize;
> > +
> > +  if (!PcdGetBool (PcdIpmiFeatureEnable)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: IPMI is not enabled! Unable to fetch
> > + Redfish
> > credentials\n", __FUNCTION__));
> > +    return EFI_UNSUPPORTED;
> > +  }
> > +
> > +  //
> > +  // NULL buffer check
> > +  //
> > +  if (!DisableBootstrapControl && ((BootstrapUsername == NULL) ||
> > (BootstrapPassword == NULL))) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  DEBUG ((DEBUG_VERBOSE, "%a: Disable bootstrap control: 0x%x\n",
> > + __FUNCTION__, DisableBootstrapControl));
> > +
> > +  //
> > +  // IPMI callout to NetFn 2C, command 02
> > +  //    Request data:
> > +  //      Byte 1: REDFISH_IPMI_GROUP_EXTENSION
> > +  //      Byte 2: DisableBootstrapControl
> > +  //
> > +  CommandData.GroupExtensionId        =
> REDFISH_IPMI_GROUP_EXTENSION;
> > +  CommandData.DisableBootstrapControl = (DisableBootstrapControl ?
> > + REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_DISABLE :
> > + REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_ENABLE);
> > +
> > +  ResponseSize = sizeof (ResponseData);
> > +
> > +  //
> > +  //    Response data:
> > +  //      Byte 1    : Completion code
> > +  //      Byte 2    : REDFISH_IPMI_GROUP_EXTENSION
> > +  //      Byte 3-18 : Username
> > +  //      Byte 19-34: Password
> > +  //
> > +  Status = IpmiSubmitCommand (
> > +             IPMI_NETFN_GROUP_EXT,
> > +             REDFISH_IPMI_GET_BOOTSTRAP_CREDENTIALS_CMD,
> > +             (UINT8 *)&CommandData,
> > +             sizeof (CommandData),
> > +             (UINT8 *)&ResponseData,
> > +             &ResponseSize
> > +             );
> > +
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: IPMI transaction failure.
> > + Returning\n",
> > __FUNCTION__));
> > +    ASSERT_EFI_ERROR (Status);
> > +    return Status;
> > +  } else {
> > +    if (ResponseData.CompletionCode != IPMI_COMP_CODE_NORMAL) {
> > +      if (ResponseData.CompletionCode ==
> > REDFISH_IPMI_COMP_CODE_BOOTSTRAP_CREDENTIAL_DISABLED) {
> > +        DEBUG ((DEBUG_ERROR, "%a: bootstrap credential support was
> > disabled\n", __FUNCTION__));
> > +        return EFI_ACCESS_DENIED;
> > +      }
> > +
> > +      DEBUG ((DEBUG_ERROR, "%a: Completion code = 0x%x.
> > + Returning\n",
> > __FUNCTION__, ResponseData.CompletionCode));
> > +      return EFI_PROTOCOL_ERROR;
> > +    } else if (ResponseData.GroupExtensionId !=
> > REDFISH_IPMI_GROUP_EXTENSION) {
> > +      DEBUG ((DEBUG_ERROR, "%a: Group Extension Response = 0x%x.
> > Returning\n", __FUNCTION__, ResponseData.GroupExtensionId));
> > +      return EFI_DEVICE_ERROR;
> > +    } else {
> > +      if (BootstrapUsername != NULL) {
> > +        CopyMem (BootstrapUsername, ResponseData.Username,
> > USERNAME_MAX_LENGTH);
> > +        //
> > +        // Manually append null-terminator in case 16 characters
> > + username
> > returned.
> > +        //
> > +        BootstrapUsername[USERNAME_MAX_LENGTH] = '\0';
> > +      }
> > +
> > +      if (BootstrapPassword != NULL) {
> > +        CopyMem (BootstrapPassword, ResponseData.Password,
> > PASSWORD_MAX_LENGTH);
> > +        //
> > +        // Manually append null-terminator in case 16 characters
> > + password
> > returned.
> > +        //
> > +        BootstrapPassword[PASSWORD_MAX_LENGTH] = '\0';
> > +      }
> > +    }
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +/**
> > +  Retrieve platform's Redfish authentication information.
> > +
> > +  This functions returns the Redfish authentication method together
> > + with the user Id and  password.
> > +  - For AuthMethodNone, the UserId and Password could be used for
> > + HTTP
> > header authentication
> > +    as defined by RFC7235.
> > +  - For AuthMethodRedfishSession, the UserId and Password could be
> > + used for
> > Redfish
> > +    session login as defined by  Redfish API specification (DSP0266).
> > +
> > +  Callers are responsible for and freeing the returned string storage.
> > +
> > +  @param[in]   This                Pointer to
> > EDKII_REDFISH_CREDENTIAL_PROTOCOL instance.
> > +  @param[out]  AuthMethod          Type of Redfish authentication method.
> > +  @param[out]  UserId              The pointer to store the returned UserId
> string.
> > +  @param[out]  Password            The pointer to store the returned
> Password
> > string.
> > +
> > +  @retval EFI_SUCCESS              Get the authentication information
> successfully.
> > +  @retval EFI_ACCESS_DENIED        SecureBoot is disabled after EndOfDxe.
> > +  @retval EFI_INVALID_PARAMETER    This or AuthMethod or UserId or
> > Password is NULL.
> > +  @retval EFI_OUT_OF_RESOURCES     There are not enough memory
> resources.
> > +  @retval EFI_UNSUPPORTED          Unsupported authentication method is
> > found.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +LibCredentialGetAuthInfo (
> > +  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This,
> > +  OUT EDKII_REDFISH_AUTH_METHOD          *AuthMethod,
> > +  OUT CHAR8                              **UserId,
> > +  OUT CHAR8                              **Password
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +
> > +  if ((AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  *UserId   = NULL;
> > +  *Password = NULL;
> > +
> > +  if (mRedfishServiceStopped) {
> > +    DEBUG ((DEBUG_ERROR, "%a: credential service is stopped due to
> > + security
> > reason\n", __FUNCTION__));
> > +    return EFI_ACCESS_DENIED;
> > +  }
> > +
> > +  *AuthMethod = AuthMethodHttpBasic;
> > +
> > +  *UserId = AllocateZeroPool (sizeof (CHAR8) * USERNAME_MAX_SIZE);
> > + if
> [Chang, Abner]
> Allocation memory with the size (USERNAME_MAX_LENGTH + 1)  for both
> BootUsername and BootstrapPassword?   Because the maximum number of
> characters defined in the spec is USERNAME_MAX_LENGTH for the
> user/password.
>
>
> > + (*UserId == NULL) {
> > +    return EFI_OUT_OF_RESOURCES;
> > +  }
> > +
> > +  *Password = AllocateZeroPool (sizeof (CHAR8) *
> > + PASSWORD_MAX_SIZE); if (*Password == NULL) {
> > +    return EFI_OUT_OF_RESOURCES;
> > +  }
> > +
> > +  Status = GetBootstrapAccountCredentials (FALSE, *UserId,
> > + *Password); if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: fail to get bootstrap credential:
> > + %r\n",
> > __FUNCTION__, Status));
> > +    return Status;
> > +  }
> > +
> > +  return EFI_SUCCESS;
> > +}
> > diff --git
> > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.h
> > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.h
> > new file mode 100644
> > index 0000000000..5b448e01be
> > --- /dev/null
> > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatfor
> > +++ mC
> > +++ re
> > +++ dentialLib.h
> > @@ -0,0 +1,75 @@
> > +/** @file
> > +*
> > +*  Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> > +*
> > +*  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +*
> > +**/
> > +#include <Uefi.h>
> > +#include <IndustryStandard/Ipmi.h>
> > +#include <Protocol/EdkIIRedfishCredential.h>
> > +#include <Library/BaseLib.h>
> > +#include <Library/BaseMemoryLib.h>
> > +#include <Library/DebugLib.h>
> > +#include <Library/IpmiBaseLib.h>
> > +#include <Library/MemoryAllocationLib.h> #include
> > +<Library/RedfishCredentialLib.h>
> > +
> > +#define REDFISH_IPMI_GROUP_EXTENSION                          0x52
> > +#define REDFISH_IPMI_GET_BOOTSTRAP_CREDENTIALS_CMD            0x02
> > +#define REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_ENABLE              0xA5
> > +#define REDFISH_IPMI_BOOTSTRAP_CREDENTIAL_DISABLE             0x00
> > +#define
> REDFISH_IPMI_COMP_CODE_BOOTSTRAP_CREDENTIAL_DISABLED
> > 0x80
> > +
> > +//
> > +// Per Redfish Host Interface Specification 1.3, The maximum lenght
> > +of // username and password is 16 characters long.
> > +//
> > +#define USERNAME_MAX_LENGTH  16
> > +#define PASSWORD_MAX_LENGTH  16
> > +#define USERNAME_MAX_SIZE    (USERNAME_MAX_LENGTH + 1)  //
> NULL
> > terminator
> > +#define PASSWORD_MAX_SIZE    (PASSWORD_MAX_LENGTH + 1)  //
> NULL
> > terminator
> > +
> > +#pragma pack(1)
> > +///
> > +/// The definition of IPMI command to get bootstrap account
> > +credentials /// typedef struct {
> > +  UINT8    GroupExtensionId;
> > +  UINT8    DisableBootstrapControl;
> > +} IPMI_BOOTSTRAP_CREDENTIALS_COMMAND_DATA;
> > +
> > +///
> > +/// The response data of getting bootstrap credential /// typedef
> > +struct {
> > +  UINT8    CompletionCode;
> > +  UINT8    GroupExtensionId;
> > +  CHAR8    Username[USERNAME_MAX_LENGTH];
> > +  CHAR8    Password[PASSWORD_MAX_LENGTH];
> > +} IPMI_BOOTSTRAP_CREDENTIALS_RESULT_RESPONSE;
> > +
> > +#pragma pack()
> > +
> > +/**
> > +  Function to retrieve temporary use credentials for the UEFI
> > +redfish client
> [Chang, Abner]
> We miss the functionality to disable bootstrap credential service in
> the function description.
>
> > +
> > +  @param[in]  DisableBootstrapControl
> > +                                      TRUE - Tell the BMC to disable the bootstrap credential
> > +                                             service to ensure no one else gains credentials
> > +                                      FALSE  Allow the bootstrap
> > + credential service to continue  @param[out] BootstrapUsername
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential username
> > +
> > +  @param[out] BootstrapPassword
> > +                                      A pointer to a UTF-8 encoded
> > + string for the credential password
> > +
> > +  @retval  EFI_SUCCESS                Credentials were successfully fetched and
> > returned
> [Chang, Abner]
> Or the bootstrap credential service is disabled successfully, right?
>
> > +  @retval  EFI_DEVICE_ERROR           An IPMI failure occurred
> > +**/
> > +EFI_STATUS
> > +GetBootstrapAccountCredentials (
> > +  IN BOOLEAN    DisableBootstrapControl,
> > +  IN OUT CHAR8  *BootstrapUsername,
> > +  IN OUT CHAR8  *BootstrapPassword
> > +  );
> > diff --git
> > a/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.inf
> > b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCre
> > de
> > ntialLi
> > b.inf
> > new file mode 100644
> > index 0000000000..a990d28363
> > --- /dev/null
> > +++ b/RedfishPkg/Library/RedfishPlatformCredentialLib/RedfishPlatfor
> > +++ mC
> > +++ re
> > +++ dentialLib.inf
> > @@ -0,0 +1,37 @@
> > +## @file
> > +#
> > +# Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> > +#
> > +#  SPDX-License-Identifier: BSD-2-Clause-Patent # ##
> > +
> > +[Defines]
> > +  INF_VERSION                    = 0x0001000b
> > +  BASE_NAME                      = RedfishPlatformCredentialLib
> > +  FILE_GUID                      = 9C45D622-4C66-417F-814C-F76246D97233
> > +  MODULE_TYPE                    = DXE_DRIVER
> > +  VERSION_STRING                 = 1.0
> > +  LIBRARY_CLASS                  = RedfishPlatformCredentialLib
> > +
> > +[Sources]
> > +  RedfishPlatformCredentialLib.c
> > +
> > +[Packages]
> > +  MdePkg/MdePkg.dec
> > +  MdeModulePkg/MdeModulePkg.dec
> > +  RedfishPkg/RedfishPkg.dec
> > +  IpmiFeaturePkg/IpmiFeaturePkg.dec
> [Chang, Abner]
> Could you please add a comment to the reference  of IpmiFeaturePkg? We
> have to give customers a notice that the dependence of "edk2-
> platforms/Features/Intel/OutOfBandManagement/". They have to add the
> path to PACKAGES_PATH. You also have to skip this dependence in the
> RedfishPkg.yaml to avoid the CI error.
>
> Another thing is I propose to move out IpmiFeaturePkg from edk2-
> platforms/Features/Intel/OutOfBandManagement to edk2-
> platforms/Features/ManageabilityPkg  that also provides the
> implementation of PLDM/MCTP/IPMI/KCS.  I had an initial talk with
> IpmiFeaturePkg owner and get the positive response on this proposal. I
> will kick off the discussion on the dev mailing list. That is to say
> this module may need a little bit change later, however that is good
> to me having this implementation now.
> Thanks
> Abner
> > +
> > +[LibraryClasses]
> > +  UefiLib
> > +  DebugLib
> > +  IpmiBaseLib
> > +  MemoryAllocationLib
> > +  BaseMemoryLib
> > +
> > +[Pcd]
> > +  gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable
> > +
> > +[Depex]
> > +  TRUE
> > --
> > 2.17.1
>
>
>
>
>
> -The information contained in this message may be confidential and
> proprietary to American Megatrends (AMI). This communication is
> intended to be read only by the individual or entity to whom it is
> addressed or by their designee. If the reader of this message is not
> the intended recipient, you are on notice that any distribution of
> this message, in any form, is strictly prohibited. Please promptly
> notify the sender by reply e-mail or by telephone at 770-246-8600, and
> then delete or destroy all copies of the transmission.
>
>
>
>
>
>
>
>
>
>
> -The information contained in this message may be confidential and
> proprietary to American Megatrends (AMI). This communication is
> intended to be read only by the individual or entity to whom it is
> addressed or by their designee. If the reader of this message is not
> the intended recipient, you are on notice that any distribution of
> this message, in any form, is strictly prohibited. Please promptly
> notify the sender by reply e-mail or by telephone at 770-246-8600, and
> then delete or destroy all copies of the transmission.
>
>
>
>
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


[edk2-staging/RiscV64QemuVirt PATCH V5 30/30] UefiCpuPkg/UefiCpuPkg.ci.yaml: Ignore RISC-V file

Sunil V L
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076

RISC-V register names do not follow the EDK2 formatting.
So, add it to ignore list for now.

Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rahul Kumar <rahul1.kumar@...>
Signed-off-by: Sunil V L <sunilvl@...>
Acked-by: Abner Chang <abner.chang@...>
---
UefiCpuPkg/UefiCpuPkg.ci.yaml | 1 +
1 file changed, 1 insertion(+)

diff --git a/UefiCpuPkg/UefiCpuPkg.ci.yaml b/UefiCpuPkg/UefiCpuPkg.ci.yaml
index a377366798b0..953361ba0479 100644
--- a/UefiCpuPkg/UefiCpuPkg.ci.yaml
+++ b/UefiCpuPkg/UefiCpuPkg.ci.yaml
@@ -27,6 +27,7 @@
],
## Both file path and directory path are accepted.
"IgnoreFiles": [
+ "Library/CpuExceptionHandlerLib/RiscV64/CpuExceptionHandlerLib.h"
]
},
"CompilerPlugin": {
--
2.38.0


[edk2-staging/RiscV64QemuVirt PATCH V5 29/30] Maintainers.txt: Add entry for OvmfPkg/RiscVVirt

Sunil V L
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076

RiscVVirt is created to support EDK2 for RISC-V qemu
virt machine platform. Add maintainer entries.

Cc: Andrew Fish <afish@...>
Cc: Leif Lindholm <quic_llindhol@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Signed-off-by: Sunil V L <sunilvl@...>
---
Maintainers.txt | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/Maintainers.txt b/Maintainers.txt
index 8e81ccfdeccf..e4faee5b7684 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -533,6 +533,10 @@ F: OvmfPkg/XenResetVector/
R: Anthony Perard <anthony.perard@...> [sheep]
R: Julien Grall <julien@...> [jgrall]

+OvmfPkg: RISC-V Qemu Virt Platform
+F: OvmfPkg/Platforms/RiscVVirt
+R: Sunil V L <sunilvl@...> [vlsunil]
+
PcAtChipsetPkg
F: PcAtChipsetPkg/
W: https://github.com/tianocore/tianocore.github.io/wiki/PcAtChipsetPkg
--
2.38.0


[edk2-staging/RiscV64QemuVirt PATCH V5 28/30] OvmfPkg: RiscVVirt: Add Qemu Virt platform support

Sunil V L
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076

Add infrastructure files to build edk2 for RISC-V qemu virt machine.

- EDK2 will boot as S-mode payload of opensbi.
- It supports building
either code and variables in unified flash or in two separate drives
via build time option UNIFIED_NVVARS.

Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jordan Justen <jordan.l.justen@...>
Cc: Gerd Hoffmann <kraxel@...>
Signed-off-by: Sunil V L <sunilvl@...>
Acked-by: Abner Chang <abner.chang@...>
---
OvmfPkg/Platforms/RiscVVirt/RiscVVirt.dsc | 727 ++++++++++++++++++++
OvmfPkg/Platforms/RiscVVirt/RiscVVirt.fdf | 406 +++++++++++
OvmfPkg/Platforms/RiscVVirt/RiscVVirt.fdf.inc | 66 ++
OvmfPkg/Platforms/RiscVVirt/VarStore.fdf.inc | 79 +++
4 files changed, 1278 insertions(+)

diff --git a/OvmfPkg/Platforms/RiscVVirt/RiscVVirt.dsc b/OvmfPkg/Platforms/RiscVVirt/RiscVVirt.dsc
new file mode 100644
index 000000000000..33c945f57624
--- /dev/null
+++ b/OvmfPkg/Platforms/RiscVVirt/RiscVVirt.dsc
@@ -0,0 +1,727 @@
+## @file
+# RISC-V EFI on RiscVVirt RISC-V platform
+#
+# Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+# Copyright (c) 2022, Ventana Micro Systems Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+ PLATFORM_NAME = RiscVVirt
+ PLATFORM_GUID = 39DADB39-1B21-4867-838E-830B6149B9E0
+ PLATFORM_VERSION = 0.1
+ DSC_SPECIFICATION = 0x0001001c
+ OUTPUT_DIRECTORY = Build/$(PLATFORM_NAME)
+ SUPPORTED_ARCHITECTURES = RISCV64
+ BUILD_TARGETS = DEBUG|RELEASE|NOOPT
+ SKUID_IDENTIFIER = DEFAULT
+ FLASH_DEFINITION = OvmfPkg/Platforms/RiscVVirt/RiscVVirt.fdf
+
+ #
+ # Enable below options may cause build error or may not work on
+ # the initial version of RISC-V package
+ # Defines for default states. These can be changed on the command line.
+ # -D FLAG=VALUE
+ #
+ DEFINE UNIFIED_VARSTORE = TRUE
+ DEFINE SECURE_BOOT_ENABLE = FALSE
+ DEFINE DEBUG_ON_SERIAL_PORT = TRUE
+
+ #
+ # Network definition
+ #
+ DEFINE NETWORK_SNP_ENABLE = FALSE
+ DEFINE NETWORK_IP6_ENABLE = FALSE
+ DEFINE NETWORK_TLS_ENABLE = TRUE
+ DEFINE NETWORK_HTTP_BOOT_ENABLE = TRUE
+ DEFINE NETWORK_ISCSI_ENABLE = FALSE
+ DEFINE NETWORK_ALLOW_HTTP_CONNECTIONS = TRUE
+
+[BuildOptions]
+ GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
+!ifdef $(SOURCE_DEBUG_ENABLE)
+ GCC:*_*_RISCV64_GENFW_FLAGS = --keepexceptiontable
+!endif
+
+[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
+ GCC: *_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+ MSFT: *_*_*_DLINK_FLAGS = /ALIGN:4096
+
+################################################################################
+#
+# SKU Identification section - list of all SKU IDs supported by this Platform.
+#
+################################################################################
+[SkuIds]
+ 0|DEFAULT
+
+################################################################################
+#
+# Library Class section - list of all Library Classes needed by this Platform.
+#
+################################################################################
+
+!include MdePkg/MdeLibs.dsc.inc
+
+[LibraryClasses]
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+ BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+ BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+ SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+ SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
+ CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
+ PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
+ PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+ CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
+ UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
+ UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
+ HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
+ CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
+ DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
+ DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
+ PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
+ IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
+ OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
+ SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
+ PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
+ UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+ UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
+ UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+ UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
+ UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
+ DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
+ UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
+ CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
+ SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
+ VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
+ UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+ VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
+ FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
+ VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+ TimerLib|UefiCpuPkg/Library/CpuTimerLib/BaseCpuTimerLib.inf
+ TimeBaseLib|EmbeddedPkg//Library/TimeBaseLib/TimeBaseLib.inf
+ RealTimeClockLib|EmbeddedPkg//Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf
+!if $(UNIFIED_VARSTORE) == TRUE
+ VirtNorFlashPlatformLib|OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.inf
+!else
+ VirtNorFlashPlatformLib|OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.inf
+!endif
+ QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.inf
+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/BaseResetSystemLib.inf
+
+!ifdef $(SOURCE_DEBUG_ENABLE)
+ PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
+ DebugCommunicationLib|SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf
+!else
+ PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
+ DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
+!endif
+
+ DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+
+!if $(SECURE_BOOT_ENABLE) == TRUE
+ IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+ OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
+ TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
+ AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
+!else
+ TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+ AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+!endif
+ VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
+
+!if $(HTTP_BOOT_ENABLE) == TRUE
+ HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf
+!endif
+
+ SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
+ OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
+
+[LibraryClasses.common]
+!if $(SECURE_BOOT_ENABLE) == TRUE
+ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+!endif
+
+ RiscVSbiLib|MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.inf
+
+ # PCI Libraries
+ PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
+ PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
+ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
+ PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
+ PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
+ DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf
+
+ # Virtio Support
+ VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
+ VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
+ QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf
+ QemuFwCfgSimpleParserLib|OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParserLib.inf
+ QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf
+
+ # PCI support
+ PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
+ PciHostBridgeLib|MdeModulePkg/Library/PciHostBridgeLibNull/PciHostBridgeLibNull.inf
+
+ # Boot Manager
+!if $(TPM2_ENABLE) == TRUE
+ Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
+ Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
+ TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
+ TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.inf
+!else
+ TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+ TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLibNull/PeiDxeTpmPlatformHierarchyLib.inf
+!endif
+
+ BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
+ PlatformBmPrintScLib|OvmfPkg/Library/PlatformBmPrintScLib/PlatformBmPrintScLib.inf
+
+ PlatformBootManagerLib|OvmfPkg/Library/PlatformBootManagerLibVirt/PlatformBootManagerLib.inf
+
+ FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
+ QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
+ FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
+
+[LibraryClasses.common.SEC]
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+!endif
+
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+ ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
+ ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
+
+!ifdef $(SOURCE_DEBUG_ENABLE)
+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
+!endif
+
+ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+ PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf
+ HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+
+[LibraryClasses.common.PEI_CORE]
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+ HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+ PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+ PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+ ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
+ OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
+ PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+!endif
+ PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+ PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf
+
+[LibraryClasses.common.PEIM]
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+ HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+ PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+ PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+ PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
+ ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
+ OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
+ PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+!endif
+ PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+ PeiResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
+ ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
+!ifdef $(SOURCE_DEBUG_ENABLE)
+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
+!endif
+ ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
+
+[LibraryClasses.common.DXE_CORE]
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+ VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
+ HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
+ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
+ MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+!endif
+ ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
+!ifdef $(SOURCE_DEBUG_ENABLE)
+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
+!endif
+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
+
+[LibraryClasses.common.DXE_RUNTIME_DRIVER]
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+ VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
+ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+ ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf
+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
+ UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+!endif
+!if $(SECURE_BOOT_ENABLE) == TRUE
+ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
+!endif
+ UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
+
+[LibraryClasses.common.UEFI_DRIVER]
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+ VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+!endif
+ UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
+ VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
+ PciExpressLib|OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf
+ PciPcdProducerLib|OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf
+ PciHostBridgeLib|OvmfPkg/Fdt/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
+
+[LibraryClasses.common.DXE_DRIVER]
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+ VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+ UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+!endif
+!ifdef $(SOURCE_DEBUG_ENABLE)
+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
+!endif
+ UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+ PlatformUpdateProgressLib|MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManagerLibNull.inf
+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
+
+[LibraryClasses.common.UEFI_APPLICATION]
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+!endif
+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
+
+################################################################################
+#
+# Pcd Section - list of all EDK II PCD Entries defined by this Platform.
+#
+################################################################################
+[PcdsFeatureFlag]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
+
+[PcdsFixedAtBuild]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
+ gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
+ gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x8000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0xe000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE
+
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0
+
+ gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x02
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
+!ifdef $(SOURCE_DEBUG_ENABLE)
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
+!else
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
+!endif
+
+!ifdef $(SOURCE_DEBUG_ENABLE)
+ gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2
+!endif
+
+!if $(SECURE_BOOT_ENABLE) == TRUE
+ # override the default values from SecurityPkg to ensure images from all sources are verified in secure boot
+ gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04
+ gEfiSecurityPkgTokenSpaceGuid.PcdFixedMediaImageVerificationPolicy|0x04
+ gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0x04
+!endif
+
+ #
+ # F2 for UI APP
+ #
+ gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
+
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"2.7"
+
+ # Serial Port
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x10000000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate|9600
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl|FALSE
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|3686400
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|1
+
+################################################################################
+#
+# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform
+#
+################################################################################
+
+[PcdsDynamicDefault]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|FALSE
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600
+
+ gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|10
+
+ # Set video resolution for text setup.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480
+
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0
+
+################################################################################
+#
+# Components Section - list of all EDK II Modules needed by this Platform.
+#
+################################################################################
+[Components]
+
+ #
+ # SEC Phase modules
+ #
+ OvmfPkg/Sec/SecMain.inf {
+ <LibraryClasses>
+ NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
+ }
+
+ #
+ # PEI Phase modules
+ #
+ MdeModulePkg/Core/Pei/PeiMain.inf
+ MdeModulePkg/Universal/PCD/Pei/Pcd.inf {
+ <LibraryClasses>
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+ }
+ MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf
+ MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf
+ MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf {
+ <LibraryClasses>
+ NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
+ }
+
+ OvmfPkg/PlatformPei/PlatformPei.inf {
+ <LibraryClasses>
+ PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+ PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf
+ }
+
+ #
+ # DXE Phase modules
+ #
+ MdeModulePkg/Core/Dxe/DxeMain.inf {
+ <LibraryClasses>
+ NULL|MdeModulePkg//Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+ }
+
+ MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
+ MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf
+
+ MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
+ <LibraryClasses>
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+ }
+
+ MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
+
+!if $(SECURE_BOOT_ENABLE) == TRUE
+ MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
+ <LibraryClasses>
+ NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
+ }
+!else
+ MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
+!endif
+
+ MdeModulePkg/Universal/Metronome/Metronome.inf
+ EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
+
+ #
+ # RISC-V Platform module
+ #
+ UefiCpuPkg/CpuTimerDxe/CpuTimerDxe.inf
+
+ OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
+
+ #
+ # RISC-V Core module
+ #
+ UefiCpuPkg/CpuDxe/CpuDxe.inf
+ MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+
+ MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+ <LibraryClasses>
+ NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+ }
+ MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
+ MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+ MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+ MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
+ MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
+
+# Graphic console
+ MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+
+ MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
+ MdeModulePkg/Universal/PrintDxe/PrintDxe.inf
+ MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
+ MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
+ MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+ MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+ MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+ MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
+ MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
+ MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
+ MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
+
+ #
+ # Network Support
+ #
+ !include NetworkPkg/Network.dsc.inc
+
+ #
+ # Usb Support
+ #
+ MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+ MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+ MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+ MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+ MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
+ #
+ # PCI support
+ #
+ UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf {
+ <LibraryClasses>
+ NULL|OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf
+ }
+ MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
+ MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {
+ <LibraryClasses>
+ NULL|OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf
+ }
+ OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
+ OvmfPkg/Virtio10Dxe/Virtio10.inf
+
+ #
+ # Video support
+ #
+ OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf
+ OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
+ OvmfPkg/PlatformDxe/Platform.inf
+
+ #
+ # Platform Driver
+ #
+ OvmfPkg/Fdt/VirtioFdtDxe/VirtioFdtDxe.inf
+ EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf
+ OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf
+ OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+ OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
+ OvmfPkg/VirtioNetDxe/VirtioNet.inf
+ OvmfPkg/VirtioRngDxe/VirtioRng.inf
+
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ OvmfPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
+
+ #
+ # FAT filesystem + GPT/MBR partitioning + UDF filesystem
+ #
+ FatPkg/EnhancedFatDxe/Fat.inf
+ MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
+
+ OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
+ <PcdsFixedAtBuild>
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+ <LibraryClasses>
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+ }
+
+ ShellPkg/Application/Shell/Shell.inf {
+ <LibraryClasses>
+ ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf
+ NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+ NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
+ HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+ BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf
+
+ <PcdsFixedAtBuild>
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+ gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000
+ }
+
+!if $(SECURE_BOOT_ENABLE) == TRUE
+ SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
+!endif
+
+ #
+ # Bds
+ #
+ MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf {
+ <LibraryClasses>
+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+ }
+ MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
+ MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
+ MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
+ MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+ MdeModulePkg/Logo/LogoDxe.inf
+ MdeModulePkg/Application/UiApp/UiApp.inf {
+ <LibraryClasses>
+ NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
+ NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
+ NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
+ }
+ OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf {
+ <LibraryClasses>
+ NULL|OvmfPkg/Library/BlobVerifierLibNull/BlobVerifierLibNull.inf
+ }
+
+# HTTPS(secure) support in GUI for updating ssl keys for PXE boot
+ MdeModulePkg/Application/UiApp/UiApp.inf {
+ <LibraryClasses>
+ NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
+ NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
+ NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
+ FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
+ }
+
+# TFTP support for PXE boot
+ ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf {
+ <PcdsFixedAtBuild>
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+ <LibraryClasses>
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+ }
+ ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf {
+ <PcdsFixedAtBuild>
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+ <LibraryClasses>
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+ }
+
+ # HTTP support for PXE boot
+ ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf {
+ <PcdsFixedAtBuild>
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+ <LibraryClasses>
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+ HttpLib|NetworkPkg/Library/DxeHttpLib/DxeHttpLib.inf
+ }
+ ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.inf {
+ <PcdsFixedAtBuild>
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+ <LibraryClasses>
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+ HttpLib|NetworkPkg/Library/DxeHttpLib/DxeHttpLib.inf
+ }
+
+# HTTPS (secure) support for PXE boot
+ NetworkPkg/TlsDxe/TlsDxe.inf {
+ <LibraryClasses>
+ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+ TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf
+ IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+ OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
+ RngLib|MdePkg/Library/DxeRngLib/DxeRngLib.inf
+ FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
+ }
+ NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf {
+ <LibraryClasses>
+ FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
+ NULL|OvmfPkg/Library/TlsAuthConfigLib/TlsAuthConfigLib.inf
+ }
+
+[PcdsDynamicDefault.common]
+ # set PcdPciExpressBaseAddress to MAX_UINT64, which signifies that this
+ # PCD and PcdPciDisableBusEnumeration above have not been assigned yet
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xFFFFFFFFFFFFFFFF
+
+ gEfiMdePkgTokenSpaceGuid.PcdPciIoTranslation|0x0
+
+[PcdsFeatureFlag.common]
+ gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE
+ gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|TRUE
+
+ ## If TRUE, Graphics Output Protocol will be installed on virtual handle created by ConsplitterDxe.
+ # It could be set FALSE to save size.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
diff --git a/OvmfPkg/Platforms/RiscVVirt/RiscVVirt.fdf b/OvmfPkg/Platforms/RiscVVirt/RiscVVirt.fdf
new file mode 100644
index 000000000000..be227cfd713a
--- /dev/null
+++ b/OvmfPkg/Platforms/RiscVVirt/RiscVVirt.fdf
@@ -0,0 +1,406 @@
+# @file
+# Flash definition file on RiscVVirt RISC-V platform
+#
+# Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+# Copyright (c) 2022, Ventana Micro Systems Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+# Platform definitions
+#
+
+!include RiscVVirt.fdf.inc
+
+################################################################################
+!if $(UNIFIED_VARSTORE) == TRUE
+[FD.RISCV_VIRT]
+BaseAddress = $(FW_BASE_ADDRESS)|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress
+Size = $(FW_SIZE)|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize
+ErasePolarity = 1
+BlockSize = $(BLOCK_SIZE)
+NumBlocks = $(FW_BLOCKS)
+
+$(SECFV_OFFSET)|$(SECFV_SIZE)
+FV = SECFV
+
+$(FVMAIN_OFFSET)|$(FVMAIN_SIZE)
+gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvBaseAddress|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvSize
+FV = FVMAIN_COMPACT
+
+!include VarStore.fdf.inc
+
+!else
+[FD.RISCV_CODE]
+BaseAddress = $(FW_BASE_ADDRESS)|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress
+Size = $(CODE_SIZE)
+ErasePolarity = 1
+BlockSize = $(BLOCK_SIZE)
+NumBlocks = $(CODE_BLOCKS)
+
+$(SECFV_OFFSET)|$(SECFV_SIZE)
+FV = SECFV
+
+$(FVMAIN_OFFSET)|$(FVMAIN_SIZE)
+gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvBaseAddress|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvSize
+FV = FVMAIN_COMPACT
+
+################################################################################
+[FD.RISCV_NVVARS]
+BaseAddress = $(VARS_BASE_ADDRESS)
+Size = $(VARS_SIZE)
+ErasePolarity = 1
+BlockSize = $(VARS_BLOCK_SIZE)
+NumBlocks = $(VARS_BLOCKS)
+
+!include VarStore.fdf.inc
+!endif
+################################################################################
+
+[FD.RISCV_MEMFD]
+BaseAddress = $(MEMFD_BASE_ADDRESS)
+Size = 0x00a00000
+ErasePolarity = 1
+BlockSize = $(BLOCK_SIZE)
+NumBlocks = 0xa00
+
+0x00000000|0x00010000
+gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
+
+0x00010000|0x001000
+gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
+
+0x00040000|0x00080000
+gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
+FV = PEIFV
+
+0x00100000|0x00900000
+gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
+FV = DXEFV
+
+##########################################################################################
+
+[FV.SECFV]
+BlockSize = 0x1000
+FvAlignment = 16
+ERASE_POLARITY = 1
+MEMORY_MAPPED = TRUE
+STICKY_WRITE = TRUE
+LOCK_CAP = TRUE
+LOCK_STATUS = TRUE
+WRITE_DISABLED_CAP = TRUE
+WRITE_ENABLED_CAP = TRUE
+WRITE_STATUS = TRUE
+WRITE_LOCK_CAP = TRUE
+WRITE_LOCK_STATUS = TRUE
+READ_DISABLED_CAP = TRUE
+READ_ENABLED_CAP = TRUE
+READ_STATUS = TRUE
+READ_LOCK_CAP = TRUE
+READ_LOCK_STATUS = TRUE
+
+#
+# SEC Phase modules
+#
+# The code in this FV handles the initial firmware startup, and
+# decompresses the PEI and DXE FVs which handles the rest of the boot sequence.
+#
+INF OvmfPkg/Sec/SecMain.inf
+
+################################################################################
+[FV.PEIFV]
+BlockSize = 0x10000
+FvAlignment = 16
+ERASE_POLARITY = 1
+MEMORY_MAPPED = TRUE
+STICKY_WRITE = TRUE
+LOCK_CAP = TRUE
+LOCK_STATUS = TRUE
+WRITE_DISABLED_CAP = TRUE
+WRITE_ENABLED_CAP = TRUE
+WRITE_STATUS = TRUE
+WRITE_LOCK_CAP = TRUE
+WRITE_LOCK_STATUS = TRUE
+READ_DISABLED_CAP = TRUE
+READ_ENABLED_CAP = TRUE
+READ_STATUS = TRUE
+READ_LOCK_CAP = TRUE
+READ_LOCK_STATUS = TRUE
+
+APRIORI PEI {
+ INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf
+ INF MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf
+ INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
+}
+
+#
+# PEI Phase modules
+#
+INF MdeModulePkg/Core/Pei/PeiMain.inf
+INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
+INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf
+INF MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf
+INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+
+# RISC-V Platform PEI Driver
+INF OvmfPkg/PlatformPei/PlatformPei.inf
+
+################################################################################
+
+[FV.DXEFV]
+BlockSize = 0x10000
+FvAlignment = 16
+ERASE_POLARITY = 1
+MEMORY_MAPPED = TRUE
+STICKY_WRITE = TRUE
+LOCK_CAP = TRUE
+LOCK_STATUS = TRUE
+WRITE_DISABLED_CAP = TRUE
+WRITE_ENABLED_CAP = TRUE
+WRITE_STATUS = TRUE
+WRITE_LOCK_CAP = TRUE
+WRITE_LOCK_STATUS = TRUE
+READ_DISABLED_CAP = TRUE
+READ_ENABLED_CAP = TRUE
+READ_STATUS = TRUE
+READ_LOCK_CAP = TRUE
+READ_LOCK_STATUS = TRUE
+
+APRIORI DXE {
+ INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
+ INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
+}
+
+#
+# DXE Phase modules
+#
+INF MdeModulePkg/Core/Dxe/DxeMain.inf
+
+INF MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
+INF MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf
+INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
+
+#
+# PCI support
+#
+INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
+INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
+INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
+INF OvmfPkg/Virtio10Dxe/Virtio10.inf
+
+#
+# Video support
+#
+INF OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf
+INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
+INF OvmfPkg/PlatformDxe/Platform.inf
+
+#
+# Platform Driver
+#
+INF OvmfPkg/Fdt/VirtioFdtDxe/VirtioFdtDxe.inf
+INF EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf
+INF OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf
+INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
+INF OvmfPkg/VirtioNetDxe/VirtioNet.inf
+INF OvmfPkg/VirtioRngDxe/VirtioRng.inf
+INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
+INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
+
+INF MdeModulePkg/Universal/Metronome/Metronome.inf
+INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
+
+INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+INF OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
+INF OvmfPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
+
+# RISC-V Platform Drivers
+INF OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
+
+# RISC-V Core Drivers
+INF UefiCpuPkg/CpuTimerDxe/CpuTimerDxe.inf
+INF UefiCpuPkg/CpuDxe/CpuDxe.inf
+
+INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+
+INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+!if $(SECURE_BOOT_ENABLE) == TRUE
+ INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
+!endif
+
+INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
+INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
+INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
+INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
+INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
+INF MdeModulePkg/Universal/PrintDxe/PrintDxe.inf
+INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
+INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
+INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
+INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
+INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
+INF FatPkg/EnhancedFatDxe/Fat.inf
+INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
+
+!ifndef $(SOURCE_DEBUG_ENABLE)
+INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
+!endif
+
+INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf
+INF ShellPkg/Application/Shell/Shell.inf
+
+# TFTP support for PXE boot
+INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
+INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf
+
+# HTTP support for PXE boot
+INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf
+INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpApp.inf
+
+#
+# Network modules
+#
+!if $(E1000_ENABLE)
+ FILE DRIVER = 5D695E11-9B3F-4b83-B25F-4A8D5D69BE07 {
+ SECTION PE32 = Intel3.5/EFIX64/E3507X2.EFI
+ }
+!endif
+
+!include NetworkPkg/Network.fdf.inc
+
+#
+# Usb Support
+#
+INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
+INF MdeModulePkg/Application/UiApp/UiApp.inf
+INF OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf
+
+################################################################################
+
+[FV.FVMAIN_COMPACT]
+FvAlignment = 16
+ERASE_POLARITY = 1
+MEMORY_MAPPED = TRUE
+STICKY_WRITE = TRUE
+LOCK_CAP = TRUE
+LOCK_STATUS = TRUE
+WRITE_DISABLED_CAP = TRUE
+WRITE_ENABLED_CAP = TRUE
+WRITE_STATUS = TRUE
+WRITE_LOCK_CAP = TRUE
+WRITE_LOCK_STATUS = TRUE
+READ_DISABLED_CAP = TRUE
+READ_ENABLED_CAP = TRUE
+READ_STATUS = TRUE
+READ_LOCK_CAP = TRUE
+READ_LOCK_STATUS = TRUE
+FvNameGuid = 27A72E80-3118-4c0c-8673-AA5B4EFA9613
+
+FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
+ SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE {
+ #
+ # These firmware volumes will have files placed in them uncompressed,
+ # and then both firmware volumes will be compressed in a single
+ # compression operation in order to achieve better overall compression.
+ #
+ SECTION FV_IMAGE = PEIFV
+ SECTION FV_IMAGE = DXEFV
+ }
+ }
+
+[Rule.Common.SEC]
+ FILE SEC = $(NAMED_GUID) RELOCS_STRIPPED {
+ PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi
+ UI STRING ="$(MODULE_NAME)" Optional
+ VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.PEI_CORE]
+ FILE PEI_CORE = $(NAMED_GUID) {
+ PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi
+ UI STRING ="$(MODULE_NAME)" Optional
+ VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.PEIM]
+ FILE PEIM = $(NAMED_GUID) {
+ PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
+ PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.DXE_CORE]
+ FILE DXE_CORE = $(NAMED_GUID) {
+ PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.DXE_DRIVER]
+ FILE DRIVER = $(NAMED_GUID) {
+ DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
+ PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.DXE_RUNTIME_DRIVER]
+ FILE DRIVER = $(NAMED_GUID) {
+ DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
+ PE32 PE32 Align = 4K $(INF_OUTPUT)/$(MODULE_NAME).efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.UEFI_DRIVER]
+ FILE DRIVER = $(NAMED_GUID) {
+ DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
+ PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.UEFI_DRIVER.BINARY]
+ FILE DRIVER = $(NAMED_GUID) {
+ DXE_DEPEX DXE_DEPEX Optional |.depex
+ PE32 PE32 Align=4K |.efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.UEFI_APPLICATION]
+ FILE APPLICATION = $(NAMED_GUID) {
+ PE32 PE32 Align=4K $(INF_OUTPUT)/$(MODULE_NAME).efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.UEFI_APPLICATION.BINARY]
+ FILE APPLICATION = $(NAMED_GUID) {
+ PE32 PE32 Align=4K |.efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+ FILE FREEFORM = $(NAMED_GUID) {
+ RAW ACPI |.acpi
+ RAW ASL |.aml
+ }
diff --git a/OvmfPkg/Platforms/RiscVVirt/RiscVVirt.fdf.inc b/OvmfPkg/Platforms/RiscVVirt/RiscVVirt.fdf.inc
new file mode 100644
index 000000000000..4cbe7f369011
--- /dev/null
+++ b/OvmfPkg/Platforms/RiscVVirt/RiscVVirt.fdf.inc
@@ -0,0 +1,66 @@
+## @file
+# Definitions of Flash definition file on RiscVVirt RISC-V platform
+#
+# Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+# Copyright (c) 2022, Ventana Micro Systems Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+DEFINE BLOCK_SIZE = 0x1000
+
+DEFINE PFLASH1_BASE = 0x22000000
+DEFINE PFLASH2_BASE = 0x23000000
+
+DEFINE FW_BASE_ADDRESS = $(PFLASH1_BASE)
+DEFINE FW_SIZE = 0x00300000
+DEFINE FW_BLOCKS = 0x300
+
+DEFINE CODE_BASE_ADDRESS = $(FW_BASE_ADDRESS)
+DEFINE CODE_SIZE = 0x00240000
+DEFINE CODE_BLOCKS = 0x240
+
+#
+# Separate varstore will start at 3rd pflash address
+#
+DEFINE VARS_BASE_ADDRESS = $(PFLASH2_BASE)
+
+DEFINE VARS_SIZE = 0x000C0000
+DEFINE VARS_BLOCK_SIZE = 0x40000
+DEFINE VARS_BLOCKS = 0x3
+
+#
+# The size of memory region must be power of 2.
+# The base address must be aligned with the size.
+#
+# FW memory region
+#
+DEFINE SECFV_OFFSET = 0x00000000
+DEFINE SECFV_SIZE = 0x00040000
+DEFINE FVMAIN_OFFSET = 0x00040000
+DEFINE FVMAIN_SIZE = 0x00200000
+
+#
+# EFI Variable memory region.
+# The total size of EFI Variable FD must include
+# all of sub regions of EFI Variable
+#
+!if $(UNIFIED_VARSTORE) == TRUE
+DEFINE VARS_OFFSET = $(CODE_SIZE)
+!else
+DEFINE VARS_OFFSET = 0x00000000
+!endif
+DEFINE VARS_LIVE_SIZE = 0x00040000
+DEFINE VARS_FTW_WORKING_OFFSET = $(VARS_OFFSET) + $(VARS_LIVE_SIZE)
+DEFINE VARS_FTW_WORKING_SIZE = 0x00040000
+DEFINE VARS_FTW_SPARE_OFFSET = $(VARS_FTW_WORKING_OFFSET) + $(VARS_FTW_WORKING_SIZE)
+DEFINE VARS_FTW_SPARE_SIZE = 0x00040000
+
+#
+# Base Address where SEC phase will decompress and load
+# the PEI and DXE FVs
+#
+DEFINE MEMFD_BASE_ADDRESS = 0x80200000
+
+SET gUefiCpuPkgTokenSpaceGuid.PcdCpuCoreCrystalClockFrequency = 10000000
diff --git a/OvmfPkg/Platforms/RiscVVirt/VarStore.fdf.inc b/OvmfPkg/Platforms/RiscVVirt/VarStore.fdf.inc
new file mode 100644
index 000000000000..30b170d77997
--- /dev/null
+++ b/OvmfPkg/Platforms/RiscVVirt/VarStore.fdf.inc
@@ -0,0 +1,79 @@
+## @file
+# FDF include file with Layout Regions that define an empty variable store.
+#
+# Copyright (c) 2022, Ventana Micro Systems Inc. All rights reserved.<BR>
+# Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+# Copyright (C) 2014, Red Hat, Inc.
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+$(VARS_OFFSET)|$(VARS_LIVE_SIZE)
+gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
+#
+# NV_VARIABLE_STORE
+#
+DATA = {
+ ## This is the EFI_FIRMWARE_VOLUME_HEADER
+ # ZeroVector []
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ # FileSystemGuid: gEfiSystemNvDataFvGuid =
+ # { 0xFFF12B8D, 0x7696, 0x4C8B,
+ # { 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50 }}
+ 0x8D, 0x2B, 0xF1, 0xFF, 0x96, 0x76, 0x8B, 0x4C,
+ 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50,
+ # FvLength: 0x20000
+ 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ # Signature "_FVH" # Attributes
+ 0x5f, 0x46, 0x56, 0x48, 0xff, 0xfe, 0x04, 0x00,
+ # HeaderLength # CheckSum # ExtHeaderOffset #Reserved #Revision
+ 0x48, 0x00, 0x39, 0xF1, 0x00, 0x00, 0x00, 0x02,
+ # Blockmap[0]: 0x20 Blocks * 0x1000 Bytes / Block
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ # Blockmap[1]: End
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ ## This is the VARIABLE_STORE_HEADER
+!if $(SECURE_BOOT_ENABLE) == TRUE
+ # Signature: gEfiAuthenticatedVariableGuid =
+ # { 0xaaf32c78, 0x947b, 0x439a,
+ # { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 }}
+ 0x78, 0x2c, 0xf3, 0xaa, 0x7b, 0x94, 0x9a, 0x43,
+ 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92,
+!else
+ # Signature: gEfiVariableGuid =
+ # { 0xddcf3616, 0x3275, 0x4164,
+ # { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d }}
+ 0x16, 0x36, 0xcf, 0xdd, 0x75, 0x32, 0x64, 0x41,
+ 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d,
+!endif
+ # Size: 0x40000 (gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize) -
+ # 0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) = 0x3FFB8
+ # This can speed up the Variable Dispatch a bit.
+ 0xB8, 0xFF, 0x03, 0x00,
+ # FORMATTED: 0x5A #HEALTHY: 0xFE #Reserved: UINT16 #Reserved1: UINT32
+ 0x5A, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+}
+
+$(VARS_FTW_WORKING_OFFSET)|$(VARS_FTW_WORKING_SIZE)
+gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
+#
+#NV_FTW_WROK
+#
+DATA = {
+ # EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature = gEdkiiWorkingBlockSignatureGuid =
+ # { 0x9e58292b, 0x7c68, 0x497d, { 0xa0, 0xce, 0x65, 0x0, 0xfd, 0x9f, 0x1b, 0x95 }}
+ 0x2b, 0x29, 0x58, 0x9e, 0x68, 0x7c, 0x7d, 0x49,
+ 0xa0, 0xce, 0x65, 0x0, 0xfd, 0x9f, 0x1b, 0x95,
+ # Crc:UINT32 #WorkingBlockValid:1, WorkingBlockInvalid:1, Reserved
+ 0x2c, 0xaf, 0x2c, 0x64, 0xFE, 0xFF, 0xFF, 0xFF,
+ # WriteQueueSize: UINT64
+ 0xE0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+}
+
+$(VARS_FTW_SPARE_OFFSET)|$(VARS_FTW_SPARE_SIZE)
+gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
+#
+#NV_FTW_SPARE
--
2.38.0


[edk2-staging/RiscV64QemuVirt PATCH V5 27/30] OvmfPkg: Add VirtNorFlashPlatformLib library

Sunil V L
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076

Add the VirtNorFlashPlatformLib library for qemu virt machines.

Add two instances of the library. One which uses DT information
and the other which is static. They are copied from
ArmVirtPkg and SbsaQemu. Two PCD variables used by the library
are added in the OvmfPkg.

Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jordan Justen <jordan.l.justen@...>
Cc: Gerd Hoffmann <kraxel@...>
Cc: Daniel Schaefer <git@...>
Signed-off-by: Sunil V L <sunilvl@...>
---
OvmfPkg/OvmfPkg.dec | 4 +
OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.inf | 40 ++++++
OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.inf | 30 +++++
OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.c | 136 ++++++++++++++++++++
OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.c | 40 ++++++
5 files changed, 250 insertions(+)

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index ba5194114c5c..142c34193d60 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -409,6 +409,10 @@ [PcdsFixedAtBuild]
# check to decide whether to abort dispatch of the driver it is linked into.
gUefiOvmfPkgTokenSpaceGuid.PcdEntryPointOverrideFwCfgVarName|""|VOID*|0x68

+ ## The base address and size of the FVMAIN
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvBaseAddress|0|UINT64|0x71
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvSize|0|UINT32|0x72
+
[PcdsDynamic, PcdsDynamicEx]
gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10
diff --git a/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.inf b/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.inf
new file mode 100644
index 000000000000..5b7a45d15782
--- /dev/null
+++ b/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.inf
@@ -0,0 +1,40 @@
+#/** @file
+#
+# Component description file for VirtNorFlashDeviceTreeLib module
+#
+# Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = VirtNorFlashDeviceTreeLib
+ FILE_GUID = 42C30D8E-BFAD-4E77-9041-E7DAAE88DF7A
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = VirtNorFlashPlatformLib
+
+[Sources.common]
+ VirtNorFlashDeviceTreeLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+ EmbeddedPkg/EmbeddedPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ UefiBootServicesTableLib
+
+[Protocols]
+ gFdtClientProtocolGuid ## CONSUMES
+
+[Depex]
+ gFdtClientProtocolGuid
+
+[Pcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvBaseAddress
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvSize
diff --git a/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.inf b/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.inf
new file mode 100644
index 000000000000..4e87bd437380
--- /dev/null
+++ b/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.inf
@@ -0,0 +1,30 @@
+#/** @file
+#
+# Component description file for VirtNorFlashStaticLib module
+#
+# Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = VirtNorFlashStaticLib
+ FILE_GUID = 064742F1-E531-4D7D-A154-22315889CC23
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = VirtNorFlashPlatformLib
+
+[Sources.common]
+ VirtNorFlashStaticLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[Pcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
diff --git a/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.c b/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.c
new file mode 100644
index 000000000000..08750e66095d
--- /dev/null
+++ b/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.c
@@ -0,0 +1,136 @@
+/** @file
+
+ Copyright (c) 2014-2018, Linaro Ltd. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ **/
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/VirtNorFlashPlatformLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#include <Protocol/FdtClient.h>
+
+#define QEMU_NOR_BLOCK_SIZE SIZE_256KB
+
+#define MAX_FLASH_BANKS 4
+
+EFI_STATUS
+VirtNorFlashPlatformInitialization (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+VIRT_NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_BANKS];
+
+EFI_STATUS
+VirtNorFlashPlatformGetDevices (
+ OUT VIRT_NOR_FLASH_DESCRIPTION **NorFlashDescriptions,
+ OUT UINT32 *Count
+ )
+{
+ FDT_CLIENT_PROTOCOL *FdtClient;
+ INT32 Node;
+ EFI_STATUS Status;
+ EFI_STATUS FindNodeStatus;
+ CONST UINT32 *Reg;
+ UINT32 PropSize;
+ UINT32 Num;
+ UINT64 Base;
+ UINT64 Size;
+
+ Status = gBS->LocateProtocol (
+ &gFdtClientProtocolGuid,
+ NULL,
+ (VOID **)&FdtClient
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Num = 0;
+ for (FindNodeStatus = FdtClient->FindCompatibleNode (
+ FdtClient,
+ "cfi-flash",
+ &Node
+ );
+ !EFI_ERROR (FindNodeStatus) && Num < MAX_FLASH_BANKS;
+ FindNodeStatus = FdtClient->FindNextCompatibleNode (
+ FdtClient,
+ "cfi-flash",
+ Node,
+ &Node
+ ))
+ {
+ Status = FdtClient->GetNodeProperty (
+ FdtClient,
+ Node,
+ "reg",
+ (CONST VOID **)&Reg,
+ &PropSize
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: GetNodeProperty () failed (Status == %r)\n",
+ __FUNCTION__,
+ Status
+ ));
+ continue;
+ }
+
+ ASSERT ((PropSize % (4 * sizeof (UINT32))) == 0);
+
+ while (PropSize >= (4 * sizeof (UINT32)) && Num < MAX_FLASH_BANKS) {
+ Base = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[0]));
+ Size = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2]));
+ Reg += 4;
+
+ PropSize -= 4 * sizeof (UINT32);
+
+ //
+ // Disregard any flash devices that overlap with the primary FV.
+ // The firmware is not updatable from inside the guest anyway.
+ //
+ if ((PcdGet64 (PcdOvmfFvBaseAddress) + PcdGet32 (PcdOvmfFvSize) > Base) &&
+ ((Base + Size) > PcdGet64 (PcdOvmfFvBaseAddress)))
+ {
+ continue;
+ }
+
+ mNorFlashDevices[Num].DeviceBaseAddress = (UINTN)Base;
+ mNorFlashDevices[Num].RegionBaseAddress = (UINTN)Base;
+ mNorFlashDevices[Num].Size = (UINTN)Size;
+ mNorFlashDevices[Num].BlockSize = QEMU_NOR_BLOCK_SIZE;
+ Num++;
+ }
+
+ //
+ // UEFI takes ownership of the NOR flash, and exposes its functionality
+ // through the UEFI Runtime Services GetVariable, SetVariable, etc. This
+ // means we need to disable it in the device tree to prevent the OS from
+ // attaching its device driver as well.
+ // Note that this also hides other flash banks, but the only other flash
+ // bank we expect to encounter is the one that carries the UEFI executable
+ // code, which is not intended to be guest updatable, and is usually backed
+ // in a readonly manner by QEMU anyway.
+ //
+ Status = FdtClient->SetNodeProperty (
+ FdtClient,
+ Node,
+ "status",
+ "disabled",
+ sizeof ("disabled")
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_WARN, "Failed to set NOR flash status to 'disabled'\n"));
+ }
+ }
+
+ *NorFlashDescriptions = mNorFlashDevices;
+ *Count = Num;
+
+ return EFI_SUCCESS;
+}
diff --git a/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.c b/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.c
new file mode 100644
index 000000000000..fdc2ccb6294e
--- /dev/null
+++ b/OvmfPkg/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.c
@@ -0,0 +1,40 @@
+/** @file
+
+ Copyright (c) 2019, Linaro Ltd. All rights reserved
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ **/
+
+#include <Base.h>
+#include <PiDxe.h>
+#include <Library/VirtNorFlashPlatformLib.h>
+
+#define QEMU_NOR_BLOCK_SIZE SIZE_256KB
+
+EFI_STATUS
+VirtNorFlashPlatformInitialization (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+VIRT_NOR_FLASH_DESCRIPTION mNorFlashDevice =
+{
+ FixedPcdGet32 (PcdOvmfFdBaseAddress),
+ FixedPcdGet64 (PcdFlashNvStorageVariableBase),
+ FixedPcdGet32 (PcdOvmfFirmwareFdSize),
+ QEMU_NOR_BLOCK_SIZE
+};
+
+EFI_STATUS
+VirtNorFlashPlatformGetDevices (
+ OUT VIRT_NOR_FLASH_DESCRIPTION **NorFlashDescriptions,
+ OUT UINT32 *Count
+ )
+{
+ *NorFlashDescriptions = &mNorFlashDevice;
+ *Count = 1;
+ return EFI_SUCCESS;
+}
--
2.38.0


[edk2-staging/RiscV64QemuVirt PATCH V5 26/30] ArmVirtPkg: Update the references to NvVarStoreFormattedLib

Sunil V L
 

The NvVarStoreFormattedLib library is moved to MdeModulePkg.
So, updates its users with the new location.

Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Leif Lindholm <quic_llindhol@...>
Cc: Sami Mujawar <sami.mujawar@...>
Cc: Gerd Hoffmann <kraxel@...>
Signed-off-by: Sunil V L <sunilvl@...>
---
ArmVirtPkg/ArmVirtKvmTool.dsc | 2 +-
ArmVirtPkg/ArmVirtQemu.dsc | 2 +-
ArmVirtPkg/ArmVirtQemuKernel.dsc | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc
index c598903b33d2..a9f8b9ec6946 100644
--- a/ArmVirtPkg/ArmVirtKvmTool.dsc
+++ b/ArmVirtPkg/ArmVirtKvmTool.dsc
@@ -258,7 +258,7 @@ [Components.common]
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
<LibraryClasses>
NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
- NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
+ NULL|MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
}

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 1d8b6dc9c04c..cd21fcb760a5 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -383,7 +383,7 @@ [Components.common]
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
<LibraryClasses>
NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
- NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
+ NULL|MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
# don't use unaligned CopyMem () on the UEFI varstore NOR flash region
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
}
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index 91119c2df9c4..c9c12827ca88 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -294,7 +294,7 @@ [Components.common]
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
<LibraryClasses>
NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
- NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
+ NULL|MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
# don't use unaligned CopyMem () on the UEFI varstore NOR flash region
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
}
--
2.38.0


[edk2-staging/RiscV64QemuVirt PATCH V5 25/30] EmbeddedPkg/NvVarStoreFormattedLib: Migrate to MdeModulePkg

Sunil V L
 

This library is required by NorFlashDxe. Since it will be used by
both virtual and real platforms, migrate this library to
MdeModulePkg.

Cc: Leif Lindholm <quic_llindhol@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Abner Chang <abner.chang@...>
Cc: Daniel Schaefer <git@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Liming Gao <gaoliming@...>
Cc: Andrew Fish <afish@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Signed-off-by: Sunil V L <sunilvl@...>
Acked-by: Ard Biesheuvel <ardb@...>
---
EmbeddedPkg/EmbeddedPkg.dec | 3 ---
MdeModulePkg/MdeModulePkg.dec | 3 +++
MdeModulePkg/MdeModulePkg.dsc | 2 ++
{EmbeddedPkg => MdeModulePkg}/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf | 1 -
{EmbeddedPkg => MdeModulePkg}/Include/Guid/NvVarStoreFormatted.h | 0
{EmbeddedPkg => MdeModulePkg}/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.c | 0
6 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
index 341ef5e6a679..b1f5654835f6 100644
--- a/EmbeddedPkg/EmbeddedPkg.dec
+++ b/EmbeddedPkg/EmbeddedPkg.dec
@@ -69,9 +69,6 @@ [Guids.common]
# HII form set GUID for ConsolePrefDxe driver
gConsolePrefFormSetGuid = { 0x2d2358b4, 0xe96c, 0x484d, { 0xb2, 0xdd, 0x7c, 0x2e, 0xdf, 0xc7, 0xd5, 0x6f } }

- ## Include/Guid/NvVarStoreFormatted.h
- gEdkiiNvVarStoreFormattedGuid = { 0xd1a86e3f, 0x0707, 0x4c35, { 0x83, 0xcd, 0xdc, 0x2c, 0x29, 0xc8, 0x91, 0xa3 } }
-
[Protocols.common]
gHardwareInterruptProtocolGuid = { 0x2890B3EA, 0x053D, 0x1643, { 0xAD, 0x0C, 0xD6, 0x48, 0x08, 0xDA, 0x3F, 0xF1 } }
gHardwareInterrupt2ProtocolGuid = { 0x32898322, 0x2da1, 0x474a, { 0xba, 0xaa, 0xf3, 0xf7, 0xcf, 0x56, 0x94, 0x70 } }
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 58e6ab004882..492bff8b7890 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -412,6 +412,9 @@ [Guids]
## Include/Guid/MigratedFvInfo.h
gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4, 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }

+ ## Include/Guid/NvVarStoreFormatted.h
+ gEdkiiNvVarStoreFormattedGuid = { 0xd1a86e3f, 0x0707, 0x4c35, { 0x83, 0xcd, 0xdc, 0x2c, 0x29, 0xc8, 0x91, 0xa3 } }
+
#
# GUID defined in UniversalPayload
#
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 659482ab737f..4142e1178dcd 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -104,6 +104,7 @@ [LibraryClasses]
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
+ NvVarStoreFormattedLib|MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf

[LibraryClasses.EBC.PEIM]
IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
@@ -443,6 +444,7 @@ [Components]
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
+ MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf

[Components.IA32, Components.X64, Components.AARCH64]
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
diff --git a/EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf b/MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
similarity index 96%
rename from EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
rename to MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
index e2eed26c5b2d..5e8cd94cc9e0 100644
--- a/EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
+++ b/MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
@@ -32,7 +32,6 @@ [Sources]
NvVarStoreFormattedLib.c

[Packages]
- EmbeddedPkg/EmbeddedPkg.dec
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec

diff --git a/EmbeddedPkg/Include/Guid/NvVarStoreFormatted.h b/MdeModulePkg/Include/Guid/NvVarStoreFormatted.h
similarity index 100%
rename from EmbeddedPkg/Include/Guid/NvVarStoreFormatted.h
rename to MdeModulePkg/Include/Guid/NvVarStoreFormatted.h
diff --git a/EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.c b/MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.c
similarity index 100%
rename from EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.c
rename to MdeModulePkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.c
--
2.38.0


[edk2-staging/RiscV64QemuVirt PATCH V5 24/30] ArmVirtPkg: Fix up the paths to PlatformBootManagerLib

Sunil V L
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076

PlatformBootManagerLib has been moved to OvmfPkg so that other
CPU architectures can reuse. So, update existing paths with the
new location.

Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Leif Lindholm <quic_llindhol@...>
Cc: Sami Mujawar <sami.mujawar@...>
Cc: Gerd Hoffmann <kraxel@...>
Signed-off-by: Sunil V L <sunilvl@...>
---
ArmVirtPkg/ArmVirtQemu.dsc | 4 ++--
ArmVirtPkg/ArmVirtQemuKernel.dsc | 4 ++--
ArmVirtPkg/ArmVirtPkg.ci.yaml | 1 -
3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 2ed1e15a08ca..1d8b6dc9c04c 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -69,7 +69,7 @@ [LibraryClasses.common]

CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
- PlatformBootManagerLib|ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+ PlatformBootManagerLib|OvmfPkg/Library/PlatformBootManagerLibVirt/PlatformBootManagerLib.inf
PlatformBmPrintScLib|OvmfPkg/Library/PlatformBmPrintScLib/PlatformBmPrintScLib.inf
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
@@ -173,7 +173,7 @@ [PcdsFixedAtBuild.common]
!if $(TTY_TERMINAL) == TRUE
gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4
# Set terminal type to TtyTerm, the value encoded is EFI_TTY_TERM_GUID
- gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 0x91, 0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94}
+ gUefiOvmfPkgTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 0x91, 0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94}
!else
gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|1
!endif
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index d6f4ac5166d7..91119c2df9c4 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -69,7 +69,7 @@ [LibraryClasses.common]

CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
- PlatformBootManagerLib|ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+ PlatformBootManagerLib|OvmfPkg/Library/PlatformBootManagerLibVirt/PlatformBootManagerLib.inf
PlatformBmPrintScLib|OvmfPkg/Library/PlatformBmPrintScLib/PlatformBmPrintScLib.inf
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
@@ -146,7 +146,7 @@ [PcdsFixedAtBuild.common]
!if $(TTY_TERMINAL) == TRUE
gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4
# Set terminal type to TtyTerm, the value encoded is EFI_TTY_TERM_GUID
- gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 0x91, 0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94}
+ gUefiOvmfPkgTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x80, 0x6d, 0x91, 0x7d, 0xb1, 0x5b, 0x8c, 0x45, 0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94}
!else
gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|1
!endif
diff --git a/ArmVirtPkg/ArmVirtPkg.ci.yaml b/ArmVirtPkg/ArmVirtPkg.ci.yaml
index 1e799dc4e194..552511c2694e 100644
--- a/ArmVirtPkg/ArmVirtPkg.ci.yaml
+++ b/ArmVirtPkg/ArmVirtPkg.ci.yaml
@@ -24,7 +24,6 @@
],
## Both file path and directory path are accepted.
"IgnoreFiles": [
- "Library/PlatformBootManagerLib/PlatformBm.c"
]
},
## options defined .pytool/Plugin/CompilerPlugin
--
2.38.0


[edk2-staging/RiscV64QemuVirt PATCH V5 23/30] ArmVirtPkg/PlatformBootManagerLib: Move to OvmfPkg

Sunil V L
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076

PlatformBootManagerLib in ArmVirtPkg is required for RISC-V
also. So, move it to OvmfPkg.

Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Leif Lindholm <quic_llindhol@...>
Cc: Sami Mujawar <sami.mujawar@...>
Cc: Gerd Hoffmann <kraxel@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jordan Justen <jordan.l.justen@...>
Signed-off-by: Sunil V L <sunilvl@...>
---
OvmfPkg/OvmfPkg.dec | 7 +++++++
{ArmVirtPkg/Library/PlatformBootManagerLib => OvmfPkg/Library/PlatformBootManagerLibVirt}/PlatformBootManagerLib.inf | 3 +--
{ArmVirtPkg/Library/PlatformBootManagerLib => OvmfPkg/Library/PlatformBootManagerLibVirt}/PlatformBm.h | 0
{ArmVirtPkg/Library/PlatformBootManagerLib => OvmfPkg/Library/PlatformBootManagerLibVirt}/PlatformBm.c | 0
{ArmVirtPkg/Library/PlatformBootManagerLib => OvmfPkg/Library/PlatformBootManagerLibVirt}/QemuKernel.c | 0
OvmfPkg/OvmfPkg.ci.yaml | 1 +
6 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index 7df05770b5d6..ba5194114c5c 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -467,6 +467,13 @@ [PcdsDynamic, PcdsDynamicEx]
#
gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi|0x0|BOOLEAN|0x69

+ #
+ # Binary representation of the GUID that determines the terminal type. The
+ # size must be exactly 16 bytes. The default value corresponds to
+ # EFI_VT_100_GUID.
+ #
+ gUefiOvmfPkgTokenSpaceGuid.PcdTerminalTypeGuidBuffer|{0x65, 0x60, 0xA6, 0xDF, 0x19, 0xB4, 0xD3, 0x11, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D}|VOID*|0x70
+
[PcdsFeatureFlag]
gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c
gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN|0x1d
diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/OvmfPkg/Library/PlatformBootManagerLibVirt/PlatformBootManagerLib.inf
similarity index 92%
rename from ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
rename to OvmfPkg/Library/PlatformBootManagerLibVirt/PlatformBootManagerLib.inf
index 997eb1a4429f..a747ea3feac0 100644
--- a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/OvmfPkg/Library/PlatformBootManagerLibVirt/PlatformBootManagerLib.inf
@@ -29,7 +29,6 @@ [Sources]
QemuKernel.c

[Packages]
- ArmVirtPkg/ArmVirtPkg.dec
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
@@ -61,7 +60,7 @@ [FixedPcd]
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits

[Pcd]
- gArmVirtTokenSpaceGuid.PcdTerminalTypeGuidBuffer
+ gUefiOvmfPkgTokenSpaceGuid.PcdTerminalTypeGuidBuffer
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut

[Guids]
diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.h b/OvmfPkg/Library/PlatformBootManagerLibVirt/PlatformBm.h
similarity index 100%
rename from ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.h
rename to OvmfPkg/Library/PlatformBootManagerLibVirt/PlatformBm.h
diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c b/OvmfPkg/Library/PlatformBootManagerLibVirt/PlatformBm.c
similarity index 100%
rename from ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
rename to OvmfPkg/Library/PlatformBootManagerLibVirt/PlatformBm.c
diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/QemuKernel.c b/OvmfPkg/Library/PlatformBootManagerLibVirt/QemuKernel.c
similarity index 100%
rename from ArmVirtPkg/Library/PlatformBootManagerLib/QemuKernel.c
rename to OvmfPkg/Library/PlatformBootManagerLibVirt/QemuKernel.c
diff --git a/OvmfPkg/OvmfPkg.ci.yaml b/OvmfPkg/OvmfPkg.ci.yaml
index ff022242b018..c6efb9a8e59e 100644
--- a/OvmfPkg/OvmfPkg.ci.yaml
+++ b/OvmfPkg/OvmfPkg.ci.yaml
@@ -22,6 +22,7 @@
],
## Both file path and directory path are accepted.
"IgnoreFiles": [
+ "Library/PlatformBootManagerLibVirt/PlatformBm.c"
],
"skip": True
},
--
2.38.0


[edk2-staging/RiscV64QemuVirt PATCH V5 22/30] ArmVirtPkg: Fix up the location of PlatformHasAcpiDtDxe

Sunil V L
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076

PlatformHasAcpiDtDxe is required by other architectures also.
Hence, it is moved to OvmfPkg. So, update the consumers of this
module with the new location.

Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Leif Lindholm <quic_llindhol@...>
Cc: Sami Mujawar <sami.mujawar@...>
Cc: Gerd Hoffmann <kraxel@...>
Signed-off-by: Sunil V L <sunilvl@...>
---
ArmVirtPkg/ArmVirtCloudHv.dsc | 2 +-
ArmVirtPkg/ArmVirtQemu.dsc | 4 ++--
ArmVirtPkg/ArmVirtQemuKernel.dsc | 2 +-
ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.inf | 2 +-
ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf | 2 +-
ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtCloudHv.dsc b/ArmVirtPkg/ArmVirtCloudHv.dsc
index 7ca7a391d9cf..c975e139a216 100644
--- a/ArmVirtPkg/ArmVirtCloudHv.dsc
+++ b/ArmVirtPkg/ArmVirtCloudHv.dsc
@@ -198,7 +198,7 @@ [PcdsDynamicDefault.common]
gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress|0x0

[PcdsDynamicHii]
- gArmVirtTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gArmVirtVariableGuid|0x0|FALSE|NV,BS
+ gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gOvmfVariableGuid|0x0|FALSE|NV,BS

################################################################################
#
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index f77443229e8e..2ed1e15a08ca 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -300,7 +300,7 @@ [PcdsPatchableInModule]
!endif

[PcdsDynamicHii]
- gArmVirtTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gArmVirtVariableGuid|0x0|FALSE|NV,BS
+ gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gOvmfVariableGuid|0x0|FALSE|NV,BS

!if $(TPM2_CONFIG_ENABLE) == TRUE
gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer|L"TCG2_VERSION"|gTcg2ConfigFormSetGuid|0x0|"1.3"|NV,BS
@@ -569,7 +569,7 @@ [Components.common]
#
# ACPI Support
#
- ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
+ OvmfPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
[Components.AARCH64]
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf {
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index f5db3ac432f3..d6f4ac5166d7 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -457,7 +457,7 @@ [Components.common]
#
# ACPI Support
#
- ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
+ OvmfPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
[Components.AARCH64]
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf {
diff --git a/ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.inf b/ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.inf
index 4af06b2a6746..7cad40e11f33 100644
--- a/ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.inf
+++ b/ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.inf
@@ -36,7 +36,7 @@ [Guids]
gEdkiiPlatformHasDeviceTreeGuid ## SOMETIMES_PRODUCES ## PROTOCOL

[Pcd]
- gArmVirtTokenSpaceGuid.PcdForceNoAcpi
+ gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi

[Depex]
gEfiVariableArchProtocolGuid
diff --git a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf
index 1cf25780f830..5888fcdc0b26 100644
--- a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf
+++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf
@@ -37,7 +37,7 @@ [Guids]
gEdkiiPlatformHasDeviceTreeGuid ## SOMETIMES_PRODUCES ## PROTOCOL

[Pcd]
- gArmVirtTokenSpaceGuid.PcdForceNoAcpi
+ gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi

[Depex]
TRUE
diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
index e06ca7424476..8a063bac04ac 100644
--- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
+++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
@@ -141,7 +141,7 @@ [FV.FvMain]
#
# ACPI Support
#
- INF ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
+ INF OvmfPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
!if $(ARCH) == AARCH64
INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
--
2.38.0