Re: [edk2-devel] [RFT PATCH v2 4/6] UefiCpuPkg/CpuExceptionHandlerLib: Remove needless runtime fixups

2023-03-30 Thread Ni, Ray

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionH=
andlerAsm.nasm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHan=
dlerAsm.nasm
similarity index 92%
rename from UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHa=
ndlerAsm.nasm
rename to UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm=
.nasm
index 957478574253e619..10af4cfcdb6b1ea2 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerA=
sm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -59,7 +59,7 @@ AsmIdtVectorBegin:
%rep 256=0D
push strict dword %[Vector] ; This instruction pushes sign-extended=
8-byte value on stack=0D
push rax=0D
- mov rax, strict qword 0 ; mov rax, ASM_PFX(CommonInterruptE=
ntry)=0D
+ mov rax, ASM_PFX(CommonInterruptEntry)=0D

I'm fairly certain this can be a relative reference, as the code doesn't seem 
to be copied away (as opposed to HookAfterStubHeaderBegin). If true, this would 
save 256 relocs, which sounds quite nice. Would you mind verifying? Thanks!

Marvin,

You are right the mov can be replaced with “lea”. But, we need to analyze if 
using lea, the size of each idt stub is fixed or variant (today the size is 
fixed, so StubSize = TotalSize / 256).

Another thing we need to evaluate is the impact to “Hook after” feature because 
“hook after” stub is very like the idt stub.

I think we can firstly use Ard’s solution. Later to evaluate to eliminate 
unnecessary absolute reference.

Thanks,

Ray


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102235): https://edk2.groups.io/g/devel/message/102235
Mute This Topic: https://groups.io/mt/97960766/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 2/3] BaseTools/Conf/tools_def: Fix CLANGDWARF_IA32_X64

2023-03-30 Thread gaoliming via groups.io
Marvin:
 Platform developer can decide how to configure this option in their DSC file 
to resolve their problem. This is one option for the platform developer. 

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Marvin
> H?user
> 发送时间: 2023年3月28日 19:26
> 收件人: gaoliming 
> 抄送: devel@edk2.groups.io; patrick.rudo...@9elements.com;
> guo.d...@intel.com; gua@intel.com; james...@intel.com;
> ray...@intel.com; a...@kernel.org
> 主题: Re: [edk2-devel] [PATCH 2/3] BaseTools/Conf/tools_def: Fix
> CLANGDWARF_IA32_X64
> 
> Hi all,
> 
> > On 28. Mar 2023, at 07:38, gaoliming  wrote:
> > Patrick:
> >  I prefer to override this option in DSC instead of the change in
> > tools_def.txt.
> 
> A DSC override to fix *binary corruption* of an unknown cause? It is 
> ridiculous
> this can even happen silently, even though it’s unclear which component is at
> fault.
> 
> > Normal EFI image needs to set its page size for the smaller
> > image size.
> >
> >  You can see GCC DLINK option. It also sets page-size as 0x40.
> >
> > DEFINE GCC49_IA32_X64_DLINK_COMMON   = -nostdlib
> -Wl,-n,-q,--gc-sections -z
> > common-page-size=0x40
> 
> Side note, the correct way to do this is setting max-page-size, not
> common-page-size.
> 
> >
> > Thanks
> > Liming
> >> -邮件原件-
> >> 发件人: devel@edk2.groups.io  代表 Patrick
> >> Rudolph
> >> 发送时间: 2023年3月17日 22:06
> >> 抄送: devel@edk2.groups.io; guo.d...@intel.com; gua@intel.com;
> >> james...@intel.com; ray...@intel.com; mhaeu...@posteo.de;
> >> a...@kernel.org
> >> 主题: [edk2-devel] [PATCH 2/3] BaseTools/Conf/tools_def: Fix
> >> CLANGDWARF_IA32_X64
> >>
> >> Drop the "-z max-page-size=0x40" option as it causes the ELF
> >> header to overflow into the .text section, causing undefined
> >> behaviour.
> 
> That *definitely* is not a fix. Not only does this regress binary size for
> platforms that have tight SPI space constraints, it also only masks the 
> issue. In
> the (frankly near-impossible) case the ELF header dramatically grows in size,
> who knows whether it can overflow again?
> 
> Sorry, but the overall description is pretty vague. Which OS / compiler 
> version
> are you using? Do you have any trivial way to detect the corruption? I never
> really touched UefiPayloadPkg and have nothing set up to boot it to reproduce
> the issue.
> 
> Best regards,
> Marvin
> 
> >>
> >> With high optimization level it corrupts essential code and
> >> the binary would crash. It might work with low optimization
> >> level though. As the default is to use Oz and LTO, it always
> >> crashes.
> >>
> >> Test:
> >> The ELF generated by
> >> 'python UefiPayloadPkg/UniversalPayloadBuild.py -a IA32' boots.
> >>
> >> Signed-off-by: Patrick Rudolph 
> >> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4357
> >> ---
> >> BaseTools/Conf/tools_def.template | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/BaseTools/Conf/tools_def.template
> >> b/BaseTools/Conf/tools_def.template
> >> index 9b59bd75c3..0c584ab390 100755
> >> --- a/BaseTools/Conf/tools_def.template
> >> +++ b/BaseTools/Conf/tools_def.template
> >> @@ -2866,7 +2866,7 @@ DEFINE CLANGDWARF_X64_PREFIX=
> >> ENV(CLANG_BIN)
> >>
> >>
> >> # LLVM/CLANG doesn't support -n link option. So, it can't share the same
> >> IA32_X64_DLINK_COMMON flag.
> >>
> >> # LLVM/CLANG doesn't support common page size. So, it can't share the
> >> same GccBase.lds script.
> >>
> >> -DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON   = -nostdlib
> >> -Wl,-q,--gc-sections -z max-page-size=0x40
> >>
> >> +DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON   = -nostdlib
> >> -Wl,-q,--gc-sections
> >>
> >> DEFINE CLANGDWARF_DLINK2_FLAGS_COMMON =
> >> -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/ClangBase.lds
> >>
> >> DEFINE CLANGDWARF_IA32_X64_ASLDLINK_FLAGS =
> >> DEF(CLANGDWARF_IA32_X64_DLINK_COMMON)
> >> -Wl,--defsym=PECOFF_HEADER_SIZE=0
> >> DEF(CLANGDWARF_DLINK2_FLAGS_COMMON)
> >> -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
> >>
> >> DEFINE CLANGDWARF_IA32_X64_DLINK_FLAGS=
> >> DEF(CLANGDWARF_IA32_X64_DLINK_COMMON)
> >> -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT)
> >> -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
> >>
> >> --
> >> 2.39.1
> >>
> >>
> >>
> >> -=-=-=-=-=-=
> >> Groups.io Links: You receive all messages sent to this group.
> >> View/Reply Online (#101341):
> >> https://edk2.groups.io/g/devel/message/101341
> >> Mute This Topic: https://groups.io/mt/97673649/4905953
> >> Group Owner: devel+ow...@edk2.groups.io
> >> Unsubscribe: https://edk2.groups.io/g/devel/unsub
> >> [gaolim...@byosoft.com.cn]
> >> -=-=-=-=-=-=
> 
> 
> 
> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102234): https://edk2.groups.io/g/devel/message/102234
Mute This Topic: https://groups.io/mt/97967312/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] Maintainers.txt: BaseTools Bob Feng -> reviewer, Rebecca Cran -> maintainer

2023-03-30 Thread gaoliming via groups.io
Reviewed-by: Liming Gao 

> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Leif Lindholm
> 发送时间: 2023年3月30日 18:18
> 收件人: devel@edk2.groups.io; rebe...@bsdio.com
> 抄送: Liming Gao ; Bob Feng
> 
> 主题: Re: [edk2-devel] [PATCH 1/1] Maintainers.txt: BaseTools Bob Feng ->
> reviewer, Rebecca Cran -> maintainer
> 
> On Wed, Mar 29, 2023 at 11:34:53 -0600, Rebecca Cran wrote:
> > Update Maintainers.txt for BaseTools: move Bob Feng from being a
> > maintainer to reviewer, and add myself (Rebecca Cran) as a new
> > maintainer.
> 
> Ooh, that's excellent!
> Reviewed-by: Leif Lindholm 
> 
> > Signed-off-by: Rebecca Cran 
> > Cc: Liming Gao 
> > Cc: Bob Feng 
> > ---
> >  Maintainers.txt | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/Maintainers.txt b/Maintainers.txt
> > index d4607af7..2f8671147a67 100644
> > --- a/Maintainers.txt
> > +++ b/Maintainers.txt
> > @@ -177,8 +177,9 @@ R: Julien Grall  [jgrall]
> >  BaseTools
> >  F: BaseTools/
> >  W: https://github.com/tianocore/tianocore.github.io/wiki/BaseTools
> > -M: Bob Feng  [BobCF]
> > +M: Rebecca Cran  [bcran]
> >  M: Liming Gao  [lgao4]
> > +R: Bob Feng  [BobCF]
> >  R: Yuwei Chen  [YuweiChen1110]
> >
> >  CryptoPkg
> > --
> > 2.34.1
> >
> >
> >
> >
> >
> >
> 
> 
> 
> 





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




Re: [edk2-devel] [RFT PATCH v2 4/6] UefiCpuPkg/CpuExceptionHandlerLib: Remove needless runtime fixups

2023-03-30 Thread Ni, Ray
Reviewed-by: Ray Ni 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Ard Biesheuvel
Sent: Friday, March 31, 2023 5:21 AM
To: devel@edk2.groups.io
Cc: Ard Biesheuvel ; Ni; Ni, Ray ; Andrew 
Fish ; Kinney, Michael D ; Liu, 
Zhiguang ; Rebecca Cran ; Tom 
Lendacky 
Subject: [edk2-devel] [RFT PATCH v2 4/6] UefiCpuPkg/CpuExceptionHandlerLib: 
Remove needless runtime fixups

Recent versions of the XCODE linker can be instructed to permit text
relocations, so we no longer have to work around this, which is
especially nice as our workaround assumes that the .text section is
mapped both writable and executable at the same time.

So remove the runtime fixups and instead, just emit the absolute
references into the .text section.

While at it, rename the Xcode5ExceptionHandlerAsm.nasm source file and
drop the Xcode5 prefix: this code is used by other toolchains too.

Signed-off-by: Ard Biesheuvel 
---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
|  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
|  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
|  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm 
=> ExceptionHandlerAsm.nasm} | 18 ++
 4 files changed, 5 insertions(+), 19 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
index d0f82095cf926e99..1b2dde746d154706 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h

 

 [Sources.X64]

-  X64/Xcode5ExceptionHandlerAsm.nasm

+  X64/ExceptionHandlerAsm.nasm

   X64/ArchExceptionHandler.c

   X64/ArchInterruptDefs.h

 

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
index 5339f8e604045801..86248cea3e97cedb 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h

 

 [Sources.X64]

-  X64/Xcode5ExceptionHandlerAsm.nasm

+  X64/ExceptionHandlerAsm.nasm

   X64/ArchExceptionHandler.c

   X64/ArchInterruptDefs.h

 

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
index 8f8a5dab79303f87..0eed594be8660302 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h

 

 [Sources.X64]

-  X64/Xcode5ExceptionHandlerAsm.nasm

+  X64/ExceptionHandlerAsm.nasm

   X64/ArchExceptionHandler.c

   X64/ArchInterruptDefs.h

 

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
similarity index 92%
rename from 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm
rename to UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
index 957478574253e619..10af4cfcdb6b1ea2 100644
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -59,7 +59,7 @@ AsmIdtVectorBegin:
 %rep  256

 pushstrict dword %[Vector] ; This instruction pushes sign-extended 
8-byte value on stack

 pushrax

-mov rax, strict qword 0; mov rax, ASM_PFX(CommonInterruptEntry)

+mov rax, ASM_PFX(CommonInterruptEntry)

 jmp rax

 %assign Vector Vector+1

 %endrep

@@ -69,8 +69,7 @@ HookAfterStubHeaderBegin:
 pushstrict dword 0  ; 0 will be fixed

 VectorNum:

 pushrax

-mov rax, strict qword 0 ; mov rax, HookAfterStubHeaderEnd

-JmpAbsoluteAddress:

+mov rax, HookAfterStubHeaderEnd

 jmp rax

 HookAfterStubHeaderEnd:

 mov rax, rsp

@@ -456,19 +455,6 @@ ASM_PFX(AsmGetTemplateAddressMap):
 mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 256

 lea rax, [HookAfterStubHeaderBegin]

 mov qword [rcx + 0x10], rax

-

-; Fix up CommonInterruptEntry address

-learax, [ASM_PFX(CommonInterruptEntry)]

-learcx, [AsmIdtVectorBegin]

-%rep  256

-movqword [rcx + (JmpAbsoluteAddress - 8 - HookAfterStubHeaderBegin)], 
rax

-addrcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) / 256

-%endrep

-; Fix up 

Re: [edk2-devel] [RFT PATCH v2 3/6] UefiCpuPkg/CpuExceptionHandlerLib: Use single SEC/PEI version

2023-03-30 Thread Ni, Ray
Thanks for the change.

But it doesn't highlight another impact due to this change: CET logic is 
removed from the SEC/PEI version.
It's not an issue because CET is only enabled in SMM environment today.
But better to highlight the impact in the commit message, and explicitly say 
that limitation in the SecPeiCpuExceptionHandlerLib.inf file.

Thanks,
Ray

-Original Message-
From: Ard Biesheuvel  
Sent: Friday, March 31, 2023 5:21 AM
To: devel@edk2.groups.io
Cc: Ard Biesheuvel ; Ni; Ni, Ray ; Andrew 
Fish ; Kinney, Michael D ; Liu, 
Zhiguang ; Rebecca Cran ; Tom 
Lendacky 
Subject: [RFT PATCH v2 3/6] UefiCpuPkg/CpuExceptionHandlerLib: Use single 
SEC/PEI version

Currently, we use the non-Xcode5 version of ExceptionHandlerAsm.nasm
only for the SEC and PEI phases, and this version was not compatible
with the XCODE or LLD linkers, which do not permit absolute relocations
in read-only sections by default. This has been fixed now, so we can use
it for all toolchains.

Let's rename the .nasm file to reflect the fact that is used for the
SecPei flavor of this library only, and while at it, remove some
unnecessary absolute references.

Since this makes the generic version compatible with the XCODE, let's
use this [smaller] version for XCODE5 builds too.

Signed-off-by: Ard Biesheuvel 
---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf 
| 2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{ExceptionHandlerAsm.nasm => 
SecPeiExceptionHandlerAsm.nasm} | 7 +++
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
   | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
index df44371fe018e06d..10c5c5f2e5d203f6 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h

 

 [Sources.X64]

-  X64/ExceptionHandlerAsm.nasm

+  X64/SecPeiExceptionHandlerAsm.nasm

   X64/ArchExceptionHandler.c

   X64/ArchInterruptDefs.h

 

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/SecPeiExceptionHandlerAsm.nasm
similarity index 95%
rename from 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
rename to 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/SecPeiExceptionHandlerAsm.nasm
index aaf8d622e6f3b8f1..585298768a66af6a 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
+++ 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/SecPeiExceptionHandlerAsm.nasm
@@ -276,8 +276,7 @@ DrFinish:
 ; and make sure RSP is 16-byte aligned

 ;

 sub rsp, 4 * 8 + 8

-mov rax, ASM_PFX(CommonExceptionHandler)

-callrax

+callASM_PFX(CommonExceptionHandler)

 add rsp, 4 * 8 + 8

 

 cli

@@ -384,10 +383,10 @@ DoIret:
 ; comments here for definition of address map

 global ASM_PFX(AsmGetTemplateAddressMap)

 ASM_PFX(AsmGetTemplateAddressMap):

-mov rax, AsmIdtVectorBegin

+lea rax, [AsmIdtVectorBegin]

 mov qword [rcx], rax

 mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32

-mov rax, HookAfterStubHeaderBegin

+lea rax, [HookAfterStubHeaderBegin]

 mov qword [rcx + 0x10], rax

 ret

 

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
index 619b39d7f1de9ae3..c58fbb0d74500e48 100644
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
+++ 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
@@ -33,7 +33,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h

 

 [Sources.X64]

-  X64/Xcode5ExceptionHandlerAsm.nasm

+  X64/SecPeiExceptionHandlerAsm.nasm

   X64/ArchExceptionHandler.c

   X64/ArchInterruptDefs.h

 

-- 
2.39.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102230): https://edk2.groups.io/g/devel/message/102230
Mute This Topic: https://groups.io/mt/97960765/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] [RFT PATCH v2 6/6] UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version

2023-03-30 Thread Ni, Ray
Reviewed-by: Ray Ni 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Ard Biesheuvel
Sent: Friday, March 31, 2023 5:21 AM
To: devel@edk2.groups.io
Cc: Ard Biesheuvel ; Ni; Ni, Ray ; Andrew 
Fish ; Kinney, Michael D ; Liu, 
Zhiguang ; Rebecca Cran ; Tom 
Lendacky 
Subject: [edk2-devel] [RFT PATCH v2 6/6] UefiCpuPkg/CpuExceptionHandlerLib: 
Drop special XCODE5 version

This library is no longer used or needed, so let's remove it.

Signed-off-by: Ard Biesheuvel 
---
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 | 65 
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
 | 18 --
 2 files changed, 83 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
deleted file mode 100644
index c58fbb0d74500e48..
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
+++ /dev/null
@@ -1,65 +0,0 @@
-## @file

-#  CPU Exception Handler library instance for SEC/PEI modules.

-#

-#  Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.

-#  Copyright (c) 2012 - 2022, Intel Corporation. All rights reserved.

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

-#

-#  This is the XCODE5 variant of the SEC/PEI CpuExceptionHandlerLib. This

-#  variant performs binary patching to fix up addresses that allow the

-#  XCODE5 toolchain to be used.

-#

-##

-

-[Defines]

-  INF_VERSION= 0x00010005

-  BASE_NAME  = Xcode5SecPeiCpuExceptionHandlerLib

-  MODULE_UNI_FILE= Xcode5SecPeiCpuExceptionHandlerLib.uni

-  FILE_GUID  = 49C481AF-1621-42F3-8FA1-27C64143E304

-  MODULE_TYPE= PEIM

-  VERSION_STRING = 1.1

-  LIBRARY_CLASS  = CpuExceptionHandlerLib|SEC PEI_CORE PEIM

-

-#

-# The following information is for reference only and not required by the 
build tools.

-#

-#  VALID_ARCHITECTURES   = IA32 X64

-#

-

-[Sources.Ia32]

-  Ia32/ExceptionHandlerAsm.nasm

-  Ia32/ExceptionTssEntryAsm.nasm

-  Ia32/ArchExceptionHandler.c

-  Ia32/ArchInterruptDefs.h

-

-[Sources.X64]

-  X64/SecPeiExceptionHandlerAsm.nasm

-  X64/ArchExceptionHandler.c

-  X64/ArchInterruptDefs.h

-

-[Sources.common]

-  CpuExceptionCommon.h

-  CpuExceptionCommon.c

-  SecPeiCpuException.c

-

-[Packages]

-  MdePkg/MdePkg.dec

-  MdeModulePkg/MdeModulePkg.dec

-  UefiCpuPkg/UefiCpuPkg.dec

-

-[LibraryClasses]

-  BaseLib

-  SerialPortLib

-  PrintLib

-  LocalApicLib

-  PeCoffGetEntryPointLib

-  CcExitLib

-

-[Pcd]

-  gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard

-  gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList

-  gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize

-

-[FeaturePcd]

-  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard## CONSUMES

-

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
deleted file mode 100644
index a63b25f39d992775..
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file

-// XCODE5 CPU Exception Handler library instance for SEC/PEI modules.

-//

-// CPU Exception Handler library instance for SEC/PEI modules when built

-// using the XCODE5 toolchain.

-//

-// Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.

-// Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.

-//

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

-//

-// **/

-

-

-#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler 
library instance for SEC/PEI modules with the XCODE5 toolchain."

-

-#string STR_MODULE_DESCRIPTION  #language en-US "CPU Exception Handler 
library instance for SEC/PEI modules with the XCODE5 toolchain."

-

-- 
2.39.2



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102217): https://edk2.groups.io/g/devel/message/102217
Mute This Topic: https://groups.io/mt/97960772/1712937
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [ray...@intel.com]
-=-=-=-=-=-=




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102231): https://edk2.groups.io/g/devel/message/102231
Mute This Topic: https://groups.io/mt/97960772/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 0/2] Support FDT library.

2023-03-30 Thread Pedro Falcato
On Fri, Mar 31, 2023 at 12:32 AM Kinney, Michael D
 wrote:
> Appreciate the feedback.  Agree that any libc API that is implemented in a
> wrapper should conform to the standard.
>
> > We also have a whole libc implementation in edk2-libc that seems to be
> > permanently gathering dust until Intel touches it for Python purposes
> > from time to time. So between crypto, libfdt, etc, could we try to
> > unify things here a bit?
>
> edk2-libc to too large for FW components and it is out of date.
>
> Would you like to volunteer to lead a design and implementation that
> is right-sized for FW modules and could be the one wrapper that works
> for all current use cases and could be extended in the future as
> needed to support additional use cases?  Don’t need all of libc.  Just
> enough to support the APIs used by the submodules used so far.
>

Mike,

I wrote up a quick RFC patch for a bunch of libc bits that you needed
in this case (BaseFdtLib and libfdt).
It's very much a WIP and only supports GCC/clang. MSVC needs some
support when it comes to limits.h (because of LP64 vs Windows's
LLP64), but nothing too hard certainly.
See 
https://edk2.groups.io/g/devel/topic/rfc_patch_1_1_mdepkg_add_a/97965830?p=,,,20,0,0,0::recentpostdate/sticky,,,20,2,0,97965830,previd%3D1680229851681438282,nextid%3D1680190220621190228=1680229851681438282=1680190220621190228

Comments welcome.

-- 
Pedro


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




[edk2-devel] [RFC PATCH 1/1] MdePkg: Add a libc implementation

2023-03-30 Thread Pedro Falcato
Add LibcLib, a libc implementation meant to centralize all libc bits in
edk2.

Work in progress, does not support Windows targets (CLANGPDB and MSVC)
just yet.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Benny Lin 
Signed-off-by: Pedro Falcato 
---
 Wrote this to fulfill the new needs for BaseFdtLib and libfdt.
 It's very much a work in progress. Please test (I have no way to test this,
 and I have not attempted to replace OpenSSL stuff just yet). It's not perfect,
 but I attempted to be as correct as possible. Please, comment.

 Some details:
 1) I attempted to be as standards-correct as possible, used __name and _Name 
to avoid namespace polution.
I (unfortunately) had to include Base.h for NULL, because defining my own 
would possibly spell disaster
if someone included a C standard header and Base.h.
 2) ProcessorBind.h implicitly polutes the global namespace. I don't think this 
is fixable.
 3) In some places, I wrote my own functions when I could redirect to 
BaseMemoryLib stuff.
The amount of possible points of failure made me nervous (max string size 
PCD, etc). To be discussed.
 4) This should fulfill BaseFdtLib's needs. I went a bit more in-depth where I 
could (without wasting too much time).
Of course, this means it's still missing a *HUGE* chunk of libc. I don't 
think I'm aiming to write a full libc here (haha).
Just the common bits that may be useful for edk2.
 5) As discussed before (in the context of compiler intrinsics), GCC and clang 
require memcpy, memset, and some others for valid
codegen. This should possibly be done implicitly by BaseTools.
 6) Again, please, comment or contribute. If anyone wants to send PRs or 
checkout directly, feel free: https://github.com/heatd/edk2/tree/wip-libc

 MdePkg/Include/limits.h |  69 ++
 MdePkg/Include/stdbool.h|  17 
 MdePkg/Include/stddef.h |  26 +
 MdePkg/Include/stdint.h | 116 +++
 MdePkg/Include/stdlib.h |  21 
 MdePkg/Include/string.h |  86 +
 MdePkg/Include/types.h  |  27 ++
 MdePkg/Library/LibcLib/LibcLib.inf  |  38 
 MdePkg/Library/LibcLib/Stdlib/strtoul.c | 121 
 MdePkg/Library/LibcLib/String/memchr.c  |  19 
 MdePkg/Library/LibcLib/String/memcmp.c  |  19 
 MdePkg/Library/LibcLib/String/memcpy.c  |  29 ++
 MdePkg/Library/LibcLib/String/memset.c  |  21 
 MdePkg/Library/LibcLib/String/strchr.c  |  56 +++
 MdePkg/Library/LibcLib/String/strcmp.c  |  27 ++
 MdePkg/Library/LibcLib/String/strcpy.c  |  59 
 MdePkg/Library/LibcLib/String/strlen.c  |  16 
 MdePkg/MdeLibs.dsc.inc  |   1 +
 MdePkg/MdePkg.dec   |   4 +
 MdePkg/MdePkg.dsc   |   1 +
 20 files changed, 773 insertions(+)
 create mode 100644 MdePkg/Include/limits.h
 create mode 100644 MdePkg/Include/stdbool.h
 create mode 100644 MdePkg/Include/stddef.h
 create mode 100644 MdePkg/Include/stdint.h
 create mode 100644 MdePkg/Include/stdlib.h
 create mode 100644 MdePkg/Include/string.h
 create mode 100644 MdePkg/Include/types.h
 create mode 100644 MdePkg/Library/LibcLib/LibcLib.inf
 create mode 100644 MdePkg/Library/LibcLib/Stdlib/strtoul.c
 create mode 100644 MdePkg/Library/LibcLib/String/memchr.c
 create mode 100644 MdePkg/Library/LibcLib/String/memcmp.c
 create mode 100644 MdePkg/Library/LibcLib/String/memcpy.c
 create mode 100644 MdePkg/Library/LibcLib/String/memset.c
 create mode 100644 MdePkg/Library/LibcLib/String/strchr.c
 create mode 100644 MdePkg/Library/LibcLib/String/strcmp.c
 create mode 100644 MdePkg/Library/LibcLib/String/strcpy.c
 create mode 100644 MdePkg/Library/LibcLib/String/strlen.c

