[edk2-devel] [PATCH 3/3] UefiCpuPkg: Disable MTC packet by default

2023-04-24 Thread duntan
MTC packet is not needed and disable MTC packet by default.

Bugzila: https://bugzilla.tianocore.org/show_bug.cgi?id=4423
Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Xiao X Chen 
---
 UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
index 1a101b7288..3f109bf29c 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
@@ -538,6 +538,14 @@ ProcTraceInitialize (
 CtrlReg.Bits.TSCEn = 0;
   }
 
+  //
+  // MTC packet is not needed. Turn it off by default.
+  //
+  if (Ebx.Bits.Mtc == 1) {
+CtrlReg.Bits.MTCEn   = 0;
+CtrlReg.Bits.MTCFreq = 0;
+  }
+
   CPU_REGISTER_TABLE_WRITE64 (
 ProcessorNumber,
 Msr,
-- 
2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103512): https://edk2.groups.io/g/devel/message/103512
Mute This Topic: https://groups.io/mt/98487623/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 2/3] UefiCpuPkg: Update PT code to support enable collect performance

2023-04-24 Thread duntan
Update ProcTrace feature code to support enable collect performance
data by generating CYC and TSC packets. Add a new dynamic
PCD to indicate if enable performance collecting. In ProcTrace.c
code, if this new PCD is true, CYC and TSC packets will be
generated by setting the corresponding MSR bits feilds.

Bugzila: https://bugzilla.tianocore.org/show_bug.cgi?id=4423
Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Xiao X Chen 
---
 UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf |  1 +
 UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c  | 66 
+++---
 UefiCpuPkg/UefiCpuPkg.dec|  8 
 3 files changed, 56 insertions(+), 19 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
index 319c8b4842..e31c1e7317 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
@@ -63,3 +63,4 @@
   gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceOutputScheme  ## 
SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceMemSize   ## 
SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdEnableProcessorTraceOnBspOnly ## 
SOMETIMES_CONSUMES
+  gUefiCpuPkgTokenSpaceGuid.ProcTraceEnablePerformanceCollecting ## 
SOMETIMES_CONSUMES
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
index f57544bf7d..1a101b7288 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
@@ -171,25 +171,26 @@ ProcTraceInitialize (
   IN BOOLEAN   State
   )
 {
-  UINT32   MemRegionSize;
-  UINTNPages;
-  UINTNAlignment;
-  UINTNMemRegionBaseAddr;
-  UINTN*ThreadMemRegionTable;
-  UINTNIndex;
-  UINTNTopaTableBaseAddr;
-  UINTNAlignedAddress;
-  UINTN*TopaMemArray;
-  PROC_TRACE_TOPA_TABLE*TopaTable;
-  PROC_TRACE_DATA  *ProcTraceData;
-  BOOLEAN  FirstIn;
-  MSR_IA32_RTIT_CTL_REGISTER   CtrlReg;
-  MSR_IA32_RTIT_STATUS_REGISTERStatusReg;
-  MSR_IA32_RTIT_OUTPUT_BASE_REGISTER   OutputBaseReg;
-  MSR_IA32_RTIT_OUTPUT_MASK_PTRS_REGISTER  OutputMaskPtrsReg;
-  RTIT_TOPA_TABLE_ENTRY*TopaEntryPtr;
-  BOOLEAN  IsBsp;
-  BOOLEAN  EnableOnBspOnly;
+  UINT32 MemRegionSize;
+  UINTN  Pages;
+  UINTN  Alignment;
+  UINTN  MemRegionBaseAddr;
+  UINTN  *ThreadMemRegionTable;
+  UINTN  Index;
+  UINTN  TopaTableBaseAddr;
+  UINTN  AlignedAddress;
+  UINTN  *TopaMemArray;
+  PROC_TRACE_TOPA_TABLE  *TopaTable;
+  PROC_TRACE_DATA*ProcTraceData;
+  BOOLEANFirstIn;
+  MSR_IA32_RTIT_CTL_REGISTER CtrlReg;
+  MSR_IA32_RTIT_STATUS_REGISTER  StatusReg;
+  MSR_IA32_RTIT_OUTPUT_BASE_REGISTER OutputBaseReg;
+  MSR_IA32_RTIT_OUTPUT_MASK_PTRS_REGISTEROutputMaskPtrsReg;
+  RTIT_TOPA_TABLE_ENTRY  *TopaEntryPtr;
+  BOOLEANIsBsp;
+  BOOLEANEnableOnBspOnly;
+  CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_EBX  Ebx;
 
   //
   // The scope of the MSR_IA32_RTIT_* is core for below processor type, only 
program
@@ -510,6 +511,33 @@ ProcTraceInitialize (
   CtrlReg.Bits.User = 1;
   CtrlReg.Bits.BranchEn = 1;
   CtrlReg.Bits.TraceEn  = 1;
+
+  AsmCpuidEx (CPUID_INTEL_PROCESSOR_TRACE, 
CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF, NULL, , NULL, NULL);
+
+  //
+  // Generate CYC/TSC timing packets to to collect performance data.
+  //
+  if (PcdGetBool (ProcTraceEnablePerformanceCollecting)) {
+if (Ebx.Bits.ConfigurablePsb == 1) {
+  CtrlReg.Bits.CYCEn = 1;
+  CtrlReg.Bits.CYCThresh = 5;
+
+  //
+  // Write to TSCEn is always supported
+  //
+  CtrlReg.Bits.TSCEn = 1;
+} else {
+  DEBUG ((DEBUG_INFO, "ProcTrace: CYC packet is not supported. Failed to 
enable Performance Collecting \n"));
+

[edk2-devel] [PATCH 1/3] UefiCpuPkg: Update code to support enable ProcTrace only on BSP

2023-04-24 Thread duntan
Update code to support enable ProcTrace only on BSP. Add a new
dynamic PCD to indicate if enable ProcTrace only on BSP. In
ProcTrace.c code, if this new PCD is true, only allocate buffer
and set CtrlReg.Bits.TraceEn to 1 for BSP.

Bugzila: https://bugzilla.tianocore.org/show_bug.cgi?id=4423
Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Xiao X Chen 
---
 UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf |  11 
++-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c  | 159 
+++
 UefiCpuPkg/UefiCpuPkg.dec|   7 +++
 3 files changed, 112 insertions(+), 65 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
index 7fbcd8da0e..319c8b4842 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
@@ -4,7 +4,7 @@
 #  This library registers CPU features defined in Intel(R) 64 and IA-32
 #  Architectures Software Developer's Manual.
 #
-# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -58,7 +58,8 @@
   LocalApicLib
 
 [Pcd]
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle   ## 
SOMETIMES_CONSUMES
-  gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset## 
SOMETIMES_CONSUMES
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceOutputScheme  ## 
SOMETIMES_CONSUMES
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceMemSize   ## 
SOMETIMES_CONSUMES
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle   ## 
SOMETIMES_CONSUMES
+  gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset## 
SOMETIMES_CONSUMES
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceOutputScheme  ## 
SOMETIMES_CONSUMES
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceMemSize   ## 
SOMETIMES_CONSUMES
+  gUefiCpuPkgTokenSpaceGuid.PcdEnableProcessorTraceOnBspOnly ## 
SOMETIMES_CONSUMES
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
index 04e6a60728..f57544bf7d 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
@@ -1,7 +1,7 @@
 /** @file
   Intel Processor Trace feature.
 
-  Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -188,6 +188,8 @@ ProcTraceInitialize (
   MSR_IA32_RTIT_OUTPUT_BASE_REGISTER   OutputBaseReg;
   MSR_IA32_RTIT_OUTPUT_MASK_PTRS_REGISTER  OutputMaskPtrsReg;
   RTIT_TOPA_TABLE_ENTRY*TopaEntryPtr;
+  BOOLEAN  IsBsp;
+  BOOLEAN  EnableOnBspOnly;
 
   //
   // The scope of the MSR_IA32_RTIT_* is core for below processor type, only 
program
@@ -236,6 +238,13 @@ ProcTraceInitialize (
 return RETURN_SUCCESS;
   }
 
+  IsBsp   = (CpuInfo->ProcessorInfo.StatusFlag & BIT0) ? TRUE : FALSE;
+  EnableOnBspOnly = (PcdGetBool (PcdEnableProcessorTraceOnBspOnly)) ? TRUE : 
FALSE;
+
+  if (EnableOnBspOnly && (IsBsp == FALSE)) {
+return RETURN_SUCCESS;
+  }
+
   MemRegionBaseAddr = 0;
   FirstIn   = FALSE;
 
@@ -260,43 +269,59 @@ ProcTraceInitialize (
 //   address base in MSR, IA32_RTIT_OUTPUT_BASE (560h) bits 47:12. Note 
that all regions must be
 //   aligned based on their size, not just 4K. Thus a 2M region must have 
bits 20:12 cleared.
 //
-ThreadMemRegionTable = (UINTN *)AllocatePool 
(ProcTraceData->NumberOfProcessors * sizeof (UINTN *));
-if (ThreadMemRegionTable == NULL) {
-  DEBUG ((DEBUG_ERROR, "Allocate ProcTrace ThreadMemRegionTable 
Failed\n"));
-  return RETURN_OUT_OF_RESOURCES;
-}
-
-ProcTraceData->ThreadMemRegionTable = ThreadMemRegionTable;
 
-for (Index = 0; Index < ProcTraceData->NumberOfProcessors; Index++, 
ProcTraceData->AllocatedThreads++) {
-  Pages  = EFI_SIZE_TO_PAGES (MemRegionSize);
-  Alignment  = MemRegionSize;
+Pages = EFI_SIZE_TO_PAGES (MemRegionSize);
+Alignment = MemRegionSize;
+if (EnableOnBspOnly) {
   AlignedAddress = (UINTN)AllocateAlignedReservedPages (Pages, Alignment);
   if (AlignedAddress == 0) {
-DEBUG ((DEBUG_ERROR, "ProcTrace: Out of mem, allocated only for %d 
threads\n", ProcTraceData->AllocatedThreads));
-if (Index == 0) {
-  //
-  // Could not allocate for BSP even
-  //
-  FreePool ((VOID *)ThreadMemRegionTable);
-  

[edk2-devel] [PATCH 0/3] Update ProcTrace feature code for new requirements.

2023-04-24 Thread duntan
Update ProcTrace feature code to support enable ProcTrace only on BSP and 
support enable collect performance.

Dun Tan (3):
  UefiCpuPkg: Update code to support enable ProcTrace only on BSP
  UefiCpuPkg: Update PT code to support enable collect performance
  UefiCpuPkg: Disable MTC packet by default

 UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf |  12 
+++-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c  | 229 
-
 UefiCpuPkg/UefiCpuPkg.dec|  15 
+++
 3 files changed, 174 insertions(+), 82 deletions(-)

-- 
2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103509): https://edk2.groups.io/g/devel/message/103509
Mute This Topic: https://groups.io/mt/98487616/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2 1/1] BaseTools: Add quotes around OBJCOPY cmd in build_rule.template

2023-04-24 Thread Bob Feng
Reviewed-by: Bob Feng 

-Original Message-
From: Rebecca Cran  
Sent: Monday, April 24, 2023 10:06 PM
To: devel@edk2.groups.io; Gao, Liming ; Feng, Bob C 
; Chen, Christine 
Cc: Rebecca Cran 
Subject: [PATCH v2 1/1] BaseTools: Add quotes around OBJCOPY cmd in 
build_rule.template

Add quotes around the OBJCOPY command in build_rule.template to fix the case 
where LLVM is installed on Windows in a path with spaces such as C:\Program 
Files\LLVM.

Signed-off-by: Rebecca Cran 
---
 BaseTools/Conf/build_rule.template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index d42e7937cc90..eb64c62060e1 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -352,12 +352,12 @@
 -$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR) 
 
 $(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).debug
-$(OBJCOPY) $(OBJCOPY_STRIPFLAG) ${src}
+"$(OBJCOPY)" $(OBJCOPY_STRIPFLAG) ${src}
 
 #
 #The below 2 lines are only needed for UNIXGCC tool chain, which 
generates PE image directly
 #
--$(OBJCOPY) $(OBJCOPY_ADDDEBUGFLAG) ${src}
+-"$(OBJCOPY)" $(OBJCOPY_ADDDEBUGFLAG) ${src}
 -$(CP) $(DEBUG_DIR)(+)$(MODULE_NAME).debug 
$(BIN_DIR)(+)$(MODULE_NAME_GUID).debug
 
 "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
--
2.40.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103508): https://edk2.groups.io/g/devel/message/103508
Mute This Topic: https://groups.io/mt/98470825/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [Patch V3 03/11] OvmfPkg:Remove code that apply AddressEncMask to non-leaf entry

2023-04-24 Thread Ni, Ray



> -Original Message-
> From: Gerd Hoffmann 
> Sent: Monday, April 24, 2023 5:55 PM
> To: Tom Lendacky 
> Cc: Tan, Dun ; devel@edk2.groups.io; Ard Biesheuvel
> ; Yao, Jiewen ; Justen,
> Jordan L ; Ni, Ray 
> Subject: Re: [Patch V3 03/11] OvmfPkg:Remove code that apply
> AddressEncMask to non-leaf entry
> 
> On Fri, Apr 21, 2023 at 09:26:44AM -0500, Tom Lendacky wrote:
> > On 4/21/23 03:36, Dun Tan wrote:
> > > Remove code that apply AddressEncMask to non-leaf entry when split
> > > smm page table by MemEncryptSevLib. In FvbServicesSmm driver, it
> > > calls MemEncryptSevClearMmioPageEncMask to clear AddressEncMask
> > > bit in page table for a specific range. In AMD SEV feature, this
> > > AddressEncMask bit in page table is used to indicate if the memory
> > > is guest private memory or shared memory. But all memory used by
> > > page table are treated as encrypted regardless of encryption bit.
> > > So remove the EncMask bit for smm non-leaf page table entry
> > > doesn't impact AMD SEV feature.
> > > If page split happens in the AddressEncMask bit clear process,
> > > there will be some new non-leaf entries with AddressEncMask
> > > applied in smm page table. When ReadyToLock, code in PiSmmCpuDxe
> > > module will use CpuPageTableLib to modify smm page table. So
> > > remove code to apply AddressEncMask for new non-leaf entries
> > > since CpuPageTableLib doesn't consume the EncMask PCD.
> >
> > I'm really not a fan of removing the encryption mask, because technically it
> > is correct to have it present in non-leaf entries. I really think the
> > pagetable library should be able to work correctly with or without the
> > encryption mask.
> 
> Agree.  We have a bunch of custom page page code in TDX and SEV support
> libraries.  See here:
> 
>  - Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
>  - Library/BaseMemEncryptTdxLib/MemoryEncryption.c
>  - Library/PeilessStartupLib/X64/VirtualMemory.c
> 
> I'd like to see those switched over to use the pagetable library, and
> that probably requires support for the tdx/sev specific page table bits.

Gerd,
Changing all TDX/SEV code to use PageTableLib would be the best.
And we have evaluated TDX/SEV spec/code-logic and concluded that
either the C_bit (SEV) or Share_bit (TDX) is not required to set in the page
table non-leaf entry.

+@Xu, Min M for confirmation from TDX part.

I don't want PageTableLib to be aware of the EncMask bit because if the guest
page table is compliant to spec to not have EncMask bit set in non-leaf entry,
PageTableLib can well support the SEV/TDX scenario.

> 
> take care,
>   Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103507): https://edk2.groups.io/g/devel/message/103507
Mute This Topic: https://groups.io/mt/98406586/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [Patch V3 0/8] Create page table by CpuPageTableLib in DxeIpl

2023-04-24 Thread Ni, Ray


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ard
> Biesheuvel
> Sent: Tuesday, April 25, 2023 2:07 AM
> To: Kinney, Michael D 
> Cc: devel@edk2.groups.io; Tan, Dun 
> Subject: Re: [edk2-devel] [Patch V3 0/8] Create page table by
> CpuPageTableLib in DxeIpl
> 
> On Mon, 24 Apr 2023 at 19:51, Kinney, Michael D
>  wrote:
> >
> > Hi Ard,
> >
> > Thanks for the feedback.  Let's work on this approach.
> >
> > Are there similar needs for CPU related services in the DXE Core before
> > the CPU AP is loaded?
> >
> > If we are going to define a new lib class to abstract DXE IPL requirements,
> > it would be good to cover DXE Core requirements too.
> >
> 
> Yeah, excellent point.
> 
> The problem I have had to work around in my strict permissions series
> (which includes the linked patch) is that there is a window from the
> moment DXE core is dispatched until the moment the CPU arch protocol
> DXE driver is dispatched where we don't have an architectural means to
> manipulate memory permissions.
> 
> So what we'd need here is a library version of the following method
> 
> typedef
> EFI_STATUS
> (EFIAPI *EFI_CPU_SET_MEMORY_ATTRIBUTES)(
>   IN EFI_CPU_ARCH_PROTOCOL  *This,
>   IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
>   IN  UINT64Length,
>   IN  UINT64Attributes
>   );

What's your idea here?
Besides HandOffToDxeCore(), you require a 2nd lib API as above for
early DXE phase before CPU AP is available?

Why do we want to combine two APIs into one lib class?
If combined, what lib class name do you think is proper to describe the lib 
purpose?

It seems to me lacking of CPU AP in early DXE phase is acknowledged by PI spec.
Having the 2nd API for DXE early phase is like a workaround to fix PI spec gap, 
do you think so?

> 
> *However*, I am aware that the X86 DXE IPL code deviates from this, as
> it needs to build long mode compatible page tables before switching
> from IA32 to X64, right?

DXEIPL creates long mode page table with following characteristics:
* 1:1 mapping to cover the entire memory space
* Set the bottom 4K of BSP stack as not-present - prevent stack overflow
* Set the entire BSP stack as NX - prevent buffer overflow attack
* Set the [0-4k] region as not-present - null protection

But it doesn't set DxeCore code region as RO, or data region as NX.

I describe the X86 DXEIPL page table behavior as above. Because I hope
you could explain a bit more on your thoughts. I don't quite understand
your above wordings.

> So whether that use case can be served with this prototype is
> doubtful, but I guess it /would/ make sense to define a single library
> abstraction that can accommodate all of these use cases.
> 
> Happy to discuss this in more detail,
> 
> 
> 
> >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of Ard
> Biesheuvel
> > > Sent: Monday, April 24, 2023 10:24 AM
> > > To: devel@edk2.groups.io; Tan, Dun 
> > > Subject: Re: [edk2-devel] [Patch V3 0/8] Create page table by
> CpuPageTableLib in DxeIpl
> > >
> > > On Mon, 24 Apr 2023 at 12:06, duntan  wrote:
> > > >
> > > > In V3 patch set:
> > > > 1. Add a new patch 'MdePkg: Move CpuPageTableLib defination to
> MdePkg' to Move CpuPageTableLib defination from UefiCpuPkg to
> > > MdePkg.
> > > >So that MdeModulePkg doesn't need to depend on UefiCpuPkg.
> > >
> > > As I replied to the other patch, I think adding CpuPageTableLib to
> > > MdePkg in its current form (even only the interface) is not the right
> > > approach here. The function protoypes and enums exposed by this
> > > library are highly specific to a particular implementation.
> > >
> > > There is a clear use case here, which is the DXE IPL code, and as has
> > > been suggested in the other thread, it would be more appropriate to
> > > define an abstraction regarding this use case, and define it as a
> > > library class (with a NULL implementation) in MdeModulePkg. That way,
> > > UefiCpuPkg can provide the x86 implementation based on
> > > CpuPageTableLilb, and other architectures can do likewise.
> > >
> > > Please refer to the patch below, which illustrates why there are other
> > > requirements in this area:
> > >
> > > https://edk2.groups.io/g/devel/message/101122
> > >
> > > --
> > > Ard.
> > >
> > >
> > >
> > >
> > > > 2. Modify the patch 'MdeModulePkg/DxeIpl: Create page table by
> CpuPageTableLib' to set GHCB page to be mapped as unencrypted
> > > for each CPU for AMD SEV feature.
> > > >
> > > > Dun Tan (8):
> > > >   MdePkg: Move CpuPageTableLib defination to MdePkg
> > > >   EmulatorPkg: Add CpuPageTableLib required by DxeIpl in DSC
> > > >   IntelFsp2Pkg: Add CpuPageTableLib required by DxeIpl in DSC
> > > >   MdeModulePkg: Add CpuPageTableLib required by DxeIpl in DSC
> > > >   OvmfPkg: Add CpuPageTableLib required by DxeIpl in DSC file
> > > >   MdeModulePkg/DxeIpl: Create page table by CpuPageTableLib
> > > >   MdeModulePkg/DxeIpl: Remove 

Re: [edk2-devel] [edk2-platforms][PATCH V3 00/14] ManageabilityPkg part II

2023-04-24 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Hi all,
I had pushed this patch set to edk2-platforms. Although not all of the 
maintainers/reviewers gave R-b for each patch, we got at least one R-b for 
each. Just let me know if you have further comments.
NV and Ampere will move forward to help implementing OpenBMC IPMI BLOB transfer 
and also support SSIF as a transport interface for IPMI.

Thanks
Abner

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chang,
> Abner via groups.io
> Sent: Friday, April 21, 2023 1:23 PM
> To: devel@edk2.groups.io
> Cc: Isaac Oram ; Attar, AbdulLateef (Abdul Lateef)
> ; Nickle Wang ; Igor
> Kulchytskyy ; Tinh Nguyen
> 
> Subject: [edk2-devel] [edk2-platforms][PATCH V3 00/14] ManageabilityPkg
> part II
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> From: Abner Chang 
> 
> In V3: Address comments given to V2.
> 
> In V2:
>   - Address uncrustify issues.
>   - Use DBBUG_MANAGEABILITY_INFO to output detailed
> manageability information.
> DEBUG_INFO is used for the function entry point,
> while DEBUG_ERROR is used for the error situations.
> 
> In part II, we had implemented
> - PLDM protocol
> - MCTP protocol
> - PLDM SMBIOS Transfer protocol
> - MCTP manageability transport interface
> - Support maximum transfer unit of transport interface
> - Add more heler functions
> - Add two new fields HeaderSize and TrailerSize in
>   MANAGEABILITY_TRANSFER_TOKEN structure.
> - Add PCDs to build the manageability modules.
> 
> Signed-off-by: Abner Chang 
> Cc: Isaac Oram 
> Cc: Abdul Lateef Attar 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> Cc: Tinh Nguyen 
> 
> Abner Chang (14):
>   ManageabilityPkg: Add more helper functions
>   ManageabilityPkg: Support Maximum Transfer Unit
>   ManageabilityPkg: Add HeaderSize and TrailerSize
>   ManageabilityPkg: Add PldmProtocolLib
>   ManageabilityPkg: Add PldmSmbiosTransferDxe driver
>   ManageabilityPkg/KCS: KCS transport interface
>   ManageabilityPkg: Add definitions of MCTP
>   ManageabilityPkg: Add MCTP manageability header file
>   ManageabilityPkg/MctpProtocol: Add MctpProtocol
>   ManageabilityPkg: Add MCTP transport interface
>   ManageabilityPkg/PldmProtocol: Add PLDM protocol
>   ManageabilityPkg: Add Manageability PCDs
>   ManageabilityPkg: Relocate Manageability.dsc
>   ManageabilityPkg: Add Manageability FDFs
> 
>  .../ManageabilityPkg/ManageabilityPkg.dec |  28 +
>  .../Include/{Dsc => }/Manageability.dsc   |  20 +
>  .../ManageabilityPkg/ManageabilityPkg.dsc |  14 +-
>  .../ManageabilityPkg/Include/PostMemory.fdf   |  28 +
>  .../ManageabilityPkg/Include/PreMemory.fdf|  12 +
>  .../BaseManageabilityTransportHelper.inf  |   1 +
>  .../Dxe/DxeManageabilityTransportMctp.inf |  44 ++
>  .../Dxe/PldmProtocolLib.inf   |  42 ++
>  .../MctpProtocol/Dxe/MctpProtocolDxe.inf  |  53 ++
>  .../PldmProtocol/Dxe/PldmProtocolDxe.inf  |  50 ++
>  .../PldmSmbiosTransferDxe.inf |  47 ++
>  .../Include/Library/BasePldmProtocolLib.h |  41 ++
>  .../Library/ManageabilityTransportHelperLib.h |  97 
>  .../Library/ManageabilityTransportLib.h   |  35 +-
>  .../Library/ManageabilityTransportMctpLib.h   |  54 ++
>  .../Include/Protocol/MctpProtocol.h   | 102 
>  .../Include/Protocol/PldmProtocol.h   |  87 +++
>  .../Protocol/PldmSmbiosTransferProtocol.h | 184 ++
>  .../Common/ManageabilityTransportKcs.h|  22 +-
>  .../Dxe/ManageabilityTransportMctp.h  |  26 +
>  .../IpmiProtocol/Common/IpmiProtocolCommon.h  |  36 +-
>  .../IpmiProtocol/Pei/IpmiPpiInternal.h|   8 +-
>  .../MctpProtocol/Common/MctpProtocolCommon.h  | 139
> +  .../PldmProtocol/Common/PldmProtocolCommon.h  | 109 
>  .../BaseManageabilityTransportHelper.c| 225 +++-
>  .../BaseManageabilityTransportNull.c  |  18 +-
>  .../Common/KcsCommon.c| 208 ---
>  .../Dxe/ManageabilityTransportKcs.c   |  89 +--
>  .../Dxe/ManageabilityTransportMctp.c  | 367 
>  .../PldmProtocolLibrary/Dxe/PldmProtocolLib.c |  87
> +++  .../IpmiProtocol/Common/IpmiProtocolCommon.c  |  63 ++-
>   .../Universal/IpmiProtocol/Dxe/IpmiProtocol.c |  24 +-
>  .../Universal/IpmiProtocol/Pei/IpmiPpi.c  |  51 +-
>  .../Universal/IpmiProtocol/Smm/IpmiProtocol.c |  24 +-
>   .../MctpProtocol/Common/MctpProtocolCommon.c  | 472
>   .../Universal/MctpProtocol/Dxe/MctpProtocol.c | 218
>   .../PldmProtocol/Common/PldmProtocolCommon.c  | 437
> +++  .../Universal/PldmProtocol/Dxe/PldmProtocol.c | 181
> ++
>  .../PldmSmbiosTransferDxe.c   | 525 ++
>  Features/ManageabilityPkg/Readme.md   |  10 +
>  .../Dxe/ManageabilityTransportMctp.uni|  13 +
>  .../Dxe/PldmProtocolLib.uni   |  18 +
>  42 files changed, 

Re: [edk2-devel] [edk2-platforms][PATCH V3 10/14] ManageabilityPkg: Add MCTP transport interface

2023-04-24 Thread Nickle Wang via groups.io
Reviewed-by: Nickle Wang 

Regards,
Nickle

> -Original Message-
> From: abner.ch...@amd.com 
> Sent: Friday, April 21, 2023 1:23 PM
> To: devel@edk2.groups.io
> Cc: Isaac Oram ; Abdul Lateef Attar
> ; Nickle Wang ; Igor Kulchytskyy
> 
> Subject: [edk2-platforms][PATCH V3 10/14] ManageabilityPkg: Add MCTP
> transport interface
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang 
> 
> Add MCTP manageability transport interface library.
> 
> The functionality is verified by checking the binary
> debug output of payload.
> 
> Signed-off-by: Abner Chang 
> Cc: Isaac Oram 
> Cc: Abdul Lateef Attar 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> ---
>  .../ManageabilityPkg/ManageabilityPkg.dsc |   1 +
>  .../Dxe/DxeManageabilityTransportMctp.inf |  44 +++
>  .../Dxe/ManageabilityTransportMctp.h  |  26 ++
>  .../Dxe/ManageabilityTransportMctp.c  | 367 ++
>  .../Dxe/ManageabilityTransportMctp.uni|  13 +
>  5 files changed, 451 insertions(+)
>  create mode 100644
> Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/DxeM
> anageabilityTransportMctp.inf
>  create mode 100644
> Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/Mana
> geabilityTransportMctp.h
>  create mode 100644
> Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/Mana
> geabilityTransportMctp.c
>  create mode 100644
> Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/Mana
> geabilityTransportMctp.uni
> 
> diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc
> b/Features/ManageabilityPkg/ManageabilityPkg.dsc
> index 412029ef6c..959b3eabd2 100644
> --- a/Features/ManageabilityPkg/ManageabilityPkg.dsc
> +++ b/Features/ManageabilityPkg/ManageabilityPkg.dsc
> @@ -37,6 +37,7 @@
> 
>  [Components]
> 
> ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/DxeManageability
> TransportKcs.inf
> +
> ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/DxeManageabili
> tyTransportMctp.inf
>ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtocolLib.inf
> 
>  [LibraryClasses]
> diff --git
> a/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/Dxe
> ManageabilityTransportMctp.inf
> b/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/Dxe
> ManageabilityTransportMctp.inf
> new file mode 100644
> index 00..22ea37c516
> --- /dev/null
> +++
> b/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/Dxe
> ManageabilityTransportMctp.inf
> @@ -0,0 +1,44 @@
> +## @file
> +# MCTP instance of Manageability Transport Library
> +#
> +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION= 0x0001001B
> +  BASE_NAME  = DxeManageabilityTransportMctp
> +  MODULE_UNI_FILE= ManageabilityTransportMctp.uni
> +  FILE_GUID  = 7770FA0F-4808-47BD-89F4-717185332486
> +  MODULE_TYPE= DXE_DRIVER
> +  VERSION_STRING = 1.0
> +  LIBRARY_CLASS  = ManageabilityTransportLib
> +
> +#
> +#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
> +#
> +
> +[Sources]
> +  ManageabilityTransportMctp.c
> +  ManageabilityTransportMctp.h
> +
> +[Packages]
> +  ManageabilityPkg/ManageabilityPkg.dec
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  DebugLib
> +  MemoryAllocationLib
> +  UefiBootServicesTableLib
> +
> +[Protocols]
> +  gEdkiiMctpProtocolGuid
> +
> +[Guids]
> +  gManageabilityProtocolPldmGuid
> +  gManageabilityTransportMctpGuid
> +
> +[Depex]
> +  gEdkiiMctpProtocolGuid  ## ALWAYS_CONSUMES
> +
> diff --git
> a/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/Ma
> nageabilityTransportMctp.h
> b/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/Ma
> nageabilityTransportMctp.h
> new file mode 100644
> index 00..1ce0d3a8bc
> --- /dev/null
> +++
> b/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/Ma
> nageabilityTransportMctp.h
> @@ -0,0 +1,26 @@
> +/** @file
> +
> +  Manageability transport MCTP internal used definitions.
> +
> +  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#ifndef MANAGEABILITY_TRANSPORT_MCTP_LIB_INTERNAL_H_
> +#define MANAGEABILITY_TRANSPORT_MCTP_LIB_INTERNAL_H_
> +
> +#include 
> +
> +#define MANAGEABILITY_TRANSPORT_MCTP_SIGNATURE  SIGNATURE_32
> ('M', 'T', 'M', 'C')
> +
> +///
> +/// Manageability transport KCS internal data structure.
> +///
> +typedef struct {
> +  UINTNSignature;
> +  MANAGEABILITY_TRANSPORT_TOKENToken;
> +} MANAGEABILITY_TRANSPORT_MCTP;
> +
> +#define MANAGEABILITY_TRANSPORT_MCTP_FROM_LINK(a)  CR (a,
> MANAGEABILITY_TRANSPORT_MCTP, Token,
> MANAGEABILITY_TRANSPORT_MCTP_SIGNATURE)
> +
> +#endif // 

Re: [edk2-devel] [edk2-platforms][PATCH V3 09/14] ManageabilityPkg/MctpProtocol: Add MctpProtocol

2023-04-24 Thread Nickle Wang via groups.io
Reviewed-by: Nickle Wang 

Regards,
Nickle

> -Original Message-
> From: abner.ch...@amd.com 
> Sent: Friday, April 21, 2023 1:23 PM
> To: devel@edk2.groups.io
> Cc: Isaac Oram ; Abdul Lateef Attar
> ; Nickle Wang ; Igor Kulchytskyy
> 
> Subject: [edk2-platforms][PATCH V3 09/14] ManageabilityPkg/MctpProtocol:
> Add MctpProtocol
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang 
> 
> MctpProtocol that transmits MCTP message
> over manageability transport interface
> library.
> 
> Signed-off-by: Abner Chang 
> Cc: Isaac Oram 
> Cc: Abdul Lateef Attar 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> ---
>  .../Include/Dsc/Manageability.dsc |   1 +
>  .../MctpProtocol/Dxe/MctpProtocolDxe.inf  |  53 ++
>  .../Include/Protocol/MctpProtocol.h   | 102 
>  .../MctpProtocol/Common/MctpProtocolCommon.h  | 139 ++
>  .../MctpProtocol/Common/MctpProtocolCommon.c  | 472
> ++
>  .../Universal/MctpProtocol/Dxe/MctpProtocol.c | 218 
>  6 files changed, 985 insertions(+)
>  create mode 100644
> Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
>  create mode 100644
> Features/ManageabilityPkg/Include/Protocol/MctpProtocol.h
>  create mode 100644
> Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCo
> mmon.h
>  create mode 100644
> Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCo
> mmon.c
>  create mode 100644
> Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocol.c
> 
> diff --git a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
> b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
> index 2a354ad898..17f067c6d0 100644
> --- a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
> +++ b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
> @@ -33,4 +33,5 @@
>  [Components.X64]
>ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.inf
> 
> ManageabilityPkg/Universal/PldmSmbiosTransferDxe/PldmSmbiosTransferDxe.i
> nf
> +  ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
> 
> diff --git
> a/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.in
> f
> b/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.in
> f
> new file mode 100644
> index 00..483fbcc04b
> --- /dev/null
> +++
> b/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.in
> f
> @@ -0,0 +1,53 @@
> +## @file
> +# MCTP Protocol DXE Driver.
> +#
> +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +##
> +
> +[Defines]
> +  INF_VERSION= 0x0001001d
> +  BASE_NAME  = MctpDxe
> +  FILE_GUID  = 58AF169A-AA3F-462B-B0F1-25FBE6C97978
> +  MODULE_TYPE= DXE_DRIVER
> +  VERSION_STRING = 1.0
> +  ENTRY_POINT= DxeMctpEntry
> +  UNLOAD_IMAGE   = MctpUnloadImage
> +
> +#
> +#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
> +#
> +
> +[Sources]
> +  MctpProtocol.c
> +  ../Common/MctpProtocolCommon.c
> +  ../Common/MctpProtocolCommon.h
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  ManageabilityPkg/ManageabilityPkg.dec
> +
> +[LibraryClasses]
> +  BaseMemoryLib
> +  DebugLib
> +  MemoryAllocationLib
> +  ManageabilityTransportHelperLib
> +  ManageabilityTransportLib
> +  UefiDriverEntryPoint
> +  UefiBootServicesTableLib
> +
> +[Guids]
> +  gManageabilityProtocolMctpGuid
> +
> +[Protocols]
> +  gEdkiiMctpProtocolGuid
> +
> +[FixedPcd]
> +  gManageabilityPkgTokenSpaceGuid.PcdMctpKcsMemoryMappedIo
> +  gManageabilityPkgTokenSpaceGuid.PcdMctpKcsBaseAddress
> +  gManageabilityPkgTokenSpaceGuid.PcdMctpSourceEndpointId
> +  gManageabilityPkgTokenSpaceGuid.PcdMctpDestinationEndpointId
> +
> +[Depex]
> +  TRUE
> diff --git a/Features/ManageabilityPkg/Include/Protocol/MctpProtocol.h
> b/Features/ManageabilityPkg/Include/Protocol/MctpProtocol.h
> new file mode 100644
> index 00..85e42f157d
> --- /dev/null
> +++ b/Features/ManageabilityPkg/Include/Protocol/MctpProtocol.h
> @@ -0,0 +1,102 @@
> +/** @file
> +  Protocol of EDKII MCTP Protocol.
> +
> +  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef EDKII_MCTP_PROTOCOL_H_
> +#define EDKII_MCTP_PROTOCOL_H_
> +
> +#include 
> +
> +typedef struct  _EDKII_MCTP_PROTOCOL EDKII_MCTP_PROTOCOL;
> +
> +#define EDKII_MCTP_PROTOCOL_GUID \
> +  { \
> +0xE93465C1, 0x9A31, 0x4C96, 0x92, 0x56, 0x22, 0x0A, 0xE1, 0x80, 0xB4,
> 0x1B \
> +  }
> +
> +#define EDKII_MCTP_PROTOCOL_VERSION_MAJOR  1
> +#define EDKII_MCTP_PROTOCOL_VERSION_MINOR  0
> +#define EDKII_MCTP_PROTOCOL_VERSION
> ((EDKII_MCTP_PROTOCOL_VERSION_MAJOR << 8) |\
> +   EDKII_MCTP_PROTOCOL_VERSION_MINOR)
> +
> +/**
> +  This service enables 

[edk2-devel] Event: TianoCore Bug Triage - APAC / NAMO - Tuesday, April 25, 2023 #cal-reminder

2023-04-24 Thread Group Notification
*Reminder: TianoCore Bug Triage - APAC / NAMO*

*When:*
Tuesday, April 25, 2023
6:30pm to 7:30pm
(UTC-07:00) America/Los Angeles

*Where:*
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTk1YzJhN2UtOGQwNi00NjY4LWEwMTktY2JiODRlYTY1NmY0%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4-1242-431b-9a51-92cd01a5df3c%22%7d

*Organizer:* Liming Gao gaolim...@byosoft.com.cn ( 
gaolim...@byosoft.com.cn?subject=Re:%20Event:%20TianoCore%20Bug%20Triage%20-%20APAC%20%2F%20NAMO
 )

View Event ( https://edk2.groups.io/g/devel/viewevent?eventid=1876206 )

*Description:*

TianoCore Bug Triage - APAC / NAMO

Hosted by Liming Gao



Microsoft Teams meeting

*Join on your computer or mobile app*

Click here to join the meeting ( 
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTk1YzJhN2UtOGQwNi00NjY4LWEwMTktY2JiODRlYTY1NmY0%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4-1242-431b-9a51-92cd01a5df3c%22%7d
 )

*Join with a video conferencing device*

te...@conf.intel.com

Video Conference ID: 116 062 094 0

Alternate VTC dialing instructions ( 
https://conf.intel.com/teams/?conf=1160620940=teams=conf.intel.com=test_call
 )

*Or call in (audio only)*

+1 916-245-6934,,77463821# ( tel:+19162456934,,77463821# ) United States, 
Sacramento

Phone Conference ID: 774 638 21#

Find a local number ( 
https://dialin.teams.microsoft.com/d195d438-2daa-420e-b9ea-da26f9d1d6d5?id=77463821
 ) | Reset PIN ( https://mysettings.lync.com/pstnconferencing )

Learn More ( https://aka.ms/JoinTeamsMeeting ) | Meeting options ( 
https://teams.microsoft.com/meetingOptions/?organizerId=b286b53a-1218-4db3-bfc9-3d4c5aa7669e=46c98d88-e344-4ed4-8496-4ed7712e255d=19_meeting_OTUyZTg2NjgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh@thread.v2=0=en-US
 )


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103502): https://edk2.groups.io/g/devel/message/103502
Mute This Topic: https://groups.io/mt/98485134/21656
Mute #cal-reminder:https://edk2.groups.io/g/devel/mutehashtag/cal-reminder
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] Partial GitHub outage affecting TianoCore CI

2023-04-24 Thread Rebecca Cran
I noticed some CI tasks are timing out. For example, from 
https://github.com/tianocore/edk2/actions/runs/4792357032/jobs/8523786475?pr=4301 
:


Did not find CodeQL tools version 2.13.0 in the toolcache.
Error: request to 
https://api.github.com/repositories/259445878/releases?page=2 failed, 
reason: connect ETIMEDOUT 192.30.255.117:443


Error: Unable to download and extract CodeQL CLI


https://www.githubstatus.com/ reports there's an ongoing issue affecting 
several services.



--
Rebecca Cran



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103501): https://edk2.groups.io/g/devel/message/103501
Mute This Topic: https://groups.io/mt/98484388/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] Bugzilla missing releases after edk2-stable202105

2023-04-24 Thread Michael D Kinney
I have updated both release fields to include all releases.

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Rebecca Cran
> Sent: Monday, April 24, 2023 6:14 AM
> To: devel@edk2.groups.io; Kinney, Michael D ; 
> Gao, Liming 
> Subject: [edk2-devel] Bugzilla missing releases after edk2-stable202105
> 
> The newest release listed in Bugzilla is edk2-stable202105.
> 
> Could someone add the newer releases please?
> 
> 
> Thanks.
> Rebecca Cran
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103500): https://edk2.groups.io/g/devel/message/103500
Mute This Topic: https://groups.io/mt/98469627/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




回复: [edk2-devel] [PATCH v2 1/1] BaseTools: Add quotes around OBJCOPY cmd in build_rule.template

2023-04-24 Thread gaoliming via groups.io
Reviewed-by: Liming Gao 

This change can be merged first. 

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Rebecca Cran
> 发送时间: 2023年4月24日 22:06
> 收件人: devel@edk2.groups.io; Liming Gao ;
> Bob Feng ; Yuwei Chen 
> 抄送: Rebecca Cran 
> 主题: [edk2-devel] [PATCH v2 1/1] BaseTools: Add quotes around OBJCOPY
> cmd in build_rule.template
> 
> Add quotes around the OBJCOPY command in build_rule.template to fix the
> case where LLVM is installed on Windows in a path with spaces such as
> C:\Program Files\LLVM.
> 
> Signed-off-by: Rebecca Cran 
> ---
>  BaseTools/Conf/build_rule.template | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/BaseTools/Conf/build_rule.template
> b/BaseTools/Conf/build_rule.template
> index d42e7937cc90..eb64c62060e1 100755
> --- a/BaseTools/Conf/build_rule.template
> +++ b/BaseTools/Conf/build_rule.template
> @@ -352,12 +352,12 @@
>  -$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR)
>  
>  $(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).debug
> -$(OBJCOPY) $(OBJCOPY_STRIPFLAG) ${src}
> +"$(OBJCOPY)" $(OBJCOPY_STRIPFLAG) ${src}
> 
>  #
>  #The below 2 lines are only needed for UNIXGCC tool chain, which
> generates PE image directly
>  #
> --$(OBJCOPY) $(OBJCOPY_ADDDEBUGFLAG) ${src}
> +-"$(OBJCOPY)" $(OBJCOPY_ADDDEBUGFLAG) ${src}
>  -$(CP) $(DEBUG_DIR)(+)$(MODULE_NAME).debug
> $(BIN_DIR)(+)$(MODULE_NAME_GUID).debug
> 
>  "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src}
> $(GENFW_FLAGS)
> --
> 2.40.0.windows.1
> 
> 
> 
> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103499): https://edk2.groups.io/g/devel/message/103499
Mute This Topic: https://groups.io/mt/98483534/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] Now: Tools, CI, Code base construction meeting series - Monday, April 24, 2023 #cal-notice

2023-04-24 Thread Group Notification
*Tools, CI, Code base construction meeting series*

*When:*
Monday, April 24, 2023
4:30pm to 5:30pm
(UTC-07:00) America/Los Angeles

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

View Event ( https://edk2.groups.io/g/devel/viewevent?eventid=1875406 )

*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.

* tianocore/edk2: EDK II (github.com)
* tianocore/edk2-basetools: EDK II BaseTools Python tools as a PIP module 
(github.com) https://github.com/tianocore/edk2-basetools
* tianocore/edk2-pytool-extensions: Extensions to the edk2 build system 
allowing for a more robust and plugin based build system and tool execution 
environment (github.com) https://github.com/tianocore/edk2-pytool-extensions
* tianocore/edk2-pytool-library: Python library package that supports UEFI 
development (github.com) https://github.com/tianocore/edk2-pytool-library

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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103498): https://edk2.groups.io/g/devel/message/103498
Mute This Topic: https://groups.io/mt/98483272/21656
Mute #cal-notice:https://edk2.groups.io/g/devel/mutehashtag/cal-notice
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] Event: Tools, CI, Code base construction meeting series - Monday, April 24, 2023 #cal-reminder

2023-04-24 Thread Group Notification
*Reminder: Tools, CI, Code base construction meeting series*

*When:*
Monday, April 24, 2023
4:30pm to 5:30pm
(UTC-07:00) America/Los Angeles

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

View Event ( https://edk2.groups.io/g/devel/viewevent?eventid=1875406 )

*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.

* tianocore/edk2: EDK II (github.com)
* tianocore/edk2-basetools: EDK II BaseTools Python tools as a PIP module 
(github.com) https://github.com/tianocore/edk2-basetools
* tianocore/edk2-pytool-extensions: Extensions to the edk2 build system 
allowing for a more robust and plugin based build system and tool execution 
environment (github.com) https://github.com/tianocore/edk2-pytool-extensions
* tianocore/edk2-pytool-library: Python library package that supports UEFI 
development (github.com) https://github.com/tianocore/edk2-pytool-library

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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103497): https://edk2.groups.io/g/devel/message/103497
Mute This Topic: https://groups.io/mt/98460434/21656
Mute #cal-reminder:https://edk2.groups.io/g/devel/mutehashtag/cal-reminder
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] Maintainers.txt: Update for IntelFsp2Pkg and IntelFsp2WrapperPkg.

2023-04-24 Thread Ashraf Ali S
Reviewed-by: S, Ashraf Ali 

From: Chiu, Chasel 
Sent: Monday, April 24, 2023 11:50:35 PM
To: devel@edk2.groups.io 
Cc: Chiu, Chasel ; Desimone, Nathaniel L 
; Duggapu, Chinni B 
; Ng, Ray Han Lim ; Chen, 
Gang C ; Zeng, Star ; Kuo, Ted 
; S, Ashraf Ali ; Mohapatra, Susovan 

Subject: [PATCH] Maintainers.txt: Update for IntelFsp2Pkg and 
IntelFsp2WrapperPkg.

Add more maintainers and reviewers for these 2 packages.

Cc: Nate DeSimone 
Cc: Duggapu Chinni B 
Cc: Ray Han Lim Ng 
Cc: Chen Gang C 
Cc: Star Zeng 
Cc: Ted Kuo 
Cc: Ashraf Ali S 
Cc: Susovan Mohapatra 
Signed-off-by: Chasel Chiu 
---
 Maintainers.txt | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/Maintainers.txt b/Maintainers.txt
index 455afdbc69..09d04af27a 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -237,14 +237,24 @@ F: IntelFsp2Pkg/
 W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2Pkg

 M: Chasel Chiu  [ChaselChiu]

 M: Nate DeSimone  [nate-desimone]

+M: Duggapu Chinni B  [cbduggap]

+M: Ray Han Lim Ng  [rayhanlimng]

 R: Star Zeng  [lzeng14]

+R: Ted Kuo  [tedkuo1]

+R: Ashraf Ali S  [AshrafAliS]

+R: Susovan Mohapatra  [susovanmohapatra]



 IntelFsp2WrapperPkg

 F: IntelFsp2WrapperPkg/

 W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2WrapperPkg

 M: Chasel Chiu  [ChaselChiu]

 M: Nate DeSimone  [nate-desimone]

+M: Duggapu Chinni B  [cbduggap]

+M: Chen Gang C  [chengangc]

 R: Star Zeng  [lzeng14]

+R: Ted Kuo  [tedkuo1]

+R: Ashraf Ali S  [AshrafAliS]

+R: Susovan Mohapatra  [susovanmohapatra]



 MdeModulePkg

 F: MdeModulePkg/

--
2.35.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103496): https://edk2.groups.io/g/devel/message/103496
Mute This Topic: https://groups.io/mt/98477288/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] Maintainers.txt: Update for IntelFsp2Pkg and IntelFsp2WrapperPkg.

2023-04-24 Thread Chiu, Chasel
Add more maintainers and reviewers for these 2 packages.

Cc: Nate DeSimone 
Cc: Duggapu Chinni B 
Cc: Ray Han Lim Ng 
Cc: Chen Gang C 
Cc: Star Zeng 
Cc: Ted Kuo 
Cc: Ashraf Ali S 
Cc: Susovan Mohapatra 
Signed-off-by: Chasel Chiu 
---
 Maintainers.txt | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/Maintainers.txt b/Maintainers.txt
index 455afdbc69..09d04af27a 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -237,14 +237,24 @@ F: IntelFsp2Pkg/
 W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2Pkg
 M: Chasel Chiu  [ChaselChiu]
 M: Nate DeSimone  [nate-desimone]
+M: Duggapu Chinni B  [cbduggap]
+M: Ray Han Lim Ng  [rayhanlimng]
 R: Star Zeng  [lzeng14]
+R: Ted Kuo  [tedkuo1]
+R: Ashraf Ali S  [AshrafAliS]
+R: Susovan Mohapatra  [susovanmohapatra]
 
 IntelFsp2WrapperPkg
 F: IntelFsp2WrapperPkg/
 W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2WrapperPkg
 M: Chasel Chiu  [ChaselChiu]
 M: Nate DeSimone  [nate-desimone]
+M: Duggapu Chinni B  [cbduggap]
+M: Chen Gang C  [chengangc]
 R: Star Zeng  [lzeng14]
+R: Ted Kuo  [tedkuo1]
+R: Ashraf Ali S  [AshrafAliS]
+R: Susovan Mohapatra  [susovanmohapatra]
 
 MdeModulePkg
 F: MdeModulePkg/
-- 
2.35.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103495): https://edk2.groups.io/g/devel/message/103495
Mute This Topic: https://groups.io/mt/98477288/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v5 00/13] BaseTools,CryptoPkg,EmulatorPkg,MdePkg,others: Delete CLANG35,CLANG38,VS2008-2013,EBC, deprecate GCC48,GCC49,GCC5, add GCC and GCCNOLTO, update CLANGDWARF

2023-04-24 Thread Rebecca Cran

It is something I could help troubleshoot in parallel?


--

Rebecca Cran


On 4/24/23 00:14, Kinney, Michael D wrote:

Hi Rebecca,

I have seen some issues with CLANGDWARF and need a little time to investigate 
further.

Mike


-Original Message-
From: Rebecca Cran 
Sent: Friday, April 21, 2023 10:15 AM
To: devel@edk2.groups.io; Gao, Liming ; Feng, Bob C 
; Chen, Christine
; Kinney, Michael D ; Michael 
Kubacki ; Sean
Brogan ; Chiu, Chasel ; 
Desimone, Nathaniel L
; Zeng, Star ; Andrew Fish 

Cc: Rebecca Cran ; Ni, Ray ; Leif Lindholm 
; Liu, Zhiguang
; Wang, Jian J ; Lu, Xiaoyu1 
; Jiang, Guomin
; Guo, Gua ; Ard Biesheuvel 
; Pedro Falcato
; Gerd Hoffmann ; Marvin Häuser 

Subject: [PATCH v5 00/13] BaseTools,CryptoPkg,EmulatorPkg,MdePkg,others: Delete 
CLANG35,CLANG38,VS2008-2013,EBC, deprecate
GCC48,GCC49,GCC5, add GCC and GCCNOLTO, update CLANGDWARF

Update the toolchain definitions:

- Delete the CLANG35 and CLANG38 toolchains, and replace CLANG38 with
   CLANGDWARF, updating it to support ARM and AARCH64 in addition to X64
and IA32.

- Mark GCC48, GCC49 and GCC5 as deprecated.

- Add GCC and GCCNOLTO toolchain definitions.

- Remove VS2008, VS2010, VS2012 and VS2013.

- Remove EBC compiler definitions. Full removal of EBC support from the
   various packages etc. will be done in a follow-up patch series.

- Remove unused IPHONE_TOOLS and SOURCERY_CYGWIN_TOOLS definitions.

- Remove unused CYGWIN_ definitions.

Personal GitHub PR: https://github.com/tianocore/edk2/pull/4240
GitHub branch: https://github.com/bcran/edk2/tree/clangdwarf

Note: CI is now passing.

Changes from v1 to v2
=

- Added a commit to delete GCC48 and GCC49, rename GCC5 to GCC and
   update the flags for other toolchains to work with the new GCC
   definitions.

- Bumped VERSION from 2.00 to 3.00 to inform users that they should
   update their Conf/tools_def.txt.

Changes from v2 to v3
=

- Keep GCC48, GCC49 and GCC5 but mark them deprecated, including with
   warnings at the start and end of running a build.

- Dropped the commit fixing the IA32 build of UefiPayloadPkg, because it
   causes CI to fail due to building both IA32 and X64 at the same time:

   "Module built under multiple ARCHs [IA32, X64]. Not able to determine which 
output to put into flash for Module..."

- Added more information to the VERSION section in tools_def.template.

- Various fixes to the CLANGDWARF flags.

Changes from v3 to v4
=

- Use lld for -a ARM -t CLANGDWARF.

Changes from v4 to v5
=

- Fixed CLANGDWARF on Windows when llvm is installed with the llvm.org
   installer and isn't installed in Visual Studio: use llvm-objcopy and the
   tools prefix.

- Added flags for GCCNOLTO to UnitTestFrameworkPkgHost.dsc.inc

- Added GCC flags to CryptoPkg/Library/OpensslLib/*.inf

Rebecca Cran (13):
   BaseTools,CryptoPkg: Update CLANGDWARF, remove CLANG 35/38 toolchains
   BaseTools: Remove VS2008, 2010, 2012 and 2013 toolchain definitions
   BaseTools: Remove VS2008-VS2013 remnants
   MdePkg: Remove VS2008-VS2013 remnants
   edksetup.bat: Remove VS2008-VS2013 remnants
   BaseTools: Remove unused IPHONE_TOOLS and SOURCERY_CYGWIN_TOOLS defs
   BaseTools: Remove EBC (EFI Byte Code) compiler definitions
   BaseTools: Update VS toolchain descriptions in tools_def.txt.template
   BaseTools/Conf/tools_def.template: Add GCC and GCCNOLTO toolchains
   BaseTools: Only call LoadConfiguration once in build.py
   BaseTools: Add a deprecation warning for GCC48,GCC49,GCC5 to build.py
   BaseTools/Conf/tools_def.template: Add section for deprecated
 toolchains
   BaseTools/Conf/tools_def.template: Bump VERSION to 3.00

  UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc   |4 
  IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc |9 -
  CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf |3 +--
  CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf  |3 +--
  CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf  |3 +--
  CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf  |3 +--
  CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf  |3 +--
  CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf |3 +--
  CryptoPkg/Library/OpensslLib/OpensslLib.inf |4 ++--
  CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf|4 ++--
  CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf   |4 ++--
  CryptoPkg/Library/OpensslLib/OpensslLibFull.inf |4 ++--
  CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf|5 +++--
  EmulatorPkg/Unix/Host/Host.inf  |2 ++
  MdePkg/Include/Ia32/ProcessorBind.h |8 ++--
  MdePkg/Include/X64/ProcessorBind.h  |8 ++--
  BaseTools/Conf/tools_def.template   | 1993

Re: [edk2-devel] [Patch V3 0/8] Create page table by CpuPageTableLib in DxeIpl

2023-04-24 Thread Ard Biesheuvel
On Mon, 24 Apr 2023 at 19:51, Kinney, Michael D
 wrote:
>
> Hi Ard,
>
> Thanks for the feedback.  Let's work on this approach.
>
> Are there similar needs for CPU related services in the DXE Core before
> the CPU AP is loaded?
>
> If we are going to define a new lib class to abstract DXE IPL requirements,
> it would be good to cover DXE Core requirements too.
>

Yeah, excellent point.

The problem I have had to work around in my strict permissions series
(which includes the linked patch) is that there is a window from the
moment DXE core is dispatched until the moment the CPU arch protocol
DXE driver is dispatched where we don't have an architectural means to
manipulate memory permissions.

So what we'd need here is a library version of the following method

typedef
EFI_STATUS
(EFIAPI *EFI_CPU_SET_MEMORY_ATTRIBUTES)(
  IN EFI_CPU_ARCH_PROTOCOL  *This,
  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
  IN  UINT64Length,
  IN  UINT64Attributes
  );

*However*, I am aware that the X86 DXE IPL code deviates from this, as
it needs to build long mode compatible page tables before switching
from IA32 to X64, right?
So whether that use case can be served with this prototype is
doubtful, but I guess it /would/ make sense to define a single library
abstraction that can accommodate all of these use cases.

Happy to discuss this in more detail,



>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Ard 
> > Biesheuvel
> > Sent: Monday, April 24, 2023 10:24 AM
> > To: devel@edk2.groups.io; Tan, Dun 
> > Subject: Re: [edk2-devel] [Patch V3 0/8] Create page table by 
> > CpuPageTableLib in DxeIpl
> >
> > On Mon, 24 Apr 2023 at 12:06, duntan  wrote:
> > >
> > > In V3 patch set:
> > > 1. Add a new patch 'MdePkg: Move CpuPageTableLib defination to MdePkg' to 
> > > Move CpuPageTableLib defination from UefiCpuPkg to
> > MdePkg.
> > >So that MdeModulePkg doesn't need to depend on UefiCpuPkg.
> >
> > As I replied to the other patch, I think adding CpuPageTableLib to
> > MdePkg in its current form (even only the interface) is not the right
> > approach here. The function protoypes and enums exposed by this
> > library are highly specific to a particular implementation.
> >
> > There is a clear use case here, which is the DXE IPL code, and as has
> > been suggested in the other thread, it would be more appropriate to
> > define an abstraction regarding this use case, and define it as a
> > library class (with a NULL implementation) in MdeModulePkg. That way,
> > UefiCpuPkg can provide the x86 implementation based on
> > CpuPageTableLilb, and other architectures can do likewise.
> >
> > Please refer to the patch below, which illustrates why there are other
> > requirements in this area:
> >
> > https://edk2.groups.io/g/devel/message/101122
> >
> > --
> > Ard.
> >
> >
> >
> >
> > > 2. Modify the patch 'MdeModulePkg/DxeIpl: Create page table by 
> > > CpuPageTableLib' to set GHCB page to be mapped as unencrypted
> > for each CPU for AMD SEV feature.
> > >
> > > Dun Tan (8):
> > >   MdePkg: Move CpuPageTableLib defination to MdePkg
> > >   EmulatorPkg: Add CpuPageTableLib required by DxeIpl in DSC
> > >   IntelFsp2Pkg: Add CpuPageTableLib required by DxeIpl in DSC
> > >   MdeModulePkg: Add CpuPageTableLib required by DxeIpl in DSC
> > >   OvmfPkg: Add CpuPageTableLib required by DxeIpl in DSC file
> > >   MdeModulePkg/DxeIpl: Create page table by CpuPageTableLib
> > >   MdeModulePkg/DxeIpl: Remove duplicated code to enable NX
> > >   MdeModulePkg/DxeIpl: Refinement to the code to set PageTable as RO
> > >
> > >  EmulatorPkg/EmulatorPkg.dsc  |   3 ++-
> > >  IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc  |   3 ++-
> > >  MdeModulePkg/Core/DxeIplPeim/DxeIpl.h|   3 ++-
> > >  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf  |   5 -
> > >  MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c  | 112 
> > > --
> > --
> > >  MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c   |   5 +++--
> > >  MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 720
> > 
> > 
> > 
> > 
> > 
> > 

Re: [edk2-devel] [Patch V3 0/8] Create page table by CpuPageTableLib in DxeIpl

2023-04-24 Thread Michael D Kinney
Hi Ard,

Thanks for the feedback.  Let's work on this approach.

Are there similar needs for CPU related services in the DXE Core before
the CPU AP is loaded?

If we are going to define a new lib class to abstract DXE IPL requirements,
it would be good to cover DXE Core requirements too.

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ard Biesheuvel
> Sent: Monday, April 24, 2023 10:24 AM
> To: devel@edk2.groups.io; Tan, Dun 
> Subject: Re: [edk2-devel] [Patch V3 0/8] Create page table by CpuPageTableLib 
> in DxeIpl
> 
> On Mon, 24 Apr 2023 at 12:06, duntan  wrote:
> >
> > In V3 patch set:
> > 1. Add a new patch 'MdePkg: Move CpuPageTableLib defination to MdePkg' to 
> > Move CpuPageTableLib defination from UefiCpuPkg to
> MdePkg.
> >So that MdeModulePkg doesn't need to depend on UefiCpuPkg.
> 
> As I replied to the other patch, I think adding CpuPageTableLib to
> MdePkg in its current form (even only the interface) is not the right
> approach here. The function protoypes and enums exposed by this
> library are highly specific to a particular implementation.
> 
> There is a clear use case here, which is the DXE IPL code, and as has
> been suggested in the other thread, it would be more appropriate to
> define an abstraction regarding this use case, and define it as a
> library class (with a NULL implementation) in MdeModulePkg. That way,
> UefiCpuPkg can provide the x86 implementation based on
> CpuPageTableLilb, and other architectures can do likewise.
> 
> Please refer to the patch below, which illustrates why there are other
> requirements in this area:
> 
> https://edk2.groups.io/g/devel/message/101122
> 
> --
> Ard.
> 
> 
> 
> 
> > 2. Modify the patch 'MdeModulePkg/DxeIpl: Create page table by 
> > CpuPageTableLib' to set GHCB page to be mapped as unencrypted
> for each CPU for AMD SEV feature.
> >
> > Dun Tan (8):
> >   MdePkg: Move CpuPageTableLib defination to MdePkg
> >   EmulatorPkg: Add CpuPageTableLib required by DxeIpl in DSC
> >   IntelFsp2Pkg: Add CpuPageTableLib required by DxeIpl in DSC
> >   MdeModulePkg: Add CpuPageTableLib required by DxeIpl in DSC
> >   OvmfPkg: Add CpuPageTableLib required by DxeIpl in DSC file
> >   MdeModulePkg/DxeIpl: Create page table by CpuPageTableLib
> >   MdeModulePkg/DxeIpl: Remove duplicated code to enable NX
> >   MdeModulePkg/DxeIpl: Refinement to the code to set PageTable as RO
> >
> >  EmulatorPkg/EmulatorPkg.dsc  |   3 ++-
> >  IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc  |   3 ++-
> >  MdeModulePkg/Core/DxeIplPeim/DxeIpl.h|   3 ++-
> >  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf  |   5 -
> >  MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c  | 112 
> > --
> --
> >  MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c   |   5 +++--
> >  MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 720
> 
> 
> 
> 
> 
> 
> >  MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h | 182 
> > ++
> 
> >  MdeModulePkg/MdeModulePkg.dsc|   3 ++-
> >  {UefiCpuPkg => MdePkg}/Include/Library/CpuPageTableLib.h |   0
> >  MdePkg/MdePkg.dec|   5 -
> >  OvmfPkg/AmdSev/AmdSevX64.dsc |   2 +-
> >  OvmfPkg/Bhyve/BhyveX64.dsc   |   3 ++-
> >  OvmfPkg/CloudHv/CloudHvX64.dsc   |   2 +-
> >  OvmfPkg/Microvm/MicrovmX64.dsc   |   2 +-
> >  OvmfPkg/OvmfPkgIa32.dsc  |   3 ++-
> >  OvmfPkg/OvmfPkgIa32X64.dsc   |   2 +-
> >  OvmfPkg/OvmfPkgX64.dsc   |   2 +-
> >  OvmfPkg/OvmfXen.dsc  |   2 +-
> >  UefiCpuPkg/UefiCpuPkg.dec|   3 ---
> >  20 files changed, 211 insertions(+), 851 deletions(-)
> >  rename {UefiCpuPkg => 

Re: [edk2-devel] [PATCH v3 2/3] MdePkg: Support FDT library.

2023-04-24 Thread Michael D Kinney
Hi Leif,

Do you have a proposal or small example on what you want to see
in the library?

Mike

> -Original Message-
> From: Leif Lindholm 
> Sent: Monday, April 24, 2023 10:29 AM
> To: devel@edk2.groups.io; Kinney, Michael D 
> Cc: Lin, Benny ; Leif Lindholm 
> ; Gao, Liming ; Liu,
> Zhiguang ; Pedro Falcato 
> Subject: Re: [edk2-devel] [PATCH v3 2/3] MdePkg: Support FDT library.
> 
> Apologies, I was refactoring a git tree and switched off the world :)
> 
> Well, being a bit late to the party ... my view is it would be
> preferable if we put the byteswapping in the library.
> 
> The DT format is *defined* to be big-endian, 32-bit cells. So frankly,
> I have no problems with pushing responsibility onto individual
> platforms if they have decided to be "clever" by ignoring that -
> if that gets rid of a bunch of boilerplate for sensibly behaving platforms.
> 
> Maybe another excuse for getting
> https://github.com/tianocore/edk2-platforms/blob/master/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c
> into MdePkg?
> 
> /
> Leif
> 
> On Thu, Apr 20, 2023 at 16:44:03 +, Michael D Kinney wrote:
> > Hi Leif,
> >
> > What is your opinion on FDT being big endian.
> >
> > Do we want the lib to help with that aspect, or leave it up to the consumer 
> > of the lib to
> > convert as needed?  Seems like an area that could be very error prone if we 
> > are not
> > careful.
> >
> > Mike
> >
> > > -Original Message-
> > > From: Lin, Benny 
> > > Sent: Wednesday, April 19, 2023 9:25 PM
> > > To: Kinney, Michael D ; devel@edk2.groups.io
> > > Cc: Gao, Liming ; Liu, Zhiguang 
> > > ; Pedro Falcato 
> > > Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library.
> > >
> > >
> > >
> > > >-Original Message-
> > > >From: Kinney, Michael D 
> > > >Sent: Thursday, April 20, 2023 5:04 AM
> > > >To: Lin, Benny ; devel@edk2.groups.io
> > > >Cc: Gao, Liming ; Liu, Zhiguang 
> > > >; Pedro Falcato
> ; Kinney,
> > > Michael D 
> > > >Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library.
> > > >
> > > >Responses below
> > > >
> > > >Mike
> > > >
> > > >> -Original Message-
> > > >> From: Lin, Benny 
> > > >> Sent: Wednesday, April 19, 2023 10:12 AM
> > > >> To: Kinney, Michael D ;
> > > >> devel@edk2.groups.io
> > > >> Cc: Gao, Liming ; Liu, Zhiguang
> > > >> ; Pedro Falcato 
> > > >> Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library.
> > > >>
> > > >> Please find my feedback below.
> > > >> We can remove FDT_RESERVE_ENTRY but keep FDT_NODE_HEADER, what do you 
> > > >> think?
> > > >>
> > > >> QQQ
> > > >> Benny
> > > >>
> > > >> >-Original Message-
> > > >> >From: Kinney, Michael D 
> > > >> >Sent: Wednesday, April 19, 2023 11:54 PM
> > > >> >To: Lin, Benny ; devel@edk2.groups.io
> > > >> >Cc: Gao, Liming ; Liu, Zhiguang
> > > >> >; Pedro Falcato ;
> > > >> >Kinney,
> > > >> Michael D 
> > > >> >Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library.
> > > >> >
> > > >> >A few comments below.
> > > >> >
> > > >> >Mike
> > > >> >
> > > >> >> -Original Message-
> > > >> >> From: Lin, Benny 
> > > >> >> Sent: Sunday, April 16, 2023 10:35 PM
> > > >> >> To: devel@edk2.groups.io
> > > >> >> Cc: Lin, Benny ; Kinney, Michael D
> > > >> >> ; Gao, Liming
> > > >> >> ; Liu, Zhiguang ;
> > > >> >> Pedro Falcato 
> > > >> >> Subject: [PATCH v3 2/3] MdePkg: Support FDT library.
> > > >> >>
> > > >> >> From: Benny Lin 
> > > >> >>
> > > >> >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392
> > > >> >> Add FDT support in EDK2 by submodule 3rd party libfdt
> > > >> >> (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt)
> > > >> >> and refer to LibcLib implementation by Pedro.
> > > >> >>
> > > >> >> Cc: Michael D Kinney 
> > > >> >> Cc: Liming Gao 
> > > >> >> Cc: Zhiguang Liu 
> > > >> >> Acked-by: Pedro Falcato 
> > > >> >> Signed-off-by: Benny Lin 
> > > >> >> ---
> > > >> >>  MdePkg/Include/Library/FdtLib.h   | 314 
> > > >> >> 
> > > >> >>  MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 
> > > >> >> MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
> > > >> >>  MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++
> > > >> >>  MdePkg/Library/BaseFdtLib/LibFdtSupport.h |  99 ++
> > > >> >> MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++
> > > >> >>  MdePkg/Library/BaseFdtLib/limits.h|  10 +
> > > >> >>  MdePkg/Library/BaseFdtLib/stdbool.h   |  10 +
> > > >> >>  MdePkg/Library/BaseFdtLib/stddef.h|  10 +
> > > >> >>  MdePkg/Library/BaseFdtLib/stdint.h|  10 +
> > > >> >>  MdePkg/Library/BaseFdtLib/stdlib.h|  10 +
> > > >> >>  MdePkg/Library/BaseFdtLib/string.h|  10 +
> > > >> >>  MdePkg/MdePkg.ci.yaml |  17 +-
> > > >> >>  MdePkg/MdePkg.dec |   4 +
> > > >> >>  MdePkg/MdePkg.dsc |   1 +
> > > >> >>  15 files changed, 1043 insertions(+), 2 deletions(-)
> > > >> >>
> > > >> >> diff --git 

Re: [edk2-devel] [PATCH v3 2/3] MdePkg: Support FDT library.

2023-04-24 Thread Leif Lindholm
Apologies, I was refactoring a git tree and switched off the world :)

Well, being a bit late to the party ... my view is it would be
preferable if we put the byteswapping in the library.

The DT format is *defined* to be big-endian, 32-bit cells. So frankly,
I have no problems with pushing responsibility onto individual
platforms if they have decided to be "clever" by ignoring that -
if that gets rid of a bunch of boilerplate for sensibly behaving platforms.

Maybe another excuse for getting
https://github.com/tianocore/edk2-platforms/blob/master/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c
into MdePkg?

/
Leif

On Thu, Apr 20, 2023 at 16:44:03 +, Michael D Kinney wrote:
> Hi Leif,
> 
> What is your opinion on FDT being big endian.
> 
> Do we want the lib to help with that aspect, or leave it up to the consumer 
> of the lib to 
> convert as needed?  Seems like an area that could be very error prone if we 
> are not
> careful.
> 
> Mike
> 
> > -Original Message-
> > From: Lin, Benny 
> > Sent: Wednesday, April 19, 2023 9:25 PM
> > To: Kinney, Michael D ; devel@edk2.groups.io
> > Cc: Gao, Liming ; Liu, Zhiguang 
> > ; Pedro Falcato 
> > Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library.
> > 
> > 
> > 
> > >-Original Message-
> > >From: Kinney, Michael D 
> > >Sent: Thursday, April 20, 2023 5:04 AM
> > >To: Lin, Benny ; devel@edk2.groups.io
> > >Cc: Gao, Liming ; Liu, Zhiguang 
> > >; Pedro Falcato ; Kinney,
> > Michael D 
> > >Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library.
> > >
> > >Responses below
> > >
> > >Mike
> > >
> > >> -Original Message-
> > >> From: Lin, Benny 
> > >> Sent: Wednesday, April 19, 2023 10:12 AM
> > >> To: Kinney, Michael D ;
> > >> devel@edk2.groups.io
> > >> Cc: Gao, Liming ; Liu, Zhiguang
> > >> ; Pedro Falcato 
> > >> Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library.
> > >>
> > >> Please find my feedback below.
> > >> We can remove FDT_RESERVE_ENTRY but keep FDT_NODE_HEADER, what do you 
> > >> think?
> > >>
> > >> QQQ
> > >> Benny
> > >>
> > >> >-Original Message-
> > >> >From: Kinney, Michael D 
> > >> >Sent: Wednesday, April 19, 2023 11:54 PM
> > >> >To: Lin, Benny ; devel@edk2.groups.io
> > >> >Cc: Gao, Liming ; Liu, Zhiguang
> > >> >; Pedro Falcato ;
> > >> >Kinney,
> > >> Michael D 
> > >> >Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library.
> > >> >
> > >> >A few comments below.
> > >> >
> > >> >Mike
> > >> >
> > >> >> -Original Message-
> > >> >> From: Lin, Benny 
> > >> >> Sent: Sunday, April 16, 2023 10:35 PM
> > >> >> To: devel@edk2.groups.io
> > >> >> Cc: Lin, Benny ; Kinney, Michael D
> > >> >> ; Gao, Liming
> > >> >> ; Liu, Zhiguang ;
> > >> >> Pedro Falcato 
> > >> >> Subject: [PATCH v3 2/3] MdePkg: Support FDT library.
> > >> >>
> > >> >> From: Benny Lin 
> > >> >>
> > >> >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392
> > >> >> Add FDT support in EDK2 by submodule 3rd party libfdt
> > >> >> (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt)
> > >> >> and refer to LibcLib implementation by Pedro.
> > >> >>
> > >> >> Cc: Michael D Kinney 
> > >> >> Cc: Liming Gao 
> > >> >> Cc: Zhiguang Liu 
> > >> >> Acked-by: Pedro Falcato 
> > >> >> Signed-off-by: Benny Lin 
> > >> >> ---
> > >> >>  MdePkg/Include/Library/FdtLib.h   | 314 
> > >> >>  MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 
> > >> >> MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
> > >> >>  MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++
> > >> >>  MdePkg/Library/BaseFdtLib/LibFdtSupport.h |  99 ++
> > >> >> MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++
> > >> >>  MdePkg/Library/BaseFdtLib/limits.h|  10 +
> > >> >>  MdePkg/Library/BaseFdtLib/stdbool.h   |  10 +
> > >> >>  MdePkg/Library/BaseFdtLib/stddef.h|  10 +
> > >> >>  MdePkg/Library/BaseFdtLib/stdint.h|  10 +
> > >> >>  MdePkg/Library/BaseFdtLib/stdlib.h|  10 +
> > >> >>  MdePkg/Library/BaseFdtLib/string.h|  10 +
> > >> >>  MdePkg/MdePkg.ci.yaml |  17 +-
> > >> >>  MdePkg/MdePkg.dec |   4 +
> > >> >>  MdePkg/MdePkg.dsc |   1 +
> > >> >>  15 files changed, 1043 insertions(+), 2 deletions(-)
> > >> >>
> > >> >> diff --git a/MdePkg/Include/Library/FdtLib.h
> > >> >> b/MdePkg/Include/Library/FdtLib.h new file mode 100644 index
> > >> >> 00..d59b749c25
> > >> >> --- /dev/null
> > >> >> +++ b/MdePkg/Include/Library/FdtLib.h
> > >> >> @@ -0,0 +1,314 @@
> > >> >> +/** @file
> > >> >>
> > >> >> +  Flattened Device Tree Library.
> > >> >>
> > >> >> +
> > >> >>
> > >> >> +  Copyright (c) 2023, Intel Corporation. All rights reserved.
> > >> >>
> > >> >> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > >> >>
> > >> >> +
> > >> >>
> > >> >> +**/
> > >> >>
> > >> >> +
> > >> >>
> > >> >> +#ifndef FDT_LIB_H_
> > >> >>
> > >> >> +#define FDT_LIB_H_
> > >> >>
> > >> >> +
> > 

Re: [edk2-devel] [Patch V3 0/8] Create page table by CpuPageTableLib in DxeIpl

2023-04-24 Thread Ard Biesheuvel
On Mon, 24 Apr 2023 at 12:06, duntan  wrote:
>
> In V3 patch set:
> 1. Add a new patch 'MdePkg: Move CpuPageTableLib defination to MdePkg' to 
> Move CpuPageTableLib defination from UefiCpuPkg to MdePkg.
>So that MdeModulePkg doesn't need to depend on UefiCpuPkg.

As I replied to the other patch, I think adding CpuPageTableLib to
MdePkg in its current form (even only the interface) is not the right
approach here. The function protoypes and enums exposed by this
library are highly specific to a particular implementation.

There is a clear use case here, which is the DXE IPL code, and as has
been suggested in the other thread, it would be more appropriate to
define an abstraction regarding this use case, and define it as a
library class (with a NULL implementation) in MdeModulePkg. That way,
UefiCpuPkg can provide the x86 implementation based on
CpuPageTableLilb, and other architectures can do likewise.

Please refer to the patch below, which illustrates why there are other
requirements in this area:

https://edk2.groups.io/g/devel/message/101122

-- 
Ard.




> 2. Modify the patch 'MdeModulePkg/DxeIpl: Create page table by 
> CpuPageTableLib' to set GHCB page to be mapped as unencrypted for each CPU 
> for AMD SEV feature.
>
> Dun Tan (8):
>   MdePkg: Move CpuPageTableLib defination to MdePkg
>   EmulatorPkg: Add CpuPageTableLib required by DxeIpl in DSC
>   IntelFsp2Pkg: Add CpuPageTableLib required by DxeIpl in DSC
>   MdeModulePkg: Add CpuPageTableLib required by DxeIpl in DSC
>   OvmfPkg: Add CpuPageTableLib required by DxeIpl in DSC file
>   MdeModulePkg/DxeIpl: Create page table by CpuPageTableLib
>   MdeModulePkg/DxeIpl: Remove duplicated code to enable NX
>   MdeModulePkg/DxeIpl: Refinement to the code to set PageTable as RO
>
>  EmulatorPkg/EmulatorPkg.dsc  |   3 ++-
>  IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc  |   3 ++-
>  MdeModulePkg/Core/DxeIplPeim/DxeIpl.h|   3 ++-
>  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf  |   5 -
>  MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c  | 112 
> 
>  MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c   |   5 +++--
>  MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 720 
> 
>  MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h | 182 
> ++
>  MdeModulePkg/MdeModulePkg.dsc|   3 ++-
>  {UefiCpuPkg => MdePkg}/Include/Library/CpuPageTableLib.h |   0
>  MdePkg/MdePkg.dec|   5 -
>  OvmfPkg/AmdSev/AmdSevX64.dsc |   2 +-
>  OvmfPkg/Bhyve/BhyveX64.dsc   |   3 ++-
>  OvmfPkg/CloudHv/CloudHvX64.dsc   |   2 +-
>  OvmfPkg/Microvm/MicrovmX64.dsc   |   2 +-
>  OvmfPkg/OvmfPkgIa32.dsc  |   3 ++-
>  OvmfPkg/OvmfPkgIa32X64.dsc   |   2 +-
>  OvmfPkg/OvmfPkgX64.dsc   |   2 +-
>  OvmfPkg/OvmfXen.dsc  |   2 +-
>  UefiCpuPkg/UefiCpuPkg.dec|   3 ---
>  20 files changed, 211 insertions(+), 851 deletions(-)
>  rename {UefiCpuPkg => MdePkg}/Include/Library/CpuPageTableLib.h (100%)
>
> --
> 2.31.1.windows.1
>
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103489): https://edk2.groups.io/g/devel/message/103489
Mute This Topic: https://groups.io/mt/98466782/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [Patch V2 5/8] MdeModulePkg: Add UefiCpuPkg.dec to pass DependencyCheck

2023-04-24 Thread Ard Biesheuvel
On Sun, 16 Apr 2023 at 07:21, Ni, Ray  wrote:
>
> Mike,
>
> MdeModule belongs to the common-package category.
>
> I agree that the common-package should not depend on a specific arch.
>
> MdeModule depending on UefiCpu because DxeIpl needs to prepare an arch 
> specific environment for DXE phase.
>
>
>
> So, I am thinking if the arch-specific-env-preparation can be abstracted 
> through an arch-agnostic API.
>
> Then each arch can implement a concrete instance for that API. The API itself 
> can be in MdeModule pkg.
>
>
>
> In fact, the API is almost already there: “HandOffToDxeCore”.
>
>
>
> So, we could:
>
> Create a new API HandOffToDxeCore() in a new TBD lib class
> Implement different instances for different arch.
> Default instance does nothing arch specific and can be used by EmulatorPkg 
> platform
>
> Today EmulatorPkg uses X64 version of HandOffToDxeCore and skips page table 
> building by setting PcdDxeIplBuildPageTables to FALSE.
>
> UefiCpuPkg implements the HandOffToDxe() for IA32 and X64.
>
>
>
> So, the dependency is reversed: only UefiCpu depends on MdeModule.
>
>
>
> This also removes the arch-specific contents from MdeModulePkg.
>
>
>
> One side effect is: every platform needs to include the new TBD lib class.
>
>
>
> I agree that moving to MdePkg also works. But we might end up with a bigger 
> and bigger MdePkg by including more and more.
>
>
>

I would prefer this approach. CpuPageTableLib is very x86-specific and
does not comply with the requirements for MdePkg.

Loading DXE core and mapping it with restricted permissions (to avoid
W+X memory) will require some kind of abstraction here in any case, so
it would be better to let the x86 specific version of that live in
UefiCpuPkg, and keep this out of MdePkg entirely.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103488): https://edk2.groups.io/g/devel/message/103488
Mute This Topic: https://groups.io/mt/97969862/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] Question regarding changing video adapter selection during pre-boot (PEI/DXE)

2023-04-24 Thread pharcellus
Greetings, all.

I have kind of a general UEFI dev question. I have multiple video adapters in a 
system in which the BIOS doesn't provide even a hidden means of selecting a 
particular adapter to use as the default boot adapter. It seems like the 
heuristic is similar to what vgaarb does in the Linux kernel, where it takes 
the adapter with the highest available PCI device ID and that one becomes the 
active boot adapter.

I've read a bit of the UEFI spec about the GOP protocol, but what I wanted to 
know was where I could look for the code that makes the determination for the 
heuristic. Does it reside in a DXE driver module, or is it in a different 
location? If so, could you tell me which one or where might I look to find it?

Also, is there a way without patching a UEFI BIOS to change that heuristic if 
the BIOS itself doesn't provide a setup option? Like, could I add a DXE driver 
to change it, or some other driver in the boot EFI partition? (I would tend to 
think it would be too late at that point, but figured I would ask).

Thank you in advance for any advice,
Talarus Luan


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103487): https://edk2.groups.io/g/devel/message/103487
Mute This Topic: https://groups.io/mt/98473321/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v4 3/3] .pytool: Support FDT library.

2023-04-24 Thread Benny Lin
From: Benny Lin 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392
Add FDT support in EDK2 by submodule 3rd party libfdt
(https://github.com/devicetree-org/pylibfdt/tree/main/libfdt)

Add RequiredSubmodule object for CI setting.

Reviewed-by: Michael D Kinney 
Cc: Sean Brogan 
Cc: Michael Kubacki 
Cc: Michael D Kinney 
Cc: Liming Gao 
Signed-off-by: Benny Lin 
---
 .pytool/CISettings.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py
index e3f44add58..2fb99f2a17 100644
--- a/.pytool/CISettings.py
+++ b/.pytool/CISettings.py
@@ -195,6 +195,8 @@ class Settings(CiBuildSettingsManager, 
UpdateSettingsManager, SetupSettingsManag
 "RedfishPkg/Library/JsonLib/jansson", False))
 rs.append(RequiredSubmodule(
 "UnitTestFrameworkPkg/Library/SubhookLib/subhook", False))
+rs.append(RequiredSubmodule(
+"MdePkg/Library/BaseFdtLib/libfdt", False))
 return rs
 
 def GetName(self):
-- 
2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103486): https://edk2.groups.io/g/devel/message/103486
Mute This Topic: https://groups.io/mt/98471369/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v4 2/3] MdePkg: Support FDT library.

2023-04-24 Thread Benny Lin
From: Benny Lin 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392
Add FDT support in EDK2 by submodule 3rd party libfdt
(https://github.com/devicetree-org/pylibfdt/tree/main/libfdt)
and refer to LibcLib implementation by Pedro.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Acked-by: Pedro Falcato 
Signed-off-by: Benny Lin 
---
 MdePkg/Include/Library/FdtLib.h   | 305 
 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 
 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
 MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++
 MdePkg/Library/BaseFdtLib/LibFdtSupport.h |  99 +++
 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++
 MdePkg/Library/BaseFdtLib/limits.h|  10 +
 MdePkg/Library/BaseFdtLib/stdbool.h   |  10 +
 MdePkg/Library/BaseFdtLib/stddef.h|  10 +
 MdePkg/Library/BaseFdtLib/stdint.h|  10 +
 MdePkg/Library/BaseFdtLib/stdlib.h|  10 +
 MdePkg/Library/BaseFdtLib/string.h|  10 +
 MdePkg/MdePkg.ci.yaml |  15 +-
 MdePkg/MdePkg.dec |   4 +
 MdePkg/MdePkg.dsc |   1 +
 15 files changed, 1033 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h
new file mode 100644
index 00..8c540b2b1d
--- /dev/null
+++ b/MdePkg/Include/Library/FdtLib.h
@@ -0,0 +1,305 @@
+/** @file
+  Flattened Device Tree Library.
+
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FDT_LIB_H_
+#define FDT_LIB_H_
+
+/**
+  Flattened Device Tree definition
+
+  The Devicetree Blob (DTB) format is a binary encoding with big-endian.
+  When producing or consuming the blob data, must translate with SwapBytesXX
+  provided by edk2 BaseLib between big-endian and little-endian.
+**/
+typedef struct {
+  UINT32Magic;   /* magic word FDT_MAGIC */
+  UINT32TotalSize;   /* total size of DT block */
+  UINT32OffsetDtStruct;  /* offset to structure */
+  UINT32OffsetDtStrings; /* offset to strings */
+  UINT32OffsetMemRsvmap; /* offset to memory reserve map */
+  UINT32Version; /* format version */
+  UINT32LastCompVersion; /* last compatible version */
+
+  /* version 2 fields below */
+  UINT32BootCpuidPhys;   /* Which physical CPU id we're
+booting on */
+  /* version 3 fields below */
+  UINT32SizeDtStrings;   /* size of the strings block */
+
+  /* version 17 fields below */
+  UINT32SizeDtStruct;/* size of the structure block */
+} FDT_HEADER;
+
+typedef struct {
+  UINT64Address;
+  UINT64Size;
+} FDT_RESERVE_ENTRY;
+
+typedef struct {
+  UINT32Tag;
+  CHAR8 Name[];
+} FDT_NODE_HEADER;
+
+typedef struct {
+  UINT32Tag;
+  UINT32Length;
+  UINT32NameOffset;
+  CHAR8 Data[];
+} FDT_PROPERTY;
+
+/**
+  Verify the header of the Flattened Device Tree
+
+  @param[in] FdtThe pointer to FDT blob.
+
+  @return Zero for successfully, otherwise failed.
+
+**/
+INT32
+EFIAPI
+FdtCheckHeader (
+  IN CONST VOID  *Fdt
+  );
+
+/**
+  Create a empty Flattened Device Tree.
+
+  @param[in] Buffer The pointer to allocate a pool for FDT blob.
+  @param[in] BufferSize The BufferSize to the pool size.
+
+  @return Zero for successfully, otherwise failed.
+
+**/
+RETURN_STATUS
+EFIAPI
+FdtCreateEmptyTree (
+  IN VOID   *Buffer,
+  IN UINTN  BufferSize
+  );
+
+/**
+  Returns a offset of next node from the given node.
+
+  @param[in] FdtThe pointer to FDT blob.
+  @param[in] Offset The offset to previous node.
+  @param[in] Depth  The depth to the level of tree hierarchy.
+
+  @return The offset to next node offset.
+
+**/
+INT32
+EFIAPI
+FdtNextNode (
+  IN CONST VOID  *Fdt,
+  IN INT32   Offset,
+  IN INT32   *Depth
+  );
+
+/**
+  Returns a offset of first node under the given node.
+
+  @param[in] FdtThe pointer to FDT blob.
+  @param[in] Offset The offset to previous node.
+
+  @return The offset to next node offset.
+
+**/
+INT32
+EFIAPI
+FdtFirstSubnode (
+  IN CONST VOID  *Fdt,
+  IN INT32   Offset
+  );
+
+/**
+  Returns a offset of next node from the given node.
+
+  @param[in] FdtThe pointer to FDT blob.
+  @param[in] Offset The offset to previous node.
+
+  @return The offset to next node offset.
+
+**/
+INT32
+EFIAPI
+FdtNextSubnode (
+  IN CONST VOID  *Fdt,
+  IN INT32   Offset
+  );
+
+/**
+  Returns a offset of first node which includes the given name.
+
+  @param[in] Fdt The pointer to FDT blob.
+  @param[in] ParentOffsetThe offset to the node which start find under.
+  @param[in] NameThe name to search the node with the name.
+  @param[in] NameLength  The length of the name to check only.
+
+  @return The offset to node 

[edk2-devel] [PATCH v4 1/3] Tianocore: Support FDT library.

2023-04-24 Thread Benny Lin
From: Benny Lin 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392
Add FDT support in EDK2 by submodule 3rd party libfdt
(https://github.com/devicetree-org/pylibfdt/tree/main/libfdt)

Add submodule libfdt and update ReadMe for the licence.

Reviewed-by: Leif Lindholm 
Reviewed-by: Michael D Kinney 
Cc: Andrew Fish 
Cc: Leif Lindholm 
Cc: Michael D Kinney 
Signed-off-by: Benny Lin 
---
 .gitmodules  | 3 +++
 MdePkg/Library/BaseFdtLib/libfdt | 1 +
 ReadMe.rst   | 1 +
 3 files changed, 5 insertions(+)

diff --git a/.gitmodules b/.gitmodules
index fe8a43be93..b1888c3488 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -26,3 +26,6 @@
 [submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"]
path = UnitTestFrameworkPkg/Library/SubhookLib/subhook
url = https://github.com/Zeex/subhook.git
+[submodule "MdePkg/Library/BaseFdtLib/libfdt"]
+   path = MdePkg/Library/BaseFdtLib/libfdt
+   url = https://github.com/devicetree-org/pylibfdt.git
diff --git a/MdePkg/Library/BaseFdtLib/libfdt b/MdePkg/Library/BaseFdtLib/libfdt
new file mode 16
index 00..cfff805481
--- /dev/null
+++ b/MdePkg/Library/BaseFdtLib/libfdt
@@ -0,0 +1 @@
+Subproject commit cfff805481bdea27f900c32698171286542b8d3c
diff --git a/ReadMe.rst b/ReadMe.rst
index 91b9cf3c5e..d46c534229 100644
--- a/ReadMe.rst
+++ b/ReadMe.rst
@@ -96,6 +96,7 @@ that are covered by additional licenses.
 -  `UnitTestFrameworkPkg/Library/GoogleTestLib/googletest 
`__
 -  `UnitTestFrameworkPkg/Library/SubhookLib/subhook 
`__
 -  `RedfishPkg/Library/JsonLib/jansson 
`__
+-  `MdePkg/Library/BaseFdtLib/libfdt 
`__
 
 The EDK II Project is composed of packages. The maintainers for each package
 are listed in `Maintainers.txt `__.
-- 
2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103484): https://edk2.groups.io/g/devel/message/103484
Mute This Topic: https://groups.io/mt/98471367/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v4 0/3] Support FDT library.

2023-04-24 Thread Benny Lin
From: Benny Lin 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392
Add FDT support in EDK2 by submodule 3rd party libfdt
(https://github.com/devicetree-org/pylibfdt/tree/main/libfdt)
and refer to LibcLib implementation by Pedro.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Sean Brogan 
Cc: Michael Kubacki 
Acked-by: Pedro Falcato 
Signed-off-by: Benny Lin 

Benny Lin (3):
  Tianocore: Support FDT library.
  MdePkg: Support FDT library.
  .pytool: Support FDT library.

 .gitmodules   |   3 +
 .pytool/CISettings.py |   2 +
 MdePkg/Include/Library/FdtLib.h   | 305 
 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 
 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
 MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++
 MdePkg/Library/BaseFdtLib/LibFdtSupport.h |  99 +++
 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++
 MdePkg/Library/BaseFdtLib/libfdt  |   1 +
 MdePkg/Library/BaseFdtLib/limits.h|  10 +
 MdePkg/Library/BaseFdtLib/stdbool.h   |  10 +
 MdePkg/Library/BaseFdtLib/stddef.h|  10 +
 MdePkg/Library/BaseFdtLib/stdint.h|  10 +
 MdePkg/Library/BaseFdtLib/stdlib.h|  10 +
 MdePkg/Library/BaseFdtLib/string.h|  10 +
 MdePkg/MdePkg.ci.yaml |  15 +-
 MdePkg/MdePkg.dec |   4 +
 MdePkg/MdePkg.dsc |   1 +
 ReadMe.rst|   1 +
 19 files changed, 1040 insertions(+), 1 deletion(-)
 create mode 100644 MdePkg/Include/Library/FdtLib.h
 create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf
 create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni
 create mode 100644 MdePkg/Library/BaseFdtLib/FdtLib.c
 create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtSupport.h
 create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c
 create mode 16 MdePkg/Library/BaseFdtLib/libfdt
 create mode 100644 MdePkg/Library/BaseFdtLib/limits.h
 create mode 100644 MdePkg/Library/BaseFdtLib/stdbool.h
 create mode 100644 MdePkg/Library/BaseFdtLib/stddef.h
 create mode 100644 MdePkg/Library/BaseFdtLib/stdint.h
 create mode 100644 MdePkg/Library/BaseFdtLib/stdlib.h
 create mode 100644 MdePkg/Library/BaseFdtLib/string.h

-- 
2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103483): https://edk2.groups.io/g/devel/message/103483
Mute This Topic: https://groups.io/mt/98471366/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] BaseTools: Add quotes around OBJCOPY cmd in build_rule.template

2023-04-24 Thread Rebecca Cran
Add quotes around the OBJCOPY command in build_rule.template to fix the
case where LLVM is installed on Windows in a path with spaces such as
C:\Program Files\LLVM.

Signed-off-by: Rebecca Cran 
---
 BaseTools/Conf/build_rule.template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index d42e7937cc90..eb64c62060e1 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -352,12 +352,12 @@
 -$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR) 
 
 $(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).debug
-$(OBJCOPY) $(OBJCOPY_STRIPFLAG) ${src}
+"$(OBJCOPY)" $(OBJCOPY_STRIPFLAG) ${src}
 
 #
 #The below 2 lines are only needed for UNIXGCC tool chain, which 
generates PE image directly
 #
--$(OBJCOPY) $(OBJCOPY_ADDDEBUGFLAG) ${src}
+-"$(OBJCOPY)" $(OBJCOPY_ADDDEBUGFLAG) ${src}
 -$(CP) $(DEBUG_DIR)(+)$(MODULE_NAME).debug 
$(BIN_DIR)(+)$(MODULE_NAME_GUID).debug
 
 "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
-- 
2.40.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103482): https://edk2.groups.io/g/devel/message/103482
Mute This Topic: https://groups.io/mt/98470825/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 1/1] BaseTools: Add quotes around OBJCOPY cmd in build_rule.template

2023-04-24 Thread Rebecca Cran
Add quotes around the OBJCOPY command in build_rule.template to fix the
case where LLVM is installed on Windows in a path with spaces such as
C:\Program Files\LLVM.

Signed-off-by: Rebecca Cran 
---
 BaseTools/Conf/build_rule.template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index d42e7937cc90..117f16d5ef49 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -352,7 +352,7 @@
 -$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR) 
 
 $(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).debug
-$(OBJCOPY) $(OBJCOPY_STRIPFLAG) ${src}
+"$(OBJCOPY)" $(OBJCOPY_STRIPFLAG) ${src}
 
 #
 #The below 2 lines are only needed for UNIXGCC tool chain, which 
generates PE image directly
-- 
2.40.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103481): https://edk2.groups.io/g/devel/message/103481
Mute This Topic: https://groups.io/mt/98470422/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v5 01/13] BaseTools,CryptoPkg: Update CLANGDWARF, remove CLANG 35/38 toolchains

2023-04-24 Thread Rebecca Cran

Thanks, I've been able to reproduce the failure.

Since it's a simple fix and is independent of my other changes, I'd 
prefer to avoid making this patch series larger and instead fix this first.


I'll send out a patch in a few minutes.


--

Rebecca Cran


On 4/24/23 05:28, Feng, Bob C wrote:

Hi Rebecca,

With this patch, the UniversalPayload will be built fail on windows.
It can be reproduced with this command on windows.

edksetup
python UefiPayloadPkg\UniversalPayloadBuild.py -t VS2019

But the root cause is a bug in build_rule.template.
Under the   section, 2 $(OBJCOPY) should be wrapped by "".  Could 
you please also update build_rule.template in this patch?

---

[Dynamic-Library-File]
 
 ?.dll

 
 $(OUTPUT_DIR)(+)$(MODULE_NAME).efi
 $(OUTPUT_DIR)(+)$(MODULE_NAME).map

 
 "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
 $(CP) ${dst} $(DEBUG_DIR)
 $(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
 -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
 -$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR)
 
 $(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).debug
 $(OBJCOPY) $(OBJCOPY_STRIPFLAG) ${src}

 #
 #The below 2 lines are only needed for UNIXGCC tool chain, which 
generates PE image directly
 #
 -$(OBJCOPY) $(OBJCOPY_ADDDEBUGFLAG) ${src}
 -$(CP) $(DEBUG_DIR)(+)$(MODULE_NAME).debug 
$(BIN_DIR)(+)$(MODULE_NAME_GUID).debug

 "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
 $(CP) ${dst} $(DEBUG_DIR)
 $(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
 -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)


Thanks,
Bob

-Original Message-
From: Rebecca Cran 
Sent: Saturday, April 22, 2023 1:15 AM
To: devel@edk2.groups.io; Gao, Liming ; Feng, Bob C ; Chen, Christine 
; Kinney, Michael D ; Michael Kubacki ; 
Sean Brogan ; Chiu, Chasel ; Desimone, Nathaniel L 
; Zeng, Star ; Andrew Fish 
Cc: Rebecca Cran ; Ni, Ray ; Leif Lindholm ; Liu, Zhiguang 
; Wang, Jian J ; Lu, Xiaoyu1 ; Jiang, Guomin 
; Guo, Gua ; Ard Biesheuvel ; Pedro Falcato 
; Gerd Hoffmann ; Marvin Häuser 
Subject: [PATCH v5 01/13] BaseTools,CryptoPkg: Update CLANGDWARF, remove CLANG 
35/38 toolchains

Update the CLANGDWARF toolchain definition in tools_def.template with the
settings from CLANG38, and delete the CLANG35 and CLANG38 toolchains.

The CLANG35 and CLANG38 toolchains were added for compatibility with
ARM's proprietary clang-based toolchain. Things have since moved on, and
with the latest clang version being 16.0.0, versions 3.5 and 3.9 are
obsolete and can be removed.

Update CryptoPkg: Add CLANGDWARF and remove CLANG35 and CLANG38 compiler flags

With the removal of CLANG35 and CLANG38 and the update of the CLANGDWARF
toolchain definition in Conf/tools_def.txt update the compiler flags in
BaseCryptLib and OpensslLib.

Signed-off-by: Rebecca Cran 
Reviewed-by: Liming Gao 
---
  CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf |   3 +--
  CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf  |   3 +--
  CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf  |   3 +--
  CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf  |   3 +--
  CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf  |   3 +--
  CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf |   3 +--
  CryptoPkg/Library/OpensslLib/OpensslLib.inf |   3 +--
  CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf|   3 +--
  CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf   |   3 +--
  CryptoPkg/Library/OpensslLib/OpensslLibFull.inf |   3 +--
  CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf|   3 +--
  BaseTools/Conf/tools_def.template   | 471 
+--
  12 files changed, 200 insertions(+), 304 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
index 5be1724f0852..d99337a9ea39 100644
--- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
@@ -110,8 +110,7 @@ [BuildOptions]
#
# suppress the following warnings so we do not break the build with 
warnings-as-errors:
#
-  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
-  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99
GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
  

[edk2-devel] Bugzilla missing releases after edk2-stable202105

2023-04-24 Thread Rebecca Cran

The newest release listed in Bugzilla is edk2-stable202105.

Could someone add the newer releases please?


Thanks.
Rebecca Cran



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103479): https://edk2.groups.io/g/devel/message/103479
Mute This Topic: https://groups.io/mt/98469627/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v5 01/13] BaseTools,CryptoPkg: Update CLANGDWARF, remove CLANG 35/38 toolchains

2023-04-24 Thread Bob Feng
Hi Rebecca,

With this patch, the UniversalPayload will be built fail on windows.
It can be reproduced with this command on windows.

edksetup
python UefiPayloadPkg\UniversalPayloadBuild.py -t VS2019

But the root cause is a bug in build_rule.template.  
Under the   section, 2 $(OBJCOPY) should be wrapped by "".  Could 
you please also update build_rule.template in this patch?

---

[Dynamic-Library-File]

?.dll


$(OUTPUT_DIR)(+)$(MODULE_NAME).efi
$(OUTPUT_DIR)(+)$(MODULE_NAME).map


"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
$(CP) ${dst} $(DEBUG_DIR)
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
-$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR) 

$(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).debug
$(OBJCOPY) $(OBJCOPY_STRIPFLAG) ${src}

#
#The below 2 lines are only needed for UNIXGCC tool chain, which 
generates PE image directly
#
-$(OBJCOPY) $(OBJCOPY_ADDDEBUGFLAG) ${src}
-$(CP) $(DEBUG_DIR)(+)$(MODULE_NAME).debug 
$(BIN_DIR)(+)$(MODULE_NAME_GUID).debug

"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
$(CP) ${dst} $(DEBUG_DIR)
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)


Thanks,
Bob

-Original Message-
From: Rebecca Cran  
Sent: Saturday, April 22, 2023 1:15 AM
To: devel@edk2.groups.io; Gao, Liming ; Feng, Bob C 
; Chen, Christine ; Kinney, Michael 
D ; Michael Kubacki ; 
Sean Brogan ; Chiu, Chasel ; 
Desimone, Nathaniel L ; Zeng, Star 
; Andrew Fish 
Cc: Rebecca Cran ; Ni, Ray ; Leif Lindholm 
; Liu, Zhiguang ; Wang, Jian 
J ; Lu, Xiaoyu1 ; Jiang, Guomin 
; Guo, Gua ; Ard Biesheuvel 
; Pedro Falcato ; Gerd Hoffmann 
; Marvin Häuser 
Subject: [PATCH v5 01/13] BaseTools,CryptoPkg: Update CLANGDWARF, remove CLANG 
35/38 toolchains

Update the CLANGDWARF toolchain definition in tools_def.template with the
settings from CLANG38, and delete the CLANG35 and CLANG38 toolchains.

The CLANG35 and CLANG38 toolchains were added for compatibility with
ARM's proprietary clang-based toolchain. Things have since moved on, and
with the latest clang version being 16.0.0, versions 3.5 and 3.9 are
obsolete and can be removed.

Update CryptoPkg: Add CLANGDWARF and remove CLANG35 and CLANG38 compiler flags

With the removal of CLANG35 and CLANG38 and the update of the CLANGDWARF
toolchain definition in Conf/tools_def.txt update the compiler flags in
BaseCryptLib and OpensslLib.

Signed-off-by: Rebecca Cran 
Reviewed-by: Liming Gao 
---
 CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf |   3 +--
 CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf  |   3 +--
 CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf  |   3 +--
 CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf  |   3 +--
 CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf  |   3 +--
 CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf |   3 +--
 CryptoPkg/Library/OpensslLib/OpensslLib.inf |   3 +--
 CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf|   3 +--
 CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf   |   3 +--
 CryptoPkg/Library/OpensslLib/OpensslLibFull.inf |   3 +--
 CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf|   3 +--
 BaseTools/Conf/tools_def.template   | 471 
+--
 12 files changed, 200 insertions(+), 304 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
index 5be1724f0852..d99337a9ea39 100644
--- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
@@ -110,8 +110,7 @@ [BuildOptions]
   #
   # suppress the following warnings so we do not break the build with 
warnings-as-errors:
   #
-  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
-  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99
   GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
 
   XCODE:*_*_*_CC_FLAGS = -std=c99
diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
index 66261138a00b..5203941c75c1 100644
--- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
@@ -97,8 +97,7 @@ [BuildOptions]
   #
   # suppress the 

Re: [edk2-devel] [Patch V2 5/8] MdeModulePkg: Add UefiCpuPkg.dec to pass DependencyCheck

2023-04-24 Thread duntan
Hi Mike,

Thanks for the comments. This patch has been dropped in the latest V4 patch 
set. I have added a new patch ‘[Patch V4 1/8] MdePkg: Move CpuPageTableLib 
definition to MdePkg’ to move CpuPageTableLib definition from UefiCpuPkg to 
MdePkg. Could you please help review?

Thanks,
Dun

From: Kinney, Michael D 
Sent: Friday, April 21, 2023 11:43 PM
To: Ni, Ray ; devel@edk2.groups.io; Wang, Jian J 
; Tan, Dun 
Cc: Gao, Liming ; Ard Biesheuvel ; 
Kinney, Michael D 
Subject: RE: [edk2-devel] [Patch V2 5/8] MdeModulePkg: Add UefiCpuPkg.dec to 
pass DependencyCheck

Not required.

Is there any use case of a null instances that would actually be needed (e.g. 
EmulatorPkg)?
If there is a real use case, then a null instance in the MdePkg would be useful.

Mike

From: Ni, Ray mailto:ray...@intel.com>>
Sent: Friday, April 21, 2023 1:10 AM
To: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 
devel@edk2.groups.io; Wang, Jian J 
mailto:jian.j.w...@intel.com>>; Tan, Dun 
mailto:dun@intel.com>>
Cc: Gao, Liming mailto:gaolim...@byosoft.com.cn>>; 
Ard Biesheuvel mailto:a...@kernel.org>>
Subject: RE: [edk2-devel] [Patch V2 5/8] MdeModulePkg: Add UefiCpuPkg.dec to 
pass DependencyCheck

Mike, shall MdePkg contain the NULL instance?

From: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Sent: Wednesday, April 19, 2023 11:03 PM
To: Ni, Ray mailto:ray...@intel.com>>; 
devel@edk2.groups.io; Wang, Jian J 
mailto:jian.j.w...@intel.com>>; Tan, Dun 
mailto:dun@intel.com>>
Cc: Gao, Liming mailto:gaolim...@byosoft.com.cn>>; 
Ard Biesheuvel mailto:a...@kernel.org>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Subject: RE: [edk2-devel] [Patch V2 5/8] MdeModulePkg: Add UefiCpuPkg.dec to 
pass DependencyCheck

Ray,

I am suggesting that only the lib class be defined in MdePkg.  Lib instance can 
remain in UefiCpuPkg.

Mike

From: Ni, Ray mailto:ray...@intel.com>>
Sent: Tuesday, April 18, 2023 11:01 PM
To: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 
devel@edk2.groups.io; Wang, Jian J 
mailto:jian.j.w...@intel.com>>; Tan, Dun 
mailto:dun@intel.com>>
Cc: Gao, Liming mailto:gaolim...@byosoft.com.cn>>; 
Ard Biesheuvel mailto:a...@kernel.org>>
Subject: RE: [edk2-devel] [Patch V2 5/8] MdeModulePkg: Add UefiCpuPkg.dec to 
pass DependencyCheck

Mike,
Moving the PageTableLib to MdePkg today also requires all downstream DSC files 
to be updated to use the instance in MdePkg.
Because MpInitLib today depends on PageTableLib already due to the change to 
put AP in 64bit before handling to OS.

But you remind me to search for other modules manipulating PageTableLib in 
MdeModulePkg, or any other packages that should not depend on UefiCpuPkg.
I found:

  1.  MdeModulePkg/Universal/CapsulePei
  2.  OvmfPkg/…: I don’t care which module because OvmfPkg can depend on 
UefiCpuPkg.
  3.  UefiPayloadPkg/…: I don’t care which module because UefiPayloadPkg can 
depend on UefiCpuPkg.

Because CapsulePei doesn’t need to use PageTableLib in 64bit PEI mode, I am 
fine with leaving CapsulePei duplicating the page table manipulating code.


+ Ard to see some feedback from ARM side.

Thanks,
Ray


From: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Sent: Wednesday, April 19, 2023 3:07 AM
To: Ni, Ray mailto:ray...@intel.com>>; 
devel@edk2.groups.io; Wang, Jian J 
mailto:jian.j.w...@intel.com>>; Tan, Dun 
mailto:dun@intel.com>>
Cc: Gao, Liming mailto:gaolim...@byosoft.com.cn>>; 
Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Subject: RE: [edk2-devel] [Patch V2 5/8] MdeModulePkg: Add UefiCpuPkg.dec to 
pass DependencyCheck

Hi Ray,

There are other discussions to add more arch specific content to MdeModulePkg

https://edk2.groups.io/g/devel/message/101104

The tradeoff here is moving a lib class from UefiCpuPkg to MdePkg vs defining a 
new lib class/instance and requiring all downstream DSC files to be updated for 
the new lib instance.

Moving the lib class is simpler and has less impact and we have done this a few 
times before (e.g. CpuLib)

I agree we need to be careful about ho much content we move into MdePkg.  
However, for this specific topic, if we want to maximize the use of the Page 
Table Library and remove redundant code that manages page tables, moving to 
MdePkg may be the best option.

Mike


From: Ni, Ray mailto:ray...@intel.com>>
Sent: Saturday, April 15, 2023 10:21 PM
To: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 
devel@edk2.groups.io; Wang, Jian J 
mailto:jian.j.w...@intel.com>>; Tan, Dun 
mailto:dun@intel.com>>
Cc: Gao, Liming mailto:gaolim...@byosoft.com.cn>>
Subject: RE: [edk2-devel] [Patch V2 5/8] MdeModulePkg: Add UefiCpuPkg.dec to 
pass DependencyCheck

Mike,
MdeModule belongs to the common-package category.
I agree that the common-package should not depend on a specific arch.
MdeModule depending on UefiCpu 

[edk2-devel] [Patch V4 6/8] MdeModulePkg/DxeIpl: Create page table by CpuPageTableLib

2023-04-24 Thread duntan
Modify CreateIdentityMappingPageTables() to create page table
based on CpuPageTableLib in DxeIpl module. This function can
be used to create both IA32 PAE paging and long mode 4-level,
5-level paging structure. With the PageTableMap() API in the
CpuPageTableLib, we can remove the complicated page table
manipulating code. This commit doesn't change any functionality.

Signed-off-by: Dun Tan 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Tom Lendacky 
---
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.h|   3 ++-
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf  |   5 -
 MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c  | 109 
-
 MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c   |   5 +++--
 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 567 
++-
 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h | 167 
++-
 6 files changed, 177 insertions(+), 679 deletions(-)

diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h 
b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
index 2f015befce..03e6f8cff7 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
@@ -2,7 +2,7 @@
   Master header file for DxeIpl PEIM. All source files in this module should
   include this file for common definitions.
 
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -42,6 +42,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #define STACK_SIZE  0x2
 #define BSP_STORE_SIZE  0x4000
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf 
b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index 052ea0ec1a..f636f042cb 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -5,7 +5,7 @@
 #  PPI to discover and dispatch the DXE Foundation and components that are
 #  needed to run the DXE Foundation.
 #
-#  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
 #  Copyright (c) 2017, AMD Incorporated. All rights reserved.
 #  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights 
reserved.
 #  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights 
reserved.
@@ -80,6 +80,9 @@
   PeiServicesTablePointerLib
   PerformanceLib
 
+[LibraryClasses.IA32, LibraryClasses.X64]
+  CpuPageTableLib
+
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
   ArmMmuLib
 
diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c 
b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
index 4bc7b749b0..69d073fb58 100644
--- a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
+++ b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
@@ -1,7 +1,7 @@
 /** @file
   Ia32-specific functionality for DxeLoad.
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
 Copyright (c) 2017, AMD Incorporated. All rights reserved.
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -70,107 +70,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED  IA32_DESCRIPTOR  
gLidtDescriptor = {
   0
 };
 
-/**
-  Allocates and fills in the Page Directory and Page Table Entries to
-  establish a 4G page table.
-
-  @param[in] StackBase  Stack base address.
-  @param[in] StackSize  Stack size.
-
-  @return The address of page table.
-
-**/
-UINTN
-Create4GPageTablesIa32Pae (
-  IN EFI_PHYSICAL_ADDRESS  StackBase,
-  IN UINTN StackSize
-  )
-{
-  UINT8   PhysicalAddressBits;
-  EFI_PHYSICAL_ADDRESSPhysicalAddress;
-  UINTN   IndexOfPdpEntries;
-  UINTN   IndexOfPageDirectoryEntries;
-  UINT32  NumberOfPdpEntriesNeeded;
-  PAGE_MAP_AND_DIRECTORY_POINTER  *PageMap;
-  PAGE_MAP_AND_DIRECTORY_POINTER  *PageDirectoryPointerEntry;
-  PAGE_TABLE_ENTRY*PageDirectoryEntry;
-  UINTN   TotalPagesNum;
-  UINTN   PageAddress;
-  UINT64  

[edk2-devel] [Patch V4 1/8] MdePkg: Move CpuPageTableLib definition to MdePkg

2023-04-24 Thread duntan
Move CpuPageTableLib definition from UefiCpuPkg to MdePkg. The
lib instance still remains in UefiCpuPkg. Move CpuPageTableLib
definition to a common location can avoid the case that
MdeModulePkg need to depend on UefiCpuPkg since DxeIpl module
in MdeModulePkg needs to consume CpuPageTableLib.

Signed-off-by: Dun Tan 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Ray Ni 
---
 {UefiCpuPkg => MdePkg}/Include/Library/CpuPageTableLib.h | 0
 MdePkg/MdePkg.dec| 5 -
 UefiCpuPkg/UefiCpuPkg.dec| 3 ---
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/UefiCpuPkg/Include/Library/CpuPageTableLib.h 
b/MdePkg/Include/Library/CpuPageTableLib.h
similarity index 100%
rename from UefiCpuPkg/Include/Library/CpuPageTableLib.h
rename to MdePkg/Include/Library/CpuPageTableLib.h
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 7488ccda7a..dfbca2d746 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -4,7 +4,7 @@
 # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs) of
 # EFI1.10/UEFI2.7/PI1.7 and some Industry Standards.
 #
-# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2023, Intel Corporation. All rights reserved.
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
 # (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development LP
 # Copyright (c) 2022, Loongson Technology Corporation Limited. All rights 
reserved.
@@ -321,6 +321,9 @@
   ##  @libraryclass  Provides function to support TDX processing.
   TdxLib|Include/Library/TdxLib.h
 
+  ##  @libraryclass  Provides function for manipulating x86 paging structures.
+  CpuPageTableLib|Include/Library/CpuPageTableLib.h
+
 [LibraryClasses.RISCV64]
   ##  @libraryclass  Provides function to make ecalls to SBI
   BaseRiscVSbiLib|Include/Library/BaseRiscVSbiLib.h
diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index a5528277ff..5ad41e9ae3 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -57,9 +57,6 @@
   ##  @libraryclass  Provides function for loading microcode.
   MicrocodeLib|Include/Library/MicrocodeLib.h
 
-  ##  @libraryclass  Provides function for manipulating x86 paging structures.
-  CpuPageTableLib|Include/Library/CpuPageTableLib.h
-
 [Guids]
   gUefiCpuPkgTokenSpaceGuid  = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa, 0xb8, 
0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}
   gMsegSmramGuid = { 0x5802bce4, 0x, 0x4e33, { 0xa1, 0x30, 
0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103475): https://edk2.groups.io/g/devel/message/103475
Mute This Topic: https://groups.io/mt/98467035/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V4 0/8] Create page table by CpuPageTableLib in DxeIpl

2023-04-24 Thread duntan
In V4 patch set:
Comparing to V3, only fix the spelling from 'defination' to 'definition' in the 
commit message of 'MdePkg: Move CpuPageTableLib definition to MdePkg'. So only 
resend the two patches which need to be reviewed.

1. A new patch 'MdePkg: Move CpuPageTableLib definition to MdePkg' to move 
CpuPageTableLib definition from UefiCpuPkg to MdePkg.
2. Patch 'MdeModulePkg/DxeIpl: Create page table by CpuPageTableLib' has been 
modified to set GHCB page to be mapped as unencrypted for each CPU for AMD SEV 
feature.

Other patches in this patch set have been reviewed.

Dun Tan (8):
  MdePkg: Move CpuPageTableLib definition to MdePkg
  EmulatorPkg: Add CpuPageTableLib required by DxeIpl in DSC
  IntelFsp2Pkg: Add CpuPageTableLib required by DxeIpl in DSC
  MdeModulePkg: Add CpuPageTableLib required by DxeIpl in DSC
  OvmfPkg: Add CpuPageTableLib required by DxeIpl in DSC file
  MdeModulePkg/DxeIpl: Create page table by CpuPageTableLib
  MdeModulePkg/DxeIpl: Remove duplicated code to enable NX
  MdeModulePkg/DxeIpl: Refinement to the code to set PageTable as RO

 EmulatorPkg/EmulatorPkg.dsc  |   3 ++-
 IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc  |   3 ++-
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.h|   3 ++-
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf  |   5 -
 MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c  | 112 

 MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c   |   5 +++--
 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 720 

 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h | 182 
++
 MdeModulePkg/MdeModulePkg.dsc|   3 ++-
 {UefiCpuPkg => MdePkg}/Include/Library/CpuPageTableLib.h |   0
 MdePkg/MdePkg.dec|   5 -
 OvmfPkg/AmdSev/AmdSevX64.dsc |   2 +-
 OvmfPkg/Bhyve/BhyveX64.dsc   |   3 ++-
 OvmfPkg/CloudHv/CloudHvX64.dsc   |   2 +-
 OvmfPkg/Microvm/MicrovmX64.dsc   |   2 +-
 OvmfPkg/OvmfPkgIa32.dsc  |   3 ++-
 OvmfPkg/OvmfPkgIa32X64.dsc   |   2 +-
 OvmfPkg/OvmfPkgX64.dsc   |   2 +-
 OvmfPkg/OvmfXen.dsc  |   2 +-
 UefiCpuPkg/UefiCpuPkg.dec|   3 ---
 20 files changed, 211 insertions(+), 851 deletions(-)
 rename {UefiCpuPkg => MdePkg}/Include/Library/CpuPageTableLib.h (100%)

-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103474): https://edk2.groups.io/g/devel/message/103474
Mute This Topic: https://groups.io/mt/98467032/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [Patch V2 3/8] MdeModulePkg: Add CpuPageTableLib required by DxeIpl in DSC

2023-04-24 Thread duntan
Thanks for the comments. In the latest V3 patch set, I have moved 
CpuPageTableLib definition from UefiCpuPkg to MdePkg. So that MdeModulePkg 
won't depend on UefiCpuPkg.

Thanks,
Dun

-Original Message-
From: Wang, Jian J  
Sent: Friday, April 14, 2023 5:10 PM
To: Tan, Dun ; devel@edk2.groups.io
Cc: Gao, Liming ; Ni, Ray 
Subject: RE: [Patch V2 3/8] MdeModulePkg: Add CpuPageTableLib required by 
DxeIpl in DSC

This will cause that MdeModulePkg depends on UefiCpuPkg. Please double check if 
there's any side effect introduced by breaking unidirectional dependency.

Acked-by: Jian J Wang 

> -Original Message-
> From: Tan, Dun 
> Sent: Friday, March 31, 2023 5:34 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J ; Gao, Liming 
> ; Ni, Ray 
> Subject: [Patch V2 3/8] MdeModulePkg: Add CpuPageTableLib required by 
> DxeIpl in DSC
> 
> Add CpuPageTableLib instance required by DxeIpl in MdeModulePkg.dsc.
> 
> Signed-off-by: Dun Tan 
> Cc: Jian J Wang 
> Cc: Liming Gao 
> Cc: Ray Ni 
> ---
>  MdeModulePkg/MdeModulePkg.dsc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dsc 
> b/MdeModulePkg/MdeModulePkg.dsc index 1014598f31..d95acabe83 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -2,7 +2,7 @@
>  # EFI/PI Reference Module Package for All Architectures  #  # (C) 
> Copyright 2014 Hewlett-Packard Development Company, L.P. -# 
> Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
> +# Copyright (c) 2007 - 2023, Intel Corporation. All rights 
> +reserved.
>  # Copyright (c) Microsoft Corporation.
>  # Copyright (C) 2023 Advanced Micro Devices, Inc. All rights 
> reserved.  # @@ -106,6 +106,7 @@
> 
> MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockM
> emoryLibNull.inf
> 
> VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/Bas
> VariableFlashInfoLib|eVar
> iableFlashInfoLib.inf
> 
> IpmiCommandLib|MdeModulePkg/Library/BaseIpmiCommandLibNull/BaseIpmi
> CommandLibNull.inf
> +  
> + CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.i
> + nf
> 
>  [LibraryClasses.EBC.PEIM]
>IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
> --
> 2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103473): https://edk2.groups.io/g/devel/message/103473
Mute This Topic: https://groups.io/mt/97969854/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V3 8/8] MdeModulePkg/DxeIpl: Refinement to the code to set PageTable as RO

2023-04-24 Thread duntan
Code refinement to the code to set page table as RO in DxeIpl module.
Set all page table pools as ReadOnly by calling PageTableMap() in
CpuPageTableLib multiple times instead of searching each page table
pool address in page table layer by layer. Also, this commit solve
the issue that original SetPageTablePoolReadOnly() code in DxeIpl
doesn't handle the Level5Paging case.

Bugzila: https://bugzilla.tianocore.org/show_bug.cgi?id=4176
Signed-off-by: Dun Tan 
Cc: Dandan Bi 
Cc: Liming Gao 
Reviewed-by: Ray Ni 
Cc: Jian J Wang 
---
 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 155 
+++
 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h |  15 ---
 2 files changed, 15 insertions(+), 155 deletions(-)

diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c 
b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
index 80482c7853..e6b6d602c1 100644
--- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
+++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
@@ -330,154 +330,37 @@ CreateOrUpdatePageTable (
   ASSERT (PageTableBufferSize == 0);
 }
 
-/**
-  Set one page of page table pool memory to be read-only.
-
-  @param[in] PageTableBaseBase address of page table (CR3).
-  @param[in] Address  Start address of a page to be set as read-only.
-  @param[in] Level4Paging Level 4 paging flag.
-
-**/
-VOID
-SetPageTablePoolReadOnly (
-  IN  UINTN PageTableBase,
-  IN  EFI_PHYSICAL_ADDRESS  Address,
-  IN  BOOLEAN   Level4Paging
-  )
-{
-  UINTN Index;
-  UINTN EntryIndex;
-  UINT64AddressEncMask;
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;
-  UINT64*PageTable;
-  UINT64*NewPageTable;
-  UINT64PageAttr;
-  UINT64LevelSize[5];
-  UINT64LevelMask[5];
-  UINTN LevelShift[5];
-  UINTN Level;
-  UINT64PoolUnitSize;
-
-  ASSERT (PageTableBase != 0);
-
-  //
-  // Since the page table is always from page table pool, which is always
-  // located at the boundary of PcdPageTablePoolAlignment, we just need to
-  // set the whole pool unit to be read-only.
-  //
-  Address = Address & PAGE_TABLE_POOL_ALIGN_MASK;
-
-  LevelShift[1] = PAGING_L1_ADDRESS_SHIFT;
-  LevelShift[2] = PAGING_L2_ADDRESS_SHIFT;
-  LevelShift[3] = PAGING_L3_ADDRESS_SHIFT;
-  LevelShift[4] = PAGING_L4_ADDRESS_SHIFT;
-
-  LevelMask[1] = PAGING_4K_ADDRESS_MASK_64;
-  LevelMask[2] = PAGING_2M_ADDRESS_MASK_64;
-  LevelMask[3] = PAGING_1G_ADDRESS_MASK_64;
-  LevelMask[4] = PAGING_1G_ADDRESS_MASK_64;
-
-  LevelSize[1] = SIZE_4KB;
-  LevelSize[2] = SIZE_2MB;
-  LevelSize[3] = SIZE_1GB;
-  LevelSize[4] = SIZE_512GB;
-
-  AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) &
-   PAGING_1G_ADDRESS_MASK_64;
-  PageTable= (UINT64 *)(UINTN)PageTableBase;
-  PoolUnitSize = PAGE_TABLE_POOL_UNIT_SIZE;
-
-  for (Level = (Level4Paging) ? 4 : 3; Level > 0; --Level) {
-Index  = ((UINTN)RShiftU64 (Address, LevelShift[Level]));
-Index &= PAGING_PAE_INDEX_MASK;
-
-PageAttr = PageTable[Index];
-if ((PageAttr & IA32_PG_PS) == 0) {
-  //
-  // Go to next level of table.
-  //
-  PageTable = (UINT64 *)(UINTN)(PageAttr & ~AddressEncMask &
-PAGING_4K_ADDRESS_MASK_64);
-  continue;
-}
-
-if (PoolUnitSize >= LevelSize[Level]) {
-  //
-  // Clear R/W bit if current page granularity is not larger than pool unit
-  // size.
-  //
-  if ((PageAttr & IA32_PG_RW) != 0) {
-while (PoolUnitSize > 0) {
-  //
-  // PAGE_TABLE_POOL_UNIT_SIZE and PAGE_TABLE_POOL_ALIGNMENT are fit in
-  // one page (2MB). Then we don't need to update attributes for pages
-  // crossing page directory. ASSERT below is for that purpose.
-  //
-  ASSERT (Index < EFI_PAGE_SIZE/sizeof (UINT64));
-
-  PageTable[Index] &= ~(UINT64)IA32_PG_RW;
-  PoolUnitSize -= LevelSize[Level];
-
-  ++Index;
-}
-  }
-
-  break;
-} else {
-  //
-  // The smaller granularity of page must be needed.
-  //
-  ASSERT (Level > 1);
-
-  NewPageTable = AllocatePageTableMemory (1);
-  ASSERT (NewPageTable != NULL);
-
-  PhysicalAddress = PageAttr & LevelMask[Level];
-  for (EntryIndex = 0;
-   EntryIndex < EFI_PAGE_SIZE/sizeof (UINT64);
-   ++EntryIndex)
-  {
-NewPageTable[EntryIndex] = PhysicalAddress  | AddressEncMask |
-   IA32_PG_P | IA32_PG_RW;
-if (Level > 2) {
-  NewPageTable[EntryIndex] |= IA32_PG_PS;
-}
-
-PhysicalAddress += LevelSize[Level - 1];
-  }
-
-  PageTable[Index] = (UINT64)(UINTN)NewPageTable 

[edk2-devel] [Patch V3 7/8] MdeModulePkg/DxeIpl: Remove duplicated code to enable NX

2023-04-24 Thread duntan
In IA32 code, remove the duplicated code to enable NX.
In the previous patch, IA32 code also uses the new
CreateIdentityMappingPageTables() to create PAE page table.
This function calls EnableExecuteDisableBit if needed.

Signed-off-by: Dun Tan 
Cc: Dandan Bi 
Cc: Liming Gao 
Reviewed-by: Ray Ni 
Cc: Jian J Wang 
---
 MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c 
b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
index 69d073fb58..dd7cbb6ce6 100644
--- a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
+++ b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
@@ -322,9 +322,6 @@ HandOffToDxeCore (
 BuildPageTablesIa32Pae = ToBuildPageTable ();
 if (BuildPageTablesIa32Pae) {
   PageTables = CreateIdentityMappingPageTables (FALSE, BaseOfStack, 
STACK_SIZE, 0, 0);
-  if (IsEnableNonExecNeeded ()) {
-EnableExecuteDisableBit ();
-  }
 }
 
 //
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103471): https://edk2.groups.io/g/devel/message/103471
Mute This Topic: https://groups.io/mt/98466790/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V3 6/8] MdeModulePkg/DxeIpl: Create page table by CpuPageTableLib

2023-04-24 Thread duntan
Modify CreateIdentityMappingPageTables() to create page table
based on CpuPageTableLib in DxeIpl module. This function can
be used to create both IA32 PAE paging and long mode 4-level,
5-level paging structure. With the PageTableMap() API in the
CpuPageTableLib, we can remove the complicated page table
manipulating code. This commit doesn't change any functionality.

Signed-off-by: Dun Tan 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Tom Lendacky 
---
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.h|   3 ++-
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf  |   5 -
 MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c  | 109 
-
 MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c   |   5 +++--
 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 567 
++-
 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h | 167 
++-
 6 files changed, 177 insertions(+), 679 deletions(-)

diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h 
b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
index 2f015befce..03e6f8cff7 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
@@ -2,7 +2,7 @@
   Master header file for DxeIpl PEIM. All source files in this module should
   include this file for common definitions.
 
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -42,6 +42,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #define STACK_SIZE  0x2
 #define BSP_STORE_SIZE  0x4000
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf 
b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index 052ea0ec1a..f636f042cb 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -5,7 +5,7 @@
 #  PPI to discover and dispatch the DXE Foundation and components that are
 #  needed to run the DXE Foundation.
 #
-#  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
 #  Copyright (c) 2017, AMD Incorporated. All rights reserved.
 #  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights 
reserved.
 #  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights 
reserved.
@@ -80,6 +80,9 @@
   PeiServicesTablePointerLib
   PerformanceLib
 
+[LibraryClasses.IA32, LibraryClasses.X64]
+  CpuPageTableLib
+
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
   ArmMmuLib
 
diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c 
b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
index 4bc7b749b0..69d073fb58 100644
--- a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
+++ b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
@@ -1,7 +1,7 @@
 /** @file
   Ia32-specific functionality for DxeLoad.
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
 Copyright (c) 2017, AMD Incorporated. All rights reserved.
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -70,107 +70,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED  IA32_DESCRIPTOR  
gLidtDescriptor = {
   0
 };
 
-/**
-  Allocates and fills in the Page Directory and Page Table Entries to
-  establish a 4G page table.
-
-  @param[in] StackBase  Stack base address.
-  @param[in] StackSize  Stack size.
-
-  @return The address of page table.
-
-**/
-UINTN
-Create4GPageTablesIa32Pae (
-  IN EFI_PHYSICAL_ADDRESS  StackBase,
-  IN UINTN StackSize
-  )
-{
-  UINT8   PhysicalAddressBits;
-  EFI_PHYSICAL_ADDRESSPhysicalAddress;
-  UINTN   IndexOfPdpEntries;
-  UINTN   IndexOfPageDirectoryEntries;
-  UINT32  NumberOfPdpEntriesNeeded;
-  PAGE_MAP_AND_DIRECTORY_POINTER  *PageMap;
-  PAGE_MAP_AND_DIRECTORY_POINTER  *PageDirectoryPointerEntry;
-  PAGE_TABLE_ENTRY*PageDirectoryEntry;
-  UINTN   TotalPagesNum;
-  UINTN   PageAddress;
-  UINT64  

[edk2-devel] [Patch V3 5/8] OvmfPkg: Add CpuPageTableLib required by DxeIpl in DSC file

2023-04-24 Thread duntan
Add CpuPageTableLib instance required by DxeIpl in corresponding
DSC files of OvmfPkg.

Signed-off-by: Dun Tan 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Acked-by: Gerd Hoffmann 
Cc: Ray Ni 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc   | 2 +-
 OvmfPkg/Bhyve/BhyveX64.dsc | 3 ++-
 OvmfPkg/CloudHv/CloudHvX64.dsc | 2 +-
 OvmfPkg/Microvm/MicrovmX64.dsc | 2 +-
 OvmfPkg/OvmfPkgIa32.dsc| 3 ++-
 OvmfPkg/OvmfPkgIa32X64.dsc | 2 +-
 OvmfPkg/OvmfPkgX64.dsc | 2 +-
 OvmfPkg/OvmfXen.dsc| 2 +-
 8 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index 943c4eed98..f8956f7147 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -169,6 +169,7 @@
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
   PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf
   DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 
 !if $(SOURCE_DEBUG_ENABLE) == TRUE
   
PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
@@ -348,7 +349,6 @@
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
-  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   
NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index d0d2712c56..67f8a77c3a 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -1,6 +1,6 @@
 #
 #  Copyright (c) 2020, Rebecca Cran 
-#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  Copyright (c) 2014, Pluribus Networks, Inc.
 #
@@ -171,6 +171,7 @@
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
   PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf
   DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 
   
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
   
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index cc2dd925bc..8a2fb8049f 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -190,6 +190,7 @@
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
   PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf
   DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 !if $(SMM_REQUIRE) == FALSE
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
 !endif
@@ -399,7 +400,6 @@
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
-  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   
NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index e9aab51559..7ffb72e06e 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -193,6 +193,7 @@
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
   PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf
   DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 
 !if $(SOURCE_DEBUG_ENABLE) == TRUE
   
PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
@@ -398,7 +399,6 @@
   PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
   PciPcdProducerLib|OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf
   
PciExpressLib|OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf
-  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   
NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf
   

[edk2-devel] [Patch V3 4/8] MdeModulePkg: Add CpuPageTableLib required by DxeIpl in DSC

2023-04-24 Thread duntan
Add CpuPageTableLib instance required by DxeIpl in
MdeModulePkg.dsc.

Signed-off-by: Dun Tan 
Acked-by: Jian J Wang 
Cc: Liming Gao 
Cc: Ray Ni 
---
 MdeModulePkg/MdeModulePkg.dsc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 1014598f31..d95acabe83 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -2,7 +2,7 @@
 # EFI/PI Reference Module Package for All Architectures
 #
 # (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2023, Intel Corporation. All rights reserved.
 # Copyright (c) Microsoft Corporation.
 # Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 #
@@ -106,6 +106,7 @@
   
MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
   
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
   
IpmiCommandLib|MdeModulePkg/Library/BaseIpmiCommandLibNull/BaseIpmiCommandLibNull.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 
 [LibraryClasses.EBC.PEIM]
   IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103468): https://edk2.groups.io/g/devel/message/103468
Mute This Topic: https://groups.io/mt/98466786/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V3 3/8] IntelFsp2Pkg: Add CpuPageTableLib required by DxeIpl in DSC

2023-04-24 Thread duntan
Add CpuPageTableLib instance required by DxeIpl in QemuFspPkg.dsc
of IntelFsp2Pkg.

Signed-off-by: Dun Tan 
Reviewed-by: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Ray Ni 
---
 IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc 
b/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc
index 3155812118..52052692dd 100644
--- a/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc
+++ b/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 # FSP DSC build file for QEMU platform
 #
-# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.
 #
 #This program and the accompanying materials
 #are licensed and made available under the terms and conditions of the BSD 
License
@@ -114,6 +114,7 @@
   DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
   SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
 !endif
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 
 
 

-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103467): https://edk2.groups.io/g/devel/message/103467
Mute This Topic: https://groups.io/mt/98466785/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V3 2/8] EmulatorPkg: Add CpuPageTableLib required by DxeIpl in DSC

2023-04-24 Thread duntan
Add CpuPageTableLib instance required by DxeIpl in EmulatorPkg.dsc.

Signed-off-by: Dun Tan 
Cc: Andrew Fish 
Reviewed-by: Ray Ni 
---
 EmulatorPkg/EmulatorPkg.dsc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index b44435d7e6..d1fb9d9256 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -4,7 +4,7 @@
 # The Emulation Platform can be used to debug individual modules, prior to 
creating
 # a real platform. This also provides an example for how an DSC is created.
 #
-# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
 # Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.
 # Copyright (c) Microsoft Corporation.
 #
@@ -66,6 +66,7 @@
   
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
   BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
   
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 
   #
   # UEFI & PI
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103466): https://edk2.groups.io/g/devel/message/103466
Mute This Topic: https://groups.io/mt/98466784/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V3 1/8] MdePkg: Move CpuPageTableLib defination to MdePkg

2023-04-24 Thread duntan
Move CpuPageTableLib defination from UefiCpuPkg to MdePkg. The
lib instance still remains in UefiCpuPkg. Move CpuPageTableLib
defination to a common location can avoid the case that
MdeModulePkg need to depend on UefiCpuPkg since DxeIpl module
in MdeModulePkg needs to consume CpuPageTableLib.

Signed-off-by: Dun Tan 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Ray Ni 
---
 {UefiCpuPkg => MdePkg}/Include/Library/CpuPageTableLib.h | 0
 MdePkg/MdePkg.dec| 5 -
 UefiCpuPkg/UefiCpuPkg.dec| 3 ---
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/UefiCpuPkg/Include/Library/CpuPageTableLib.h 
b/MdePkg/Include/Library/CpuPageTableLib.h
similarity index 100%
rename from UefiCpuPkg/Include/Library/CpuPageTableLib.h
rename to MdePkg/Include/Library/CpuPageTableLib.h
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 7488ccda7a..dfbca2d746 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -4,7 +4,7 @@
 # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs) of
 # EFI1.10/UEFI2.7/PI1.7 and some Industry Standards.
 #
-# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2023, Intel Corporation. All rights reserved.
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
 # (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development LP
 # Copyright (c) 2022, Loongson Technology Corporation Limited. All rights 
reserved.
@@ -321,6 +321,9 @@
   ##  @libraryclass  Provides function to support TDX processing.
   TdxLib|Include/Library/TdxLib.h
 
+  ##  @libraryclass  Provides function for manipulating x86 paging structures.
+  CpuPageTableLib|Include/Library/CpuPageTableLib.h
+
 [LibraryClasses.RISCV64]
   ##  @libraryclass  Provides function to make ecalls to SBI
   BaseRiscVSbiLib|Include/Library/BaseRiscVSbiLib.h
diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index a5528277ff..5ad41e9ae3 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -57,9 +57,6 @@
   ##  @libraryclass  Provides function for loading microcode.
   MicrocodeLib|Include/Library/MicrocodeLib.h
 
-  ##  @libraryclass  Provides function for manipulating x86 paging structures.
-  CpuPageTableLib|Include/Library/CpuPageTableLib.h
-
 [Guids]
   gUefiCpuPkgTokenSpaceGuid  = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa, 0xb8, 
0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}
   gMsegSmramGuid = { 0x5802bce4, 0x, 0x4e33, { 0xa1, 0x30, 
0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103465): https://edk2.groups.io/g/devel/message/103465
Mute This Topic: https://groups.io/mt/98466783/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V3 0/8] Create page table by CpuPageTableLib in DxeIpl

2023-04-24 Thread duntan
In V3 patch set:
1. Add a new patch 'MdePkg: Move CpuPageTableLib defination to MdePkg' to Move 
CpuPageTableLib defination from UefiCpuPkg to MdePkg.
   So that MdeModulePkg doesn't need to depend on UefiCpuPkg.
2. Modify the patch 'MdeModulePkg/DxeIpl: Create page table by CpuPageTableLib' 
to set GHCB page to be mapped as unencrypted for each CPU for AMD SEV feature.

Dun Tan (8):
  MdePkg: Move CpuPageTableLib defination to MdePkg
  EmulatorPkg: Add CpuPageTableLib required by DxeIpl in DSC
  IntelFsp2Pkg: Add CpuPageTableLib required by DxeIpl in DSC
  MdeModulePkg: Add CpuPageTableLib required by DxeIpl in DSC
  OvmfPkg: Add CpuPageTableLib required by DxeIpl in DSC file
  MdeModulePkg/DxeIpl: Create page table by CpuPageTableLib
  MdeModulePkg/DxeIpl: Remove duplicated code to enable NX
  MdeModulePkg/DxeIpl: Refinement to the code to set PageTable as RO

 EmulatorPkg/EmulatorPkg.dsc  |   3 ++-
 IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc  |   3 ++-
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.h|   3 ++-
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf  |   5 -
 MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c  | 112 

 MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c   |   5 +++--
 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 720 

 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h | 182 
++
 MdeModulePkg/MdeModulePkg.dsc|   3 ++-
 {UefiCpuPkg => MdePkg}/Include/Library/CpuPageTableLib.h |   0
 MdePkg/MdePkg.dec|   5 -
 OvmfPkg/AmdSev/AmdSevX64.dsc |   2 +-
 OvmfPkg/Bhyve/BhyveX64.dsc   |   3 ++-
 OvmfPkg/CloudHv/CloudHvX64.dsc   |   2 +-
 OvmfPkg/Microvm/MicrovmX64.dsc   |   2 +-
 OvmfPkg/OvmfPkgIa32.dsc  |   3 ++-
 OvmfPkg/OvmfPkgIa32X64.dsc   |   2 +-
 OvmfPkg/OvmfPkgX64.dsc   |   2 +-
 OvmfPkg/OvmfXen.dsc  |   2 +-
 UefiCpuPkg/UefiCpuPkg.dec|   3 ---
 20 files changed, 211 insertions(+), 851 deletions(-)
 rename {UefiCpuPkg => MdePkg}/Include/Library/CpuPageTableLib.h (100%)

-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103464): https://edk2.groups.io/g/devel/message/103464
Mute This Topic: https://groups.io/mt/98466782/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [Patch V3 03/11] OvmfPkg:Remove code that apply AddressEncMask to non-leaf entry

2023-04-24 Thread Gerd Hoffmann
On Fri, Apr 21, 2023 at 09:26:44AM -0500, Tom Lendacky wrote:
> On 4/21/23 03:36, Dun Tan wrote:
> > Remove code that apply AddressEncMask to non-leaf entry when split
> > smm page table by MemEncryptSevLib. In FvbServicesSmm driver, it
> > calls MemEncryptSevClearMmioPageEncMask to clear AddressEncMask
> > bit in page table for a specific range. In AMD SEV feature, this
> > AddressEncMask bit in page table is used to indicate if the memory
> > is guest private memory or shared memory. But all memory used by
> > page table are treated as encrypted regardless of encryption bit.
> > So remove the EncMask bit for smm non-leaf page table entry
> > doesn't impact AMD SEV feature.
> > If page split happens in the AddressEncMask bit clear process,
> > there will be some new non-leaf entries with AddressEncMask
> > applied in smm page table. When ReadyToLock, code in PiSmmCpuDxe
> > module will use CpuPageTableLib to modify smm page table. So
> > remove code to apply AddressEncMask for new non-leaf entries
> > since CpuPageTableLib doesn't consume the EncMask PCD.
> 
> I'm really not a fan of removing the encryption mask, because technically it
> is correct to have it present in non-leaf entries. I really think the
> pagetable library should be able to work correctly with or without the
> encryption mask.

Agree.  We have a bunch of custom page page code in TDX and SEV support
libraries.  See here:

 - Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
 - Library/BaseMemEncryptTdxLib/MemoryEncryption.c
 - Library/PeilessStartupLib/X64/VirtualMemory.c

I'd like to see those switched over to use the pagetable library, and
that probably requires support for the tdx/sev specific page table bits.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103463): https://edk2.groups.io/g/devel/message/103463
Mute This Topic: https://groups.io/mt/98406586/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] OvmfPkg/PlatformPei: Skip PlatformInitEmuVariableNvStore in SEV guest

