Re: [edk2-devel] [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid using ACPI reclaim memory
Hi Liming, Can you help merge the patch? Thanks. Best, Aaron -Original Message- From: gaoliming Sent: Tuesday, April 2, 2024 9:26 AM To: devel@edk2.groups.io; Li, Aaron Cc: Bi, Dandan ; Liu, Yun Y ; Yao, Jiewen ; Ni, Ray ; Kinney, Michael D ; Liu, Zhiguang Subject: 回复: [edk2-devel] [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid using ACPI reclaim memory Aaron: Per the specification, it is valid to publish all ACPI table in EfiAcpiMemoryNVS. So, I have no other comments for this patch. Reviewed-by: Liming Gao Thanks Liming > -邮件原件- > 发件人: devel@edk2.groups.io 代表 Aaron Li > 发送时间: 2024年4月1日 10:32 > 收件人: devel@edk2.groups.io; Liming Gao > 抄送: Bi, Dandan ; Liu, Yun Y ; > Yao, Jiewen ; Ni, Ray ; Kinney, > Michael D ; Liu, Zhiguang > > 主题: Re: [edk2-devel] [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD > switch to avoid using ACPI reclaim memory > > Hi Liming, > > Could you please help review and merge it? Thanks. > > Best, > Aaron > > -Original Message- > From: Liu, Zhiguang > Sent: Monday, April 1, 2024 10:06 AM > To: Li, Aaron ; devel@edk2.groups.io > Cc: Bi, Dandan ; Liming Gao > ; Liu, Yun Y ; Yao, Jiewen > ; Ni, Ray ; Kinney, Michael D > > Subject: RE: [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to > avoid using ACPI reclaim memory > > Reviewed-by: Zhiguang Liu > > > -Original Message- > > From: Li, Aaron > > Sent: Tuesday, March 26, 2024 3:58 PM > > To: devel@edk2.groups.io > > Cc: Liu, Zhiguang ; Bi, Dandan > > ; Liming Gao ; Liu, Yun > Y > > ; Yao, Jiewen ; Ni, Ray > > ; Kinney, Michael D > > Subject: [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid > > using ACPI reclaim memory > > > > UEFI spec defined ACPI Tables at boot time can be contained in memory of > > type EfiACPIReclaimMemory or EfiAcpiMemoryNVS, although > InstallAcpiTable > > with AcpiTableProtocol will only allocate memory with type > > EfiACPIReclaimMemory (Except FACS). > > > > This patch provides an optional method controlled by PCD to avoid using > > EfiACPIReclaimMemory, by setting the PCD PcdNoACPIReclaimMemory to > > TRUE, all ACPI allocated memory will use EfiAcpiMemoryNVS instead. > > > > Cc: Zhiguang Liu > > Cc: Dandan Bi > > Cc: Liming Gao > > Cc: Liu Yun > > Cc: Jiewen Yao > > Cc: Ray Ni > > Cc: Michael D Kinney > > Signed-off-by: Aaron Li > > --- > > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 37 > > +++- > > MdeModulePkg/MdeModulePkg.dec > | 7 > > MdeModulePkg/MdeModulePkg.uni > | 8 + > > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf| 1 > + > > 4 files changed, 45 insertions(+), 8 deletions(-) > > > > diff --git > a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > > b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > > index e09bc9b704f5..080768033cfa 100644 > > --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > > +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > > @@ -340,6 +340,7 @@ ReallocateAcpiTableBuffer ( > >EFI_ACPI_TABLE_INSTANCE TempPrivateData; > >EFI_STATUS Status; > >UINT64 CurrentData; > > + EFI_MEMORY_TYPE AcpiAllocateMemoryType; > > > >CopyMem (, AcpiTableInstance, sizeof > > (EFI_ACPI_TABLE_INSTANCE)); > >// > > @@ -359,6 +360,12 @@ ReallocateAcpiTableBuffer ( > > NewMaxTableNumber * sizeof (UINT32); > >} > > > > + if (PcdGetBool (PcdNoACPIReclaimMemory)) { > > +AcpiAllocateMemoryType = EfiACPIMemoryNVS; } else { > > +AcpiAllocateMemoryType = EfiACPIReclaimMemory; } > > + > >if (mAcpiTableAllocType != AllocateAnyPages) { > > // > > // Allocate memory in the lower 32 bit of address range for @@ > -372,13 > > +379,13 @@ ReallocateAcpiTableBuffer ( > > PageAddress = 0x; > > Status = gBS->AllocatePages ( > > mAcpiTableAllocType, > > - EfiACPIReclaimMemory, > > + AcpiAllocateMemoryType, > > EFI_SIZE_TO_PAGES (TotalSize), > > > > ); > >} else { > > Status = gBS->AllocatePool ( > > -EfiACPIReclaimMemory, > > +AcpiAllocateMemoryType, > > TotalSize, > >
Re: [edk2-devel] [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid using ACPI reclaim memory
Hi Liming, Could you please help review and merge it? Thanks. Best, Aaron -Original Message- From: Liu, Zhiguang Sent: Monday, April 1, 2024 10:06 AM To: Li, Aaron ; devel@edk2.groups.io Cc: Bi, Dandan ; Liming Gao ; Liu, Yun Y ; Yao, Jiewen ; Ni, Ray ; Kinney, Michael D Subject: RE: [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid using ACPI reclaim memory Reviewed-by: Zhiguang Liu > -Original Message- > From: Li, Aaron > Sent: Tuesday, March 26, 2024 3:58 PM > To: devel@edk2.groups.io > Cc: Liu, Zhiguang ; Bi, Dandan > ; Liming Gao ; Liu, Yun Y > ; Yao, Jiewen ; Ni, Ray > ; Kinney, Michael D > Subject: [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid > using ACPI reclaim memory > > UEFI spec defined ACPI Tables at boot time can be contained in memory of > type EfiACPIReclaimMemory or EfiAcpiMemoryNVS, although InstallAcpiTable > with AcpiTableProtocol will only allocate memory with type > EfiACPIReclaimMemory (Except FACS). > > This patch provides an optional method controlled by PCD to avoid using > EfiACPIReclaimMemory, by setting the PCD PcdNoACPIReclaimMemory to > TRUE, all ACPI allocated memory will use EfiAcpiMemoryNVS instead. > > Cc: Zhiguang Liu > Cc: Dandan Bi > Cc: Liming Gao > Cc: Liu Yun > Cc: Jiewen Yao > Cc: Ray Ni > Cc: Michael D Kinney > Signed-off-by: Aaron Li > --- > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 37 > +++- > MdeModulePkg/MdeModulePkg.dec| 7 > MdeModulePkg/MdeModulePkg.uni| 8 + > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf| 1 + > 4 files changed, 45 insertions(+), 8 deletions(-) > > diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > index e09bc9b704f5..080768033cfa 100644 > --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > @@ -340,6 +340,7 @@ ReallocateAcpiTableBuffer ( >EFI_ACPI_TABLE_INSTANCE TempPrivateData; >EFI_STATUS Status; >UINT64 CurrentData; > + EFI_MEMORY_TYPE AcpiAllocateMemoryType; > >CopyMem (, AcpiTableInstance, sizeof > (EFI_ACPI_TABLE_INSTANCE)); >// > @@ -359,6 +360,12 @@ ReallocateAcpiTableBuffer ( > NewMaxTableNumber * sizeof (UINT32); >} > > + if (PcdGetBool (PcdNoACPIReclaimMemory)) { > +AcpiAllocateMemoryType = EfiACPIMemoryNVS; } else { > +AcpiAllocateMemoryType = EfiACPIReclaimMemory; } > + >if (mAcpiTableAllocType != AllocateAnyPages) { > // > // Allocate memory in the lower 32 bit of address range for @@ -372,13 > +379,13 @@ ReallocateAcpiTableBuffer ( > PageAddress = 0x; > Status = gBS->AllocatePages ( > mAcpiTableAllocType, > - EfiACPIReclaimMemory, > + AcpiAllocateMemoryType, > EFI_SIZE_TO_PAGES (TotalSize), > > ); >} else { > Status = gBS->AllocatePool ( > -EfiACPIReclaimMemory, > +AcpiAllocateMemoryType, > TotalSize, > (VOID **) > ); > @@ -512,6 +519,7 @@ AddTableToList ( >EFI_PHYSICAL_ADDRESS AllocPhysAddress; >UINT64Buffer64; >BOOLEAN AddToRsdt; > + EFI_MEMORY_TYPE AcpiAllocateMemoryType; > >// >// Check for invalid input parameters @@ -550,6 +558,12 @@ > AddTableToList ( >CurrentTableList->TableSize = CurrentTableSize; >CurrentTableList->PoolAllocation = FALSE; > > + if (PcdGetBool (PcdNoACPIReclaimMemory)) { > +AcpiAllocateMemoryType = EfiACPIMemoryNVS; } else { > +AcpiAllocateMemoryType = EfiACPIReclaimMemory; } > + >// >// Allocation memory type depends on the type of the table >// > @@ -585,7 +599,7 @@ AddTableToList ( > // such as AArch64 that allocate multiples of 64 KB > // > Status = gBS->AllocatePool ( > -EfiACPIReclaimMemory, > +AcpiAllocateMemoryType, > CurrentTableList->TableSize, > (VOID **)>Table > ); > @@ -596,7 +610,7 @@ AddTableToList ( > // > Status = gBS->AllocatePages ( > mAcpiTableAllocType, > -EfiACPIReclaimMemory, > +
Re: [edk2-devel] [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid using ACPI reclaim memory
Hi Ard, We have a feature that requires to publish all ACPI table in EfiAcpiMemoryNVS. Currently only table "FACS" and "UEFI" was published in NVS memory. Best, Aaron -Original Message- From: devel@edk2.groups.io On Behalf Of Ard Biesheuvel Sent: Thursday, March 28, 2024 1:59 PM To: devel@edk2.groups.io; Li, Aaron Cc: gaoliming ; Liu, Zhiguang ; Bi, Dandan ; Liu, Yun Y ; Yao, Jiewen ; Ni, Ray ; Kinney, Michael D Subject: Re: [edk2-devel] [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid using ACPI reclaim memory Hello Aaron, Could you describe the problem that is being solved by the ability to use EfiAcpiMemoryNVS for ACPI tables? On Thu, 28 Mar 2024 at 05:59, Aaron Li wrote: > > Hi Liming, > > Currently this patch does not have a related Bugzilla. > > According to UEFI spec, the ACPI Tables at boot time can be contained in > memory of type EfiACPIReclaimMemory or EfiAcpiMemoryNVS. > Current implementation in AcpiTableDxe only allocate memory with type > EfiACPIReclaimMemory by default. > This patch provides an option method to let ACPI Tables be allocated in > memory with type EfiAcpiMemoryNVS controlled by PCD. > > > Best, > Aaron > > -Original Message- > From: gaoliming > Sent: Thursday, March 28, 2024 9:15 AM > To: Li, Aaron ; devel@edk2.groups.io > Cc: Liu, Zhiguang ; Bi, Dandan ; > Liu, Yun Y ; Yao, Jiewen ; Ni, Ray > ; Kinney, Michael D > Subject: 回复: [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid > using ACPI reclaim memory > > Aaron: > Is there a Bugzilla for this issue? What problem will be resolved with this > change? > > Thanks > Liming > > -邮件原件- > > 发件人: Aaron Li > > 发送时间: 2024年3月26日 15:58 > > 收件人: devel@edk2.groups.io > > 抄送: Zhiguang Liu ; Dandan Bi > > ; Liming Gao ; Liu Yun > > ; Jiewen Yao ; Ray Ni > > ; Michael D Kinney > > 主题: [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid > > using ACPI reclaim memory > > > > UEFI spec defined ACPI Tables at boot time can be contained in memory of > > type EfiACPIReclaimMemory or EfiAcpiMemoryNVS, although InstallAcpiTable > > with AcpiTableProtocol will only allocate memory with type > > EfiACPIReclaimMemory (Except FACS). > > > > This patch provides an optional method controlled by PCD to avoid using > > EfiACPIReclaimMemory, by setting the PCD PcdNoACPIReclaimMemory to > > TRUE, > > all ACPI allocated memory will use EfiAcpiMemoryNVS instead. > > > > Cc: Zhiguang Liu > > Cc: Dandan Bi > > Cc: Liming Gao > > Cc: Liu Yun > > Cc: Jiewen Yao > > Cc: Ray Ni > > Cc: Michael D Kinney > > Signed-off-by: Aaron Li > > --- > > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 37 > > +++- > > MdeModulePkg/MdeModulePkg.dec > > | 7 > > MdeModulePkg/MdeModulePkg.uni > > | 8 + > > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf| 1 + > > 4 files changed, 45 insertions(+), 8 deletions(-) > > > > diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > > b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > > index e09bc9b704f5..080768033cfa 100644 > > --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > > +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > > @@ -340,6 +340,7 @@ ReallocateAcpiTableBuffer ( > >EFI_ACPI_TABLE_INSTANCE TempPrivateData; > >EFI_STATUS Status; > >UINT64 CurrentData; > > + EFI_MEMORY_TYPE AcpiAllocateMemoryType; > > > >CopyMem (, AcpiTableInstance, sizeof > > (EFI_ACPI_TABLE_INSTANCE)); > >// > > @@ -359,6 +360,12 @@ ReallocateAcpiTableBuffer ( > > NewMaxTableNumber * sizeof (UINT32); > >} > > > > + if (PcdGetBool (PcdNoACPIReclaimMemory)) { > > +AcpiAllocateMemoryType = EfiACPIMemoryNVS; > > + } else { > > +AcpiAllocateMemoryType = EfiACPIReclaimMemory; > > + } > > + > >if (mAcpiTableAllocType != AllocateAnyPages) { > > // > > // Allocate memory in the lower 32 bit of address range for > > @@ -372,13 +379,13 @@ ReallocateAcpiTableBuffer ( > > PageAddress = 0x; > > Status = gBS->AllocatePages ( > > mAcpiTableAllocType, > > - EfiACPIReclaimMemory, > > + AcpiAllocateMemoryType, > > EFI_SIZE_TO_PAGES (TotalSize), > >
Re: [edk2-devel] [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid using ACPI reclaim memory
Hi Liming, Currently this patch does not have a related Bugzilla. According to UEFI spec, the ACPI Tables at boot time can be contained in memory of type EfiACPIReclaimMemory or EfiAcpiMemoryNVS. Current implementation in AcpiTableDxe only allocate memory with type EfiACPIReclaimMemory by default. This patch provides an option method to let ACPI Tables be allocated in memory with type EfiAcpiMemoryNVS controlled by PCD. Best, Aaron -Original Message- From: gaoliming Sent: Thursday, March 28, 2024 9:15 AM To: Li, Aaron ; devel@edk2.groups.io Cc: Liu, Zhiguang ; Bi, Dandan ; Liu, Yun Y ; Yao, Jiewen ; Ni, Ray ; Kinney, Michael D Subject: 回复: [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid using ACPI reclaim memory Aaron: Is there a Bugzilla for this issue? What problem will be resolved with this change? Thanks Liming > -邮件原件- > 发件人: Aaron Li > 发送时间: 2024年3月26日 15:58 > 收件人: devel@edk2.groups.io > 抄送: Zhiguang Liu ; Dandan Bi > ; Liming Gao ; Liu Yun > ; Jiewen Yao ; Ray Ni > ; Michael D Kinney > 主题: [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid > using ACPI reclaim memory > > UEFI spec defined ACPI Tables at boot time can be contained in memory of > type EfiACPIReclaimMemory or EfiAcpiMemoryNVS, although InstallAcpiTable > with AcpiTableProtocol will only allocate memory with type > EfiACPIReclaimMemory (Except FACS). > > This patch provides an optional method controlled by PCD to avoid using > EfiACPIReclaimMemory, by setting the PCD PcdNoACPIReclaimMemory to > TRUE, > all ACPI allocated memory will use EfiAcpiMemoryNVS instead. > > Cc: Zhiguang Liu > Cc: Dandan Bi > Cc: Liming Gao > Cc: Liu Yun > Cc: Jiewen Yao > Cc: Ray Ni > Cc: Michael D Kinney > Signed-off-by: Aaron Li > --- > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 37 > +++- > MdeModulePkg/MdeModulePkg.dec > | 7 > MdeModulePkg/MdeModulePkg.uni > | 8 + > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf| 1 + > 4 files changed, 45 insertions(+), 8 deletions(-) > > diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > index e09bc9b704f5..080768033cfa 100644 > --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > @@ -340,6 +340,7 @@ ReallocateAcpiTableBuffer ( >EFI_ACPI_TABLE_INSTANCE TempPrivateData; >EFI_STATUS Status; >UINT64 CurrentData; > + EFI_MEMORY_TYPE AcpiAllocateMemoryType; > >CopyMem (, AcpiTableInstance, sizeof > (EFI_ACPI_TABLE_INSTANCE)); >// > @@ -359,6 +360,12 @@ ReallocateAcpiTableBuffer ( > NewMaxTableNumber * sizeof (UINT32); >} > > + if (PcdGetBool (PcdNoACPIReclaimMemory)) { > +AcpiAllocateMemoryType = EfiACPIMemoryNVS; > + } else { > +AcpiAllocateMemoryType = EfiACPIReclaimMemory; > + } > + >if (mAcpiTableAllocType != AllocateAnyPages) { > // > // Allocate memory in the lower 32 bit of address range for > @@ -372,13 +379,13 @@ ReallocateAcpiTableBuffer ( > PageAddress = 0x; > Status = gBS->AllocatePages ( > mAcpiTableAllocType, > - EfiACPIReclaimMemory, > + AcpiAllocateMemoryType, > EFI_SIZE_TO_PAGES (TotalSize), > > ); >} else { > Status = gBS->AllocatePool ( > -EfiACPIReclaimMemory, > +AcpiAllocateMemoryType, > TotalSize, > (VOID **) > ); > @@ -512,6 +519,7 @@ AddTableToList ( >EFI_PHYSICAL_ADDRESS AllocPhysAddress; >UINT64Buffer64; >BOOLEAN AddToRsdt; > + EFI_MEMORY_TYPE AcpiAllocateMemoryType; > >// >// Check for invalid input parameters > @@ -550,6 +558,12 @@ AddTableToList ( >CurrentTableList->TableSize = CurrentTableSize; >CurrentTableList->PoolAllocation = FALSE; > > + if (PcdGetBool (PcdNoACPIReclaimMemory)) { > +AcpiAllocateMemoryType = EfiACPIMemoryNVS; > + } else { > +AcpiAllocateMemoryType = EfiACPIReclaimMemory; > + } > + >// >// Allocation memory type depends on the type of the table >// > @@ -585,7 +599,7 @@ AddTableToList ( > // such as AArch64 that allocate multiples of 64 KB > // > Status = gBS->AllocatePool ( > -EfiACPIReclaimMemory
[edk2-devel] [PATCH v2 1/1] MdeModulePkg/AcpiTableDxe: PCD switch to avoid using ACPI reclaim memory
UEFI spec defined ACPI Tables at boot time can be contained in memory of type EfiACPIReclaimMemory or EfiAcpiMemoryNVS, although InstallAcpiTable with AcpiTableProtocol will only allocate memory with type EfiACPIReclaimMemory (Except FACS). This patch provides an optional method controlled by PCD to avoid using EfiACPIReclaimMemory, by setting the PCD PcdNoACPIReclaimMemory to TRUE, all ACPI allocated memory will use EfiAcpiMemoryNVS instead. Cc: Zhiguang Liu Cc: Dandan Bi Cc: Liming Gao Cc: Liu Yun Cc: Jiewen Yao Cc: Ray Ni Cc: Michael D Kinney Signed-off-by: Aaron Li --- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 37 +++- MdeModulePkg/MdeModulePkg.dec| 7 MdeModulePkg/MdeModulePkg.uni| 8 + MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf| 1 + 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c index e09bc9b704f5..080768033cfa 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c @@ -340,6 +340,7 @@ ReallocateAcpiTableBuffer ( EFI_ACPI_TABLE_INSTANCE TempPrivateData; EFI_STATUS Status; UINT64 CurrentData; + EFI_MEMORY_TYPE AcpiAllocateMemoryType; CopyMem (, AcpiTableInstance, sizeof (EFI_ACPI_TABLE_INSTANCE)); // @@ -359,6 +360,12 @@ ReallocateAcpiTableBuffer ( NewMaxTableNumber * sizeof (UINT32); } + if (PcdGetBool (PcdNoACPIReclaimMemory)) { +AcpiAllocateMemoryType = EfiACPIMemoryNVS; + } else { +AcpiAllocateMemoryType = EfiACPIReclaimMemory; + } + if (mAcpiTableAllocType != AllocateAnyPages) { // // Allocate memory in the lower 32 bit of address range for @@ -372,13 +379,13 @@ ReallocateAcpiTableBuffer ( PageAddress = 0x; Status = gBS->AllocatePages ( mAcpiTableAllocType, - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, EFI_SIZE_TO_PAGES (TotalSize), ); } else { Status = gBS->AllocatePool ( -EfiACPIReclaimMemory, +AcpiAllocateMemoryType, TotalSize, (VOID **) ); @@ -512,6 +519,7 @@ AddTableToList ( EFI_PHYSICAL_ADDRESS AllocPhysAddress; UINT64Buffer64; BOOLEAN AddToRsdt; + EFI_MEMORY_TYPE AcpiAllocateMemoryType; // // Check for invalid input parameters @@ -550,6 +558,12 @@ AddTableToList ( CurrentTableList->TableSize = CurrentTableSize; CurrentTableList->PoolAllocation = FALSE; + if (PcdGetBool (PcdNoACPIReclaimMemory)) { +AcpiAllocateMemoryType = EfiACPIMemoryNVS; + } else { +AcpiAllocateMemoryType = EfiACPIReclaimMemory; + } + // // Allocation memory type depends on the type of the table // @@ -585,7 +599,7 @@ AddTableToList ( // such as AArch64 that allocate multiples of 64 KB // Status = gBS->AllocatePool ( -EfiACPIReclaimMemory, +AcpiAllocateMemoryType, CurrentTableList->TableSize, (VOID **)>Table ); @@ -596,7 +610,7 @@ AddTableToList ( // Status = gBS->AllocatePages ( mAcpiTableAllocType, -EfiACPIReclaimMemory, +AcpiAllocateMemoryType, EFI_SIZE_TO_PAGES (CurrentTableList->TableSize), ); @@ -1944,6 +1958,7 @@ AcpiTableAcpiTableConstructor ( UINTN RsdpTableSize; UINT8 *Pointer; EFI_PHYSICAL_ADDRESS PageAddress; + EFI_MEMORY_TYPE AcpiAllocateMemoryType; // // Check for invalid input parameters @@ -1978,17 +1993,23 @@ AcpiTableAcpiTableConstructor ( RsdpTableSize += sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER); } + if (PcdGetBool (PcdNoACPIReclaimMemory)) { +AcpiAllocateMemoryType = EfiACPIMemoryNVS; + } else { +AcpiAllocateMemoryType = EfiACPIReclaimMemory; + } + if (mAcpiTableAllocType != AllocateAnyPages) { PageAddress = 0x; Status = gBS->AllocatePages ( mAcpiTableAllocType, - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, EFI_SIZE_TO_PAGES (RsdpTableSize), ); } else { Status = gBS->AllocatePool ( -EfiACPIReclaimMemory, +AcpiAllocateMemoryType, RsdpTabl
[edk2-devel] [PATCH v1 1/1] MdeModulePkg/AcpiTableDxe: Select ACPI memory type by PCD
UEFI spec defined ACPI Tables at boot time can be contained in memory of type EfiACPIReclaimMemory or EfiAcpiMemoryNVS, although InstallAcpiTable with AcpiTableProtocol will only allocate memory with type EfiACPIReclaimMemory (Except FACS). This patch provides an optional method controlled by PCD to switch all ACPI allocated memory from EfiACPIReclaimMemory to EfiAcpiMemoryNVS. If the PcdAcpiMemoryUseNvs is set to TRUE, all ACPI allocated memory will using EfiAcpiMemoryNVS. Cc: Zhiguang Liu Cc: Dandan Bi Cc: Liming Gao Cc: Liu Yun Signed-off-by: Aaron Li --- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 37 +++- MdeModulePkg/MdeModulePkg.dec| 6 MdeModulePkg/MdeModulePkg.uni| 7 MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf| 1 + 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c index e09bc9b704f5..6c3dbad90345 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c @@ -340,6 +340,7 @@ ReallocateAcpiTableBuffer ( EFI_ACPI_TABLE_INSTANCE TempPrivateData; EFI_STATUS Status; UINT64 CurrentData; + EFI_MEMORY_TYPE AcpiAllocateMemoryType; CopyMem (, AcpiTableInstance, sizeof (EFI_ACPI_TABLE_INSTANCE)); // @@ -359,6 +360,12 @@ ReallocateAcpiTableBuffer ( NewMaxTableNumber * sizeof (UINT32); } + if (PcdGetBool (PcdAcpiMemoryUseNvs)) { +AcpiAllocateMemoryType = EfiACPIMemoryNVS; + } else { +AcpiAllocateMemoryType = EfiACPIReclaimMemory; + } + if (mAcpiTableAllocType != AllocateAnyPages) { // // Allocate memory in the lower 32 bit of address range for @@ -372,13 +379,13 @@ ReallocateAcpiTableBuffer ( PageAddress = 0x; Status = gBS->AllocatePages ( mAcpiTableAllocType, - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, EFI_SIZE_TO_PAGES (TotalSize), ); } else { Status = gBS->AllocatePool ( -EfiACPIReclaimMemory, +AcpiAllocateMemoryType, TotalSize, (VOID **) ); @@ -512,6 +519,7 @@ AddTableToList ( EFI_PHYSICAL_ADDRESS AllocPhysAddress; UINT64Buffer64; BOOLEAN AddToRsdt; + EFI_MEMORY_TYPE AcpiAllocateMemoryType; // // Check for invalid input parameters @@ -550,6 +558,12 @@ AddTableToList ( CurrentTableList->TableSize = CurrentTableSize; CurrentTableList->PoolAllocation = FALSE; + if (PcdGetBool (PcdAcpiMemoryUseNvs)) { +AcpiAllocateMemoryType = EfiACPIMemoryNVS; + } else { +AcpiAllocateMemoryType = EfiACPIReclaimMemory; + } + // // Allocation memory type depends on the type of the table // @@ -585,7 +599,7 @@ AddTableToList ( // such as AArch64 that allocate multiples of 64 KB // Status = gBS->AllocatePool ( -EfiACPIReclaimMemory, +AcpiAllocateMemoryType, CurrentTableList->TableSize, (VOID **)>Table ); @@ -596,7 +610,7 @@ AddTableToList ( // Status = gBS->AllocatePages ( mAcpiTableAllocType, -EfiACPIReclaimMemory, +AcpiAllocateMemoryType, EFI_SIZE_TO_PAGES (CurrentTableList->TableSize), ); @@ -1944,6 +1958,7 @@ AcpiTableAcpiTableConstructor ( UINTN RsdpTableSize; UINT8 *Pointer; EFI_PHYSICAL_ADDRESS PageAddress; + EFI_MEMORY_TYPE AcpiAllocateMemoryType; // // Check for invalid input parameters @@ -1978,17 +1993,23 @@ AcpiTableAcpiTableConstructor ( RsdpTableSize += sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER); } + if (PcdGetBool (PcdAcpiMemoryUseNvs)) { +AcpiAllocateMemoryType = EfiACPIMemoryNVS; + } else { +AcpiAllocateMemoryType = EfiACPIReclaimMemory; + } + if (mAcpiTableAllocType != AllocateAnyPages) { PageAddress = 0x; Status = gBS->AllocatePages ( mAcpiTableAllocType, - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, EFI_SIZE_TO_PAGES (RsdpTableSize), ); } else { Status = gBS->AllocatePool ( -EfiACPIReclaimMemory, +AcpiAllocateMemoryType, RsdpTabl
[edk2-devel] [PATCH v1 1/1] IntelSiliconPkg/ShadowMicrocodePei: Add microcode header verification.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3196 Microcode header should be checked before calling IsMicrocodePatchNeedLoad(). This is to make sure garbage value after remove microcode from FV would not cause stack overflow in IsMicrocodePatchNeedLoad(). Signed-off-by: Aaron Li Cc: Ray Ni Cc: Rangasai V Chaganty Cc: Siyuan Fu --- Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c | 30 +++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c b/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c index 1494397a8e36..98a7aed69757 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c @@ -402,6 +402,7 @@ ShadowMicrocode ( UINTN MaxPatchNumber; CPU_MICROCODE_HEADER *MicrocodeEntryPoint; UINTN PatchCount; + UINTN DataSize; UINTN TotalSize; UINTN TotalLoadSize; @@ -446,7 +447,34 @@ ShadowMicrocode ( for (Index = 0; Index < EntryNum; Index++) { if (FitEntry[Index].Type == FIT_TYPE_01_MICROCODE) { MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (UINTN) FitEntry[Index].Address; - TotalSize = (MicrocodeEntryPoint->DataSize == 0) ? 2048 : MicrocodeEntryPoint->TotalSize; + + if (*(UINT32 *) MicrocodeEntryPoint == 0x) { +// +// An empty slot for reserved microcode update, skip to check next entry. +// +continue; + } + + if (MicrocodeEntryPoint->HeaderVersion != 0x1) { +// +// Not a valid microcode header, skip to check next entry. +// +continue; + } + + DataSize = MicrocodeEntryPoint->DataSize; + TotalSize = (DataSize == 0) ? 2048 : MicrocodeEntryPoint->TotalSize; + if ( (UINTN)MicrocodeEntryPoint > (MAX_ADDRESS - TotalSize) || + (DataSize & 0x3) != 0 || + (TotalSize & (SIZE_1KB - 1)) != 0 || + TotalSize < DataSize +) { +// +// Not a valid microcode header, skip to check next entry. +// +continue; + } + if (IsMicrocodePatchNeedLoad (CpuIdCount, MicrocodeCpuId, MicrocodeEntryPoint)) { PatchInfoBuffer[PatchCount].Address = (UINTN) MicrocodeEntryPoint; PatchInfoBuffer[PatchCount].Size= TotalSize; -- 2.29.2.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#71096): https://edk2.groups.io/g/devel/message/71096 Mute This Topic: https://groups.io/mt/80348273/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 1/1] IntelSiliconPkg/ShadowMicrocodePei: Add PCD for shadowing all microcode.
Hi Ray, Accroding to https://edk2.groups.io/g/devel/files/Designs/2020/0214/Support%20the%202nd%20Microcode%20FV%20Flash%20Region.pdf The ShadowMicrocodePei provide a FIT based shadow microcode ppi to MpInitLib. It's needed. Best, Aaron > -Original Message- > From: Ni, Ray > Sent: Wednesday, September 23, 2020 2:25 PM > To: Li, Aaron ; devel@edk2.groups.io > Cc: Chaganty, Rangasai V ; Fu, Siyuan > > Subject: RE: [PATCH v1 1/1] IntelSiliconPkg/ShadowMicrocodePei: Add PCD > for shadowing all microcode. > > MpInitLib already contains logic to shadow microcode to memory. > Is this still needed? > > > -Original Message- > > From: Li, Aaron > > Sent: Wednesday, August 12, 2020 3:55 PM > > To: devel@edk2.groups.io > > Cc: Ni, Ray ; Chaganty, Rangasai V > > ; Fu, Siyuan > > Subject: [PATCH v1 1/1] IntelSiliconPkg/ShadowMicrocodePei: Add PCD for > > shadowing all microcode. > > > > This patch is to add a PCD PcdShadowAllMicrocode to support shadowing > > all microcode patch to memory. > > > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2891 > > > > Signed-off-by: Aaron Li > > Cc: Ray Ni > > Cc: Rangasai V Chaganty > > Cc: Siyuan Fu > > --- > > > > > Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodeP > ei.c > > | 4 > > > > > Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodeP > ei.i > > nf | 3 +++ > > Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec > > | 7 +++ > > 3 files changed, 14 insertions(+) > > > > diff --git > > > a/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocod > ePei > > .c > > > b/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocod > ePei > > .c > > index 8d6574f66794..5c7ee6910c8e 100644 > > --- > > > a/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocod > ePei > > .c > > +++ > > > b/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocod > ePei > > .c > > @@ -132,6 +132,10 @@ IsMicrocodePatchNeedLoad ( > >CPU_MICROCODE_EXTENDED_TABLE *ExtendedTable; > > > >UINTN Index; > > > > > > > > + if (FeaturePcdGet (PcdShadowAllMicrocode)) { > > > > +return TRUE; > > > > + } > > > > + > > > >// > > > >// Check the 'ProcessorSignature' and 'ProcessorFlags' in microcode patch > > header. > > > >// > > > > diff --git > > > a/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocod > ePei > > .inf > > > b/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocod > ePei > > .inf > > index 019400ab31da..581780add891 100644 > > --- > > > a/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocod > ePei > > .inf > > +++ > > > b/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocod > ePei > > .inf > > @@ -39,5 +39,8 @@ [Guids] > >gEdkiiMicrocodeShadowInfoHobGuid > > > >gEdkiiMicrocodeStorageTypeFlashGuid > > > > > > > > +[Pcd] > > > > + gIntelSiliconPkgTokenSpaceGuid.PcdShadowAllMicrocode > > > > + > > > > [Depex] > > > >TRUE > > > > diff --git a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec > > b/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec > > index e4a7fec3a3ea..3a12fe99fac6 100644 > > --- a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec > > +++ b/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec > > @@ -76,6 +76,13 @@ [Protocols] > ># Include/Protocol/PlatformDeviceSecurityPolicy.h > > > >gEdkiiDeviceSecurityPolicyProtocolGuid = {0x7ea41a99, 0x5e32, 0x4c97, > > {0x88, 0xc4, 0xd6, 0xe7, 0x46, 0x84, 0x9, 0xd4}} > > > > > > > > +[PcdsFeatureFlag] > > > > + ## Indicates if all microcode update patches shall be shadowed to > memory. > > > > + # TRUE - All microcode patches will be shadowed. > > > > + # FALSE - Only the microcode for current present processors will be > > shadowed. > > > > + # @Prompt Shadow all microcode update patches. > > > > + > > > gIntelSiliconPkgTokenSpaceGuid.PcdShadowAllMicrocode|FALSE|BOOLEAN| > 0x > > 0006 > > > > + > > > > [PcdsFixedAtBuild, PcdsPatchableInModule] > > > >## Error code for VTd error. > > > ># EDKII_ERROR_CODE_VTD_ERROR = (EFI_IO_BUS_UNSPECIFIED | > > (EFI_OEM_SPECIFIC | 0x)) = 0x02008000 > > > > -- > > 2.23.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#65551): https://edk2.groups.io/g/devel/message/65551 Mute This Topic: https://groups.io/mt/76143134/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 1/1] Tools/FitGen: Fix microcode alignment support
Hi Liming, Checked in SDM, there is a requirement: The microcode update data must start at a 16-byte aligned linear address. Such as 0xFF should not be supported. I re-sent a v2 patch and added this requirement check. Please help review again. Thanks. Best, Aaron > -Original Message- > From: devel@edk2.groups.io On Behalf Of > gaoliming > Sent: Tuesday, September 22, 2020 9:27 AM > To: Li, Aaron ; Feng, Bob C > Cc: devel@edk2.groups.io; Fu, Siyuan > Subject: 回复: [edk2-devel] [PATCH v1 1/1] Tools/FitGen: Fix microcode > alignment support > > Aaron: > This change is good. But, I would like to know whether there is the > specific alignment requirement for microcode. Or, any alignment value is > allowed, such as 0xFF? > > Thanks > Liming > > -邮件原件- > > 发件人: Li, Aaron > > 发送时间: 2020年9月21日 13:23 > > 收件人: Feng, Bob C ; Liming Gao > > > > 抄送: devel@edk2.groups.io; Li, Aaron ; Fu, Siyuan > > > > 主题: RE: [edk2-devel] [PATCH v1 1/1] Tools/FitGen: Fix microcode > alignment > > support > > > > Hi Bob & Liming, > > > > Could you help review this patch? > > Thanks. > > > > Best, > > Aaron > > > > > -Original Message- > > > From: devel@edk2.groups.io On Behalf Of > Aaron > > Li > > > Sent: Thursday, September 17, 2020 1:58 PM > > > To: devel@edk2.groups.io > > > Cc: Feng, Bob C ; Liming Gao > > > > > > Subject: [edk2-devel] [PATCH v1 1/1] Tools/FitGen: Fix microcode > alignment > > > support > > > > > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2971 > > > > > > This patch is to fix a issue that "-A" option would only support > > > 2^n Byte alignment of microcode. > > > > > > Signed-off-by: Aaron Li > > > Cc: Bob Feng > > > Cc: Liming Gao > > > --- > > > Silicon/Intel/Tools/FitGen/FitGen.c | 2 +- > > > Silicon/Intel/Tools/FitGen/FitGen.h | 4 +++- > > > 2 files changed, 4 insertions(+), 2 deletions(-) > > > > > > diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c > > > b/Silicon/Intel/Tools/FitGen/FitGen.c > > > index c4006e69c822..4caaf70ee018 100644 > > > --- a/Silicon/Intel/Tools/FitGen/FitGen.c > > > +++ b/Silicon/Intel/Tools/FitGen/FitGen.c > > > @@ -1176,7 +1176,7 @@ Returns: > > > // MCU might be put at 2KB alignment, if so, we need > > to adjust the > > > size as 2KB alignment. > > > > > > // > > > > > > if (gFitTableContext.MicrocodeIsAligned) { > > > > > > - MicrocodeSize = (*(UINT32 *)(MicrocodeBuffer + 32) > > + > > > (gFitTableContext.MicrocodeAlignValue - 1)) & > > > ~(gFitTableContext.MicrocodeAlignValue - 1); > > > > > > + MicrocodeSize = ROUNDUP (*(UINT32 > > *)(MicrocodeBuffer + 32), > > > gFitTableContext.MicrocodeAlignValue); > > > > > > } else { > > > > > >MicrocodeSize = (*(UINT32 *)(MicrocodeBuffer + > > 32)); > > > > > > } > > > > > > diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h > > > b/Silicon/Intel/Tools/FitGen/FitGen.h > > > index abad2d8799c8..435fc26209da 100644 > > > --- a/Silicon/Intel/Tools/FitGen/FitGen.h > > > +++ b/Silicon/Intel/Tools/FitGen/FitGen.h > > > @@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > // Utility version information > > > > > > // > > > > > > #define UTILITY_MAJOR_VERSION 0 > > > > > > -#define UTILITY_MINOR_VERSION 62 > > > > > > +#define UTILITY_MINOR_VERSION 63 > > > > > > #define UTILITY_DATE __DATE__ > > > > > > > > > > > > // > > > > > > @@ -45,4 +45,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > >(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & > > > ((Alignment) - 1)) > > > > > > ; > > > > > > > > > > > > +#define ROUNDUP(Size, Alignment) (((Size) + (Alignment) - 1) / > (Alignment) > > > * (Alignment)) > > > > > > + > > > > > > #endif > > > > > > -- > > > 2.23.0.windows.1 > > > > > > > > > > > > -=-=-=-=-=-= > > > Groups.io Links: You receive all messages sent to this group. > > > View/Reply Online (#65353): > > https://edk2.groups.io/g/devel/message/65353 > > > Mute This Topic: https://groups.io/mt/76904091/4128994 > > > Group Owner: devel+ow...@edk2.groups.io > > > Unsubscribe: https://edk2.groups.io/g/devel/unsub [aaron...@intel.com] > > > -=-=-=-=-=-= > > > > > > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#65423): https://edk2.groups.io/g/devel/message/65423 Mute This Topic: https://groups.io/mt/77005901/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v2 1/1] Tools/FitGen: Fix microcode alignment support
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2971 v2: Add check for basic 16-byte alignment. This patch is to fix a issue that "-A" option would only support 2^n Byte alignment of microcode. Signed-off-by: Aaron Li Cc: Bob Feng Cc: Liming Gao --- Silicon/Intel/Tools/FitGen/FitGen.c | 8 ++-- Silicon/Intel/Tools/FitGen/FitGen.h | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitGen/FitGen.c index c4006e69c822..851d42cb4aca 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.c +++ b/Silicon/Intel/Tools/FitGen/FitGen.c @@ -363,7 +363,7 @@ Returns: printf ("\tMicrocodeSlotSize - Occupied region size of each Microcode binary.\n"); printf ("\tMicrocodeFfsGuid - Guid of FFS which is used to save Microcode binary"); printf ("\t-NA- No 0x800 aligned Microcode requirement. No -NA means Microcode is aligned with option MicrocodeAlignment value.\n"); - printf ("\tMicrocodeAlignment - HEX value of Microcode alignment. Ignored if \"-NA\" is specified. Default value is 0x800.\n"); + printf ("\tMicrocodeAlignment - HEX value of Microcode alignment. Ignored if \"-NA\" is specified. Default value is 0x800. The Microcode update data must start at a 16-byte aligned linear address.\n"); printf ("\tRecordType - FIT entry record type. User should ensure it is ordered.\n"); printf ("\tRecordDataAddress - FIT entry record data address.\n"); printf ("\tRecordDataSize - FIT entry record data size.\n"); @@ -1176,7 +1176,11 @@ Returns: // MCU might be put at 2KB alignment, if so, we need to adjust the size as 2KB alignment. // if (gFitTableContext.MicrocodeIsAligned) { - MicrocodeSize = (*(UINT32 *)(MicrocodeBuffer + 32) + (gFitTableContext.MicrocodeAlignValue - 1)) & ~(gFitTableContext.MicrocodeAlignValue - 1); + if (gFitTableContext.MicrocodeAlignValue & 0xF) { +printf ("-A Parameter incorrect, Microcode data must start at a 16-byte aligned linear address!\n"); +return 0; + } + MicrocodeSize = ROUNDUP (*(UINT32 *)(MicrocodeBuffer + 32), gFitTableContext.MicrocodeAlignValue); } else { MicrocodeSize = (*(UINT32 *)(MicrocodeBuffer + 32)); } diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitGen/FitGen.h index abad2d8799c8..435fc26209da 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.h +++ b/Silicon/Intel/Tools/FitGen/FitGen.h @@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // Utility version information // #define UTILITY_MAJOR_VERSION 0 -#define UTILITY_MINOR_VERSION 62 +#define UTILITY_MINOR_VERSION 63 #define UTILITY_DATE __DATE__ // @@ -45,4 +45,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)) ; +#define ROUNDUP(Size, Alignment) (((Size) + (Alignment) - 1) / (Alignment) * (Alignment)) + #endif -- 2.23.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#65422): https://edk2.groups.io/g/devel/message/65422 Mute This Topic: https://groups.io/mt/77005848/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 1/1] Tools/FitGen: Fix microcode alignment support
Hi Bob & Liming, Could you help review this patch? Thanks. Best, Aaron > -Original Message- > From: devel@edk2.groups.io On Behalf Of Aaron Li > Sent: Thursday, September 17, 2020 1:58 PM > To: devel@edk2.groups.io > Cc: Feng, Bob C ; Liming Gao > > Subject: [edk2-devel] [PATCH v1 1/1] Tools/FitGen: Fix microcode alignment > support > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2971 > > This patch is to fix a issue that "-A" option would only support > 2^n Byte alignment of microcode. > > Signed-off-by: Aaron Li > Cc: Bob Feng > Cc: Liming Gao > --- > Silicon/Intel/Tools/FitGen/FitGen.c | 2 +- > Silicon/Intel/Tools/FitGen/FitGen.h | 4 +++- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c > b/Silicon/Intel/Tools/FitGen/FitGen.c > index c4006e69c822..4caaf70ee018 100644 > --- a/Silicon/Intel/Tools/FitGen/FitGen.c > +++ b/Silicon/Intel/Tools/FitGen/FitGen.c > @@ -1176,7 +1176,7 @@ Returns: > // MCU might be put at 2KB alignment, if so, we need to > adjust the > size as 2KB alignment. > > // > > if (gFitTableContext.MicrocodeIsAligned) { > > - MicrocodeSize = (*(UINT32 *)(MicrocodeBuffer + 32) + > (gFitTableContext.MicrocodeAlignValue - 1)) & > ~(gFitTableContext.MicrocodeAlignValue - 1); > > + MicrocodeSize = ROUNDUP (*(UINT32 *)(MicrocodeBuffer + 32), > gFitTableContext.MicrocodeAlignValue); > > } else { > >MicrocodeSize = (*(UINT32 *)(MicrocodeBuffer + 32)); > > } > > diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h > b/Silicon/Intel/Tools/FitGen/FitGen.h > index abad2d8799c8..435fc26209da 100644 > --- a/Silicon/Intel/Tools/FitGen/FitGen.h > +++ b/Silicon/Intel/Tools/FitGen/FitGen.h > @@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > // Utility version information > > // > > #define UTILITY_MAJOR_VERSION 0 > > -#define UTILITY_MINOR_VERSION 62 > > +#define UTILITY_MINOR_VERSION 63 > > #define UTILITY_DATE __DATE__ > > > > // > > @@ -45,4 +45,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent >(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & > ((Alignment) - 1)) > > ; > > > > +#define ROUNDUP(Size, Alignment) (((Size) + (Alignment) - 1) / (Alignment) > * (Alignment)) > > + > > #endif > > -- > 2.23.0.windows.1 > > > > -=-=-=-=-=-= > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#65353): https://edk2.groups.io/g/devel/message/65353 > Mute This Topic: https://groups.io/mt/76904091/4128994 > Group Owner: devel+ow...@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [aaron...@intel.com] > -=-=-=-=-=-= > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#65414): https://edk2.groups.io/g/devel/message/65414 Mute This Topic: https://groups.io/mt/76904091/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 1/1] Tools/FitGen: Fix microcode alignment support
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2971 This patch is to fix a issue that "-A" option would only support 2^n Byte alignment of microcode. Signed-off-by: Aaron Li Cc: Bob Feng Cc: Liming Gao --- Silicon/Intel/Tools/FitGen/FitGen.c | 2 +- Silicon/Intel/Tools/FitGen/FitGen.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitGen/FitGen.c index c4006e69c822..4caaf70ee018 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.c +++ b/Silicon/Intel/Tools/FitGen/FitGen.c @@ -1176,7 +1176,7 @@ Returns: // MCU might be put at 2KB alignment, if so, we need to adjust the size as 2KB alignment. // if (gFitTableContext.MicrocodeIsAligned) { - MicrocodeSize = (*(UINT32 *)(MicrocodeBuffer + 32) + (gFitTableContext.MicrocodeAlignValue - 1)) & ~(gFitTableContext.MicrocodeAlignValue - 1); + MicrocodeSize = ROUNDUP (*(UINT32 *)(MicrocodeBuffer + 32), gFitTableContext.MicrocodeAlignValue); } else { MicrocodeSize = (*(UINT32 *)(MicrocodeBuffer + 32)); } diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitGen/FitGen.h index abad2d8799c8..435fc26209da 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.h +++ b/Silicon/Intel/Tools/FitGen/FitGen.h @@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // Utility version information // #define UTILITY_MAJOR_VERSION 0 -#define UTILITY_MINOR_VERSION 62 +#define UTILITY_MINOR_VERSION 63 #define UTILITY_DATE __DATE__ // @@ -45,4 +45,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)) ; +#define ROUNDUP(Size, Alignment) (((Size) + (Alignment) - 1) / (Alignment) * (Alignment)) + #endif -- 2.23.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#65353): https://edk2.groups.io/g/devel/message/65353 Mute This Topic: https://groups.io/mt/76904091/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 1/1] IntelSiliconPkg/ShadowMicrocodePei: Add PCD for shadowing all microcode.
This patch is to add a PCD PcdShadowAllMicrocode to support shadowing all microcode patch to memory. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2891 Signed-off-by: Aaron Li Cc: Ray Ni Cc: Rangasai V Chaganty Cc: Siyuan Fu --- Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c | 4 Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.inf | 3 +++ Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec| 7 +++ 3 files changed, 14 insertions(+) diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c b/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c index 8d6574f66794..5c7ee6910c8e 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c @@ -132,6 +132,10 @@ IsMicrocodePatchNeedLoad ( CPU_MICROCODE_EXTENDED_TABLE *ExtendedTable; UINTN Index; + if (FeaturePcdGet (PcdShadowAllMicrocode)) { +return TRUE; + } + // // Check the 'ProcessorSignature' and 'ProcessorFlags' in microcode patch header. // diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.inf b/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.inf index 019400ab31da..581780add891 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.inf +++ b/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.inf @@ -39,5 +39,8 @@ [Guids] gEdkiiMicrocodeShadowInfoHobGuid gEdkiiMicrocodeStorageTypeFlashGuid +[Pcd] + gIntelSiliconPkgTokenSpaceGuid.PcdShadowAllMicrocode + [Depex] TRUE diff --git a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec b/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec index e4a7fec3a3ea..3a12fe99fac6 100644 --- a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec +++ b/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec @@ -76,6 +76,13 @@ [Protocols] # Include/Protocol/PlatformDeviceSecurityPolicy.h gEdkiiDeviceSecurityPolicyProtocolGuid = {0x7ea41a99, 0x5e32, 0x4c97, {0x88, 0xc4, 0xd6, 0xe7, 0x46, 0x84, 0x9, 0xd4}} +[PcdsFeatureFlag] + ## Indicates if all microcode update patches shall be shadowed to memory. + # TRUE - All microcode patches will be shadowed. + # FALSE - Only the microcode for current present processors will be shadowed. + # @Prompt Shadow all microcode update patches. + gIntelSiliconPkgTokenSpaceGuid.PcdShadowAllMicrocode|FALSE|BOOLEAN|0x0006 + [PcdsFixedAtBuild, PcdsPatchableInModule] ## Error code for VTd error. # EDKII_ERROR_CODE_VTD_ERROR = (EFI_IO_BUS_UNSPECIFIED | (EFI_OEM_SPECIFIC | 0x)) = 0x02008000 -- 2.23.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#64056): https://edk2.groups.io/g/devel/message/64056 Mute This Topic: https://groups.io/mt/76143134/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1] BaseTools/Capsule: Add capsule dependency support
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2412 Capsule generate tool support encode capsule dependencies through '-j' command with a JSON file. To enable dependency feature, "Dependencies" field for each payload in JSON file is required. The value of "Dependencies" field is C style infix notation expression. For example: "Dependencies":"72E2945A-00DA-448E-9AA7-075AD840F9D4 > 0x0001" The relation of Dependency Expression Opcode in UEFI2.8 chap 23.2 and infix notation expression value is as follows: +-+--+ | OPCODE | INFIX EXPRESSION VALUE | +-+--+ | 0x00 (PUSH_GUID)| {GUID} | | 0x01 (PUSH_VERSION) | {UINT32} | | 0x02 (DECLEAR_VERSION_NAME} | DECLEAR "{VERSION_NAME}" | | 0x03 (AND) | && | | 0x04 (OR) | || | | 0x05 (NOT) | ~| | 0x06 (TRUE) | TRUE | | 0x07 (FALSE)| FALSE| | 0x08 (EQ) | == | | 0x09 (GT) | >| | 0x0A (GTE) | >= | | 0x0B (LT) | <| | 0x0C (LTE) | <= | +-+------+ Cc: Bob Feng Cc: Liming Gao Signed-off-by: Aaron Li --- BaseTools/Source/Python/Capsule/GenerateCapsule.py | 62 ++- BaseTools/Source/Python/Common/Uefi/Capsule/CapsuleDependency.py | 409 2 files changed, 464 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py b/BaseTools/Source/Python/Capsule/GenerateCapsule.py index 6838beb682..a8de988253 100644 --- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py +++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py @@ -31,6 +31,7 @@ import json from Common.Uefi.Capsule.UefiCapsuleHeader import UefiCapsuleHeaderClass from Common.Uefi.Capsule.FmpCapsuleHeader import FmpCapsuleHeaderClass from Common.Uefi.Capsule.FmpAuthHeader import FmpAuthHeaderClass +from Common.Uefi.Capsule.CapsuleDependency import CapsuleDependencyClass from Common.Edk2.Capsule.FmpPayloadHeader import FmpPayloadHeaderClass # @@ -306,6 +307,7 @@ if __name__ == '__main__': OpenSslOtherPublicCertFile = ConvertJsonValue (Config, 'OpenSslOtherPublicCertFile', os.path.expandvars, Required = False, Default = None, Open = True) OpenSslTrustedPublicCertFile = ConvertJsonValue (Config, 'OpenSslTrustedPublicCertFile', os.path.expandvars, Required = False, Default = None, Open = True) SigningToolPath = ConvertJsonValue (Config, 'SigningToolPath', os.path.expandvars, Required = False, Default = None) +DepexExp = ConvertJsonValue (Config, 'Dependencies', str, Required = False, Default = None) # # Read binary input file @@ -330,7 +332,8 @@ if __name__ == '__main__': OpenSslSignerPrivateCertFile, OpenSslOtherPublicCertFile, OpenSslTrustedPublicCertFile, -SigningToolPath +SigningToolPath, +DepexExp )) def GenerateOutputJson (PayloadJsonDescriptorList): @@ -348,7 +351,8 @@ if __name__ == '__main__': "OpenSslSignerPrivateCertFile": str(PayloadDescriptor.OpenSslSignerPrivateCertFile), "OpenSslOtherPublicCertFile": str(PayloadDescriptor.OpenSslOtherPublicCertFile), "OpenSslTrustedPublicCertFile": str(PayloadDescriptor.OpenSslTrustedPublicCertFile), - "SigningToolPath": str(PayloadDescriptor.SigningToolPath) + "SigningToolPath": str(PayloadDescriptor.SigningToolPath), + "Dependencies" : str(PayloadDescriptor.DepexExp) }for PayloadDescriptor in PayloadJsonDescriptorList ] } @@ -424,7 +428,8 @@ if __name__ == '__main__': OpenSslSignerPrivateCertFile = None, OpenSslOtherPublicCertFile = None, OpenSslTrustedPublicCertFile = None, - SigningToolPath