diff --git a/MdePkg/Include/limits.h b/MdePkg/Include/limits.h
new file mode 100644
index ..f87b870e6cbc
--- /dev/null
+++ b/MdePkg/Include/limits.h
@@ -0,0 +1,69 @@
+/** @file
+  ISO C limits.h
+
+  Copyright (c) 2023 Pedro Falcato All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _LIMITS_H
+#define _LIMITS_H
+
+#if defined (MDE_CPU_X64) || defined (MDE_CPU_AARCH64)
+// Hint for LONG_* stuff
+#define __LIMITS_64BIT
+#endif
+
+#ifndef __GNUC__
+// TODO: MSVC support is missing (some types are not exactly the same)
+// Should this whole logic be in ProcessorBind.h or something?
+  #error "MSVC support TODO"
+#endif
+
+#define CHAR_BIT  8
+
+/* Char limits - for char, signed char, unsigned char */
+#define SCHAR_MIN  -128
+#define SCHAR_MAX  127
+#define UCHAR_MAX  255
+
+// Note: We must check if chars are signed or unsigned here. 0xff = -128 for 
signed chars
+#if '\xff' < 0
+#define __CHAR_IS_SIGNED
+#endif
+
+#ifdef __CHAR_IS_SIGNED
+#define CHAR_MIN  SCHAR_MIN
+#define CHAR_MAX  SCHAR_MAX
+#else
+#define CHAR_MIN  0
+#define CHAR_MAX  UCHAR_MAX
+#endif
+
+/* Short limits - for short, unsigned short 

[edk2-devel] [edk2-platforms] Platform/Loongson: Fixed multi-core boot issue

2023-03-30 Thread xianglai
Fixed the bug of slave cpu querying MAILBUF register address.

Cc: Ard Biesheuvel 
Cc: Bibo Mao 
Cc: Chao Li 
Cc: Leif Lindholm 
Cc: Liming Gao 
Cc: Michael D Kinney 
Signed-off-by: xianglai li 
---
 Platform/Loongson/LoongArchQemuPkg/Sec/LoongArch64/Start.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Platform/Loongson/LoongArchQemuPkg/Sec/LoongArch64/Start.S 
b/Platform/Loongson/LoongArchQemuPkg/Sec/LoongArch64/Start.S
index 5d7ce313c0..8fb1b416f6 100644
--- a/Platform/Loongson/LoongArchQemuPkg/Sec/LoongArch64/Start.S
+++ b/Platform/Loongson/LoongArchQemuPkg/Sec/LoongArch64/Start.S
@@ -56,6 +56,8 @@ slave_main:
 li.d  T1, LOONGSON_IOCSR_IPI_EN
 iocsrwr.w T0, T1
 
+li.d  T1, LOONGSON_CSR_MAIL_BUF0
+
 1:
 # wait for wakeup
 idle 0
-- 
2.31.1



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




Re: [edk2-devel] [RFT PATCH v2 5/6] OvmfPkg: Drop special Xcode5 version of exception handler library

2023-03-30 Thread Yao, Jiewen
Acked-by: Jiewen Yao 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ard
> Biesheuvel
> Sent: Friday, March 31, 2023 5:21 AM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel ; Ni; Ni, Ray ;
> Andrew Fish ; Kinney, Michael D
> ; Liu, Zhiguang ;
> Rebecca Cran ; Tom Lendacky
> 
> Subject: [edk2-devel] [RFT PATCH v2 5/6] OvmfPkg: Drop special Xcode5
> version of exception handler library
> 
> The generic and XCODE5 versions of this library are now identical, so
> drop the special case. The library will be removed entirely in a
> subsequent patch.
> 
> Signed-off-by: Ard Biesheuvel 
> ---
>  OvmfPkg/AmdSev/AmdSevX64.dsc | 4 
>  OvmfPkg/CloudHv/CloudHvX64.dsc   | 4 
>  OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 
>  OvmfPkg/Microvm/MicrovmX64.dsc   | 4 
>  OvmfPkg/OvmfPkgIa32.dsc  | 4 
>  OvmfPkg/OvmfPkgIa32X64.dsc   | 4 
>  OvmfPkg/OvmfPkgX64.dsc   | 4 
>  OvmfPkg/OvmfXen.dsc  | 4 
>  8 files changed, 32 deletions(-)
> 
> diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc
> b/OvmfPkg/AmdSev/AmdSevX64.dsc
> index c005e474dd826759..943c4eed9831a1c5 100644
> --- a/OvmfPkg/AmdSev/AmdSevX64.dsc
> +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
> @@ -224,11 +224,7 @@ [LibraryClasses.common.SEC]
>PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
> 
> 
> PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/P
> eiServicesTablePointerLibIdt.inf
> 
> 
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemory
> AllocationLib.inf
> 
> -!if $(TOOL_CHAIN_TAG) == "XCODE5"
> 
> -
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcod
> e5SecPeiCpuExceptionHandlerLib.inf
> 
> -!else
> 
> 
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPe
> iCpuExceptionHandlerLib.inf
> 
> -!endif
> 
>CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf
> 
> 
> MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncry
> ptSevLib.inf
> 
> 
> 
> diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc
> b/OvmfPkg/CloudHv/CloudHvX64.dsc
> index b9820cc14bee0693..cc2dd925bc940ea8 100644
> --- a/OvmfPkg/CloudHv/CloudHvX64.dsc
> +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
> @@ -270,11 +270,7 @@ [LibraryClasses.common.SEC]
>PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
> 
> 
> PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/P
> eiServicesTablePointerLibIdt.inf
> 
> 
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemory
> AllocationLib.inf
> 
> -!if $(TOOL_CHAIN_TAG) == "XCODE5"
> 
> -
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcod
> e5SecPeiCpuExceptionHandlerLib.inf
> 
> -!else
> 
> 
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPe
> iCpuExceptionHandlerLib.inf
> 
> -!endif
> 
>CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf
> 
> 
> MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncry
> ptSevLib.inf
> 
> 
> 
> diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> index 5c56858d063b96bf..f734409055400859 100644
> --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> @@ -238,11 +238,7 @@ [LibraryClasses.common.SEC]
> 
> ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/Bas
> eExtractGuidedSectionLib.inf
> 
> 
> PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/P
> eiServicesTablePointerLibIdt.inf
> 
> 
> MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/Pre
> PiMemoryAllocationLib.inf
> 
> -!if $(TOOL_CHAIN_TAG) == "XCODE5"
> 
> -
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcod
> e5SecPeiCpuExceptionHandlerLib.inf
> 
> -!else
> 
> 
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPe
> iCpuExceptionHandlerLib.inf
> 
> -!endif
> 
>CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf
> 
> 
> MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncry
> ptSevLib.inf
> 
> 
> PrePiHobListPointerLib|OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiH
> obListPointerLibTdx.inf
> 
> diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc
> b/OvmfPkg/Microvm/MicrovmX64.dsc
> index 384b0b7afc74e90f..e9aab515592ffcec 100644
> --- a/OvmfPkg/Microvm/MicrovmX64.dsc
> +++ b/OvmfPkg/Microvm/MicrovmX64.dsc
> @@ -272,11 +272,7 @@ [LibraryClasses.common.SEC]
>PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
> 
> 
> PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/P
> eiServicesTablePointerLibIdt.inf
> 
> 
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemory
> AllocationLib.inf
> 
> -!if $(TOOL_CHAIN_TAG) == "XCODE5"
> 
> -
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcod
> e5SecPeiCpuExceptionHandlerLib.inf
> 
> -!else
> 
> 
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPe
> iCpuExceptionHandlerLib.inf
> 
> -!endif
> 
>

Re: [edk2-devel] edk2 MdeModulePkg build error

2023-03-30 Thread Nickle Wang via groups.io
VFR compiler is in BaseTools. Please check this to see how to generate binary 
tool: 
https://github.com/tianocore/edk2/tree/master/BaseTools#build-step-to-generate-the-binary-tools

Regards,
Nickle

From: ritul guru 
Sent: Thursday, March 30, 2023 11:05 PM
To: Nickle Wang ; edk2-devel-groups-io 

Subject: Re: [edk2-devel] edk2 MdeModulePkg build error

External email: Use caution opening links or attachments

Thanks, How to install vfr compiler in ubuntu?

Thanks & Regards
Ritul Guru
+91-9916513186


On Thu, Mar 30, 2023 at 6:42 PM Nickle Wang 
mailto:nick...@nvidia.com>> wrote:
You probably need to update VFR compiler. REST_STYLE token was introduced in 
below commit long time ago.

https://github.com/tianocore/edk2/commit/1b840718f72711d442ecd7b7e54256a31df8bd20

Regards,
Nickle

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of ritul guru via 
groups.io
Sent: Thursday, March 30, 2023 4:40 AM
To: edk2-devel-groups-io mailto:devel@edk2.groups.io>>
Subject: [edk2-devel] edk2 MdeModulePkg build error

External email: Use caution opening links or attachments

Hi,
getting below error while building MdeModulePkg, help is appreciated.

build cmd:
build -p "MdeModulePkg/MdeModulePkg.dsc" -b DEBUG -t GCC5


MdeModulePkg/Include 
-I/home/a/src/opensource/edk2/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/c/include
 
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei/DEBUG/AutoGen.c
VfrCompile...
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(164):
 WARNING: default
: default value re-defined with different value

VfrCompile...
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(238):
 ERROR 12288: REST_STYLE
: unexpected token

VfrCompile...
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(246):
 ERROR 12288: REST_STYLE
: unexpected token

VfrCompile: ERROR 0003: Error parsing
  compile error in file 
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i
make: *** [GNUmakefile:461: 
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/DEBUG/Vfr.c]
 Error 2


build.py...
 : error 7000: Failed to execute command
make tbuild 
[/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe]

Thanks & Regards
Ritul Guru
+91-9916513186



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




Re: [edk2-devel] [PATCH 0/2] Support FDT library.

2023-03-30 Thread Michael D Kinney


> -Original Message-
> From: Pedro Falcato 
> Sent: Thursday, March 30, 2023 4:27 PM
> To: Kinney, Michael D 
> Cc: devel@edk2.groups.io; Lin, Benny ; Gao, Liming 
> ; Liu, Zhiguang
> ; Sean Brogan ; Michael 
> Kubacki ; Leif
> Lindholm 
> Subject: Re: [edk2-devel] [PATCH 0/2] Support FDT library.
> 
> On Thu, Mar 30, 2023 at 11:59 PM Kinney, Michael D
>  wrote:
> >
> >
> >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of Pedro 
> > > Falcato
> > > Sent: Thursday, March 30, 2023 2:50 PM
> > > To: devel@edk2.groups.io; Lin, Benny 
> > > Cc: Kinney, Michael D ; Gao, Liming 
> > > ; Liu, Zhiguang
> > > ; Sean Brogan ; 
> > > Michael Kubacki 
> > > Subject: Re: [edk2-devel] [PATCH 0/2] Support FDT library.
> > >
> > > On Thu, Mar 30, 2023 at 6:13 PM Benny Lin  wrote:
> > > >
> > > > 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)
> > > >
> > > > Cc: Michael D Kinney 
> > > > Cc: Liming Gao 
> > > > Cc: Zhiguang Liu 
> > > > Cc: Sean Brogan 
> > > > Cc: Michael Kubacki 
> > > > Signed-off-by: Benny Lin 
> > > >
> > > > Benny Lin (2):
> > > >   MdePkg: Support FDT library.
> > > >   .pytool: Support FDT library.
> > > >
> > > >  .gitmodules   |   3 +
> > > >  .pytool/CISettings.py |   2 +
> > > >  MdePkg/Include/Library/FdtLib.h   | 300 ++
> > > >  MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 +
> > > >  MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
> > > >  MdePkg/Library/BaseFdtLib/FdtLib.c| 284 
> > > >  MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 102 
> > > >  MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 138 ++
> > > >  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 |  17 +-
> > > >  MdePkg/MdePkg.dec |   4 +
> > > >  MdePkg/MdePkg.dsc |   2 +
> > > >  ReadMe.rst|   1 +
> > > >  19 files changed, 988 insertions(+), 2 deletions(-)
> > > >  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
> > >
> > > There's already a copy of libfdt plus "FdtLib" at
> > > https://github.com/tianocore/edk2/tree/master/EmbeddedPkg/Library/FdtLib.
> > > Please figure out what to do with it.
> > > It's an old copy and has been accidentally uncrustify'd so it's
> > > probably a good idea to at least ditch that specific copy for a git
> > > submodule.
> >
> > I have discussed this overlap with Leif. After this patch series is
> > added, the EmbeddedPkg maintainers can convert that package to use
> > this lib and delete the duplicate sources.
> Ok, SGTM.
> >
> > >
> > > Also, NAK to Yet Another libc Implementation (and not a particularly
> > > good one at that).
> >
> > Please provide constructive feedback on what is not good about this 
> > specific libc
> > Implementation so that appropriate code updates could be made for this 
> > patch series.
> 
> Done.
> > This is following the same pattern as other libs that are consuming a 
> > submodule
> > that requires some amount of libc support.
> >
> > Getting down to one libc wrapper would be great.  Do you want to provide a 
> > proposed
> > implementation?  That could be handled as a separate task.
> 
> I would like it if we could stop contributing to that problem. We very
> much *know* there is a problem with both libc fragments and compiler
> intrinsic fragments all over edk2.
> A proper, correct C standard library is not trivial to implement
> (hence the multiple problems I did find from a quick read of the
> patch).

Appreciate the feedback.  Agree that any libc API that is 

Re: [edk2-devel] [PATCH 0/2] Support FDT library.

2023-03-30 Thread Pedro Falcato
On Thu, Mar 30, 2023 at 11:59 PM Kinney, Michael D
 wrote:
>
>
>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Pedro Falcato
> > Sent: Thursday, March 30, 2023 2:50 PM
> > To: devel@edk2.groups.io; Lin, Benny 
> > Cc: Kinney, Michael D ; Gao, Liming 
> > ; Liu, Zhiguang
> > ; Sean Brogan ; Michael 
> > Kubacki 
> > Subject: Re: [edk2-devel] [PATCH 0/2] Support FDT library.
> >
> > On Thu, Mar 30, 2023 at 6:13 PM Benny Lin  wrote:
> > >
> > > 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)
> > >
> > > Cc: Michael D Kinney 
> > > Cc: Liming Gao 
> > > Cc: Zhiguang Liu 
> > > Cc: Sean Brogan 
> > > Cc: Michael Kubacki 
> > > Signed-off-by: Benny Lin 
> > >
> > > Benny Lin (2):
> > >   MdePkg: Support FDT library.
> > >   .pytool: Support FDT library.
> > >
> > >  .gitmodules   |   3 +
> > >  .pytool/CISettings.py |   2 +
> > >  MdePkg/Include/Library/FdtLib.h   | 300 ++
> > >  MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 +
> > >  MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
> > >  MdePkg/Library/BaseFdtLib/FdtLib.c| 284 
> > >  MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 102 
> > >  MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 138 ++
> > >  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 |  17 +-
> > >  MdePkg/MdePkg.dec |   4 +
> > >  MdePkg/MdePkg.dsc |   2 +
> > >  ReadMe.rst|   1 +
> > >  19 files changed, 988 insertions(+), 2 deletions(-)
> > >  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
> >
> > There's already a copy of libfdt plus "FdtLib" at
> > https://github.com/tianocore/edk2/tree/master/EmbeddedPkg/Library/FdtLib.
> > Please figure out what to do with it.
> > It's an old copy and has been accidentally uncrustify'd so it's
> > probably a good idea to at least ditch that specific copy for a git
> > submodule.
>
> I have discussed this overlap with Leif. After this patch series is
> added, the EmbeddedPkg maintainers can convert that package to use
> this lib and delete the duplicate sources.
Ok, SGTM.
>
> >
> > Also, NAK to Yet Another libc Implementation (and not a particularly
> > good one at that).
>
> Please provide constructive feedback on what is not good about this specific 
> libc
> Implementation so that appropriate code updates could be made for this patch 
> series.

Done.
> This is following the same pattern as other libs that are consuming a 
> submodule
> that requires some amount of libc support.
>
> Getting down to one libc wrapper would be great.  Do you want to provide a 
> proposed
> implementation?  That could be handled as a separate task.

I would like it if we could stop contributing to that problem. We very
much *know* there is a problem with both libc fragments and compiler
intrinsic fragments all over edk2.
A proper, correct C standard library is not trivial to implement
(hence the multiple problems I did find from a quick read of the
patch).
We also have a whole libc implementation in edk2-libc that seems to be
permanently gathering dust until Intel touches it for Python purposes
from time to time. So between crypto, libfdt, etc, could we try to
unify things here a bit?

Thanks,
Pedro


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

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

2023-03-30 Thread Pedro Falcato
On Thu, Mar 30, 2023 at 6:13 PM Benny Lin  wrote:
>
> 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)
>
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Signed-off-by: Benny Lin 
> ---
>  .gitmodules   |   3 +
>  MdePkg/Include/Library/FdtLib.h   | 300 ++
>  MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 +
>  MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
>  MdePkg/Library/BaseFdtLib/FdtLib.c| 284 
>  MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 102 
>  MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 138 ++
>  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 |  17 +-
>  MdePkg/MdePkg.dec |   4 +
>  MdePkg/MdePkg.dsc |   2 +
>  ReadMe.rst|   1 +
>  18 files changed, 986 insertions(+), 2 deletions(-)
>  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
>
> diff --git a/.gitmodules b/.gitmodules
> index 8011a88d9d..5da342e90c 100644
> --- a/.gitmodules
> +++ b/.gitmodules
> @@ -23,3 +23,6 @@
>  [submodule "UnitTestFrameworkPkg/Library/GoogleTestLib/googletest"]
> path = UnitTestFrameworkPkg/Library/GoogleTestLib/googletest
> url = https://github.com/google/googletest.git
> +[submodule "MdePkg/Library/BaseFdtLib/libfdt"]
> +   path = MdePkg/Library/BaseFdtLib/libfdt
> +   url = https://github.com/devicetree-org/pylibfdt.git
> diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h
> new file mode 100644
> index 00..bcb097b77e
> --- /dev/null
> +++ b/MdePkg/Include/Library/FdtLib.h
> @@ -0,0 +1,300 @@
> +/** @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
> +///
> +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;
> +
> +#define FDT_GET_HEADER(Fdt, Field)  FDT32_TO_CPU(((CONST FDT_HEADER 
> *)(Fdt))->Field)
> +
> +#define FDT_MAGIC(Fdt)  (FDT_GET_HEADER(Fdt, Magic))
> +#define FDT_TOTAL_SIZE(Fdt) (FDT_GET_HEADER(Fdt, TotalSize))
> +#define FDT_OFFSET_DT_STRUCT(Fdt)   (FDT_GET_HEADER(Fdt, OffsetDtStruct))
> +#define FDT_OFFSET_DT_STRINGS(Fdt)  (FDT_GET_HEADER(Fdt, OffsetDtStrings))
> +#define FDT_OFFSET_MEM_RSVMAP(Fdt)  (FDT_GET_HEADER(Fdt, OffsetMemRsvmap))
> +#define FDT_VERSION(Fdt)(FDT_GET_HEADER(Fdt, Version))
> +#define FDT_LAST_COMP_VERSION(Fdt)  (FDT_GET_HEADER(Fdt, LastCompVersion))
> +#define FDT_BOOT_CPUID_PHYS(Fdt)

Re: [edk2-devel] [PATCH 0/2] Support FDT library.

2023-03-30 Thread Michael D Kinney


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Pedro Falcato
> Sent: Thursday, March 30, 2023 2:50 PM
> To: devel@edk2.groups.io; Lin, Benny 
> Cc: Kinney, Michael D ; Gao, Liming 
> ; Liu, Zhiguang
> ; Sean Brogan ; Michael 
> Kubacki 
> Subject: Re: [edk2-devel] [PATCH 0/2] Support FDT library.
> 
> On Thu, Mar 30, 2023 at 6:13 PM Benny Lin  wrote:
> >
> > 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)
> >
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> > Cc: Sean Brogan 
> > Cc: Michael Kubacki 
> > Signed-off-by: Benny Lin 
> >
> > Benny Lin (2):
> >   MdePkg: Support FDT library.
> >   .pytool: Support FDT library.
> >
> >  .gitmodules   |   3 +
> >  .pytool/CISettings.py |   2 +
> >  MdePkg/Include/Library/FdtLib.h   | 300 ++
> >  MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 +
> >  MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
> >  MdePkg/Library/BaseFdtLib/FdtLib.c| 284 
> >  MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 102 
> >  MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 138 ++
> >  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 |  17 +-
> >  MdePkg/MdePkg.dec |   4 +
> >  MdePkg/MdePkg.dsc |   2 +
> >  ReadMe.rst|   1 +
> >  19 files changed, 988 insertions(+), 2 deletions(-)
> >  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
> 
> There's already a copy of libfdt plus "FdtLib" at
> https://github.com/tianocore/edk2/tree/master/EmbeddedPkg/Library/FdtLib.
> Please figure out what to do with it.
> It's an old copy and has been accidentally uncrustify'd so it's
> probably a good idea to at least ditch that specific copy for a git
> submodule.

I have discussed this overlap with Leif. After this patch series is 
added, the EmbeddedPkg maintainers can convert that package to use
this lib and delete the duplicate sources.

> 
> Also, NAK to Yet Another libc Implementation (and not a particularly
> good one at that).

Please provide constructive feedback on what is not good about this specific 
libc
Implementation so that appropriate code updates could be made for this patch 
series.

This is following the same pattern as other libs that are consuming a submodule
that requires some amount of libc support.

Getting down to one libc wrapper would be great.  Do you want to provide a 
proposed
implementation?  That could be handled as a separate task.

> 
> --
> Pedro
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102221): https://edk2.groups.io/g/devel/message/102221
Mute This Topic: https://groups.io/mt/97955736/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] [RFT PATCH v2 4/6] UefiCpuPkg/CpuExceptionHandlerLib: Remove needless runtime fixups

2023-03-30 Thread Marvin Häuser
Hi Ard,

Thanks for these important updates!

On Thu, Mar 30, 2023 at 02:21 PM, Ard Biesheuvel wrote:

> 
> Recent versions of the XCODE linker can be instructed to permit text
> relocations, so we no longer have to work around this, which is
> especially nice as our workaround assumes that the .text section is
> mapped both writable and executable at the same time.
> 
> So remove the runtime fixups and instead, just emit the absolute
> references into the .text section.
> 
> While at it, rename the Xcode5ExceptionHandlerAsm.nasm source file and
> drop the Xcode5 prefix: this code is used by other toolchains too.
> 
> Signed-off-by: Ard Biesheuvel 
> ---
> UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf =
> | 2 +-
> UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf =
> | 2 +-
> UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf =
> | 2 +-
> UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.n=
> 
> asm =3D> ExceptionHandlerAsm.nasm} | 18 ++
> 4 files changed, 5 insertions(+), 19 deletions(-)
> 
> diff --git
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandl=
> erLib.inf
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandle=
> rLib.inf
> index d0f82095cf926e99..1b2dde746d154706 100644
> ---
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.i=
> nf
> +++
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.i=
> nf
> @@ -28,7 +28,7 @@ [Sources.Ia32]
> Ia32/ArchInterruptDefs.h=0D
> =0D
> [Sources.X64]=0D
> - X64/Xcode5ExceptionHandlerAsm.nasm=0D
> + X64/ExceptionHandlerAsm.nasm=0D
> X64/ArchExceptionHandler.c=0D
> X64/ArchInterruptDefs.h=0D
> =0D
> diff --git
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandl=
> erLib.inf
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandle=
> rLib.inf
> index 5339f8e604045801..86248cea3e97cedb 100644
> ---
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.i=
> nf
> +++
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.i=
> nf
> @@ -28,7 +28,7 @@ [Sources.Ia32]
> Ia32/ArchInterruptDefs.h=0D
> =0D
> [Sources.X64]=0D
> - X64/Xcode5ExceptionHandlerAsm.nasm=0D
> + X64/ExceptionHandlerAsm.nasm=0D
> X64/ArchExceptionHandler.c=0D
> X64/ArchInterruptDefs.h=0D
> =0D
> diff --git
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandl=
> erLib.inf
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandle=
> rLib.inf
> index 8f8a5dab79303f87..0eed594be8660302 100644
> ---
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.i=
> nf
> +++
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.i=
> nf
> @@ -28,7 +28,7 @@ [Sources.Ia32]
> Ia32/ArchInterruptDefs.h=0D
> =0D
> [Sources.X64]=0D
> - X64/Xcode5ExceptionHandlerAsm.nasm=0D
> + X64/ExceptionHandlerAsm.nasm=0D
> X64/ArchExceptionHandler.c=0D
> X64/ArchInterruptDefs.h=0D
> =0D
> diff --git
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionH=
> andlerAsm.nasm
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHan=
> dlerAsm.nasm
> similarity index 92%
> rename from
> UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHa=
> ndlerAsm.nasm
> rename to
> UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm=
> .nasm
> index 957478574253e619..10af4cfcdb6b1ea2 100644
> ---
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerA=
> sm.nasm
> +++
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> @@ -59,7 +59,7 @@ AsmIdtVectorBegin:
> %rep 256=0D
> push strict dword %[Vector] ; This instruction pushes sign-extended=
> 8-byte value on stack=0D
> push rax=0D
> - mov rax, strict qword 0 ; mov rax, ASM_PFX(CommonInterruptE=
> ntry)=0D
> + mov rax, ASM_PFX(CommonInterruptEntry)=0D

I'm fairly certain this can be a relative reference, as the code doesn't seem 
to be copied away (as opposed to HookAfterStubHeaderBegin). If true, this would 
save 256 relocs, which sounds quite nice. Would you mind verifying? Thanks!

If you want to take things a step further, this is how we merged the SEC/PEI 
and DXE/SMM variants: 
https://github.com/acidanthera/audk/commit/9646f2c4bc0475e0635b60b7c7828999a1d40dcb
 ( 
https://github.com/acidanthera/audk/commit/9646f2c4bc0475e0635b60b7c7828999a1d40dcb
 )
(There is a bug visible in the changes, which was fixed only later, so take 
this only as a PoC).

Best regards,
Marvin

> 
> jmp rax=0D
> %assign Vector Vector+1=0D
> %endrep=0D
> @@ -69,8 +69,7 @@ HookAfterStubHeaderBegin:
> push strict dword 0 ; 0 will be fixed=0D
> VectorNum:=0D
> push rax=0D
> - mov rax, strict qword 0 ; mov rax, HookAfterStubHeaderEnd=
> =0D
> -JmpAbsoluteAddress:=0D
> + mov rax, HookAfterStubHeaderEnd=0D
> jmp rax=0D
> HookAfterStubHeaderEnd:=0D
> mov rax, rsp=0D
> @@ -456,19 +455,6 @@ ASM_PFX(AsmGetTemplateAddressMap):
> mov qword [rcx + 0x8], 

Re: [edk2-devel] [RFT PATCH v2 1/6] BaseTools/tools_def XCODE: Link X64 with -read_only_relocs suppress

2023-03-30 Thread Marvin Häuser
Hi Ard,

Sorry, I cannot preserve the CC list as the groups.io interface doesn't seem to 
allow it. Can you please CC me on future revisions?

This patch will badly corrupt binaries. I cannot cite a source right now (if 
you want me to, please remind me in your response, so I can look it up 
tomorrow), but for X64 (but not IA32, which is why this is enabled there), 
relocs are relative to the first *writable* segment. In other words, any 
relocation to __TEXT will badly corrupt binaries this way.

In AUDK, we support this with two essential changes. The first is that we 
always generate a writable dummy segment at the beginning of the address space 
[1], making the relocs relative to the image base. The second is that in 
ocmtoc, our fork of the abandoned (and pretty badly-bugged) Apple mtoc, we 
explicitly require this segment to be present and verify its virtual address is 
the minimum virtual address [2]. It is then omitted from the conversion process 
[3]. I suggest you replicate these changes and fully switch to ocmtoc for 
XCODE5 builds.

Best regards,
Marvin

[1]
https://github.com/acidanthera/audk/blob/c382e9c571c7d5f39ba53b46a0c723c7943f33c5/BaseTools/Conf/tools_def.template#L2976-L2988

[2]
https://github.com/acidanthera/ocmtoc/blob/b0152c51beae264770c3faf0d213f9594ee043be/efitools/mtoc.c#L1097-L1123
https://github.com/acidanthera/ocmtoc/blob/b0152c51beae264770c3faf0d213f9594ee043be/efitools/mtoc.c#L1204-L1214

[3]
https://github.com/acidanthera/ocmtoc/blob/b0152c51beae264770c3faf0d213f9594ee043be/efitools/mtoc.c#L1307-L1311


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




Re: [edk2-devel] [PATCH 0/2] Support FDT library.

2023-03-30 Thread Pedro Falcato
On Thu, Mar 30, 2023 at 6:13 PM Benny Lin  wrote:
>
> 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)
>
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Cc: Sean Brogan 
> Cc: Michael Kubacki 
> Signed-off-by: Benny Lin 
>
> Benny Lin (2):
>   MdePkg: Support FDT library.
>   .pytool: Support FDT library.
>
>  .gitmodules   |   3 +
>  .pytool/CISettings.py |   2 +
>  MdePkg/Include/Library/FdtLib.h   | 300 ++
>  MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 +
>  MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
>  MdePkg/Library/BaseFdtLib/FdtLib.c| 284 
>  MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 102 
>  MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 138 ++
>  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 |  17 +-
>  MdePkg/MdePkg.dec |   4 +
>  MdePkg/MdePkg.dsc |   2 +
>  ReadMe.rst|   1 +
>  19 files changed, 988 insertions(+), 2 deletions(-)
>  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

There's already a copy of libfdt plus "FdtLib" at
https://github.com/tianocore/edk2/tree/master/EmbeddedPkg/Library/FdtLib.
Please figure out what to do with it.
It's an old copy and has been accidentally uncrustify'd so it's
probably a good idea to at least ditch that specific copy for a git
submodule.

Also, NAK to Yet Another libc Implementation (and not a particularly
good one at that).

-- 
Pedro


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




[edk2-devel] [RFT PATCH v2 6/6] UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version

2023-03-30 Thread Ard Biesheuvel
This library is no longer used or needed, so let's remove it.

Signed-off-by: Ard Biesheuvel 
---
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 | 65 
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
 | 18 --
 2 files changed, 83 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
deleted file mode 100644
index c58fbb0d74500e48..
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
+++ /dev/null
@@ -1,65 +0,0 @@
-## @file
-#  CPU Exception Handler library instance for SEC/PEI modules.
-#
-#  Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
-#  Copyright (c) 2012 - 2022, Intel Corporation. All rights reserved.
-#  SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#  This is the XCODE5 variant of the SEC/PEI CpuExceptionHandlerLib. This
-#  variant performs binary patching to fix up addresses that allow the
-#  XCODE5 toolchain to be used.
-#
-##
-
-[Defines]
-  INF_VERSION= 0x00010005
-  BASE_NAME  = Xcode5SecPeiCpuExceptionHandlerLib
-  MODULE_UNI_FILE= Xcode5SecPeiCpuExceptionHandlerLib.uni
-  FILE_GUID  = 49C481AF-1621-42F3-8FA1-27C64143E304
-  MODULE_TYPE= PEIM
-  VERSION_STRING = 1.1
-  LIBRARY_CLASS  = CpuExceptionHandlerLib|SEC PEI_CORE PEIM
-
-#
-# The following information is for reference only and not required by the 
build tools.
-#
-#  VALID_ARCHITECTURES   = IA32 X64
-#
-
-[Sources.Ia32]
-  Ia32/ExceptionHandlerAsm.nasm
-  Ia32/ExceptionTssEntryAsm.nasm
-  Ia32/ArchExceptionHandler.c
-  Ia32/ArchInterruptDefs.h
-
-[Sources.X64]
-  X64/SecPeiExceptionHandlerAsm.nasm
-  X64/ArchExceptionHandler.c
-  X64/ArchInterruptDefs.h
-
-[Sources.common]
-  CpuExceptionCommon.h
-  CpuExceptionCommon.c
-  SecPeiCpuException.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  UefiCpuPkg/UefiCpuPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  SerialPortLib
-  PrintLib
-  LocalApicLib
-  PeCoffGetEntryPointLib
-  CcExitLib
-
-[Pcd]
-  gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize
-
-[FeaturePcd]
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard## CONSUMES
-
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
deleted file mode 100644
index a63b25f39d992775..
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file
-// XCODE5 CPU Exception Handler library instance for SEC/PEI modules.
-//
-// CPU Exception Handler library instance for SEC/PEI modules when built
-// using the XCODE5 toolchain.
-//
-// Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
-// Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
-//
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler 
library instance for SEC/PEI modules with the XCODE5 toolchain."
-
-#string STR_MODULE_DESCRIPTION  #language en-US "CPU Exception Handler 
library instance for SEC/PEI modules with the XCODE5 toolchain."
-
-- 
2.39.2



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




[edk2-devel] [RFT PATCH v2 5/6] OvmfPkg: Drop special Xcode5 version of exception handler library

2023-03-30 Thread Ard Biesheuvel
The generic and XCODE5 versions of this library are now identical, so
drop the special case. The library will be removed entirely in a
subsequent patch.

Signed-off-by: Ard Biesheuvel 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc | 4 
 OvmfPkg/CloudHv/CloudHvX64.dsc   | 4 
 OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 
 OvmfPkg/Microvm/MicrovmX64.dsc   | 4 
 OvmfPkg/OvmfPkgIa32.dsc  | 4 
 OvmfPkg/OvmfPkgIa32X64.dsc   | 4 
 OvmfPkg/OvmfPkgX64.dsc   | 4 
 OvmfPkg/OvmfXen.dsc  | 4 
 8 files changed, 32 deletions(-)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index c005e474dd826759..943c4eed9831a1c5 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -224,11 +224,7 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
-!if $(TOOL_CHAIN_TAG) == "XCODE5"
-  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
-!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
-!endif
   CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLib.inf
 
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index b9820cc14bee0693..cc2dd925bc940ea8 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -270,11 +270,7 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
-!if $(TOOL_CHAIN_TAG) == "XCODE5"
-  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
-!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
-!endif
   CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLib.inf
 
diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
index 5c56858d063b96bf..f734409055400859 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
@@ -238,11 +238,7 @@ [LibraryClasses.common.SEC]
   
ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
-!if $(TOOL_CHAIN_TAG) == "XCODE5"
-  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
-!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
-!endif
   CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLib.inf
   
PrePiHobListPointerLib|OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointerLibTdx.inf
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 384b0b7afc74e90f..e9aab515592ffcec 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -272,11 +272,7 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
-!if $(TOOL_CHAIN_TAG) == "XCODE5"
-  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
-!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
-!endif
   CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLib.inf
 
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index a6db902f54ece86f..86177bb948999435 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -275,11 +275,7 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
-!if $(TOOL_CHAIN_TAG) == "XCODE5"
-  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
-!else

[edk2-devel] [RFT PATCH v2 4/6] UefiCpuPkg/CpuExceptionHandlerLib: Remove needless runtime fixups

2023-03-30 Thread Ard Biesheuvel
Recent versions of the XCODE linker can be instructed to permit text
relocations, so we no longer have to work around this, which is
especially nice as our workaround assumes that the .text section is
mapped both writable and executable at the same time.

So remove the runtime fixups and instead, just emit the absolute
references into the .text section.

While at it, rename the Xcode5ExceptionHandlerAsm.nasm source file and
drop the Xcode5 prefix: this code is used by other toolchains too.

Signed-off-by: Ard Biesheuvel 
---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
|  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
|  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
|  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm 
=> ExceptionHandlerAsm.nasm} | 18 ++
 4 files changed, 5 insertions(+), 19 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
index d0f82095cf926e99..1b2dde746d154706 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h
 
 [Sources.X64]
-  X64/Xcode5ExceptionHandlerAsm.nasm
+  X64/ExceptionHandlerAsm.nasm
   X64/ArchExceptionHandler.c
   X64/ArchInterruptDefs.h
 
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
index 5339f8e604045801..86248cea3e97cedb 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h
 
 [Sources.X64]
-  X64/Xcode5ExceptionHandlerAsm.nasm
+  X64/ExceptionHandlerAsm.nasm
   X64/ArchExceptionHandler.c
   X64/ArchInterruptDefs.h
 
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
index 8f8a5dab79303f87..0eed594be8660302 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h
 
 [Sources.X64]
-  X64/Xcode5ExceptionHandlerAsm.nasm
+  X64/ExceptionHandlerAsm.nasm
   X64/ArchExceptionHandler.c
   X64/ArchInterruptDefs.h
 
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
similarity index 92%
rename from 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm
rename to UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
index 957478574253e619..10af4cfcdb6b1ea2 100644
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -59,7 +59,7 @@ AsmIdtVectorBegin:
 %rep  256
 pushstrict dword %[Vector] ; This instruction pushes sign-extended 
8-byte value on stack
 pushrax
-mov rax, strict qword 0; mov rax, ASM_PFX(CommonInterruptEntry)
+mov rax, ASM_PFX(CommonInterruptEntry)
 jmp rax
 %assign Vector Vector+1
 %endrep
@@ -69,8 +69,7 @@ HookAfterStubHeaderBegin:
 pushstrict dword 0  ; 0 will be fixed
 VectorNum:
 pushrax
-mov rax, strict qword 0 ; mov rax, HookAfterStubHeaderEnd
-JmpAbsoluteAddress:
+mov rax, HookAfterStubHeaderEnd
 jmp rax
 HookAfterStubHeaderEnd:
 mov rax, rsp
@@ -456,19 +455,6 @@ ASM_PFX(AsmGetTemplateAddressMap):
 mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 256
 lea rax, [HookAfterStubHeaderBegin]
 mov qword [rcx + 0x10], rax
-
-; Fix up CommonInterruptEntry address
-learax, [ASM_PFX(CommonInterruptEntry)]
-learcx, [AsmIdtVectorBegin]
-%rep  256
-movqword [rcx + (JmpAbsoluteAddress - 8 - HookAfterStubHeaderBegin)], 
rax
-addrcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) / 256
-%endrep
-; Fix up HookAfterStubHeaderEnd
-learax, [HookAfterStubHeaderEnd]
-learcx, [JmpAbsoluteAddress]
-movqword [rcx - 8], rax
-
 ret
 
 
;-
-- 
2.39.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102215): https://edk2.groups.io/g/devel/message/102215
Mute This Topic: 

[edk2-devel] [RFT PATCH v2 3/6] UefiCpuPkg/CpuExceptionHandlerLib: Use single SEC/PEI version

2023-03-30 Thread Ard Biesheuvel
Currently, we use the non-Xcode5 version of ExceptionHandlerAsm.nasm
only for the SEC and PEI phases, and this version was not compatible
with the XCODE or LLD linkers, which do not permit absolute relocations
in read-only sections by default. This has been fixed now, so we can use
it for all toolchains.

Let's rename the .nasm file to reflect the fact that is used for the
SecPei flavor of this library only, and while at it, remove some
unnecessary absolute references.

Since this makes the generic version compatible with the XCODE, let's
use this [smaller] version for XCODE5 builds too.

Signed-off-by: Ard Biesheuvel 
---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf 
| 2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{ExceptionHandlerAsm.nasm => 
SecPeiExceptionHandlerAsm.nasm} | 7 +++
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
   | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
index df44371fe018e06d..10c5c5f2e5d203f6 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h
 
 [Sources.X64]
-  X64/ExceptionHandlerAsm.nasm
+  X64/SecPeiExceptionHandlerAsm.nasm
   X64/ArchExceptionHandler.c
   X64/ArchInterruptDefs.h
 
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/SecPeiExceptionHandlerAsm.nasm
similarity index 95%
rename from 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
rename to 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/SecPeiExceptionHandlerAsm.nasm
index aaf8d622e6f3b8f1..585298768a66af6a 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
+++ 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/SecPeiExceptionHandlerAsm.nasm
@@ -276,8 +276,7 @@ DrFinish:
 ; and make sure RSP is 16-byte aligned
 ;
 sub rsp, 4 * 8 + 8
-mov rax, ASM_PFX(CommonExceptionHandler)
-callrax
+callASM_PFX(CommonExceptionHandler)
 add rsp, 4 * 8 + 8
 
 cli
@@ -384,10 +383,10 @@ DoIret:
 ; comments here for definition of address map
 global ASM_PFX(AsmGetTemplateAddressMap)
 ASM_PFX(AsmGetTemplateAddressMap):
-mov rax, AsmIdtVectorBegin
+lea rax, [AsmIdtVectorBegin]
 mov qword [rcx], rax
 mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
-mov rax, HookAfterStubHeaderBegin
+lea rax, [HookAfterStubHeaderBegin]
 mov qword [rcx + 0x10], rax
 ret
 
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
index 619b39d7f1de9ae3..c58fbb0d74500e48 100644
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
+++ 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
@@ -33,7 +33,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h
 
 [Sources.X64]
-  X64/Xcode5ExceptionHandlerAsm.nasm
+  X64/SecPeiExceptionHandlerAsm.nasm
   X64/ArchExceptionHandler.c
   X64/ArchInterruptDefs.h
 
-- 
2.39.2



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




[edk2-devel] [RFT PATCH v2 2/6] BaseTools/tools_def CLANGDWARF: Permit text relocations

2023-03-30 Thread Ard Biesheuvel
We rely on PIE executables to get the codegen that is suitable for
PE/COFF conversion where the resulting executables can be loaded
anywhere in the address space.

However, ELF linkers may default to disallowing text relocations in PIE
executables, as this would require text segments to be updated at
runtime, which is bad for security and increases the copy-on-write
footprint of ELF executables and shared libraries.

However, none of those concerns apply to PE/COFF executables in the
context of EFI, which are copied into memory rather than mmap()'ed, and
fixed up by the loader before launch.

So pass -z notext to the LLD linker to permit runtime relocations in
read-only sections.

Signed-off-by: Ard Biesheuvel 
---
 BaseTools/Conf/tools_def.template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 1855f1038b1571e4..0c6fc4a3011c8d5c 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -2870,7 +2870,7 @@ DEFINE CLANGDWARF_X64_PREFIX= ENV(CLANG_BIN)
 DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON   = -nostdlib -Wl,-q,--gc-sections -z 
max-page-size=0x40
 DEFINE CLANGDWARF_DLINK2_FLAGS_COMMON = 
-Wl,--script=$(EDK_TOOLS_PATH)/Scripts/ClangBase.lds
 DEFINE CLANGDWARF_IA32_X64_ASLDLINK_FLAGS = 
DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0 
DEF(CLANGDWARF_DLINK2_FLAGS_COMMON) -Wl,--entry,ReferenceAcpiTable -u 
ReferenceAcpiTable
-DEFINE CLANGDWARF_IA32_X64_DLINK_FLAGS= 
DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u 
$(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
+DEFINE CLANGDWARF_IA32_X64_DLINK_FLAGS= 
DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u 
$(IMAGE_ENTRY_POINT) 
-Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive -Wl,-z,notext
 DEFINE CLANGDWARF_IA32_DLINK2_FLAGS   = 
-Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(CLANGDWARF_DLINK2_FLAGS_COMMON)
 DEFINE CLANGDWARF_X64_DLINK2_FLAGS= 
-Wl,--defsym=PECOFF_HEADER_SIZE=0x228 DEF(CLANGDWARF_DLINK2_FLAGS_COMMON)
 
-- 
2.39.2



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




[edk2-devel] [RFT PATCH v2 0/6] UefiCpuPkg, OvmfPkf: Simplify CpuExceptionHandlerLib

2023-03-30 Thread Ard Biesheuvel
We have a special version of CpuExceptionHandlerLib for XCODE5, whose
linker (LLD) does not permit absolute symbol references in read-only
sections.

Instead of fixing this up at runtime (which is done by writing the fixed
up values to the .text section, which we'd prefer to avoid), pass the
appropriate linker switches to allow these absolute relocations.

Changes since v2:
- pass linker switches to permit absolute relocations in read-only
  regions, and keep all code in .text

Cc: Ni, Ray 
Cc: Andrew Fish 
Cc: "Kinney, Michael D" 
Cc: "Liu, Zhiguang" 
Cc: Rebecca Cran 
Cc: Tom Lendacky 

Ard Biesheuvel (6):
  BaseTools/tools_def XCODE: Link X64 with -read_only_relocs suppress
  BaseTools/tools_def CLANGDWARF: Permit text relocations
  UefiCpuPkg/CpuExceptionHandlerLib: Use single SEC/PEI version
  UefiCpuPkg/CpuExceptionHandlerLib: Remove needless runtime fixups
  OvmfPkg: Drop special Xcode5 version of exception handler library
  UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version

 BaseTools/Conf/tools_def.template  
  |   8 +-
 OvmfPkg/AmdSev/AmdSevX64.dsc   
  |   4 -
 OvmfPkg/CloudHv/CloudHvX64.dsc 
  |   4 -
 OvmfPkg/IntelTdx/IntelTdxX64.dsc   
  |   4 -
 OvmfPkg/Microvm/MicrovmX64.dsc 
  |   4 -
 OvmfPkg/OvmfPkgIa32.dsc
  |   4 -
 OvmfPkg/OvmfPkgIa32X64.dsc 
  |   4 -
 OvmfPkg/OvmfPkgX64.dsc 
  |   4 -
 OvmfPkg/OvmfXen.dsc
  |   4 -
 UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
  |   2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
  |   2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf 
  |   2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
  |   2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm 
  |  92 ++---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm 
=> SecPeiExceptionHandlerAsm.nasm} | 103 +++-
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 |  65 
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
 |  18 
 17 files changed, 98 insertions(+), 228 deletions(-)
 rename 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm 
=> SecPeiExceptionHandlerAsm.nasm} (70%)
 delete mode 100644 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 delete mode 100644 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni

-- 
2.39.2



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




[edk2-devel] [RFT PATCH v2 1/6] BaseTools/tools_def XCODE: Link X64 with -read_only_relocs suppress

2023-03-30 Thread Ard Biesheuvel
Earlier XCODE versions did not support the -read_only_relocs suppress
linker option, which suppresses errors resulting from absolute
relocations emitted into read-only sections when building PIE
executables.

This requires a rather messy workaround in the CPU exception handler
libraries, to permit absolute relocations in code that may get copied
from a template in some cases.

Fortunately, this seems to be permitted now, so add the option for X64
as well (it was already present for IA32).

This will allows us to simplify the CPU exception handler libraries in
subsequent patches.

Signed-off-by: Ard Biesheuvel 
---
 BaseTools/Conf/tools_def.template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index ae43101853870c6d..1855f1038b1571e4 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -3010,9 +3010,9 @@ RELEASE_XCODE5_IA32_CC_FLAGS   = -arch i386 -c-Os 
  -Wall -Werror -inclu
 ##
 # X64 definitions
 ##
-  DEBUG_XCODE5_X64_DLINK_FLAGS  = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e 
_$(IMAGE_ENTRY_POINT) -preload -segalign 0x20  -pie -all_load -dead_strip 
-seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
-  NOOPT_XCODE5_X64_DLINK_FLAGS  = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e 
_$(IMAGE_ENTRY_POINT) -preload -segalign 0x20  -pie -all_load -dead_strip 
-seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
-RELEASE_XCODE5_X64_DLINK_FLAGS  = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e 
_$(IMAGE_ENTRY_POINT) -preload -segalign 0x20  -pie -all_load -dead_strip 
-seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+  DEBUG_XCODE5_X64_DLINK_FLAGS  = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e 
_$(IMAGE_ENTRY_POINT) -preload -segalign 0x20  -pie -all_load -dead_strip 
-seg1addr 0x240 -read_only_relocs suppress -map 
$(DEST_DIR_DEBUG)/$(BASE_NAME).map
+  NOOPT_XCODE5_X64_DLINK_FLAGS  = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e 
_$(IMAGE_ENTRY_POINT) -preload -segalign 0x20  -pie -all_load -dead_strip 
-seg1addr 0x240 -read_only_relocs suppress -map 
$(DEST_DIR_DEBUG)/$(BASE_NAME).map
+RELEASE_XCODE5_X64_DLINK_FLAGS  = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e 
_$(IMAGE_ENTRY_POINT) -preload -segalign 0x20  -pie -all_load -dead_strip 
-seg1addr 0x240 -read_only_relocs suppress -map 
$(DEST_DIR_DEBUG)/$(BASE_NAME).map
 
 *_XCODE5_X64_SLINK_FLAGS  = -static -o
   DEBUG_XCODE5_X64_ASM_FLAGS  = -arch x86_64 -g
-- 
2.39.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102211): https://edk2.groups.io/g/devel/message/102211
Mute This Topic: https://groups.io/mt/97960758/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] .github/workflows/codeql-analysis.yml: Add PIP caching

2023-03-30 Thread Michael D Kinney
Reviewed-by: Michael D Kinney 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Michael Kubacki
> Sent: Thursday, March 30, 2023 1:44 PM
> To: devel@edk2.groups.io
> Cc: Sean Brogan ; Michael Kubacki 
> ; Kinney, Michael D
> 
> Subject: [edk2-devel] [PATCH v1 1/1] .github/workflows/codeql-analysis.yml: 
> Add PIP caching
> 
> From: Michael Kubacki 
> 
> Adds caching of PIP dependencies. This reduces overall execution time
> and decreases likelihood of a network error reaching out pypi to get
> the dependencies.
> 
> Caching happens based on modules specified in pip-requirements.txt.
> 
> Cc: Sean Brogan 
> Cc: Michael Kubacki 
> Cc: Michael D Kinney 
> Signed-off-by: Michael Kubacki 
> ---
>  .github/workflows/codeql-analysis.yml | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/.github/workflows/codeql-analysis.yml 
> b/.github/workflows/codeql-analysis.yml
> index 791f79d1f014..33cc0bd6b46d 100644
> --- a/.github/workflows/codeql-analysis.yml
> +++ b/.github/workflows/codeql-analysis.yml
> @@ -66,6 +66,8 @@ jobs:
>uses: actions/setup-python@v4
>with:
>  python-version: '3.10.6'
> +cache: 'pip'
> +cache-dependency-path: 'pip-requirements.txt'
> 
>  # Initializes the CodeQL tools for scanning.
>  - name: Initialize CodeQL
> --
> 2.40.0.windows.1
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#102209): https://edk2.groups.io/g/devel/message/102209
> Mute This Topic: https://groups.io/mt/97960009/1643496
> Group Owner: devel+ow...@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [michael.d.kin...@intel.com]
> -=-=-=-=-=-=
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102210): https://edk2.groups.io/g/devel/message/102210
Mute This Topic: https://groups.io/mt/97960009/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 edk2-basetools 0/1] Change BUILD_CFLAGS to CFLAGS to match edk2 BaseTools change

2023-03-30 Thread Rebecca Cran

Good idea. I'll send out a v2 patch with that change.


On 3/30/23 2:09 PM, Kinney, Michael D wrote:

Rebecca,

In order to avoid issues with the order or timing or merges, could
CFLAGS be added in one set of patches and then later remove BUILD_CLAGS
in a second set of patches?

Mike


-Original Message-
From: devel@edk2.groups.io  On Behalf Of Rebecca Cran
Sent: Thursday, March 30, 2023 1:05 PM
To: devel@edk2.groups.io; Barkelew, Bret ; Sean Brogan 
; Chris
Fernald ; Feng, Bob C ; Kubacki, 
Michael ;
Oliver Steffen ; Gao, Liming 
Cc: Rebecca Cran 
Subject: [edk2-devel] [PATCH edk2-basetools 0/1] Change BUILD_CFLAGS to CFLAGS 
to match edk2 BaseTools change

Change BUILD_CFLAGS to CFLAGS to match edk2 BaseTools change

This should be merged at the same time as the edk2 patch that supports
passing CC and CXX to make when building BaseTools.

Rebecca Cran (1):
   Change BUILD_CFLAGS to CFLAGS to match edk2 BaseTools change

  edk2basetools/Workspace/DscBuildData.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

--
2.34.1








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




Re: [edk2-devel] [PATCH edk2-basetools 0/1] Change BUILD_CFLAGS to CFLAGS to match edk2 BaseTools change

2023-03-30 Thread Michael D Kinney
Rebecca,

In order to avoid issues with the order or timing or merges, could
CFLAGS be added in one set of patches and then later remove BUILD_CLAGS
in a second set of patches?

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Rebecca Cran
> Sent: Thursday, March 30, 2023 1:05 PM
> To: devel@edk2.groups.io; Barkelew, Bret ; Sean 
> Brogan ; Chris
> Fernald ; Feng, Bob C ; 
> Kubacki, Michael ;
> Oliver Steffen ; Gao, Liming 
> Cc: Rebecca Cran 
> Subject: [edk2-devel] [PATCH edk2-basetools 0/1] Change BUILD_CFLAGS to 
> CFLAGS to match edk2 BaseTools change
> 
> Change BUILD_CFLAGS to CFLAGS to match edk2 BaseTools change
> 
> This should be merged at the same time as the edk2 patch that supports
> passing CC and CXX to make when building BaseTools.
> 
> Rebecca Cran (1):
>   Change BUILD_CFLAGS to CFLAGS to match edk2 BaseTools change
> 
>  edk2basetools/Workspace/DscBuildData.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --
> 2.34.1
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102207): https://edk2.groups.io/g/devel/message/102207
Mute This Topic: https://groups.io/mt/97959297/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 edk2-basetools 1/1] Change BUILD_CFLAGS to CFLAGS to match edk2 BaseTools change

2023-03-30 Thread Rebecca Cran
In order to support building BaseTools using non-default compilers, a
change is being made in the edk2 BaseTools directory to remove the
'BUILD_' prefix to CC, CXX, CFLAGS etc. so developers can for example
run 'make CC=clang CXX=clang++' to build using clang.

Update DscBuildData.py to generate Makefiles with CFLAGS instead of
BUILD_CFLAGS.

Signed-off-by: Rebecca Cran 
---
 edk2basetools/Workspace/DscBuildData.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/edk2basetools/Workspace/DscBuildData.py 
b/edk2basetools/Workspace/DscBuildData.py
index ff5662f35702..38a5283389f9 100644
--- a/edk2basetools/Workspace/DscBuildData.py
+++ b/edk2basetools/Workspace/DscBuildData.py
@@ -89,7 +89,7 @@ def _IsFieldValueAnArray (Value):
 '''
 
 WindowsCFLAGS = 'CFLAGS = $(CFLAGS) /wd4200 /wd4034 /wd4101 '
-LinuxCFLAGS = 'BUILD_CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable '
+LinuxCFLAGS = 'CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable '
 PcdMakefileEnd = '''
 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common
 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app
-- 
2.34.1



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




[edk2-devel] [PATCH edk2-basetools 0/1] Change BUILD_CFLAGS to CFLAGS to match edk2 BaseTools change

2023-03-30 Thread Rebecca Cran
Change BUILD_CFLAGS to CFLAGS to match edk2 BaseTools change

This should be merged at the same time as the edk2 patch that supports
passing CC and CXX to make when building BaseTools.

Rebecca Cran (1):
  Change BUILD_CFLAGS to CFLAGS to match edk2 BaseTools change

 edk2basetools/Workspace/DscBuildData.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.34.1



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




Re: [edk2-devel] edk2 MdeModulePkg build error

2023-03-30 Thread ritul guru
Thanks, How to install vfr compiler in ubuntu?



*Thanks & RegardsRitul Guru+91-9916513186*


On Thu, Mar 30, 2023 at 6:42 PM Nickle Wang  wrote:

> You probably need to update VFR compiler. REST_STYLE token was introduced
> in below commit long time ago.
>
>
>
>
> https://github.com/tianocore/edk2/commit/1b840718f72711d442ecd7b7e54256a31df8bd20
>
>
>
> Regards,
>
> Nickle
>
>
>
> *From:* devel@edk2.groups.io  * On Behalf Of *ritul
> guru via groups.io
> *Sent:* Thursday, March 30, 2023 4:40 AM
> *To:* edk2-devel-groups-io 
> *Subject:* [edk2-devel] edk2 MdeModulePkg build error
>
>
>
> *External email: Use caution opening links or attachments*
>
>
>
> Hi,
>
> getting below error while building MdeModulePkg, help is appreciated.
>
>
>
> build cmd:
>
> build -p "MdeModulePkg/MdeModulePkg.dsc" -b DEBUG -t GCC5
>
>
>
>
>
> MdeModulePkg/Include
> -I/home/a/src/opensource/edk2/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/c/include
> /home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei/DEBUG/AutoGen.c
> VfrCompile...
> /home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(164):
> WARNING: default
> : default value re-defined with different value
>
> VfrCompile...
> /home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(238):
> ERROR 12288: REST_STYLE
> : unexpected token
>
> VfrCompile...
> /home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(246):
> ERROR 12288: REST_STYLE
> : unexpected token
>
> VfrCompile: ERROR 0003: Error parsing
>   compile error in file
> /home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i
> make: *** [GNUmakefile:461:
> /home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/DEBUG/Vfr.c]
> Error 2
>
>
> build.py...
>  : error 7000: Failed to execute command
> make tbuild
> [/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe]
>
>
>
>
>
> *Thanks & Regards Ritul Guru +91-9916513186*
>
> 
>


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




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

2023-03-30 Thread 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)

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Signed-off-by: Benny Lin 
---
 .gitmodules   |   3 +
 MdePkg/Include/Library/FdtLib.h   | 300 ++
 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 +
 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
 MdePkg/Library/BaseFdtLib/FdtLib.c| 284 
 MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 102 
 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 138 ++
 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 |  17 +-
 MdePkg/MdePkg.dec |   4 +
 MdePkg/MdePkg.dsc |   2 +
 ReadMe.rst|   1 +
 18 files changed, 986 insertions(+), 2 deletions(-)
 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

diff --git a/.gitmodules b/.gitmodules
index 8011a88d9d..5da342e90c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -23,3 +23,6 @@
 [submodule "UnitTestFrameworkPkg/Library/GoogleTestLib/googletest"]
path = UnitTestFrameworkPkg/Library/GoogleTestLib/googletest
url = https://github.com/google/googletest.git
+[submodule "MdePkg/Library/BaseFdtLib/libfdt"]
+   path = MdePkg/Library/BaseFdtLib/libfdt
+   url = https://github.com/devicetree-org/pylibfdt.git
diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h
new file mode 100644
index 00..bcb097b77e
--- /dev/null
+++ b/MdePkg/Include/Library/FdtLib.h
@@ -0,0 +1,300 @@
+/** @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
+///
+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;
+
+#define FDT_GET_HEADER(Fdt, Field)  FDT32_TO_CPU(((CONST FDT_HEADER 
*)(Fdt))->Field)
+
+#define FDT_MAGIC(Fdt)  (FDT_GET_HEADER(Fdt, Magic))
+#define FDT_TOTAL_SIZE(Fdt) (FDT_GET_HEADER(Fdt, TotalSize))
+#define FDT_OFFSET_DT_STRUCT(Fdt)   (FDT_GET_HEADER(Fdt, OffsetDtStruct))
+#define FDT_OFFSET_DT_STRINGS(Fdt)  (FDT_GET_HEADER(Fdt, OffsetDtStrings))
+#define FDT_OFFSET_MEM_RSVMAP(Fdt)  (FDT_GET_HEADER(Fdt, OffsetMemRsvmap))
+#define FDT_VERSION(Fdt)(FDT_GET_HEADER(Fdt, Version))
+#define FDT_LAST_COMP_VERSION(Fdt)  (FDT_GET_HEADER(Fdt, LastCompVersion))
+#define FDT_BOOT_CPUID_PHYS(Fdt)(FDT_GET_HEADER(Fdt, BootCpuidPhys))
+#define FDT_SIZE_DT_STRINGS(Fdt)(FDT_GET_HEADER(Fdt, SizeDtStrings))
+#define FDT_SIZE_DT_STRUCT(Fdt) (FDT_GET_HEADER(Fdt, SizeDtStruct))
+
+/**
+  Create a empty Flattened Device Tree.
+
+  @param[in] Buffer The pointer to allocate a pool for 

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

2023-03-30 Thread 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.

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 d87c8e838e..126c9f0164 100644
--- a/.pytool/CISettings.py
+++ b/.pytool/CISettings.py
@@ -193,6 +193,8 @@ class Settings(CiBuildSettingsManager, 
UpdateSettingsManager, SetupSettingsManag
 "BaseTools/Source/C/BrotliCompress/brotli", False))
 rs.append(RequiredSubmodule(
 "RedfishPkg/Library/JsonLib/jansson", 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 (#102202): https://edk2.groups.io/g/devel/message/102202
Mute This Topic: https://groups.io/mt/97955740/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




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

2023-03-30 Thread 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)

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

Benny Lin (2):
  MdePkg: Support FDT library.
  .pytool: Support FDT library.

 .gitmodules   |   3 +
 .pytool/CISettings.py |   2 +
 MdePkg/Include/Library/FdtLib.h   | 300 ++
 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 +
 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
 MdePkg/Library/BaseFdtLib/FdtLib.c| 284 
 MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 102 
 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 138 ++
 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 |  17 +-
 MdePkg/MdePkg.dec |   4 +
 MdePkg/MdePkg.dsc |   2 +
 ReadMe.rst|   1 +
 19 files changed, 988 insertions(+), 2 deletions(-)
 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 (#102200): https://edk2.groups.io/g/devel/message/102200
Mute This Topic: https://groups.io/mt/97955736/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] Is Xcode5ExceptionHandlerAsm.nasm still needed?

2023-03-30 Thread Ard Biesheuvel
On Thu, 30 Mar 2023 at 18:54, Rebecca Cran  wrote:
>
> On 3/30/23 10:33 AM, Ard Biesheuvel wrote:
> > i'll respin the series I sent out earlier today with that if I manage
> > to build a working OVMF.fd with XCODE5
>
> Let me know if you'd like any help test building/running anything with
> XCODE5 on an Intel or ARM Mac.
>
> I have both a 2012 era Intel Mac Pro and an M1 MacBook Pro.
>

Ah excellent - thanks.

Once I make a bit more progress, I'll cc you [again] on my v2 series,
and I'd appreciate it if you could give that a spin.


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




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

2023-03-30 Thread Michael D Kinney
+Leif
+Andrew

For .gitmodules and ReadMe.rst changes

Mike


> -Original Message-
> From: Lin, Benny 
> Sent: Thursday, March 30, 2023 9:52 AM
> To: devel@edk2.groups.io
> Cc: Lin, Benny ; Kinney, Michael D 
> ; Gao, Liming
> ; Liu, Zhiguang 
> Subject: [PATCH 1/2] MdePkg: Support FDT library.
> 
> 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)
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Signed-off-by: Benny Lin 
> ---
>  .gitmodules   |   3 +
>  MdePkg/Include/Library/FdtLib.h   | 300 ++
>  MdePkg/Library/BaseFdtLib/BaseFdtLib.inf  |  62 +
>  MdePkg/Library/BaseFdtLib/BaseFdtLib.uni  |  14 +
>  MdePkg/Library/BaseFdtLib/FdtLib.c| 284 
>  MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 102 
>  MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 138 ++
>  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 |  17 +-
>  MdePkg/MdePkg.dec |   4 +
>  MdePkg/MdePkg.dsc |   2 +
>  ReadMe.rst|   1 +
>  18 files changed, 986 insertions(+), 2 deletions(-)
>  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
> 
> diff --git a/.gitmodules b/.gitmodules
> index 8011a88d9d..5da342e90c 100644
> --- a/.gitmodules
> +++ b/.gitmodules
> @@ -23,3 +23,6 @@
>  [submodule "UnitTestFrameworkPkg/Library/GoogleTestLib/googletest"]
>   path = UnitTestFrameworkPkg/Library/GoogleTestLib/googletest
>   url = https://github.com/google/googletest.git
> +[submodule "MdePkg/Library/BaseFdtLib/libfdt"]
> + path = MdePkg/Library/BaseFdtLib/libfdt
> + url = https://github.com/devicetree-org/pylibfdt.git
> diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h
> new file mode 100644
> index 00..bcb097b77e
> --- /dev/null
> +++ b/MdePkg/Include/Library/FdtLib.h
> @@ -0,0 +1,300 @@
> +/** @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
> 
> +///
> 
> +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;
> 
> +
> 
> +#define FDT_GET_HEADER(Fdt, Field)  FDT32_TO_CPU(((CONST FDT_HEADER 
> *)(Fdt))->Field)
> 
> +
> 
> +#define FDT_MAGIC(Fdt)  (FDT_GET_HEADER(Fdt, Magic))
> 
> +#define FDT_TOTAL_SIZE(Fdt) (FDT_GET_HEADER(Fdt, TotalSize))
> 
> +#define 

Re: [edk2-devel] Is Xcode5ExceptionHandlerAsm.nasm still needed?

2023-03-30 Thread Rebecca Cran

On 3/30/23 10:33 AM, Ard Biesheuvel wrote:

i'll respin the series I sent out earlier today with that if I manage
to build a working OVMF.fd with XCODE5


Let me know if you'd like any help test building/running anything with 
XCODE5 on an Intel or ARM Mac.


I have both a 2012 era Intel Mac Pro and an M1 MacBook Pro.


--
Rebecca Cran



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




Re: [edk2-devel] Is Xcode5ExceptionHandlerAsm.nasm still needed?

2023-03-30 Thread Ard Biesheuvel
On Thu, 30 Mar 2023 at 18:33, Ard Biesheuvel  wrote:
>
> On Thu, 30 Mar 2023 at 17:04, Ard Biesheuvel  wrote:
> >
> > On Thu, 30 Mar 2023 at 16:25, Ni, Ray  wrote:
> > >
> > > I am afraid they are not template code.
> > > That means if nx is set for data section, they can not be executed.
> > >
> >
> > Currently, we fix up the entries by writing to the .text section at
> > runtime, so NX seems out of scope in any case.
> >
> > Someone should check Xcode5, but for LLD, adding  -Wl,-z,notext is
> > sufficient to work around the error.
>
> As far as I could figure out, '-read_only_relocs suppress' does the
> same thing as '-z notext' on the GNU linker, and permits the code to
> be built with the absolute relocations in the .text section.
>
> AFAICT, this means we don't need the runtime fixups, nor do we need to
> move that code out of .text
>
> i'll respin the series I sent out earlier today with that if I manage
> to build a working OVMF.fd with XCODE5

Hmm seems we are already using that for XCODE5.


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




Re: [edk2-devel] Is Xcode5ExceptionHandlerAsm.nasm still needed?

2023-03-30 Thread Ard Biesheuvel
On Thu, 30 Mar 2023 at 17:04, Ard Biesheuvel  wrote:
>
> On Thu, 30 Mar 2023 at 16:25, Ni, Ray  wrote:
> >
> > I am afraid they are not template code.
> > That means if nx is set for data section, they can not be executed.
> >
>
> Currently, we fix up the entries by writing to the .text section at
> runtime, so NX seems out of scope in any case.
>
> Someone should check Xcode5, but for LLD, adding  -Wl,-z,notext is
> sufficient to work around the error.

As far as I could figure out, '-read_only_relocs suppress' does the
same thing as '-z notext' on the GNU linker, and permits the code to
be built with the absolute relocations in the .text section.

AFAICT, this means we don't need the runtime fixups, nor do we need to
move that code out of .text

i'll respin the series I sent out earlier today with that if I manage
to build a working OVMF.fd with XCODE5


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




Re: [edk2-devel] Is Xcode5ExceptionHandlerAsm.nasm still needed?

2023-03-30 Thread Michael D Kinney
Hi Ray,

No sure if I recall all the details.  Andrew may know them much better than me.

The code gen for XCODE uses PIE and RIP relative addressing, which does not 
require the same number/type of relocation fixups.

Whenever there is a need to access a data element at an absolute address and 
the code is copied to
a new location the RIP relative address will not work.

And if you try to use absolute addressing, you will get an error from XCODE 
linker for an unsupported fixup type.

Mike

From: Ni, Ray 
Sent: Thursday, March 30, 2023 3:16 AM
To: Andrew Fish 
Cc: Kinney, Michael D ; devel@edk2.groups.io; Liu, 
Zhiguang 
Subject: Is Xcode5ExceptionHandlerAsm.nasm still needed?

Andrew,
In UefiCpuPkg\Library\CpuExceptionHandlerLib\X64\, there are two nasm files: 
ExceptionHandlerAsm.nasm and the other XCODE version.

The major diff between the two is the second operand in “mov rax, 
ASM_PFX(CommonInterruptEntry)” is patched at runtime by code, instead of 
relying on linker/loader to fix it.
Can I know more background why it’s needed for XCODE?

Given Apple is switching away from X86 CPU, is the XCODE version still needed?

+ Mike because I found another commit by you for bug: 565 – Fix X64 XCODE5/NASM 
compatibility issue in UefiCpuPkg MpInitLib 
(tianocore.org).

Thanks,
Ray


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102194): https://edk2.groups.io/g/devel/message/102194
Mute This Topic: https://groups.io/mt/97947477/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 v2] IntelFsp2Pkg: LoadMicrocodeDefault() causing unnecessary delay.

2023-03-30 Thread Chiu, Chasel


Thanks for reviewing Ray!
Please see my reply below inline.


> -Original Message-
> From: Ni, Ray 
> Sent: Wednesday, March 29, 2023 10:31 PM
> To: Chiu, Chasel ; devel@edk2.groups.io
> Cc: Desimone, Nathaniel L ; Zeng, Star
> 
> Subject: RE: [PATCH v2] IntelFsp2Pkg: LoadMicrocodeDefault() causing
> unnecessary delay.
> 
> >
> > +   mov   eax, 1
> >
> > +   cpuid
> >
> > +   mov   ecx, MSR_IA32_BIOS_SIGN_ID
> >
> > +   rdmsr ; Get current microcode signature
> >
> > +   xor   eax, eax
> >
> > +   test  edx, edx
> >
> > +   jnz   Exit2
> >
> 1. SDM uses following assembly to read current microcode signature.
> 
> Example 10-9. Assembly Code to Retrieve the Update Revision MOV ECX,
> 08BH ;IA32_BIOS_SIGN_ID XOR EAX, EAX ;clear EAX XOR EDX, EDX ;clear EDX
> WRMSR ;Load 0 to MSR at 8BH MOV EAX, 1 Cupid MOV ECX,
> 08BH ;IA32_BIOS_SIGN_ID rdmsr ;Read Model Specific Register
> 
> 
> Comparing against yours, I think there are two diffs:
> 1). you missed the write-zero to msr 8b


I will add this back.


> 2). you cleared RAX (I don't know why)


This is for returning 0 (EFI_SUCCESS) to caller when microcode already loaded.



> 
> And the existing code "LoadCheck:" actually contains exactly the SDM
> recommended logic to get current microcode revision.
> Why not use that directly?
> 
> > -   jeContinue
> >
> > +   jeDone ; if already one version microcode loaded, go to done
> 
> 2. You changed another behavior: from load all microcodes to load one only.
> Can you separate it in a standalone patch and explain in commit?
> I guess since the 1st check you added will skip loading when cpu microcode
> revision is not 0, so the change here is to align with that behavior.



This is another optimization for reducing unnecessary delay and I explained 
this in commit message (second line).
Because that we usually only put one version microcode for one CPU in FV, if 
LoadMicrocodeDefault() already found one matching microcode and attempted to 
load it, then it should return with either SUCCESS or ERROR and no need to 
parse rest of the microcode files in FV. 

Commit message:
FSP should support the scenario that CPU microcode already loaded before 
calling LoadMicrocodeDefault(), in this case it should return directly without 
spending more time.
Also the LoadMicrocodeDefault() should only attempt to load one version of the 
microcode for current CPU and return.








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




Re: [edk2-devel] [PATCH 0/6] Substract TME-MK KEY_ID_BITS from CPU max PA

2023-03-30 Thread Lendacky, Thomas via groups.io

On 3/29/23 21:26, Ni, Ray wrote:

Tom,
I would assume this won't break any AMD system because the CPUID bit doesn't 
declare this feature.


Right, shouldn't be an issue on AMD systems.

Though it does bring to mind that we should probably do something similar 
for AMD at some point. With SEV there is a 1-bit physical address 
reduction (reported via CPUID) in the guest (but it should only be 
reported in CPUID if the encryption bit is part of the reported max 
physical address).


Thanks,
Tom



Gerd,
This is needed by Intel platform for TME-MK. Can you help to analyze if it has 
any impact to OVMF? I assume no.


Thanks,
Ray

From: devel@edk2.groups.io  On Behalf Of Ni, Ray
Sent: Tuesday, March 28, 2023 10:10 PM
To: devel@edk2.groups.io
Cc: 'Gerd Hoffmann' ; Tom Lendacky 
Subject: Re: [edk2-devel] [PATCH 0/6] Substract TME-MK KEY_ID_BITS from CPU max 
PA

Gerd, Tom,
Can you please review this patch series?

thanks,
ray

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> on behalf of Ni, Ray 
mailto:ray...@intel.com>>
Sent: Wednesday, March 22, 2023 7:56:44 AM
To: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>>
Subject: [edk2-devel] [PATCH 0/6] Substract TME-MK KEY_ID_BITS from CPU max PA


Ray Ni (6):
   MdePkg: Add TME-MK related CPUID and MSR definitions
   UefiCpuPkg/MtrrTest: Only claim CPUID max leaf as 1
   UefiCpuPkg/MtrrLib: Substract TME-MK KEY_ID_BITS from CPU max PA
   UefiCpuPkg/CpuDxe: Refactor to use CPUID definitions
   UefiCpuPkg/CpuDxe: Substract TME-MK KEY_ID_BITS from CPU max PA
   UefiCpuPkg/MtrrTest: Add test cases for TME-MK enable case

  .../Include/Register/Intel/ArchitecturalMsr.h | 106 ++-
  MdePkg/Include/Register/Intel/Cpuid.h |   9 +-
  UefiCpuPkg/CpuDxe/CpuDxe.c|  38 --
  UefiCpuPkg/CpuDxe/CpuDxe.h|   3 +-
  UefiCpuPkg/Library/MtrrLib/MtrrLib.c  |  24 +++-
  .../MtrrLib/UnitTest/MtrrLibUnitTest.c|  18 +--
  .../MtrrLib/UnitTest/MtrrLibUnitTest.h|   3 +-
  UefiCpuPkg/Library/MtrrLib/UnitTest/Support.c | 126 ++
  8 files changed, 278 insertions(+), 49 deletions(-)

--
2.39.1.windows.1










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




Re: [edk2-devel] [Patch 1/1] .azurepipelines/templates: Increase run to shell timeout

2023-03-30 Thread Ard Biesheuvel
On Thu, 30 Mar 2023 at 17:17, Michael D Kinney
 wrote:
>
> Increase the CI agent timeout to boot to UEFI Shell from
> 1 minute to 2 minutes.  There have been a few cases where
> the boot to shell in QEMU has not quite completed in 1
> minute and it is failing the CI check and preventing a PR
> from being merged.
>
> Cc: Sean Brogan 
> Cc: Michael Kubacki 
> Cc: Liming Gao 
> Signed-off-by: Michael D Kinney 

Acked-by: Ard Biesheuvel 

> ---
>  .azurepipelines/templates/platform-build-run-steps.yml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/.azurepipelines/templates/platform-build-run-steps.yml 
> b/.azurepipelines/templates/platform-build-run-steps.yml
> index 087f460d7fec..8be46cda0e2d 100644
> --- a/.azurepipelines/templates/platform-build-run-steps.yml
> +++ b/.azurepipelines/templates/platform-build-run-steps.yml
> @@ -116,7 +116,7 @@ steps:
>  filename: stuart_build
>  arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ 
> parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ 
> parameters.build_arch}} ${{ parameters.build_flags}} ${{ parameters.run_flags 
> }} --FlashOnly
>condition: and(and(gt(variables.pkg_count, 0), succeeded()), 
> eq(variables['Run'], true))
> -  timeoutInMinutes: 1
> +  timeoutInMinutes: 2
>
>  # Copy the build logs to the artifact staging directory
>  - task: CopyFiles@2
> --
> 2.39.1.windows.1
>
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102191): https://edk2.groups.io/g/devel/message/102191
Mute This Topic: https://groups.io/mt/97953071/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] .azurepipelines/templates: Increase run to shell timeout

2023-03-30 Thread Michael D Kinney
Increase the CI agent timeout to boot to UEFI Shell from
1 minute to 2 minutes.  There have been a few cases where
the boot to shell in QEMU has not quite completed in 1
minute and it is failing the CI check and preventing a PR
from being merged.

Cc: Sean Brogan 
Cc: Michael Kubacki 
Cc: Liming Gao 
Signed-off-by: Michael D Kinney 
---
 .azurepipelines/templates/platform-build-run-steps.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.azurepipelines/templates/platform-build-run-steps.yml 
b/.azurepipelines/templates/platform-build-run-steps.yml
index 087f460d7fec..8be46cda0e2d 100644
--- a/.azurepipelines/templates/platform-build-run-steps.yml
+++ b/.azurepipelines/templates/platform-build-run-steps.yml
@@ -116,7 +116,7 @@ steps:
 filename: stuart_build
 arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ 
parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ 
parameters.build_arch}} ${{ parameters.build_flags}} ${{ parameters.run_flags 
}} --FlashOnly
   condition: and(and(gt(variables.pkg_count, 0), succeeded()), 
eq(variables['Run'], true))
-  timeoutInMinutes: 1
+  timeoutInMinutes: 2
 
 # Copy the build logs to the artifact staging directory
 - task: CopyFiles@2
-- 
2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102190): https://edk2.groups.io/g/devel/message/102190
Mute This Topic: https://groups.io/mt/97953071/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] Is Xcode5ExceptionHandlerAsm.nasm still needed?

2023-03-30 Thread Ard Biesheuvel
On Thu, 30 Mar 2023 at 16:25, Ni, Ray  wrote:
>
> I am afraid they are not template code.
> That means if nx is set for data section, they can not be executed.
>

Currently, we fix up the entries by writing to the .text section at
runtime, so NX seems out of scope in any case.

Someone should check Xcode5, but for LLD, adding  -Wl,-z,notext is
sufficient to work around the error.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102189): https://edk2.groups.io/g/devel/message/102189
Mute This Topic: https://groups.io/mt/97947477/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 16/17] MdePkg/PeCoffLib: Capture DLL characteristics fieldis in image context

2023-03-30 Thread Ard Biesheuvel
On Thu, 30 Mar 2023 at 16:45, Michael Kubacki
 wrote:
>
> On 3/27/2023 7:01 AM, Ard Biesheuvel wrote:
> > When loading a PE/COFF image, capture the DLL characteristics fields of
> > the header into our image context structure so we can refer to them when
> > mapping the image.
> >
> > Signed-off-by: Ard Biesheuvel 
> > ---
> >   MdePkg/Include/IndustryStandard/PeImage.h | 13 +-
> >   MdePkg/Include/Library/PeCoffLib.h|  6 +++
> >   MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 46 +++-
> >   3 files changed, 53 insertions(+), 12 deletions(-)
> >
> > diff --git a/MdePkg/Include/IndustryStandard/PeImage.h 
> > b/MdePkg/Include/IndustryStandard/PeImage.h
> > index dd4cc25483bc4bcf..a5b9b848ed391f98 100644
> > --- a/MdePkg/Include/IndustryStandard/PeImage.h
> > +++ b/MdePkg/Include/IndustryStandard/PeImage.h
> > @@ -625,7 +625,8 @@ typedef struct {
> > UINT32FileOffset;  ///< The file pointer to the debug data.
> >
> >   } EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;
> >
> >
> >
> > -#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW  2///< The Visual C++ debug 
> > information.
> >
> > +#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW   2///< The Visual 
> > C++ debug information.
> >
> > +#define EFI_IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS  20
> >
> >
> >
> >   ///
> >
> >   /// Debug Data Structure defined in Microsoft C++.
> >
> > @@ -669,6 +670,16 @@ typedef struct {
> > //
> >
> >   } EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY;
> >
> >
> >
> > +///
> >
> > +/// Extended DLL Characteristics
> >
> > +///
> >
> > +#define EFI_IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT  0x0001
> >
> > +#define EFI_IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT  0x0040
> >
> > +
> >
> > +typedef struct {
> >
> > +  UINT16DllCharacteristicsEx;
> >
> > +} EFI_IMAGE_DEBUG_EX_DLLCHARACTERISTICS_ENTRY;
> >
> > +
> >
> >   ///
> >
> >   /// Resource format.
> >
> >   ///
> >
> > diff --git a/MdePkg/Include/Library/PeCoffLib.h 
> > b/MdePkg/Include/Library/PeCoffLib.h
> > index b45879453785c77d..d21c932076c072f6 100644
> > --- a/MdePkg/Include/Library/PeCoffLib.h
> > +++ b/MdePkg/Include/Library/PeCoffLib.h
> > @@ -171,6 +171,12 @@ typedef struct {
> > ///
> >
> > UINT16  ImageType;
> >
> > ///
> >
> > +  /// Set by PeCoffLoaderGetImageInfo() to the DLL flags stored in the 
> > PE/COFF header and
> >
> > +  /// in the DllCharacteristicsEx debug table.
> >
> > +  ///
> >
> > +  UINT16  DllCharacteristics;
> >
> > +  UINT16  DllCharacteristicsEx;
> >
> I know DllCharacteristics has a size of 2 in the spec, but the
> DllCharacteristicsEx is defined as 4 bytes. I will try to get a spec
> update to clarify this.
>

Thanks. I'll change this to 4 in the next respin.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102188): https://edk2.groups.io/g/devel/message/102188
Mute This Topic: https://groups.io/mt/97879303/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 16/17] MdePkg/PeCoffLib: Capture DLL characteristics fieldis in image context

2023-03-30 Thread Michael Kubacki

On 3/27/2023 7:01 AM, Ard Biesheuvel wrote:

When loading a PE/COFF image, capture the DLL characteristics fields of
the header into our image context structure so we can refer to them when
mapping the image.

Signed-off-by: Ard Biesheuvel 
---
  MdePkg/Include/IndustryStandard/PeImage.h | 13 +-
  MdePkg/Include/Library/PeCoffLib.h|  6 +++
  MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 46 +++-
  3 files changed, 53 insertions(+), 12 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/PeImage.h 
b/MdePkg/Include/IndustryStandard/PeImage.h
index dd4cc25483bc4bcf..a5b9b848ed391f98 100644
--- a/MdePkg/Include/IndustryStandard/PeImage.h
+++ b/MdePkg/Include/IndustryStandard/PeImage.h
@@ -625,7 +625,8 @@ typedef struct {
UINT32FileOffset;  ///< The file pointer to the debug data.

  } EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;

  


-#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW  2///< The Visual C++ debug 
information.

+#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW   2///< The Visual C++ 
debug information.

+#define EFI_IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS  20

  


  ///

  /// Debug Data Structure defined in Microsoft C++.

@@ -669,6 +670,16 @@ typedef struct {
//

  } EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY;

  


+///

+/// Extended DLL Characteristics

+///

+#define EFI_IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT  0x0001

+#define EFI_IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT  0x0040

+

+typedef struct {

+  UINT16DllCharacteristicsEx;

+} EFI_IMAGE_DEBUG_EX_DLLCHARACTERISTICS_ENTRY;

+

  ///

  /// Resource format.

  ///

diff --git a/MdePkg/Include/Library/PeCoffLib.h 
b/MdePkg/Include/Library/PeCoffLib.h
index b45879453785c77d..d21c932076c072f6 100644
--- a/MdePkg/Include/Library/PeCoffLib.h
+++ b/MdePkg/Include/Library/PeCoffLib.h
@@ -171,6 +171,12 @@ typedef struct {
///

UINT16  ImageType;

///

+  /// Set by PeCoffLoaderGetImageInfo() to the DLL flags stored in the PE/COFF 
header and

+  /// in the DllCharacteristicsEx debug table.

+  ///

+  UINT16  DllCharacteristics;

+  UINT16  DllCharacteristicsEx;

I know DllCharacteristics has a size of 2 in the spec, but the 
DllCharacteristicsEx is defined as 4 bytes. I will try to get a spec 
update to clarify this.



+  ///

/// Set by PeCoffLoaderGetImageInfo() to TRUE if the PE/COFF image does not 
contain

/// relocation information.

///

diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c 
b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index 97a8aaf8c73d3e3c..4b71176a0c7c2ed0 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -308,10 +308,11 @@ PeCoffLoaderGetPeHeader (
//

// Use PE32 offset

//

-  ImageContext->ImageType= Hdr.Pe32->OptionalHeader.Subsystem;

-  ImageContext->ImageSize= 
(UINT64)Hdr.Pe32->OptionalHeader.SizeOfImage;

-  ImageContext->SectionAlignment = 
Hdr.Pe32->OptionalHeader.SectionAlignment;

-  ImageContext->SizeOfHeaders= Hdr.Pe32->OptionalHeader.SizeOfHeaders;

+  ImageContext->ImageType  = Hdr.Pe32->OptionalHeader.Subsystem;

+  ImageContext->ImageSize  = 
(UINT64)Hdr.Pe32->OptionalHeader.SizeOfImage;

+  ImageContext->SectionAlignment   = 
Hdr.Pe32->OptionalHeader.SectionAlignment;

+  ImageContext->SizeOfHeaders  = 
Hdr.Pe32->OptionalHeader.SizeOfHeaders;

+  ImageContext->DllCharacteristics = 
Hdr.Pe32->OptionalHeader.DllCharacteristics;

  } else if (Hdr.Pe32->OptionalHeader.Magic == 
EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {

//

// 1. Check FileHeader.NumberOfRvaAndSizes filed.

@@ -429,10 +430,11 @@ PeCoffLoaderGetPeHeader (
//

// Use PE32+ offset

//

-  ImageContext->ImageType= Hdr.Pe32Plus->OptionalHeader.Subsystem;

-  ImageContext->ImageSize= 
(UINT64)Hdr.Pe32Plus->OptionalHeader.SizeOfImage;

-  ImageContext->SectionAlignment = 
Hdr.Pe32Plus->OptionalHeader.SectionAlignment;

-  ImageContext->SizeOfHeaders= 
Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders;

+  ImageContext->ImageType  = 
Hdr.Pe32Plus->OptionalHeader.Subsystem;

+  ImageContext->ImageSize  = 
(UINT64)Hdr.Pe32Plus->OptionalHeader.SizeOfImage;

+  ImageContext->SectionAlignment   = 
Hdr.Pe32Plus->OptionalHeader.SectionAlignment;

+  ImageContext->SizeOfHeaders  = 
Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders;

+  ImageContext->DllCharacteristics = 
Hdr.Pe32Plus->OptionalHeader.DllCharacteristics;

  } else {

ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;

return RETURN_UNSUPPORTED;

@@ -545,8 +547,9 @@ PeCoffLoaderGetPeHeader (
Retrieves information about a PE/COFF image.

  


Computes the PeCoffHeaderOffset, IsTeImage, ImageType, ImageAddress, 
ImageSize,

-  DestinationAddress, RelocationsStripped, 

Re: [edk2-devel] Is Xcode5ExceptionHandlerAsm.nasm still needed?

2023-03-30 Thread Ni, Ray
I am afraid they are not template code.
That means if nx is set for data section, they can not be executed.


thanks,
ray

From: Ard Biesheuvel 
Sent: Thursday, March 30, 2023 7:47:03 PM
To: devel@edk2.groups.io ; Ni, Ray ; 
Rebecca Cran 
Cc: Andrew Fish ; Kinney, Michael D 
; Liu, Zhiguang 
Subject: Re: [edk2-devel] Is Xcode5ExceptionHandlerAsm.nasm still needed?

(cc Rebecca)

On Thu, 30 Mar 2023 at 12:48, Ard Biesheuvel  wrote:
>
> On Thu, 30 Mar 2023 at 12:16, Ni, Ray  wrote:
> >
> > Andrew,
> >
> > In UefiCpuPkg\Library\CpuExceptionHandlerLib\X64\, there are two nasm 
> > files: ExceptionHandlerAsm.nasm and the other XCODE version.
> >
> >
> >
> > The major diff between the two is the second operand in “mov rax, 
> > ASM_PFX(CommonInterruptEntry)” is patched at runtime by code, instead of 
> > relying on linker/loader to fix it.
> >
> > Can I know more background why it’s needed for XCODE?
> >
> >
> >
> > Given Apple is switching away from X86 CPU, is the XCODE version still 
> > needed?
> >
> >
> >
> > + Mike because I found another commit by you for bug: 565 – Fix X64 
> > XCODE5/NASM compatibility issue in UefiCpuPkg MpInitLib (tianocore.org).
> >
> >
>
>
> Yes, we still need it, also for non-Xcode clang + lld
>
> The problem is that the little code templates use absolute addressing
> to refer to the jump targets. This is necessary because these
> templates are copied into the vector table, and so they are moved
> independently from the code they refer to, and so relative addressing
> is not an option here.
>
> One thing I haven't tried yet is to emit the template code into .data
> instead of .text, which /should/ be fine given that the template code
> is never executed directly, only the copied versions are executed.

I had a quick go at this, and the change below appears to work: it
moves the template code into .data, and changes the absolute
references to relative ones in the code that executes from where it
gets loaded.

I'm not sure how to test this, though.



--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -27,7 +27,6 @@ extern ASM_PFX(CommonExceptionHandler)
 SECTION .data

 DEFAULT REL
-SECTION .text

 ALIGN   8

@@ -51,6 +50,9 @@ HookAfterStubHeaderBegin:
 pushrax
 mov rax, HookAfterStubHeaderEnd
 jmp rax
+
+SECTION .text
+
 HookAfterStubHeaderEnd:
 mov rax, rsp
 and sp,  0xfff0; make sure 16-byte aligned for
exception context
@@ -276,8 +278,7 @@ DrFinish:
 ; and make sure RSP is 16-byte aligned
 ;
 sub rsp, 4 * 8 + 8
-mov rax, ASM_PFX(CommonExceptionHandler)
-callrax
+callASM_PFX(CommonExceptionHandler)
 add rsp, 4 * 8 + 8

 cli
@@ -384,10 +385,10 @@ DoIret:
 ; comments here for definition of address map
 global ASM_PFX(AsmGetTemplateAddressMap)
 ASM_PFX(AsmGetTemplateAddressMap):
-mov rax, AsmIdtVectorBegin
+lea rax, AsmIdtVectorBegin
 mov qword [rcx], rax
 mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
-mov rax, HookAfterStubHeaderBegin
+lea rax, HookAfterStubHeaderBegin
 mov qword [rcx + 0x10], rax
 ret


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102186): https://edk2.groups.io/g/devel/message/102186
Mute This Topic: https://groups.io/mt/97947477/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 4/4] UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version

2023-03-30 Thread Ard Biesheuvel
This library is no longer used or needed, so let's remove it.

Signed-off-by: Ard Biesheuvel 
---
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 | 65 
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
 | 18 --
 2 files changed, 83 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
deleted file mode 100644
index c58fbb0d74500e48..
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
+++ /dev/null
@@ -1,65 +0,0 @@
-## @file
-#  CPU Exception Handler library instance for SEC/PEI modules.
-#
-#  Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
-#  Copyright (c) 2012 - 2022, Intel Corporation. All rights reserved.
-#  SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#  This is the XCODE5 variant of the SEC/PEI CpuExceptionHandlerLib. This
-#  variant performs binary patching to fix up addresses that allow the
-#  XCODE5 toolchain to be used.
-#
-##
-
-[Defines]
-  INF_VERSION= 0x00010005
-  BASE_NAME  = Xcode5SecPeiCpuExceptionHandlerLib
-  MODULE_UNI_FILE= Xcode5SecPeiCpuExceptionHandlerLib.uni
-  FILE_GUID  = 49C481AF-1621-42F3-8FA1-27C64143E304
-  MODULE_TYPE= PEIM
-  VERSION_STRING = 1.1
-  LIBRARY_CLASS  = CpuExceptionHandlerLib|SEC PEI_CORE PEIM
-
-#
-# The following information is for reference only and not required by the 
build tools.
-#
-#  VALID_ARCHITECTURES   = IA32 X64
-#
-
-[Sources.Ia32]
-  Ia32/ExceptionHandlerAsm.nasm
-  Ia32/ExceptionTssEntryAsm.nasm
-  Ia32/ArchExceptionHandler.c
-  Ia32/ArchInterruptDefs.h
-
-[Sources.X64]
-  X64/SecPeiExceptionHandlerAsm.nasm
-  X64/ArchExceptionHandler.c
-  X64/ArchInterruptDefs.h
-
-[Sources.common]
-  CpuExceptionCommon.h
-  CpuExceptionCommon.c
-  SecPeiCpuException.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  UefiCpuPkg/UefiCpuPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  SerialPortLib
-  PrintLib
-  LocalApicLib
-  PeCoffGetEntryPointLib
-  CcExitLib
-
-[Pcd]
-  gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize
-
-[FeaturePcd]
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard## CONSUMES
-
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
deleted file mode 100644
index a63b25f39d992775..
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
+++ /dev/null
@@ -1,18 +0,0 @@
-// /** @file
-// XCODE5 CPU Exception Handler library instance for SEC/PEI modules.
-//
-// CPU Exception Handler library instance for SEC/PEI modules when built
-// using the XCODE5 toolchain.
-//
-// Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
-// Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
-//
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler 
library instance for SEC/PEI modules with the XCODE5 toolchain."
-
-#string STR_MODULE_DESCRIPTION  #language en-US "CPU Exception Handler 
library instance for SEC/PEI modules with the XCODE5 toolchain."
-
-- 
2.39.2



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




[edk2-devel] [PATCH 3/4] OvmfPkg: Drop special Xcode5 version of exception handler library

2023-03-30 Thread Ard Biesheuvel
The generic and XCODE5 versions of this library are now identical, so
drop the special case. The library will be removed entirely in a
subsequent patch.

Signed-off-by: Ard Biesheuvel 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc | 4 
 OvmfPkg/CloudHv/CloudHvX64.dsc   | 4 
 OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 
 OvmfPkg/Microvm/MicrovmX64.dsc   | 4 
 OvmfPkg/OvmfPkgIa32.dsc  | 4 
 OvmfPkg/OvmfPkgIa32X64.dsc   | 4 
 OvmfPkg/OvmfPkgX64.dsc   | 4 
 OvmfPkg/OvmfXen.dsc  | 4 
 8 files changed, 32 deletions(-)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index c005e474dd826759..943c4eed9831a1c5 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -224,11 +224,7 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
-!if $(TOOL_CHAIN_TAG) == "XCODE5"
-  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
-!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
-!endif
   CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLib.inf
 
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index b9820cc14bee0693..cc2dd925bc940ea8 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -270,11 +270,7 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
-!if $(TOOL_CHAIN_TAG) == "XCODE5"
-  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
-!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
-!endif
   CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLib.inf
 
diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
index 5c56858d063b96bf..f734409055400859 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
@@ -238,11 +238,7 @@ [LibraryClasses.common.SEC]
   
ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
-!if $(TOOL_CHAIN_TAG) == "XCODE5"
-  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
-!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
-!endif
   CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLib.inf
   
PrePiHobListPointerLib|OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointerLibTdx.inf
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 384b0b7afc74e90f..e9aab515592ffcec 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -272,11 +272,7 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
-!if $(TOOL_CHAIN_TAG) == "XCODE5"
-  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
-!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
-!endif
   CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLib.inf
 
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index a6db902f54ece86f..86177bb948999435 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -275,11 +275,7 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
-!if $(TOOL_CHAIN_TAG) == "XCODE5"
-  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
-!else

[edk2-devel] [PATCH 2/4] UefiCpuPkg/CpuExceptionHandlerLib: Remove pointless runtime fixups

2023-03-30 Thread Ard Biesheuvel
The XCODE5 compatible version of ExceptionHandlerAsm, which is in fact
used for all builds of this library except the SecPei flavor, performs
runtime fixups that are not really necessary: we can just move the code
templates into the .data section where absolute relocations are
permitted.

So simplify the code, and rename it to ExceptionHandlerAsm.nasm to
reflect the reality that this code is not Xcode5 specific.

Signed-off-by: Ard Biesheuvel 
---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
|  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
|  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
|  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm 
=> ExceptionHandlerAsm.nasm} | 22 +---
 4 files changed, 8 insertions(+), 20 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
index d0f82095cf926e99..1b2dde746d154706 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h
 
 [Sources.X64]
-  X64/Xcode5ExceptionHandlerAsm.nasm
+  X64/ExceptionHandlerAsm.nasm
   X64/ArchExceptionHandler.c
   X64/ArchInterruptDefs.h
 
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
index 5339f8e604045801..86248cea3e97cedb 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h
 
 [Sources.X64]
-  X64/Xcode5ExceptionHandlerAsm.nasm
+  X64/ExceptionHandlerAsm.nasm
   X64/ArchExceptionHandler.c
   X64/ArchInterruptDefs.h
 
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
index 8f8a5dab79303f87..0eed594be8660302 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h
 
 [Sources.X64]
-  X64/Xcode5ExceptionHandlerAsm.nasm
+  X64/ExceptionHandlerAsm.nasm
   X64/ArchExceptionHandler.c
   X64/ArchInterruptDefs.h
 
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
similarity index 92%
rename from 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm
rename to UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
index 957478574253e619..55a58c6a58858c81 100644
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -49,7 +49,6 @@ extern ASM_PFX(CommonExceptionHandler)
 SECTION .data
 
 DEFAULT REL
-SECTION .text
 
 ALIGN   8
 
@@ -59,7 +58,7 @@ AsmIdtVectorBegin:
 %rep  256
 pushstrict dword %[Vector] ; This instruction pushes sign-extended 
8-byte value on stack
 pushrax
-mov rax, strict qword 0; mov rax, ASM_PFX(CommonInterruptEntry)
+mov rax, ASM_PFX(CommonInterruptEntry)
 jmp rax
 %assign Vector Vector+1
 %endrep
@@ -69,9 +68,11 @@ HookAfterStubHeaderBegin:
 pushstrict dword 0  ; 0 will be fixed
 VectorNum:
 pushrax
-mov rax, strict qword 0 ; mov rax, HookAfterStubHeaderEnd
-JmpAbsoluteAddress:
+mov rax, HookAfterStubHeaderEnd
 jmp rax
+
+SECTION .text
+
 HookAfterStubHeaderEnd:
 mov rax, rsp
 and sp,  0xfff0; make sure 16-byte aligned for exception 
context
@@ -456,19 +457,6 @@ ASM_PFX(AsmGetTemplateAddressMap):
 mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 256
 lea rax, [HookAfterStubHeaderBegin]
 mov qword [rcx + 0x10], rax
-
-; Fix up CommonInterruptEntry address
-learax, [ASM_PFX(CommonInterruptEntry)]
-learcx, [AsmIdtVectorBegin]
-%rep  256
-movqword [rcx + (JmpAbsoluteAddress - 8 - HookAfterStubHeaderBegin)], 
rax
-addrcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) / 256
-%endrep
-; Fix up HookAfterStubHeaderEnd
-learax, [HookAfterStubHeaderEnd]
-learcx, [JmpAbsoluteAddress]
-movqword [rcx - 8], rax
-
 ret
 
 
;-
-- 
2.39.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages 

[edk2-devel] [PATCH 1/4] UefiCpuPkg/CpuExceptionHandlerLib: Create LLD compatible SEC/PEI version

2023-03-30 Thread Ard Biesheuvel
Currently, we use the non-Xcode5 version of ExceptionHandlerAsm.nasm
only for the SEC and PEI phases, and this version is not compatible with
the LLD linker, which does not permit absolute relocations in read-only
sections.

Let's rename the .nasm file to reflect this, and tweak it so that LLD
accepts it as well. This involves using relative references where
possible, and moving the template code (which is never executed
directly) into the .data section.

Since this makes the generic version compatible with the XCODE5 version,
let's use this [smaller] version for XCODE5 builds too.

Signed-off-by: Ard Biesheuvel 
---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf 
|  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{ExceptionHandlerAsm.nasm => 
SecPeiExceptionHandlerAsm.nasm} | 11 ++-
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
   |  2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
index df44371fe018e06d..10c5c5f2e5d203f6 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
@@ -28,7 +28,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h
 
 [Sources.X64]
-  X64/ExceptionHandlerAsm.nasm
+  X64/SecPeiExceptionHandlerAsm.nasm
   X64/ArchExceptionHandler.c
   X64/ArchInterruptDefs.h
 
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/SecPeiExceptionHandlerAsm.nasm
similarity index 95%
rename from 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
rename to 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/SecPeiExceptionHandlerAsm.nasm
index aaf8d622e6f3b8f1..84d51bf6302e1dcb 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
+++ 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/SecPeiExceptionHandlerAsm.nasm
@@ -27,7 +27,6 @@ extern ASM_PFX(CommonExceptionHandler)
 SECTION .data
 
 DEFAULT REL
-SECTION .text
 
 ALIGN   8
 
@@ -51,6 +50,9 @@ HookAfterStubHeaderBegin:
 pushrax
 mov rax, HookAfterStubHeaderEnd
 jmp rax
+
+SECTION .text
+
 HookAfterStubHeaderEnd:
 mov rax, rsp
 and sp,  0xfff0; make sure 16-byte aligned for exception 
context
@@ -276,8 +278,7 @@ DrFinish:
 ; and make sure RSP is 16-byte aligned
 ;
 sub rsp, 4 * 8 + 8
-mov rax, ASM_PFX(CommonExceptionHandler)
-callrax
+callASM_PFX(CommonExceptionHandler)
 add rsp, 4 * 8 + 8
 
 cli
@@ -384,10 +385,10 @@ DoIret:
 ; comments here for definition of address map
 global ASM_PFX(AsmGetTemplateAddressMap)
 ASM_PFX(AsmGetTemplateAddressMap):
-mov rax, AsmIdtVectorBegin
+lea rax, [AsmIdtVectorBegin]
 mov qword [rcx], rax
 mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
-mov rax, HookAfterStubHeaderBegin
+lea rax, [HookAfterStubHeaderBegin]
 mov qword [rcx + 0x10], rax
 ret
 
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
index 619b39d7f1de9ae3..c58fbb0d74500e48 100644
--- 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
+++ 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
@@ -33,7 +33,7 @@ [Sources.Ia32]
   Ia32/ArchInterruptDefs.h
 
 [Sources.X64]
-  X64/Xcode5ExceptionHandlerAsm.nasm
+  X64/SecPeiExceptionHandlerAsm.nasm
   X64/ArchExceptionHandler.c
   X64/ArchInterruptDefs.h
 
-- 
2.39.2



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




[edk2-devel] [PATCH 0/4] UefiCpuPkg, OvmfPkf: Simplify CpuExceptionHandlerLib

2023-03-30 Thread Ard Biesheuvel
We have a special version of CpuExceptionHandlerLib for XCODE5, whose
linker (LLD) does not permit absolute symbol references in read-only
sections.

Instead of fixing this up at runtime (which is done by writing the fixed
up values to the .text section), move the code templates into .data
instead. This way, they can be fixed up by the PE/COFF loader as usual.

Given that this is a net improvement (as we no longer write to the
.text section at runtime), apply the fix for all versions of this
library, and drop the special XCODE5 version entirely.


Cc: Ni, Ray 
Cc: Andrew Fish 
Cc: "Kinney, Michael D" 
Cc: "Liu, Zhiguang" 
Cc: Rebecca Cran 
Cc: Tom Lendacky 

Ard Biesheuvel (4):
  UefiCpuPkg/CpuExceptionHandlerLib: Create LLD compatible SEC/PEI
version
  UefiCpuPkg/CpuExceptionHandlerLib: Remove pointless runtime fixups
  OvmfPkg: Drop special Xcode5 version of exception handler library
  UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version

 OvmfPkg/AmdSev/AmdSevX64.dsc   
  |   4 -
 OvmfPkg/CloudHv/CloudHvX64.dsc 
  |   4 -
 OvmfPkg/IntelTdx/IntelTdxX64.dsc   
  |   4 -
 OvmfPkg/Microvm/MicrovmX64.dsc 
  |   4 -
 OvmfPkg/OvmfPkgIa32.dsc
  |   4 -
 OvmfPkg/OvmfPkgIa32X64.dsc 
  |   4 -
 OvmfPkg/OvmfPkgX64.dsc 
  |   4 -
 OvmfPkg/OvmfXen.dsc
  |   4 -
 UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
  |   2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
  |   2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf 
  |   2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
  |   2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm 
  |  96 +++---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm 
=> SecPeiExceptionHandlerAsm.nasm} | 107 +++-
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 |  65 
 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
 |  18 
 16 files changed, 100 insertions(+), 226 deletions(-)
 rename 
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm 
=> SecPeiExceptionHandlerAsm.nasm} (70%)
 delete mode 100644 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
 delete mode 100644 
UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni

-- 
2.39.2



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




Re: [edk2-devel] [RESEND v1 1/1] CI: Use Fedora-37 (gcc12) image for Linux jobs

2023-03-30 Thread Dhaval Sharma
Hi Oliver,
when is this patch expected to get merged? I need to use CI with GCC12 in order 
to get my changes through for this
https://edk2.groups.io/g/devel/message/101795?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Ccmo%2C20%2C2%2C0%2C97826395
=D


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




Re: [edk2-devel] edk2 MdeModulePkg build error

2023-03-30 Thread Nickle Wang via groups.io
You probably need to update VFR compiler. REST_STYLE token was introduced in 
below commit long time ago.

https://github.com/tianocore/edk2/commit/1b840718f72711d442ecd7b7e54256a31df8bd20

Regards,
Nickle

From: devel@edk2.groups.io  On Behalf Of ritul guru via 
groups.io
Sent: Thursday, March 30, 2023 4:40 AM
To: edk2-devel-groups-io 
Subject: [edk2-devel] edk2 MdeModulePkg build error

External email: Use caution opening links or attachments

Hi,
getting below error while building MdeModulePkg, help is appreciated.

build cmd:
build -p "MdeModulePkg/MdeModulePkg.dsc" -b DEBUG -t GCC5


MdeModulePkg/Include 
-I/home/a/src/opensource/edk2/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/c/include
 
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei/DEBUG/AutoGen.c
VfrCompile...
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(164):
 WARNING: default
: default value re-defined with different value

VfrCompile...
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(238):
 ERROR 12288: REST_STYLE
: unexpected token

VfrCompile...
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(246):
 ERROR 12288: REST_STYLE
: unexpected token

VfrCompile: ERROR 0003: Error parsing
  compile error in file 
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i
make: *** [GNUmakefile:461: 
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/DEBUG/Vfr.c]
 Error 2


build.py...
 : error 7000: Failed to execute command
make tbuild 
[/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe]

Thanks & Regards
Ritul Guru
+91-9916513186



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




[edk2-devel] edk2 MdeModulePkg build error

2023-03-30 Thread ritul guru
Hi,
getting below error while building MdeModulePkg, help is appreciated.

build cmd:
build -p "MdeModulePkg/MdeModulePkg.dsc" -b DEBUG -t GCC5


MdeModulePkg/Include
-I/home/a/src/opensource/edk2/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/c/include
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei/DEBUG/AutoGen.c
VfrCompile...
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(164):
WARNING: default
: default value re-defined with different value

VfrCompile...
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(238):
ERROR 12288: REST_STYLE
: unexpected token

VfrCompile...
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i(246):
ERROR 12288: REST_STYLE
: unexpected token

VfrCompile: ERROR 0003: Error parsing
  compile error in file
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/OUTPUT/Vfr.i
make: *** [GNUmakefile:461:
/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe/DEBUG/Vfr.c]
Error 2


build.py...
 : error 7000: Failed to execute command
make tbuild
[/home/a/src/opensource/edk2/Build/MdeModule/DEBUG_GCC5/IA32/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe]




*Thanks & RegardsRitul Guru+91-9916513186*


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




[edk2-devel] [PATCH] ShellPkg: Fixed system hang issue when executing ping6 command cross network segment in EFI Shell.

2023-03-30 Thread Kanagavel S via groups.io
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4376

While shell is polling to send/receive ICMP packets, Private ->status is not 
updated for below scenario,
Considering 10 packets are transferred and it's RTT time is between 1764-1812 
ms .In this 10 packets 2 or 3 packets
are lost in between ping communication and reported timeout issue and last one 
is successful packet.
In this case failed packet is reported before the last successful packet hence 
,private ->status is not
updated with either success or EFI_TIMEOUT.
Counted Fail count of Ping communication ,when private->Txinfo list is empty 
and sum of failcount and receive
count equals to the total packets private->status has been updated to timeout.

Signed-off-by: Kanagavel S 
---
 ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
index e0b58d4b85..50d1bb6e1d 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
@@ -2,6 +2,7 @@
   The implementation for Ping6 application.



   Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.

+  Copyright (c) 1985 - 2023, American Megatrends International LLC.



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



@@ -92,7 +93,7 @@ SHELL_PARAM_ITEM  Ping6ParamList[] = {
 CONST CHAR16   *mIp6DstString;

 CONST CHAR16   *mIp6SrcString;

 EFI_CPU_ARCH_PROTOCOL  *Cpu = NULL;

-

+UINT32  gFailCount = 0;

 /**

   RTT timer tick routine.



@@ -457,6 +458,9 @@ Ping6OnEchoReplyReceived6 (
 ON_EXIT:



   if (Private->RxCount < Private->SendNum) {

+  if (IsListEmpty (>TxList) && ((Private->RxCount + gFailCount) 
== Private->SendNum)){

+  Private->Status = EFI_TIMEOUT;

+  }

 //

 // Continue to receive icmp6 echo reply packets.

 //

@@ -715,7 +719,7 @@ Ping6OnTimerRoutine6 (
   // Remove the timeout icmp6 echo request from list.

   //

   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_TIMEOUT), 
gShellNetwork2HiiHandle, TxInfo->SequenceNum);

-

+  gFailCount++;

   RemoveEntryList (>Link);

   Ping6DestroyTxInfo (TxInfo);



@@ -1048,6 +1052,7 @@ ShellPing6 (
   SHELL_STATUS ShellStatus;



   ShellStatus = SHELL_SUCCESS;

+  gFailCount = 0;

   Private = AllocateZeroPool (sizeof (PING6_PRIVATE_DATA));



   if (Private == NULL) {

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


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




Re: [edk2-devel] Is Xcode5ExceptionHandlerAsm.nasm still needed?

2023-03-30 Thread Ard Biesheuvel
(cc Rebecca)

On Thu, 30 Mar 2023 at 12:48, Ard Biesheuvel  wrote:
>
> On Thu, 30 Mar 2023 at 12:16, Ni, Ray  wrote:
> >
> > Andrew,
> >
> > In UefiCpuPkg\Library\CpuExceptionHandlerLib\X64\, there are two nasm 
> > files: ExceptionHandlerAsm.nasm and the other XCODE version.
> >
> >
> >
> > The major diff between the two is the second operand in “mov rax, 
> > ASM_PFX(CommonInterruptEntry)” is patched at runtime by code, instead of 
> > relying on linker/loader to fix it.
> >
> > Can I know more background why it’s needed for XCODE?
> >
> >
> >
> > Given Apple is switching away from X86 CPU, is the XCODE version still 
> > needed?
> >
> >
> >
> > + Mike because I found another commit by you for bug: 565 – Fix X64 
> > XCODE5/NASM compatibility issue in UefiCpuPkg MpInitLib (tianocore.org).
> >
> >
>
>
> Yes, we still need it, also for non-Xcode clang + lld
>
> The problem is that the little code templates use absolute addressing
> to refer to the jump targets. This is necessary because these
> templates are copied into the vector table, and so they are moved
> independently from the code they refer to, and so relative addressing
> is not an option here.
>
> One thing I haven't tried yet is to emit the template code into .data
> instead of .text, which /should/ be fine given that the template code
> is never executed directly, only the copied versions are executed.

I had a quick go at this, and the change below appears to work: it
moves the template code into .data, and changes the absolute
references to relative ones in the code that executes from where it
gets loaded.

I'm not sure how to test this, though.



--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -27,7 +27,6 @@ extern ASM_PFX(CommonExceptionHandler)
 SECTION .data

 DEFAULT REL
-SECTION .text

 ALIGN   8

@@ -51,6 +50,9 @@ HookAfterStubHeaderBegin:
 pushrax
 mov rax, HookAfterStubHeaderEnd
 jmp rax
+
+SECTION .text
+
 HookAfterStubHeaderEnd:
 mov rax, rsp
 and sp,  0xfff0; make sure 16-byte aligned for
exception context
@@ -276,8 +278,7 @@ DrFinish:
 ; and make sure RSP is 16-byte aligned
 ;
 sub rsp, 4 * 8 + 8
-mov rax, ASM_PFX(CommonExceptionHandler)
-callrax
+callASM_PFX(CommonExceptionHandler)
 add rsp, 4 * 8 + 8

 cli
@@ -384,10 +385,10 @@ DoIret:
 ; comments here for definition of address map
 global ASM_PFX(AsmGetTemplateAddressMap)
 ASM_PFX(AsmGetTemplateAddressMap):
-mov rax, AsmIdtVectorBegin
+lea rax, AsmIdtVectorBegin
 mov qword [rcx], rax
 mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
-mov rax, HookAfterStubHeaderBegin
+lea rax, HookAfterStubHeaderBegin
 mov qword [rcx + 0x10], rax
 ret


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102176): https://edk2.groups.io/g/devel/message/102176
Mute This Topic: https://groups.io/mt/97947477/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 1/1] OvmfPkg/SmbiosPlatformDxe: use PcdFirmware*

2023-03-30 Thread Gerd Hoffmann
On Thu, Mar 30, 2023 at 12:18:35PM +0200, Fiona Ebner wrote:
> Am 30.03.23 um 10:53 schrieb Gerd Hoffmann:
> > On Thu, Mar 30, 2023 at 10:04:02AM +0200, Fiona Ebner wrote:
> >> Am 28.11.22 um 06:40 schrieb Gerd Hoffmann:
> >> Hi,
> >> after this patch, certain SMBIOS values are different[2]. We got a
> >> report that the different vendor causes issues with hardware keys[0].
> >> And, as I learned from the patch fixing it, the missing date can cause
> >> issues with Windows[1].
> > 
> > See a0f9628705e3 ("OvmfPkg/SmbiosPlatformDxe: tweak fallback release
> > date") for the windows issue.
> > 
> 
> Should the date string be "02/02/2022" rather than "2/2/2022" in that
> commit?

Windows tests pass with "2/2/2022", but I have to admit didn't check the
specs.

take care,
  Gerd



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




Re: [edk2-devel] Is Xcode5ExceptionHandlerAsm.nasm still needed?

2023-03-30 Thread Ard Biesheuvel
On Thu, 30 Mar 2023 at 12:16, Ni, Ray  wrote:
>
> Andrew,
>
> In UefiCpuPkg\Library\CpuExceptionHandlerLib\X64\, there are two nasm files: 
> ExceptionHandlerAsm.nasm and the other XCODE version.
>
>
>
> The major diff between the two is the second operand in “mov rax, 
> ASM_PFX(CommonInterruptEntry)” is patched at runtime by code, instead of 
> relying on linker/loader to fix it.
>
> Can I know more background why it’s needed for XCODE?
>
>
>
> Given Apple is switching away from X86 CPU, is the XCODE version still needed?
>
>
>
> + Mike because I found another commit by you for bug: 565 – Fix X64 
> XCODE5/NASM compatibility issue in UefiCpuPkg MpInitLib (tianocore.org).
>
>


Yes, we still need it, also for non-Xcode clang + lld

The problem is that the little code templates use absolute addressing
to refer to the jump targets. This is necessary because these
templates are copied into the vector table, and so they are moved
independently from the code they refer to, and so relative addressing
is not an option here.

One thing I haven't tried yet is to emit the template code into .data
instead of .text, which /should/ be fine given that the template code
is never executed directly, only the copied versions are executed.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102174): https://edk2.groups.io/g/devel/message/102174
Mute This Topic: https://groups.io/mt/97947477/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 01/17] MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note

2023-03-30 Thread Leif Lindholm
On Thu, Mar 30, 2023 at 09:28:45 +0200, Ard Biesheuvel wrote:
> > > Patch-set wide comment: is there any chance we could take this
> > > opportunity to introduce a global ASM_FUNC (or a more Linux-named
> > > ENTRY(FuncName))?
> > > It seems to be that the current way is a bit error prone and you end
> > > up repeating yourself quite a bit with:
> > >
> > > ASM_PFX(Foo):
> > > AARCH64_BTI(c)
> > > 
> > >
> > > having a:
> > > ASM_FUNC(Foo)
> > > 
> > >
> > > that does proper PFX and BTI expansion internally seems better to me.
> >
> > I was thinking while looking at this patch that ASM_FUNC could
> > probably do with moving over to this file from AsmMacroIoLibV8.h.
> > I didn't take the thought far enough to consider including the BTI
> > bits in that, but I guess that could make sense.
> 
> Yeah, but I'd prefer it if we could do that globally, and not just for
> AArch64 as part of this series.

Yeah, no issue with that.
This set adds primitives that will be useful for that in future.

/
Leif


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102173): https://edk2.groups.io/g/devel/message/102173
Mute This Topic: https://groups.io/mt/97879282/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 1/1] OvmfPkg/SmbiosPlatformDxe: use PcdFirmware*

2023-03-30 Thread Fiona Ebner
Am 30.03.23 um 10:53 schrieb Gerd Hoffmann:
> On Thu, Mar 30, 2023 at 10:04:02AM +0200, Fiona Ebner wrote:
>> Am 28.11.22 um 06:40 schrieb Gerd Hoffmann:
>>> Instead of using hard-coded strings ("0.0.0" for BiosVersion etc)
>>> which is mostly useless read the PCDs (PcdFirmwareVendor,
>>> PcdFirmwareVersionString and PcdFirmwareReleaseDateString) and
>>> build the string table dynamuically at runtime.
>>>
>>> Signed-off-by: Gerd Hoffmann 
>>> ---
>>>  .../SmbiosPlatformDxe/SmbiosPlatformDxe.inf   |   6 +
>>>  .../XenSmbiosPlatformDxe.inf  |   9 +-
>>>  OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 115 +++---
>>>  3 files changed, 85 insertions(+), 45 deletions(-)
>>>
>>
>> Hi,
>> after this patch, certain SMBIOS values are different[2]. We got a
>> report that the different vendor causes issues with hardware keys[0].
>> And, as I learned from the patch fixing it, the missing date can cause
>> issues with Windows[1].
> 
> See a0f9628705e3 ("OvmfPkg/SmbiosPlatformDxe: tweak fallback release
> date") for the windows issue.
> 

Should the date string be "02/02/2022" rather than "2/2/2022" in that
commit?

I was wondering whether month or date comes first and found the
following in ([0], section 7.1):
> String number of the BIOS release date.
> The date string, if supplied, is in either
> mm/dd/yy or mm/dd/ format. If the year
> portion of the string is two digits, the year is
> assumed to be 19yy.
> NOTE: The mm/dd/ format is required for
> SMBIOS version 2.3 and later.


> You can set those using
>   'build --pcd PcdFirmwareVersionString="L${string}\\0" ...'
> (same for the other pcds).

I had already found the build option in the discussion of v1 of this
patch, but now I'm wondering: is the "\\0" explicitly required? My build
yesterday seemed to work without it, but I guess, I'll just add it to
make sure.

>>> It'd be
>>> good to understand what upstream's intention was there - are they
>>> expecting each distributor to set our own values, and if so, is there
>>> a scheme we should follow?
> 
> The intention is to allow setting version information to whatever makes
> sense for you.  A hardcoded "0.0.0" version certainly isn't very useful
> when it comes to bug reporting etc.
> 
> Fedora leaves vendor unchanged, sets release date to the commit date of
> the edk2-stablemm stable tag the build is based on and version to
> the rpm package version, i.e. like this ...
> 
> Handle 0x, DMI type 0, 26 bytes
> BIOS Information
>   Vendor: EDK II
>   Version: edk2-20230301gitf80f052277c8-1.test6.fc37
>   Release Date: 03/01/2023
>   [ ... ]
> 
> ... which allows to easily identify the exact firmware build running.
> The one listed above happens to be this one:
> 
> https://download.copr.fedorainfracloud.org/results/kraxel/edk2.testbuilds/fedora-37-x86_64/05727085-edk2/
> 

Thank you for the explanation!

Best regards,
Fiona

[0]:
https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.2.0.pdf



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




Re: [edk2-devel] [PATCH 1/1] Maintainers.txt: BaseTools Bob Feng -> reviewer, Rebecca Cran -> maintainer

2023-03-30 Thread Leif Lindholm
On Wed, Mar 29, 2023 at 11:34:53 -0600, Rebecca Cran wrote:
> Update Maintainers.txt for BaseTools: move Bob Feng from being a
> maintainer to reviewer, and add myself (Rebecca Cran) as a new
> maintainer.

Ooh, that's excellent!
Reviewed-by: Leif Lindholm 

> Signed-off-by: Rebecca Cran 
> Cc: Liming Gao 
> Cc: Bob Feng 
> ---
>  Maintainers.txt | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/Maintainers.txt b/Maintainers.txt
> index d4607af7..2f8671147a67 100644
> --- a/Maintainers.txt
> +++ b/Maintainers.txt
> @@ -177,8 +177,9 @@ R: Julien Grall  [jgrall]
>  BaseTools
>  F: BaseTools/
>  W: https://github.com/tianocore/tianocore.github.io/wiki/BaseTools
> -M: Bob Feng  [BobCF]
> +M: Rebecca Cran  [bcran]
>  M: Liming Gao  [lgao4]
> +R: Bob Feng  [BobCF]
>  R: Yuwei Chen  [YuweiChen1110]
>  
>  CryptoPkg
> -- 
> 2.34.1
> 
> 
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102171): https://edk2.groups.io/g/devel/message/102171
Mute This Topic: https://groups.io/mt/97933998/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] Is Xcode5ExceptionHandlerAsm.nasm still needed?

2023-03-30 Thread Ni, Ray
Andrew,
In UefiCpuPkg\Library\CpuExceptionHandlerLib\X64\, there are two nasm files: 
ExceptionHandlerAsm.nasm and the other XCODE version.

The major diff between the two is the second operand in "mov rax, 
ASM_PFX(CommonInterruptEntry)" is patched at runtime by code, instead of 
relying on linker/loader to fix it.
Can I know more background why it's needed for XCODE?

Given Apple is switching away from X86 CPU, is the XCODE version still needed?

+ Mike because I found another commit by you for bug: 565 - Fix X64 XCODE5/NASM 
compatibility issue in UefiCpuPkg MpInitLib 
(tianocore.org).

Thanks,
Ray


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102170): https://edk2.groups.io/g/devel/message/102170
Mute This Topic: https://groups.io/mt/97947477/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] [edk2-platforms][PATCH V3 0/5] Enable SoC expansion block and Virtio-P9 for RD-N2 variants

2023-03-30 Thread Vivek Kumar Gautam

Hi Pierre,


On 3/30/23 15:16, Pierre Gondois wrote:

Hello Vivek,
Thanks for the new version,

Reviewed-by: Pierre Gondois: 


Thanks a lot for your review.

Best regards
Vivek

[snip]


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102169): https://edk2.groups.io/g/devel/message/102169
Mute This Topic: https://groups.io/mt/97821127/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/Conf/tools_def: Fix linking using CLANGDWARF_IA32

2023-03-30 Thread Patrick Rudolph
The clang toolchain might default to fPIE/fPIC, which prevents
lld from linking the objects into a binary.

Specify -fno-pie -fno-pic as done on GCC to fix linking.

Test:
Building the Universal Payload using the command
'python UefiPayloadPkg/UniversalPayloadBuild.py -a IA32' actually
works.

Signed-off-by: Patrick Rudolph 
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4356
---
 BaseTools/Conf/tools_def.template | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 471eb67c0c..9b59bd75c3 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -2888,7 +2888,7 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS= 
-Wl,--defsym=PECOFF_HEADER_SIZE=0x22
 *_CLANGDWARF_IA32_RC_PATH  = DEF(CLANGDWARF_IA32_PREFIX)llvm-rc
 
 *_CLANGDWARF_IA32_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto 
DEF(CLANG38_IA32_TARGET)
-*_CLANGDWARF_IA32_ASLDLINK_FLAGS   = 
DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -fuse-ld=lld
+*_CLANGDWARF_IA32_ASLDLINK_FLAGS   = 
DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -fuse-ld=lld -no-pie
 *_CLANGDWARF_IA32_ASM_FLAGS= DEF(GCC5_ASM_FLAGS) -m32 -march=i386 
DEF(CLANG38_IA32_TARGET)
 *_CLANGDWARF_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
 *_CLANGDWARF_IA32_OBJCOPY_FLAGS=
@@ -2897,17 +2897,17 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS= 
-Wl,--defsym=PECOFF_HEADER_SIZE=0x22
 *_CLANGDWARF_IA32_ASLPP_FLAGS  = DEF(GCC_ASLPP_FLAGS) 
DEF(CLANG38_IA32_TARGET)
 *_CLANGDWARF_IA32_VFRPP_FLAGS  = DEF(GCC_VFRPP_FLAGS) 
DEF(CLANG38_IA32_TARGET)
 
-DEBUG_CLANGDWARF_IA32_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz 
-flto -march=i586 DEF(CLANG38_IA32_TARGET) -g -malign-double
+DEBUG_CLANGDWARF_IA32_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -fno-pic 
-fno-pie -m32 -Oz -flto -march=i586 DEF(CLANG38_IA32_TARGET) -g -malign-double
 DEBUG_CLANGDWARF_IA32_DLINK_FLAGS  = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) 
-flto -Wl,-O3 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
-DEBUG_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 
-fuse-ld=lld
+DEBUG_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 
-fuse-ld=lld -no-pie
 
-RELEASE_CLANGDWARF_IA32_CC_FLAGS   = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz 
-flto -march=i586 DEF(CLANG38_IA32_TARGET) -malign-double
+RELEASE_CLANGDWARF_IA32_CC_FLAGS   = DEF(CLANG38_ALL_CC_FLAGS) -fno-pic 
-fno-pie -m32 -Oz -flto -march=i586 DEF(CLANG38_IA32_TARGET) -malign-double
 RELEASE_CLANGDWARF_IA32_DLINK_FLAGS= DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) 
-flto -Wl,-O3 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
-RELEASE_CLANGDWARF_IA32_DLINK2_FLAGS   = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 
-fuse-ld=lld
+RELEASE_CLANGDWARF_IA32_DLINK2_FLAGS   = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 
-fuse-ld=lld -no-pie
 
-NOOPT_CLANGDWARF_IA32_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m32 -O0 
-march=i586 DEF(CLANG38_IA32_TARGET) -g -malign-double
+NOOPT_CLANGDWARF_IA32_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -fno-pic 
-fno-pie -m32 -O0 -march=i586 DEF(CLANG38_IA32_TARGET) -g -malign-double
 NOOPT_CLANGDWARF_IA32_DLINK_FLAGS  = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) 
-Wl,-O0 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
-NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 
-fuse-ld=lld
+NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 
-fuse-ld=lld -no-pie
 
 ##
 # CLANGDWARF X64 definitions
-- 
2.39.1



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




Re: [edk2-devel] [PATCH 1/3] BaseTools/Conf/tools_def: Fix linking using CLANGDWARF_IA32

2023-03-30 Thread Patrick Rudolph
Hi Marvin,
will send out a new patch series.

Regards,
Patrick Rudolph

On Thu, Mar 30, 2023 at 10:05 AM Marvin Häuser  wrote:
>
> Hi Lean,
>
> I don’t think individual patches from a series are merged generally. Your 2/3 
> has open concerns from both Liming and myself.
>
> Best regards,
> Marvin
>
> On 30. Mar 2023, at 09:31, Lean Sheng Tan  wrote:
>
> 
> HI Liming,
> If no further concern, would you mind to help get this patch merged?
> Thanks!
>
> Best Regards,
> Lean Sheng Tan
>
>
> On Tue, 28 Mar 2023 at 07:42, gaoliming via groups.io 
>  wrote:
>>
>> Reviewed-by: Liming Gao 
>>
>> > -邮件原件-
>> > 发件人: devel@edk2.groups.io  代表 Patrick
>> > Rudolph
>> > 发送时间: 2023年3月17日 22:06
>> > 抄送: devel@edk2.groups.io; guo.d...@intel.com; gua@intel.com;
>> > james...@intel.com; ray...@intel.com; mhaeu...@posteo.de;
>> > a...@kernel.org
>> > 主题: [edk2-devel] [PATCH 1/3] BaseTools/Conf/tools_def: Fix linking using
>> > CLANGDWARF_IA32
>> >
>> > The clang toolchain might default to fPIE/fPIC, which prevents
>> > lld from linking the objects into a binary.
>> >
>> > Specify -fno-pie -fno-pic as done on GCC to fix linking.
>> >
>> > Test:
>> > Building the Universal Payload using the command
>> > 'python UefiPayloadPkg/UniversalPayloadBuild.py -a IA32' actually
>> > works.
>> >
>> > Signed-off-by: Patrick Rudolph 
>> > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4356
>> > ---
>> >  BaseTools/Conf/tools_def.template | 14 +++---
>> >  1 file changed, 7 insertions(+), 7 deletions(-)
>> >
>> > diff --git a/BaseTools/Conf/tools_def.template
>> > b/BaseTools/Conf/tools_def.template
>> > index 471eb67c0c..9b59bd75c3 100755
>> > --- a/BaseTools/Conf/tools_def.template
>> > +++ b/BaseTools/Conf/tools_def.template
>> > @@ -2888,7 +2888,7 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS
>> > = -Wl,--defsym=PECOFF_HEADER_SIZE=0x22
>> >  *_CLANGDWARF_IA32_RC_PATH  =
>> > DEF(CLANGDWARF_IA32_PREFIX)llvm-rc
>> >
>> >
>> >
>> >  *_CLANGDWARF_IA32_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS)
>> > -m32 -fno-lto DEF(CLANG38_IA32_TARGET)
>> >
>> > -*_CLANGDWARF_IA32_ASLDLINK_FLAGS   =
>> > DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -fuse-ld=lld
>> >
>> > +*_CLANGDWARF_IA32_ASLDLINK_FLAGS   =
>> > DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -fuse-ld=lld
>> > -no-pie
>> >
>> >  *_CLANGDWARF_IA32_ASM_FLAGS= DEF(GCC5_ASM_FLAGS)
>> > -m32 -march=i386 DEF(CLANG38_IA32_TARGET)
>> >
>> >  *_CLANGDWARF_IA32_RC_FLAGS =
>> > DEF(GCC_IA32_RC_FLAGS)
>> >
>> >  *_CLANGDWARF_IA32_OBJCOPY_FLAGS=
>> >
>> > @@ -2897,17 +2897,17 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS
>> > = -Wl,--defsym=PECOFF_HEADER_SIZE=0x22
>> >  *_CLANGDWARF_IA32_ASLPP_FLAGS  = DEF(GCC_ASLPP_FLAGS)
>> > DEF(CLANG38_IA32_TARGET)
>> >
>> >  *_CLANGDWARF_IA32_VFRPP_FLAGS  = DEF(GCC_VFRPP_FLAGS)
>> > DEF(CLANG38_IA32_TARGET)
>> >
>> >
>> >
>> > -DEBUG_CLANGDWARF_IA32_CC_FLAGS =
>> > DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586
>> > DEF(CLANG38_IA32_TARGET) -g -malign-double
>> >
>> > +DEBUG_CLANGDWARF_IA32_CC_FLAGS =
>> > DEF(CLANG38_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -Oz -flto -march=i586
>> > DEF(CLANG38_IA32_TARGET) -g -malign-double
>> >
>> >  DEBUG_CLANGDWARF_IA32_DLINK_FLAGS  =
>> > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386
>> > -Wl,--oformat,elf32-i386
>> >
>> > -DEBUG_CLANGDWARF_IA32_DLINK2_FLAGS =
>> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld
>> >
>> > +DEBUG_CLANGDWARF_IA32_DLINK2_FLAGS =
>> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld -no-pie
>> >
>> >
>> >
>> > -RELEASE_CLANGDWARF_IA32_CC_FLAGS   =
>> > DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586
>> > DEF(CLANG38_IA32_TARGET) -malign-double
>> >
>> > +RELEASE_CLANGDWARF_IA32_CC_FLAGS   =
>> > DEF(CLANG38_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -Oz -flto -march=i586
>> > DEF(CLANG38_IA32_TARGET) -malign-double
>> >
>> >  RELEASE_CLANGDWARF_IA32_DLINK_FLAGS=
>> > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386
>> > -Wl,--oformat,elf32-i386
>> >
>> > -RELEASE_CLANGDWARF_IA32_DLINK2_FLAGS   =
>> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld
>> >
>> > +RELEASE_CLANGDWARF_IA32_DLINK2_FLAGS   =
>> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld -no-pie
>> >
>> >
>> >
>> > -NOOPT_CLANGDWARF_IA32_CC_FLAGS =
>> > DEF(CLANG38_ALL_CC_FLAGS) -m32 -O0 -march=i586
>> > DEF(CLANG38_IA32_TARGET) -g -malign-double
>> >
>> > +NOOPT_CLANGDWARF_IA32_CC_FLAGS =
>> > DEF(CLANG38_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -O0 -march=i586
>> > DEF(CLANG38_IA32_TARGET) -g -malign-double
>> >
>> >  NOOPT_CLANGDWARF_IA32_DLINK_FLAGS  =
>> > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_i386
>> > -Wl,--oformat,elf32-i386
>> >
>> > -NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS =
>> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -fuse-ld=lld
>> >
>> > +NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS =
>> > 

Re: [edk2-devel] [edk2-platforms][PATCH V3 0/5] Enable SoC expansion block and Virtio-P9 for RD-N2 variants

2023-03-30 Thread PierreGondois

Hello Vivek,
Thanks for the new version,

Reviewed-by: Pierre Gondois: 

On 3/24/23 12:02, Vivek Gautam wrote:

Arm reference design Fixed Virtual Platforms (FVPs) such as the RD-N2
platform variants have multiple IO virtualization blocks that allow
connecting PCIe root bus or non-PCIe SoC peripherals to the system.
Each of these IO virtualization blocks consists of an Arm SMMUv3, a
GIC-ITS and a NCI (network chip interconnect).

SoC expansion blocks connect to the IO virtualization blocks via x4, x8
or x16 ports exposed by the system. A SoC expansion block implementation
includes 2 UARTs, 2 DMA devices and 2 Memory nodes.

In addition, Arm reference design platforms support Virtio-P9 device as
part of the Rest of System (RoS). The Virtio-P9 device implements a
subset of the Plan 9 file protocol over a virtio transport that enables
accessing a shared directory on the host's filesystem from a running
FVP platform.

This patch series adds SSDT tables for various RD-N2 platforms such as
RD-N2, RD-N2-Cfg1, and RD-N2-Cfg2 to describe the SoC expansion block
devices - UARTs, and DMAs and the Virtio-P9 devices present on the
platforms. The patches also add support for platform DXE driver to
initialize the UARTs that are present in SoC expansion blocks. By
default these UARTs are kept disabled and can be enabled with a Pcd -
PcdIoVirtSocExpBlkUartEnable.

This patch series is now a combination of two patch series [1] and [2]
that added Virtio-P9 support and SoC expansion block (non-discoverable)
IO block for RD-N2:
[edk2-platforms][PATCH V1 0/2] Enable Virtio-P9 on RD-N2 platforms
[edk2-platforms][PATCH V1 0/6] Add non-discoverable IO block for Rd-N2

[1] https://edk2.groups.io/g/devel/message/94936
[2] https://edk2.groups.io/g/devel/message/86646

Changes since v2:
  - Updates to SoC expansion block patches:
- Replaced PcdIoVirtSocExpBlkPeriOffset and PcdIoVirtSocExpBlkResourceSize
  PCDs with corresponding macros.
- Updated SSDT table to add definitions at build time with #if macro for PCD
  for chip count rather than checking at run time with LGreater() method.
- Fixed the comments at multiple places as suggested.
  - Updates to Virtio-P9 patches:
- Added Reviewed-by tag given by Pierre. Thanks for his review.

Changes since v1:
  - Minor update to Virtio-P9 SSDT table:
- Name of the DefinitionBlock() is set to SsdtRosVirtioP9.aml rather
  than SsdtRosVirtioP9Table.aml
  - Updates to SoC expansion block patches:
- Removed IORT table for SoC expansion block and kept only the SSDT
  table for devices as the IORT table changes will come later as part
  of a different series.
- SSDT table now uses arithmetic operations to calculate the start
  and end addresses of the devices in QWordMemory() blocks.
- The number of PCDs for UARTs and DMAs are now reduced as the
  addresses are now calculated within the SSDT table based on the
  SoC expansion block base address and device offsets.
- Defined macros for Interrupt() block for various DMA nodes.
- Removed the first patch of the series that added PCDs for SMMU:
  [PATCH V1 1/6] Platform/Sgi: add PCDs for SMMUv3 base address and 
interrupts
- Added support for SoC expansion block on RD-N2-Cfg2 platform as
  well.

Shriram K (1):
   Platform/Sgi: Initialize additional UART controllers

Vivek Gautam (4):
   Platform/Sgi: Add SSDT table for Virtio-P9
   Platform/Sgi: Enable virtio-p9 device on RD-N2 platform variants
   Platform/Sgi: Add SSDT table for IO virtualization SoC expansion block
   Platform/Sgi: Enable SoC expansion block for RD-N2 variants

  Platform/ARM/SgiPkg/SgiPlatform.dec  |  11 +-
  Platform/ARM/SgiPkg/SgiMemoryMap2.dsc.inc|  10 +-
  Platform/ARM/SgiPkg/AcpiTables/RdN2AcpiTables.inf|  13 +-
  Platform/ARM/SgiPkg/AcpiTables/RdN2Cfg1AcpiTables.inf|  13 +-
  Platform/ARM/SgiPkg/AcpiTables/RdN2Cfg2AcpiTables.inf|   9 +-
  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf  |   9 +-
  Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf  |   6 +-
  Platform/ARM/SgiPkg/Include/IoVirtSoCExp.h   | 188 

  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c|  64 ++-
  Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c |  44 -
  Platform/ARM/SgiPkg/AcpiTables/SsdtIoVirtSocExp.asl  |  96 ++
  Platform/ARM/SgiPkg/AcpiTables/SsdtRosVirtioP9.asl   |  42 +
  12 files changed, 491 insertions(+), 14 deletions(-)
  create mode 100644 Platform/ARM/SgiPkg/Include/IoVirtSoCExp.h
  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/SsdtIoVirtSocExp.asl
  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/SsdtRosVirtioP9.asl




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102166): https://edk2.groups.io/g/devel/message/102166
Mute This Topic: https://groups.io/mt/97821127/21656
Group Owner: 

Re: [edk2-devel] [PATCH 0/6] Substract TME-MK KEY_ID_BITS from CPU max PA

2023-03-30 Thread Gerd Hoffmann
  Hi,

> For tdx, the actual max physical address bits is decreased by the KEY_ID_BITS 
> bits.
> But the max physical address bits reported from CPUID instruction don't 
> change.

I guess the physical address bits calculation for tdx needs adjustment
then.  Right now we have:

  if (TdIsEnabled ()) {
if (TdSharedPageMask () == (1ULL << 47)) {
  PhysMemAddressWidth = 48;
} else {
  PhysMemAddressWidth = 52;
}
  }


See PlatformAddressWidthInitialization() in PlatformInitLib/MemDetect.c

Which would be the third place needing the same logic.  Maybe worth
thinking about a helper function in a library somewhere, so we don't
cut the same code snippet again and again ...

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102165): https://edk2.groups.io/g/devel/message/102165
Mute This Topic: https://groups.io/mt/97767965/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 1/1] OvmfPkg/SmbiosPlatformDxe: use PcdFirmware*

2023-03-30 Thread Gerd Hoffmann
On Thu, Mar 30, 2023 at 10:04:02AM +0200, Fiona Ebner wrote:
> Am 28.11.22 um 06:40 schrieb Gerd Hoffmann:
> > Instead of using hard-coded strings ("0.0.0" for BiosVersion etc)
> > which is mostly useless read the PCDs (PcdFirmwareVendor,
> > PcdFirmwareVersionString and PcdFirmwareReleaseDateString) and
> > build the string table dynamuically at runtime.
> > 
> > Signed-off-by: Gerd Hoffmann 
> > ---
> >  .../SmbiosPlatformDxe/SmbiosPlatformDxe.inf   |   6 +
> >  .../XenSmbiosPlatformDxe.inf  |   9 +-
> >  OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 115 +++---
> >  3 files changed, 85 insertions(+), 45 deletions(-)
> > 
> 
> Hi,
> after this patch, certain SMBIOS values are different[2]. We got a
> report that the different vendor causes issues with hardware keys[0].
> And, as I learned from the patch fixing it, the missing date can cause
> issues with Windows[1].

See a0f9628705e3 ("OvmfPkg/SmbiosPlatformDxe: tweak fallback release
date") for the windows issue.

> I assume this will affect other downstream distributors too. Since we
> base our packaging off Debian, I asked there for how to best handle it
> and am now passing along the question I got in return:

You can set those using
'build --pcd PcdFirmwareVersionString="L${string}\\0" ...'
(same for the other pcds).

We had a patch introducing a define for that to allow the slightly more
convenient 'build -D FIRMWARE_VER="${string}" ...' but that was never
merged.

> > It'd be
> > good to understand what upstream's intention was there - are they
> > expecting each distributor to set our own values, and if so, is there
> > a scheme we should follow?

The intention is to allow setting version information to whatever makes
sense for you.  A hardcoded "0.0.0" version certainly isn't very useful
when it comes to bug reporting etc.

Fedora leaves vendor unchanged, sets release date to the commit date of
the edk2-stablemm stable tag the build is based on and version to
the rpm package version, i.e. like this ...

Handle 0x, DMI type 0, 26 bytes
BIOS Information
Vendor: EDK II
Version: edk2-20230301gitf80f052277c8-1.test6.fc37
Release Date: 03/01/2023
[ ... ]

... which allows to easily identify the exact firmware build running.
The one listed above happens to be this one:

https://download.copr.fedorainfracloud.org/results/kraxel/edk2.testbuilds/fedora-37-x86_64/05727085-edk2/

HTH & take care,
  Gerd



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




Re: [edk2-devel] [PATCH v4 2/9] ManageabilityPkg: Initial package

2023-03-30 Thread Tinh Nguyen via groups.io

Thank you Abner,

Let's go on

Regards,

- Tinh

On 3/29/2023 8:32 AM, Chang, Abner wrote:

[AMD Official Use Only - General]

Hi Tinh,
See my response below,


-Original Message-
From: devel@edk2.groups.io  On Behalf Of Tinh
Nguyen via groups.io
Sent: Tuesday, March 28, 2023 8:37 PM
To: devel@edk2.groups.io; Chang, Abner 
Cc: Liming Gao ; Isaac Oram
; Nate DeSimone
; Attar, AbdulLateef (Abdul Lateef)
; Nickle Wang ; Igor
Kulchytskyy ; Attar, AbdulLateef (Abdul Lateef)

Subject: Re: [edk2-devel] [PATCH v4 2/9] ManageabilityPkg: Initial package

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


Hi Abner,

   How can I include this package into flash description? May we lack the FDF
file?

We can refer to AdvanceFeaturePkg, could have PreMemory.fdf and
PostMemory.fdf

Yes, this is the plan to leverage AdvanceFeaturePkg.


BTW, Please add PCDs to the feature configuration; this will be very useful
when other transport drivers are supported.

Sure, I didn’t do this yet because there are not many drivers so far. I will 
add PCD in next patch set. The first patch is already got reviewed and I am 
thinking to merge it now or adding more patches on top of it as a new patch 
version for community review.
Thanks
Abner



Regards,

Tinh


On 3/22/2023 9:48 AM, Chang, Abner via groups.io wrote:

From: Abner Chang 

Initial commit of ManageabilityPkg

Signed-off-by: Abner Chang 
Cc: Liming Gao 
Cc: Isaac Oram 
Cc: Nate DeSimone 
Cc: Abdul Lateef Attar 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Reviewed-by: Abdul Lateef Attar 
Reviewed-by: Nickle Wang 
---
   .../ManageabilityPkg/ManageabilityPkg.dec | 21 ++
   .../Include/Dsc/Manageability.dsc | 16 
   .../ManageabilityPkg/ManageabilityPkg.dsc | 39

+++

   3 files changed, 76 insertions(+)
   create mode 100644 Features/ManageabilityPkg/ManageabilityPkg.dec
   create mode 100644

Features/ManageabilityPkg/Include/Dsc/Manageability.dsc

   create mode 100644 Features/ManageabilityPkg/ManageabilityPkg.dsc

diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec
b/Features/ManageabilityPkg/ManageabilityPkg.dec
new file mode 100644
index 00..71bd8a0c80
--- /dev/null
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
@@ -0,0 +1,21 @@
+## @file
+# Manageabilty Package
+# This is the package provides the edk2 drivers and libraries # those
+are related to the platform management.
+#
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
+reserved. # SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+[Defines]
+  DEC_SPECIFICATION = 0x0001001d
+  PACKAGE_NAME  = ManageabilityPkg
+  PACKAGE_GUID  = 36310119-4FB2-4BA3-959D-74C16B849F9E
+  PACKAGE_VERSION   = 1.0
+
+[Includes]
+  Include
+
+[Guids]
+  gManageabilityPkgTokenSpaceGuid = { 0xBDEFFF48, 0x1C31, 0x49CD, {
+0xA7, 0x6D, 0x92, 0x9E, 0x60, 0xDB, 0xB9, 0xF8 } }
diff --git a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
new file mode 100644
index 00..2cb63c1ca6
--- /dev/null
+++ b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
@@ -0,0 +1,16 @@
+## @file
+# Common libraries for Manageabilty Package # # Copyright (C) 2023
+Advanced Micro Devices, Inc. All rights reserved. #
+SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+[LibraryClasses.ARM, LibraryClasses.AARCH64]
+  #
+  # This library provides the instrinsic functions generated by a given

compiler.

+  #
+  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+  NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
+  ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
+
diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc
b/Features/ManageabilityPkg/ManageabilityPkg.dsc
new file mode 100644
index 00..b3586afa07
--- /dev/null
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dsc
@@ -0,0 +1,39 @@
+## @file
+# Manageabilty Package
+# This is the package provides edk2 drivers and libraries # those are
+related to the platform management.
+#
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
+reserved. # SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+[Defines]
+  PLATFORM_NAME  = ManageabilityPkg
+  PLATFORM_GUID  = 7A98123A-B194-40B6-A863-A52192F6D65D
+  PLATFORM_VERSION   = 1.0
+  DSC_SPECIFICATION  = 0x0001001e
+  OUTPUT_DIRECTORY   = Build/ManageabilityPkg
+  SUPPORTED_ARCHITECTURES= IA32|X64|ARM|AARCH64|RISCV64
+  BUILD_TARGETS  = DEBUG|RELEASE|NOOPT
+  SKUID_IDENTIFIER   = DEFAULT
+
+[Packages]
+  MinPlatformPkg/MinPlatformPkg.dec
+
+[PcdsFeatureFlag]
+  #
+  # MinPlatform common include currently required PCD
+  #
+  gMinPlatformPkgTokenSpaceGuid.PcdUefiSecureBootEnable

|FALSE

+  gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable

|FALSE


Re: [edk2-devel] [PATCH 0/6] Substract TME-MK KEY_ID_BITS from CPU max PA

2023-03-30 Thread Ni, Ray
I don' t think vt is related.

For tdx, the actual max physical address bits is decreased by the KEY_ID_BITS 
bits.
But the max physical address bits reported from CPUID instruction don't change.

Details in 
https://cdrdv2-public.intel.com/679154/multi-key-total-memory-encryption-spec-1.4.pdf



> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Gerd
> Hoffmann
> Sent: Thursday, March 30, 2023 3:25 PM
> To: Ni, Ray 
> Cc: Tom Lendacky ; devel@edk2.groups.io
> Subject: Re: [edk2-devel] [PATCH 0/6] Substract TME-MK KEY_ID_BITS from
> CPU max PA
> 
> On Thu, Mar 30, 2023 at 02:26:25AM +, Ni, Ray wrote:
> > Gerd,
> > This is needed by Intel platform for TME-MK. Can you help to analyze if it
> has any impact to OVMF? I assume no.
> 
> How does that feature interact with vt and tdx?
> 
> take care,
>   Gerd
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102162): https://edk2.groups.io/g/devel/message/102162
Mute This Topic: https://groups.io/mt/97767965/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 1/3] BaseTools/Conf/tools_def: Fix linking using CLANGDWARF_IA32

2023-03-30 Thread Marvin Häuser
Hi Lean,I don’t think individual patches from a series are merged generally. Your 2/3 has open concerns from both Liming and myself.Best regards,MarvinOn 30. Mar 2023, at 09:31, Lean Sheng Tan  wrote:HI Liming,If no further concern, would you mind to help get this patch merged?Thanks!Best Regards,Lean Sheng TanOn Tue, 28 Mar 2023 at 07:42, gaoliming via groups.io byosoft.com...@groups.io> wrote:Reviewed-by: Liming Gao 

> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Patrick
> Rudolph
> 发送时间: 2023年3月17日 22:06
> 抄送: devel@edk2.groups.io; guo.d...@intel.com; gua@intel.com;
> james...@intel.com; ray...@intel.com; mhaeu...@posteo.de;
> a...@kernel.org
> 主题: [edk2-devel] [PATCH 1/3] BaseTools/Conf/tools_def: Fix linking using
> CLANGDWARF_IA32
> 
> The clang toolchain might default to fPIE/fPIC, which prevents
> lld from linking the objects into a binary.
> 
> Specify -fno-pie -fno-pic as done on GCC to fix linking.
> 
> Test:
> Building the Universal Payload using the command
> 'python UefiPayloadPkg/UniversalPayloadBuild.py -a IA32' actually
> works.
> 
> Signed-off-by: Patrick Rudolph 
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4356
> ---
>  BaseTools/Conf/tools_def.template | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template
> b/BaseTools/Conf/tools_def.template
> index 471eb67c0c..9b59bd75c3 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -2888,7 +2888,7 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS
> = -Wl,--defsym=PECOFF_HEADER_SIZE=0x22
>  *_CLANGDWARF_IA32_RC_PATH              =
> DEF(CLANGDWARF_IA32_PREFIX)llvm-rc
> 
> 
> 
>  *_CLANGDWARF_IA32_ASLCC_FLAGS          = DEF(GCC_ASLCC_FLAGS)
> -m32 -fno-lto DEF(CLANG38_IA32_TARGET)
> 
> -*_CLANGDWARF_IA32_ASLDLINK_FLAGS       =
> DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -fuse-ld=lld
> 
> +*_CLANGDWARF_IA32_ASLDLINK_FLAGS       =
> DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -fuse-ld=lld
> -no-pie
> 
>  *_CLANGDWARF_IA32_ASM_FLAGS            = DEF(GCC5_ASM_FLAGS)
> -m32 -march=i386 DEF(CLANG38_IA32_TARGET)
> 
>  *_CLANGDWARF_IA32_RC_FLAGS             =
> DEF(GCC_IA32_RC_FLAGS)
> 
>  *_CLANGDWARF_IA32_OBJCOPY_FLAGS        =
> 
> @@ -2897,17 +2897,17 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS
> = -Wl,--defsym=PECOFF_HEADER_SIZE=0x22
>  *_CLANGDWARF_IA32_ASLPP_FLAGS          = DEF(GCC_ASLPP_FLAGS)
> DEF(CLANG38_IA32_TARGET)
> 
>  *_CLANGDWARF_IA32_VFRPP_FLAGS          = DEF(GCC_VFRPP_FLAGS)
> DEF(CLANG38_IA32_TARGET)
> 
> 
> 
> -DEBUG_CLANGDWARF_IA32_CC_FLAGS         =
> DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586
> DEF(CLANG38_IA32_TARGET) -g -malign-double
> 
> +DEBUG_CLANGDWARF_IA32_CC_FLAGS         =
> DEF(CLANG38_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -Oz -flto -march=i586
> DEF(CLANG38_IA32_TARGET) -g -malign-double
> 
>  DEBUG_CLANGDWARF_IA32_DLINK_FLAGS      =
> DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386
> -Wl,--oformat,elf32-i386
> 
> -DEBUG_CLANGDWARF_IA32_DLINK2_FLAGS     =
> DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld
> 
> +DEBUG_CLANGDWARF_IA32_DLINK2_FLAGS     =
> DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld -no-pie
> 
> 
> 
> -RELEASE_CLANGDWARF_IA32_CC_FLAGS       =
> DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586
> DEF(CLANG38_IA32_TARGET) -malign-double
> 
> +RELEASE_CLANGDWARF_IA32_CC_FLAGS       =
> DEF(CLANG38_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -Oz -flto -march=i586
> DEF(CLANG38_IA32_TARGET) -malign-double
> 
>  RELEASE_CLANGDWARF_IA32_DLINK_FLAGS    =
> DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386
> -Wl,--oformat,elf32-i386
> 
> -RELEASE_CLANGDWARF_IA32_DLINK2_FLAGS   =
> DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld
> 
> +RELEASE_CLANGDWARF_IA32_DLINK2_FLAGS   =
> DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld -no-pie
> 
> 
> 
> -NOOPT_CLANGDWARF_IA32_CC_FLAGS         =
> DEF(CLANG38_ALL_CC_FLAGS) -m32 -O0 -march=i586
> DEF(CLANG38_IA32_TARGET) -g -malign-double
> 
> +NOOPT_CLANGDWARF_IA32_CC_FLAGS         =
> DEF(CLANG38_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -O0 -march=i586
> DEF(CLANG38_IA32_TARGET) -g -malign-double
> 
>  NOOPT_CLANGDWARF_IA32_DLINK_FLAGS      =
> DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_i386
> -Wl,--oformat,elf32-i386
> 
> -NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS     =
> DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -fuse-ld=lld
> 
> +NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS     =
> DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -fuse-ld=lld -no-pie
> 
> 
> 
>  ##
> 
>  # CLANGDWARF X64 definitions
> 
> --
> 2.39.1
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#101340):
> https://edk2.groups.io/g/devel/message/101340
> Mute This Topic: https://groups.io/mt/97673648/4905953
> Group Owner: devel+ow...@edk2.groups.io
> Unsubscribe: 

Re: [edk2-devel] [PATCH v3 1/1] OvmfPkg/SmbiosPlatformDxe: use PcdFirmware*

2023-03-30 Thread Fiona Ebner
Am 28.11.22 um 06:40 schrieb Gerd Hoffmann:
> Instead of using hard-coded strings ("0.0.0" for BiosVersion etc)
> which is mostly useless read the PCDs (PcdFirmwareVendor,
> PcdFirmwareVersionString and PcdFirmwareReleaseDateString) and
> build the string table dynamuically at runtime.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  .../SmbiosPlatformDxe/SmbiosPlatformDxe.inf   |   6 +
>  .../XenSmbiosPlatformDxe.inf  |   9 +-
>  OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 115 +++---
>  3 files changed, 85 insertions(+), 45 deletions(-)
> 

Hi,
after this patch, certain SMBIOS values are different[2]. We got a
report that the different vendor causes issues with hardware keys[0].
And, as I learned from the patch fixing it, the missing date can cause
issues with Windows[1].

To keep backwards compatibility for [0], it's necessary for us to
specify the old vendor value during build.

I assume this will affect other downstream distributors too. Since we
base our packaging off Debian, I asked there for how to best handle it
and am now passing along the question I got in return:

Am 29.03.23 um 18:51 schrieb dann frazier:
> It'd be
> good to understand what upstream's intention was there - are they
> expecting each distributor to set our own values, and if so, is there
> a scheme we should follow?

Best Regards,
Fiona

[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=4625
[1]: https://edk2.groups.io/g/devel/message/100922
[2]: dmidecode output differences in a Linux guest when running with a
build with OvmfPkg/OvmfPkgIa32X64.dsc:

edk2-stable202205:

Vendor: EFI Development Kit II / OVMF
Version: 0.0.0
Release Date: 02/06/2015

edk2-stable202302:

Vendor: EDK II
Version: unknown
Release Date: unknown



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




Re: [edk2-devel] [edk2][PATCH V1 1/1] MdePkg/IndustryStandard: add definitions for MPAM ACPI specification

2023-03-30 Thread Rohit Mathew
Thanks Sami, Michael, Liming for the review/ack.

I'll post a V2 with the comments addressed. Let me also work on the Acpi parser 
for the same.

Regards,
Rohit

> -Original Message-
> From: Sami Mujawar 
> Sent: Wednesday, March 29, 2023 10:57 AM
> To: Rohit Mathew ; devel@edk2.groups.io
> Cc: Michael D Kinney ; Liming Gao
> ; Zhiguang Liu ; Thomas
> Abraham ; Swatisri Kantamsetti
> ; nd 
> Subject: Re: [edk2][PATCH V1 1/1] MdePkg/IndustryStandard: add definitions
> for MPAM ACPI specification
> 
> Hi Rohit,
> 
> Thank you for this patch, and apologies for the delay in reply.
> 
> I have a few minor suggestions marked inline as [SAMI].
> 
> Other than that, I would like to see a corresponding patch to add MPAM
> support to Acpiview.
> 
> With that addressed,
> 
> Reviewed-by: Sami Mujawar 
> 
> regards,
> 
> Sami Mujawar
> 
> On 25/01/2023 12:39 am, Rohit Mathew wrote:
> > add definitions, macros and types for elements associated with MPAM
> > ACPI 2.0 specification.
> >
> > Signed-off-by: Rohit Mathew 
> > ---
> >   MdePkg/Include/IndustryStandard/Acpi64.h |   7 +-
> >   MdePkg/Include/IndustryStandard/Mpam.h   | 229
> 
> >   2 files changed, 235 insertions(+), 1 deletion(-)
> >
> > github link:
> > https://github.com/rohit-arm/edk2/tree/mpam_acpi
> >
> > diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h
> > b/MdePkg/Include/IndustryStandard/Acpi64.h
> > index 575ca0430c..2be9525979 100644
> > --- a/MdePkg/Include/IndustryStandard/Acpi64.h
> > +++ b/MdePkg/Include/IndustryStandard/Acpi64.h
> > @@ -2,7 +2,7 @@
> > ACPI 6.4 definitions from the ACPI Specification Revision 6.4 Jan, 2021.
> >
> > Copyright (c) 2017 - 2022, Intel Corporation. All rights
> > reserved.
> > -  Copyright (c) 2019 - 2021, ARM Ltd. All rights reserved.
> > +  Copyright (c) 2019 - 2023, ARM Limited. All rights reserved.
> >
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >   **/
> > @@ -3157,6 +3157,11 @@ typedef struct {
> >   ///
> >   #define EFI_ACPI_6_4_XEN_PROJECT_TABLE_SIGNATURE
> SIGNATURE_32('X',
> > 'E', 'N', 'V')
> >
> > +///
> > +/// "MPAM" Memory System Resource Partitioning and Monitoring Table
> > +/// #define
> >
> +EFI_ACPI_MEMORY_SYSTEM_RESOURCE_PARTITIONING_AND_MONITORING
> _TABLE_SIG
> > +NATURE  SIGNATURE_32('M', 'P', 'A', 'M')
> > +
> >   #pragma pack()
> >
> >   #endif
> > diff --git a/MdePkg/Include/IndustryStandard/Mpam.h
> > b/MdePkg/Include/IndustryStandard/Mpam.h
> > new file mode 100644
> > index 00..8e6e72ea28
> > --- /dev/null
> > +++ b/MdePkg/Include/IndustryStandard/Mpam.h
> > @@ -0,0 +1,229 @@
> > +/** @file
> > +  ACPI for Memory System Resource Partitioning and Monitoring 2.0
> > +(MPAM) as
> > +  specified in ARM spec DEN0065
> > +
> > +  Copyright (c) 2023, Arm Limited. All rights reserved.
> > +
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +  @par Specification Reference:
> > +   - [1] ACPI for Memory System Resource Partitioning and Monitoring 2.0
> > + (https://developer.arm.com/documentation/den0065/latest)
> > +
> > +  @par Glossary:
> > +- MPAM - Memory System Resource Partitioning And Monitoring
> > +- MSC  - Memory System Component
> > +- PCC  - Platform Communication Channel
> > +- RIS  - Resource Instance Selection
> > +- SMMU - Arm System Memory Management Unit **/
> > +
> > +#ifndef MPAM_H_
> > +#define MPAM_H_
> > +
> > +#include 
> > +
> > +///
> > +/// MPAM Revision
> > +///
> > +#define
> >
> +EFI_ACPI_MEMORY_SYSTEM_RESOURCE_PARTITIONING_AND_MONITORING
> _TABLE_REV
> > +ISION  (0x01)
> > +
> > +///
> > +/// MPAM Interrupt mode
> > +///
> > +#define EFI_ACPI_MPAM_INTERRUPT_LEVEL_TRIGGERED  (0x0)
> > +#define EFI_ACPI_MPAM_INTERRUPT_EDGE_TRIGGERED   (0x1)
> > +
> > +///
> > +/// MPAM Interrupt type
> > +///
> > +#define EFI_ACPI_MPAM_INTERRUPT_WIRED  (0x0)
> > +
> > +///
> > +/// MPAM Interrupt affinity type
> > +///
> > +#define EFI_ACPI_MPAM_PROCESSOR_AFFINITY(0x0)
> > +#define EFI_ACPI_MPAM_PROCESSOR_CONTAINER_AFFINITY  (0x1)
> > +
> > +///
> > +/// MPAM MSC affinity valid
> > +///
> > +#define EFI_ACPI_MPAM_AFFINITY_NOT_VALID  (0x0)
> > +#define EFI_ACPI_MPAM_AFFINITY_VALID  (0x1)
> > +
> > +///
> > +/// MPAM Interrupt flag - bit positions /// #define
> > +EFI_ACPI_MPAM_INTERRUPT_MODE_POS  (0x0) #define
> > +EFI_ACPI_MPAM_INTERRUPT_TYPE_POS  (0x1)
> > +#define EFI_ACPI_MPAM_AFFINITY_TYPE_POS   (0x3)
> > +#define EFI_ACPI_MPAM_AFFINITY_VALID_POS  (0x4)
> > +#define EFI_ACPI_MPAM_RESERVED_POS(0x5)
> [SAMI] I think it would be better to change the postfix _POS to _SHIFT and
> corresponing definitions for masks
> (i.e.EFI_ACPI_MPAM_INTERRUPT_MODE_MASK) be added.
> > +
> > +///
> > +/// MPAM Location types
> > +/// as described in document [1], table 11 /// #define
> > +EFI_ACPI_MPAM_LOCATION_PROCESSOR_CACHE  (0x0)
> > +#define EFI_ACPI_MPAM_LOCATION_MEMORY   (0x1)
> > +#define EFI_ACPI_MPAM_LOCATION_SMMU (0x2)
> > +#define 

Re: [edk2-devel] [PATCH V1 1/1] OvmfPkg/PlatformPei: Skip PlatformInitEmuVariableNvStore in SEV guest

2023-03-30 Thread Gerd Hoffmann
On Wed, Mar 29, 2023 at 01:23:10PM +0800, Min Xu wrote:
> From: Min M Xu 
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4379
> 
> PlatformInitEmuVariableNvStore is called to initialize the
> EmuVariableNvStore with the content pointed by
> PcdOvmfFlashNvStorageVariableBase. This is because when OVMF is launched
> with -bios parameter, UEFI variables will be partially emulated, and
> non-volatile variables may lose their contents after a reboot. This makes
> the secure boot feature not working.
> 
> But in SEV guest, this design doesn't work. Because at this point the
> variable store mapping is still private/encrypted, OVMF will see
> ciphertext. So we skip the call of PlatformInitEmuVariableNvStore in
> SEV guest.

I'd suggest to simply build without -D SECURE_BOOT_ENABLE instead.
Without initializing the emu var store you will not get a functional
secure boot setup anyway.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102158): https://edk2.groups.io/g/devel/message/102158
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 v2 00/17] Enable BTI support in memory attributes table