2023-04-24 Thread Gerd Hoffmann
On Fri, Apr 21, 2023 at 03:49:27PM -0500, Tom Lendacky wrote:
> On 4/21/23 04:18, Gerd Hoffmann wrote:
> > > > Hmm, good question.  Can the guest figure what memory ranges are part
> > > > of the launch measurement?
> > > > 
> > > > I have a patch here (attached below) which refines flash detection and
> > > > can detect whenever varstore flash is writable or not.  I suspect that
> > > > doesn't help much though as flash probing requires mappings already
> > > > being correct.
> > > 
> > > Sorry for the delay, but, yeah, doesn't help. SEV and SEV-ES assert and
> > > SEV-SNP terminates because of accessing a shared page (in the RMP) as a
> > > private page (we don't support the generated 0x404 error code in the #VC
> > > handler).
> > 
> > Can you try this?
> > https://github.com/kraxel/edk2/commits/devel/secure-boot-pcd
> 
> It works for the split vars/code launch, but fails for the combined
> vars/code launch:
> 
> EMU Variable FVB Started
> EMU Variable FVB: Using pre-reserved block at 7FE7C000
> EMU Variable FVB: Basic FV headers were invalid
> EMU Variable FVB: SecureBoot: restore FV from ROM
> EMU Variable FVB: Basic FV headers were invalid
> ASSERT [EmuVariableFvbRuntimeDxe] 
> /root/kernels/ovmf-gerd-build-X64/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c(781):
>  ((BOOLEAN)(0==1))
> 
> So the mapping isn't correct at this point either.

