回复: [edk2-devel] please help fix building error

2023-04-11 Thread gaoliming via groups.io
The error message says the below file can’t be found. Can you confirm it?

 

/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/Build/MakenaAU/Core/RELEASE_CLANG100LINUX/FV/Ffs/5E0EAE60-EAED-4D75-B8BF-EDBBAABC3F09SecurityDxe/5E0EAE60-EAED-4D75-B8BF-EDBBAABC3F09SEC2.1.pe32

 

发件人: devel@edk2.groups.io  代表 luming.jin via groups.io
发送时间: 2023年4月6日 9:39
收件人: gaolim...@byosoft.com.cn; devel@edk2.groups.io
主题: Re: [edk2-devel] please help fix building error

 

Hello liming

Same error, I used another computer to build with python 2.7 seems ok

But failed build in the server, any possible reason? 

Active Platform  = 
/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/boot/QcomPkg/SocPkg/Makena/AU/Core.dsc
 done!
#

 

build.py...
: error C0DE: Unknown fatal error when processing 
[/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/boot/QcomPkg/Library/EblCmdLib/EblCmdLib.inf
 [AARCH64, CLANG100LINUX, RELEASE]]

(Please send email to devel@edk2.groups.io   for 
help, attaching following call stack trace!)

 

(Python 3.8.10 on linux) Traceback (most recent call last):
  File 
"/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/build/build.py",
 line 2599, in Main
MyBuild.Launch()
  File 
"/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/build/build.py",
 line 2392, in Launch
self._BuildPlatform()
  File 
"/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/build/build.py",
 line 1756, in _BuildPlatform
CmdListDict = self._GenFfsCmd(Wa.ArchList)
  File 
"/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/build/build.py",
 line 2006, in _GenFfsCmd
GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, 
ArchList, GlobalData)
  File 
"/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/GenFds/GenFds.py",
 line 544, in GenFfsMakefile
FvObj.AddToBuffer(Buffer=None, Flag=True)
  File 
"/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/GenFds/Fv.py",
 line 127, in AddToBuffer
FileName = FfsFile.GenFfs(MacroDict, FvParentAddr=BaseAddress, 
IsMakefile=Flag, FvName=self.UiFvName)
  File 
"/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/GenFds/FfsInfStatement.py",
 line 518, in GenFfs
InputSectList, InputSectAlignments = self.__GenComplexFileSection__(Rule, 
FvChildAddr, FvParentAddr, IsMakefile=IsMakefile)
  File 
"/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/GenFds/FfsInfStatement.py",
 line 969, in __GenComplexFileSection__
SectList, Align = Sect.GenSection(self.OutputPath, self.ModuleGuid, 
SecIndex, self.KeyStringList, self, IsMakefile = IsMakefile)
  File 
"/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/GenFds/EfiSection.py",
 line 318, in GenSection