2023-03-30 Thread Ard Biesheuvel
On Wed, 29 Mar 2023 at 18:31, Leif Lindholm  wrote:
>
> On Mon, Mar 27, 2023 at 13:00:55 +0200, Ard Biesheuvel wrote:
> > Implement version 2 of the memory attributes table, which now contains a
> > flag informing the OS whether or not code regions may be mapped with CFI
> > mitigations such as IBT or BTI enabled.
> >
> > This series covers roughly the following parts:
> >
> > - (AARCH64) Annotate ELF objects generated from asm as BTI compatible
> >   when BTI codegen is enabled
> > - Update the BaseTools to emit the appropriate PE/COFF annotation when a
> >   BTI/IBT compatible ELF executable is converted to PE/COFF
> > - Take this PE/COFF annotation into account when populating the memory
> >   attributes table in the DXE core
>
> For any patches I haven't explicitly commented on in this set:
> Reviewed-by: Leif Lindholm 
>
> (but I did comment on patch 17 in the review of patch 15)
>

Thanks.

I have pushed the AArch64 specific codegen changes and the MdePkg one
that updates the definition of the table.

That leaves the following changes:

  BaseTools/GenFw: Parse IBT/BTI support status from ELF note
  BaseTools/GenFw: Add DllCharacteristicsEx field to debug data