Log looks like this for me, using grep -Ei '(fvb|flash|amdsev)'

Loading driver at 0x0003F022000 EntryPoint=0x0003F0245B5 AmdSevDxe.efi
Loading driver at 0x0003F6E4000 EntryPoint=0x0003F6E7035 
FvbServicesRuntimeDxe.efi
QEMU Flash: Attempting flash detection at FFC00010
QemuFlashDetected => FD behaves as ROM
QemuFlashDetected => No
QEMU flash was not detected. Writable FVB is not being installed.
Loading driver at 0x0003F6D3000 EntryPoint=0x0003F6D55B9 
EmuVariableFvbRuntimeDxe.efi
EMU Variable FVB Started
EMU Variable FVB: Using pre-reserved block at 3FEF4000
EMU Variable FVB: Basic FV headers were invalid
Installing FVB for EMU Variable support

So AmdSevDxe is loaded first, next comes FvbServicesRuntimeDxe, finally
EmuVariableFvbRuntimeDxe.

So AmdSev should have (in theory, in practice obviously not ...) setup
everything at that point I assume?

Failing that FvbServicesRuntimeDxe might do it as well, there actually
is some code doing so to fixup things after calling
SetMemorySpaceAttributes (see MarkIoMemoryRangeForRuntimeAccess).