GenFdsGlobalVariable.GenerateSection(OutputFile,
  File 
"/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py",
 line 502, in GenerateSection
if (os.path.getsize(Output) >= GenFdsGlobalVariable.LARGE_FILE_SIZE and
  File 
"/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/Common/LongFilePathOsPath.py",
 line 21, in getsize
return os.path.getsize(LongFilePath(filename))
  File "/usr/lib/python3.8/genericpath.py", line 50, in getsize
return os.stat(filename).st_size
FileNotFoundError: [Errno 2] No such file or directory: 
'/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/Build/MakenaAU/Core/RELEASE_CLANG100LINUX/FV/Ffs/5E0EAE60-EAED-4D75-B8BF-EDBBAABC3F09SecurityDxe/5E0EAE60-EAED-4D75-B8BF-EDBBAABC3F09SEC2.1.pe32'

 


- Failed -
Build end time: 09:21:47, Apr.06 2023
Build total time: 00:00:05

 

ERROR: buildex::Run  ['python', 
'/home/luming/01_work/01_project/8295/rse/sa8295p-hqx-4-5-5-1_amss_standard_oem.git/boot/boot_images/edk2/BaseTools/Source/Python/build/build.py',
 '-p', 'QcomPkg/SocPkg/Makena/AU/Core.dsc', '-j', 
'QcomPkg/SocPkg/Makena/AU/build_Core.log', '-w', '-a', 'AARCH64', '-b', 
'RELEASE', '-t', 'CLANG100LINUX', 'cleanall', '-D', 

Re: [edk2-devel] [PATCH v4 0/3] Adds Platform/AMD/AmdMinBoardPkg

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

Forget to CC Sean.

Hi Sean,
The package naming AmdMinBoardPkg looks good to you?

Thanks
Abner


> -Original Message-
> From: Chang, Abner
> Sent: Tuesday, April 11, 2023 7:05 PM
> To: Abdul Lateef Attar ; devel@edk2.groups.io
> Cc: Attar, AbdulLateef (Abdul Lateef) ; Ard
> Biesheuvel ; Leif Lindholm
> ; Michael D Kinney
> 
> Subject: RE: [PATCH v4 0/3] Adds Platform/AMD/AmdMinBoardPkg
> 
> [AMD Official Use Only - General]
> 
> Is any one has additional comments on the V4 patch set? Otherwise I will
> push it to edk2-platforms.
> 
> Thanks
> Abner
> 
> > -Original Message-
> > From: Abdul Lateef Attar 
> > Sent: Monday, April 3, 2023 7:23 PM
> > To: devel@edk2.groups.io
> > Cc: Attar, AbdulLateef (Abdul Lateef) ; Ard
> > Biesheuvel ; Leif Lindholm
> > ; Chang, Abner ;
> > Michael D Kinney 
> > Subject: [PATCH v4 0/3] Adds Platform/AMD/AmdMinBoardPkg
> >
> > V4 changes:
> >   Rename MinBoardPkg to AmdMinBoardPkg.
> >   removed empty Guid section.
> > V3 changes:
> >   Dropped the PlatformPkg package.
> >   Rename BoardPkg to MinBoardPkg
> >   Addressed review comments from Leif and Abner.
> >
> > Adds AMD/AmdMinBoardPkg to support MinPlatformPkg framework.
> >
> > PR: https://github.com/tianocore/edk2-platforms/pull/75
> >
> > Cc: Ard Biesheuvel 
> > Cc: Leif Lindholm 
> > Cc: Abner Chang 
> > Cc: Michael D Kinney 
> > Cc: Abdul Lateef Attar 
> >
> > Abdul Lateef Attar (3):
> >   Platform/AMD: Adds AmdMinBoardPkg to support MinPlatformPkg
> >   Platform/AMD/MinBoardPkg: Adds SetCacheMtrrLib library
> >   Maintainers.txt: Adds AMD/AmdMinBoardPkg maintainers
> >
> >  .../AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec |  19 +++
> >  .../AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc |  30 
> >  .../SetCacheMtrrLib/SetCacheMtrrLib.inf   |  35 +
> >  .../Library/SetCacheMtrrLib/SetCacheMtrrLib.c | 133
> ++
> >  Maintainers.txt   |   5 +
> >  5 files changed, 222 insertions(+)
> >  create mode 100644
> > Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec
> >  create mode 100644
> > Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc
> >  create mode 100644
> >
> Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib
> > .inf
> >  create mode 100644
> >
> Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib
> > .c
> >
> > --
> > 2.25.1


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




Re: [edk2-devel] [PATCH v7 1/3] UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support

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

Hi Richard and Pedro,
Understand that is the standard USB communication class device, that is why I 
think put it under MdeModulePkg/Bus/Usb/UsbNetwork makes more sense because it 
is similar to the USB mass storage or HID classes.
USB RNDIS driver and EDKII USB Ethernet protocol are on top of USB devices that 
akin to BLOCK IO protocol to USB MSD, which I think those two can be located 
under MdeModulePkg/Bus/Usb/UsbNetwork as well because those are only used by 
USB CDC devices.
That is no problem to add those fixed PCDs and other definitions such as 
protocol definitions in MdeModulePkg.dec if UsbNetwork is part of MdeModulePkg.

Thanks
Abner

> -Original Message-
> From: Richard Ho (何明忠) 
> Sent: Wednesday, April 12, 2023 10:27 AM
> To: Pedro Falcato ; devel@edk2.groups.io;
> rebe...@bsdio.com; Chang, Abner 
> Cc: Andrew Fish ; Leif Lindholm
> ; Michael D Kinney
> ; Michael Kubacki
> ; Zhiguang Liu ;
> Liming Gao ; Tinh Nguyen
> ; Tony Lo (羅金松)
> ; Marvin Häuser 
> Subject: RE: [EXTERNAL] Re: [edk2-devel] [PATCH v7 1/3]
> UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Hi Pedro/Abner,
> 
> UsbNetworkPkg provide the RNDIS/ECM/NCM device support that are
> implement form USB specification(we have other USB network device's
> driver to upstream).
> It is not specific USB device. The driver could work on any platform. So, we
> create UsbNetworkPkg same as NetworkPkg in edk2 repo.
> 
> Currently, we have some Fixed PCDs in UsbNetworkPkg.dec. Can add it to
> MdeModulePkg.dec?
> Which one is better for upstream from below rules?
> 
> #1: edk2-platforms/Features/UsbNetworkPkg
> #2: edk2/MdeModulePkg/Bus/Usb/UsbNetwork
> #3: edk2/UsbNetworkPkg
> 
> Thanks,
> Richard
> 
> -Original Message-
> From: Pedro Falcato 
> Sent: 2023年4月11日 8:39 PM
> To: devel@edk2.groups.io; rebe...@bsdio.com
> Cc: Richard Ho (何明忠) ; Andrew Fish
> ; Leif Lindholm ; Michael D
> Kinney ; Michael Kubacki
> ; Zhiguang Liu ;
> Liming Gao ; Tinh Nguyen
> ; Tony Lo (羅金松)
> ; Marvin Häuser 
> Subject: [EXTERNAL] Re: [edk2-devel] [PATCH v7 1/3]
> UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support
> 
> 
> **CAUTION: The e-mail below is from an external source. Please exercise
> caution before opening attachments, clicking links, or following guidance.**
> 
> On Tue, Apr 11, 2023 at 1:31 PM Rebecca Cran  wrote:
> > Given this is adding a new top-level package, I'd like to see a
> > review/feedback from the TianoCore Stewards.
> 
> I would personally love to understand why this is being pushed as a top level
> package in edk2 when "supposedly" edk2-platforms/Features is the more
> correct approach here (as discussed with Sean, Nate a few months back).
> 
> Or is that hellscape only reserved for me? :v
> 
> --
> Pedro
> -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 (#102864): https://edk2.groups.io/g/devel/message/102864
Mute This Topic: https://groups.io/mt/98122714/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [edk2-platforms][PATCH] ManageabilityPkg: add support for the phosphor ipmi blob transfer protocol

2023-04-11 Thread Nickle Wang via groups.io
This change implements the blob transfer protocol used in OpenBmc
documented here: https://github.com/openbmc/phosphor-ipmi-blobs

Signed-off-by: Nick Ramirez 
Cc: Abner Chang 
Cc: Isaac Oram 
Cc: Abdul Lateef Attar 
Cc: Nickle Wang 
Cc: Tinh Nguyen 
---
 .../ManageabilityPkg/ManageabilityPkg.dec |6 +
 .../Include/Dsc/Manageability.dsc |4 +-
 .../IpmiBlobTransferDxe.inf   |   39 +
 .../IpmiBlobTransferTestUnitTestsHost.inf |   40 +
 .../Include/Protocol/IpmiBlobTransfer.h   |  136 ++
 .../InternalIpmiBlobTransfer.h|  363 ++
 .../IpmiBlobTransferDxe/IpmiBlobTransferDxe.c |  799 
 .../UnitTest/IpmiBlobTransferTestUnitTests.c  | 1113 +
 .../Universal/IpmiBlobTransferDxe/Readme.md   |   24 +
 9 files changed, 2523 insertions(+), 1 deletion(-)
 create mode 100644 
Features/ManageabilityPkg/Universal/IpmiBlobTransferDxe/IpmiBlobTransferDxe.inf
 create mode 100644 
Features/ManageabilityPkg/Universal/IpmiBlobTransferDxe/UnitTest/IpmiBlobTransferTestUnitTestsHost.inf
 create mode 100644 
Features/ManageabilityPkg/Include/Protocol/IpmiBlobTransfer.h
 create mode 100644 
Features/ManageabilityPkg/Universal/IpmiBlobTransferDxe/InternalIpmiBlobTransfer.h
 create mode 100644 
Features/ManageabilityPkg/Universal/IpmiBlobTransferDxe/IpmiBlobTransferDxe.c
 create mode 100644 
Features/ManageabilityPkg/Universal/IpmiBlobTransferDxe/UnitTest/IpmiBlobTransferTestUnitTests.c
 create mode 100644 
Features/ManageabilityPkg/Universal/IpmiBlobTransferDxe/Readme.md

diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec 
b/Features/ManageabilityPkg/ManageabilityPkg.dec
index 9a930d3e4b..e2d650 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dec
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
@@ -4,6 +4,7 @@
 # those are related to the platform management.
 #
 # Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -48,3 +49,8 @@
   gManageabilityProtocolMctpGuid= { 0x76FED8F1, 0x0BE5, 0x4269, { 0xA3, 
0x1A, 0x38, 0x0F, 0x54, 0xF1, 0xA1, 0x8A } }
   # Manageability Protocol PLDM
   gManageabilityProtocolPldmGuid= { 0x3958090D, 0x69DD, 0x4868, { 0x9C, 
0x41, 0xC9, 0xAC, 0x31, 0xB5, 0x25, 0xC5 } }
+
+[Protocols]
+
+  ## Include/Protocol/IpmiBlobTransfer.h
+  gEdkiiIpmiBlobTransferProtocolGuid = { 0x05837c75, 0x1d65, 0x468b, { 0xb1, 
0xc2, 0x81, 0xaf, 0x9a, 0x31, 0x5b, 0x2c } }
diff --git a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc 
b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
index 0d868fdf4a..111d6b91dc 100644
--- a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
+++ b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
@@ -2,11 +2,13 @@
 # Common libraries for Manageabilty Package
 #
 # Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
 [LibraryClasses]
   
ManageabilityTransportHelperLib|ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf
+  
IpmiLib|MdeModulePkg/Library/DxeIpmiLibIpmiProtocol/DxeIpmiLibIpmiProtocol.inf
 
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
   #
@@ -22,4 +24,4 @@
 [Components.X64]
   ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocolDxe.inf
   ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.inf
-
+  ManageabilityPkg/Universal/IpmiBlobTransferDxe/IpmiBlobTransferDxe.inf
diff --git 
a/Features/ManageabilityPkg/Universal/IpmiBlobTransferDxe/IpmiBlobTransferDxe.inf
 
b/Features/ManageabilityPkg/Universal/IpmiBlobTransferDxe/IpmiBlobTransferDxe.inf
new file mode 100644
index 00..28e9d293c1
--- /dev/null
+++ 
b/Features/ManageabilityPkg/Universal/IpmiBlobTransferDxe/IpmiBlobTransferDxe.inf
@@ -0,0 +1,39 @@
+## @file
+# IPMI Blob Transfer Protocol DXE Driver.
+#
+#  Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights 
reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = IpmiBlobTransferDxe
+  FILE_GUID  = 6357c804-78bb-4b0c-abdf-c75df942f319
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= IpmiBlobTransferDxeDriverEntryPoint
+
+[Sources.common]
+  IpmiBlobTransferDxe.c
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  IpmiLib
+  MemoryAllocationLib
+  PcdLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  ManageabilityPkg/ManageabilityPkg.dec
+
+[Protocols]
+  gEdkiiIpmiBlobTransferProtocolGuid
+
+[Depex]
+  TRUE
diff --git 

Re: [edk2-devel] [PATCH v7 1/3] UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support

2023-04-11 Thread RichardHo [何明忠] via groups . io
Hi Pedro/Abner,

UsbNetworkPkg provide the RNDIS/ECM/NCM device support that are implement form 
USB specification(we have other USB network device's driver to upstream).
It is not specific USB device. The driver could work on any platform. So, we 
create UsbNetworkPkg same as NetworkPkg in edk2 repo.

Currently, we have some Fixed PCDs in UsbNetworkPkg.dec. Can add it to 
MdeModulePkg.dec?
Which one is better for upstream from below rules?

#1: edk2-platforms/Features/UsbNetworkPkg
#2: edk2/MdeModulePkg/Bus/Usb/UsbNetwork
#3: edk2/UsbNetworkPkg

Thanks,
Richard

-Original Message-
From: Pedro Falcato 
Sent: 2023年4月11日 8:39 PM
To: devel@edk2.groups.io; rebe...@bsdio.com
Cc: Richard Ho (何明忠) ; Andrew Fish ; Leif 
Lindholm ; Michael D Kinney 
; Michael Kubacki ; 
Zhiguang Liu ; Liming Gao ; 
Tinh Nguyen ; Tony Lo (羅金松) 
; Marvin Häuser 
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH v7 1/3] UsbNetworkPkg/UsbRndis: Add 
USB RNDIS devices support


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

On Tue, Apr 11, 2023 at 1:31 PM Rebecca Cran  wrote:
> Given this is adding a new top-level package, I'd like to see a
> review/feedback from the TianoCore Stewards.

I would personally love to understand why this is being pushed as a top level 
package in edk2 when "supposedly" edk2-platforms/Features is the more correct 
approach here (as discussed with Sean, Nate a few months back).

Or is that hellscape only reserved for me? :v

--
Pedro
-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 (#102862): https://edk2.groups.io/g/devel/message/102862
Mute This Topic: https://groups.io/mt/98122714/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




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

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

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

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

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

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

*Description:*

TianoCore Bug Triage - APAC / NAMO

Hosted by Liming Gao



Microsoft Teams meeting

*Join on your computer or mobile app*

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

*Join with a video conferencing device*

te...@conf.intel.com

Video Conference ID: 116 062 094 0

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

*Or call in (audio only)*

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

Phone Conference ID: 774 638 21#

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

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


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




Re: [edk2-devel] [PATCH 1/1] BaseTools: Update PatchCheck.py to check for __FUNCTION__

2023-04-11 Thread Michael D Kinney
I agree C related source files and scripts that generate C code would be 
included.

Some of BaseTools python scripts generate .c/.h files too, so don't want to 
exclude all .py.

Perhaps just exclude __file__?

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Rebecca Cran
> Sent: Tuesday, April 11, 2023 2:30 PM
> To: devel@edk2.groups.io; Kinney, Michael D ; 
> Gao, Liming ; Feng,
> Bob C ; Chen, Christine 
> Subject: Re: [edk2-devel] [PATCH 1/1] BaseTools: Update PatchCheck.py to 
> check for __FUNCTION__
> 
> On 4/11/23 2:21 PM, Michael D Kinney wrote:
> > Should use we os.path services to get the file extension?
> >
> > There are may other file types that this check should be excluded
> > (e.g. .sh, .gitignore, .gitmodules, .uni).  Should this check only
> > apply to .c, .h.  What about .C and .H and also the addition of unit
> > tests that use c++ file extensions?
> 
> __func__ is valid in C99 and C++11, so it should apply to .c, .h, .C,
> .H, .cpp, .hpp etc.
> 
> I was wondering if we might have shell scripts that generate code too,
> for example OvmfPkg/QemuVideoDxe/VbeShim.sh, in which case we might only
> want to exclude .py which would catch this change to PatchCheck.py.
> 
> 
> --
> Rebecca Cran
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102860): https://edk2.groups.io/g/devel/message/102860
Mute This Topic: https://groups.io/mt/98117903/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/1] BaseTools: Update PatchCheck.py to check for __FUNCTION__

2023-04-11 Thread Rebecca Cran

On 4/11/23 2:21 PM, Michael D Kinney wrote:

Should use we os.path services to get the file extension?

There are may other file types that this check should be excluded
(e.g. .sh, .gitignore, .gitmodules, .uni).  Should this check only
apply to .c, .h.  What about .C and .H and also the addition of unit
tests that use c++ file extensions?


__func__ is valid in C99 and C++11, so it should apply to .c, .h, .C, 
.H, .cpp, .hpp etc.


I was wondering if we might have shell scripts that generate code too, 
for example OvmfPkg/QemuVideoDxe/VbeShim.sh, in which case we might only 
want to exclude .py which would catch this change to PatchCheck.py.



--
Rebecca Cran



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102859): https://edk2.groups.io/g/devel/message/102859
Mute This Topic: https://groups.io/mt/98117903/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] BaseTools: Update PatchCheck.py to check for __FUNCTION__

2023-04-11 Thread Michael D Kinney


> -Original Message-
> From: Rebecca Cran 
> Sent: Tuesday, April 11, 2023 11:06 AM
> To: devel@edk2.groups.io; Gao, Liming ; Feng, Bob C 
> ; Chen, Christine
> ; Kinney, Michael D 
> Subject: Re: [edk2-devel] [PATCH 1/1] BaseTools: Update PatchCheck.py to 
> check for __FUNCTION__
> 
> Could I get some reviews on this please?
> 
> 
> --
> 
> Rebecca Cran
> 
> 
> On 4/6/23 7:30 PM, Rebecca Cran wrote:
> > New code should use the C99 macro __func__ instead of the pre-Standard
> > macro __FUNCTION__. Update PatchCheck.py to reject patches with the
> > latter.
> >
> > Signed-off-by: Rebecca Cran 
> > ---
> >   BaseTools/Scripts/PatchCheck.py | 4 
> >   1 file changed, 4 insertions(+)
> >
> > diff --git a/BaseTools/Scripts/PatchCheck.py 
> > b/BaseTools/Scripts/PatchCheck.py
> > index 5d17d99a12ef..5f96b05dbcec 100755
> > --- a/BaseTools/Scripts/PatchCheck.py
> > +++ b/BaseTools/Scripts/PatchCheck.py
> > @@ -491,6 +491,10 @@ class GitDiffCheck:
> > 'but DEBUG_' + mo.group(1) +
> > ' is now recommended', line)
> >
> > +if line.find('__FUNCTION__') != -1 and not 
> > self.filename.endswith('.py'):

Should use we os.path services to get the file extension?

There are may other file types that this check should be excluded
(e.g. .sh, .gitignore, .gitmodules, .uni).  Should this check only
apply to .c, .h.  What about .C and .H and also the addition of unit
tests that use c++ file extensions?

> > +self.added_line_error('__FUNCTION__ was used, but __func__ '
> > +  'is now recommended', line)
> > +
> >   split_diff_re = re.compile(r'''
> >  (?P
> >  ^ diff \s+ --git \s+ a/.+ \s+ b/.+ 
> > $


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102858): https://edk2.groups.io/g/devel/message/102858
Mute This Topic: https://groups.io/mt/98117903/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/1] BaseTools: Update SetupGit.py to add new 'fp' alias for patch formatting

2023-04-11 Thread Michael D Kinney
Reviewed-by: Michael D Kinney 


> -Original Message-
> From: Rebecca Cran 
> Sent: Tuesday, April 11, 2023 11:06 AM
> To: devel@edk2.groups.io; Gao, Liming ; Feng, Bob C 
> ; Chen, Christine
> ; Kinney, Michael D 
> Subject: Re: [edk2-devel] [PATCH 1/1] BaseTools: Update SetupGit.py to add 
> new 'fp' alias for patch formatting
> 
> Could I get some reviews on this please?
> 
> 
> --
> 
> Rebecca Cran
> 
> 
> 
> On 4/6/23 7:28 PM, Rebecca Cran wrote:
> > To help people format patches with the correct options, add an alias
> > named 'fp' to SetupGit.py that runs format-patch with '-M --stat=1000
> > --stat-graph-width=20'.
> >
> > Signed-off-by: Rebecca Cran 
> > ---
> >   BaseTools/Scripts/SetupGit.py | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/BaseTools/Scripts/SetupGit.py b/BaseTools/Scripts/SetupGit.py
> > index 91814199bfb9..5f93124967bf 100644
> > --- a/BaseTools/Scripts/SetupGit.py
> > +++ b/BaseTools/Scripts/SetupGit.py
> > @@ -57,6 +57,8 @@ MIN_GIT_VERSION = (1, 9, 0)
> >
> >   # Set of options to be set identically for all repositories
> >   OPTIONS = [
> > +{'section': 'alias',   'option': 'fp',
> > + 'value': 'format-patch -M --stat=1000 --stat-graph-width=20'},
> >   {'section': 'am',  'option': 'keepcr','value': 
> > True},
> >   {'section': 'am',  'option': 'signoff',   'value': 
> > True},
> >   {'section': 'cherry-pick', 'option': 'signoff',   'value': 
> > True},


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102856): https://edk2.groups.io/g/devel/message/102856
Mute This Topic: https://groups.io/mt/98117880/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 v8 1/9] MdePkg: Adds AMD SMRAM save state map

2023-04-11 Thread Michael D Kinney
I agree.  This is proper use of the term "Smram".

Mike

> -Original Message-
> From: Ni, Ray 
> Sent: Tuesday, April 11, 2023 12:38 AM
> To: devel@edk2.groups.io; abdat...@amd.com; Kinney, Michael D 
> 
> Cc: Paul Grimes ; Garrett Kirkendall 
> ; Abner Chang ;
> Gao, Liming ; Liu, Zhiguang 
> Subject: RE: [edk2-devel] [PATCH v8 1/9] MdePkg: Adds AMD SMRAM save state map
> 
> The patch looks good in general.
> @Kinney, Michael D, I think it's ok to use "SmramSaveStateMap.h" instead of 
> "MmramSaveStateMap.h" because it matches to
> the CPU spec.
> Do you agree?
> 
> "MM" is more like a general term that applies to all archs, X86, ARM, etc.
> 
> Abdul, just curious why do you add prefix "_" for some of the fields? I am ok 
> if it matches to the AMD CPU spec.
> 
> Thanks,
> Ray
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Abdul
> > Lateef Attar via groups.io
> > Sent: Monday, April 10, 2023 7:10 PM
> > To: devel@edk2.groups.io
> > Cc: Abdul Lateef Attar ; Paul Grimes
> > ; Garrett Kirkendall ;
> > Abner Chang ; Kinney, Michael D
> > ; Gao, Liming ;
> > Liu, Zhiguang 
> > Subject: [edk2-devel] [PATCH v8 1/9] MdePkg: Adds AMD SMRAM save state
> > map
> >
> > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182
> >
> > Adds an SMM SMRAM save-state map for AMD processors.
> > SMRAM save state maps for the AMD processor family are now supported.
> >
> > Save state map structure is added based on
> > AMD64 Architecture Programmer's Manual, Volume 2, Section 10.2.
> >
> > The AMD legacy save state map for 32-bit architecture is defined.
> > The AMD64 save state map for 64-bit architecture is defined.
> >
> > Also added Amd/SmramSaveStateMap.h to IgnoreFiles of EccCheck,
> > because structures defined in this file are derived from
> > Intel/SmramSaveStateMap.h.
> >
> > Cc: Paul Grimes 
> > Cc: Garrett Kirkendall 
> > Cc: Abner Chang 
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> >
> > Signed-off-by: Abdul Lateef Attar 
> > Reviewed-by: Abner Chang 
> > Reviewed-by: Michael D Kinney 
> > ---
> >  .../Include/Register/Amd/SmramSaveStateMap.h  | 194
> > ++
> >  MdePkg/MdePkg.ci.yaml |   4 +-
> >  2 files changed, 197 insertions(+), 1 deletion(-)
> >  create mode 100644
> > MdePkg/Include/Register/Amd/SmramSaveStateMap.h
> >
> > diff --git a/MdePkg/Include/Register/Amd/SmramSaveStateMap.h
> > b/MdePkg/Include/Register/Amd/SmramSaveStateMap.h
> > new file mode 100644
> > index ..0607d2a19145
> > --- /dev/null
> > +++ b/MdePkg/Include/Register/Amd/SmramSaveStateMap.h
> > @@ -0,0 +1,194 @@
> > +/** @file
> > +  AMD SMRAM Save State Map Definitions.
> > +
> > +  SMRAM Save State Map definitions based on contents of the
> > +AMD64 Architecture Programmer Manual:
> > +Volume 2, System Programming, Section 10.2 SMM Resources
> > +
> > +  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
> > +  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved .
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#ifndef AMD_SMRAM_SAVE_STATE_MAP_H_
> > +#define AMD_SMRAM_SAVE_STATE_MAP_H_
> > +
> > +///
> > +/// Default SMBASE address
> > +///
> > +#define SMM_DEFAULT_SMBASE  0x3
> > +
> > +///
> > +/// Offset of SMM handler from SMBASE
> > +///
> > +#define SMM_HANDLER_OFFSET  0x8000
> > +
> > +// SMM-Revision Identifier for AMD64 Architecture.
> > +#define AMD_SMM_MIN_REV_ID_X64  0x30064
> > +
> > +#pragma pack (1)
> > +
> > +///
> > +/// 32-bit SMRAM Save State Map
> > +///
> > +typedef struct {
> > +  // Padded an extra 0x200 bytes to match Intel/EDK2
> > +  UINT8 Reserved[0x200]; // fc00h
> > +  // AMD Save State area starts @ 0xfe00
> > +  UINT8 Reserved1[0xf8]; // fe00h
> > +  UINT32SMBASE;  // fef8h
> > +  UINT32SMMRevId;// fefch
> > +  UINT16IORestart;   // ff00h
> > +  UINT16AutoHALTRestart; // ff02h
> > +  UINT8 Reserved2[0x84]; // ff04h
> > +  UINT32GDTBase; // ff88h
> > +  UINT64Reserved3;   // ff8ch
> > +  UINT32IDTBase; // ff94h
> > +  UINT8 Reserved4[0x10]; // ff98h
> > +  UINT32_ES; // ffa8h
> > +  UINT32_CS; // ffach
> > +  UINT32_SS; // ffb0h
> > +  UINT32_DS; // ffb4h
> > +  UINT32_FS; // ffb8h
> > +  UINT32_GS; // ffbch
> > +  UINT32LDTBase; // ffc0h
> > +  UINT32_TR; // ffc4h
> > +  UINT32_DR7;// ffc8h
> > +  UINT32_DR6;// ffcch
> > +  UINT32_EAX;// ffd0h
> > +  UINT32_ECX;// ffd4h
> > +  UINT32_EDX;// ffd8h
> > +  UINT32_EBX;// ffdch
> > +  UINT32_ESP;// ffe0h
> > +  UINT32_EBP;// ffe4h
> > +  UINT32_ESI;// ffe8h
> > +  UINT32_EDI;// ffech
> > +  UINT32_EIP;   

Re: [edk2-devel] [PATCH v8 0/9] Adds AmdSmmCpuFeaturesLib and SmmSmramSaveStateLib

2023-04-11 Thread Michael D Kinney
Thanks for the feedback Abdul.  We usually do not see this in the history for a 
new lib instance.

I know we recommend developers start from a template of a lib instance if it is 
available
and then fill in the specific implementation, but those 2 steps do not go into 
commit
history.

Mike

> -Original Message-
> From: Attar, AbdulLateef (Abdul Lateef) 
> Sent: Monday, April 10, 2023 9:17 PM
> To: Chang, Abner ; Kinney, Michael D 
> ; devel@edk2.groups.io
> Cc: Grimes, Paul ; Kirkendall, Garrett 
> ; Dong, Eric
> ; Ni, Ray ; Kumar, Rahul R 
> ; Gerd Hoffmann
> ; Gao, Liming ; Liu, Zhiguang 
> ; Ard Biesheuvel
> ; Yao, Jiewen ; Justen, 
> Jordan L 
> Subject: RE: [PATCH v8 0/9] Adds AmdSmmCpuFeaturesLib and SmmSmramSaveStateLib
> 
> [AMD Official Use Only - General]
> 
> Hi Mike, Abner,
> Patch 5/9 is blank implementation of SmmCpuFeaturesLib library class.
> Whereas patch 6/9 is actual implementation of the library for AMD processor 
> family.
> I had separated in two different patches for easy to review.
> Thanks
> AbduL
> 
> -Original Message-
> From: Chang, Abner 
> Sent: 11 April 2023 06:38
> To: Kinney, Michael D ; Attar, AbdulLateef (Abdul 
> Lateef) ;
> devel@edk2.groups.io
> Cc: Grimes, Paul ; Kirkendall, Garrett 
> ; Dong, Eric
> ; Ni, Ray ; Kumar, Rahul R 
> ; Gerd Hoffmann
> ; Gao, Liming ; Liu, Zhiguang 
> ; Ard Biesheuvel
> ; Yao, Jiewen ; Justen, 
> Jordan L 
> Subject: RE: [PATCH v8 0/9] Adds AmdSmmCpuFeaturesLib and SmmSmramSaveStateLib
> 
> [AMD Official Use Only - General]
> 
> Hi Mike,
> I think 5/9 was added for those functions AMD has no implementation as the 
> initial commit, while 6/9 was updated for the
> functions with AMD implementations.
> @Attar, AbdulLateef (Abdul Lateef)can confirm this.
> 
> Thanks
> Abner
> 
> > -Original Message-
> > From: Kinney, Michael D 
> > Sent: Tuesday, April 11, 2023 12:29 AM
> > To: Attar, AbdulLateef (Abdul Lateef) ;
> > devel@edk2.groups.io
> > Cc: Grimes, Paul ; Kirkendall, Garrett
> > ; Chang, Abner ;
> > Dong, Eric ; Ni, Ray ; Kumar,
> > Rahul R ; Gerd Hoffmann ;
> > Gao, Liming ; Liu, Zhiguang
> > ; Ard Biesheuvel ;
> > Yao, Jiewen ; Justen, Jordan L
> > ; Kinney, Michael D
> > 
> > Subject: RE: [PATCH v8 0/9] Adds AmdSmmCpuFeaturesLib and
> > SmmSmramSaveStateLib
> >
> > Caution: This message originated from an External Source. Use proper
> > caution when opening attachments, clicking links, or responding.
> >
> >
> > Is there a reason why patches 5 and 6 where not combined?
> >
> > Mike
> >
> > > -Original Message-
> > > From: Abdul Lateef Attar 
> > > Sent: Monday, April 10, 2023 4:10 AM
> > > To: devel@edk2.groups.io
> > > Cc: Abdul Lateef Attar ; Paul Grimes
> > > ; Garrett Kirkendall
> > > ; Abner Chang ;
> > Dong,
> > > Eric ; Ni, Ray ; Kumar, Rahul
> > > R ; Gerd Hoffmann ;
> > Kinney,
> > > Michael D ; Gao, Liming
> > > ; Liu, Zhiguang ;
> > > Ard Biesheuvel ; Yao, Jiewen
> > > ; Justen, Jordan L 
> > > Subject: [PATCH v8 0/9] Adds AmdSmmCpuFeaturesLib and
> > > SmmSmramSaveStateLib
> > >
> > > PR: https://github.com/tianocore/edk2/pull/4258
> > >
> > > V8 delta changes:
> > >Addressed review comments from Abner,
> > >Fix the whitespace error.
> > >Seperate the Ovmf changes to another patch
> > > V7 delta changes:
> > >Adds SmmSmramSaveStateLib for Intel processor.
> > >Integrate SmmSmramSaveStateLib library.
> > > V6 delta changes:
> > >Addressed review comments for Ray NI.
> > >removed unnecessary EFIAPI.
> > > V5 delta changes:
> > >rebase to master branch.
> > >updated Reviewed-by
> > > V4 delta changes:
> > >   rebase to master branch.
> > >   added reviewed-by.
> > > V3 delta changes:
> > >   Addressed review comments from Abner chang.
> > >   Re-arranged patch order.
> > >
> > > Cc: Paul Grimes 
> > > Cc: Garrett Kirkendall 
> > > Cc: Abner Chang 
> > > Cc: Eric Dong 
> > > Cc: Ray Ni 
> > > Cc: Rahul Kumar 
> > > Cc: Gerd Hoffmann 
> > > Cc: Michael D Kinney 
> > > Cc: Liming Gao 
> > > Cc: Zhiguang Liu 
> > > Cc: Ard Biesheuvel 
> > > Cc: Jiewen Yao 
> > > Cc: Jordan Justen 
> > > Cc: Abdul Lateef Attar 
> > >
> > > Abdul Lateef Attar (9):
> > >   MdePkg: Adds AMD SMRAM save state map
> > >   UefiCpuPkg: Adds SmmSmramSaveStateLib library class
> > >   UefiCpuPkg: Implements SmmSmramSaveStateLib library class
> > >   UefiCpuPkg/SmmCpuFeaturesLib: Restructure arch-dependent code
> > >   UefiCpuPkg: Initial implementation of AMD's SmmCpuFeaturesLib
> > >   UefiCpuPkg: Implements SmmCpuFeaturesLib for AMD Family
> > >   UefiCpuPkg: Implements SmmSmramSaveStateLib for Intel
> > >   UefiCpuPkg: Uses SmmSmramSaveStateLib library
> > >   OvmfPkg: Uses SmmSmramSaveStateLib library
> > >
> > >  UefiCpuPkg/UefiCpuPkg.dec |   4 +
> > >  OvmfPkg/OvmfPkgIa32X64.dsc|   2 +
> > >  UefiCpuPkg/UefiCpuPkg.dsc |  15 +
> > >  .../AmdSmmCpuFeaturesLib.inf  |  38 ++
> > >  

Re: [edk2-devel] [PATCH 1/2] SimicsOpenBoardPkg: Fix bug in DSDT

2023-04-11 Thread Michael D Kinney
Looks like obvious syntax fix.

Reviewed-by: Michael D Kinney 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ni, Ray
> Sent: Monday, April 10, 2023 7:53 PM
> To: Desimone, Nathaniel L 
> Cc: devel@edk2.groups.io; Guenzel, Robert 
> Subject: Re: [edk2-devel] [PATCH 1/2] SimicsOpenBoardPkg: Fix bug in DSDT
> 
> Nate, can you help to give the R-B and push?
> 
> Thanks,
> Ray
> 
> > -Original Message-
> > From: Ni, Ray
> > Sent: Saturday, October 8, 2022 3:32 PM
> > To: devel@edk2.groups.io; Guenzel, Robert 
> > Subject: RE: [PATCH 1/2] SimicsOpenBoardPkg: Fix bug in DSDT
> >
> > Thanks for fixing that.
> > Reviewed-by: Ray Ni 
> >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of
> > Guenzel,
> > > Robert
> > > Sent: Friday, October 7, 2022 5:27 PM
> > > To: devel@edk2.groups.io
> > > Cc: Guenzel, Robert 
> > > Subject: [edk2-devel] [PATCH 1/2] SimicsOpenBoardPkg: Fix bug in DSDT
> > >
> > >
> > > The DSDT had a syntax error that was not detected by older iasl versions.
> > > This commit fixes the Syntax error.
> > >
> > > Signed-off-by: Robert Guenzel 
> > > ---
> > >  Platform/Intel/SimicsOpenBoardPkg/AcpiTables/Dsdt.asl | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/Platform/Intel/SimicsOpenBoardPkg/AcpiTables/Dsdt.asl
> > > b/Platform/Intel/SimicsOpenBoardPkg/AcpiTables/Dsdt.asl
> > > index 8a6c3792..3421c9e8 100644
> > > --- a/Platform/Intel/SimicsOpenBoardPkg/AcpiTables/Dsdt.asl
> > > +++ b/Platform/Intel/SimicsOpenBoardPkg/AcpiTables/Dsdt.asl
> > > @@ -372,7 +372,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 1, "INTEL ",
> > > "SIMICS  ", 4) {
> > >
> > >  Package () {0x000E, 0x00, 0, 16},
> > >  Package () {0x000E, 0x01, 0, 17},
> > > -Package () {0x000E, 0x02, 0C, 18},
> > > +Package () {0x000E, 0x02, 0, 18},
> > >  Package () {0x000E, 0x03, 0, 19},
> > >
> > >  Package () {0x000F, 0x00, 0, 16},
> > > --
> > > 2.34.1
> > >
> > > Intel Deutschland GmbH
> > > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
> > > Tel: +49 89 99 8853-0, www.intel.de 
> > > Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
> > > Chairperson of the Supervisory Board: Nicole Lau
> > > Registered Office: Munich
> > > Commercial Register: Amtsgericht Muenchen HRB 186928
> > >
> > >
> > >
> > >
> > >
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102853): https://edk2.groups.io/g/devel/message/102853
Mute This Topic: https://groups.io/mt/94178621/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 v8 0/9] Adds AmdSmmCpuFeaturesLib and SmmSmramSaveStateLib

2023-04-11 Thread Michael D Kinney
For the final version of this patch series, wouldn't only the full 
implementation commit be required in the git history?

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chang, Abner 
> via groups.io
> Sent: Monday, April 10, 2023 6:08 PM
> To: Kinney, Michael D ; Attar, AbdulLateef (Abdul 
> Lateef) ;
> devel@edk2.groups.io
> Cc: Grimes, Paul ; Kirkendall, Garrett 
> ; Dong, Eric
> ; Ni, Ray ; Kumar, Rahul R 
> ; Gerd Hoffmann
> ; Gao, Liming ; Liu, Zhiguang 
> ; Ard Biesheuvel
> ; Yao, Jiewen ; Justen, 
> Jordan L 
> Subject: Re: [edk2-devel] [PATCH v8 0/9] Adds AmdSmmCpuFeaturesLib and 
> SmmSmramSaveStateLib
> 
> [AMD Official Use Only - General]
> 
> Hi Mike,
> I think 5/9 was added for those functions AMD has no implementation as the 
> initial commit, while 6/9 was updated for the
> functions with AMD implementations.
> @Attar, AbdulLateef (Abdul Lateef)can confirm this.
> 
> Thanks
> Abner
> 
> > -Original Message-
> > From: Kinney, Michael D 
> > Sent: Tuesday, April 11, 2023 12:29 AM
> > To: Attar, AbdulLateef (Abdul Lateef) ;
> > devel@edk2.groups.io
> > Cc: Grimes, Paul ; Kirkendall, Garrett
> > ; Chang, Abner ;
> > Dong, Eric ; Ni, Ray ; Kumar, Rahul
> > R ; Gerd Hoffmann ; Gao,
> > Liming ; Liu, Zhiguang
> > ; Ard Biesheuvel ;
> > Yao, Jiewen ; Justen, Jordan L
> > ; Kinney, Michael D
> > 
> > Subject: RE: [PATCH v8 0/9] Adds AmdSmmCpuFeaturesLib and
> > SmmSmramSaveStateLib
> >
> > Caution: This message originated from an External Source. Use proper
> > caution when opening attachments, clicking links, or responding.
> >
> >
> > Is there a reason why patches 5 and 6 where not combined?
> >
> > Mike
> >
> > > -Original Message-
> > > From: Abdul Lateef Attar 
> > > Sent: Monday, April 10, 2023 4:10 AM
> > > To: devel@edk2.groups.io
> > > Cc: Abdul Lateef Attar ; Paul Grimes
> > > ; Garrett Kirkendall
> > > ; Abner Chang ;
> > Dong,
> > > Eric ; Ni, Ray ; Kumar, Rahul R
> > > ; Gerd Hoffmann ;
> > Kinney,
> > > Michael D ; Gao, Liming
> > > ; Liu, Zhiguang ;
> > > Ard Biesheuvel ; Yao, Jiewen
> > > ; Justen, Jordan L 
> > > Subject: [PATCH v8 0/9] Adds AmdSmmCpuFeaturesLib and
> > > SmmSmramSaveStateLib
> > >
> > > PR: https://github.com/tianocore/edk2/pull/4258
> > >
> > > V8 delta changes:
> > >Addressed review comments from Abner,
> > >Fix the whitespace error.
> > >Seperate the Ovmf changes to another patch
> > > V7 delta changes:
> > >Adds SmmSmramSaveStateLib for Intel processor.
> > >Integrate SmmSmramSaveStateLib library.
> > > V6 delta changes:
> > >Addressed review comments for Ray NI.
> > >removed unnecessary EFIAPI.
> > > V5 delta changes:
> > >rebase to master branch.
> > >updated Reviewed-by
> > > V4 delta changes:
> > >   rebase to master branch.
> > >   added reviewed-by.
> > > V3 delta changes:
> > >   Addressed review comments from Abner chang.
> > >   Re-arranged patch order.
> > >
> > > Cc: Paul Grimes 
> > > Cc: Garrett Kirkendall 
> > > Cc: Abner Chang 
> > > Cc: Eric Dong 
> > > Cc: Ray Ni 
> > > Cc: Rahul Kumar 
> > > Cc: Gerd Hoffmann 
> > > Cc: Michael D Kinney 
> > > Cc: Liming Gao 
> > > Cc: Zhiguang Liu 
> > > Cc: Ard Biesheuvel 
> > > Cc: Jiewen Yao 
> > > Cc: Jordan Justen 
> > > Cc: Abdul Lateef Attar 
> > >
> > > Abdul Lateef Attar (9):
> > >   MdePkg: Adds AMD SMRAM save state map
> > >   UefiCpuPkg: Adds SmmSmramSaveStateLib library class
> > >   UefiCpuPkg: Implements SmmSmramSaveStateLib library class
> > >   UefiCpuPkg/SmmCpuFeaturesLib: Restructure arch-dependent code
> > >   UefiCpuPkg: Initial implementation of AMD's SmmCpuFeaturesLib
> > >   UefiCpuPkg: Implements SmmCpuFeaturesLib for AMD Family
> > >   UefiCpuPkg: Implements SmmSmramSaveStateLib for Intel
> > >   UefiCpuPkg: Uses SmmSmramSaveStateLib library
> > >   OvmfPkg: Uses SmmSmramSaveStateLib library
> > >
> > >  UefiCpuPkg/UefiCpuPkg.dec |   4 +
> > >  OvmfPkg/OvmfPkgIa32X64.dsc|   2 +
> > >  UefiCpuPkg/UefiCpuPkg.dsc |  15 +
> > >  .../AmdSmmCpuFeaturesLib.inf  |  38 ++
> > >  .../AmdSmmSmramSaveStateLib.inf   |  28 +
> > >  .../IntelSmmSmramSaveStateLib.inf |  28 +
> > >  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf  |   2 +
> > >  .../Include/Register/Amd/SmramSaveStateMap.h  | 194 +++
> > >  .../Include/Library/SmmSmramSaveStateLib.h|  70 +++
> > >  .../SmmSmramSaveStateLib/SmramSaveState.h | 100 
> > >  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h|   2 +
> > >  .../SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c  | 445
> > 
> > >  .../IntelSmmCpuFeaturesLib.c  | 128 +
> > >  .../SmmCpuFeaturesLibCommon.c | 128 -
> > >  .../SmmSmramSaveStateLib/AmdSmramSaveState.c  | 286 ++
> > >  .../IntelSmramSaveState.c | 359 +
> > >  .../SmramSaveStateCommon.c| 232 
> > >  

Re: [edk2-devel] [PATCH 1/1] BaseTools: Update SetupGit.py to add new 'fp' alias for patch formatting

2023-04-11 Thread Rebecca Cran

Could I get some reviews on this please?


--

Rebecca Cran



On 4/6/23 7:28 PM, Rebecca Cran wrote:

To help people format patches with the correct options, add an alias
named 'fp' to SetupGit.py that runs format-patch with '-M --stat=1000
--stat-graph-width=20'.

Signed-off-by: Rebecca Cran 
---
  BaseTools/Scripts/SetupGit.py | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/BaseTools/Scripts/SetupGit.py b/BaseTools/Scripts/SetupGit.py
index 91814199bfb9..5f93124967bf 100644
--- a/BaseTools/Scripts/SetupGit.py
+++ b/BaseTools/Scripts/SetupGit.py
@@ -57,6 +57,8 @@ MIN_GIT_VERSION = (1, 9, 0)
  
  # Set of options to be set identically for all repositories

  OPTIONS = [
+{'section': 'alias',   'option': 'fp',
+ 'value': 'format-patch -M --stat=1000 --stat-graph-width=20'},
  {'section': 'am',  'option': 'keepcr','value': True},
  {'section': 'am',  'option': 'signoff',   'value': True},
  {'section': 'cherry-pick', 'option': 'signoff',   'value': True},



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102851): https://edk2.groups.io/g/devel/message/102851
Mute This Topic: https://groups.io/mt/98117880/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] BaseTools: Update PatchCheck.py to check for __FUNCTION__

2023-04-11 Thread Rebecca Cran

Could I get some reviews on this please?


--

Rebecca Cran


On 4/6/23 7:30 PM, Rebecca Cran wrote:

New code should use the C99 macro __func__ instead of the pre-Standard
macro __FUNCTION__. Update PatchCheck.py to reject patches with the
latter.

Signed-off-by: Rebecca Cran 
---
  BaseTools/Scripts/PatchCheck.py | 4 
  1 file changed, 4 insertions(+)

diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py
index 5d17d99a12ef..5f96b05dbcec 100755
--- a/BaseTools/Scripts/PatchCheck.py
+++ b/BaseTools/Scripts/PatchCheck.py
@@ -491,6 +491,10 @@ class GitDiffCheck:
'but DEBUG_' + mo.group(1) +
' is now recommended', line)
  
+if line.find('__FUNCTION__') != -1 and not self.filename.endswith('.py'):

+self.added_line_error('__FUNCTION__ was used, but __func__ '
+  'is now recommended', line)
+
  split_diff_re = re.compile(r'''
 (?P
 ^ diff \s+ --git \s+ a/.+ \s+ b/.+ $



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




[edk2-devel] [PATCH v4 1/1] MdePkg: Add new JedecJep106Lib to fetch JEDEC JEP106 manufacturer

2023-04-11 Thread Rebecca Cran
From: Rebecca Cran 

Add a new library, JedecJep106Lib which provides a service to return the
JEDEC JEP106 manufacturer string given the code and continuation bytes
values.

Signed-off-by: Rebecca Cran 
---
 MdePkg/MdePkg.dec|3 +
 MdePkg/MdePkg.dsc|2 +
 MdePkg/Library/JedecJep106Lib/JedecJep106Lib.inf |   25 +
 MdePkg/Include/Library/JedecJep106Lib.h  |   29 +
 MdePkg/Library/JedecJep106Lib/JedecJep106Lib.c   | 1839 
 5 files changed, 1898 insertions(+)

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 5cf04bc0cb69..3c6fbaa04062 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -258,6 +258,9 @@ [LibraryClasses]
   #
   UnitTestLib|Include/Library/UnitTestLib.h
 
+  ## @libraryclass Provides service to get the manufacturer given JEP106 bytes.
+  JedecJep106Lib|Include/Library/JedecJep106Lib.h
+
   ## @libraryclass Extension to BaseLib for host based unit tests that allows a
   #subset of BaseLib services to be hooked for emulation.
   #
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index 0ac7618b4623..152c02991a7c 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -136,6 +136,8 @@ [Components]
   MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf
   MdePkg/Library/SmmCpuRendezvousLibNull/SmmCpuRendezvousLibNull.inf
 
+  MdePkg/Library/JedecJep106Lib/JedecJep106Lib.inf
+
 [Components.IA32, Components.X64, Components.ARM, Components.AARCH64]
   #
   # Add UEFI Target Based Unit Tests
diff --git a/MdePkg/Library/JedecJep106Lib/JedecJep106Lib.inf 
b/MdePkg/Library/JedecJep106Lib/JedecJep106Lib.inf
new file mode 100644
index ..b49e2ba720fd
--- /dev/null
+++ b/MdePkg/Library/JedecJep106Lib/JedecJep106Lib.inf
@@ -0,0 +1,25 @@
+## @file
+#  Instance of JEDEC JEP106 Library
+#
+#  JedecJep106Lib fetches the manufacturer string given the JEP106
+#  Code and Continuation Bytes.
+#
+#  Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights 
reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001d
+  BASE_NAME  = JedecJep106Lib
+  FILE_GUID  = d48d43d7-ba31-4463-9433-ccb233cf0df7
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = JedecJep106Lib
+
+[Sources]
+  JedecJep106Lib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
diff --git a/MdePkg/Include/Library/JedecJep106Lib.h 
b/MdePkg/Include/Library/JedecJep106Lib.h
new file mode 100644
index ..de8904360d5d
--- /dev/null
+++ b/MdePkg/Include/Library/JedecJep106Lib.h
@@ -0,0 +1,29 @@
+/** @file
+  Provides JEDEC JEP-106 Manufacturer functions.
+
+  Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef JEDEC_JEP106_LIB_H_
+#define JEDEC_JEP106_LIB_H_
+
+/**
+  Looks up the JEP-106 manufacturer.
+
+  @param Code  Last non-zero byte of the manufacturer's ID code.
+  @param ContinuationBytes Number of continuation bytes indicated in JEP-106.
+
+  @return The manufacturer string, or NULL if an error occurred or the
+  combination of Code and ContinuationBytes are not valid.
+
+**/
+CONST CHAR8 *
+EFIAPI
+Jep106GetManufacturerName (
+  IN UINT8  Code,
+  IN UINT8  ContinuationBytes
+  );
+
+#endif /* JEDEC_JEP106_LIB_H_ */
diff --git a/MdePkg/Library/JedecJep106Lib/JedecJep106Lib.c 
b/MdePkg/Library/JedecJep106Lib/JedecJep106Lib.c
new file mode 100644
index ..f6fde355892f
--- /dev/null
+++ b/MdePkg/Library/JedecJep106Lib/JedecJep106Lib.c
@@ -0,0 +1,1839 @@
+/** @file
+  Provides JEDEC JEP-106 Manufacturer functions.
+
+  Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+
+typedef struct {
+  UINT8  Code;
+  CONST CHAR8*Manufacturer;
+} JEDEC_MANUFACTURERS;
+
+// From JEP106BE, published Jan 2022.
+GLOBAL_REMOVE_IF_UNREFERENCED
+STATIC CONST JEDEC_MANUFACTURERS  Jep106ManufacturersBank1[] = {
+  { 0x01, "AMD"  },
+  { 0x02, "AMI"  },
+  { 0x83, "Fairchild"},
+  { 0x04, "Fujitsu"  },
+  { 0x85, "GTE"  },
+  { 0x86, "Harris"   },
+  { 0x07, "Hitachi"  },
+  { 0x08, "Inmos"},
+  { 0x89, "Intel"},
+  { 0x8A, "I.T.T."   },
+  { 0x0B, "Intersil" },
+  { 0x8C, "Monolithic Technologies"  },
+  { 0x0D, "Mostek"   },
+  { 0x0E, "Freescale (Motorola)" },
+  { 0x8F, "National" },
+  { 0x10, "NEC"  },
+  { 0x91, "RCA"  },

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

2023-04-11 Thread Lendacky, Thomas via groups.io

On 4/11/23 05:04, Gerd Hoffmann wrote:

On Fri, Apr 07, 2023 at 12:00:46PM -0500, Tom Lendacky wrote:


Thanks for the quick turn-around, but that patch didn't work for me. I've
update the bugzilla.


Can you try the patch below?


That doesn't work either.

Specifying both OVMF_CODE.fd and OVMF_VARS.fd generates an ASSERT.
Specifying just OVMF_CODE.fd causes VMRUN failure (triple fault)
Specifying just OVMF.fd boots successfully

Thanks,
Tom



thanks,
   Gerd

 From a9179864523d12c3dcc137f36f6ed1a2832ed22c Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann 
Date: Tue, 11 Apr 2023 11:12:37 +0200
Subject: [PATCH 1/1] OvmfPkg: call ReserveEmuVariableNvStore after
  AmdSevInitialize

Signed-off-by: Gerd Hoffmann 
---
  OvmfPkg/PlatformPei/Platform.c | 10 ++
  1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index c56247e294f2..1e70c1920830 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -378,10 +378,6 @@ InitializePlatform (
InitializeRamRegions (PlatformInfoHob);
  
if (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) {

-if (!PlatformInfoHob->SmmSmramRequire) {
-  ReserveEmuVariableNvStore ();
-}
-
  PeiFvInitialization (PlatformInfoHob);
  MemTypeInfoInitialization (PlatformInfoHob);
  MemMapInitialization (PlatformInfoHob);
@@ -390,6 +386,12 @@ InitializePlatform (
  
InstallClearCacheCallback ();

AmdSevInitialize (PlatformInfoHob);
+
+  if ((PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) &&
+  (!PlatformInfoHob->SmmSmramRequire)) {
+ReserveEmuVariableNvStore ();
+  }
+
if (PlatformInfoHob->HostBridgeDevId == 0x) {
  MiscInitializationForMicrovm (PlatformInfoHob);
} else {



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102848): https://edk2.groups.io/g/devel/message/102848
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 0/8] BaseTools: remove duplicate includes.

2023-04-11 Thread Rebecca Cran
BaseTools fails to build on my system (Ubuntu 22.04.2 with g++ 11.3.0) 
after applying the patches.



g++ -o ../bin/VfrCompile  AParser.o DLexerBase.o ATokenBuffer.o 
EfiVfrParser.o VfrLexer.o VfrSyntax.o VfrFormPkg.o VfrError.o 
VfrUtilityLib.o VfrCompiler.o -L../libs -lCommon
/usr/bin/ld: VfrFormPkg.o: in function 
`CFormPkg::AdjustDynamicInsertOpcode(char*, char*, unsigned char)':

VfrFormPkg.cpp:(.text+0x12e0): undefined reference to `__assert_fail'
/usr/bin/ld: VfrFormPkg.cpp:(.text+0x160c): undefined reference to 
`__assert_fail'
/usr/bin/ld: VfrFormPkg.cpp:(.text+0x168c): undefined reference to 
`__assert_fail'
/usr/bin/ld: VfrFormPkg.cpp:(.text+0x16d8): undefined reference to 
`__assert_fail'
/usr/bin/ld: VfrFormPkg.o: in function `CIfrObj::CIfrObj(unsigned char, 
char**, unsigned char, unsigned char)':

VfrFormPkg.cpp:(.text+0x27a5): undefined reference to `__assert_fail'
/usr/bin/ld: VfrFormPkg.o:VfrFormPkg.cpp:(.text+0x3012): more undefined 
references to `__assert_fail' follow
/usr/bin/ld: VfrUtilityLib.o: in function 
`CVfrStringDB::GetVarStoreNameFormStringId(unsigned short)':

VfrUtilityLib.cpp:(.text+0x662f): undefined reference to `fseek'
/usr/bin/ld: VfrUtilityLib.cpp:(.text+0x6646): undefined reference to 
`fseek'

/usr/bin/ld: VfrCompiler.o: in function `CVfrCompiler::GenRecordListFile()':
VfrCompiler.cpp:(.text+0x18ed): undefined reference to `feof'
/usr/bin/ld: VfrLexer.o: in function `VfrLexer::nextTokenType()':
VfrLexer.cpp:(.text+0x13e3): undefined reference to `__assert_fail'
/usr/bin/ld: ../libs/libCommon.a(CommonLib.o): in function 
`InternalAllocatePool':
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:685: 
undefined reference to `__assert_fail'
/usr/bin/ld: ../libs/libCommon.a(CommonLib.o): in function 
`ReadUnaligned64':
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:1060: 
undefined reference to `__assert_fail'
/usr/bin/ld: ../libs/libCommon.a(CommonLib.o): in function 
`WriteUnaligned64':
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:1071: 
undefined reference to `__assert_fail'
/usr/bin/ld: ../libs/libCommon.a(CommonLib.o): in function 
`InternalAllocateCopyPool':
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:1132: 
undefined reference to `__assert_fail'
/usr/bin/ld: 
../libs/libCommon.a(CommonLib.o):/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:1903: 
more undefined references to `__assert_fail' follow

/usr/bin/ld: ../libs/libCommon.a(CommonLib.o): in function `GetFileImage':
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:168: 
undefined reference to `fseek'
/usr/bin/ld: 
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:193: 
undefined reference to `fseek'

/usr/bin/ld: ../libs/libCommon.a(CommonLib.o): in function `_filelength':
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:475: 
undefined reference to `fstat'

/usr/bin/ld: ../libs/libCommon.a(CommonLib.o): in function `StrnLenS':
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:657: 
undefined reference to `__assert_fail'

/usr/bin/ld: ../libs/libCommon.a(CommonLib.o): in function `StrLen':
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:741: 
undefined reference to `__assert_fail'
/usr/bin/ld: 
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:742: 
undefined reference to `__assert_fail'
/usr/bin/ld: ../libs/libCommon.a(CommonLib.o): in function 
`StrDecimalToUint64S':
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:846: 
undefined reference to `__assert_fail'
/usr/bin/ld: 
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:840: 
undefined reference to `__assert_fail'
/usr/bin/ld: 
../libs/libCommon.a(CommonLib.o):/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/CommonLib.c:839: 
more undefined references to `__assert_fail' follow
/usr/bin/ld: ../libs/libCommon.a(ParseInf.o): in function 
`FindSectionInStream':
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/ParseInf.c:618: 
undefined reference to `fseek'
/usr/bin/ld: 
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/ParseInf.c:624: 
undefined reference to `feof'
/usr/bin/ld: 
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/ParseInf.c:613: 
undefined reference to `__assert_fail'
/usr/bin/ld: 
/home/bcran/src/uefi/edk2/BaseTools/Source/C/Common/ParseInf.c:612: 
undefined reference to `__assert_fail'

/usr/bin/ld: ../bin/VfrCompile: hidden symbol `__assert_fail' isn't defined
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [GNUmakefile:45: ../bin/VfrCompile] Error 1
make[2]: Leaving directory 
'/home/bcran/src/uefi/edk2/BaseTools/Source/C/VfrCompile'

make[1]: *** [GNUmakefile:79: VfrCompile] Error 2
make[1]: Leaving directory '/home/bcran/src/uefi/edk2/BaseTools/Source/C'
make: *** [GNUmakefile:19: Source/C] Error 2
make: Leaving directory '/home/bcran/src/uefi/edk2/BaseTools'


--

Rebecca Cran


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

2023-04-11 Thread Michael D Kinney


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Pedro Falcato
> Sent: Tuesday, April 11, 2023 9:07 AM
> To: Tan, Lean Sheng 
> Cc: Kinney, Michael D ; Warkentin, Andrei 
> ; devel@edk2.groups.io;
> Lin, Benny ; Gao, Liming ; 
> Liu, Zhiguang ; Sean
> Brogan ; Michael Kubacki 
> 
> Subject: Re: [edk2-devel] [PATCH 0/2] Support FDT library.
> 
> On Tue, Apr 11, 2023 at 2:20 PM Lean Sheng Tan  
> wrote:
> >
> > Thanks Mike for the proposal layout!
> > It sounds good to me :)
> >
> > Hi Pedro,
> > I went through the email chain again, basically these are 2 of your main 
> > concerns (correct me if I'm wrong):
> > 1. a good idea to at least ditch that specific copy (current FDT in 
> > Embedded Pkg) for a git submodule.
> > 2. Rework to remove/reduce libc Implementation as there is a problem with 
> > both libc fragments and compiler intrinsic
> fragments all over edk2. Should unify standards between crypto, libfdt, etc, 
> could we try here
> >
> > I guess Mike has provided a plan to answer your first question, and the 2nd 
> > question would require a broader discussion
> with a few key owners.
> >
> > So it seems like we could get the current patchset from Benny Lin in for 
> > now? Any minor clean up needed for the current
> patch?
> >
> 
> No.
> 
> 3. Lots of questions and comments on the actual patch set regarding
> the quality of the libc implementation. Which should be fixed,
> regardless of centralizing a libc implementation.
> Also questions on the FdtLib itself (why are we wrapping pure
> libfdt functions with FluffyIdentifierNames and SCARY_TYPEDEFS?).

This is done to accommodate potential future changes to the submodule APIs
and types.  The wrapper lib is a common practice in EDK II use of submodules.
The calling code can use the APIs/types defined in EDK II lib class.  If
there are changes to the submodule APIs/types, we only have to update one
location. Can also provide flexibility to move to a different submodule or
implementation if there is a better option in the future.

Look at CryptoPkg CryptoLibs as an example. We have an implementation that
layers on top of openssl.  We also have experiments looking at mbedtls. 
No changes to calling code that uses CrytoLibs.

> I also sent out an RFC for a central libc for GCC/clang based
> toolchains, which should cover the libc usage of libfdt. Asked for
> testing, got ignored.

I provided feedback on your work on a central libc and asked if you are
able to test the libc uses currently checked into edk2.  Are you able to
help with that testing?

> 
> So a NAK from me, in its current state.
> 
> --
> Pedro
> 
> 
> 
> 



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

2023-04-11 Thread Pedro Falcato
On Tue, Apr 11, 2023 at 2:20 PM Lean Sheng Tan  wrote:
>
> Thanks Mike for the proposal layout!
> It sounds good to me :)
>
> Hi Pedro,
> I went through the email chain again, basically these are 2 of your main 
> concerns (correct me if I'm wrong):
> 1. a good idea to at least ditch that specific copy (current FDT in Embedded 
> Pkg) for a git submodule.
> 2. Rework to remove/reduce libc Implementation as there is a problem with 
> both libc fragments and compiler intrinsic fragments all over edk2. Should 
> unify standards between crypto, libfdt, etc, could we try here
>
> I guess Mike has provided a plan to answer your first question, and the 2nd 
> question would require a broader discussion with a few key owners.
>
> So it seems like we could get the current patchset from Benny Lin in for now? 
> Any minor clean up needed for the current patch?
>

No.

3. Lots of questions and comments on the actual patch set regarding
the quality of the libc implementation. Which should be fixed,
regardless of centralizing a libc implementation.
Also questions on the FdtLib itself (why are we wrapping pure
libfdt functions with FluffyIdentifierNames and SCARY_TYPEDEFS?).
I also sent out an RFC for a central libc for GCC/clang based
toolchains, which should cover the libc usage of libfdt. Asked for
testing, got ignored.

So a NAK from me, in its current state.

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102845): https://edk2.groups.io/g/devel/message/102845
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] [PATCH v2 7/8] BaseTools: remove duplicate includes: IndustryStandard/PeImage.h

2023-04-11 Thread Gerd Hoffmann
Use the MdePkg version instead of maintaining a copy in BaseTools.

Signed-off-by: Gerd Hoffmann 
Reviewed-by: Chao Li 
---
 .../C/Include/IndustryStandard/PeImage.h  | 790 --
 1 file changed, 790 deletions(-)
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/PeImage.h

diff --git a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h 
b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
deleted file mode 100644
index fb867b5660a9..
--- a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
+++ /dev/null
@@ -1,790 +0,0 @@
-/** @file
-  EFI image format for PE32+. Please note some data structures are different
-  for IA-32 and Itanium-based images, look for UINTN and the #ifdef EFI_IA64
-
-  @bug Fix text - doc as defined in MSFT EFI specification.
-
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-  Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
-  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights 
reserved.
-  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights 
reserved.
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __PE_IMAGE_H__
-#define __PE_IMAGE_H__
-
-//
-// PE32+ Subsystem type for EFI images
-//
-#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION 10
-#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
-#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER  12
-#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER  13
-
-//
-// BugBug: Need to get a real answer for this problem. This is not in the
-// PE specification.
-//
-// A SAL runtime driver does not get fixed up when a transition to
-// virtual mode is made. In all other cases it should be treated
-// like a EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER image
-//
-#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER  13
-
-//
-// PE32+ Machine type for EFI images
-//
-#define IMAGE_FILE_MACHINE_I3860x014c
-#define IMAGE_FILE_MACHINE_EBC 0x0EBC
-#define IMAGE_FILE_MACHINE_X64 0x8664
-#define IMAGE_FILE_MACHINE_ARM 0x01c0  // Thumb only
-#define IMAGE_FILE_MACHINE_ARMT0x01c2  // 32bit Mixed ARM and 
Thumb/Thumb 2  Little Endian
-#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED IMAGE_FILE_MACHINE_ARMT
-#define IMAGE_FILE_MACHINE_ARM64   0xAA64  // 64bit ARM Architecture, 
Little Endian
-#define IMAGE_FILE_MACHINE_RISCV64 0x5064  // 64bit RISC-V ISA
-#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264  // 64bit LoongArch Architecture
-
-//
-// Support old names for backward compatible
-//
-#define EFI_IMAGE_MACHINE_IA32IMAGE_FILE_MACHINE_I386
-#define EFI_IMAGE_MACHINE_EBC IMAGE_FILE_MACHINE_EBC
-#define EFI_IMAGE_MACHINE_X64 IMAGE_FILE_MACHINE_X64
-#define EFI_IMAGE_MACHINE_ARMTIMAGE_FILE_MACHINE_ARMT
-#define EFI_IMAGE_MACHINE_AARCH64 IMAGE_FILE_MACHINE_ARM64
-#define EFI_IMAGE_MACHINE_RISCV64 IMAGE_FILE_MACHINE_RISCV64
-#define EFI_IMAGE_MACHINE_LOONGARCH64 IMAGE_FILE_MACHINE_LOONGARCH64
-
-#define EFI_IMAGE_DOS_SIGNATURE 0x5A4D  // MZ
-#define EFI_IMAGE_OS2_SIGNATURE 0x454E  // NE
-#define EFI_IMAGE_OS2_SIGNATURE_LE  0x454C  // LE
-#define EFI_IMAGE_NT_SIGNATURE  0x4550  // PE00
-#define EFI_IMAGE_EDOS_SIGNATURE0x44454550  // PEED
-
-///
-/// PE images can start with an optional DOS header, so if an image is run
-///  under DOS it can print an error message.
-///
-typedef struct {
-  UINT16  e_magic;// Magic number
-  UINT16  e_cblp; // Bytes on last page of file
-  UINT16  e_cp;   // Pages in file
-  UINT16  e_crlc; // Relocations
-  UINT16  e_cparhdr;  // Size of header in paragraphs
-  UINT16  e_minalloc; // Minimum extra paragraphs needed
-  UINT16  e_maxalloc; // Maximum extra paragraphs needed
-  UINT16  e_ss;   // Initial (relative) SS value
-  UINT16  e_sp;   // Initial SP value
-  UINT16  e_csum; // Checksum
-  UINT16  e_ip;   // Initial IP value
-  UINT16  e_cs;   // Initial (relative) CS value
-  UINT16  e_lfarlc;   // File address of relocation table
-  UINT16  e_ovno; // Overlay number
-  UINT16  e_res[4];   // Reserved words
-  UINT16  e_oemid;// OEM identifier (for e_oeminfo)
-  UINT16  e_oeminfo;  // OEM information; e_oemid specific
-  UINT16  e_res2[10]; // Reserved words
-  UINT32  e_lfanew;   // File address of new exe header
-} EFI_IMAGE_DOS_HEADER;
-
-///
-/// File header format.
-///
-typedef struct {
-  UINT16  Machine;
-  UINT16  NumberOfSections;
-  UINT32  TimeDateStamp;
-  UINT32  PointerToSymbolTable;
-  UINT32  NumberOfSymbols;
-  UINT16  SizeOfOptionalHeader;
-  UINT16  Characteristics;
-} EFI_IMAGE_FILE_HEADER;
-
-#define EFI_IMAGE_SIZEOF_FILE_HEADER20
-
-#define EFI_IMAGE_FILE_RELOCS_STRIPPED  0x0001  // Relocation info 
stripped from file.
-#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE 0x0002  // File is executable  
(i.e. no unresolved externel references).
-#define 

[edk2-devel] [PATCH v2 8/8] BaseTools: remove duplicate includes: IndustryStandard/*.h

2023-04-11 Thread Gerd Hoffmann
Use the MdePkg versions instead of maintaining a copy in BaseTools.

Signed-off-by: Gerd Hoffmann 
---
 BaseTools/Source/C/EfiRom/EfiRom.h|   4 +-
 .../C/Include/IndustryStandard/Bluetooth.h|  56 --
 .../C/Include/IndustryStandard/EfiPci.h   |  51 --
 ...emoryMappedConfigurationSpaceAccessTable.h |  39 --
 .../Source/C/Include/IndustryStandard/pci22.h | 536 --
 .../Source/C/Include/IndustryStandard/pci23.h |  18 -
 .../Source/C/Include/IndustryStandard/pci30.h |  38 --
 7 files changed, 2 insertions(+), 740 deletions(-)
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/Bluetooth.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/EfiPci.h
 delete mode 100644 
BaseTools/Source/C/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/pci22.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/pci23.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/pci30.h

diff --git a/BaseTools/Source/C/EfiRom/EfiRom.h 
b/BaseTools/Source/C/EfiRom/EfiRom.h
index 887a6a51e25b..dfb4c3207794 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.h
+++ b/BaseTools/Source/C/EfiRom/EfiRom.h
@@ -16,8 +16,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include  // for PE32 structure definitions
 
-#include   // for option ROM header structures
-#include 
+#include   // for option ROM header structures
+#include 
 
 #include "Compress.h"
 #include "CommonLib.h"
diff --git a/BaseTools/Source/C/Include/IndustryStandard/Bluetooth.h 
b/BaseTools/Source/C/Include/IndustryStandard/Bluetooth.h
deleted file mode 100644
index 82f5e6299e78..
--- a/BaseTools/Source/C/Include/IndustryStandard/Bluetooth.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/** @file
-  This file contains the Bluetooth definitions that are consumed by drivers.
-  These definitions are from Bluetooth Core Specification Version 4.0 June, 
2010
-
-  Copyright (c) 2017, Intel Corporation. All rights reserved.
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef _BLUETOOTH_H_
-#define _BLUETOOTH_H_
-
-#pragma pack(1)
-
-///
-/// BLUETOOTH_ADDRESS
-///
-typedef struct {
-  ///
-  /// 48bit Bluetooth device address.
-  ///
-  UINT8  Address[6];
-} BLUETOOTH_ADDRESS;
-
-///
-/// BLUETOOTH_CLASS_OF_DEVICE. See Bluetooth specification for detail.
-///
-typedef struct {
-  UINT8  FormatType:2;
-  UINT8  MinorDeviceClass: 6;
-  UINT16 MajorDeviceClass: 5;
-  UINT16 MajorServiceClass:11;
-} BLUETOOTH_CLASS_OF_DEVICE;
-
-///
-/// BLUETOOTH_LE_ADDRESS
-///
-typedef struct {
-  ///
-  /// 48-bit Bluetooth device address
-  ///
-  UINT8  Address[6];
-  ///
-  /// 0x00 - Public Device Address
-  /// 0x01 - Random Device Address
-  ///
-  UINT8  Type;
-} BLUETOOTH_LE_ADDRESS;
-
-#pragma pack()
-
-#define BLUETOOTH_HCI_COMMAND_LOCAL_READABLE_NAME_MAX_SIZE248
-
-#define BLUETOOTH_HCI_LINK_KEY_SIZE   16
-
-#endif
diff --git a/BaseTools/Source/C/Include/IndustryStandard/EfiPci.h 
b/BaseTools/Source/C/Include/IndustryStandard/EfiPci.h
deleted file mode 100644
index aab27f9bf914..
--- a/BaseTools/Source/C/Include/IndustryStandard/EfiPci.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/** @file
-  Support for EFI PCI specification.
-
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef _EFI_PCI_H_
-#define _EFI_PCI_H_
-
-//#include "pci22.h"
-//#include "pci23.h"
-//#include "pci30.h"
-
-#pragma pack(push, 1)
-
-typedef struct {
-  UINT8 Register;
-  UINT8 Function;
-  UINT8 Device;
-  UINT8 Bus;
-  UINT8 Reserved[4];
-} DEFIO_PCI_ADDR;
-
-#define EFI_ROOT_BRIDGE_LIST'eprb'
-#define EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE   0x0EF1
-
-typedef struct {
-  UINT16  Signature;// 0xaa55
-  UINT16  InitializationSize;
-  UINT32  EfiSignature; // 0x0EF1
-  UINT16  EfiSubsystem;
-  UINT16  EfiMachineType;
-  UINT16  CompressionType;
-  UINT8   Reserved[8];
-  UINT16  EfiImageHeaderOffset;
-  UINT16  PcirOffset;
-} EFI_PCI_EXPANSION_ROM_HEADER;
-
-typedef union {
-  UINT8   *Raw;
-  PCI_EXPANSION_ROM_HEADER*Generic;
-  EFI_PCI_EXPANSION_ROM_HEADER*Efi;
-  EFI_LEGACY_EXPANSION_ROM_HEADER *PcAt;
-} EFI_PCI_ROM_HEADER;
-
-#pragma pack(pop)
-
-#endif
diff --git 
a/BaseTools/Source/C/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h
 
b/BaseTools/Source/C/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h
deleted file mode 100644
index 3d435001fc4d..
--- 
a/BaseTools/Source/C/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/** @file
-  ACPI memory mapped configuration space access table definition, defined at
-  in the PCI Firmware Specification, version 3.0 draft version 0.5.
-  Specification is available at 

[edk2-devel] [PATCH v2 4/8] MdePkg/PeImage.h: add bits from BaseTools version

2023-04-11 Thread Gerd Hoffmann
The BaseTools and MdePkg versions of PeImage.h diverged over time,
add some missing bits to the MdePkg header file in preparation for
removing the BaseTools version.

Signed-off-by: Gerd Hoffmann 
---
 MdePkg/Include/IndustryStandard/PeImage.h | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/MdePkg/Include/IndustryStandard/PeImage.h 
b/MdePkg/Include/IndustryStandard/PeImage.h
index 8646ff22b55f..47037049348c 100644
--- a/MdePkg/Include/IndustryStandard/PeImage.h
+++ b/MdePkg/Include/IndustryStandard/PeImage.h
@@ -101,6 +101,7 @@ typedef struct {
 #define EFI_IMAGE_FILE_EXECUTABLE_IMAGE BIT1 ///< 0x0002  File is 
executable  (i.e. no unresolved externel references).
 #define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED   BIT2 ///< 0x0004  Line numbers 
stripped from file.
 #define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED  BIT3 ///< 0x0008  Local 
symbols stripped from file.
+#define EFI_IMAGE_FILE_LARGE_ADDRESS_AWARE  BIT5 ///< 0x0020  Supports 
addresses > 2-GB
 #define EFI_IMAGE_FILE_BYTES_REVERSED_LOBIT7 ///< 0x0080  Bytes of 
machine word are reversed.
 #define EFI_IMAGE_FILE_32BIT_MACHINEBIT8 ///< 0x0100  32 bit word 
machine.
 #define EFI_IMAGE_FILE_DEBUG_STRIPPED   BIT9 ///< 0x0200  Debugging 
info stripped from file in .DBG file.
@@ -577,6 +578,13 @@ typedef struct {
   UINT32AddressOfNameOrdinals;
 } EFI_IMAGE_EXPORT_DIRECTORY;
 
+//
+// Based export types.
+//
+#define EFI_IMAGE_EXPORT_ORDINAL_BASE  1
+#define EFI_IMAGE_EXPORT_ADDR_SIZE 4
+#define EFI_IMAGE_EXPORT_ORDINAL_SIZE  2
+
 ///
 /// Hint/Name Table.
 ///
@@ -670,6 +678,29 @@ typedef struct {
   //
 } EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY;
 
+// avoid conflict with windows header files
+#ifndef RUNTIME_FUNCTION_INDIRECT
+
+//
+// .pdata entries for X64
+//
+typedef struct {
+  UINT32FunctionStartAddress;
+  UINT32FunctionEndAddress;
+  UINT32UnwindInfoAddress;
+} RUNTIME_FUNCTION;
+
+#endif
+
+typedef struct {
+  UINT8Version : 3;
+  UINT8Flags   : 5;
+  UINT8SizeOfProlog;
+  UINT8CountOfUnwindCodes;
+  UINT8FrameRegister   : 4;
+  UINT8FrameRegisterOffset : 4;
+} UNWIND_INFO;
+
 ///
 /// Extended DLL Characteristics
 ///
-- 
2.39.2



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




[edk2-devel] [PATCH v2 5/8] BaseTools: drop IMAGE_FILE_MACHINE_ARM hacks

2023-04-11 Thread Gerd Hoffmann
The #define for IMAGE_FILE_MACHINE_ARM is not present in MdePkg,
this looks like a relic not used any more.  Remove.

Signed-off-by: Gerd Hoffmann 
---
 BaseTools/Source/C/Common/BasePeCoff.c | 23 ---
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/BaseTools/Source/C/Common/BasePeCoff.c 
b/BaseTools/Source/C/Common/BasePeCoff.c
index b8bfb7b58b91..0172370174b6 100644
--- a/BaseTools/Source/C/Common/BasePeCoff.c
+++ b/BaseTools/Source/C/Common/BasePeCoff.c
@@ -176,25 +176,10 @@ PeCoffLoaderCheckImageType (
   ImageContext->Machine != EFI_IMAGE_MACHINE_AARCH64 && \
   ImageContext->Machine != EFI_IMAGE_MACHINE_RISCV64 && \
   ImageContext->Machine != EFI_IMAGE_MACHINE_LOONGARCH64) {
-if (ImageContext->Machine == IMAGE_FILE_MACHINE_ARM) {
-  //
-  // There are two types of ARM images. Pure ARM and ARM/Thumb.
-  // If we see the ARM say it is the ARM/Thumb so there is only
-  // a single machine type we need to check for ARM.
-  //
-  ImageContext->Machine = EFI_IMAGE_MACHINE_ARMT;
-  if (ImageContext->IsTeImage == FALSE) {
-PeHdr->Pe32.FileHeader.Machine = ImageContext->Machine;
-  } else {
-TeHdr->Machine = ImageContext->Machine;
-  }
-
-} else {
-  //
-  // unsupported PeImage machine type
-  //
-  return RETURN_UNSUPPORTED;
-}
+//
+// unsupported PeImage machine type
+//
+return RETURN_UNSUPPORTED;
   }
 
   //
-- 
2.39.2



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




[edk2-devel] [PATCH v2 2/8] BaseTools: remove duplicate includes: /ProcessorBind.h

2023-04-11 Thread Gerd Hoffmann
Use the MdePkg version instead of maintaining a copy in BaseTools.

Signed-off-by: Gerd Hoffmann 
Reviewed-by: Chao Li 
---
 .../Source/C/Include/AArch64/ProcessorBind.h  | 148 --
 .../Source/C/Include/Arm/ProcessorBind.h  | 147 --
 .../Source/C/Include/Ia32/ProcessorBind.h | 155 ---
 .../C/Include/LoongArch64/ProcessorBind.h |  80 
 .../Source/C/Include/RiscV64/ProcessorBind.h  |  85 
 .../Source/C/Include/X64/ProcessorBind.h  | 183 --
 BaseTools/Source/C/Common/Decompress.c|   1 +
 BaseTools/Source/C/Makefiles/header.makefile  |  14 +-
 BaseTools/Source/C/Makefiles/ms.common|  12 +-
 9 files changed, 19 insertions(+), 806 deletions(-)
 delete mode 100644 BaseTools/Source/C/Include/AArch64/ProcessorBind.h
 delete mode 100644 BaseTools/Source/C/Include/Arm/ProcessorBind.h
 delete mode 100644 BaseTools/Source/C/Include/Ia32/ProcessorBind.h
 delete mode 100644 BaseTools/Source/C/Include/LoongArch64/ProcessorBind.h
 delete mode 100644 BaseTools/Source/C/Include/RiscV64/ProcessorBind.h
 delete mode 100644 BaseTools/Source/C/Include/X64/ProcessorBind.h

diff --git a/BaseTools/Source/C/Include/AArch64/ProcessorBind.h 
b/BaseTools/Source/C/Include/AArch64/ProcessorBind.h
deleted file mode 100644
index dfa725b2e363..
--- a/BaseTools/Source/C/Include/AArch64/ProcessorBind.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/** @file
-  Processor or Compiler specific defines and types for AArch64.
-
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
-  Portions copyright (c) 2013, ARM Ltd. All rights reserved.
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __PROCESSOR_BIND_H__
-#define __PROCESSOR_BIND_H__
-
-///
-/// Define the processor type so other code can make processor based choices
-///
-#define MDE_CPU_AARCH64
-
-//
-// Make sure we are using the correct packing rules per EFI specification
-//
-#ifndef __GNUC__
-#pragma pack()
-#endif
-
-#if _MSC_EXTENSIONS
-  //
-  // use Microsoft* C compiler dependent integer width types
-  //
-  typedef unsigned __int64UINT64;
-  typedef __int64 INT64;
-  typedef unsigned __int32UINT32;
-  typedef __int32 INT32;
-  typedef unsigned short  UINT16;
-  typedef unsigned short  CHAR16;
-  typedef short   INT16;
-  typedef unsigned char   BOOLEAN;
-  typedef unsigned char   UINT8;
-  typedef charCHAR8;
-  typedef signed char INT8;
-#else
-  //
-  // Use ANSI C 2000 stdint.h integer width declarations
-  //
-  #include 
-  typedef uint8_t   BOOLEAN;
-  typedef int8_tINT8;
-  typedef uint8_t   UINT8;
-  typedef int16_t   INT16;
-  typedef uint16_t  UINT16;
-  typedef int32_t   INT32;
-  typedef uint32_t  UINT32;
-  typedef int64_t   INT64;
-  typedef uint64_t  UINT64;
-  typedef char  CHAR8;
-  typedef uint16_t  CHAR16;
-
-#endif
-
-///
-/// Unsigned value of native width.  (4 bytes on supported 32-bit processor 
instructions,
-/// 8 bytes on supported 64-bit processor instructions)
-///
-typedef UINT64  UINTN;
-
-///
-/// Signed value of native width.  (4 bytes on supported 32-bit processor 
instructions,
-/// 8 bytes on supported 64-bit processor instructions)
-///
-typedef INT64   INTN;
-
-//
-// Processor specific defines
-//
-
-///
-/// A value of native width with the highest bit set.
-///
-#define MAX_BIT  0x8000
-
-///
-/// A value of native width with the two highest bits set.
-///
-#define MAX_2_BITS   0xC000
-
-///
-/// The stack alignment required for AARCH64
-///
-#define CPU_STACK_ALIGNMENT  16
-
-//
-// Modifier to ensure that all protocol member functions and EFI intrinsics
-// use the correct C calling convention. All protocol member functions and
-// EFI intrinsics are required to modify their member functions with EFIAPI.
-//
-#define EFIAPI
-
-#if defined(__GNUC__)
-  ///
-  /// For GNU assembly code, .global or .globl can declare global symbols.
-  /// Define this macro to unify the usage.
-  ///
-  #define ASM_GLOBAL .globl
-
-  #if !defined(__APPLE__)
-///
-/// ARM EABI defines that the linker should not manipulate call relocations
-/// (do bl/blx conversion) unless the target symbol has function type.
-/// CodeSourcery 2010.09 started requiring the .type to function properly
-///
-#define INTERWORK_FUNC(func__)   .type ASM_PFX(func__), %function
-
-#define GCC_ASM_EXPORT(func__)  \
- .global  _CONCATENATE (__USER_LABEL_PREFIX__, func__);\
- .type ASM_PFX(func__), %function
-
-#define GCC_ASM_IMPORT(func__)  \
- .extern  _CONCATENATE (__USER_LABEL_PREFIX__, func__)
-
-  #else
-//
-// .type not supported by Apple Xcode tools
-//
-#define INTERWORK_FUNC(func__)
-
-#define GCC_ASM_EXPORT(func__)  \
- .globl  _CONCATENATE 

[edk2-devel] [PATCH v2 6/8] BaseTools: switch from EFI_IMAGE_MACHINE_* to IMAGE_FILE_MACHINE_*

2023-04-11 Thread Gerd Hoffmann
Use the newer versions of the machine #defines.

Signed-off-by: Gerd Hoffmann 
Reviewed-by: Chao Li 
---
 BaseTools/Source/C/EfiRom/EfiRom.h| 10 ++---
 .../C/Include/IndustryStandard/PeImage.h  |  1 +
 BaseTools/Source/C/Common/BasePeCoff.c| 28 ++---
 BaseTools/Source/C/GenFv/GenFvInternalLib.c   | 42 +--
 BaseTools/Source/C/GenFw/Elf32Convert.c   |  6 +--
 BaseTools/Source/C/GenFw/Elf64Convert.c   | 10 ++---
 BaseTools/Source/C/GenFw/GenFw.c  |  8 +---
 7 files changed, 50 insertions(+), 55 deletions(-)

diff --git a/BaseTools/Source/C/EfiRom/EfiRom.h 
b/BaseTools/Source/C/EfiRom/EfiRom.h
index 0b39e2af2e0c..887a6a51e25b 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.h
+++ b/BaseTools/Source/C/EfiRom/EfiRom.h
@@ -108,11 +108,11 @@ typedef struct {
 // Machine Types
 //
 static STRING_LOOKUP  mMachineTypes[] = {
-  { EFI_IMAGE_MACHINE_IA32, "IA32" },
-  { EFI_IMAGE_MACHINE_X64, "X64" },
-  { EFI_IMAGE_MACHINE_EBC, "EBC" },
-  { EFI_IMAGE_MACHINE_ARMT, "ARM" },
-  { EFI_IMAGE_MACHINE_AARCH64, "AA64" },
+  { IMAGE_FILE_MACHINE_I386, "IA32" },
+  { IMAGE_FILE_MACHINE_X64, "X64" },
+  { IMAGE_FILE_MACHINE_EBC, "EBC" },
+  { IMAGE_FILE_MACHINE_ARMTHUMB_MIXED, "ARM" },
+  { IMAGE_FILE_MACHINE_ARM64, "AA64" },
   { 0, NULL }
 };
 
diff --git a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h 
b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
index 22161edf443d..fb867b5660a9 100644
--- a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
+++ b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
@@ -42,6 +42,7 @@
 #define IMAGE_FILE_MACHINE_X64 0x8664
 #define IMAGE_FILE_MACHINE_ARM 0x01c0  // Thumb only
 #define IMAGE_FILE_MACHINE_ARMT0x01c2  // 32bit Mixed ARM and 
Thumb/Thumb 2  Little Endian
+#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED IMAGE_FILE_MACHINE_ARMT
 #define IMAGE_FILE_MACHINE_ARM64   0xAA64  // 64bit ARM Architecture, 
Little Endian
 #define IMAGE_FILE_MACHINE_RISCV64 0x5064  // 64bit RISC-V ISA
 #define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264  // 64bit LoongArch Architecture
diff --git a/BaseTools/Source/C/Common/BasePeCoff.c 
b/BaseTools/Source/C/Common/BasePeCoff.c
index 0172370174b6..038bb054e57a 100644
--- a/BaseTools/Source/C/Common/BasePeCoff.c
+++ b/BaseTools/Source/C/Common/BasePeCoff.c
@@ -169,13 +169,13 @@ PeCoffLoaderCheckImageType (
 ImageContext->Machine = TeHdr->Machine;
   }
 
-  if (ImageContext->Machine != EFI_IMAGE_MACHINE_IA32 && \
-  ImageContext->Machine != EFI_IMAGE_MACHINE_X64  && \
-  ImageContext->Machine != EFI_IMAGE_MACHINE_ARMT && \
-  ImageContext->Machine != EFI_IMAGE_MACHINE_EBC  && \
-  ImageContext->Machine != EFI_IMAGE_MACHINE_AARCH64 && \
-  ImageContext->Machine != EFI_IMAGE_MACHINE_RISCV64 && \
-  ImageContext->Machine != EFI_IMAGE_MACHINE_LOONGARCH64) {
+  if (ImageContext->Machine != IMAGE_FILE_MACHINE_I386 && \
+  ImageContext->Machine != IMAGE_FILE_MACHINE_X64  && \
+  ImageContext->Machine != IMAGE_FILE_MACHINE_ARMTHUMB_MIXED && \
+  ImageContext->Machine != IMAGE_FILE_MACHINE_EBC  && \
+  ImageContext->Machine != IMAGE_FILE_MACHINE_ARM64 && \
+  ImageContext->Machine != IMAGE_FILE_MACHINE_RISCV64 && \
+  ImageContext->Machine != IMAGE_FILE_MACHINE_LOONGARCH64) {
 //
 // unsupported PeImage machine type
 //
@@ -759,16 +759,16 @@ PeCoffLoaderRelocateImage (
 
   default:
 switch (MachineType) {
-case EFI_IMAGE_MACHINE_IA32:
+case IMAGE_FILE_MACHINE_I386:
   Status = PeCoffLoaderRelocateIa32Image (Reloc, Fixup, , 
Adjust);
   break;
-case EFI_IMAGE_MACHINE_ARMT:
+case IMAGE_FILE_MACHINE_ARMTHUMB_MIXED:
   Status = PeCoffLoaderRelocateArmImage (, Fixup, , 
Adjust);
   break;
-case EFI_IMAGE_MACHINE_RISCV64:
+case IMAGE_FILE_MACHINE_RISCV64:
   Status = PeCoffLoaderRelocateRiscVImage (Reloc, Fixup, , 
Adjust);
   break;
-case EFI_IMAGE_MACHINE_LOONGARCH64:
+case IMAGE_FILE_MACHINE_LOONGARCH64:
   Status = PeCoffLoaderRelocateLoongArch64Image (Reloc, Fixup, 
, Adjust);
   break;
 default:
@@ -1255,14 +1255,14 @@ PeCoffLoaderGetPdbPointer (
 //   generate PE32+ image with PE32 Magic.
 //
 switch (Hdr.Pe32->FileHeader.Machine) {
-case EFI_IMAGE_MACHINE_IA32:
-case EFI_IMAGE_MACHINE_ARMT:
+case IMAGE_FILE_MACHINE_I386:
+case IMAGE_FILE_MACHINE_ARMTHUMB_MIXED:
   //
   // Assume PE32 image with IA32 Machine field.
   //
   Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
   break;
-case EFI_IMAGE_MACHINE_X64:
+case IMAGE_FILE_MACHINE_X64:
   //
   // Assume PE32+ image with X64 Machine field
   //
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index c8d5cac8e26e..f466324d6192 100644
--- 

[edk2-devel] [PATCH v2 3/8] BaseTools: remove duplicate includes: IndustryStandard/Acpi*.h

2023-04-11 Thread Gerd Hoffmann
Use the MdePkg version instead of maintaining a copy in BaseTools.

Signed-off-by: Gerd Hoffmann 
Acked-by: Sunil V L 
---
 .../Source/C/Include/IndustryStandard/Acpi.h  | 117 ---
 .../C/Include/IndustryStandard/Acpi1_0.h  | 285 
 .../C/Include/IndustryStandard/Acpi2_0.h  | 520 --
 .../C/Include/IndustryStandard/Acpi3_0.h  | 668 --
 .../Source/C/Include/Protocol/DevicePath.h|   2 +-
 BaseTools/Source/C/GenFw/GenFw.c  |   8 +-
 BaseTools/Source/C/Makefiles/header.makefile  |   1 +
 BaseTools/Source/C/Makefiles/ms.common|   1 +
 8 files changed, 7 insertions(+), 1595 deletions(-)
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/Acpi.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/Acpi1_0.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/Acpi2_0.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/Acpi3_0.h

diff --git a/BaseTools/Source/C/Include/IndustryStandard/Acpi.h 
b/BaseTools/Source/C/Include/IndustryStandard/Acpi.h
deleted file mode 100644
index 3516478ce400..
--- a/BaseTools/Source/C/Include/IndustryStandard/Acpi.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/** @file
-  This file contains some basic ACPI definitions that are consumed by drivers
-  that do not care about ACPI versions.
-
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef _ACPI_H_
-#define _ACPI_H_
-
-//
-// Common table header, this prefaces all ACPI tables, including FACS, but
-// excluding the RSD PTR structure
-//
-typedef struct {
-  UINT32  Signature;
-  UINT32  Length;
-} EFI_ACPI_COMMON_HEADER;
-
-//
-// Common ACPI description table header.  This structure prefaces most ACPI 
tables.
-//
-#pragma pack(1)
-
-typedef struct {
-  UINT32  Signature;
-  UINT32  Length;
-  UINT8   Revision;
-  UINT8   Checksum;
-  UINT8   OemId[6];
-  UINT64  OemTableId;
-  UINT32  OemRevision;
-  UINT32  CreatorId;
-  UINT32  CreatorRevision;
-} EFI_ACPI_DESCRIPTION_HEADER;
-
-#pragma pack()
-//
-// Define for Pci Host Bridge Resource Allocation
-//
-#define ACPI_ADDRESS_SPACE_DESCRIPTOR 0x8A
-#define ACPI_END_TAG_DESCRIPTOR   0x79
-
-#define ACPI_ADDRESS_SPACE_TYPE_MEM   0x00
-#define ACPI_ADDRESS_SPACE_TYPE_IO0x01
-#define ACPI_ADDRESS_SPACE_TYPE_BUS   0x02
-
-//
-// Power Management Timer frequency is fixed at 3.579545MHz
-//
-#define ACPI_TIMER_FREQUENCY   3579545
-
-//
-// Make sure structures match spec
-//
-#pragma pack(1)
-
-typedef struct {
-  UINT8   Desc;
-  UINT16  Len;
-  UINT8   ResType;
-  UINT8   GenFlag;
-  UINT8   SpecificFlag;
-  UINT64  AddrSpaceGranularity;
-  UINT64  AddrRangeMin;
-  UINT64  AddrRangeMax;
-  UINT64  AddrTranslationOffset;
-  UINT64  AddrLen;
-} EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR;
-
-typedef struct {
-  UINT8 Desc;
-  UINT8 Checksum;
-} EFI_ACPI_END_TAG_DESCRIPTOR;
-
-//
-// General use definitions
-//
-#define EFI_ACPI_RESERVED_BYTE  0x00
-#define EFI_ACPI_RESERVED_WORD  0x
-#define EFI_ACPI_RESERVED_DWORD 0x
-#define EFI_ACPI_RESERVED_QWORD 0x
-
-//
-// Resource Type Specific Flags
-// Ref ACPI specification 6.4.3.5.5
-//
-// Bit [0]: Write Status, _RW
-//
-#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_WRITE(1 << 
0)
-#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_ONLY (0 << 
0)
-//
-// Bit [2:1]  : Memory Attributes, _MEM
-//
-#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_NON_CACHEABLE (0 << 
1)
-#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE (1 << 
1)
-#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_WRITE_COMBINING (2 << 
1)
-#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE(3 << 
1)
-//
-// Bit [4:3]  : Memory Attributes, _MTP
-//
-#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_MEMORY  (0 << 
3)
-#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_RESERVED(1 << 
3)
-#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_ACPI(2 << 
3)
-#define EFI_APCI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_NVS (3 << 
3)
-//
-// Bit [5]: Memory to I/O Translation, _TTP
-//
-#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_TYPE_TRANSLATION  (1 << 
5)
-#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_TYPE_STATIC   (0 << 
5)
-
-#pragma pack()
-
-#endif
diff --git a/BaseTools/Source/C/Include/IndustryStandard/Acpi1_0.h 
b/BaseTools/Source/C/Include/IndustryStandard/Acpi1_0.h
deleted file mode 100644
index 62bd9f477e0b..
--- a/BaseTools/Source/C/Include/IndustryStandard/Acpi1_0.h
+++ /dev/null
@@ -1,285 +0,0 @@
-/** @file
-  ACPI 1.0b definitions from the ACPI Specification, revision 1.0b
-
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef _ACPI_1_0_H_
-#define _ACPI_1_0_H_
-

[edk2-devel] [PATCH v2 1/8] BaseTools: remove WinNtInclude.h

2023-04-11 Thread Gerd Hoffmann
Appears to be a relic for ancient windows / compiler versions,
windows builds in CI work just fine without it.

Signed-off-by: Gerd Hoffmann 
---
 BaseTools/Source/C/Common/WinNtInclude.h| 66 -
 BaseTools/Source/C/GenFv/GenFvInternalLib.c |  1 -
 BaseTools/Source/C/GenFw/Elf32Convert.c |  2 -
 BaseTools/Source/C/GenFw/Elf64Convert.c |  2 -
 BaseTools/Source/C/GenFw/ElfConvert.c   |  2 -
 BaseTools/Source/C/GenFw/GenFw.c|  2 -
 6 files changed, 75 deletions(-)
 delete mode 100644 BaseTools/Source/C/Common/WinNtInclude.h

diff --git a/BaseTools/Source/C/Common/WinNtInclude.h 
b/BaseTools/Source/C/Common/WinNtInclude.h
deleted file mode 100644
index 181e6ac33370..
--- a/BaseTools/Source/C/Common/WinNtInclude.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/** @file
-Include file for the WinNt Library
-
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __WIN_NT_INCLUDE_H__
-#define __WIN_NT_INCLUDE_H__
-
-#define GUID  _WINNT_DUP_GUID_
-#define _LIST_ENTRY  _WINNT_DUP_LIST_ENTRY_FORWARD
-#define LIST_ENTRY   _WINNT_DUP_LIST_ENTRY
-
-#if (_MSC_VER < 1800)
-#define InterlockedIncrement _WINNT_DUP_InterlockedIncrement
-#define InterlockedDecrement _WINNT_DUP_InterlockedDecrement
-#define InterlockedCompareExchange64 _WINNT_DUP_InterlockedCompareExchange64
-#endif
-
-#undef UNALIGNED
-#undef CONST
-#undef VOID
-
-#ifndef __GNUC__
-#include "windows.h"
-
-//
-// Win32 include files do not compile clean with /W4, so we use the warning
-// pragma to suppress the warnings for Win32 only. This way our code can still
-// compile at /W4 (highest warning level) with /WX (warnings cause build
-// errors).
-//
-#pragma warning(disable : 4115)
-#pragma warning(disable : 4201)
-#pragma warning(disable : 4214)
-#pragma warning(disable : 4028)
-#pragma warning(disable : 4133)
-
-//
-// Set the warnings back on as the EFI code must be /W4.
-//
-#pragma warning(default : 4115)
-#pragma warning(default : 4201)
-#pragma warning(default : 4214)
-
-#endif
-
-#undef GUID
-#undef _LIST_ENTRY
-#undef LIST_ENTRY
-#undef InterlockedIncrement
-#undef InterlockedDecrement
-#undef InterlockedCompareExchange64
-#undef InterlockedCompareExchangePointer
-
-#define VOID void
-
-//
-// Prevent collisions with Windows API name macros that deal with Unicode/Not 
issues
-//
-#undef LoadImage
-#undef CreateEvent
-
-#endif
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index 2df7182f8b52..c8d5cac8e26e 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -25,7 +25,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include 
 
-#include "WinNtInclude.h"
 #include "GenFvInternalLib.h"
 #include "FvLib.h"
 #include "PeCoffLib.h"
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c 
b/BaseTools/Source/C/GenFw/Elf32Convert.c
index 87d7f133f132..e9fb3593a91b 100644
--- a/BaseTools/Source/C/GenFw/Elf32Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf32Convert.c
@@ -9,8 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#include "WinNtInclude.h"
-
 #ifndef __GNUC__
 #include 
 #include 
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c 
b/BaseTools/Source/C/GenFw/Elf64Convert.c
index 9c17c90b1660..dfcb100a594f 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -10,8 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#include "WinNtInclude.h"
-
 #ifndef __GNUC__
 #include 
 #include 
diff --git a/BaseTools/Source/C/GenFw/ElfConvert.c 
b/BaseTools/Source/C/GenFw/ElfConvert.c
index be98544056ec..3205f61494b6 100644
--- a/BaseTools/Source/C/GenFw/ElfConvert.c
+++ b/BaseTools/Source/C/GenFw/ElfConvert.c
@@ -7,8 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#include "WinNtInclude.h"
-
 #ifndef __GNUC__
 #include 
 #include 
diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index d0e52ccc2643..80ee73a80399 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -6,8 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#include "WinNtInclude.h"
-
 #ifndef __GNUC__
 #include 
 #include 
-- 
2.39.2



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




[edk2-devel] [PATCH v2 0/8] BaseTools: remove duplicate includes.

2023-04-11 Thread Gerd Hoffmann
There is alot of code duplication between BaseTools and MdePkg (and also
MdeModulePkg).  This patch series starts reducing this by removing some
header files.  BaseTools are switched over to use the include files in
MdePkg instead.  It also cleans up some (apparently) obsolete code and
adapts BaseTools code in a few places to work with the MdePkg version of
the include files.

v2 changes:
 - rebase to latest master, resolve conflicts.
 - pick up reviews and acks.

take care,
  Gerd

Gerd Hoffmann (8):
  BaseTools: remove WinNtInclude.h
  BaseTools: remove duplicate includes: /ProcessorBind.h
  BaseTools: remove duplicate includes: IndustryStandard/Acpi*.h
  MdePkg/PeImage.h: add bits from BaseTools version
  BaseTools: drop IMAGE_FILE_MACHINE_ARM hacks
  BaseTools: switch from EFI_IMAGE_MACHINE_* to IMAGE_FILE_MACHINE_*
  BaseTools: remove duplicate includes: IndustryStandard/PeImage.h
  BaseTools: remove duplicate includes: IndustryStandard/*.h

 BaseTools/Source/C/Common/WinNtInclude.h  |  66 --
 BaseTools/Source/C/EfiRom/EfiRom.h|  14 +-
 .../Source/C/Include/AArch64/ProcessorBind.h  | 148 
 .../Source/C/Include/Arm/ProcessorBind.h  | 147 
 .../Source/C/Include/Ia32/ProcessorBind.h | 155 
 .../Source/C/Include/IndustryStandard/Acpi.h  | 117 ---
 .../C/Include/IndustryStandard/Acpi1_0.h  | 285 ---
 .../C/Include/IndustryStandard/Acpi2_0.h  | 520 
 .../C/Include/IndustryStandard/Acpi3_0.h  | 668 ---
 .../C/Include/IndustryStandard/Bluetooth.h|  56 --
 .../C/Include/IndustryStandard/EfiPci.h   |  51 --
 ...emoryMappedConfigurationSpaceAccessTable.h |  39 -
 .../C/Include/IndustryStandard/PeImage.h  | 789 --
 .../Source/C/Include/IndustryStandard/pci22.h | 536 
 .../Source/C/Include/IndustryStandard/pci23.h |  18 -
 .../Source/C/Include/IndustryStandard/pci30.h |  38 -
 .../C/Include/LoongArch64/ProcessorBind.h |  80 --
 .../Source/C/Include/Protocol/DevicePath.h|   2 +-
 .../Source/C/Include/RiscV64/ProcessorBind.h  |  85 --
 .../Source/C/Include/X64/ProcessorBind.h  | 183 
 MdePkg/Include/IndustryStandard/PeImage.h |  31 +
 BaseTools/Source/C/Common/BasePeCoff.c|  51 +-
 BaseTools/Source/C/Common/Decompress.c|   1 +
 BaseTools/Source/C/GenFv/GenFvInternalLib.c   |  43 +-
 BaseTools/Source/C/GenFw/Elf32Convert.c   |   8 +-
 BaseTools/Source/C/GenFw/Elf64Convert.c   |  12 +-
 BaseTools/Source/C/GenFw/ElfConvert.c |   2 -
 BaseTools/Source/C/GenFw/GenFw.c  |  18 +-
 BaseTools/Source/C/Makefiles/header.makefile  |  15 +-
 BaseTools/Source/C/Makefiles/ms.common|  13 +-
 30 files changed, 112 insertions(+), 4079 deletions(-)
 delete mode 100644 BaseTools/Source/C/Common/WinNtInclude.h
 delete mode 100644 BaseTools/Source/C/Include/AArch64/ProcessorBind.h
 delete mode 100644 BaseTools/Source/C/Include/Arm/ProcessorBind.h
 delete mode 100644 BaseTools/Source/C/Include/Ia32/ProcessorBind.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/Acpi.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/Acpi1_0.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/Acpi2_0.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/Acpi3_0.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/Bluetooth.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/EfiPci.h
 delete mode 100644 
BaseTools/Source/C/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/PeImage.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/pci22.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/pci23.h
 delete mode 100644 BaseTools/Source/C/Include/IndustryStandard/pci30.h
 delete mode 100644 BaseTools/Source/C/Include/LoongArch64/ProcessorBind.h
 delete mode 100644 BaseTools/Source/C/Include/RiscV64/ProcessorBind.h
 delete mode 100644 BaseTools/Source/C/Include/X64/ProcessorBind.h

-- 
2.39.2



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




Re: [edk2-devel] [PATCH v7 1/3] UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support

2023-04-11 Thread Rebecca Cran
I've pushed the patches to a branch at 
https://github.com/bcran/edk2/tree/usbnetworkpkg-202304



--

Rebecca Cran


On 4/7/23 5:27 AM, Richard Ho (何明忠) wrote:

This driver provides UEFI driver for USB RNDIS device

Signed-off-by: Richard Ho 
Cc: Andrew Fish 
Cc: Leif Lindholm 
Cc: Michael D Kinney 
Cc: Michael Kubacki 
Cc: Zhiguang Liu 
Cc: Liming Gao 
Cc: Rebecca Cran 
Tested-by: Tinh Nguyen 
Reviewed-by: Tony Lo 
---
  .../Protocol/EdkIIUsbEthernetProtocol.h   |  878 
  UsbNetworkPkg/NetworkCommon/ComponentName.c   |  263 +++
  UsbNetworkPkg/NetworkCommon/DriverBinding.c   |  595 ++
  UsbNetworkPkg/NetworkCommon/DriverBinding.h   |  266 +++
  UsbNetworkPkg/NetworkCommon/NetworkCommon.inf |   49 +
  UsbNetworkPkg/NetworkCommon/PxeFunction.c | 1803 +
  UsbNetworkPkg/ReadMe.md   |   65 +
  UsbNetworkPkg/UsbNetworkPkg.ci.yaml   |   65 +
  UsbNetworkPkg/UsbNetworkPkg.dec   |   46 +
  UsbNetworkPkg/UsbNetworkPkg.dsc   |   50 +
  UsbNetworkPkg/UsbNetworkPkg.dsc.inc   |   27 +
  .../UsbNetworkPkgComponentsDxe.dsc.inc|   20 +
  .../UsbNetworkPkgComponentsDxe.fdf.inc|   20 +
  UsbNetworkPkg/UsbNetworkPkgPcds.dsc.inc   |   14 +
  UsbNetworkPkg/UsbRndis/ComponentName.c|  172 ++
  UsbNetworkPkg/UsbRndis/UsbRndis.c |  886 
  UsbNetworkPkg/UsbRndis/UsbRndis.h |  586 ++
  UsbNetworkPkg/UsbRndis/UsbRndis.inf   |   42 +
  UsbNetworkPkg/UsbRndis/UsbRndisFunction.c | 1718 
  19 files changed, 7565 insertions(+)
  create mode 100644 UsbNetworkPkg/Include/Protocol/EdkIIUsbEthernetProtocol.h
  create mode 100644 UsbNetworkPkg/NetworkCommon/ComponentName.c
  create mode 100644 UsbNetworkPkg/NetworkCommon/DriverBinding.c
  create mode 100644 UsbNetworkPkg/NetworkCommon/DriverBinding.h
  create mode 100644 UsbNetworkPkg/NetworkCommon/NetworkCommon.inf
  create mode 100644 UsbNetworkPkg/NetworkCommon/PxeFunction.c
  create mode 100644 UsbNetworkPkg/ReadMe.md
  create mode 100644 UsbNetworkPkg/UsbNetworkPkg.ci.yaml
  create mode 100644 UsbNetworkPkg/UsbNetworkPkg.dec
  create mode 100644 UsbNetworkPkg/UsbNetworkPkg.dsc
  create mode 100644 UsbNetworkPkg/UsbNetworkPkg.dsc.inc
  create mode 100644 UsbNetworkPkg/UsbNetworkPkgComponentsDxe.dsc.inc
  create mode 100644 UsbNetworkPkg/UsbNetworkPkgComponentsDxe.fdf.inc
  create mode 100644 UsbNetworkPkg/UsbNetworkPkgPcds.dsc.inc
  create mode 100644 UsbNetworkPkg/UsbRndis/ComponentName.c
  create mode 100644 UsbNetworkPkg/UsbRndis/UsbRndis.c
  create mode 100644 UsbNetworkPkg/UsbRndis/UsbRndis.h
  create mode 100644 UsbNetworkPkg/UsbRndis/UsbRndis.inf
  create mode 100644 UsbNetworkPkg/UsbRndis/UsbRndisFunction.c




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




[edk2-devel] [PATCH edk2-platforms 2/2] Platform/ARM/JunoPkg: Enable the NOOPT build

2023-04-11 Thread Rebecca Cran
Enable the NOOPT build for the Juno platform. This is useful for
source-level debugging.

Signed-off-by: Rebecca Cran 
---
 Platform/ARM/JunoPkg/ArmJuno.dsc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
index 8cb2d54bccaa..1ea0aba2655f 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dsc
+++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
@@ -21,7 +21,7 @@ [Defines]
   OUTPUT_DIRECTORY   = Build/ArmJuno
 !endif
   SUPPORTED_ARCHITECTURES= AARCH64|ARM
-  BUILD_TARGETS  = DEBUG|RELEASE
+  BUILD_TARGETS  = DEBUG|RELEASE|NOOPT
   SKUID_IDENTIFIER   = DEFAULT
   FLASH_DEFINITION   = Platform/ARM/JunoPkg/ArmJuno.fdf
 
-- 
2.34.1



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




[edk2-devel] [PATCH edk2-platforms 1/2] Platform/ARM/JunoPkg: Bump the FV size to 2MB

2023-04-11 Thread Rebecca Cran
Increase the FV size from 996KB to 2MB. This allows more features to be
accommodated in the firmware image, such as HTTPS boot. It also allows a
NOOPT build to be added, which is useful for source-level debugging.

Add a comment explaining that the size chosen doesn't reflect the actual
size of the Flash Device but is instead selected to reduce the amount of
time needed to copy the image to the target.

Update the BlockSize and NumBlocks to reflect the 256KB block size of
the main area on the Juno R2.

Signed-off-by: Rebecca Cran 
---
 Platform/ARM/JunoPkg/ArmJuno.fdf | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/Platform/ARM/JunoPkg/ArmJuno.fdf b/Platform/ARM/JunoPkg/ArmJuno.fdf
index 836d3cde8781..0c5a50e968e1 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.fdf
+++ b/Platform/ARM/JunoPkg/ArmJuno.fdf
@@ -18,14 +18,21 @@
 #
 

 
+# The Size value is rather arbitrary, and doesn't reflect the actual size of 
the FLASH Device,
+# but is instead chosen to accommodate a normal build while reducing the 
amount of time required
+# to copy the image to the target.
+#
+# Juno R2 has a 64MB NOR flash split into 2 areas: the main area is 65280KB 
(0x3FC) with
+# a 256KB block size.
+
 [FD.BL33_AP_UEFI]
 BaseAddress   = 0xE000|gArmTokenSpaceGuid.PcdFdBaseAddress  # The base 
address of the Firmware in NOR Flash.
-Size  = 0x000F9000|gArmTokenSpaceGuid.PcdFdSize # The size in 
bytes of the FLASH Device
+Size  = 0x0020|gArmTokenSpaceGuid.PcdFdSize # The size in 
bytes of the FLASH Device
 ErasePolarity = 1
 
 # This one is tricky, it must be: BlockSize * NumBlocks = Size
-BlockSize = 0x1000
-NumBlocks = 0xF9
+BlockSize = 0x0004
+NumBlocks = 0x0008
 
 

 #
@@ -43,7 +50,7 @@ [FD.BL33_AP_UEFI]
 #
 

 
-0x|0x000F9000
+0x|0x0020
 gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
 FV = FVMAIN_COMPACT
 
-- 
2.34.1



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




[edk2-devel] [PATCH edk2-platforms 0/2] Platform/ARM/JunoPkg: Increase FV size and enable NOOPT build

2023-04-11 Thread Rebecca Cran
The current FV size of 996KB for the Juno platform is rather restrictive
nowadays: a NOOPT build can be made to fit, but when enabling HTTPS boot
the firmware size becomes far too large even with an optimized DEBUG build.

Since the size value is rather arbitrary, bump it to 2MB: a build with
HTTPS boot and dynamic framework pkg uses around 72%, giving plenty of
headroom for future growth.

Since the NOOPT build makes source-level debugging via Arm Development
Studio so much more useful, enable it in the .dsc file.

Rebecca Cran (2):
  Platform/ARM/JunoPkg: Bump the FV size to 2MB
  Platform/ARM/JunoPkg: Enable the NOOPT build

 Platform/ARM/JunoPkg/ArmJuno.dsc |  2 +-
 Platform/ARM/JunoPkg/ArmJuno.fdf | 15 +++
 2 files changed, 12 insertions(+), 5 deletions(-)

-- 
2.34.1



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




Re: [edk2-devel] [edk2-platforms][PATCH 05/14] ManageabilityPkg: Add PldmProtocolLib

2023-04-11 Thread Nickle Wang via groups.io
Hi Abner,

It seems to me that some of protocol GUIDs are defined in [Guids] section 
instead of [Protocol] section in Features/ManageabilityPkg/ManageabilityPkg.dec 
file. Could you please address this together?

Thanks,
Nickle

> -Original Message-
> From: abner.ch...@amd.com 
> Sent: Monday, April 3, 2023 11:05 PM
> To: devel@edk2.groups.io
> Cc: Isaac Oram ; Abdul Lateef Attar
> ; Nickle Wang ; Igor Kulchytskyy
> 
> Subject: [edk2-platforms][PATCH 05/14] ManageabilityPkg: Add
> PldmProtocolLib
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang 
> 
> PldmProtocolLib provides the library
> function to PLDM protocol.
> 
> Signed-off-by: Abner Chang 
> Cc: Isaac Oram 
> Cc: Abdul Lateef Attar 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> ---
>  .../ManageabilityPkg/ManageabilityPkg.dec |  3 +
>  .../Include/Dsc/Manageability.dsc |  3 +
>  .../ManageabilityPkg/ManageabilityPkg.dsc |  1 +
>  .../Dxe/PldmProtocolLib.inf   | 42 +
>  .../Include/Library/BasePldmProtocolLib.h | 41 +
>  .../Include/Protocol/PldmProtocol.h   | 87 +++
>  .../PldmProtocolLibrary/Dxe/PldmProtocolLib.c | 87 +++
>  .../Dxe/PldmProtocolLib.uni   | 18 
>  8 files changed, 282 insertions(+)
>  create mode 100644
> Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtocolLib.i
> nf
>  create mode 100644
> Features/ManageabilityPkg/Include/Library/BasePldmProtocolLib.h
>  create mode 100644
> Features/ManageabilityPkg/Include/Protocol/PldmProtocol.h
>  create mode 100644
> Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtocolLib.c
>  create mode 100644
> Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtocolLib.
> uni
> 
> diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec
> b/Features/ManageabilityPkg/ManageabilityPkg.dec
> index 9a930d3e4b..1e9245c8dc 100644
> --- a/Features/ManageabilityPkg/ManageabilityPkg.dec
> +++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
> @@ -48,3 +48,6 @@
>gManageabilityProtocolMctpGuid= { 0x76FED8F1, 0x0BE5, 0x4269, { 0xA3,
> 0x1A, 0x38, 0x0F, 0x54, 0xF1, 0xA1, 0x8A } }
># Manageability Protocol PLDM
>gManageabilityProtocolPldmGuid= { 0x3958090D, 0x69DD, 0x4868, { 0x9C,
> 0x41, 0xC9, 0xAC, 0x31, 0xB5, 0x25, 0xC5 } }
> +
> +[Protocols]
> +  gEdkiiPldmProtocolGuid= { 0x60997616, 0xDB70, 0x4B5F, { 
> 0x86,
> 0xA4, 0x09, 0x58, 0xA3, 0x71, 0x47, 0xB4 } }
> diff --git a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
> b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
> index 0d868fdf4a..59549eb39a 100644
> --- a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
> +++ b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc
> @@ -8,6 +8,9 @@
>  [LibraryClasses]
> 
> ManageabilityTransportHelperLib|ManageabilityPkg/Library/BaseManageability
> TransportHelperLib/BaseManageabilityTransportHelper.inf
> 
> +[LibraryClasses.common.DXE_DRIVER]
> +
> +PldmProtocolLib|ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmPr
> +otocolLib.inf
> +
>  [LibraryClasses.ARM, LibraryClasses.AARCH64]
>#
># This library provides the instrinsic functions generated by a given 
> compiler.
> diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc
> b/Features/ManageabilityPkg/ManageabilityPkg.dsc
> index 6a083385fd..412029ef6c 100644
> --- a/Features/ManageabilityPkg/ManageabilityPkg.dsc
> +++ b/Features/ManageabilityPkg/ManageabilityPkg.dsc
> @@ -37,6 +37,7 @@
> 
>  [Components]
> 
> ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/DxeManageability
> TransportKcs.inf
> +  ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtocolLib.inf
> 
>  [LibraryClasses]
> 
> ManageabilityTransportLib|ManageabilityPkg/Library/BaseManageabilityTransp
> ortNullLib/BaseManageabilityTransportNull.inf
> diff --git
> a/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtocolLi
> b.inf
> b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtocolLi
> b.inf
> new file mode 100644
> index 00..1233d76726
> --- /dev/null
> +++ b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProt
> +++ ocolLib.inf
> @@ -0,0 +1,42 @@
> +## @file
> +#  Instance of PLDM Protocol Library in DXE phase.
> +#
> +#  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
> +reserved. # #  SPDX-License-Identifier: BSD-2-Clause-Patent # # ##
> +
> +[Defines]
> +  INF_VERSION= 0x00010005
> +  BASE_NAME  = PldmProtocolLib
> +  MODULE_UNI_FILE= PldmProtocolLib.uni
> +  FILE_GUID  = 5B1173E8-6A5A-468B-BDA4-02303530C55C
> +  MODULE_TYPE= DXE_DRIVER
> +  VERSION_STRING = 1.0
> +  LIBRARY_CLASS  = PldmProtocolLib|DXE_RUNTIME_DRIVER
> DXE_DRIVER DXE_CORE UEFI_DRIVER UEFI_APPLICATION
> +
> +#
> +#  VALID_ARCHITECTURES

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

2023-04-11 Thread Sheng Lean Tan
Thanks Mike for the proposal layout!
It sounds good to me :)

*Hi Pedro,*
I went through the email chain again, basically these are 2 of your main
concerns (correct me if I'm wrong):
1. a good idea to at least ditch that specific copy (current FDT in
Embedded Pkg) for a git submodule.
2. Rework to remove/reduce libc Implementation as there is a problem with
both libc fragments and compiler intrinsic fragments all over edk2. Should
unify standards between crypto, libfdt, etc, could we try here

I guess Mike has provided a plan to answer your first question, and the 2nd
question would require a broader discussion with a few key owners.

So it seems like we could get the current patchset from Benny Lin in for
now? Any minor clean up needed for the current patch?



On Sat, 8 Apr 2023 at 01:04, Kinney, Michael D 
wrote:

> The main advantage of the new lib is that it depends on a submodule for
> the FDT
> content so we can easily move to new releases for bug fixes or features.
>
> The FDT content in the EmbeddedPkg is a snap-shot of the code from a long
> time
> ago.  We have been discouraging that approach and trying to move to
> released
> content from a well support submodule if one is available.
>
> Once this new better supported version is accepted, we can then
> incrementally
> remove the duplicate content with the existing consumers moving from use of
> EmbeddedPkg version to the MdePkg version and finally the removal of the
> duplicate content in the EmbeddedPkg.
>
> Mike
>
> > -Original Message-
> > From: Warkentin, Andrei 
> > Sent: Friday, April 7, 2023 3:36 PM
> > To: Pedro Falcato ; devel@edk2.groups.io; Tan,
> Lean Sheng 
> > Cc: Lin, Benny ; Kinney, Michael D <
> michael.d.kin...@intel.com>; Gao, Liming ;
> > Liu, Zhiguang ; Sean Brogan <
> sean.bro...@microsoft.com>; Michael Kubacki 
> > Subject: RE: [edk2-devel] [PATCH 0/2] Support FDT library.
> >
> > I think in general it would be nice to understand the long term picture
> of a change, esp. since there is already FDT support in
> > EDK2 in various forms (with libraries and drivers depending on the
> existing FdtLib). So it would really of confusing to see
> > another FDT library in MdePkg, without a clear reasoning for the work
> (this isn't reflected in the BZ) and a clear action plan
> > to end up with just one FDT library in MdePkg in some identified time
> frame.
> >
> > I do think FDT lib *does* belong in MdePkg, but it seems the shortest
> path to get there is to simply move the existing
> > EmbeddedPkg one (and update all users). Subsequent cleanup can be
> incremental. And regardless, every existing FdtLib user ought
> > to be updated to use the new one, so there need to be more patches
> (we're not just throwing the code over the wall, right?)
> >
> > A
> >
> > > -Original Message-
> > > From: Pedro Falcato 
> > > Sent: Friday, April 7, 2023 8:24 AM
> > > To: devel@edk2.groups.io; Tan, Lean Sheng 
> > > Cc: Warkentin, Andrei ; Lin, Benny
> > > ; Kinney, Michael D ;
> > > Gao, Liming ; Liu, Zhiguang
> > > ; Sean Brogan ;
> > > Michael Kubacki 
> > > Subject: Re: [edk2-devel] [PATCH 0/2] Support FDT library.
> > >
> > > On Thu, Apr 6, 2023 at 5:34 PM Sheng Lean Tan
> > >  wrote:
> > > >
> > > > Thanks for the nice feedback Pedro, Gerd and Andrei! Yeah it seems
> like a
> > > valid concern here as Mik mentioned on edk2-libc, and it seems to fits
> edk2
> > > long term interest on this.
> > > > Can we file this as an issue in Bugzilla for tracking or something?
> Since this
> > > will take some time to work on this as it involves a bigger discussion,
> > > personally I think we could get this FDT patch in first meanwhile, and
> also
> > > remove the FDT from Embedded Pkg as next step, per discussion with
> Leif?
> > > > What do you think?
> > >
> > > I'm all for not merging this without a proper solution in that regard
> (I even
> > > presented a quick RFC solution which wasn't tested by anyone involved
> in
> > > this patch, yet).
> > >
> > > But if there really is an urgent need for this lib, I'm O-K with
> merging this
> > > given that all my concerns are addressed (minus libc duplication).
> > >
> > > --
> > > Pedro
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102830): https://edk2.groups.io/g/devel/message/102830
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 v8 9/9] OvmfPkg: Uses SmmSmramSaveStateLib library

2023-04-11 Thread Ni, Ray
yes

thanks,
ray

From: Attar, AbdulLateef (Abdul Lateef) 
Sent: Tuesday, April 11, 2023 7:17:03 PM
To: Ni, Ray ; devel@edk2.groups.io ; 
kra...@redhat.com 
Cc: Grimes, Paul ; Kirkendall, Garrett 
; Chang, Abner ; Dong, Eric 
; Kumar, Rahul R ; Ard Biesheuvel 
; Yao, Jiewen ; Justen, Jordan 
L 
Subject: RE: [edk2-devel] [PATCH v8 9/9] OvmfPkg: Uses SmmSmramSaveStateLib 
library

[AMD Official Use Only - General]

Hi Ray,
You mean directly call the SmramSaveStateReadRegister instead of below 
code from edk2/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c ?

  Status = SmmCpuFeaturesReadSaveStateRegister (CpuIndex, Register, Width, 
Buffer);
  if (Status == EFI_UNSUPPORTED) {
Status = SmramSaveStateReadRegister (CpuIndex, Register, Width, Buffer);
  }

Thanks
AbduL

-Original Message-
From: Ni, Ray 
Sent: 11 April 2023 15:40
To: devel@edk2.groups.io; kra...@redhat.com; Attar, AbdulLateef (Abdul Lateef) 

Cc: Attar, AbdulLateef (Abdul Lateef) ; Grimes, Paul 
; Kirkendall, Garrett ; Chang, 
Abner ; Dong, Eric ; Kumar, Rahul R 
; Ard Biesheuvel ; Yao, 
Jiewen ; Justen, Jordan L 
Subject: RE: [edk2-devel] [PATCH v8 9/9] OvmfPkg: Uses SmmSmramSaveStateLib 
library

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


Gerd,
I am asking Abdul to directly call SaveStateLib from CpuSmm driver.
I don't think SmmCpuFeaturesLib should be in the middle of CpuSmm driver and 
SaveStateLib regarding the save state access.

Thanks,
Ray

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Gerd
> Hoffmann
> Sent: Tuesday, April 11, 2023 5:43 PM
> To: Abdul Lateef Attar 
> Cc: devel@edk2.groups.io; Abdul Lateef Attar
> ; Paul Grimes ;
> Garrett Kirkendall ; Abner Chang
> ; Dong, Eric ; Ni, Ray
> ; Kumar, Rahul R ; Ard
> Biesheuvel ; Yao, Jiewen
> ; Justen, Jordan L 
> Subject: Re: [edk2-devel] [PATCH v8 9/9] OvmfPkg: Uses
> SmmSmramSaveStateLib library
>
> > Uses new SmmSmramSaveStateLib library, which fix the CI failure.
>
> What is the exact failure you are seeing?
>
> > +
> SmmSmramSaveStateLib|UefiCpuPkg/Library/SmmSmramSaveStateLib/Intel
> SmmSmramSaveStateLib.inf
>
> This should be the AMD version.  KVM uses the AMD smram state.
>
> Also: OvmfPkg/Library/SmmCpuFeaturesLib should be updated to use
> actually use the new SmmSmramSaveStateLib library, and once this has
> been done it should be possible to remove
> OvmfPkg/Include/Register/QemuSmramSaveStateMap.h
>
> take care,
>   Gerd
>
>
>
> 
>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102829): https://edk2.groups.io/g/devel/message/102829
Mute This Topic: https://groups.io/mt/98172964/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 v7 1/3] UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support

2023-04-11 Thread Pedro Falcato
On Tue, Apr 11, 2023 at 1:31 PM Rebecca Cran  wrote:
> Given this is adding a new top-level package, I'd like to see a
> review/feedback from the TianoCore Stewards.

I would personally love to understand why this is being pushed as a
top level package in edk2 when "supposedly" edk2-platforms/Features is
the more correct approach here (as discussed with Sean, Nate a few
months back).

Or is that hellscape only reserved for me? :v

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102828): https://edk2.groups.io/g/devel/message/102828
Mute This Topic: https://groups.io/mt/98122714/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 0/3] Adds Platform/AMD/AmdMinBoardPkg

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

Is any one has additional comments on the V4 patch set? Otherwise I will push 
it to edk2-platforms.

Thanks
Abner

> -Original Message-
> From: Abdul Lateef Attar 
> Sent: Monday, April 3, 2023 7:23 PM
> To: devel@edk2.groups.io
> Cc: Attar, AbdulLateef (Abdul Lateef) ; Ard
> Biesheuvel ; Leif Lindholm
> ; Chang, Abner ;
> Michael D Kinney 
> Subject: [PATCH v4 0/3] Adds Platform/AMD/AmdMinBoardPkg
> 
> V4 changes:
>   Rename MinBoardPkg to AmdMinBoardPkg.
>   removed empty Guid section.
> V3 changes:
>   Dropped the PlatformPkg package.
>   Rename BoardPkg to MinBoardPkg
>   Addressed review comments from Leif and Abner.
> 
> Adds AMD/AmdMinBoardPkg to support MinPlatformPkg framework.
> 
> PR: https://github.com/tianocore/edk2-platforms/pull/75
> 
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Cc: Abner Chang 
> Cc: Michael D Kinney 
> Cc: Abdul Lateef Attar 
> 
> Abdul Lateef Attar (3):
>   Platform/AMD: Adds AmdMinBoardPkg to support MinPlatformPkg
>   Platform/AMD/MinBoardPkg: Adds SetCacheMtrrLib library
>   Maintainers.txt: Adds AMD/AmdMinBoardPkg maintainers
> 
>  .../AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec |  19 +++
>  .../AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc |  30 
>  .../SetCacheMtrrLib/SetCacheMtrrLib.inf   |  35 +
>  .../Library/SetCacheMtrrLib/SetCacheMtrrLib.c | 133 ++
>  Maintainers.txt   |   5 +
>  5 files changed, 222 insertions(+)
>  create mode 100644
> Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec
>  create mode 100644
> Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc
>  create mode 100644
> Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib
> .inf
>  create mode 100644
> Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib
> .c
> 
> --
> 2.25.1


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




Re: [edk2-devel] [PATCH v8 9/9] OvmfPkg: Uses SmmSmramSaveStateLib library

2023-04-11 Thread Gerd Hoffmann
On Tue, Apr 11, 2023 at 10:09:59AM +, Ni, Ray wrote:
> Gerd,
> I am asking Abdul to directly call SaveStateLib from CpuSmm driver.
> I don't think SmmCpuFeaturesLib should be in the middle of CpuSmm driver and 
> SaveStateLib
> regarding the save state access.

Yes, sure.  The SmmCpuFeatures{Read,Write}SaveStateRegister() functions
in OvmfPkg/Library/SmmCpuFeaturesLib can be removed in favor of the AMD
version of SmmSmramSaveStateLib.

There are a few more places in OvmfPkg/Library/SmmCpuFeaturesLib which
access the state, for example the functions handling CPU hutplug.  They
use QEMU_SMRAM_SAVE_STATE_MAP today, which should be identical to the
AMD version, so once we have the AMD version merged into the tree ovmf
can just use that instead of its own copy.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102825): https://edk2.groups.io/g/devel/message/102825
Mute This Topic: https://groups.io/mt/98172964/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/7] Use CpuPageTableLib to create and update smm page table

2023-04-11 Thread Gerd Hoffmann
On Tue, Apr 11, 2023 at 02:49:05PM +0800, duntan wrote:
> This patch set is to use CpuPageTableLib to create and update smm page table.
> With the CpuPageTableLib, we can create or update page table by calling
> PageTableMap() in CpuPageTableLib multiple times. Then the original page table
> manipulating code can be removed.

With the patch series applied OvmfPkg/OvmfPkgIa32X64.dsc fails to build.

take care,
  Gerd



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




Re: [edk2-devel] [PATCH v8 9/9] OvmfPkg: Uses SmmSmramSaveStateLib library

2023-04-11 Thread Ni, Ray
Gerd,
I am asking Abdul to directly call SaveStateLib from CpuSmm driver.
I don't think SmmCpuFeaturesLib should be in the middle of CpuSmm driver and 
SaveStateLib
regarding the save state access.

Thanks,
Ray

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Gerd
> Hoffmann
> Sent: Tuesday, April 11, 2023 5:43 PM
> To: Abdul Lateef Attar 
> Cc: devel@edk2.groups.io; Abdul Lateef Attar
> ; Paul Grimes ;
> Garrett Kirkendall ; Abner Chang
> ; Dong, Eric ; Ni, Ray
> ; Kumar, Rahul R ; Ard
> Biesheuvel ; Yao, Jiewen
> ; Justen, Jordan L 
> Subject: Re: [edk2-devel] [PATCH v8 9/9] OvmfPkg: Uses
> SmmSmramSaveStateLib library
> 
> > Uses new SmmSmramSaveStateLib library,
> > which fix the CI failure.
> 
> What is the exact failure you are seeing?
> 
> > +
> SmmSmramSaveStateLib|UefiCpuPkg/Library/SmmSmramSaveStateLib/Intel
> SmmSmramSaveStateLib.inf
> 
> This should be the AMD version.  KVM uses the AMD smram state.
> 
> Also: OvmfPkg/Library/SmmCpuFeaturesLib should be updated to use
> actually use the new SmmSmramSaveStateLib library, and once this
> has been done it should be possible to remove
> OvmfPkg/Include/Register/QemuSmramSaveStateMap.h
> 
> take care,
>   Gerd
> 
> 
> 
> 
> 



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

2023-04-11 Thread Gerd Hoffmann
On Fri, Apr 07, 2023 at 12:00:46PM -0500, Tom Lendacky wrote:
> 
> Thanks for the quick turn-around, but that patch didn't work for me. I've
> update the bugzilla.

Can you try the patch below?

thanks,
  Gerd

>From a9179864523d12c3dcc137f36f6ed1a2832ed22c Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann 
Date: Tue, 11 Apr 2023 11:12:37 +0200
Subject: [PATCH 1/1] OvmfPkg: call ReserveEmuVariableNvStore after
 AmdSevInitialize

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/PlatformPei/Platform.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index c56247e294f2..1e70c1920830 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -378,10 +378,6 @@ InitializePlatform (
   InitializeRamRegions (PlatformInfoHob);
 
   if (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) {
-if (!PlatformInfoHob->SmmSmramRequire) {
-  ReserveEmuVariableNvStore ();
-}
-
 PeiFvInitialization (PlatformInfoHob);
 MemTypeInfoInitialization (PlatformInfoHob);
 MemMapInitialization (PlatformInfoHob);
@@ -390,6 +386,12 @@ InitializePlatform (
 
   InstallClearCacheCallback ();
   AmdSevInitialize (PlatformInfoHob);
+
+  if ((PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) &&
+  (!PlatformInfoHob->SmmSmramRequire)) {
+ReserveEmuVariableNvStore ();
+  }
+
   if (PlatformInfoHob->HostBridgeDevId == 0x) {
 MiscInitializationForMicrovm (PlatformInfoHob);
   } else {
-- 
2.39.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102822): https://edk2.groups.io/g/devel/message/102822
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 1/1] ShellPkg: UefiShellDebug1CommandsLib: Uefi Config Tables in Dmem.c

2023-04-11 Thread Gao, Zhichao
The change is only for the coding style: make sure there is a white space 
between the function name and '('.
I think you can keep the previous R-B.

Thanks,
Zhichao

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Sam
> Kaynor
> Sent: Wednesday, April 5, 2023 4:11 AM
> To: devel@edk2.groups.io
> Cc: Sam Kaynor ; Ni, Ray ; Gao,
> Zhichao ; Sam Kaynor 
> Subject: [edk2-devel] [PATCH v2 1/1] ShellPkg:
> UefiShellDebug1CommandsLib: Uefi Config Tables in Dmem.c
> 
> Added entries for UEFI Config Tables not present in current Dmem output.
> v2 for revising CI formatting errors.
> 
> Cc: Ray Ni 
> Cc: Zhichao Gao 
> Signed-off-by: Sam Kaynor 
> ---
> 
> ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands
> Lib.inf |  9 ++
>  ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 
> 99
> ++--
> 
> ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands
> Lib.uni | 28 --
>  3 files changed, 123 insertions(+), 13 deletions(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman
> dsLib.inf
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman
> dsLib.inf
> index 74ad5facf6b1..3741dac5d94c 100644
> ---
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman
> dsLib.inf
> +++
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman
> d
> +++ sLib.inf
> @@ -121,6 +121,7 @@ [Protocols]
>gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES
> gEfiSimplePointerProtocolGuid   ## SOMETIMES_CONSUMES
> gEfiCpuIo2ProtocolGuid  ## SOMETIMES_CONSUMES+
> gEfiHiiDatabaseProtocolGuid ## SOMETIMES_CONSUMES  [Guids]
> gEfiGlobalVariableGuid  ## SOMETIMES_CONSUMES ## GUID@@ -130,3
> +131,11 @@ [Guids]
>gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## SystemTable
> gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## SystemTable
> gShellDebug1HiiGuid ## SOMETIMES_CONSUMES ## HII+
> gEfiMemoryAttributesTableGuid   ## SOMETIMES_CONSUMES ##
> SystemTable+  gEfiRtPropertiesTableGuid   ## SOMETIMES_CONSUMES ##
> SystemTable+  gEfiSystemResourceTableGuid ## SOMETIMES_CONSUMES
> ## SystemTable+  gEfiDebugImageInfoTableGuid ##
> SOMETIMES_CONSUMES ## SystemTable+  gEfiImageSecurityDatabaseGuid
> ## SOMETIMES_CONSUMES ## SystemTable+  gEfiJsonConfigDataTableGuid
> ## SOMETIMES_CONSUMES ## SystemTable+
> gEfiJsonCapsuleDataTableGuid## SOMETIMES_CONSUMES ##
> SystemTable+  gEfiJsonCapsuleResultTableGuid  ## SOMETIMES_CONSUMES
> ## SystemTablediff --git
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
> index c52c212a56f8..a609971f345e 100644
> --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
> +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
> @@ -10,9 +10,15 @@
>   #include "UefiShellDebug1CommandsLib.h" #include
> +#include  #include
>  #include  #include +#include
> +#include
> +#include
> +#include
> +#include 
> /**   Make a printable character.@@ -108,6 +114,18 @@
> ShellCommandRunDmem (
>UINT64SalTableAddress;   UINT64SmbiosTableAddress;   UINT64
> MpsTableAddress;+  UINT64DtbTableAddress;+  UINT64
> MemoryAttributesTableAddress;+  UINT64RtPropertiesTableAddress;+
> UINT64SystemResourceTableAddress;+  UINT64
> DebugImageInfoTableAddress;+  UINT64ImageExecutionTableAddress;+
> UINT64JsonConfigDataTableAddress;+  UINT64
> JsonCapsuleDataTableAddress;+  UINT64
> JsonCapsuleResultTableAddress;+  UINT64
> MemoryRangeCapsuleAddress;+  UINT64
> HiiDatabaseExportBufferAddress;+  UINT64
> ConformanceProfileTableAddress;   UINTN TableWalker;ShellStatus =
> SHELL_SUCCESS;@@ -168,11 +186,23 @@ ShellCommandRunDmem (
>  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DMEM_HEADER_ROW), gShellDebug1HiiHandle,
> (UINT64)(UINTN)Address, Size); DumpHex (2, (UINTN)Address,
> (UINTN)Size, Address); if (Address == (VOID *)gST) {-
> Acpi20TableAddress = 0;-  AcpiTableAddress   = 0;-  
> SalTableAddress
> = 0;-  SmbiosTableAddress = 0;-  MpsTableAddress= 0;+
> Acpi20TableAddress = 0;+  AcpiTableAddress   
> = 0;+
> SalTableAddress= 0;+  SmbiosTableAddress 
> = 0;+
> MpsTableAddress= 0;+  DtbTableAddress
> = 0;+
> MemoryAttributesTableAddress   = 0;+  RtPropertiesTableAddress   =
> 0;+  SystemResourceTableAddress = 0;+
> DebugImageInfoTableAddress = 0;+  ImageExecutionTableAddress =
> 0;+  JsonConfigDataTableAddress = 0;+
> JsonCapsuleDataTableAddress= 0;+  JsonCapsuleResultTableAddress  =
> 0;+  MemoryRangeCapsuleAddress  = 0;+
> HiiDatabaseExportBufferAddress = 0;+  

Re: [edk2-devel] [PATCH] ShellPkg: Update smbiosview type 0/4/17/41 with SMBIOS 3.5 fields v3

2023-04-11 Thread Gao, Zhichao
Merge at 51734dfc48466eddfb0f8acdb24518266c36c905

Thanks,
Zhichao

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Gao,
> Zhichao
> Sent: Monday, April 10, 2023 1:53 PM
> To: Lin, MillerX ; devel@edk2.groups.io
> Cc: Ni, Ray 
> Subject: Re: [edk2-devel] [PATCH] ShellPkg: Update smbiosview type
> 0/4/17/41 with SMBIOS 3.5 fields v3
> 
> Reviewed-by: Zhichao Gao 
> 
> Thanks,
> Zhichao
> 
> > -Original Message-
> > From: Lin, MillerX 
> > Sent: Monday, April 10, 2023 11:41 AM
> > To: devel@edk2.groups.io
> > Cc: Lin, MillerX ; Ni, Ray ;
> > Gao, Zhichao 
> > Subject: [PATCH] ShellPkg: Update smbiosview type 0/4/17/41 with
> > SMBIOS
> > 3.5 fields v3
> >
> > Cc: Signed-off-by: MillerX Lin 
> > Cc: Ray Ni 
> > Cc: Zhichao Gao 
> > ---
> >  .../SmbiosView/PrintInfo.c| 152 +-
> >  .../SmbiosView/SmbiosViewStrings.uni  |  28 ++--
> >  2 files changed, 89 insertions(+), 91 deletions(-)
> >
> > diff --git
> > a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > index 2611601230..380e4d98c7 100644
> > ---
> > a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > +++
> > b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > @@ -335,10 +335,10 @@ SmbiosPrintStructure (
> >  // BIOS Information (Type 0)
> >  //
> >  case 0:
> > -  PRINT_PENDING_STRING (Struct, Type0, Vendor);
> > -  PRINT_PENDING_STRING (Struct, Type0, BiosVersion);
> > -  PRINT_STRUCT_VALUE_H (Struct, Type0, BiosSegment);
> > -  PRINT_PENDING_STRING (Struct, Type0, BiosReleaseDate);
> > +  ShellPrintEx (-1, -1, L"Vendor: %a\n", LibGetSmbiosString
> > + (Struct, Struct-
> > >Type0->Vendor));
> > +  ShellPrintEx (-1, -1, L"BIOS Version: %a\n", LibGetSmbiosString
> > + (Struct,
> > Struct->Type0->BiosVersion));
> > +  ShellPrintEx (-1, -1, L"BIOS Starting Address Segment: 0x%x\n",
> > + Struct-
> > >Type0->BiosSegment);
> > +  ShellPrintEx (-1, -1, L"BIOS Release Date: %a\n",
> > + LibGetSmbiosString (Struct, Struct->Type0->BiosReleaseDate));
> >ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_BIOS_SIZE), gShellDebug1HiiHandle, 64 *
> > (Struct->Type0->BiosSize + 1));
> >
> >DisplayBiosCharacteristics (ReadUnaligned64 ((UINT64
> > *)(UINTN)&(Struct->Type0->BiosCharacteristics)), Option); @@ -352,10
> > +352,10 @@ SmbiosPrintStructure (
> >}
> >
> >if (AE_SMBIOS_VERSION (0x2, 0x4) && (Struct->Hdr->Length > 0x14)) {
> > -PRINT_STRUCT_VALUE (Struct, Type0, SystemBiosMajorRelease);
> > -PRINT_STRUCT_VALUE (Struct, Type0, SystemBiosMinorRelease);
> > -PRINT_STRUCT_VALUE (Struct, Type0,
> > EmbeddedControllerFirmwareMajorRelease);
> > -PRINT_STRUCT_VALUE (Struct, Type0,
> > EmbeddedControllerFirmwareMinorRelease);
> > +ShellPrintEx (-1, -1, L"System BIOS Major Release: %u\n",
> > + Struct-
> > >Type0->SystemBiosMajorRelease);
> > +ShellPrintEx (-1, -1, L"System BIOS Minor Release: %u\n",
> > + Struct-
> > >Type0->SystemBiosMinorRelease);
> > +ShellPrintEx (-1, -1, L"Embedded Controller Firmware Major
> > Release: %u\n", Struct->Type0-
> > >EmbeddedControllerFirmwareMajorRelease);
> > +ShellPrintEx (-1, -1, L"Embedded Controller Firmware Minor
> > + Release: %u\n",
> > + Struct->Type0->EmbeddedControllerFirmwareMinorRelease);
> >}
> >
> >if (AE_SMBIOS_VERSION (0x3, 0x1) && (Struct->Hdr->Length >
> > 0x18)) { @@ -470,48 +470,49 @@ SmbiosPrintStructure (
> >  // Processor Information (Type 4)
> >  //
> >  case 4:
> > -  PRINT_SMBIOS_STRING (Struct, Struct->Type4->Socket,
> > SocketDesignation)
> > +  ShellPrintEx (-1, -1, L"Socket Designation: %a\n",
> > + LibGetSmbiosString (Struct, Struct->Type4->Socket));
> >DisplayProcessorType (Struct->Type4->ProcessorType, Option);
> > -  if (AE_SMBIOS_VERSION (0x2, 0x6) && (Struct->Hdr->Length > 0x28)
> &&
> > -  (Struct->Type4->ProcessorFamily == 0xFE))
> > -  {
> > -//
> > -// Get family from ProcessorFamily2 field
> > -//
> > -DisplayProcessorFamily2 (Struct->Type4->ProcessorFamily2, Option);
> > -  } else {
> > -DisplayProcessorFamily (Struct->Type4->ProcessorFamily, Option);
> > -  }
> > -
> > -  PRINT_PENDING_STRING (Struct, Type4, ProcessorManufacturer);
> > -  PRINT_BIT_FIELD (Struct, Type4, ProcessorId, 8);
> > -  PRINT_PENDING_STRING (Struct, Type4, ProcessorVersion);
> > +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_PROCESSOR_FAMILY),
> > gShellDebug1HiiHandle);
> > +  DisplayProcessorFamily (Struct->Type4->ProcessorFamily, Option);
> > +  ShellPrintEx (-1, -1, L"Processor Manufacturer: %a\n",
> > LibGetSmbiosString (Struct, Struct->Type4->ProcessorManufacturer));
> > +  

Re: [edk2-devel] [PATCH v8 9/9] OvmfPkg: Uses SmmSmramSaveStateLib library

2023-04-11 Thread Gerd Hoffmann
> Uses new SmmSmramSaveStateLib library,
> which fix the CI failure.

What is the exact failure you are seeing?

> +  
> SmmSmramSaveStateLib|UefiCpuPkg/Library/SmmSmramSaveStateLib/IntelSmmSmramSaveStateLib.inf

This should be the AMD version.  KVM uses the AMD smram state.

Also: OvmfPkg/Library/SmmCpuFeaturesLib should be updated to use
actually use the new SmmSmramSaveStateLib library, and once this
has been done it should be possible to remove
OvmfPkg/Include/Register/QemuSmramSaveStateMap.h

take care,
  Gerd



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




Re: [edk2-devel] [PATCH 00/18] Replace pre-standard macro __FUNCTION__ with C99 __func__ throughout edk2

2023-04-11 Thread Gerd Hoffmann
On Thu, Apr 06, 2023 at 04:23:01PM -0600, Rebecca Cran wrote:
> Following on from commit b17a3a133b18fb41493fba7d86e9b5804ea6a8cf which
> updated MdePkg to be more C11 compliant by replacing the pre-standard
> __FUNCTION__ with __func__ which was introduced in C99, this patch
> series updates the remaining packages in edk2.
> 
> The changes were generated by using "Replace in Files" in VS Code.

Acked-by: Gerd Hoffmann 



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




Re: [edk2-devel] [PATCH v8 8/9] UefiCpuPkg: Uses SmmSmramSaveStateLib library

2023-04-11 Thread Ni, Ray


>Status = SmmCpuFeaturesReadSaveStateRegister (CpuIndex, Register,
> Width, Buffer);
>if (Status == EFI_UNSUPPORTED) {
> -Status = ReadSaveStateRegister (CpuIndex, Register, Width, Buffer);
> +Status = SmramSaveStateReadRegister (CpuIndex, Register, Width,
> Buffer);
>}
> 

I would expect that above code unconditionally calls 
SmramSaveStateReadRegister()
instead of having the Smram Save state access logic in either SmmCpuFeaturesLib 
or in SmramSaveStateLib.

In open source project, you could directly call SmramSaveStateReadRegister() 
because SmmCpuFeaturesReadSaveStateRegister()
in edk2 repo returns EFI_UNSUPPORTED.

I agree that close-source project which does something in 
SmmCpuFeaturesReadSaveStateRegister() should update the implementation to
move the logic from SmmCpuFeaturesReadSaveStateRegister() to the new 
close-source MmSaveStateLib instance.

We should explicitly mention the impact to these projects in commit messages.

Thanks,
Ray



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102817): https://edk2.groups.io/g/devel/message/102817
Mute This Topic: https://groups.io/mt/98172957/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 4/8] OvmfPkg: Add CpuPageTableLib required by DxeIpl in DSC file

2023-04-11 Thread Gerd Hoffmann
On Tue, Apr 11, 2023 at 06:51:25AM +, Tan, Dun wrote:
> Hi all, 
> Could you please help review this patch?

Acked-by: Gerd Hoffmann 



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




Re: [edk2-devel] [PATCH v8 7/9] UefiCpuPkg: Implements SmmSmramSaveStateLib for Intel

2023-04-11 Thread Ni, Ray
> +
> SmmSmramSaveStateLib|UefiCpuPkg/Library/SmmSmramSaveStateLib/Intel
> SmmSmramSaveStateLib.inf

1. Can you rename it to "IntelMmSaveStateLib"?


> +  INF_VERSION= 1.29
> +  BASE_NAME  = IntelSmmSmramSaveStateLib
> +  FILE_GUID  = 37E8137B-9F74-4250-8951-7A970A3C39C0
> +  MODULE_TYPE= DXE_SMM_DRIVER
> +  VERSION_STRING = 1.0
> +  LIBRARY_CLASS  = SmmSmramSaveStateLib

2. Can you check back the comments I left for AMD instance and apply similar 
changes here?

>  **/
>  EFI_STATUS
> -EFIAPI

3. Why remove "EFIAPI"?


> +/**
> +  Read an SMM Save State register on the target processor.  If this function
> +  returns EFI_UNSUPPORTED, then the caller is responsible for reading the
> +  SMM Save Sate register.
> +
> +  @param[in]  CpuIndex  The index of the CPU to read the SMM Save State.
> The
> +value must be between 0 and the NumberOfCpus field in
> +the System Management System Table (SMST).
> +  @param[in]  Register  The SMM Save State register to read.
> +  @param[in]  Width The number of bytes to read from the CPU save
> state.
> +  @param[out] BufferUpon return, this holds the CPU register value read
> +from the save state.
> +
> +  @retval EFI_SUCCESS   The register was read from Save State.
> +  @retval EFI_INVALID_PARAMTER  Buffer is NULL.
> +  @retval EFI_UNSUPPORTED   This function does not support reading
> Register.
> +  @retval EFI_NOT_FOUND If desired Register not found.
> +**/
> +EFI_STATUS
> +EFIAPI
> +SmramSaveStateReadRegister (
> +  IN  UINTNCpuIndex,
> +  IN  EFI_SMM_SAVE_STATE_REGISTER  Register,
> +  IN  UINTNWidth,
> +  OUT VOID *Buffer
> +  )
> +{
> +  UINT32  SmmRevId;
> +  SMRAM_SAVE_STATE_IOMISC IoMisc;
> +  EFI_SMM_SAVE_STATE_IO_INFO  *IoInfo;
> +
> +  //
> +  // Check for special EFI_SMM_SAVE_STATE_REGISTER_LMA
> +  //
> +  if (Register == EFI_SMM_SAVE_STATE_REGISTER_LMA) {
> +//
> +// Only byte access is supported for this register
> +//
> +if (Width != 1) {
> +  return EFI_INVALID_PARAMETER;
> +}
> +
> +*(UINT8 *)Buffer = SmramSaveStateGetRegisterLma ();

4. It's Intel specific flow. I am curious how AMD flow handles the LMA read.

> +
> +return EFI_SUCCESS;
> +  }
> +
> +  //
> +  // Check for special EFI_SMM_SAVE_STATE_REGISTER_IO
> +  //
> +  if (Register == EFI_SMM_SAVE_STATE_REGISTER_IO) {

5. Similar question here: how AMD flow handles the IO read?


> +
> +  //
> +  // Convert Register to a register lookup table index
> +  //
> +  return SmramSaveStateReadRegisterByIndex (CpuIndex,
> SmramSaveStateGetRegisterIndex (Register), Width, Buffer);

6. Can you double check here? The mSmmSmramCpuWidthOffset[] of Intel/AMD 
version don't put the GdtBase in the same location.
SMM_SAVE_STATE_REGISTER_MAX_INDEX is 2 for AMD but should be 4 for Intel.
How about define a "CONST UINTN gSmmSaveStateRegisterMaxIndex" with different 
values in Intel/AmdSmramSaveState.c?



>  EFI_STATUS
> -EFIAPI

7. Why remove "EFIAPI"?

> +UINT8
> +IntelSmramSaveStateGetRegisterLma (

8. Can you implement the SmramSaveStateGetRegisterLma() in Intel/Amd C files?



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102815): https://edk2.groups.io/g/devel/message/102815
Mute This Topic: https://groups.io/mt/98172953/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 v8 6/9] UefiCpuPkg: Implements SmmCpuFeaturesLib for AMD Family

2023-04-11 Thread Ni, Ray
Acked-by: Ray Ni 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Abdul
> Lateef Attar via groups.io
> Sent: Monday, April 10, 2023 7:10 PM
> To: devel@edk2.groups.io
> Cc: Abdul Lateef Attar ; Paul Grimes
> ; Garrett Kirkendall ;
> Abner Chang ; Dong, Eric ;
> Ni, Ray ; Kumar, Rahul R ;
> Abdul Lateef Attar 
> Subject: [edk2-devel] [PATCH v8 6/9] UefiCpuPkg: Implements
> SmmCpuFeaturesLib for AMD Family
> 
> From: Abdul Lateef Attar 
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182
> 
> Implements interfaces to read and write save state
> registers of AMD's processor family.
> Initializes processor SMMADDR and MASK depends
> on PcdSmrrEnable flag.
> Program or corrects the IP once control returns from SMM.
> 
> Cc: Paul Grimes 
> Cc: Garrett Kirkendall 
> Cc: Abner Chang 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Signed-off-by: Abdul Lateef Attar 
> Reviewed-by: Abner Chang 
> ---
>  .../AmdSmmCpuFeaturesLib.inf  |   5 +
>  .../SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c  | 106
> +-
>  2 files changed, 108 insertions(+), 3 deletions(-)
> 
> diff --git
> a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
> b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
> index 4c77efc64462..6d6f879e2a43 100644
> --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
> +++
> b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
> @@ -31,3 +31,8 @@ [LibraryClasses]
>PcdLib
>MemoryAllocationLib
>DebugLib
> +  SmmSmramSaveStateLib
> +
> +[FeaturePcd]
> +  gUefiCpuPkgTokenSpaceGuid.PcdSmrrEnable   ## CONSUMES
> +  gUefiCpuPkgTokenSpaceGuid.PcdSmmFeatureControlEnable  ##
> CONSUMES
> diff --git
> a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
> b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
> index c74e1a0c0c5b..af45be3e265a 100644
> --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
> +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
> @@ -11,6 +11,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  #include 
>  #include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +// EFER register LMA bit
> +#define LMA  BIT10
> +
> +// Machine Specific Registers (MSRs)
> +#define SMMADDR_ADDRESS  0xC0010112ul
> +#define SMMMASK_ADDRESS  0xC0010113ul
> +#define EFER_ADDRESS 0XC080ul
> +
> +// The mode of the CPU at the time an SMI occurs
> +STATIC UINT8  mSmmSaveStateRegisterLma;
> 
>  /**
>Read an SMM Save State register on the target processor.  If this function
> @@ -39,7 +54,7 @@ SmmCpuFeaturesReadSaveStateRegister (
>OUT VOID *Buffer
>)
>  {
> -  return EFI_SUCCESS;
> +  return SmramSaveStateReadRegister (CpuIndex, Register, Width, Buffer);
>  }
> 
>  /**
> @@ -67,7 +82,7 @@ SmmCpuFeaturesWriteSaveStateRegister (
>IN CONST VOID   *Buffer
>)
>  {
> -  return EFI_SUCCESS;
> +  return SmramSaveStateWriteRegister (CpuIndex, Register, Width, Buffer);
>  }
> 
>  /**
> @@ -82,6 +97,13 @@ CpuFeaturesLibInitialization (
>VOID
>)
>  {
> +  UINT32  LMAValue;
> +
> +  LMAValue = (UINT32)AsmReadMsr64 (EFER_ADDRESS) & LMA;
> +  mSmmSaveStateRegisterLma =
> EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT;
> +  if (LMAValue) {
> +mSmmSaveStateRegisterLma =
> EFI_SMM_SAVE_STATE_REGISTER_LMA_64BIT;
> +  }
>  }
> 
>  /**
> @@ -117,6 +139,52 @@ SmmCpuFeaturesInitializeProcessor (
>IN CPU_HOT_PLUG_DATA  *CpuHotPlugData
>)
>  {
> +  AMD_SMRAM_SAVE_STATE_MAP  *CpuState;
> +  UINT32LMAValue;
> +
> +  //
> +  // Configure SMBASE.
> +  //
> +  CpuState = (AMD_SMRAM_SAVE_STATE_MAP
> *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
> +  CpuState->x64.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex];
> +
> +  // Re-initialize the value of mSmmSaveStateRegisterLma flag which might
> have been changed in PiCpuSmmDxeSmm Driver
> +  // Entry point, to make sure correct value on AMD platform is assigned to
> be used by SmmCpuFeaturesLib.
> +  LMAValue = (UINT32)AsmReadMsr64 (EFER_ADDRESS) & LMA;
> +  mSmmSaveStateRegisterLma =
> EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT;
> +  if (LMAValue) {
> +mSmmSaveStateRegisterLma =
> EFI_SMM_SAVE_STATE_REGISTER_LMA_64BIT;
> +  }
> +
> +  //
> +  // If SMRR is supported, then program SMRR base/mask MSRs.
> +  // The EFI_MSR_SMRR_PHYS_MASK_VALID bit is not set until the first
> normal SMI.
> +  // The code that initializes SMM environment is running in normal mode
> +  // from SMRAM region.  If SMRR is enabled here, then the SMRAM region
> +  // is protected and the normal mode code execution will fail.
> +  //
> +  if (FeaturePcdGet (PcdSmrrEnable)) {
> +//
> +// SMRR size cannot be less than 4-KBytes
> +// SMRR size must be of length 2^n
> +// SMRR base alignment cannot be less than SMRR length
> +//
> +if 

Re: [edk2-devel] [PATCH v8 5/9] UefiCpuPkg: Initial implementation of AMD's SmmCpuFeaturesLib

2023-04-11 Thread Ni, Ray
Reviewed-by: Ray Ni 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Abdul
> Lateef Attar via groups.io
> Sent: Monday, April 10, 2023 7:10 PM
> To: devel@edk2.groups.io
> Cc: Abdul Lateef Attar ; Paul Grimes
> ; Garrett Kirkendall ;
> Abner Chang ; Dong, Eric ;
> Ni, Ray ; Kumar, Rahul R 
> Subject: [edk2-devel] [PATCH v8 5/9] UefiCpuPkg: Initial implementation of
> AMD's SmmCpuFeaturesLib
> 
> From: Abdul Lateef Attar 
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182
> 
> Adds initial defination for AMD's SmmCpuFeaturesLib
> library implementation.
> All function's body either empty or just returns
> value. Its initial skeleton of library implementation.
> 
> Cc: Paul Grimes 
> Cc: Garrett Kirkendall 
> Cc: Abner Chang 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Signed-off-by: Abdul Lateef Attar 
> Reviewed-by: Abner Chang 
> ---
>  UefiCpuPkg/UefiCpuPkg.dsc |   8 +
>  .../AmdSmmCpuFeaturesLib.inf  |  33 ++
>  .../SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c  | 345
> ++
>  3 files changed, 386 insertions(+)
>  create mode 100644
> UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
>  create mode 100644
> UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
> 
> diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
> index c33059cd3209..043eb2dbc1b1 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dsc
> +++ b/UefiCpuPkg/UefiCpuPkg.dsc
> @@ -171,6 +171,13 @@ [Components.IA32, Components.X64]
>  
> 
> SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFea
> turesLibStm.inf
>}
> +  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
> +
> +  FILE_GUID = B7242C74-BD21-49EE-84B4-07162E8C080D
> +
> +
> SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCp
> uFeaturesLib.inf
> +
> SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull
> /SmmCpuPlatformHookLibNull.inf
> +  }
>UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
>UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf
>UefiCpuPkg/Library/SmmCpuRendezvousLib/SmmCpuRendezvousLib.inf
> @@ -187,6 +194,7 @@ [Components.IA32, Components.X64]
> 
> UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultRep
> ortLib/UnitTestResultReportLibConOut.inf
>}
> 
> UefiCpuPkg/Library/SmmSmramSaveStateLib/AmdSmmSmramSaveStateLib.
> inf
> +  UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
> 
>  [Components.X64]
> 
> UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHan
> dlerLibUnitTest.inf
> diff --git
> a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
> b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
> new file mode 100644
> index ..4c77efc64462
> --- /dev/null
> +++
> b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
> @@ -0,0 +1,33 @@
> +## @file
> +#  The CPU specific programming for PiSmmCpuDxeSmm module.
> +#
> +#  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
> +#  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION= 0x00010005
> +  BASE_NAME  = SmmCpuFeaturesLib
> +  MODULE_UNI_FILE= SmmCpuFeaturesLib.uni
> +  FILE_GUID  = 5849E964-78EC-428E-8CBD-848A7E359134
> +  MODULE_TYPE= DXE_SMM_DRIVER
> +  VERSION_STRING = 1.0
> +  LIBRARY_CLASS  = SmmCpuFeaturesLib
> +  CONSTRUCTOR= SmmCpuFeaturesLibConstructor
> +
> +[Sources]
> +  SmmCpuFeaturesLib.c
> +  SmmCpuFeaturesLibCommon.c
> +  AmdSmmCpuFeaturesLib.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  UefiCpuPkg/UefiCpuPkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  PcdLib
> +  MemoryAllocationLib
> +  DebugLib
> diff --git
> a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
> b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
> new file mode 100644
> index ..c74e1a0c0c5b
> --- /dev/null
> +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
> @@ -0,0 +1,345 @@
> +/** @file
> +Implementation specific to the SmmCpuFeatureLib library instance
> +for AMD based platforms.
> +
> +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
> +Copyright (c) Microsoft Corporation.
> +Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include 
> +#include 
> +
> +/**
> +  Read an SMM Save State register on the target processor.  If this function
> +  returns EFI_UNSUPPORTED, then the caller is responsible for reading the
> +  SMM Save Sate register.
> +
> +  @param[in]  CpuIndex  The index of the CPU to read the SMM Save State.
> The
> +value must be between 0 and the NumberOfCpus field in
> +

Re: [edk2-devel] [PATCH v8 3/9] UefiCpuPkg: Implements SmmSmramSaveStateLib library class

2023-04-11 Thread Ni, Ray
> +
> SmmSmramSaveStateLib|UefiCpuPkg/Library/SmmSmramSaveStateLib/Am
> dSmmSmramSaveStateLib.inf

1. The lib instance name can be AmdMmSaveStateLib inside X86MmSaveStateLib 
folder.

> +[Defines]
> +  INF_VERSION= 1.29
> +  BASE_NAME  = AmdSmmSmramSaveStateLib
> +  FILE_GUID  = FB7D0A60-E8D4-4EFA-90AA-B357BC569879
> +  MODULE_TYPE= DXE_SMM_DRIVER


2. The module type can be BASE.


> +  VERSION_STRING = 1.0
> +  LIBRARY_CLASS  = SmmSmramSaveStateLib

3. The LIBRARY_CLASS can be "MmSaveStateLib|DXE_SMM_DRIVER MM_STANDALONE" 
indicating it supports the two types of modules.

> +typedef struct {
> +  UINT8  Width32;
> +  UINT8  Width64;
> +  UINT16 Offset32;
> +  UINT16 Offset64Lo;
> +  UINT16 Offset64Hi;

4. With above structure definition "Offset64Lo/Offset64Hi", I realized that you 
define AMD_SMRAM_SAVE_STATE_MAP64 in a way
to split the lower 32bit and high 32bit to two fields.  I think it's only 
needed when the lower 32bit and higher 32bit are not adjacent.
Otherwise, you can just define "UINT64 _IDTRBase" in AMD_SMRAM_SAVE_STATE_MAP64.
(Unfortunately, GdtBase/LdtBase/IdtBase are split to two 32bit fields not 
adjacent to each other in Intel 64bit save state. But AMD
doesn't need to.)
So the recommendation here is to do some simplification to the AMD 64bit save 
state definition.

5. Another thought here: Can we remove "AMD_" prefix from the structure name 
"AMD_SMRAM_SAVE_STATE_MAP64"?
Because when we define CPUIDs or MSRs, we don't put "INTEL_" or "AMD_" prefix 
either.
The definition file is in "MdePkg/Include/Register/Amd" folder which already 
indicates it's AMD specific definition.

> +**/
> +UINTN
> +EFIAPI

6. No need for "EFIAPI".

> +SmramSaveStateGetRegisterIndex (

7. Since it's not an API, can it be renamed as "MmSaveStateLibGetRegisterIndex"?

> +  IN EFI_SMM_SAVE_STATE_REGISTER  Register
> +  );
> +


> +EFI_STATUS
> +EFIAPI
> +SmramSaveStateReadRegisterByIndex (
> +  IN UINTN  CpuIndex,
> +  IN UINTN  RegisterIndex,
> +  IN UINTN  Width,
> +  OUT VOID  *Buffer
> +  )
> +{
> +  if (RegisterIndex == 0) {
> +return EFI_NOT_FOUND;
> +  }
> +
> +  if (SmramSaveStateGetRegisterLma () ==
> EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) {
> +//
> +// If 32-bit mode width is zero, then the specified register can not be
> accessed
> +//
> +if (mSmmSmramCpuWidthOffset[RegisterIndex].Width32 == 0) {
> +  return EFI_NOT_FOUND;
> +}
> +
> +//
> +// If Width is bigger than the 32-bit mode width, then the specified
> register can not be accessed
> +//
> +if (Width > mSmmSmramCpuWidthOffset[RegisterIndex].Width32) {
> +  return EFI_INVALID_PARAMETER;
> +}
> +
> +//
> +// Write return buffer
> +//
> +ASSERT (gSmst->CpuSaveState[CpuIndex] != NULL);
> +CopyMem (Buffer, (UINT8 *)gSmst->CpuSaveState[CpuIndex] +
> mSmmSmramCpuWidthOffset[RegisterIndex].Offset32, Width);
> +  } else {
> +//
> +// If 64-bit mode width is zero, then the specified register can not be
> accessed
> +//
> +if (mSmmSmramCpuWidthOffset[RegisterIndex].Width64 == 0) {
> +  return EFI_NOT_FOUND;
> +}
> +
> +//
> +// If Width is bigger than the 64-bit mode width, then the specified
> register can not be accessed
> +//
> +if (Width > mSmmSmramCpuWidthOffset[RegisterIndex].Width64) {
> +  return EFI_INVALID_PARAMETER;
> +}
> +
> +//
> +// Write lower 32-bits of return buffer
> +//
> +CopyMem (Buffer, (UINT8 *)gSmst->CpuSaveState[CpuIndex] +
> mSmmSmramCpuWidthOffset[RegisterIndex].Offset64Lo, MIN (4, Width));
> +if (Width >= 4) {
> +  //
> +  // Write upper 32-bits of return buffer
> +  //
> +  CopyMem ((UINT8 *)Buffer + 4, (UINT8 *)gSmst-
> >CpuSaveState[CpuIndex] +
> mSmmSmramCpuWidthOffset[RegisterIndex].Offset64Hi, Width - 4);
> +}
> +  }
> +
> +  return EFI_SUCCESS;

8. I feel the above logic that reads from 32bit/64bit SMRAM save state can be
written in a simpler way.
But since the logic aligns with the existing one in CpuSmm driver, I am ok that 
we
do the simplification in other time.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102812): https://edk2.groups.io/g/devel/message/102812
Mute This Topic: https://groups.io/mt/98172963/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 v8 2/9] UefiCpuPkg: Adds SmmSmramSaveStateLib library class

2023-04-11 Thread Ni, Ray
> +  ## @libraryclass   Provides functions for manipulating Smram savestate
> registers.
> +  SmmSmramSaveSateLib|Include/Library/SmmSmramSaveStateLib.h

1. Can you please rename the lib class to MmSaveStateLib? So the lib can be 
potentially linked with standalone MM CPU driver.
2. Also the lib header file name can be "MmSaveStateLib.h".

> +EFI_STATUS
> +EFIAPI
> +SmramSaveStateReadRegister (
3. The API can be MmSaveStateReadRegister().


> +  IN  UINTNCpuIndex,
> +  IN  EFI_SMM_SAVE_STATE_REGISTER  Register,
4. "EFI_MM_SAVE_STATE_REGISTER"



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102811): https://edk2.groups.io/g/devel/message/102811
Mute This Topic: https://groups.io/mt/98172965/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 v8 1/9] MdePkg: Adds AMD SMRAM save state map

2023-04-11 Thread Ni, Ray
The patch looks good in general.
@Kinney, Michael D, I think it's ok to use "SmramSaveStateMap.h" instead of 
"MmramSaveStateMap.h" because it matches to the CPU spec.
Do you agree?

"MM" is more like a general term that applies to all archs, X86, ARM, etc.

Abdul, just curious why do you add prefix "_" for some of the fields? I am ok 
if it matches to the AMD CPU spec.

Thanks,
Ray

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Abdul
> Lateef Attar via groups.io
> Sent: Monday, April 10, 2023 7:10 PM
> To: devel@edk2.groups.io
> Cc: Abdul Lateef Attar ; Paul Grimes
> ; Garrett Kirkendall ;
> Abner Chang ; Kinney, Michael D
> ; Gao, Liming ;
> Liu, Zhiguang 
> Subject: [edk2-devel] [PATCH v8 1/9] MdePkg: Adds AMD SMRAM save state
> map
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182
> 
> Adds an SMM SMRAM save-state map for AMD processors.
> SMRAM save state maps for the AMD processor family are now supported.
> 
> Save state map structure is added based on
> AMD64 Architecture Programmer's Manual, Volume 2, Section 10.2.
> 
> The AMD legacy save state map for 32-bit architecture is defined.
> The AMD64 save state map for 64-bit architecture is defined.
> 
> Also added Amd/SmramSaveStateMap.h to IgnoreFiles of EccCheck,
> because structures defined in this file are derived from
> Intel/SmramSaveStateMap.h.
> 
> Cc: Paul Grimes 
> Cc: Garrett Kirkendall 
> Cc: Abner Chang 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> 
> Signed-off-by: Abdul Lateef Attar 
> Reviewed-by: Abner Chang 
> Reviewed-by: Michael D Kinney 
> ---
>  .../Include/Register/Amd/SmramSaveStateMap.h  | 194
> ++
>  MdePkg/MdePkg.ci.yaml |   4 +-
>  2 files changed, 197 insertions(+), 1 deletion(-)
>  create mode 100644
> MdePkg/Include/Register/Amd/SmramSaveStateMap.h
> 
> diff --git a/MdePkg/Include/Register/Amd/SmramSaveStateMap.h
> b/MdePkg/Include/Register/Amd/SmramSaveStateMap.h
> new file mode 100644
> index ..0607d2a19145
> --- /dev/null
> +++ b/MdePkg/Include/Register/Amd/SmramSaveStateMap.h
> @@ -0,0 +1,194 @@
> +/** @file
> +  AMD SMRAM Save State Map Definitions.
> +
> +  SMRAM Save State Map definitions based on contents of the
> +AMD64 Architecture Programmer Manual:
> +Volume 2, System Programming, Section 10.2 SMM Resources
> +
> +  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
> +  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved .
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_SMRAM_SAVE_STATE_MAP_H_
> +#define AMD_SMRAM_SAVE_STATE_MAP_H_
> +
> +///
> +/// Default SMBASE address
> +///
> +#define SMM_DEFAULT_SMBASE  0x3
> +
> +///
> +/// Offset of SMM handler from SMBASE
> +///
> +#define SMM_HANDLER_OFFSET  0x8000
> +
> +// SMM-Revision Identifier for AMD64 Architecture.
> +#define AMD_SMM_MIN_REV_ID_X64  0x30064
> +
> +#pragma pack (1)
> +
> +///
> +/// 32-bit SMRAM Save State Map
> +///
> +typedef struct {
> +  // Padded an extra 0x200 bytes to match Intel/EDK2
> +  UINT8 Reserved[0x200]; // fc00h
> +  // AMD Save State area starts @ 0xfe00
> +  UINT8 Reserved1[0xf8]; // fe00h
> +  UINT32SMBASE;  // fef8h
> +  UINT32SMMRevId;// fefch
> +  UINT16IORestart;   // ff00h
> +  UINT16AutoHALTRestart; // ff02h
> +  UINT8 Reserved2[0x84]; // ff04h
> +  UINT32GDTBase; // ff88h
> +  UINT64Reserved3;   // ff8ch
> +  UINT32IDTBase; // ff94h
> +  UINT8 Reserved4[0x10]; // ff98h
> +  UINT32_ES; // ffa8h
> +  UINT32_CS; // ffach
> +  UINT32_SS; // ffb0h
> +  UINT32_DS; // ffb4h
> +  UINT32_FS; // ffb8h
> +  UINT32_GS; // ffbch
> +  UINT32LDTBase; // ffc0h
> +  UINT32_TR; // ffc4h
> +  UINT32_DR7;// ffc8h
> +  UINT32_DR6;// ffcch
> +  UINT32_EAX;// ffd0h
> +  UINT32_ECX;// ffd4h
> +  UINT32_EDX;// ffd8h
> +  UINT32_EBX;// ffdch
> +  UINT32_ESP;// ffe0h
> +  UINT32_EBP;// ffe4h
> +  UINT32_ESI;// ffe8h
> +  UINT32_EDI;// ffech
> +  UINT32_EIP;// fff0h
> +  UINT32_EFLAGS; // fff4h
> +  UINT32_CR3;// fff8h
> +  UINT32_CR0;// fffch
> +} AMD_SMRAM_SAVE_STATE_MAP32;
> +
> +///
> +/// 64-bit SMRAM Save State Map
> +///
> +typedef struct {
> +  // Padded an extra 0x200 bytes to match Intel/EDK2
> +  UINT8 Reserved[0x200]; // fc00h
> +  // AMD Save State area starts @ 0xfe00
> +  UINT16_ES;  // fe00h
> +  UINT16_ESAttributes;// fe02h
> +  UINT32_ESLimit; // fe04h
> +  UINT64_ESBase;  // fe08h
> +
> +  UINT16_CS;  // fe10h
> +  UINT16_CSAttributes;// fe12h
> +  

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

2023-04-11 Thread duntan
Hi all,
Could you please help review this patch?

Thanks,
Dun

-Original Message-
From: devel@edk2.groups.io  On Behalf Of duntan
Sent: Friday, March 31, 2023 5:34 PM
To: devel@edk2.groups.io
Cc: Wang, Jian J ; Gao, Liming 
; Ni, Ray 
Subject: [edk2-devel] [Patch V2 3/8] MdeModulePkg: Add CpuPageTableLib required 
by DxeIpl in DSC

Add CpuPageTableLib instance required by DxeIpl in MdeModulePkg.dsc.

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

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








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




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

2023-04-11 Thread duntan
Hi all, 

Could you please help review this patch?

Thanks,
Dun

-Original Message-
From: devel@edk2.groups.io  On Behalf Of duntan
Sent: Friday, March 31, 2023 5:34 PM
To: devel@edk2.groups.io
Cc: Gao, Liming ; Ni, Ray ; Wang, 
Jian J 
Subject: [edk2-devel] [Patch V2 5/8] MdeModulePkg: Add UefiCpuPkg.dec to pass 
DependencyCheck

Add UefiCpuPkg/UefiCpuPkg.dec in MdeModulePkg.ci.yaml to pass DependencyCheck 
since DxeIpl in MdeModulePkg needs to consume CpuPageTableLib in UefiCpuPkg.

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

diff --git a/MdeModulePkg/MdeModulePkg.ci.yaml 
b/MdeModulePkg/MdeModulePkg.ci.yaml
index f69989087b..d2616f4cdc 100644
--- a/MdeModulePkg/MdeModulePkg.ci.yaml
+++ b/MdeModulePkg/MdeModulePkg.ci.yaml
@@ -2,7 +2,7 @@
 # CI configuration for MdeModulePkg
 #
 # Copyright (c) Microsoft Corporation
-# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2020 - 2023, Intel Corporation. All rights 
+reserved.
 # (C) Copyright 2021 Hewlett Packard Enterprise Development LP  # 
SPDX-License-Identifier: BSD-2-Clause-Patent  ## @@ -51,7 +51,8 @@
 "MdePkg/MdePkg.dec",
 "MdeModulePkg/MdeModulePkg.dec",
 "StandaloneMmPkg/StandaloneMmPkg.dec",
-"ArmPkg/ArmPkg.dec"  # this should be fixed by promoting an 
abstraction
+"ArmPkg/ArmPkg.dec",  # this should be fixed by promoting an 
abstraction
+"UefiCpuPkg/UefiCpuPkg.dec"
 ],
 # For host based unit tests
 "AcceptableDependencies-HOST_APPLICATION":[
--
2.31.1.windows.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102808): https://edk2.groups.io/g/devel/message/102808
Mute This Topic: https://groups.io/mt/98192624/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 4/8] OvmfPkg: Add CpuPageTableLib required by DxeIpl in DSC file

2023-04-11 Thread duntan
Hi all, 
Could you please help review this patch?

Thanks,
Dun

-Original Message-
From: devel@edk2.groups.io  On Behalf Of duntan
Sent: Friday, March 31, 2023 5:34 PM
To: devel@edk2.groups.io
Cc: Ard Biesheuvel ; Yao, Jiewen 
; Justen, Jordan L ; Gerd 
Hoffmann ; Ni, Ray 
Subject: [edk2-devel] [Patch V2 4/8] OvmfPkg: Add CpuPageTableLib required by 
DxeIpl in DSC file

Add CpuPageTableLib instance required by DxeIpl in corresponding DSC files of 
OvmfPkg.

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

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index 
c005e474dd..3a23e38263 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -169,6 +169,7 @@
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
   PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf
   DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf
+  
+ CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 
 !if $(SOURCE_DEBUG_ENABLE) == TRUE
   
PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
@@ -352,7 +353,6 @@
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
-  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   
NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc index 
d0d2712c56..67f8a77c3a 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -1,6 +1,6 @@
 #
 #  Copyright (c) 2020, Rebecca Cran  -#  Copyright (c) 2006 
- 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2023, Intel Corporation. All rights 
+reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP  #  
Copyright (c) 2014, Pluribus Networks, Inc.
 #
@@ -171,6 +171,7 @@
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
   PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf
   DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf
+  
+ CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 
   
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
   
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc 
index b9820cc14b..ffc65b0e15 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -190,6 +190,7 @@
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
   PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf
   DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf
+  
+ CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 !if $(SMM_REQUIRE) == FALSE
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
 !endif
@@ -403,7 +404,6 @@
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
-  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   
NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc 
index 384b0b7afc..aa74a9d5ad 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -193,6 +193,7 @@
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
   PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf
   DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf
+  
+ CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 
 !if $(SOURCE_DEBUG_ENABLE) == TRUE
   
PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
@@ -402,7 +403,6 @@
   PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
   

[edk2-devel] [PATCH 7/7] UefiCpuPkg/PiSmmCpuDxeSmm: Remove unnecessary function

2023-04-11 Thread duntan
Remove unnecessary function SetNotPresentPage(). We can directly
use ConvertMemoryPageAttributes to set a range to non-present.

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c |  8 ++--
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 16 
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 22 --
 3 files changed, 6 insertions(+), 40 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
index c0e368ea94..5316ba7b5a 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -1074,10 +1074,14 @@ PiCpuSmmEntry (
 mSmmShadowStackSize
 );
   if (FeaturePcdGet (PcdCpuSmmStackGuard)) {
-SetNotPresentPage (
+ConvertMemoryPageAttributes (
   Cr3,
+  mPagingMode,
   (EFI_PHYSICAL_ADDRESS)(UINTN)Stacks + mSmmStackSize + 
EFI_PAGES_TO_SIZE (1) + (mSmmStackSize + mSmmShadowStackSize) * Index,
-  EFI_PAGES_TO_SIZE (1)
+  EFI_PAGES_TO_SIZE (1),
+  EFI_MEMORY_RP,
+  TRUE,
+  NULL
   );
   }
 }
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index 518bbf7853..a95ecc876a 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -1236,22 +1236,6 @@ SetShadowStack (
   IN  UINT64Length
   );
 
-/**
-  Set not present memory.
-
-  @param[in]  Cr3  The page table base address.
-  @param[in]  BaseAddress  The physical address that is the start address 
of a memory region.
-  @param[in]  Length   The size in bytes of the memory region.
-
-  @retval EFI_SUCCESS   The not present memory is set.
-**/
-EFI_STATUS
-SetNotPresentPage (
-  IN  UINTN Cr3,
-  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
-  IN  UINT64Length
-  );
-
 /**
   Initialize the shadow stack related data structure.
 
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
index 5b970157c6..968a15919f 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
@@ -676,28 +676,6 @@ SetShadowStack (
   return Status;
 }
 
-/**
-  Set not present memory.
-
-  @param[in]  Cr3  The page table base address.
-  @param[in]  BaseAddress  The physical address that is the start address 
of a memory region.
-  @param[in]  Length   The size in bytes of the memory region.
-
-  @retval EFI_SUCCESS   The not present memory is set.
-**/
-EFI_STATUS
-SetNotPresentPage (
-  IN  UINTN Cr3,
-  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
-  IN  UINT64Length
-  )
-{
-  EFI_STATUS  Status;
-
-  Status = SmmSetMemoryAttributesEx (Cr3, mPagingMode, BaseAddress, Length, 
EFI_MEMORY_RP);
-  return Status;
-}
-
 /**
   Retrieves a pointer to the system configuration table from the SMM System 
Table
   based on a specified GUID.
-- 
2.39.1.windows.1



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




[edk2-devel] [PATCH 6/7] UefiCpuPkg: Refinement to code about updating smm page table

2023-04-11 Thread duntan
This commit is code refinement to current smm runtime pagetable
update code. In InitPaging() function, sort mProtectionMemRange
or mSmmCpuSmramRanges at first. If PcdCpuSmmProfileEnable is TRUE,
use ConvertMemoryPageAttributes() API to map the range in
mProtectionMemRange to the attrbute recorded in the attribute field
of mProtectionMemRange, map the range outside mProtectionMemRange
as non-present. If PcdCpuSmmProfileEnable is FALSE, set the ranges
not in mSmmCpuSmramRanges as NX.

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h   |  38 
++
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf |   1 +
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c   | 343 
+++
 3 files changed, 158 insertions(+), 224 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index b72c883fc5..518bbf7853 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -51,6 +51,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -713,6 +714,43 @@ SmmBlockingStartupThisAp (
   IN OUT  VOID  *ProcArguments OPTIONAL
   );
 
+/**
+  This function modifies the page attributes for the memory region specified 
by BaseAddress and
+  Length from their current attributes to the attributes specified by 
Attributes.
+
+  Caller should make sure BaseAddress and Length is at page boundary.
+
+  @param[in]   PageTableBaseThe page table base.
+  @param[in]   BaseAddress  The physical address that is the start address 
of a memory region.
+  @param[in]   Length   The size in bytes of the memory region.
+  @param[in]   Attributes   The bit mask of attributes to modify for the 
memory region.
+  @param[in]   IsSetTRUE means to set attributes. FALSE means to 
clear attributes.
+  @param[out]  IsModified   TRUE means page table modified. FALSE means 
page table not modified.
+
+  @retval RETURN_SUCCESS   The attributes were modified for the memory 
region.
+  @retval RETURN_ACCESS_DENIED The attributes for the memory resource 
range specified by
+   BaseAddress and Length cannot be modified.
+  @retval RETURN_INVALID_PARAMETER Length is zero.
+   Attributes specified an illegal combination 
of attributes that
+   cannot be set together.
+  @retval RETURN_OUT_OF_RESOURCES  There are not enough system resources to 
modify the attributes of
+   the memory resource range.
+  @retval RETURN_UNSUPPORTED   The processor does not support one or more 
bytes of the memory
+   resource range specified by BaseAddress and 
Length.
+   The bit mask of attributes is not support 
for the memory resource
+   range specified by BaseAddress and Length.
+**/
+RETURN_STATUS
+ConvertMemoryPageAttributes (
+  IN  UINTN PageTableBase,
+  IN  PAGING_MODE   PagingMode,
+  IN  PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length,
+  IN  UINT64Attributes,
+  IN  BOOLEAN   IsSet,
+  OUT BOOLEAN   *IsModified   OPTIONAL
+  );
+
 /**
   This function sets the attributes for the memory region specified by 
BaseAddress and
   Length from their current attributes to the attributes specified by 
Attributes.
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
index 38d4e950a4..0971562bc3 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
@@ -98,6 +98,7 @@
   SmmCpuFeaturesLib
   PeCoffGetEntryPointLib
   CpuPageTableLib
+  SortLib
 
 [Protocols]
   gEfiSmmAccess2ProtocolGuid   ## CONSUMES
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
index 1b0b6673e1..4d79f8045f 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
@@ -546,259 +546,154 @@ InitProtectedMemRange (
 }
 
 /**
-  Update page table according to protected memory ranges and the 4KB-page 
mapped memory ranges.
+  Function to compare 2 MEMORY_PROTECTION_RANGE based on range base.
+
+  @param[in] Buffer1pointer to Device Path poiner to compare
+  @param[in] Buffer2pointer to second DevicePath pointer to compare
 
+  @retval 0   

[edk2-devel] [PATCH 5/7] UefiCpuPkg: Add SortLib required by PiSmmCpuDxe in DSC

2023-04-11 Thread duntan
Add SortLib required by PiSmmCpuDxe in UefiCpuPkg.dsc

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
---
 UefiCpuPkg/UefiCpuPkg.dsc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index d85d56916f..a00667d850 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  UefiCpuPkg Package
 #
-#  Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
+#  Copyright (c) 2007 - 2023, Intel Corporation. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -66,6 +66,7 @@
   UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.inf
   
UnitTestPersistenceLib|UnitTestFrameworkPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.inf
   
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.inf
+  SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
 
 [LibraryClasses.common.SEC]
   PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf
-- 
2.39.1.windows.1



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




[edk2-devel] [PATCH 4/7] UefiCpuPkg: Refinement to current smm page table generation code

2023-04-11 Thread duntan
This commit is code refinement to current smm pagetable generation
code. Add a new GenSmmPageTable() API to create page table for smm
based on the PageTableMap() API in CpuPageTableLib. Caller only
needs to specify the paging mode and the PhysicalAddressBits to map.
This function can be used to create both IA32 pae paging and X64
5level, 4level paging.

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c   |   2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c|   2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  | 130 
--
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h |  15 +--
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c |  65 
+
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c| 218 
+++---
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c |  19 ++-
 7 files changed, 101 insertions(+), 350 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
index 9c8107080a..b11264ce4a 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
@@ -63,7 +63,7 @@ SmmInitPageTable (
 InitializeIDTSmmStackGuard ();
   }
 
-  return Gen4GPageTable (TRUE);
+  return GenSmmPageTable (PagingPae, mPhysicalAddressBits);
 }
 
 /**
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c
index bba4a6f058..650090e534 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c
@@ -18,7 +18,7 @@ InitSmmS3Cr3 (
   VOID
   )
 {
-  mSmmS3ResumeState->SmmS3Cr3 = Gen4GPageTable (TRUE);
+  mSmmS3ResumeState->SmmS3Cr3 = GenSmmPageTable (PagingPae, 
mPhysicalAddressBits);
 
   return;
 }
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 1878252eac..f8b81fc96e 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -999,136 +999,6 @@ APHandler (
   ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run);
 }
 
-/**
-  Create 4G PageTable in SMRAM.
-
-  @param[in]  Is32BitPageTable Whether the page table is 32-bit PAE
-  @return PageTable Address
-
-**/
-UINT32
-Gen4GPageTable (
-  IN  BOOLEAN  Is32BitPageTable
-  )
-{
-  VOID*PageTable;
-  UINTN   Index;
-  UINT64  *Pte;
-  UINTN   PagesNeeded;
-  UINTN   Low2MBoundary;
-  UINTN   High2MBoundary;
-  UINTN   Pages;
-  UINTN   GuardPage;
-  UINT64  *Pdpte;
-  UINTN   PageIndex;
-  UINTN   PageAddress;
-
-  Low2MBoundary  = 0;
-  High2MBoundary = 0;
-  PagesNeeded= 0;
-  if (FeaturePcdGet (PcdCpuSmmStackGuard)) {
-//
-// Add one more page for known good stack, then find the lower 2MB aligned 
address.
-//
-Low2MBoundary = (mSmmStackArrayBase + EFI_PAGE_SIZE) & ~(SIZE_2MB-1);
-//
-// Add two more pages for known good stack and stack guard page,
-// then find the lower 2MB aligned address.
-//
-High2MBoundary = (mSmmStackArrayEnd - mSmmStackSize - mSmmShadowStackSize 
+ EFI_PAGE_SIZE * 2) & ~(SIZE_2MB-1);
-PagesNeeded= ((High2MBoundary - Low2MBoundary) / SIZE_2MB) + 1;
-  }
-
-  //
-  // Allocate the page table
-  //
-  PageTable = AllocatePageTableMemory (5 + PagesNeeded);
-  ASSERT (PageTable != NULL);
-
-  PageTable = (VOID *)((UINTN)PageTable);
-  Pte   = (UINT64 *)PageTable;
-
-  //
-  // Zero out all page table entries first
-  //
-  ZeroMem (Pte, EFI_PAGES_TO_SIZE (1));
-
-  //
-  // Set Page Directory Pointers
-  //
-  for (Index = 0; Index < 4; Index++) {
-Pte[Index] = ((UINTN)PageTable + EFI_PAGE_SIZE * (Index + 1)) | 
mAddressEncMask |
- (Is32BitPageTable ? IA32_PAE_PDPTE_ATTRIBUTE_BITS : 
PAGE_ATTRIBUTE_BITS);
-  }
-
-  Pte += EFI_PAGE_SIZE / sizeof (*Pte);
-
-  //
-  // Fill in Page Directory Entries
-  //
-  for (Index = 0; Index < EFI_PAGE_SIZE * 4 / sizeof (*Pte); Index++) {
-Pte[Index] = (Index << 21) | mAddressEncMask | IA32_PG_PS | 
PAGE_ATTRIBUTE_BITS;
-  }
-
-  Pdpte = (UINT64 *)PageTable;
-  if (FeaturePcdGet (PcdCpuSmmStackGuard)) {
-Pages = (UINTN)PageTable + EFI_PAGES_TO_SIZE (5);
-GuardPage = mSmmStackArrayBase + EFI_PAGE_SIZE;
-for (PageIndex = Low2MBoundary; PageIndex <= High2MBoundary; PageIndex += 
SIZE_2MB) {
-  Pte = (UINT64 
*)(UINTN)(Pdpte[BitFieldRead32 ((UINT32)PageIndex, 30, 31)] & ~mAddressEncMask 
& ~(EFI_PAGE_SIZE - 1));
-  Pte[BitFieldRead32 

[edk2-devel] [PATCH 3/7] UefiCpuPkg: Extern mSmmShadowStackSize in PiSmmCpuDxeSmm.h

2023-04-11 Thread duntan
Extern mSmmShadowStackSize in PiSmmCpuDxeSmm.h and remove
extern for mSmmShadowStackSize in c files to simplify code.

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c | 3 +--
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 2 --
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h| 1 +
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c   | 2 --
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c  | 3 +--
 5 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
index 6c48a53f67..636dc8d92f 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
@@ -1,7 +1,7 @@
 /** @file
   SMM CPU misc functions for Ia32 arch specific.
 
-Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -14,7 +14,6 @@ EFI_PHYSICAL_ADDRESS  mGdtBuffer;
 UINTN mGdtBufferSize;
 
 extern BOOLEAN  mCetSupported;
-extern UINTNmSmmShadowStackSize;
 
 X86_ASSEMBLY_PATCH_LABEL  mPatchCetPl0Ssp;
 X86_ASSEMBLY_PATCH_LABEL  mPatchCetInterruptSsp;
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index baf827cf9d..1878252eac 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -29,8 +29,6 @@ MM_COMPLETIONmSmmStartupThisApToken;
 //
 UINT32  *mPackageFirstThreadIndex = NULL;
 
-extern UINTN  mSmmShadowStackSize;
-
 /**
   Performs an atomic compare exchange operation to get semaphore.
   The compare exchange operation must be performed using
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index ba341cadc6..a155e09200 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -262,6 +262,7 @@ extern EFI_SMM_CPU_PROTOCOL  mSmmCpu;
 extern EFI_MM_MP_PROTOCOLmSmmMp;
 extern BOOLEAN   m5LevelPagingNeeded;
 extern PAGING_MODE   mPagingMode;
+extern UINTN mSmmShadowStackSize;
 
 ///
 /// The mode of the CPU at the time an SMI occurs
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
index a25a96f68c..25ced50955 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
@@ -13,8 +13,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define PAGE_TABLE_PAGES  8
 #define ACC_MAX_BIT   BIT3
 
-extern UINTN  mSmmShadowStackSize;
-
 LIST_ENTRYmPagePool   = INITIALIZE_LIST_HEAD_VARIABLE 
(mPagePool);
 BOOLEAN   m1GPageTableSupport = FALSE;
 BOOLEAN   mCpuSmmRestrictedMemoryAccess;
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
index 00a284c369..c4f21e2155 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
@@ -1,7 +1,7 @@
 /** @file
   SMM CPU misc functions for x64 arch specific.
 
-Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -12,7 +12,6 @@ EFI_PHYSICAL_ADDRESS  mGdtBuffer;
 UINTN mGdtBufferSize;
 
 extern BOOLEAN  mCetSupported;
-extern UINTNmSmmShadowStackSize;
 
 X86_ASSEMBLY_PATCH_LABEL  mPatchCetPl0Ssp;
 X86_ASSEMBLY_PATCH_LABEL  mPatchCetInterruptSsp;
-- 
2.39.1.windows.1



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




[edk2-devel] [PATCH 2/7] UefiCpuPkg/PiSmmCpuDxeSmm: Avoid setting non-present range to RO/NX

2023-04-11 Thread duntan
In PiSmmCpuDxeSmm code, SetMemMapAttributes() marks memory ranges
in SmmMemoryAttributesTable to RO/NX. There may exist non-present
range in these memory ranges. Set other attributes for a non-present
range is not permitted in CpuPageTableMapLib. So add code to handle
this case. Only map the present ranges in SmmMemoryAttributesTable
to RO or NX.

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 141 
+++--
 1 file changed, 119 insertions(+), 22 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
index deb5895d83..89040d386e 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
@@ -858,6 +858,89 @@ PatchGdtIdtMap (
 );
 }
 
+/**
+  This function remove the non-present range in [MemMapStart, MemMapLimit] and
+  set [MemMapStart, NonPresentRangeStart] as MemoryAttribute in page table.
+
+  @param  MemMapStartPointer to the start address of range.
+  @param  MemMapLimitLimit address of range.
+  @param  NonPresentRangeStart   Start address of non-present range.
+  @param  NonPresentRangeLimit   Limit address of non-present range.
+  @param  MemoryAttributeThe bit mask of attributes to modify for 
the memory region.
+
+**/
+VOID
+RemoveNonPresentRange (
+  UINT64  *MemMapStart,
+  UINT64  MemMapLimit,
+  UINT64  NonPresentRangeStart,
+  UINT64  NonPresentRangeLimit,
+  UINT64  MemoryAttribute
+  )
+{
+  if (*MemMapStart < NonPresentRangeStart) {
+SmmSetMemoryAttributes (
+  *MemMapStart,
+  NonPresentRangeStart - *MemMapStart,
+  MemoryAttribute
+  );
+  }
+
+  *MemMapStart = NonPresentRangeLimit;
+}
+
+/**
+  This function set [MemMapStart, MemMapLimit] to the input MemoryAttribute.
+
+  @param  MemMapStart Start address of range.
+  @param  MemMapLimit Limit address of range.
+  @param  Map Pointer to the array of Cr3 IA32_MAP_ENTRY.
+  @param  Count   Count of IA32_MAP_ENTRY in Map.
+  @param  MemoryAttribute The bit mask of attributes to modify for the 
memory region.
+
+**/
+VOID
+SetMemMapWithNonPresentRange (
+  UINT64  MemMapStart,
+  UINT64  MemMapLimit,
+  IA32_MAP_ENTRY  *Map,
+  UINTN   Count,
+  UINT64  MemoryAttribute
+  )
+{
+  UINTN   Index;
+  UINT64  NonPresentRangeStart;
+
+  NonPresentRangeStart = 0;
+
+  for (Index = 0; Index < Count; Index++) {
+if ((Map[Index].LinearAddress > NonPresentRangeStart) &&
+(MemMapStart < Map[Index].LinearAddress) && (MemMapLimit > 
NonPresentRangeStart))
+{
+  //
+  // [NonPresentRangeStart, Map[Index].LinearAddress] is non-present.
+  //
+  RemoveNonPresentRange (, MemMapLimit, NonPresentRangeStart, 
Map[Index].LinearAddress, MemoryAttribute);
+}
+
+NonPresentRangeStart = Map[Index].LinearAddress + Map[Index].Length;
+if (NonPresentRangeStart >= MemMapLimit) {
+  break;
+}
+  }
+
+  //
+  // There is no non-present in current [MemMapStart, MemMapLimit] anymore.
+  //
+  if (MemMapStart < MemMapLimit) {
+SmmSetMemoryAttributes (
+  MemMapStart,
+  MemMapLimit - MemMapStart,
+  MemoryAttribute
+  );
+  }
+}
+
 /**
   This function sets memory attribute according to MemoryAttributesTable.
 **/
@@ -872,6 +955,21 @@ SetMemMapAttributes (
   UINTN DescriptorSize;
   UINTN Index;
   EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE  *MemoryAttributesTable;
+  UINTN PageTable;
+  EFI_STATUSStatus;
+  IA32_MAP_ENTRY*Map;
+  UINTN Count;
+  UINT64MemoryAttribute;
+
+  Count = 0;
+  Map   = NULL;
+  PageTable = AsmReadCr3 ();
+  Status= PageTableParse (PageTable, mPagingMode, NULL, );
+  ASSERT (Status == RETURN_BUFFER_TOO_SMALL);
+  Map = AllocatePool (Count * sizeof (IA32_MAP_ENTRY));
+  ASSERT (Map != NULL);
+  Status = PageTableParse (PageTable, mPagingMode, Map, );
+  ASSERT_RETURN_ERROR (Status);
 
   SmmGetSystemConfigurationTable (, (VOID 
**));
   if (MemoryAttributesTable == NULL) {
@@ -901,33 +999,32 @@ SetMemMapAttributes (
   MemoryMap = MemoryMapStart;
   for (Index = 0; Index < MemoryMapEntryCount; Index++) {
 DEBUG ((DEBUG_VERBOSE, "SetAttribute: Memory Entry - 0x%lx, 0x%x\n", 
MemoryMap->PhysicalStart, MemoryMap->NumberOfPages));
-switch (MemoryMap->Type) {
-  case EfiRuntimeServicesCode:
-SmmSetMemoryAttributes (
-  MemoryMap->PhysicalStart,
-  EFI_PAGES_TO_SIZE ((UINTN)MemoryMap->NumberOfPages),
-  

[edk2-devel] [PATCH 1/7] UefiCpuPkg: Use CpuPageTableLib to convert SMM paging attribute.

2023-04-11 Thread duntan
Simplify the ConvertMemoryPageAttributes API to convert paging
attribute by CpuPageTableLib. In the new API, it calls
PageTableMap() to update the page attributes of a memory range.
With the PageTableMap() API in CpuPageTableLib, we can remove
the complicated page table manipulating code.

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c   |   3 ++-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h |  28 
+---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf   |   1 +
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 403 
+++
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c|   9 +++--
 5 files changed, 114 insertions(+), 330 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
index 34bf6e1a25..9c8107080a 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
@@ -1,7 +1,7 @@
 /** @file
 Page table manipulation functions for IA-32 processors
 
-Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
 Copyright (c) 2017, AMD Incorporated. All rights reserved.
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -31,6 +31,7 @@ SmmInitPageTable (
   InitializeSpinLock (mPFLock);
 
   mPhysicalAddressBits = 32;
+  mPagingMode  = PagingPae;
 
   if (FeaturePcdGet (PcdCpuSmmProfileEnable) ||
   HEAP_GUARD_NONSTOP_MODE ||
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index a5c2bdd971..ba341cadc6 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -50,6 +50,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -260,6 +261,7 @@ extern UINTN mNumberOfCpus;
 extern EFI_SMM_CPU_PROTOCOL  mSmmCpu;
 extern EFI_MM_MP_PROTOCOLmSmmMp;
 extern BOOLEAN   m5LevelPagingNeeded;
+extern PAGING_MODE   mPagingMode;
 
 ///
 /// The mode of the CPU at the time an SMI occurs
@@ -1008,11 +1010,10 @@ SetPageTableAttributes (
   Length from their current attributes to the attributes specified by 
Attributes.
 
   @param[in]   PageTableBaseThe page table base.
-  @param[in]   EnablePML5Paging If PML5 paging is enabled.
+  @param[in]   PagingMode   The paging mode.
   @param[in]   BaseAddress  The physical address that is the start address 
of a memory region.
   @param[in]   Length   The size in bytes of the memory region.
   @param[in]   Attributes   The bit mask of attributes to set for the 
memory region.
-  @param[out]  IsSplitted   TRUE means page table splitted. FALSE means 
page table not splitted.
 
   @retval EFI_SUCCESS   The attributes were set for the memory region.
   @retval EFI_ACCESS_DENIED The attributes for the memory resource range 
specified by
@@ -1030,12 +1031,11 @@ SetPageTableAttributes (
 **/
 EFI_STATUS
 SmmSetMemoryAttributesEx (
-  IN  UINTN PageTableBase,
-  IN  BOOLEAN   EnablePML5Paging,
-  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
-  IN  UINT64Length,
-  IN  UINT64Attributes,
-  OUT BOOLEAN   *IsSplitted  OPTIONAL
+  IN  UINTN PageTableBase,
+  IN  PAGING_MODE   PagingMode,
+  IN  PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINT64Length,
+  IN  UINT64Attributes
   );
 
 /**
@@ -1043,34 +1043,32 @@ SmmSetMemoryAttributesEx (
   Length from their current attributes to the attributes specified by 
Attributes.
 
   @param[in]   PageTableBaseThe page table base.
-  @param[in]   EnablePML5Paging If PML5 paging is enabled.
+  @param[in]   PagingMode   The paging mode.
   @param[in]   BaseAddress  The physical address that is the start address 
of a memory region.
   @param[in]   Length   The size in bytes of the memory region.
   @param[in]   Attributes   The bit mask of attributes to clear for the 
memory region.
-  @param[out]  IsSplitted   TRUE means page table splitted. FALSE means 
page table not splitted.
 
   @retval EFI_SUCCESS   The attributes were cleared for the memory 
region.
   @retval EFI_ACCESS_DENIED The attributes for the memory resource range 
specified by
 BaseAddress and Length cannot be modified.
   @retval EFI_INVALID_PARAMETER Length is zero.
   

[edk2-devel] [PATCH 0/7] Use CpuPageTableLib to create and update smm page table

2023-04-11 Thread duntan
This patch set is to use CpuPageTableLib to create and update smm page table.
With the CpuPageTableLib, we can create or update page table by calling
PageTableMap() in CpuPageTableLib multiple times. Then the original page table
manipulating code can be removed.

Dun Tan (7):
  UefiCpuPkg: Use CpuPageTableLib to convert SMM paging attribute.
  UefiCpuPkg/PiSmmCpuDxeSmm: Avoid setting non-present range to RO/NX
  UefiCpuPkg: Extern mSmmShadowStackSize in PiSmmCpuDxeSmm.h
  UefiCpuPkg: Refinement to current smm page table generation code
  UefiCpuPkg: Add SortLib required by PiSmmCpuDxe in DSC
  UefiCpuPkg: Refinement to code about updating smm page table
  UefiCpuPkg/PiSmmCpuDxeSmm: Remove unnecessary function

 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c   |   5 +++--
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c  |   3 +--
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c|   2 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  | 132 

 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c |   8 ++--
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h |  98 
+-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf   |   2 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 629 
++---
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 343 
+++
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c| 229 
++---
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c   |   3 +--
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c |  19 ++-
 UefiCpuPkg/UefiCpuPkg.dsc  |   3 ++-
 13 files changed, 502 insertions(+), 974 deletions(-)

-- 
2.39.1.windows.1



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