Liming, Bob, Rebecca: any comments here?

  MdePkg/PeCoffLib: Capture DLL characteristics fieldis in image context
  MdeModulePkg: Enable forward edge CFI in mem attributes table

Jiewen, Liming?


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




Re: [edk2-devel] [PATCH 1/1] Maintainers.txt: BaseTools Bob Feng -> reviewer, Rebecca Cran -> maintainer

2023-03-30 Thread Ard Biesheuvel
On Wed, 29 Mar 2023 at 19:35, Rebecca Cran  wrote:
>
> Update Maintainers.txt for BaseTools: move Bob Feng from being a
> maintainer to reviewer, and add myself (Rebecca Cran) as a new
> maintainer.
>
> Signed-off-by: Rebecca Cran 
> Cc: Liming Gao 
> Cc: Bob Feng 
> ---
>  Maintainers.txt | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/Maintainers.txt b/Maintainers.txt
> index d4607af7..2f8671147a67 100644
> --- a/Maintainers.txt
> +++ b/Maintainers.txt
> @@ -177,8 +177,9 @@ R: Julien Grall  [jgrall]
>  BaseTools
>  F: BaseTools/
>  W: https://github.com/tianocore/tianocore.github.io/wiki/BaseTools
> -M: Bob Feng  [BobCF]
> +M: Rebecca Cran  [bcran]
>  M: Liming Gao  [lgao4]
> +R: Bob Feng  [BobCF]
>  R: Yuwei Chen  [YuweiChen1110]
>