Maybe that should also be called before QemuFlashInitialize() so the SEV
settings are correct when OVMF goes do flash detection?

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103462): https://edk2.groups.io/g/devel/message/103462
Mute This Topic: https://groups.io/mt/97922617/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v5 00/13] BaseTools,CryptoPkg,EmulatorPkg,MdePkg,others: Delete CLANG35,CLANG38,VS2008-2013,EBC, deprecate GCC48,GCC49,GCC5, add GCC and GCCNOLTO, update CLANGDWARF

2023-04-24 Thread Michael D Kinney
Hi Rebecca,

I have seen some issues with CLANGDWARF and need a little time to investigate 
further.

Mike

> -Original Message-
> From: Rebecca Cran 
> Sent: Friday, April 21, 2023 10:15 AM
> To: devel@edk2.groups.io; Gao, Liming ; Feng, Bob C 
> ; Chen, Christine
> ; Kinney, Michael D ; 
> Michael Kubacki ; Sean
> Brogan ; Chiu, Chasel ; 
> Desimone, Nathaniel L
> ; Zeng, Star ; Andrew 
> Fish 
> Cc: Rebecca Cran ; Ni, Ray ; Leif 
> Lindholm ; Liu, Zhiguang
> ; Wang, Jian J ; Lu, Xiaoyu1 
> ; Jiang, Guomin
> ; Guo, Gua ; Ard Biesheuvel 
> ; Pedro Falcato
> ; Gerd Hoffmann ; Marvin Häuser 
> 
> Subject: [PATCH v5 00/13] BaseTools,CryptoPkg,EmulatorPkg,MdePkg,others: 
> Delete CLANG35,CLANG38,VS2008-2013,EBC, deprecate
> GCC48,GCC49,GCC5, add GCC and GCCNOLTO, update CLANGDWARF
> 
> Update the toolchain definitions:
> 
> - Delete the CLANG35 and CLANG38 toolchains, and replace CLANG38 with
>   CLANGDWARF, updating it to support ARM and AARCH64 in addition to X64
> and IA32.
> 
> - Mark GCC48, GCC49 and GCC5 as deprecated.
> 
> - Add GCC and GCCNOLTO toolchain definitions.
> 
> - Remove VS2008, VS2010, VS2012 and VS2013.
> 
> - Remove EBC compiler definitions. Full removal of EBC support from the
>   various packages etc. will be done in a follow-up patch series.
> 
> - Remove unused IPHONE_TOOLS and SOURCERY_CYGWIN_TOOLS definitions.
> 
> - Remove unused CYGWIN_ definitions.
> 
> Personal GitHub PR: https://github.com/tianocore/edk2/pull/4240
> GitHub branch: https://github.com/bcran/edk2/tree/clangdwarf
> 
> Note: CI is now passing.
> 
> Changes from v1 to v2
> =
> 
> - Added a commit to delete GCC48 and GCC49, rename GCC5 to GCC and
>   update the flags for other toolchains to work with the new GCC
>   definitions.
> 
> - Bumped VERSION from 2.00 to 3.00 to inform users that they should
>   update their Conf/tools_def.txt.
> 
> Changes from v2 to v3
> =
> 
> - Keep GCC48, GCC49 and GCC5 but mark them deprecated, including with
>   warnings at the start and end of running a build.
> 
> - Dropped the commit fixing the IA32 build of UefiPayloadPkg, because it
>   causes CI to fail due to building both IA32 and X64 at the same time:
> 
>   "Module built under multiple ARCHs [IA32, X64]. Not able to determine which 
> output to put into flash for Module..."
> 
> - Added more information to the VERSION section in tools_def.template.
> 
> - Various fixes to the CLANGDWARF flags.
> 
> Changes from v3 to v4
> =
> 
> - Use lld for -a ARM -t CLANGDWARF.
> 
> Changes from v4 to v5
> =
> 
> - Fixed CLANGDWARF on Windows when llvm is installed with the llvm.org
>   installer and isn't installed in Visual Studio: use llvm-objcopy and the
>   tools prefix.
> 
> - Added flags for GCCNOLTO to UnitTestFrameworkPkgHost.dsc.inc
> 
> - Added GCC flags to CryptoPkg/Library/OpensslLib/*.inf
> 
> Rebecca Cran (13):
>   BaseTools,CryptoPkg: Update CLANGDWARF, remove CLANG 35/38 toolchains
>   BaseTools: Remove VS2008, 2010, 2012 and 2013 toolchain definitions
>   BaseTools: Remove VS2008-VS2013 remnants
>   MdePkg: Remove VS2008-VS2013 remnants
>   edksetup.bat: Remove VS2008-VS2013 remnants
>   BaseTools: Remove unused IPHONE_TOOLS and SOURCERY_CYGWIN_TOOLS defs
>   BaseTools: Remove EBC (EFI Byte Code) compiler definitions
>   BaseTools: Update VS toolchain descriptions in tools_def.txt.template
>   BaseTools/Conf/tools_def.template: Add GCC and GCCNOLTO toolchains
>   BaseTools: Only call LoadConfiguration once in build.py
>   BaseTools: Add a deprecation warning for GCC48,GCC49,GCC5 to build.py
>   BaseTools/Conf/tools_def.template: Add section for deprecated
> toolchains
>   BaseTools/Conf/tools_def.template: Bump VERSION to 3.00
> 
>  UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc   |4 
>  IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc |9 -
>  CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf |3 +--
>  CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf  |3 +--
>  CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf  |3 +--
>  CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf  |3 +--
>  CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf  |3 +--
>  CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf |3 +--
>  CryptoPkg/Library/OpensslLib/OpensslLib.inf |4 ++--
>  CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf|4 ++--
>  CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf   |4 ++--
>  CryptoPkg/Library/OpensslLib/OpensslLibFull.inf |4 ++--
>  CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf|5 +++--
>  EmulatorPkg/Unix/Host/Host.inf  |2 ++
>  MdePkg/Include/Ia32/ProcessorBind.h |8 ++--
>  MdePkg/Include/X64/ProcessorBind.h  |8 ++--
>