Thanks a lot for stepping up.

Acked-by: Ard Biesheuvel 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102156): https://edk2.groups.io/g/devel/message/102156
Mute This Topic: https://groups.io/mt/97933998/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 0/2] SEV-SNP guest support fixes

2023-03-30 Thread Gerd Hoffmann
On Tue, Mar 28, 2023 at 01:09:22PM -0500, Lendacky, Thomas via groups.io wrote:
> This patch series provides some fixes around AP creation:
> 
> - An erratum on AMD hardware requires that a VMSA not be aligned on a
>   2MB boundary. To work around this issue, allocate 2 pages of memory
>   and using the page that is not 2MB aligned and freeing the other.
> 
> - When parking APs after exiting boot services, the current SNP support
>   will perform an allocation that will not be reflected in memory map
>   being supplied to the OS. Instead of allocating new VMSAs each time,
>   re-use the current VMSA.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4353
> 
> ---
> 
> Changes since v1:
>   - Change the order of the patches to make the patch diffs easier
> to review
>   - Add erratum number to the patch description and code comment
>   - Use existing ALIGN_POINTER macro

Series:
Acked-by: Gerd Hoffmann 

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102155): https://edk2.groups.io/g/devel/message/102155
Mute This Topic: https://groups.io/mt/97911955/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 0/6] MdePkg/Base.h: Introduce various alignment-related macros

2023-03-30 Thread Gerd Hoffmann
On Wed, Mar 22, 2023 at 08:02:37AM +0100, Gerd Hoffmann wrote:
> v2 changes:
>  - rebase to latest master, adapt patches to changes.
>  - update macro documentation to use @retval TRUE/FALSE.
>  - added patch to use IS_POW2 in MtrrLib.
>  - add reviews and acks.

Ping.  This is fully reviewed now, can this be merged please?

thanks,
  Gerd



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




Re: [edk2-devel] [PATCH 1/3] BaseTools/Conf/tools_def: Fix linking using CLANGDWARF_IA32

2023-03-30 Thread Sheng Lean Tan
HI Liming,
If no further concern, would you mind to help get this patch merged?
Thanks!

Best Regards,
*Lean Sheng Tan*


On Tue, 28 Mar 2023 at 07:42, gaoliming via groups.io  wrote:

> Reviewed-by: Liming Gao 
>
> > -邮件原件-
> > 发件人: devel@edk2.groups.io  代表 Patrick
> > Rudolph
> > 发送时间: 2023年3月17日 22:06
> > 抄送: devel@edk2.groups.io; guo.d...@intel.com; gua@intel.com;
> > james...@intel.com; ray...@intel.com; mhaeu...@posteo.de;
> > a...@kernel.org
> > 主题: [edk2-devel] [PATCH 1/3] BaseTools/Conf/tools_def: Fix linking using
> > CLANGDWARF_IA32
> >
> > The clang toolchain might default to fPIE/fPIC, which prevents
> > lld from linking the objects into a binary.
> >
> > Specify -fno-pie -fno-pic as done on GCC to fix linking.
> >
> > Test:
> > Building the Universal Payload using the command
> > 'python UefiPayloadPkg/UniversalPayloadBuild.py -a IA32' actually
> > works.
> >
> > Signed-off-by: Patrick Rudolph 
> > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4356
> > ---
> >  BaseTools/Conf/tools_def.template | 14 +++---
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/BaseTools/Conf/tools_def.template
> > b/BaseTools/Conf/tools_def.template
> > index 471eb67c0c..9b59bd75c3 100755
> > --- a/BaseTools/Conf/tools_def.template
> > +++ b/BaseTools/Conf/tools_def.template
> > @@ -2888,7 +2888,7 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS
> > = -Wl,--defsym=PECOFF_HEADER_SIZE=0x22
> >  *_CLANGDWARF_IA32_RC_PATH  =
> > DEF(CLANGDWARF_IA32_PREFIX)llvm-rc
> >
> >
> >
> >  *_CLANGDWARF_IA32_ASLCC_FLAGS  = DEF(GCC_ASLCC_FLAGS)
> > -m32 -fno-lto DEF(CLANG38_IA32_TARGET)
> >
> > -*_CLANGDWARF_IA32_ASLDLINK_FLAGS   =
> > DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -fuse-ld=lld
> >
> > +*_CLANGDWARF_IA32_ASLDLINK_FLAGS   =
> > DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -fuse-ld=lld
> > -no-pie
> >
> >  *_CLANGDWARF_IA32_ASM_FLAGS= DEF(GCC5_ASM_FLAGS)
> > -m32 -march=i386 DEF(CLANG38_IA32_TARGET)
> >
> >  *_CLANGDWARF_IA32_RC_FLAGS =
> > DEF(GCC_IA32_RC_FLAGS)
> >
> >  *_CLANGDWARF_IA32_OBJCOPY_FLAGS=
> >
> > @@ -2897,17 +2897,17 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS
> > = -Wl,--defsym=PECOFF_HEADER_SIZE=0x22
> >  *_CLANGDWARF_IA32_ASLPP_FLAGS  = DEF(GCC_ASLPP_FLAGS)
> > DEF(CLANG38_IA32_TARGET)
> >
> >  *_CLANGDWARF_IA32_VFRPP_FLAGS  = DEF(GCC_VFRPP_FLAGS)
> > DEF(CLANG38_IA32_TARGET)
> >
> >
> >
> > -DEBUG_CLANGDWARF_IA32_CC_FLAGS =
> > DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586
> > DEF(CLANG38_IA32_TARGET) -g -malign-double
> >
> > +DEBUG_CLANGDWARF_IA32_CC_FLAGS =
> > DEF(CLANG38_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -Oz -flto -march=i586
> > DEF(CLANG38_IA32_TARGET) -g -malign-double
> >
> >  DEBUG_CLANGDWARF_IA32_DLINK_FLAGS  =
> > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386
> > -Wl,--oformat,elf32-i386
> >
> > -DEBUG_CLANGDWARF_IA32_DLINK2_FLAGS =
> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld
> >
> > +DEBUG_CLANGDWARF_IA32_DLINK2_FLAGS =
> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld -no-pie
> >
> >
> >
> > -RELEASE_CLANGDWARF_IA32_CC_FLAGS   =
> > DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586
> > DEF(CLANG38_IA32_TARGET) -malign-double
> >
> > +RELEASE_CLANGDWARF_IA32_CC_FLAGS   =
> > DEF(CLANG38_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -Oz -flto -march=i586
> > DEF(CLANG38_IA32_TARGET) -malign-double
> >
> >  RELEASE_CLANGDWARF_IA32_DLINK_FLAGS=
> > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386
> > -Wl,--oformat,elf32-i386
> >
> > -RELEASE_CLANGDWARF_IA32_DLINK2_FLAGS   =
> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld
> >
> > +RELEASE_CLANGDWARF_IA32_DLINK2_FLAGS   =
> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld -no-pie
> >
> >
> >
> > -NOOPT_CLANGDWARF_IA32_CC_FLAGS =
> > DEF(CLANG38_ALL_CC_FLAGS) -m32 -O0 -march=i586
> > DEF(CLANG38_IA32_TARGET) -g -malign-double
> >
> > +NOOPT_CLANGDWARF_IA32_CC_FLAGS =
> > DEF(CLANG38_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -O0 -march=i586
> > DEF(CLANG38_IA32_TARGET) -g -malign-double
> >
> >  NOOPT_CLANGDWARF_IA32_DLINK_FLAGS  =
> > DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_i386
> > -Wl,--oformat,elf32-i386
> >
> > -NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS =
> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -fuse-ld=lld
> >
> > +NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS =
> > DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -fuse-ld=lld -no-pie
> >
> >
> >
> >  ##
> >
> >  # CLANGDWARF X64 definitions
> >
> > --
> > 2.39.1
> >
> >
> >
> > -=-=-=-=-=-=
> > Groups.io Links: You receive all messages sent to this group.
> > View/Reply Online (#101340):
> > https://edk2.groups.io/g/devel/message/101340
> > Mute This Topic: https://groups.io/mt/97673648/4905953
> > Group Owner: devel+ow...@edk2.groups.io
> > Unsubscribe: https://edk2.groups.io/g/devel/unsub
> > 

Re: [edk2-devel] [PATCH v2 01/17] MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note

2023-03-30 Thread Ard Biesheuvel
On Mon, 27 Mar 2023 at 16:24, Leif Lindholm  wrote:
>
> On Mon, Mar 27, 2023 at 15:12:29 +0100, Pedro Falcato wrote:
> > On Mon, Mar 27, 2023 at 12:01 PM Ard Biesheuvel  wrote:
> > >
> > > Implement a CPP macro that can be called from .S files to emit the .note
> > > section carrying the annotation that informs the linker that the object
> > > file is compatible with BTI control flow integrity checks.
> > >
> > > Signed-off-by: Ard Biesheuvel 
> > > ---
> > >  MdePkg/Include/AArch64/ProcessorBind.h | 31 
> > >  1 file changed, 31 insertions(+)
> > >
> > > diff --git a/MdePkg/Include/AArch64/ProcessorBind.h 
> > > b/MdePkg/Include/AArch64/ProcessorBind.h
> > > index abe2571245c665f3..11814f1ffaef698a 100644
> > > --- a/MdePkg/Include/AArch64/ProcessorBind.h
> > > +++ b/MdePkg/Include/AArch64/ProcessorBind.h
> > > @@ -186,6 +186,37 @@ typedef INT64 INTN;
> > >  #define GCC_ASM_IMPORT(func__)  \
> > >   .extern  _CONCATENATE (__USER_LABEL_PREFIX__, func__)
> > >
> > > +#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
> > > +#define AARCH64_BTI(__type)\
> > > +.ifnc __type, ;\
> > > +bti   __type  ;\
> > > +.endif;\
> > > +.ifndef   .Lgnu_bti_notesize  ;\
> > > +.pushsection  .note.gnu.property, "a" ;\
> > > +.set  NT_GNU_PROPERTY_TYPE_0, 0x5 ;\
> > > +.set  GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc000  ;\
> > > +.set  GNU_PROPERTY_AARCH64_FEATURE_1_BTI, 0x1 ;\
> > > +.align3   ;\
> > > +.long .Lnamesize  ;\
> > > +.long .Lgnu_bti_notesize  ;\
> > > +.long NT_GNU_PROPERTY_TYPE_0  ;\
> > > +0:  .asciz"GNU"   ;\
> > > +.set  .Lnamesize, . - 0b  ;\
> > > +.align3   ;\
> > > +1:  .long GNU_PROPERTY_AARCH64_FEATURE_1_AND  ;\
> > > +.long .Lvalsize   ;\
> > > +2:  .long GNU_PROPERTY_AARCH64_FEATURE_1_BTI  ;\
> > > +.set  .Lvalsize, . - 2b   ;\
> > > +.align3   ;\
> > > +.set  .Lgnu_bti_notesize, . - 1b  ;\
> > > +.popsection   ;\
> > > +.endif
> > > +#endif
> > > +
> > > +#endif
> > > +
> > > +#ifndef AARCH64_BTI
> > > +#define AARCH64_BTI(__type)
> > >  #endif
> > >
> > >  /**
> > > --
> > > 2.39.2
> >
> > Patch-set wide comment: is there any chance we could take this
> > opportunity to introduce a global ASM_FUNC (or a more Linux-named
> > ENTRY(FuncName))?
> > It seems to be that the current way is a bit error prone and you end
> > up repeating yourself quite a bit with:
> >
> > ASM_PFX(Foo):
> > AARCH64_BTI(c)
> > 
> >
> > having a:
> > ASM_FUNC(Foo)
> > 
> >
> > that does proper PFX and BTI expansion internally seems better to me.
>
> I was thinking while looking at this patch that ASM_FUNC could
> probably do with moving over to this file from AsmMacroIoLibV8.h.
> I didn't take the thought far enough to consider including the BTI
> bits in that, but I guess that could make sense.
>

Yeah, but I'd prefer it if we could do that globally, and not just for
AArch64 as part of this series.


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




Re: [edk2-devel] [PATCH 0/6] Substract TME-MK KEY_ID_BITS from CPU max PA

2023-03-30 Thread Gerd Hoffmann
On Thu, Mar 30, 2023 at 02:26:25AM +, Ni, Ray wrote:
> Gerd,
> This is needed by Intel platform for TME-MK. Can you help to analyze if it 
> has any impact to OVMF? I assume no.

How does that feature interact with vt and tdx?

take care,
  Gerd



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




Re: [edk2-devel] [edk2-libc Patch 1/1] Python/Python3.6.8: migration of edk2module from chipsec repo

2023-03-30 Thread Ajay Kadapathri
Hi JP,

Missed to add inf changes and I have resubmitted the updated patch request.

Thanks,
Ajay

-Original Message-
From: Jayaprakash, N  
Sent: Thursday, March 30, 2023 1:36 AM
To: Kadapathri, Ajay ; devel@edk2.groups.io
Cc: Rebecca Cran ; Kinney, Michael D 

Subject: RE: [edk2-libc Patch 1/1] Python/Python3.6.8: migration of edk2module 
from chipsec repo

Hi Ajay,

Looks like inf file is missing some dependencies (Libs and nasm file). Due to 
this the code doesn't build after applying the patch.
So, please fix this and resubmit the updated patch request.

   "C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64\lib.exe" 
/NOLOGO /LTCG 
/OUT:c:\users\njayapra\github\edk2\Build\AppPkg\RELEASE_VS2019\X64\AppPkg\Applications\Python\Python-3.6.8\Python368\OUTPUT\Python.lib
 
@c:\users\njayapra\github\edk2\Build\AppPkg\RELEASE_VS2019\X64\AppPkg\Applications\Python\Python-3.6.8\Python368\OUTPUT\object_files.lst
"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64\link.exe" 
/OUT:c:\users\njayapra\github\edk2\Build\AppPkg\RELEASE_VS2019\X64\AppPkg\Applications\Python\Python-3.6.8\Python368\DEBUG\Python.dll
 /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /IGNORE:4254 /OPT:REF 
/OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 
/LTCG /DLL /ENTRY:_ModuleEntryPoint /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER 
/SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data /WHOLEARCHIVE  
@c:\users\njayapra\github\edk2\Build\AppPkg\RELEASE_VS2019\X64\AppPkg\Applications\Python\Python-3.6.8\Python368\OUTPUT\static_library_files.lst
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol PciRead8
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol PciWrite8
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol PciRead16
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol 
PciWrite16
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol PciRead32
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol 
PciWrite32
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoRead8
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoWrite8
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoRead16
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoWrite16
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoRead32
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol IoWrite32
Python.lib(edk2module.obj) : error LNK2001: unresolved external symbol _swsmi 
c:\users\njayapra\github\edk2\Build\AppPkg\RELEASE_VS2019\X64\AppPkg\Applications\Python\Python-3.6.8\Python368\DEBUG\Python.dll
 : fatal error LNK1120: 13 unresolved externals NMAKE : fatal error U1077: 
'"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64\link.exe"' : 
return code '0x460'
Stop.


Regards,
JP

-Original Message-
From: Kadapathri, Ajay 
Sent: Monday, March 27, 2023 1:35 PM
To: devel@edk2.groups.io
Cc: Rebecca Cran ; Kinney, Michael D 
; Jayaprakash, N 
Subject: [edk2-libc Patch 1/1] Python/Python3.6.8: migration of edk2module from 
chipsec repo

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

This patch merges the enhancements done by chipsec tool to edk2 module into 
edk2-libc repo.
The chipsec enhancements can be used for various other Python based tools to 
access platform registers.
These enhancements providing a set of APIs to access the platform registers 
directly from the python scripts running on UEFI shell. This will benefit the 
Python users on UEFI shell in general and enhances it's usability. Python can 
be used effectively to implement tools, scripts required for automation, debug 
from UEFI shell.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Ajay Kadapathri 
---
 .../Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm |  63 +++
 .../PyMod-3.6.8/Modules/cpu_gcc.s |  64 +++
 .../PyMod-3.6.8/Modules/cpu_ia32.nasm |  35 ++
 .../PyMod-3.6.8/Modules/cpu_ia32_gcc.s|  38 ++
 .../PyMod-3.6.8/Modules/edk2module.c  | 519 +-
 5 files changed, 717 insertions(+), 2 deletions(-)  create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_gcc.s
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_ia32.nasm
 create mode 100644 
AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu_ia32_gcc.s

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/cpu.nasm
new file mode 100644
index 000..bd50015
--- /dev/null
+++