Re: [edk2-devel] [PATCH V1 1/1] UefiCpuPkg/ResetVector: Cache Disable should not be set by default in CR0

2024-01-09 Thread Min Xu
This patch causes a regression when launching a vm guest with below command:

$ /usr/libexec/qemu-kvm  \
-name guestVM1 -machine q35 -accel kvm -m 10240 -smp 8 -cpu host -monitor pty \
-drive format=raw,file=/home/tdvf/centos-stream-9.img  \
-bios /home/tdvf/OVMF.fd \
-nic user,hostfwd=tcp::-:22 -nographic \
-object iommufd,id=iommufd0 \
-device 
intel-iommu,caching-mode=on,dma-drain=on,x-scalable-mode="modern",x-pasid-mode=true,device-iotlb=on,iommufd=iommufd0
 \
-device 
vfio-pci,sysfsdev=/sys/bus/dsa/devices/vdev0.0,iommufd=iommufd0,bypass-iommu=false

Commit e8aa4c6546 (this patch has been merged) clear the CD bit in CR0 when 
transferring from real16 mode to 32bit protect mode. After the patch is 
applied,  it costs about 60s in DecompressMemFvs@SecMain.c. 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ni, Ray
> Sent: Thursday, August 3, 2023 4:14 PM
> To: devel@edk2.groups.io; Ni, Ray ; Xue, Shengfeng
> ; Dong, Eric ; Kumar,
> Rahul R ; kra...@redhat.com; De, Debkumar
> ; West, Catharine 
> Cc: Wu, MingliangX 
> Subject: Re: [edk2-devel] [PATCH V1 1/1] UefiCpuPkg/ResetVector: Cache
> Disable should not be set by default in CR0
> 
> The patch resolves an issue in Boot Guard enabled system that NEM is already
> enabled by Boot Guard, disabling cache evicts all cache content which is
> unexpected.
> 
> Reviewed-by: Ray Ni 
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Ni, Ray
> > Sent: Wednesday, July 26, 2023 5:56 PM
> > To: Xue, Shengfeng ;
> > devel@edk2.groups.io; Dong, Eric ; Kumar, Rahul R
> > ; kra...@redhat.com; De, Debkumar
> > ; West, Catharine 
> > Cc: Wu, MingliangX 
> > Subject: Re: [edk2-devel] [PATCH V1 1/1] UefiCpuPkg/ResetVector: Cache
> > Disable should not be set by default in CR0
> >
> > This patch is not right.
> >
> > Intel SDM explicitly says the initial CR0 value is 6000_0010. CD bit is set.
> >
> > So the ResetVector code that still sets CD bit should be good.
> >
> > If you are facing NEM enable failure, can you change your NEM enable
> > logic to explicitly clear CD bit instead of changing here?
> >
> > Thanks,
> > Ray
> >
> >
> > > -Original Message-
> > > From: xueshengfeng 
> > > Sent: Wednesday, July 26, 2023 5:48 PM
> > > To: devel@edk2.groups.io; Dong, Eric ; Ni, Ray
> > > ; Kumar, Rahul R ;
> > > kra...@redhat.com; De, Debkumar ; West,
> > > Catharine 
> > > Cc: Wu, MingliangX ; Wu
> > > Subject: [PATCH V1 1/1] UefiCpuPkg/ResetVector: Cache Disable should
> > > not be set by default in CR0
> > >
> > > From: "Wu, MingliangX" 
> > >
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4511
> > >
> > > With 64 bit build we are seeing the CD in control register CR 0 set.
> > > This causes the NEM to disabled for some specific bios profiles.
> > >
> > > Cc: Eric Dong 
> > > Cc: Ray Ni 
> > > Cc: Rahul Kumar 
> > > Cc: Gerd Hoffmann 
> > > Cc: Debkumar De 
> > > Cc: Catharine West 
> > > Signed-off-by: Wu, Mingliang 
> > > ---
> > >  UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> > > b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> > > index f59fc6ead4ba..4af2e875c31c 100644
> > > --- a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> > > +++ b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> > > @@ -7,7 +7,7 @@
> > >  ;
> > >
> > > ;---
> > > ---
> > >
> > > -%define SEC_DEFAULT_CR0  0x4023
> > > +%define SEC_DEFAULT_CR0  0x0023
> > >  %define SEC_DEFAULT_CR4  0x640
> > >
> > >  BITS16
> > > --
> > > 2.26.2.windows.1
> > >
> >
> >
> >
> >
> >
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings containing valid escape characters

2024-01-09 Thread Huang, Yanbo
@Gao, Liming @'Rebecca 
Cran'
Could you please help to merge this PR?
BaseTools: Fix raw strings containing valid escape characters by YuweiChen1110 
· Pull Request #5238 · tianocore/edk2 
(github.com)
Thanks in advance!

Best Regards,
Yanbo Huang

From: Chen, Christine 
Sent: Tuesday, January 9, 2024 4:15 PM
To: Gao, Liming ; devel@edk2.groups.io; 
joeyvage...@microsoft.com; Huang, Yanbo 
Cc: Feng, Bob C ; Kinney, Michael D 
; 'Rebecca Cran' 
Subject: RE: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings containing 
valid escape characters

Liming:
PR has been created: BaseTools: Fix raw strings containing valid escape 
characters by YuweiChen1110 · Pull Request #5238 · tianocore/edk2 
(github.com)
Thanks for reviewing.

Thanks,
Christine
From: gaoliming mailto:gaolim...@byosoft.com.cn>>
Sent: Tuesday, January 9, 2024 10:01 AM
To: devel@edk2.groups.io; 
joeyvage...@microsoft.com; Huang, Yanbo 
mailto:yanbo.hu...@intel.com>>
Cc: Chen, Christine mailto:yuwei.c...@intel.com>>; Feng, 
Bob C mailto:bob.c.f...@intel.com>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 'Rebecca Cran' 
mailto:rebe...@bsdio.com>>
Subject: 回复: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings containing 
valid escape characters

Joey and Yanbo:
 Thanks for your update. So, this one is new introduced issue. I agree to 
resolve it asap.

Christine:
 Can you create Pull Request to merge it?

Thanks
Liming
发件人: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> 代表 Joey Vagedes via 
groups.io
发送时间: 2024年1月8日 23:09
收件人: Huang, Yanbo mailto:yanbo.hu...@intel.com>>
抄送: Chen, Christine mailto:yuwei.c...@intel.com>>; Feng, 
Bob C mailto:bob.c.f...@intel.com>>; Gao, Liming 
mailto:gaolim...@byosoft.com.cn>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; Rebecca Cran 
mailto:rebe...@bsdio.com>>; 
devel@edk2.groups.io
主题: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings containing valid 
escape characters

Hi Liming,

It was introduced due to the fact that a few of the regex strings with invalid 
escape sequences (due to regex using their own escape sequences) also included 
valid escape sequences - for handling new lines. I did not see the valid escape 
characters in the strings, and the virtual platforms (Ovmf, etc) did not have 
the circumstances to catch this, so it slipped through the cracks.

Some platform DSCs do, and cause the break that the patch is resolving. I’ve 
already verified this fix resolves the issue on numerous platforms.

thanks,
Joey

On Mon, Jan 8, 2024 at 5:59 AM Huang, Yanbo 
mailto:yanbo.hu...@intel.com>> wrote:
Hi Liming,

This issue is introduced by this commit:
SHA-1: 9f0061a03b61d282fbc0ba5be22155d06a5e64a1

* BaseTools: Resolve regex syntax warnings

Switches regex patterns to raw text to resolve python 3.12 syntax
warnings in regards to invalid escape sequences, as is suggested by the
re (regex) module in python.

Best Regards,
Yanbo Huang

-Original Message-
From: gaoliming mailto:gaolim...@byosoft.com.cn>>
Sent: Monday, January 8, 2024 9:25 PM
To: devel@edk2.groups.io; Chen, Christine 
mailto:yuwei.c...@intel.com>>; 'Joey Vagedes' 
mailto:joey.vage...@gmail.com>>
Cc: 'Rebecca Cran' mailto:rebe...@bsdio.com>>; Feng, Bob C 
mailto:bob.c.f...@intel.com>>; Huang, Yanbo 
mailto:yanbo.hu...@intel.com>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Subject: 回复: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings containing 
valid escape characters

Christine:
  Is this a regression issue? Or does it resolve new usage? I am curious why it 
is not reported before.

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io 
> mailto:devel@edk2.groups.io>> 代表 Yuwei Chen
> 发送时间: 2024年1月8日 13:37
> 收件人: devel@edk2.groups.io; Chen, Christine 
> mailto:yuwei.c...@intel.com>>;
> Joey Vagedes mailto:joey.vage...@gmail.com>>
> 抄送: Rebecca Cran mailto:rebe...@bsdio.com>>; Gao, Liming
> mailto:gaolim...@byosoft.com.cn>>; Feng, Bob C 
> mailto:bob.c.f...@intel.com>>; Huang,
> Yanbo mailto:yanbo.hu...@intel.com>>; Kinney, Michael D
> mailto:michael.d.kin...@intel.com>>
> 主题: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings
containing
> valid escape characters
>
> Hi Liming and Cran,
>
> We should merge this fixing patch asap as it influences BaseTool's usage.
>
> Thanks,
> Christine
>
> > -Original Message-
> > From: devel@edk2.groups.io 
> > mailto:devel@edk2.groups.io>> On Behalf Of Yuwei
> > Chen
> > Sent: Monday, January 8, 2024 9:16 AM
> > To: Joey Vagedes mailto:joey.vage...@gmail.com>>; 
> > devel@edk2.groups.io
> > Cc: Rebecca Cran mailto:

回复: [edk2-devel] [PATCH 1/1] MdePkg: Update GetHealthStatus function description

2024-01-09 Thread gaoliming via groups.io
Reviewed-by: Liming Gao 

> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Junfeng Guan
> 发送时间: 2023年12月28日 15:54
> 收件人: devel@edk2.groups.io
> 抄送: Michael D Kinney ; Liming Gao
> ; Zhiguang Liu ; Yi Li
> 
> 主题: [edk2-devel] [PATCH 1/1] MdePkg: Update GetHealthStatus function
> description
> 
> Refer to Uefi spec 2.10 section 11.10.2, update the return value
> for EFI_DRIVER_HEALTH_PROTOCOL.GetHealthStatus.
> 
> Signed-off-by: Junfeng Guan 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Cc: Yi Li 
> ---
>  MdePkg/Include/Protocol/DriverHealth.h | 32 +++---
>  1 file changed, 8 insertions(+), 24 deletions(-)
> 
> diff --git a/MdePkg/Include/Protocol/DriverHealth.h
> b/MdePkg/Include/Protocol/DriverHealth.h
> index 9de025434ef3..9e1bd903f4be 100644
> --- a/MdePkg/Include/Protocol/DriverHealth.h
> +++ b/MdePkg/Include/Protocol/DriverHealth.h
> @@ -137,35 +137,19 @@ EFI_STATUS
>will only be returned with a
> HealthStatus value of
> 
> EfiDriverHealthStatusConfigurationRequired.
> 
> -  @retval EFI_SUCCESS   ControllerHandle is NULL, and all the
> controllers
> -managed by this driver specified by
> This have a health
> -status of
> EfiDriverHealthStatusHealthy with no warning
> -messages to be returned.  The
> ChildHandle, HealthStatus,
> -MessageList, and FormList
> parameters are ignored.
> -
> -  @retval EFI_DEVICE_ERROR  ControllerHandle is NULL, and one or
> more of the
> -controllers managed by this driver
> specified by This
> -do not have a health status of
> EfiDriverHealthStatusHealthy.
> -The ChildHandle, HealthStatus,
> MessageList, and
> -FormList parameters are ignored.
> -
> -  @retval EFI_DEVICE_ERROR  ControllerHandle is NULL, and one or
> more of the
> -controllers managed by this driver
> specified by This
> -have one or more warning and/or
> error messages.
> -The ChildHandle, HealthStatus,
> MessageList, and
> -FormList parameters are ignored.
> -
> -  @retval EFI_SUCCESS   ControllerHandle is not NULL and the
> health status
> -of the controller specified by
> ControllerHandle and
> -ChildHandle was returned in
> HealthStatus.  A list
> -of warning and error messages may
> be optionally
> -returned in MessageList, and a list of
> HII Forms
> -may be optionally returned in
> FormList.
> +  @retval EFI_SUCCESS   The health status of the controller
> specified by
> +ControllerHandle and ChildHandle
> was returned in HealthStatus.
> +A list of warning and error messages
> may be optionally
> +returned in MessageList, and an HII
> Form may be optionally
> +specified by FormHiiHandle.
> 
>@retval EFI_UNSUPPORTED   ControllerHandle is not NULL, and
> the controller
>  specified by ControllerHandle and
> ChildHandle is not
>  currently being managed by the
> driver specified by This.
> 
> +  @retval EFI_UNSUPPORTED   ControllerHandle is NULL and there
> are no devices being
> +managed by the driver.
> +
>@retval EFI_INVALID_PARAMETER HealthStatus is NULL.
> 
>@retval EFI_OUT_OF_RESOURCES  MessageList is not NULL, and there
> are not enough
> --
> 2.26.2.windows.1
> 
> 
> 
> 
> 





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




[edk2-devel] [PATCH] UefiCpuPkg/CpuMpPei: Don't write CR3 in ConvertMemoryPageToNotPresent

2024-01-09 Thread Zhiguang Liu
After ConvertMemoryPageToNotPresent, there is always a flush TLB
function. So, to improve performance, there is no need to write CR3
inside ConvertMemoryPageToNotPresent

Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Signed-off-by: Zhiguang Liu 
---
 UefiCpuPkg/CpuMpPei/CpuPaging.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index 15c7015fb8..c6894458f7 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -167,7 +167,6 @@ ConvertMemoryPageToNotPresent (
   }
 
   ASSERT_EFI_ERROR (Status);
-  AsmWriteCr3 (PageTable);
   return Status;
 }
 
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH] UefiCpuPkg: Fix issue that IsModified is wrongly set in PageTableMap

2024-01-09 Thread Zhiguang Liu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4614

Fix issue that IsModified is wrongly set in PageTableMap.

Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Crystal Lee 
Signed-off-by: Zhiguang Liu 
---
 UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c 
b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
index 36b2c4e6a3..164187f151 100644
--- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
+++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
@@ -567,7 +567,10 @@ PageTableLibMapInLevel (
 OriginalCurrentPagingEntry.Uint64 = CurrentPagingEntry->Uint64;
 PageTableLibSetPle (Level, CurrentPagingEntry, Offset, Attribute, 
&CurrentMask);
 
-if (OriginalCurrentPagingEntry.Uint64 != CurrentPagingEntry->Uint64) {
+if (Modify && (OriginalCurrentPagingEntry.Uint64 != 
CurrentPagingEntry->Uint64)) {
+  //
+  // The page table entry can be changed by this function only when 
Modify is true.
+  //
   *IsModified = TRUE;
 }
   }
@@ -609,7 +612,10 @@ PageTableLibMapInLevel (
   // Check if ParentPagingEntry entry is modified here is enough. Except the 
changes happen in leaf PagingEntry during
   // the while loop, if there is any other change happens in page table, the 
ParentPagingEntry must has been modified.
   //
-  if (OriginalParentPagingEntry.Uint64 != ParentPagingEntry->Uint64) {
+  if (Modify && (OriginalParentPagingEntry.Uint64 != 
ParentPagingEntry->Uint64)) {
+//
+// The page table entry can be changed by this function only when Modify 
is true.
+//
 *IsModified = TRUE;
   }
 
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH] [Patch V3]IntelFsp2Pkg\Tools\ConfigEditor:Added new USF config workstream.

2024-01-09 Thread Arun Sura
Config Editor utility addition/changes:
Support to enable config editor tool to have a new feature that can load
and view the configuration data of compiled VFR or HFR in form of YAML.
This can help users to understand and track the configuration data when
modifications are made.

Requires compiled vfr file as input in YAML format.

Running Configuration Editor:
python ConfigEditor.py

Cc: Chasel Chiu 
Cc: Duggapu Chinni B 
Cc: Nate DeSimone 
Cc: Ray Han Lim Ng 
Cc: Star Zeng 
Cc: Ted Kuo 
Cc: Ashraf Ali S 
Cc: Susovan Mohapatra 

Signed-off-by: Arun Sura 
---
 IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py  | 225 
++---
 IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py| 197 
+
 IntelFsp2Pkg/Tools/Tests/test_vfr_yaml.yml   | 233 
+
 IntelFsp2Pkg/Tools/UserManuals/ConfigEditorUserManual.md |   2 ++
 4 files changed, 602 insertions(+), 55 deletions(-)

diff --git a/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py 
b/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py
index 5271504282..6e67a3e073 100644
--- a/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py
+++ b/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py
@@ -1015,6 +1015,10 @@ class application(tkinter.Frame):
  "Unsupported file '%s' !" % path)
 return
 
+# VFR Format Page modification
+def page_construct(self):
+self.left.bind("<>", self.on_config_page_select_change)
+
 def search_bar(self):
 # get data from text box
 self.search_text = self.edit.get()
@@ -1165,7 +1169,8 @@ class application(tkinter.Frame):
 page_id = next(iter(page))
 # Put CFG items into related page list
 self.page_list[page_id] = self.cfg_data_obj.get_cfg_list(page_id)
-self.page_list[page_id].sort(key=lambda x: x['order'])
+if self.mode == 'fsp':
+self.page_list[page_id].sort(key=lambda x: x['order'])
 page_name = self.cfg_data_obj.get_page_title(page_id)
 child = self.left.insert(
 parent, 'end',
@@ -1199,17 +1204,22 @@ class application(tkinter.Frame):
 for item in self.get_current_config_data():
 disp_list.append(item)
 row = 0
-disp_list.sort(key=lambda x: x['order'])
-for item in disp_list:
-self.add_config_item(item, row)
-row += 2
-if self.invalid_values:
-string = 'The following contails invalid options/values \n\n'
-for i in self.invalid_values:
-string += i + ": " + str(self.invalid_values[i]) + "\n"
-reply = messagebox.showwarning('Warning!', string)
-if reply == 'ok':
-self.invalid_values.clear()
+if self.mode == 'fsp':
+disp_list.sort(key=lambda x: x['order'])
+for item in disp_list:
+self.add_config_item(item, row)
+row += 2
+if self.invalid_values:
+string = 'The following contails invalid options/values \n\n'
+for i in self.invalid_values:
+string += i + ": " + str(self.invalid_values[i]) + "\n"
+reply = messagebox.showwarning('Warning!', string)
+if reply == 'ok':
+self.invalid_values.clear()
+elif self.mode == 'vfr':
+for item in disp_list:
+self.add_vfr_config_item(item, row)
+row += 2
 
 fsp_version = ''
 
@@ -1219,16 +1229,19 @@ class application(tkinter.Frame):
 with open(file_name, "rb") as pkl_file:
 gen_cfg_data.__dict__ = marshal.load(pkl_file)
 gen_cfg_data.prepare_marshal(False)
-elif file_name.endswith('.yaml'):
+elif file_name.endswith('.yaml') or file_name.endswith('.yml'):
 if gen_cfg_data.load_yaml(file_name) != 0:
 raise Exception(gen_cfg_data.get_last_error())
 else:
 raise Exception('Unsupported file "%s" !' % file_name)
+
+self.mode = gen_cfg_data.yaml_type
 # checking fsp version
-if gen_cfg_data.detect_fsp():
-self.fsp_version = '2.X'
-else:
-self.fsp_version = '1.X'
+if gen_cfg_data.yaml_type == 'fsp':
+if gen_cfg_data.d

Re: [edk2-devel] [RFC PATCH v1 00/20] DynamicTablesPkg: Prepare to add RISC-V support

2024-01-09 Thread Sunil V L
Hi Jeshua,

On Tue, Jan 09, 2024 at 06:37:43PM +, Jeshua Smith wrote:
> > From: devel@edk2.groups.io  On Behalf Of Sunil V L
> > via groups.io
> > Sent: Tuesday, January 9, 2024 9:29 AM
> > DynamicTablesPkg can be used by RISC-V platforms to generate ACPI tables
> > from FDT passed from previous stage FW. However, DynamicTablesPkg
> > currently is ARM specific even though several parsers and ACPI generators 
> > can
> > be used across architectures. For ex: SSDT (PCIe), SSDT (CPU), MCFG, SPCR,
> > DBG2, FADT, SRAT, Raw (DSDT) are mostly common across architectures. Only
> > MADT, IORT and GTDT are ARM specific.
> > 
> > This series tries to refactor the DynamicTablesPkg so that RISC-V support 
> > can
> > be added fairly easily later.
> 
> It looks like instead of moving the common code to EObjNameSpaceStandard 
> namespace or a new (Arch? Common?) namespace, you're renaming the entire 
> EObjNameSpaceArm namespace to EObjNameSpaceArch. It seems to me that if ARM 
> code vs. common code is being separated out, then the EObjNameSpaceArm 
> namespace should continue to be used for the ARM-specific code and a common 
> namespace should be used for the common code.

I agree. I started with separating common things into new common space
and create one for risc-v. However, I dropped that approach for two
reasons.

1) The commit "b2bbe3df5470 DynamicTablesPkg: Remove PPTT ID structure
from ACPI 6.4 generator" when removed one of the enums from ArmObjectID,
didn't change the other values for other enums but reserved the removed
one. So, I thought there may be some assumptions which will break if the
enum value changes.

2) DynamicPlatformRepositoryInfo structure has ArmCmObjList and
ArmCmObjArray. With separate spaces for Arm, RiscV and Common, list
management needs some redesign and I was not sure it is worth it.

Hence, I thought a single list of all possible Obj Ids for all
architectures and common things would be a good trade off. But I can go
back to that approach in v2 if above issues are fine.

Thanks!
Sunil


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




Re: [edk2-devel] [PATCH v6 26/36] OvmfPkg/LoongArchVirt: Add a NULL library named CollectApResouceLibNull

2024-01-09 Thread Chao Li

Hi Bibo,


Thanks,
Chao
On 2024/1/10 09:24, maobibo wrote:



On 2024/1/5 下午5:45, Chao Li wrote:

This Library is used to collect APs resources, but is currently NULL
for OvmfPkg, because it is not used by the LoongArch virtual machine.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Bibo Mao 
Cc: Dongyan Qian 
Signed-off-by: Chao Li 
---
  .../CollectApResourceLibNull.c    | 38 +++
  .../CollectApResourceLibNull.inf  | 31 +++
  .../CollectApResourceLibNull.uni  |  9 +
  3 files changed, 78 insertions(+)
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.c
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.inf
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.uni


diff --git 
a/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.c 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.c 


new file mode 100644
index 00..19995c1193
--- /dev/null
+++ 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.c

@@ -0,0 +1,38 @@
+/** @file
+  LoongArch64 CPU Collect AP resource NULL Library functions.
+
+  Copyright (c) 2024, Loongson Technology Corporation Limited. All 
rights reserved.

+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "../../../UefiCpuPkg/Library/LoongArch64MpInitLib/MpLib.h"
The included path is a little strange, should we put 
CollectApResouceLibNull library in ovmf package or 
UefiCpuPkg/Library/LoongArch64MpInitLib package?
This library is a private because virtual-matchines collect AP resouces 
differently from physical machines, so I thought would be fine if it was 
located in OvmfPkg/LoongArchVirt/Library.


Regards
Bibo Mao


+
+VOID
+SaveProcessorResourceData (
+  IN PROCESSOR_RESOURCE_DATA *
+  );
+
+VOID
+EFIAPI
+SaveProcessorResource (
+  PROCESSOR_RESOURCE_DATA  *mProcessorResource
+  )
+{
+  SaveProcessorResourceData (mProcessorResource);
+}
+
+VOID
+EFIAPI
+CollectAllProcessorResource (
+  VOID
+  )
+{
+  return;
+}
diff --git 
a/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.inf 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.inf 


new file mode 100644
index 00..c166df6bbd
--- /dev/null
+++ 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.inf

@@ -0,0 +1,31 @@
+## @file
+#  LoongArch64 CPU Collect AP resource NULL Library.
+#
+#  Copyright (c) 2024, Loongson Technology Corporation Limited. All 
rights reserved.

+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION    = 1.29
+  BASE_NAME  = CollectApResourceLibNull
+  MODULE_UNI_FILE    = CollectApResourceLibNull.uni
+  FILE_GUID  = 8C3B54BF-6A9F-E8B4-4D57-67B3AB578DD6
+  MODULE_TYPE    = PEIM
+  VERSION_STRING = 1.1
+  LIBRARY_CLASS  = PEIM
+
+[Sources.common]
+  CollectApResourceLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  HobLib
+  MemoryAllocationLib
+
+[Pcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber
diff --git 
a/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.uni 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.uni 


new file mode 100644
index 00..d1638ab11e
--- /dev/null
+++ 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.uni

@@ -0,0 +1,9 @@
+// @file
+//  LoongArch64 CPU Collect AP resource NULL Library.
+//
+//  Copyright (c) 2024, Loongson Technology Corporation Limited. All 
rights reserved.

+//  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+#string STR_MODULE_ABSTRACT #language en-US "CPU Collect 
AP resource NULL Library."

+
+#string STR_MODULE_DESCRIPTION  #language en-US "CPU Collect 
AP resource NULL Library."











-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113510): https://edk2.groups.io/g/devel/message/113510
Mute This Topic: https://groups.io/mt/103540125/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] RedfishPkg/RedfishDebugLib: add function to print buffer.

2024-01-09 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Reviewed-by: Abner Chang 

> -Original Message-
> From: Nickle Wang 
> Sent: Tuesday, January 9, 2024 7:13 PM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; Igor Kulchytskyy
> ; Nick Ramirez 
> Subject: [PATCH v2] RedfishPkg/RedfishDebugLib: add function to print
> buffer.
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Introduce DumpBuffer function to print the buffer content. This helps
> developer to debug Redfish issue.
>
> Signed-off-by: Nickle Wang 
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> Cc: Nick Ramirez 
> ---
>  RedfishPkg/Include/Library/RedfishDebugLib.h  | 20 -
>  .../Library/RedfishDebugLib/RedfishDebugLib.c | 45 +--
>  2 files changed, 61 insertions(+), 4 deletions(-)
>
> diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h
> b/RedfishPkg/Include/Library/RedfishDebugLib.h
> index 5f75bad12a..3430cf1d14 100644
> --- a/RedfishPkg/Include/Library/RedfishDebugLib.h
> +++ b/RedfishPkg/Include/Library/RedfishDebugLib.h
> @@ -1,7 +1,7 @@
>  /** @file
>This file defines the Redfish debug library interface.
>
> -  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> +  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
>
>SPDX-License-Identifier: BSD-2-Clause-Patent
>
> @@ -138,4 +138,22 @@ DumpIpv4Address (
>IN EFI_IPv4_ADDRESS  *Ipv4Address
>);
>
> +/**
> +  Debug output raw data buffer.
> +
> +  @param[in]ErrorLevel  DEBUG macro error level
> +  @param[in]Buffer  Debug output data buffer.
> +  @param[in]BufferSize  The size of Buffer in byte.
> +
> +  @retval EFI_SUCCESS Debug dump finished.
> +  @retval EFI_INVALID_PARAMETER   Buffer is NULL.
> +
> +**/
> +EFI_STATUS
> +DumpBuffer (
> +  IN  UINTN  ErrorLevel,
> +  IN  UINT8  *Buffer,
> +  IN  UINTN  BufferSize
> +  );
> +
>  #endif
> diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> index efa9a5ca13..3728f51213 100644
> --- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
> @@ -1,7 +1,7 @@
>  /** @file
>Redfish debug library to debug Redfish application.
>
> -  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> +  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
>
>SPDX-License-Identifier: BSD-2-Clause-Patent
>
> @@ -19,8 +19,9 @@
>  #define IS_EMPTY_STRING(a)  ((a) == NULL || (a)[0] == '\0')
>  #endif
>
> -#define REDFISH_JSON_STRING_LENGTH  200
> -#define REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT |
> EDKII_JSON_INDENT(2))
> +#define REDFISH_JSON_STRING_LENGTH  200
> +#define REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT |
> EDKII_JSON_INDENT(2))
> +#define REDFISH_PRINT_BUFFER_BYTES_PER_ROW  16
>
>  /**
>Debug print the value of StatementValue.
> @@ -366,3 +367,41 @@ DumpIpv4Address (
>
>return EFI_SUCCESS;
>  }
> +
> +/**
> +  Debug output raw data buffer.
> +
> +  @param[in]ErrorLevel  DEBUG macro error level
> +  @param[in]Buffer  Debug output data buffer.
> +  @param[in]BufferSize  The size of Buffer in byte.
> +
> +  @retval EFI_SUCCESS Debug dump finished.
> +  @retval EFI_INVALID_PARAMETER   Buffer is NULL.
> +
> +**/
> +EFI_STATUS
> +DumpBuffer (
> +  IN  UINTN  ErrorLevel,
> +  IN  UINT8  *Buffer,
> +  IN  UINTN  BufferSize
> +  )
> +{
> +  UINTN  Index;
> +
> +  if (Buffer == NULL) {
> +return EFI_INVALID_PARAMETER;
> +  }
> +
> +  DEBUG ((ErrorLevel, "Address: 0x%p size: %d\n", Buffer, BufferSize));
> +  for (Index = 0; Index < BufferSize; Index++) {
> +if (Index % REDFISH_PRINT_BUFFER_BYTES_PER_ROW == 0) {
> +  DEBUG ((ErrorLevel, "\n%04X: ", Index));
> +}
> +
> +DEBUG ((ErrorLevel, "%02X ", Buffer[Index]));
> +  }
> +
> +  DEBUG ((ErrorLevel, "\n"));
> +
> +  return EFI_SUCCESS;
> +}
> --
> 2.34.1



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




Re: [edk2-devel] [PATCH] UefiPayloadPkg: Add macro to enable selection of timer

2024-01-09 Thread Benjamin Doron
Hi Nate,
Ah, that makes sense. Thanks!

Best regards,
Benjamin

On January 9, 2024 8:28:08 p.m. EST, "Desimone, Nathaniel L" 
 wrote:
>Hi Benjamin,
>
>We consider using the LAPIC as a timer to be technically superior because it 
>is closer to the CPU. The HPET is a PCH device, which means all access to the 
>timer needs go from CPU -> Home Agent -> Fabric/IO Ring -> DMI Controller -> 
>PCH. Using the LAPIC cuts this path to just the Home Agent. That reduces 
>access latency, which for a timer means higher resolution.
>
>Hope that helps,
>Nate
>
>From: devel@edk2.groups.io  on behalf of Benjamin Doron 
>
>Date: Tuesday, January 9, 2024 at 3:48 PM
>To: Ma <>, Ma, Hua , devel@edk2.groups.io 
>
>Subject: Re: [edk2-devel] [PATCH] UefiPayloadPkg: Add macro to enable 
>selection of timer
>Hi,
>Are there platforms that will use this? What advantages does using the LAPIC 
>as a timer offer? Thanks.
>
>Regards,
>Benjamin
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113508): https://edk2.groups.io/g/devel/message/113508
Mute This Topic: https://groups.io/mt/103538255/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/6] NetworkPkg/HttpDxe: Refactor TlsCreateChild

2024-01-09 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Thanks Saloni, I will create a PR and merge it.

Abner

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Saloni
> Kasbekar via groups.io
> Sent: Wednesday, January 10, 2024 7:26 AM
> To: devel@edk2.groups.io; Chang, Abner 
> Cc: Clark-williams, Zachary ; Michael
> Brown ; Nickle Wang ; Igor
> Kulchytskyy 
> Subject: Re: [edk2-devel] [PATCH V2 1/6] NetworkPkg/HttpDxe: Refactor
> TlsCreateChild
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Reviewed-by: Saloni Kasbekar 
>
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chang,
> Abner via groups.io
> Sent: Sunday, January 7, 2024 5:27 AM
> To: devel@edk2.groups.io
> Cc: Kasbekar, Saloni ; Clark-williams, Zachary
> ; Michael Brown ;
> Nickle Wang ; Igor Kulchytskyy 
> Subject: [edk2-devel] [PATCH V2 1/6] NetworkPkg/HttpDxe: Refactor
> TlsCreateChild
>
> From: Abner Chang 
>
> - Use HTTP instance as the parameter for TlsCreateChild function.
> - Install TLS protocol on the HTTP instance thats create TLS child.
>
> Signed-off-by: Abner Chang 
> Cc: Saloni Kasbekar 
> Cc: Zachary Clark-williams 
> Cc: Michael Brown 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> Reviewed-by: Michael Brown 
> ---
>  NetworkPkg/HttpDxe/HttpProto.h|  3 +-
>  NetworkPkg/HttpDxe/HttpsSupport.h | 18 ---
>  NetworkPkg/HttpDxe/HttpImpl.c | 23 ++---
>  NetworkPkg/HttpDxe/HttpProto.c|  7 +--
>  NetworkPkg/HttpDxe/HttpsSupport.c | 78 ++
> -
>  5 files changed, 64 insertions(+), 65 deletions(-)
>
> diff --git a/NetworkPkg/HttpDxe/HttpProto.h
> b/NetworkPkg/HttpDxe/HttpProto.h index 012f1f4b467..7e77b389a78
> 100644
> --- a/NetworkPkg/HttpDxe/HttpProto.h
> +++ b/NetworkPkg/HttpDxe/HttpProto.h
> @@ -3,6 +3,7 @@
>
>  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
>  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
> +Copyright (C) 2024 Advanced Micro Devices, Inc. All rights
> +reserved.
>  SPDX-License-Identifier: BSD-2-Clause-Patent
>
>  **/
> @@ -171,7 +172,7 @@ typedef struct _HTTP_PROTOCOL {
>BOOLEAN   UseHttps;
>
>EFI_SERVICE_BINDING_PROTOCOL  *TlsSb;
> -  EFI_HANDLETlsChildHandle; /// Tls ChildHandle
> +  BOOLEAN   TlsAlreadyCreated;
>TLS_CONFIG_DATA   TlsConfigData;
>EFI_TLS_PROTOCOL  *Tls;
>EFI_TLS_CONFIGURATION_PROTOCOL*TlsConfiguration;
> diff --git a/NetworkPkg/HttpDxe/HttpsSupport.h
> b/NetworkPkg/HttpDxe/HttpsSupport.h
> index 3c70825e8c3..5b44c7ac395 100644
> --- a/NetworkPkg/HttpDxe/HttpsSupport.h
> +++ b/NetworkPkg/HttpDxe/HttpsSupport.h
> @@ -2,6 +2,7 @@
>The header files of miscellaneous routines specific to Https for HttpDxe
> driver.
>
>  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
> +Copyright (C) 2024 Advanced Micro Devices, Inc. All rights
> +reserved.
>  SPDX-License-Identifier: BSD-2-Clause-Patent
>
>  **/
> @@ -30,21 +31,18 @@ IsHttpsUrl (
>  /**
>Creates a Tls child handle, open EFI_TLS_PROTOCOL and
> EFI_TLS_CONFIGURATION_PROTOCOL.
>
> -  @param[in]  ImageHandle   The firmware allocated handle for the 
> UEFI
> image.
> -  @param[out] TlsSb Pointer to the TLS
> SERVICE_BINDING_PROTOCOL.
> -  @param[out] TlsProto  Pointer to the EFI_TLS_PROTOCOL instance.
> -  @param[out] TlsConfiguration  Pointer to the
> EFI_TLS_CONFIGURATION_PROTOCOL instance.
> +  @param[in]  HttpInstance  Pointer to HTTP_PROTOCOL structure.
>
> -  @return  The child handle with opened EFI_TLS_PROTOCOL and
> EFI_TLS_CONFIGURATION_PROTOCOL.
> +  @return  EFI_SUCCESSTLS child handle is returned in HttpInstance-
> >TlsChildHandle
> +  with opened EFI_TLS_PROTOCOL and
> EFI_TLS_CONFIGURATION_PROTOCOL.
> +   EFI_DEVICE_ERROR   TLS service binding protocol is not found.
> +   Otherwise  Fail to create TLS chile handle.
>
>  **/
> -EFI_HANDLE
> +EFI_STATUS
>  EFIAPI
>  TlsCreateChild (
> -  IN  EFI_HANDLE  ImageHandle,
> -  OUT EFI_SERVICE_BINDING_PROTOCOL**TlsSb,
> -  OUT EFI_TLS_PROTOCOL**TlsProto,
> -  OUT EFI_TLS_CONFIGURATION_PROTOCOL  **TlsConfiguration
> +  IN  HTTP_PROTOCOL  *HttpInstance
>);
>
>  /**
> diff --git a/NetworkPkg/HttpDxe/HttpImpl.c
> b/NetworkPkg/HttpDxe/HttpImpl.c index 7c5c925cf78..6606c293421
> 100644
> --- a/NetworkPkg/HttpDxe/HttpImpl.c
> +++ b/NetworkPkg/HttpDxe/HttpImpl.c
> @@ -3,6 +3,7 @@
>
>Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
>(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
> +  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights
> + reserved.
>
>SPDX-License-Identifier: BSD-2-Clause-Patent
>
> @@ -248,7 +249,6 @@ EfiHttpRequest (
>HTTP_TOKEN_WRAP

Re: [edk2-devel] [PATCH v6 36/36] OvmfPkg/LoongArchVirt: Add self introduction file

2024-01-09 Thread maobibo




On 2024/1/5 下午5:46, Chao Li wrote:

Add self introduction file for LoongArch virtual machine.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Bibo Mao 
Cc: Dongyan Qian 
Signed-off-by: Chao Li 
---
  OvmfPkg/LoongArchVirt/Readme.md | 67 +
  1 file changed, 67 insertions(+)
  create mode 100644 OvmfPkg/LoongArchVirt/Readme.md

diff --git a/OvmfPkg/LoongArchVirt/Readme.md b/OvmfPkg/LoongArchVirt/Readme.md
new file mode 100644
index 00..57fc74c296
--- /dev/null
+++ b/OvmfPkg/LoongArchVirt/Readme.md
@@ -0,0 +1,67 @@
+# LoongArch QEMU virt platform
+
+## Overview
+
+  LoongArch QEMU virt is a generic platform that dose not require any actual 
hardware.
+  The minimum required QEMU version is 
[8.1](https://gitlab.com/qemu-project/qemu/-/tags), the minimum required GCC 
version is [GCC13](https://gcc.gnu.org/gcc-13/), the minimum required Binutils 
version is [2.40](https://ftp.gnu.org/gnu/binutils/).
+
+## Prepare (X86 Linux Environment)
+
+### Fedora39
+Install LoongArch64 cross compiler, LoongArch system QEMU.
+
+yum install gcc-loongarch64-linux-gnu
+yum install qemu-system-loongarch64
+
+### Others X86 OS ENV
+ Configure cross-tools
+
+**Download:**
+
+wget 
https://github.com/loongson/build-tools/releases/download/2023.08.08/x86_64-cross-tools-loongarch64-binutils_2.41-gcc_13.2.0.tar.xz
+
+**Configure the cross-tools environment:**
+
+mkdir /opt/loongarch64_cross-toolchain/
+tar -vxf x86_64-cross-tools-loongarch64-binutils_2.41-gcc_13.2.0.tar.xz -C 
/opt/loongarch64_cross-toolchain/
+export PATH=/opt/loongarch64_cross-toolchain/cross-tools/bin:$PATH
+
+Note: Please obtain [the latest 
cross-compilation](https://github.com/loongson/build-tools) toolchains.
+
+ Build QEMU
+
+git clone https://gitlab.com/qemu-project/qemu.git
+
+Note: Please refer to QEMU compilation rules, located in 
qemu/doc/system/loongarch/virt.rst.
+
+
+## Build LoongArch QEMU virtual machine firmware
+ Get edk2 resouces
+
+git clone --recurse-submodule https://github.com/tianocore/edk2.git
+
+ Building LoongArch QEMU virt FW with GCC
+
+export WORKSPACE=`pwd`
+export GCC5_LOONGARCH64_PREFIX=loongarch64-unknown-linux-gnu-
+export PACKAGES_PATH=$WORKSPACE/edk2
+export EDK_TOOLS_PATH=$WORKSPACE/edk2/BaseTools
+source edk2/edksetup.sh --reconfig
+make -C edk2/BaseTools
+source edk2/edksetup.sh BaseTools
+build -b RELEASE -t GCC5 -a LOONGARCH64 -p 
OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc
+
+## Test LoongArch QEMU virtual machine firmware
+qemu-system-loongarch64 \
+-m 4G \
+-M virt \
+-smp 2 \
+-cpu la464 \
+-bios Build/LoongArchVirtQemu/RELEASE_GCC5/FV/QEMU_EFI.fd \
+-serial stdio
+
+## Test LoongArch QEMU virtual machine OS
+
+* Download ArchLinux QCOW 
[images](https://mirrors.pku.edu.cn/loongarch/archlinux/images) for LoongArch.
+
+* [Running LoongArch ArchLinux on virtual 
machine](https://mirrors.pku.edu.cn/loongarch/archlinux/images/README.html).


Reviewed-by: Bibo Mao 



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




Re: [edk2-devel] [PATCH v6 35/36] OvmfPkg/LoongArchVirt: Add build file

2024-01-09 Thread maobibo




On 2024/1/5 下午5:46, Chao Li wrote:

Add infrastructure files to build edk2 for LoongArch QEMU virtual
machine.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Bibo Mao 
Cc: Dongyan Qian 
Signed-off-by: Chao Li 
Co-authored-by: Xianglai Li 
Co-authored-by: Bibo Mao 
---
  OvmfPkg/LoongArchVirt/LoongArchVirt.fdf.inc |  34 +
  OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc | 679 
  OvmfPkg/LoongArchVirt/LoongArchVirtQemu.fdf | 313 +
  OvmfPkg/LoongArchVirt/VarStore.fdf.inc  |  67 ++
  4 files changed, 1093 insertions(+)
  create mode 100644 OvmfPkg/LoongArchVirt/LoongArchVirt.fdf.inc
  create mode 100644 OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc
  create mode 100644 OvmfPkg/LoongArchVirt/LoongArchVirtQemu.fdf
  create mode 100644 OvmfPkg/LoongArchVirt/VarStore.fdf.inc

diff --git a/OvmfPkg/LoongArchVirt/LoongArchVirt.fdf.inc 
b/OvmfPkg/LoongArchVirt/LoongArchVirt.fdf.inc
new file mode 100644
index 00..22373bec6a
--- /dev/null
+++ b/OvmfPkg/LoongArchVirt/LoongArchVirt.fdf.inc
@@ -0,0 +1,34 @@
+## @file
+#
+#  Copyright (c) 2024 Loongson Technology Corporation Limited. All rights 
reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+DEFINE BLOCK_SIZE = 0x1000
+
+
+# FW total
+DEFINE FW_BASE_ADDRESS= 0x1c00
+DEFINE FW_BLOCKS  = 0x400
+DEFINE FW_SIZE= 0x40
+
+
+#Flash code layout
+#Set Sec size in flash
+DEFINE SECFV_SIZE = 0x0001
+
+#Set Pei size in flash
+DEFINE PEIFV_SIZE = 0x0004
+
+#Set Dxe size in flash
+DEFINE DXEFV_SIZE = 0x0035
+
+#Set FVMAIN size
+DEFINE FVMAIN_SIZE= $(SECFV_SIZE) + $(PEIFV_SIZE) 
+$(DXEFV_SIZE)
+
+#Set Memory layout
+DEFINE SEC_PEI_TEMP_RAM_BASE  = 0x1
+DEFINE SEC_PEI_TEMP_RAM_SIZE  = 0x8
+DEFINE DEVICE_TREE_RAM_BASE   = 0x10
diff --git a/OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc 
b/OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc
new file mode 100644
index 00..0a6b5f830b
--- /dev/null
+++ b/OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc
@@ -0,0 +1,679 @@
+## @file
+#
+#  Copyright (c) 2024 Loongson Technology Corporation Limited. All rights 
reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+###
+[Defines]
+  PLATFORM_NAME  = LoongArchVirtQemu
+  PLATFORMPKG_NAME   = LoongArchVirtQemu
+  PLATFORM_GUID  = 7926ea52-b0dc-4ee8-ac63-341eebd84ed4
+  PLATFORM_VERSION   = 0.1
+  DSC_SPECIFICATION  = 0x00010005
+  OUTPUT_DIRECTORY   = Build/$(PLATFORM_NAME)
+  SUPPORTED_ARCHITECTURES= LOONGARCH64
+  BUILD_TARGETS  = DEBUG|RELEASE
+  SKUID_IDENTIFIER   = DEFAULT
+  FLASH_DEFINITION   = OvmfPkg/LoongArchVirt/LoongArchVirtQemu.fdf
+  TTY_TERMINAL   = FALSE
+
+!include LoongArchVirt.fdf.inc
+
+  #
+  # Defines for default states.  These can be changed on the command line.
+  # -D FLAG=VALUE
+  DEFINE TTY_TERMINAL= FALSE
+  DEFINE SECURE_BOOT_ENABLE  = FALSE
+  DEFINE TPM2_ENABLE = FALSE
+  DEFINE TPM2_CONFIG_ENABLE  = FALSE
+
+  #
+  # Network definition
+  #
+  DEFINE NETWORK_IP6_ENABLE  = FALSE
+  DEFINE NETWORK_HTTP_BOOT_ENABLE= FALSE
+  DEFINE NETWORK_SNP_ENABLE  = FALSE
+  DEFINE NETWORK_TLS_ENABLE  = FALSE
+  DEFINE NETWORK_ALLOW_HTTP_CONNECTIONS  = TRUE
+  DEFINE NETWORK_ISCSI_ENABLE= FALSE
+
+!include NetworkPkg/NetworkDefines.dsc.inc
+
+#
+# Defines for default states.  These can be changed on the command line.
+# -D FLAG=VALUE
+
+[BuildOptions]
+  GCC:RELEASE_*_*_CC_FLAGS   = -DSPEEDUP
+
+  #
+  # Disable deprecated APIs.
+  #
+  GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+
+!include NetworkPkg/NetworkBuildOptions.dsc.inc
+
+[BuildOptions.LOONGARCH64.EDKII.SEC]
+  *_*_*_CC_FLAGS =
+
+#
+# Default page size is 16K for loongarch qemu tcg
+# code section separated with data section with 16K page alignment, else data
+# write operation in the same page with code section will cause qemu TB flush.
+#
+[BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION]
+  GC

Re: [edk2-devel] [PATCH] UefiPayloadPkg: Add macro to enable selection of timer

2024-01-09 Thread Nate DeSimone
Hi Benjamin,

We consider using the LAPIC as a timer to be technically superior because it is 
closer to the CPU. The HPET is a PCH device, which means all access to the 
timer needs go from CPU -> Home Agent -> Fabric/IO Ring -> DMI Controller -> 
PCH. Using the LAPIC cuts this path to just the Home Agent. That reduces access 
latency, which for a timer means higher resolution.

Hope that helps,
Nate

From: devel@edk2.groups.io  on behalf of Benjamin Doron 

Date: Tuesday, January 9, 2024 at 3:48 PM
To: Ma <>, Ma, Hua , devel@edk2.groups.io 

Subject: Re: [edk2-devel] [PATCH] UefiPayloadPkg: Add macro to enable selection 
of timer
Hi,
Are there platforms that will use this? What advantages does using the LAPIC as 
a timer offer? Thanks.

Regards,
Benjamin



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




Re: [edk2-devel] [PATCH] UefiPayloadPkg: Add macro to enable selection of timer

2024-01-09 Thread Nate DeSimone
Hi Hua,

Please make TIMER_SUPPORT a FixedAtBuiildPcd instead of a build flag. Something 
like PcdDxeTimerSelection or similar.

Thanks,
Nate

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ma, Hua
> Sent: Thursday, January 4, 2024 9:39 PM
> To: devel@edk2.groups.io
> Cc: Ma, Hua 
> Subject: [edk2-devel] [PATCH] UefiPayloadPkg: Add macro to enable selection
> of timer
> 
> Add macro to enable selection of timer
> 
> - HPET:  UEFI Payload will use HPET timer
> - LAPIC: UEFI Payload will use local APIC timer
> 
> Signed-off-by: Hua Ma 
> ---
>  UefiPayloadPkg/UefiPayloadPkg.dsc | 16 
> UefiPayloadPkg/UefiPayloadPkg.fdf |  4 
>  2 files changed, 20 insertions(+)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index b8b13ad201..4f195c1e52 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -139,6 +139,12 @@
># Note: for emulation platform such as QEMU, this may not work and should
> set it as FALSE
>DEFINE CPU_TIMER_LIB_ENABLE  = TRUE
> 
> +  #
> +  # HPET:  UEFI Payload will use HPET timer  # LAPIC: UEFI Payload will
> + use local APIC timer  #
> +  DEFINE TIMER_SUPPORT  = HPET
> +
>DEFINE MULTIPLE_DEBUG_PORT_SUPPORT = FALSE
> 
>  [BuildOptions]
> @@ -676,7 +682,17 @@
> 
> MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuAp
> p.inf
> 
> 
> +!if $(TIMER_SUPPORT) == "HPET"
>PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
> +!elseif $(TIMER_SUPPORT) == "LAPIC"
> +  OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf {
> +
> +
> +NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInter
> +ruptTplLib.inf
> +  }
> +!else
> +  !error "Invalid TIMER_SUPPORT"
> +!endif
> +
>MdeModulePkg/Universal/Metronome/Metronome.inf
>MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
>MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf
> b/UefiPayloadPkg/UefiPayloadPkg.fdf
> index 835798be1c..7d04a8cffd 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.fdf
> +++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
> @@ -161,7 +161,11 @@ INF
> MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
>  !endif
>  INF UefiCpuPkg/CpuDxe/CpuDxe.inf
> 
> +!if $(TIMER_SUPPORT) == "HPET"
>  INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
> +!elseif $(TIMER_SUPPORT) == "LAPIC"
> +INF OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf
> +!endif
>  INF MdeModulePkg/Universal/Metronome/Metronome.inf
>  INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
>  INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
> --
> 2.39.1.windows.1
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH v6 31/36] OvmfPkg/LoongArchVirt: Add FdtQemuFwCfgLib

2024-01-09 Thread maobibo




On 2024/1/5 下午5:46, Chao Li wrote:

This library for PEI phase, and obtains the QemuFwCfg base address by
directly parsing the FDT, reads and writes the data in QemuFwCfg by
operating on the QemuFwCfg base address.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Bibo Mao 
Cc: Dongyan Qian 
Signed-off-by: Chao Li 
Co-authored-by: Xianglai Li 
Co-authored-by: Bibo Mao 
---
  .../FdtQemuFwCfgLib/FdtQemuFwCfgPeiLib.c  | 504 ++
  .../FdtQemuFwCfgLib/FdtQemuFwCfgPeiLib.inf|  42 ++
  .../FdtQemuFwCfgLib/QemuFwCfgLibInternal.h|  73 +++
  .../Library/FdtQemuFwCfgLib/QemuFwCfgPei.c| 117 
  4 files changed, 736 insertions(+)
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/FdtQemuFwCfgLib/FdtQemuFwCfgPeiLib.c
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/FdtQemuFwCfgLib/FdtQemuFwCfgPeiLib.inf
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/FdtQemuFwCfgLib/QemuFwCfgLibInternal.h
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/FdtQemuFwCfgLib/QemuFwCfgPei.c

diff --git a/OvmfPkg/LoongArchVirt/Library/FdtQemuFwCfgLib/FdtQemuFwCfgPeiLib.c 
b/OvmfPkg/LoongArchVirt/Library/FdtQemuFwCfgLib/FdtQemuFwCfgPeiLib.c
new file mode 100644
index 00..a1f114b327
--- /dev/null
+++ b/OvmfPkg/LoongArchVirt/Library/FdtQemuFwCfgLib/FdtQemuFwCfgPeiLib.c
@@ -0,0 +1,504 @@
+/** @file
+
+  Copyright (c) 2024 Loongson Technology Corporation Limited. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Glossary:
+- FwCfg   - firmWare  Configure
+- CTL   - Control
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "QemuFwCfgLibInternal.h"
+
+EFI_GUID  mFwCfgSelectorAddressGuid = FW_CONFIG_SELECTOR_ADDRESS_HOB_GUID;
+EFI_GUID  mFwCfgDataAddressGuid = FW_CONFIG_DATA_ADDRESS_HOB_GUID;
+
+STATIC UINTN  mFwCfgSelectorAddress;
+STATIC UINTN  mFwCfgDataAddress;
+
+/**
+  To get firmware configure selector address.
+
+  @param VOID
+
+  @retval  firmware configure selector address
+**/
+UINTN
+EFIAPI
+QemuGetFwCfgSelectorAddress (
+  VOID
+  )
+{
+  UINTN  FwCfgSelectorAddress;
+  EFI_HOB_GUID_TYPE  *GuidHob;
+  VOID   *DataInHob;
+
+  FwCfgSelectorAddress = mFwCfgSelectorAddress;
+  GuidHob  = NULL;
+  DataInHob= NULL;
+
+  if (FwCfgSelectorAddress == 0) {
+GuidHob  = GetFirstGuidHob (&mFwCfgSelectorAddressGuid);
+DataInHob= GET_GUID_HOB_DATA (GuidHob);
+FwCfgSelectorAddress = (UINT64)(*(UINTN *)DataInHob);
+  }
+
+  return FwCfgSelectorAddress;
+}
+
+/**
+  To get firmware configure Data address.
+
+  @param VOID
+
+  @retval  firmware configure data address
+**/
+UINTN
+EFIAPI
+QemuGetFwCfgDataAddress (
+  VOID
+  )
+{
+  UINTN  FwCfgDataAddress;
+  EFI_HOB_GUID_TYPE  *GuidHob;
+  VOID   *DataInHob;
+
+  FwCfgDataAddress = mFwCfgDataAddress;
+  GuidHob  = NULL;
+  DataInHob= NULL;
+
+  if (FwCfgDataAddress == 0) {
+GuidHob  = GetFirstGuidHob (&mFwCfgDataAddressGuid);
+DataInHob= GET_GUID_HOB_DATA (GuidHob);
+FwCfgDataAddress = (UINT64)(*(UINTN *)DataInHob);
+  }
+
+  return FwCfgDataAddress;
+}
+
+/**
+  Selects a firmware configuration item for reading.
+
+  Following this call, any data read from this item will start from
+  the beginning of the configuration item's data.
+
+  @param[in] QemuFwCfgItem - Firmware Configuration item to read
+**/
+VOID
+EFIAPI
+QemuFwCfgSelectItem (
+  IN FIRMWARE_CONFIG_ITEM  QemuFwCfgItem
+  )
+{
+  UINTN  FwCfgSelectorAddress;
+
+  FwCfgSelectorAddress = QemuGetFwCfgSelectorAddress ();
+  MmioWrite16 (FwCfgSelectorAddress, SwapBytes16 
((UINT16)(UINTN)QemuFwCfgItem));
+}
+
+/**
+  Slow READ_BYTES_FUNCTION.
+
+  @param[in]  The size of the data to be read.
+  @param[in]  BufferThe buffer that stores the readout data.
+**/
+VOID
+EFIAPI
+MmioReadBytes (
+  IN UINTN  Size,
+  IN VOID   *Buffer OPTIONAL
+  )
+{
+  UINTN  Left;
+  UINT8  *Ptr;
+  UINT8  *End;
+  UINTN  FwCfgDataAddress;
+
+  Left = Size & 7;
+
+  Size -= Left;
+  Ptr   = Buffer;
+  End   = Ptr + Size;
+
+  FwCfgDataAddress = QemuGetFwCfgDataAddress ();
+  while (Ptr < End) {
+*(UINT64 *)Ptr = MmioRead64 (FwCfgDataAddress);
+Ptr   += 8;
+  }
+
+  if (Left & 4) {
+*(UINT32 *)Ptr = MmioRead32 (FwCfgDataAddress);
+Ptr   += 4;
+  }
+
+  if (Left & 2) {
+*(UINT16 *)Ptr = MmioRead16 (FwCfgDataAddress);
+Ptr   += 2;
+  }
+
+  if (Left & 1) {
+*Ptr = MmioRead8 (FwCfgDataAddress);
+  }
+}
+
+/**
+  Slow WRITE_BYTES_FUNCTION.
+
+  @param[in]  The size of the data to be write.
+  @param[in]  BufferThe buffer that stores the writein data.
+**/
+VOID
+EFIAPI
+MmioWriteBytes (
+  IN UINTN  Size,
+  IN VOID   *Buffer OPTIONAL
+  )
+{
+  UINTN  Idx;
+  UINTN  FwCfgDataAddress;

Re: [edk2-devel] [PATCH v6 30/36] OvmfPkg/LoongArchVirt: Add NorFlashQemuLib

2024-01-09 Thread maobibo




On 2024/1/5 下午5:46, Chao Li wrote:

Add NorFlashQemuLib for LoongArch, it is referenced from ArmVirtPkg.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Bibo Mao 
Cc: Dongyan Qian 
Signed-off-by: Chao Li 
Co-authored-by: Xianglai Li 
Co-authored-by: Bibo Mao 
---
  .../Library/NorFlashQemuLib/NorFlashQemuLib.c | 140 ++
  .../NorFlashQemuLib/NorFlashQemuLib.inf   |  43 ++
  2 files changed, 183 insertions(+)
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/NorFlashQemuLib/NorFlashQemuLib.c
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/NorFlashQemuLib/NorFlashQemuLib.inf

diff --git a/OvmfPkg/LoongArchVirt/Library/NorFlashQemuLib/NorFlashQemuLib.c 
b/OvmfPkg/LoongArchVirt/Library/NorFlashQemuLib/NorFlashQemuLib.c
new file mode 100644
index 00..ae9af09c4c
--- /dev/null
+++ b/OvmfPkg/LoongArchVirt/Library/NorFlashQemuLib/NorFlashQemuLib.c
@@ -0,0 +1,140 @@
+/** @file
+
+  Copyright (c) 2024 Loongson Technology Corporation Limited. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define QEMU_NOR_BLOCK_SIZE  SIZE_128KB
+
+EFI_STATUS
+VirtNorFlashPlatformInitialization (
+  VOID
+  )
+{
+  return EFI_SUCCESS;
+}
+
+STATIC VIRT_NOR_FLASH_DESCRIPTION  mNorFlashDevices;
+
+EFI_STATUS
+VirtNorFlashPlatformGetDevices (
+  OUT VIRT_NOR_FLASH_DESCRIPTION  **NorFlashDescriptions,
+  OUT UINT32  *Count
+  )
+{
+  FDT_CLIENT_PROTOCOL  *FdtClient;
+  INT32Node;
+  EFI_STATUS   Status;
+  EFI_STATUS   FindNodeStatus;
+  CONST UINT32 *Reg;
+  UINT32   PropSize;
+  UINT64   Base;
+  UINT64   Size;
+
+  Status = gBS->LocateProtocol (
+  &gFdtClientProtocolGuid,
+  NULL,
+  (VOID **)&FdtClient
+  );
+  ASSERT_EFI_ERROR (Status);
+
+  FindNodeStatus = FdtClient->FindCompatibleNode (
+FdtClient,
+"cfi-flash",
+&Node
+);
+  ASSERT_EFI_ERROR (FindNodeStatus);
+
+  Status = FdtClient->GetNodeProperty (
+FdtClient,
+Node,
+"reg",
+(CONST VOID **)&Reg,
+&PropSize
+);
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "%a: GetNodeProperty () failed (Status == %r)\n",
+  __func__,
+  Status
+  ));
+return Status;
+  }
+
+  ASSERT ((PropSize % (4 * sizeof (UINT32))) == 0);
+
+  if (PropSize < (4 * sizeof (UINT32))) {
+DEBUG ((
+  DEBUG_ERROR,
+  "%a: reg node size(%d) is too small \n",
+  __func__,
+  PropSize
+  ));
+return EFI_NOT_FOUND;
+  }
+
+  Base = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[0]));
+  Size = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2]));
+
+  mNorFlashDevices.DeviceBaseAddress = (UINTN)Base;
+  mNorFlashDevices.RegionBaseAddress = (UINTN)Base;
+  mNorFlashDevices.Size  = (UINTN)Size;
+  mNorFlashDevices.BlockSize = QEMU_NOR_BLOCK_SIZE;
+
+  Status = PcdSet32S (PcdFlashNvStorageVariableBase, Base);
+  ASSERT_EFI_ERROR (Status);
+
+  /*
+   * Base is the value of PcdFlashNvStorageVariableBase,
+   * PcdFlashNvStorageFtwWorkingBase can be got by
+   *   PcdFlashNvStorageVariableBase + PcdFlashNvStorageVariableSize
+   */
+  Base  += PcdGet32 (PcdFlashNvStorageVariableSize);
+  Status = PcdSet32S (PcdFlashNvStorageFtwWorkingBase, Base);
+  ASSERT_EFI_ERROR (Status);
+
+  /*
+   * Now,Base is the value of PcdFlashNvStorageFtwWorkingBase,
+   * PcdFlashNvStorageFtwSpareBase can be got by
+   *   PcdFlashNvStorageFtwWorkingBase + PcdFlashNvStorageFtwWorkingSize.
+   */
+  Base  += PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
+  Status = PcdSet32S (PcdFlashNvStorageFtwSpareBase, Base);
+  ASSERT_EFI_ERROR (Status);
+
+  //
+  // UEFI takes ownership of the NOR flash, and exposes its functionality
+  // through the UEFI Runtime Services GetVariable, SetVariable, etc. This
+  // means we need to disable it in the device tree to prevent the OS from
+  // attaching its device driver as well.
+  // Note that this also hides other flash banks, but the only other flash
+  // bank we expect to encounter is the one that carries the UEFI executable
+  // code, which is not intended to be guest updatable, and is usually backed
+  // in a readonly manner by QEMU anyway.
+  //
+  Status = FdtClient->SetNodeProperty (
+FdtClient,
+Node,
+"status",
+"disabled",
+sizeof ("disabled")
+);
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_WARN, "Failed to set NOR flash status

Re: [edk2-devel] [PATCH v6 28/36] OvmfPkg/LoongArchVirt: Add the early serial port output library

2024-01-09 Thread maobibo




On 2024/1/5 下午5:45, Chao Li wrote:

Add a early serial port output library into LoongArchVirt that named
EarlyFdtSerialPortLib16550, this library is referenced from
MdeModulePkg.

This library is used in the PEI phase. Since the serial port address can
not be saved in memory of the LoongArch QEMU virtual machine in the PEI
phase, the serial prot base address will be obtained from the FDT before
each output.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Bibo Mao 
Cc: Dongyan Qian 
Signed-off-by: Chao Li 
Co-authored-by: Xianglai Li 
---
  .../EarlyFdtSerialPortLib16550.c  | 815 ++
  .../EarlyFdtSerialPortLib16550.inf|  46 +
  2 files changed, 861 insertions(+)
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/EarlyFdtSerialPortLib16550/EarlyFdtSerialPortLib16550.c
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/EarlyFdtSerialPortLib16550/EarlyFdtSerialPortLib16550.inf

diff --git 
a/OvmfPkg/LoongArchVirt/Library/EarlyFdtSerialPortLib16550/EarlyFdtSerialPortLib16550.c
 
b/OvmfPkg/LoongArchVirt/Library/EarlyFdtSerialPortLib16550/EarlyFdtSerialPortLib16550.c
new file mode 100644
index 00..8cc108501c
--- /dev/null
+++ 
b/OvmfPkg/LoongArchVirt/Library/EarlyFdtSerialPortLib16550/EarlyFdtSerialPortLib16550.c
@@ -0,0 +1,815 @@
+/** @file
+  16550 UART Serial Port library functions
+
+  Copyright (c) 2024, Loongson Technology Corporation Limited. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+//
+// PCI Defintions.
+//
+#define PCI_BRIDGE_32_BIT_IO_SPACE  0x01
+
+//
+// 16550 UART register offsets and bitfields
+//
+#define R_UART_RXBUF   0// LCR_DLAB = 0
+#define R_UART_TXBUF   0// LCR_DLAB = 0
+#define R_UART_BAUD_LOW0// LCR_DLAB = 1
+#define R_UART_BAUD_HIGH   1// LCR_DLAB = 1
+#define R_UART_IER 1// LCR_DLAB = 0
+#define R_UART_FCR 2
+#define B_UART_FCR_FIFOE   BIT0
+#define B_UART_FCR_FIFO64  BIT5
+#define R_UART_LCR 3
+#define B_UART_LCR_DLABBIT7
+#define R_UART_MCR 4
+#define B_UART_MCR_DTRCBIT0
+#define B_UART_MCR_RTS BIT1
+#define R_UART_LSR 5
+#define B_UART_LSR_RXRDY   BIT0
+#define B_UART_LSR_TXRDY   BIT5
+#define B_UART_LSR_TEMTBIT6
+#define R_UART_MSR 6
+#define B_UART_MSR_CTS BIT4
+#define B_UART_MSR_DSR BIT5
+#define B_UART_MSR_RI  BIT6
+#define B_UART_MSR_DCD BIT7
+
+/**
+  Read an 8-bit 16550 register.  If PcdSerialUseMmio is TRUE, then the value 
is read from
+  MMIO space.  If PcdSerialUseMmio is FALSE, then the value is read from I/O 
space.  The
+  parameter Offset is added to the base address of the 16550 registers that is 
specified
+  by PcdSerialRegisterBase. PcdSerialRegisterAccessWidth specifies the MMIO 
space access
+  width and defaults to 8 bit access, and supports 8 or 32 bit access.
+
+  @param  BaseThe base address register of UART device.
+  @param  Offset  The offset of the 16550 register to read.
+
+  @return The value read from the 16550 register.
+**/
+UINT8
+SerialPortReadRegister (
+  UINTN  Base,
+  UINTN  Offset
+  )
+{
+  if (PcdGetBool (PcdSerialUseMmio)) {
+if (PcdGet8 (PcdSerialRegisterAccessWidth) == 32) {
+  return (UINT8)MmioRead32 (Base + Offset * PcdGet32 
(PcdSerialRegisterStride));
+}
+
+return MmioRead8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride));
+  } else {
+return IoRead8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride));
+  }
+}
+
+/**
+  Write an 8-bit 16550 register.  If PcdSerialUseMmio is TRUE, then the value 
is written to
+  MMIO space.  If PcdSerialUseMmio is FALSE, then the value is written to I/O 
space.  The
+  parameter Offset is added to the base address of the 16550 registers that is 
specified
+  by PcdSerialRegisterBase. PcdSerialRegisterAccessWidth specifies the MMIO 
space access
+  width and defaults to 8 bit access, and supports 8 or 32 bit access.
+
+  @param  BaseThe base address register of UART device.
+  @param  Offset  The offset of the 16550 register to write.
+  @param  Value   The value to write to the 16550 register specified by Offset.
+
+  @return The value written to the 16550 register.
+**/
+UINT8
+SerialPortWriteRegister (
+  UINTN  Base,
+  UINTN  Offset,
+  UINT8  Value
+  )
+{
+  if (PcdGetBool (PcdSerialUseMmio)) {
+if (PcdGet8 (PcdSerialRegisterAccessWidth) == 32) {
+  return (UINT8)MmioWrite32 (Base + Offset * PcdGet32 
(PcdSerialRegisterStride), (UINT8)Value);
+}
+
+return MmioWrite8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), 
Value);
+  } else {
+return IoWrite8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), 
Value);
+  }
+}
+
+/**
+  Retrieve the I/O or MMIO base address register for the PCI UART device.
+
+  This function assumes Root Bus Numer is Zero, and enables I/O and MMIO in 
P

Re: [edk2-devel] [PATCH v6 26/36] OvmfPkg/LoongArchVirt: Add a NULL library named CollectApResouceLibNull

2024-01-09 Thread maobibo




On 2024/1/5 下午5:45, Chao Li wrote:

This Library is used to collect APs resources, but is currently NULL
for OvmfPkg, because it is not used by the LoongArch virtual machine.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Bibo Mao 
Cc: Dongyan Qian 
Signed-off-by: Chao Li 
---
  .../CollectApResourceLibNull.c| 38 +++
  .../CollectApResourceLibNull.inf  | 31 +++
  .../CollectApResourceLibNull.uni  |  9 +
  3 files changed, 78 insertions(+)
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.c
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.inf
  create mode 100644 
OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.uni

diff --git 
a/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.c
 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.c
new file mode 100644
index 00..19995c1193
--- /dev/null
+++ 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.c
@@ -0,0 +1,38 @@
+/** @file
+  LoongArch64 CPU Collect AP resource NULL Library functions.
+
+  Copyright (c) 2024, Loongson Technology Corporation Limited. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "../../../UefiCpuPkg/Library/LoongArch64MpInitLib/MpLib.h"
The included path is a little strange, should we put 
CollectApResouceLibNull library in ovmf package or 
UefiCpuPkg/Library/LoongArch64MpInitLib package?


Regards
Bibo Mao


+
+VOID
+SaveProcessorResourceData (
+  IN PROCESSOR_RESOURCE_DATA *
+  );
+
+VOID
+EFIAPI
+SaveProcessorResource (
+  PROCESSOR_RESOURCE_DATA  *mProcessorResource
+  )
+{
+  SaveProcessorResourceData (mProcessorResource);
+}
+
+VOID
+EFIAPI
+CollectAllProcessorResource (
+  VOID
+  )
+{
+  return;
+}
diff --git 
a/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.inf
 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.inf
new file mode 100644
index 00..c166df6bbd
--- /dev/null
+++ 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.inf
@@ -0,0 +1,31 @@
+## @file
+#  LoongArch64 CPU Collect AP resource NULL Library.
+#
+#  Copyright (c) 2024, Loongson Technology Corporation Limited. All rights 
reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 1.29
+  BASE_NAME  = CollectApResourceLibNull
+  MODULE_UNI_FILE= CollectApResourceLibNull.uni
+  FILE_GUID  = 8C3B54BF-6A9F-E8B4-4D57-67B3AB578DD6
+  MODULE_TYPE= PEIM
+  VERSION_STRING = 1.1
+  LIBRARY_CLASS  = PEIM
+
+[Sources.common]
+  CollectApResourceLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  HobLib
+  MemoryAllocationLib
+
+[Pcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber
diff --git 
a/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.uni
 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.uni
new file mode 100644
index 00..d1638ab11e
--- /dev/null
+++ 
b/OvmfPkg/LoongArchVirt/Library/CollectApResouceLibNull/CollectApResourceLibNull.uni
@@ -0,0 +1,9 @@
+// @file
+//  LoongArch64 CPU Collect AP resource NULL Library.
+//
+//  Copyright (c) 2024, Loongson Technology Corporation Limited. All rights 
reserved.
+//  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+#string STR_MODULE_ABSTRACT #language en-US "CPU Collect AP resource 
NULL Library."
+
+#string STR_MODULE_DESCRIPTION  #language en-US "CPU Collect AP resource 
NULL Library."





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




Re: [edk2-devel] [Patch V3 0/2] Change the usage of input parameter ProcessorNumber in MpInitLibGetProcessorInfo() of MpInitLibUp

2024-01-09 Thread duntan
Thank you so much!

Thanks,
Dun

-Original Message-
From: Laszlo Ersek  
Sent: Wednesday, January 10, 2024 12:35 AM
To: devel@edk2.groups.io; Tan, Dun 
Subject: Re: [edk2-devel] [Patch V3 0/2] Change the usage of input parameter 
ProcessorNumber in MpInitLibGetProcessorInfo() of MpInitLibUp

On 1/8/24 06:08, duntan wrote:
> Please ignore the V2 PATCH set. No other change except adding BaseMemoryLib 
> headfile and lib instance in .inf to pass build since ZeroMem() is used. 
> 
> Comparing to the V1 patch set:
> In "set EXTENDED_PROCESSOR_INFORMATION to 0", set 
> EXTENDED_PROCESSOR_INFORMATION to 0 in API MpInitLibGetProcessorInfo() of 
> MpInitLibUp. This commit use ZeroMem() to set all fileds in output 
> EFI_PROCESSOR_INFORMATION to 0 before StatusFlag field is reassigned.
> 
> In "Check lower 24 bits of ProcessorNumber", use BIT24 instead of 
> CPU_V2_EXTENDED_TOPOLOGY to clearly tell that processor number only occupies 
> the lower 24 bits.
> 
> Dun Tan (2):
>   UefiCpuPkg: set EXTENDED_PROCESSOR_INFORMATION to 0
>   UefiCpuPkg: Check lower 24 bits of ProcessorNumber
> 
>  UefiCpuPkg/Include/Library/MpInitLib.h |  2 ++
>  UefiCpuPkg/Library/MpInitLib/MpLib.c   |  2 ++
>  UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c   | 20 
>  UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf |  1 +
>  4 files changed, 17 insertions(+), 8 deletions(-)
> 

Merged as commit range f2b074398ca0..08a6528bac38, via 
 (first two commits in the PR).

BR
Laszlo



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




Re: [edk2-devel] Memory Attribute for depex section

2024-01-09 Thread Nhi Pham via groups.io
++ disc...@edk2.groups.io

On 1/8/2024 5:11 PM, Nhi Pham wrote:
> Hi Ard, all,
> 
> Could you please help explain how the depex section in an image is
> mapped in terms of memory attribute?
> 
> As my observation, dispatcher locates[1] the depex section inside the
> module image and write[2] an evaluated data to the depex if necessary
> for scheduled boot order. The problem that the depex section is now in
> RO+X memory due to a part of the module image, so a writing to depex
> would cause data abort. I'm unsure whether this issue is generic in EDK2
> or not.
> 
> I think of two approaches:
> 
> #1 Relocate the depex section to heap memory for dependency evaluation?
> 
> #2 EDK2 build tool to support granting write permission for depex section.
> 
> [1] StandaloneMmPkg/Core/FwVol.c:236
> [2] StandaloneMmPkg/Core/Dependency.c:256
> 
> Thanks,
> Nhi



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




Re: [edk2-devel] [PATCH] UefiPayloadPkg: Add macro to enable selection of timer

2024-01-09 Thread Benjamin Doron
Hi,
Are there platforms that will use this? What advantages does using the LAPIC as 
a timer offer? Thanks.

Regards,
Benjamin


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113496): https://edk2.groups.io/g/devel/message/113496
Mute This Topic: https://groups.io/mt/103538255/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/6] NetworkPkg/HttpDxe: Refactor TlsCreateChild

2024-01-09 Thread Saloni Kasbekar
Reviewed-by: Saloni Kasbekar 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Chang, Abner via 
groups.io
Sent: Sunday, January 7, 2024 5:27 AM
To: devel@edk2.groups.io
Cc: Kasbekar, Saloni ; Clark-williams, Zachary 
; Michael Brown ; Nickle Wang 
; Igor Kulchytskyy 
Subject: [edk2-devel] [PATCH V2 1/6] NetworkPkg/HttpDxe: Refactor TlsCreateChild

From: Abner Chang 

- Use HTTP instance as the parameter for TlsCreateChild function.
- Install TLS protocol on the HTTP instance thats create TLS child.

Signed-off-by: Abner Chang 
Cc: Saloni Kasbekar 
Cc: Zachary Clark-williams 
Cc: Michael Brown 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Reviewed-by: Michael Brown 
---
 NetworkPkg/HttpDxe/HttpProto.h|  3 +-
 NetworkPkg/HttpDxe/HttpsSupport.h | 18 ---
 NetworkPkg/HttpDxe/HttpImpl.c | 23 ++---
 NetworkPkg/HttpDxe/HttpProto.c|  7 +--
 NetworkPkg/HttpDxe/HttpsSupport.c | 78 ++-
 5 files changed, 64 insertions(+), 65 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h 
index 012f1f4b467..7e77b389a78 100644
--- a/NetworkPkg/HttpDxe/HttpProto.h
+++ b/NetworkPkg/HttpDxe/HttpProto.h
@@ -3,6 +3,7 @@
 
 Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
+Copyright (C) 2024 Advanced Micro Devices, Inc. All rights 
+reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -171,7 +172,7 @@ typedef struct _HTTP_PROTOCOL {
   BOOLEAN   UseHttps;
 
   EFI_SERVICE_BINDING_PROTOCOL  *TlsSb;
-  EFI_HANDLETlsChildHandle; /// Tls ChildHandle
+  BOOLEAN   TlsAlreadyCreated;
   TLS_CONFIG_DATA   TlsConfigData;
   EFI_TLS_PROTOCOL  *Tls;
   EFI_TLS_CONFIGURATION_PROTOCOL*TlsConfiguration;
diff --git a/NetworkPkg/HttpDxe/HttpsSupport.h 
b/NetworkPkg/HttpDxe/HttpsSupport.h
index 3c70825e8c3..5b44c7ac395 100644
--- a/NetworkPkg/HttpDxe/HttpsSupport.h
+++ b/NetworkPkg/HttpDxe/HttpsSupport.h
@@ -2,6 +2,7 @@
   The header files of miscellaneous routines specific to Https for HttpDxe 
driver.
 
 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+Copyright (C) 2024 Advanced Micro Devices, Inc. All rights 
+reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -30,21 +31,18 @@ IsHttpsUrl (
 /**
   Creates a Tls child handle, open EFI_TLS_PROTOCOL and 
EFI_TLS_CONFIGURATION_PROTOCOL.
 
-  @param[in]  ImageHandle   The firmware allocated handle for the UEFI 
image.
-  @param[out] TlsSb Pointer to the TLS 
SERVICE_BINDING_PROTOCOL.
-  @param[out] TlsProto  Pointer to the EFI_TLS_PROTOCOL instance.
-  @param[out] TlsConfiguration  Pointer to the 
EFI_TLS_CONFIGURATION_PROTOCOL instance.
+  @param[in]  HttpInstance  Pointer to HTTP_PROTOCOL structure.
 
-  @return  The child handle with opened EFI_TLS_PROTOCOL and 
EFI_TLS_CONFIGURATION_PROTOCOL.
+  @return  EFI_SUCCESSTLS child handle is returned in 
HttpInstance->TlsChildHandle
+  with opened EFI_TLS_PROTOCOL and 
EFI_TLS_CONFIGURATION_PROTOCOL.
+   EFI_DEVICE_ERROR   TLS service binding protocol is not found.
+   Otherwise  Fail to create TLS chile handle.
 
 **/
-EFI_HANDLE
+EFI_STATUS
 EFIAPI
 TlsCreateChild (
-  IN  EFI_HANDLE  ImageHandle,
-  OUT EFI_SERVICE_BINDING_PROTOCOL**TlsSb,
-  OUT EFI_TLS_PROTOCOL**TlsProto,
-  OUT EFI_TLS_CONFIGURATION_PROTOCOL  **TlsConfiguration
+  IN  HTTP_PROTOCOL  *HttpInstance
   );
 
 /**
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c 
index 7c5c925cf78..6606c293421 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -3,6 +3,7 @@
 
   Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights 
+ reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -248,7 +249,6 @@ EfiHttpRequest (
   HTTP_TOKEN_WRAP*Wrap;
   CHAR8  *FileUrl;
   UINTN  RequestMsgSize;
-  EFI_HANDLE ImageHandle;
 
   //
   // Initializations
@@ -371,23 +371,10 @@ EfiHttpRequest (
 //
 // Check whether we need to create Tls child and open the TLS protocol.
 //
-if (HttpInstance->UseHttps && (HttpInstance->TlsChildHandle == NULL)) {
-  //
-  // Use TlsSb to create Tls child and open the TLS protocol.
-  //
-  if (HttpInstance->LocalAddressIsIPv6) {
-ImageHandle = HttpInstance->Service->Ip6DriverBindingHandle;
-  } else {
-ImageHandle = HttpInstance->Service->Ip4DriverBindingHandle;
-  }
-
-  HttpInstance->TlsChildHandle = TlsCreateChild (
-   ImageHandle,
-

Re: [edk2-devel] [PATCH V2 3/6] NetworkPkg/HttpDxe: Add HttpEventTlsConfigured HTTP callback event

2024-01-09 Thread Saloni Kasbekar
Reviewed-by: Saloni Kasbekar 

-Original Message-
From: abner.ch...@amd.com  
Sent: Sunday, January 7, 2024 5:27 AM
To: devel@edk2.groups.io
Cc: Kasbekar, Saloni ; Clark-williams, Zachary 
; Michael Brown ; Nickle Wang 
; Igor Kulchytskyy 
Subject: [PATCH V2 3/6] NetworkPkg/HttpDxe: Add HttpEventTlsConfigured HTTP 
callback event

From: Abner Chang 

Add HttpEventTlsConfigured HTTP callback event and notify callback functions 
when TlsConfigureSession () returns.

Signed-off-by: Abner Chang 
Cc: Saloni Kasbekar 
Cc: Zachary Clark-williams 
Cc: Michael Brown 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Reviewed-by: Michael Brown 
---
 NetworkPkg/Include/Protocol/HttpCallback.h | 15 ++-
 NetworkPkg/HttpDxe/HttpProto.c |  1 +
 NetworkPkg/HttpDxe/HttpsSupport.c  |  4 ++--
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/NetworkPkg/Include/Protocol/HttpCallback.h 
b/NetworkPkg/Include/Protocol/HttpCallback.h
index 3accd2f8424..ae66cc9f771 100644
--- a/NetworkPkg/Include/Protocol/HttpCallback.h
+++ b/NetworkPkg/Include/Protocol/HttpCallback.h
@@ -2,6 +2,7 @@
   This file defines the EDKII HTTP Callback Protocol interface.
 
   Copyright (c) 2021, Intel Corporation. All rights reserved.
+  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights 
+ reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent  **/
 
@@ -55,7 +56,19 @@ typedef enum {
   /// EFI_SUCCESSThe initialization of session is done.
   /// Others Other error as indicated.
   ///
-  HttpEventInitSession
+  HttpEventInitSession,
+
+  ///
+  /// The Status of Event to configure TLS configuration data.
+  /// EventStatus:
+  /// EFI_SUCCESSThe TLS is configured successfully with the 
default value.
+  /// EFI_INVALID_PARAMETER  One or more input parameters to SetSessionData() 
is invalid.
+  /// EFI_NOT_READY  Current TLS session state is NOT 
EfiTlsSessionStateNotStarted.
+  /// EFI_NOT_FOUND  Fail to get 'HttpTlsCipherList' variable.
+  /// Others Other error as indicated.
+  ///
+  HttpEventTlsConfigured
+
 } EDKII_HTTP_CALLBACK_EVENT;
 
 /**
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c 
index 94900328ba9..9c3b497dce2 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -1418,6 +1418,7 @@ HttpInitSession (
   //
   if (TlsConfigure) {
 Status = TlsConfigureSession (HttpInstance);
+HttpNotify (HttpEventTlsConfigured, Status);
 if (EFI_ERROR (Status)) {
   return Status;
 }
diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c 
b/NetworkPkg/HttpDxe/HttpsSupport.c
index 04a830f7152..8d7bffe1e9c 100644
--- a/NetworkPkg/HttpDxe/HttpsSupport.c
+++ b/NetworkPkg/HttpDxe/HttpsSupport.c
@@ -723,7 +723,7 @@ TlsConfigureSession (
   Status = TlsConfigCertificate (HttpInstance);
   if (EFI_ERROR (Status)) {
 if (Status == EFI_NOT_FOUND) {
-  DEBUG((DEBUG_WARN, "TLS Certificate is not found on the system!\n"));
+  DEBUG ((DEBUG_WARN, "TLS Certificate is not found on the 
+ system!\n"));
   //
   // We still return EFI_SUCCESS to the caller when TlsConfigCertificate
   // returns error, for the use case the platform doesn't require @@ 
-734,7 +734,7 @@ TlsConfigureSession (
   //
   Status = EFI_SUCCESS;
 } else {
-  DEBUG((DEBUG_ERROR, "TLS Certificate Config Error!\n"));
+  DEBUG ((DEBUG_ERROR, "TLS Certificate Config Error!\n"));
   return Status;
 }
   }
--
2.37.1.windows.1



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




Re: [edk2-devel] [RFC PATCH v1 00/20] DynamicTablesPkg: Prepare to add RISC-V support

2024-01-09 Thread Jeshua Smith via groups.io
> From: devel@edk2.groups.io  On Behalf Of Sunil V L
> via groups.io
> Sent: Tuesday, January 9, 2024 9:29 AM
> DynamicTablesPkg can be used by RISC-V platforms to generate ACPI tables
> from FDT passed from previous stage FW. However, DynamicTablesPkg
> currently is ARM specific even though several parsers and ACPI generators can
> be used across architectures. For ex: SSDT (PCIe), SSDT (CPU), MCFG, SPCR,
> DBG2, FADT, SRAT, Raw (DSDT) are mostly common across architectures. Only
> MADT, IORT and GTDT are ARM specific.
> 
> This series tries to refactor the DynamicTablesPkg so that RISC-V support can
> be added fairly easily later.

It looks like instead of moving the common code to EObjNameSpaceStandard 
namespace or a new (Arch? Common?) namespace, you're renaming the entire 
EObjNameSpaceArm namespace to EObjNameSpaceArch. It seems to me that if ARM 
code vs. common code is being separated out, then the EObjNameSpaceArm 
namespace should continue to be used for the ARM-specific code and a common 
namespace should be used for the common code.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113493): https://edk2.groups.io/g/devel/message/113493
Mute This Topic: https://groups.io/mt/103622702/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/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test

2024-01-09 Thread Stuart Yoder
From: Joseph Hemann 

-add test for GetEventLog()
  -test for valid and invalid event log format
  -test event log header
  -verify expected event log entry

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |  20 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  17 ++
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h   
  |  46 +
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |   8 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 207 +++-
 5 files changed, 297 insertions(+), 1 deletion(-)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index dcfd5919acda..746ff83f899c 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -85,3 +85,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
 { 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \
+{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0x35 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \
+{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \
+{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0x51 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID \
+{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid016;
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index cbbadef4a5c7..5ce275dc6258 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -43,8 +43,13 @@ Abstract:
 #define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \
  {0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} 
}
 
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104 \
+ {0x9087ad78, 0x9ad2, 0x4172, {0x9a, 0xbc, 0x98, 0x23, 0x08, 0xf5, 0x6d, 0x26} 
}
+
 #define EV_POST_CODE 0x01
 
+#define EV_NO_ACTION 0x03
+
 #define EFI_TCG2_EXTEND_ONLY 0x0001
 
 #define PE_COFF_IMAGE 0x0010
@@ -103,6 +108,18 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2
   );
 
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint1 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint2 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
 EFI_STATUS
 BBTestGetCapabilityConformanceTest (
   IN EFI_BB_TEST_PROTOCOL   *This,
diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h 
b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
index e62ecd85cbe9..fd31204a9299 100644
--- a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -50,6 +50,8 @@ Abstract:
 
 #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
 
+#define HASH_NUMBER 0x04
+
 typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
 
 typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP;
@@ -115,6 +117,50 @@ typedef struct tdEFI_TCG2_EVENT {
   UINT8 Event[];
 } EFI_TCG2_EVENT;
 
+typedef struct {
+  UINT16 hashAlg;
+  UINT8  digest[];
+} TPMT_HA;
+
+typedef struct tdTPML_DIGEST_VALUES {
+  UINT32 Count;// number of digests
+  TPMT_HA Digests[HASH_NUMBER];// Count digests
+} TPML_DIGEST_VALUES;
+
+// This Declaration is for parsing the eventlog header which is defined to be 
20 bytes in TCG EFI Protocol Spec
+typedef UINT8 TCG_DIGEST[20];
+
+typedef struct tdTCG_PCR_EVENT2 {
+  TCG_PCRINDEX PCRIndex;   // PCRIndex event extended to
+  TCG_EVENTTYPE EventType; // Type of event (see [2])
+  TPML_DIGEST_VALUES Digests;  // List of digests extended to //PCRIndex
+  UINT32 EventSize;// Size of the event data
+  UINT8 *Event;// The event data
+} TCG_PCR_EVENT2;
+
+typedef struct tdTCG_PCR_EVENT {
+  UINT32 PCRIndex; // PCRIndex event extended to
+  UINT32 EventType; // Type of event (see EFI specs)
+  T

[edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions

2024-01-09 Thread Stuart Yoder
From: Joseph Hemann 

Define constants and data structure specified in the TCG EFI Protocol
specification.

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 177 
 1 file changed, 177 insertions(+)

diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h 
b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
new file mode 100644
index ..e62ecd85cbe9
--- /dev/null
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -0,0 +1,177 @@
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.
+  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+  TCG2.h
+
+Abstract:
+
+  EFI TCG Protocol
+
+--*/
+
+
+#ifndef __TCG2_PROTOCOL_H__
+#define __TCG2_PROTOCOL_H__
+
+//
+// Global ID for the TCG2 Protocol
+//
+#define EFI_TCG2_PROTOCOL_GUID\
+   {0x607f766c, 0x7455, 0x42be, {0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 
0x0f}}
+
+// Following defintions come from TCG2 Efi Protocol Spec
+#define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x0001
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x0002
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x0004
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x0008
+
+#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x0010
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x0001
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
+
+typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
+
+typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP;
+
+typedef UINT32 EFI_TCG2_EVENT_LOG_FORMAT;
+
+typedef UINT32 EFI_TCG2_EVENT_ALGORITHM_BITMAP;
+
+typedef UINT32 TCG_PCRINDEX;
+
+typedef UINT32 TCG_EVENTTYPE;
+
+// Following struct defintions come from TCG2 Efi Protocol Spec
+typedef struct {
+  UINT8 Major;
+  UINT8 Minor;
+} EFI_TCG2_VERSION;
+
+typedef struct {
+  UINT8 Size;
+  EFI_TCG2_VERSION StructureVersion;
+  EFI_TCG2_VERSION ProtocolVersion;
+  EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap;
+  EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs;
+  BOOLEAN TPMPresentFlag;
+  UINT16 MaxCommandSize;
+  UINT16 MaxResponseSize;
+  UINT32 ManufacturerID;
+  UINT32 NumberOfPcrBanks;
+  EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks;
+} EFI_TCG2_BOOT_SERVICE_CAPABILITY;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_CAPABILITY) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_EVENT_LOG) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat,
+  OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,
+  OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry,
+  OUT BOOLEAN *EventLogTruncated
+);
+
+// all structs except EFI_TCG2_BOOT_SERVICE_CAPABILITY are packed
+#pragma pack(1)
+
+typedef struct tdEFI_TCG2_EVENT_HEADER {
+  UINT32 HeaderSize;
+  UINT16 HeaderVersion;
+  TCG_PCRINDEX PCRIndex;
+  TCG_EVENTTYPE EventType;
+} EFI_TCG2_EVENT_HEADER;
+
+typedef struct tdEFI_TCG2_EVENT {
+  UINT32 Size;
+  EFI_TCG2_EVENT_HEADER Header;
+  UINT8 Event[];
+} EFI_TCG2_EVENT;
+
+#pragma pack()
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_HASH_LOG_EXTEND_EVENT) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN UINT64 Flags,
+  IN EFI_PHYSICAL_ADDRESS DataToHash,
+  IN UINT64 DataToHashLen,
+  IN EFI_TCG2_EVENT *EfiTcgEvent
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SUBMIT_COMMAND) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN UINT32 InputParameterBlockSize,
+  IN UINT8 *InputParameterBlock,
+  IN UINT32 OutputParameterBlockSize,
+  IN UINT8 *OutputParameterBlock
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_ACTIVE_PCR_BANKS) (
+  IN EFI_TCG2_PROTOCOL *This,
+  OUT UINT32 *ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SET_ACTIVE_PCR_BANKS) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN UINT32 ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS) (
+  IN EFI_TCG2_PROTOCOL *This,
+  OUT UINT32 *OperationPresent,
+  OUT UINT32 *Response
+);
+
+//
+// Interface structure for the TCG2 Protocol
+//
+struct _EFI_TCG2_PROTOCOL {
+  EFI_TCG2_GET_CAPABILITY GetCapability;
+  EFI_TCG2_GET_EVENT_LOG GetEventLog;
+  EFI_TCG2_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;
+  EFI_TCG2_SUBMIT_COMMAND SubmitCommand;
+  EFI_TCG2_GET_ACTIVE_PCR_BANKS GetActivePcrBanks;
+  EFI_TCG2_SET_ACTIVE_PCR_BANKS SetActivePcrBanks;
+  EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS GetResultOfSetActivePcrBanks;
+};
+
+extern EFI_GUID gEfiTcg2ProtocolGuid;
+
+#endif
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this gr

[edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

2024-01-09 Thread Stuart Yoder
From: Joseph Hemann 

Add test verifying the functionality of the SubmitCommand function
using the TPM command TPM2_HASH_COMMAND.

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |   5 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  71 
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |   2 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 173 
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
|   9 +
 5 files changed, 260 insertions(+)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index 746ff83f899c..044e549ce8f0 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -105,3 +105,8 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
 { 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 
}}
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid016;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_017_GUID \
+{ 0x3aac8b9a, 0x312a, 0x4dcf, {0x12, 0x76, 0x54, 0x55, 0x32, 0xcd, 0x3a, 0xea 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid017;
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index 5ce275dc6258..f8880599f150 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -54,6 +54,64 @@ Abstract:
 
 #define PE_COFF_IMAGE 0x0010
 
+// ST_NO_SESSION as defined in Table 19 of TPM Library Part 2: Structures
+#define ST_NO_SESSIONS (UINT16) 0x8001
+
+// TPM_RC_SUCCESS as defined in Table 16 of TPM Library Spec Part 2: Structures
+#define TPM_RC_SUCCESS (UINT32) 0x000
+
+// TPM_CC_Hash as defined in Table 12 of TPM Library Spec Part 2: Structures
+#define TPM_CC_Hash(UINT32)(0x017D)
+
+#define TPM_RH_NULL(UINT32) 0x4007
+
+#define TPM_ALG_SHA256 (UINT16) 0x000B
+
+#define SHA256_LENGTH (UINT16) 0x0020
+
+#pragma pack(1)
+// TPM2B_MAX_BUFFER as defined in Table 86 of TPM Library Spec Part 2: 
Structures
+// Size of buffer in spec is variable length, but hash test will always use a 
fixed length string
+// of length 43
+#define TEST_STRING_LEN 43
+typedef struct {
+  UINT16 size;
+  UINT8  buffer[TEST_STRING_LEN];
+} TPM2B_MAX_BUFFER;
+
+#pragma pack(1)
+// TPM2B_DIGEST as defined in Table 73 of TPM Library Spec Part 2: Structures
+typedef struct {
+  UINT16 size;
+  UINT8  digest[32];  // Size of buffer in spec is defined to be variable 
length but for this test will always be 32
+} TPM2B_DIGEST;
+
+typedef struct {
+  UINT16   tag;
+  UINT32   hierarchy;
+  UINT16   digest;  // Size of buffer in spec is defined to be 
variable length but for this test will always be UINT16
+} TPMT_TK_HASHCHECK;
+
+// TPM2_Hash command Structure as defined in Section 15.4 of TPM Spec Part 3: 
Commands
+typedef struct {
+  UINT16 Tag;
+  UINT32 CommandSize;
+  UINT32 CommandCode;
+  TPM2B_MAX_BUFFER data;
+  UINT16 hashAlg;
+  UINT32 hierarchy;
+} TPM2_HASH_COMMAND;
+
+// TPM2_Hash Response Structure as defined in Section 15.4 of TPM Spec Part 3: 
Commands
+typedef struct {
+  UINT16 Tag;
+  UINT32 ResponseSize;
+  UINT32 ResponseCode;
+  TPM2B_DIGEST data;
+  TPMT_TK_HASHCHECK validation;
+} TPM2_HASH_RESPONSE;
+#pragma
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -120,6 +178,12 @@ BBTestGetEventLogConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2
   );
 
+EFI_STATUS
+BBTestSubmitCommandConformanceTestCheckpoint1 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
 EFI_STATUS
 BBTestGetCapabilityConformanceTest (
   IN EFI_BB_TEST_PROTOCOL   *This,
@@ -144,3 +208,10 @@ BBTestHashLogExtendEventConformanceTest (
   IN EFI_HANDLE SupportHandle
   );
 
+EFI_STATUS
+BBTestSubmitCommandConformanceTest (
+  IN EFI_BB_TEST_PROTOCOL   *This,
+  IN VOID   *ClientInterface,
+  IN EFI_TEST_LEVEL TestLevel,
+  IN EFI_HANDLE SupportHandle
+  );
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 8c528aa8ddfc..9aa5315e670e 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -59,3 +59

[edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test

2024-01-09 Thread Stuart Yoder
From: Joseph Hemann 

-implement initial infrastructure for the TCG2 protocol test
 including updates to .dsc file, inf file, GUID source files,
 update to Category.ini.

-add test case for GetCapability(), as defined in the TCG EFI
 Protocol Spec 6.4.4.

-add checkpoint for NULL pointer passed for buffer

-add checkpoint for validating fields of the struct returned by GetCapability()

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc  
  |   1 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
  |  51 +++
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |  47 +++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  77 +
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |  37 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 361 
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
| 102 ++
 uefi-sct/SctPkg/CommonGenFramework.sh  
  |   1 +
 uefi-sct/SctPkg/Config/Data/Category.ini   
  |   7 +
 9 files changed, 684 insertions(+)

diff --git a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc 
b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
index 155490fa39d3..96c93e73992c 100644
--- a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
+++ b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
@@ -301,6 +301,7 @@ 
SctPkg/TestCase/UEFI/EFI/Protocol/StorageSecurityCommand/BlackBoxTest/StorageSec
 
SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoProtocolBBTest.inf
 
SctPkg/TestCase/UEFI/EFI/Protocol/TimeStamp/BlackBoxTest/TimeStampProtocolBBTest.inf
 
SctPkg/TestCase/UEFI/EFI/Protocol/RandomNumber/BlackBoxTest/RandomNumberBBTest.inf
+SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 
 SctPkg/TestCase/UEFI/EFI/Protocol/Hash2/BlackBoxTest/Hash2BBTest.inf
 SctPkg/TestCase/UEFI/EFI/Protocol/PKCS7Verify/BlackBoxTest/Pkcs7BBTest.inf
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
new file mode 100644
index ..563d81b7e859
--- /dev/null
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
@@ -0,0 +1,51 @@
+## @file
+#
+#  Copyright 2006 - 2015 Unified EFI, Inc.
+#  Copyright (c) 2013, Intel Corporation. All rights reserved.
+#  Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+##
+#/*++
+#
+# Module Name:
+#
+#   TCG2ProtocolBBTest.inf
+#
+# Abstract:
+#
+#   Component description file for TCG2 Protocol Black-Box Test.
+#
+#--*/
+
+[defines]
+  INF_VERSION  = 0x00010005
+  BASE_NAME= TCG2ProtocolBBTest
+  FILE_GUID= BD8CB762-3935-434C-AC3F-462244910A2D
+  MODULE_TYPE  = UEFI_DRIVER
+  VERSION_STRING   = 1.0
+  ENTRY_POINT  = InitializeBBTestTCG2Protocol
+
+[sources.common]
+  Guid.c
+  TCG2ProtocolBBTestMain.c
+  TCG2ProtocolBBTestConformance.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  SctPkg/SctPkg.dec
+  SctPkg/UEFI/UEFI.dec
+
+[LibraryClasses]
+  UefiDriverEntryPoint
+  SctLib
+  EfiTestLib
+
+[Protocols]
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
new file mode 100644
index ..50b14272939f
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -0,0 +1,47 @@
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.
+  Copyright (c) 2013, Intel Corporation. All rights reserved.
+  Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+  guid.h
+
+Abstract:
+
+  GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTI

[edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test

2024-01-09 Thread Stuart Yoder
From: Joseph Hemann 

-add tests for HashLogExtendEvent()
  -tests with valid, invalid, and out of range parameters
  -do extend of data to PCR 16

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |  29 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  29 ++
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |  12 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 283 
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
|   9 +
 5 files changed, 362 insertions(+)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index d6797f5287f4..dcfd5919acda 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -56,3 +56,32 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID \
+{ 0xa8e1b5e6, 0xfc09, 0x461c, {0xb0, 0xe9, 0x2a, 0x49, 0xcd, 0x25, 0xc1, 0x24 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid007;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID \
+{ 0x26f04a9b, 0x7b7a, 0x4f47, {0xbe, 0xa8, 0xb1, 0xa6, 0x02, 0x65, 0x19, 0x8a 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID \
+{ 0x4d1d9985, 0x91e2, 0x4948, {0x89, 0x16, 0xbb, 0x98, 0x13, 0x62, 0x39, 0x1d 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID \
+{ 0xfb59cab7, 0x4f8c, 0x4ded, {0xa4, 0x1c, 0xc8, 0x41, 0x20, 0x1c, 0x37, 0x22 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid010;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID \
+{ 0x0363d22f, 0xc66a, 0x4872, {0xa5, 0x46, 0x06, 0x7f, 0x6a, 0x0d, 0xdb, 0xcd 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID \
+{ 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index 80c02d9ed2d2..cbbadef4a5c7 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -40,6 +40,15 @@ Abstract:
 #define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102 \
  {0x847f1ae0, 0xb429, 0x49f1, {0x9e, 0x0c, 0x8f, 0x43, 0xfb, 0x55, 0x34, 0x54} 
}
 
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \
+ {0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} 
}
+
+#define EV_POST_CODE 0x01
+
+#define EFI_TCG2_EXTEND_ONLY 0x0001
+
+#define PE_COFF_IMAGE 0x0010
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -82,6 +91,18 @@ BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2
   );
 
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint1 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint2 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
 EFI_STATUS
 BBTestGetCapabilityConformanceTest (
   IN EFI_BB_TEST_PROTOCOL   *This,
@@ -98,3 +119,11 @@ BBTestGetActivePcrBanksConformanceTest (
   IN EFI_HANDLE SupportHandle
   );
 
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTest (
+  IN EFI_BB_TEST_PROTOCOL   *This,
+  IN VOID   *ClientInterface,
+  IN EFI_TEST_LEVEL TestLevel,
+  IN EFI_HANDLE SupportHandle
+  );
+
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 0dc2cfddfcbf..ccc20259d128 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -39,3 +39,15 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid004 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 EFI_GUID gTcg2ConformanceTestAssertionGuid005 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
 
 EFI_GUID gTcg2ConformanceTestAssertionGuid006 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid007 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID;
+
+EFI_GUID gTc

[edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test

2024-01-09 Thread Stuart Yoder
From: Joseph Hemann 

-add test for GetActivePcrBanks()
  -checkpoint for NULL pointer passed for buffer
  -checkpoint for test of function with proper input

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |  11 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  23 +++
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |   4 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 159 
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
|   9 ++
 5 files changed, 206 insertions(+)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index 50b14272939f..d6797f5287f4 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -45,3 +45,14 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;
 { 0x8ddb031b, 0x7448, 0x40ee, {0xb1, 0xa2, 0xe6, 0xf8, 0xe8, 0xc4, 0xe5, 0x5f 
}}
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID \
+{ 0x7a1e79a3, 0x4064, 0x4372, {0xbb, 0x64, 0x55, 0xb8, 0xf2, 0xa5, 0xa3, 0x26 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID \
+{ 0xb0e717c4, 0xb1e2, 0x49f7, {0xb2, 0xd7, 0x60, 0x58, 0x97, 0x7d, 0x09, 0x2c 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
+
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index a7ce2db322d9..80c02d9ed2d2 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -37,6 +37,9 @@ Abstract:
 #define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101 \
  {0x39ff9c71, 0x4b41, 0x4e5b, {0xae, 0xd7, 0x87, 0xc7, 0x94, 0x18, 0x7d, 0x67} 
}
 
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102 \
+ {0x847f1ae0, 0xb429, 0x49f1, {0x9e, 0x0c, 0x8f, 0x43, 0xfb, 0x55, 0x34, 0x54} 
}
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -67,6 +70,18 @@ BBTestGetCapabilityConformanceTestCheckpoint4 (
   IN EFI_TCG2_PROTOCOL *TCG2
   );
 
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint1 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
 EFI_STATUS
 BBTestGetCapabilityConformanceTest (
   IN EFI_BB_TEST_PROTOCOL   *This,
@@ -75,3 +90,11 @@ BBTestGetCapabilityConformanceTest (
   IN EFI_HANDLE SupportHandle
   );
 
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTest (
+  IN EFI_BB_TEST_PROTOCOL   *This,
+  IN VOID   *ClientInterface,
+  IN EFI_TEST_LEVEL TestLevel,
+  IN EFI_HANDLE SupportHandle
+  );
+
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 3e75ffdc0a60..0dc2cfddfcbf 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -35,3 +35,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid002 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 EFI_GUID gTcg2ConformanceTestAssertionGuid003 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID;
 
 EFI_GUID gTcg2ConformanceTestAssertionGuid004 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid005 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid006 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID;
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 686cf4baebcd..681f57ac224a 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -87,6 +87,58 @@ BBTestGetCapabilityConformanceTest (
   return EFI_SUCCESS;
 }
 
+/**
+ *  @brief Entrypoint for GetActivePcrBanks() Function Test.
+ * 2 checkpoints will be tested.
+ *  @param This a pointer of EFI_BB_TEST_PROTOCOL
+ *  @param ClientInterface A pointer to the interface arr

[edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol

2024-01-09 Thread Stuart Yoder
This patch series adds tests for the TCG2 Protocol which is implemented by EDK2.
The protocol is defined in chapter 6 in the TCG EFI Protocol Specification:
https://trustedcomputinggroup.org/resource/tcg-efi-protocol-specification/

The definition of the test cases is in a specification that has been
reviewed in 2022 by participants in the monthly Tianocore edk2-test bug triage
 meeting.  That spec is here:
https://github.com/stuyod01/edk2-test/blob/master/uefi-sct/Doc/UEFI-SCT-Case-Spec/30_Protocols_TCG2_Test.md

Bugzilla ticket for this is:
https://bugzilla.tianocore.org/show_bug.cgi?id=3736

The patches in this series are an updated version of code that has been
in the Arm SystemReady ACS for several years, and have been used as
part of SystemReady certifications.

There are tests for functions
  EFI_TCG2_PROTOCOL.GetCapability
  EFI_TCG2_PROTOCOL.GetEventLog
  EFI_TCG2_PROTOCOL.HashLogExtendEvent
  EFI_TCG2_PROTOCOL.SubmitCommand
  EFI_TCG2_PROTOCOL.GetActivePcrBanks

v2 changes
   -added commit messages for all patches
   -deleted typedef for EFI_PHYSICAL_ADDRESS since it is defined elsewhere

Joseph Hemann (6):
  uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol
definitions
  uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and
GetCapability Test
  uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test
  uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test
  uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
  uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc  
  |1 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
  |   51 +
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |  112 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  217 
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h   
  |  223 
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |   63 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 1181 
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
|  129 +++
 uefi-sct/SctPkg/CommonGenFramework.sh  
  |1 +
 uefi-sct/SctPkg/Config/Data/Category.ini   
  |7 +
 10 files changed, 1985 insertions(+)
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c

-- 
2.34.1



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




Re: [edk2-devel] [PATCH] DynamicTablesPkg/SSDT: Remove incorrect root node check

2024-01-09 Thread Jeshua Smith via groups.io
> > Two physical packages are on a multi-chip module and share resources on
> the module. The module then plugs into the baseboard/motherboard.
> 
> Is it possible to elaborate on the resource being shared ?

In our specific case the problem is related to the PPTT's "Identical 
Implementation" flag. We need a top level node above the physical package nodes 
to be able to set the "Identical Implementation" flag to indicate that all of 
the procs in all of the child packages are the same identical implementation. 
Without this (ie. forcing each physical package to be its own root node) Linux 
will fail to load the SPE driver when there are multiple identical packages 
because it detects that some of the procs have a different root node than other 
procs, implying that the packages don't have identical implementations.

> Does it fall into the subject of this thread ? Some resources might be aswell
> described in other ACPI tables.

The thread you linked looks like it is about non-processor resources, and 
therefore wasn't in scope for PPTT. I don't think this is related.

> > Note: While investigating this we noticed that another vendor also has a
> similar PPTT topology to what is being flagged as invalid, so either that 
> vendor
> isn't using EDK2 or they have done something to avoid this check without
> submitting a patch to EDK2.
> 
> This check is only present in the DynamicTablesPkg, so it shouldn't be too
> restrictive.

Ah, correct. If they're not using DynamicTablesPkg to generate the PPTT/SSDT, 
then they wouldn't hit this.

> If the platform is known to use it, is it possible to share which platform it 
> is ?

We see the topology in question (ie. a root node is a parent node to physical 
package nodes) in Ampere's two-socket Altra PPTT.


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




Re: [edk2-devel] [PATCH v5 3/3] OvmfPkg/VirtNorFlashDxe: sanity-check variables

2024-01-09 Thread Laszlo Ersek
On 1/9/24 15:11, Gerd Hoffmann wrote:
>   Hi,
> 
>> Nit: to my knowledge, the coding style forbids initialization of "auto"
>> storage class variables (more commonly put, "non-static local
>> variables"). IOW, we should spell the above as:
>>
>> | diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c 
>> b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
>> | index ca2e40743dfd..8fcd999ac6df 100644
>> | --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
>> | +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
>> | @@ -283,7 +283,9 @@ ValidateFvHeader (
>> |
>> |  if (VarHeaderEnd >= VariableStoreHeader->Size) {
>> |if (VarOffset <= VariableStoreHeader->Size - sizeof (UINT16)) {
>> | -CONST UINT16  *StartId = (VOID *)((UINTN)VariableStoreHeader + 
>> VarOffset);
>> | +CONST UINT16  *StartId;
>> | +
>> | +StartId = (VOID *)((UINTN)VariableStoreHeader + VarOffset);
>> |  if (*StartId == 0x55aa) {
>> |DEBUG ((DEBUG_ERROR, "%a: startid at invalid location\n", 
>> __func__));
>> |return EFI_NOT_FOUND;
>>
>> Do you want me to fix up the patch upon merge for you,
> 
> I happily accept that service offer ;)

Series merged as commit range 08a6528bac38..4a443f73fd67, via
. (Last three commits in
the PR.)

Laszlo



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




Re: [edk2-devel] [Patch V3 0/2] Change the usage of input parameter ProcessorNumber in MpInitLibGetProcessorInfo() of MpInitLibUp

2024-01-09 Thread Laszlo Ersek
On 1/8/24 06:08, duntan wrote:
> Please ignore the V2 PATCH set. No other change except adding BaseMemoryLib 
> headfile and lib instance in .inf to pass build since ZeroMem() is used. 
> 
> Comparing to the V1 patch set:
> In "set EXTENDED_PROCESSOR_INFORMATION to 0", set 
> EXTENDED_PROCESSOR_INFORMATION to 0 in API MpInitLibGetProcessorInfo() of 
> MpInitLibUp. This commit use ZeroMem() to set all fileds in output 
> EFI_PROCESSOR_INFORMATION to 0 before StatusFlag field is reassigned.
> 
> In "Check lower 24 bits of ProcessorNumber", use BIT24 instead of 
> CPU_V2_EXTENDED_TOPOLOGY to clearly tell that processor number only occupies 
> the lower 24 bits.
> 
> Dun Tan (2):
>   UefiCpuPkg: set EXTENDED_PROCESSOR_INFORMATION to 0
>   UefiCpuPkg: Check lower 24 bits of ProcessorNumber
> 
>  UefiCpuPkg/Include/Library/MpInitLib.h |  2 ++
>  UefiCpuPkg/Library/MpInitLib/MpLib.c   |  2 ++
>  UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c   | 20 
>  UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf |  1 +
>  4 files changed, 17 insertions(+), 8 deletions(-)
> 

Merged as commit range f2b074398ca0..08a6528bac38, via
 (first two commits in the PR).

BR
Laszlo



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




[edk2-devel] [RFC PATCH v1 20/20] DynamicTablesPkg.ci.yaml: Update exception and ignore list

2024-01-09 Thread Sunil V L
GICV, GICH and MPIDR are variables defined in GicCInfo structure which
probably needs to match AcpiTable.g to be all capital. But this is
against EDK2 coding standards and somehow CI gives error now though it
exists currently also. Add them to ignore list unless there is a better
way.

Add EARCH and NAMESPACEID to ignore list of the spell checker to keep CI
happy.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 DynamicTablesPkg/DynamicTablesPkg.ci.yaml | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.ci.yaml 
b/DynamicTablesPkg/DynamicTablesPkg.ci.yaml
index 42829f393e69..2bf8859d6c9e 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.ci.yaml
+++ b/DynamicTablesPkg/DynamicTablesPkg.ci.yaml
@@ -24,6 +24,9 @@
 "9005", "@ingroup",   # Use extra Doxygen commands
 "9005", "@mainpage",  # Use extra Doxygen commands
 "9005", "@ref",   # Use extra Doxygen commands
+"8005", "CM_ARCH_GICC_INFO.GICV",
+"8005", "CM_ARCH_GICC_INFO.GICH",
+"8005", "CM_ARCH_GICC_INFO.MPIDR",
 ],
 ## Both file path and directory path are accepted.
 "IgnoreFiles": [
@@ -128,7 +131,9 @@
"TABLEEX",
"TNSID",
"Vatos",
-   "WBINVD"
+   "WBINVD",
+   "EARCH",
+   "NAMESPACEID"
],   # words to extend to the dictionary for this package
 "IgnoreStandardPaths": [],   # Standard Plugin defined paths that
  # should be ignore
-- 
2.34.1



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




[edk2-devel] [RFC PATCH v1 19/20] DynamicTablesPkg/AmlLib: Fix typo

2024-01-09 Thread Sunil V L
For some reason, spell checker in CI finds this typo though it existed
earlier.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c | 2 +-
 DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNode.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c 
b/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
index d3a51a94c70c..3762441c7a71 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
@@ -330,7 +330,7 @@ AmlParseString (
   StrSize = 0;
   // AML String is NULL terminated.
   do {
-// Reading the stream moves the stream forward aswell.
+// Reading the stream moves the stream forward as well.
 Status = AmlStreamReadByte (FStream, &Byte);
 if (EFI_ERROR (Status)) {
   ASSERT (0);
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNode.c 
b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNode.c
index 1404a2182b65..0a744f1ff3fa 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNode.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNode.c
@@ -573,7 +573,7 @@ AmlIsMethodDefinitionNode (
 {
   AML_DATA_NODE  *ObjectType;
 
-  // Node is checked to be an object node aswell.
+  // Node is checked to be an object node as well.
   if (AmlNodeCompareOpCode (Node, AML_METHOD_OP, 0)) {
 return TRUE;
   } else if (AmlNodeCompareOpCode (Node, AML_EXTERNAL_OP, 0)) {
-- 
2.34.1



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




[edk2-devel] [RFC PATCH v1 18/20] DynamicTablesPkg: X86: Add interfaces to succeed CI tests

2024-01-09 Thread Sunil V L
CI tests builds DynamicTablesPkg even for X86. Though the current ACPI
table list is very ARM specific, it looks like there is a value in
building it for x86. So, add dummy interfaces to help CI tests to
succeed.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../DynamicTableManagerDxe.inf|  5 ++-
 .../X86DynamicTableManagerDxe.c   | 44 +++
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 
DynamicTablesPkg/Drivers/DynamicTableManagerDxe/X86DynamicTableManagerDxe.c

diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
index b49f6b811691..646454a64bc2 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
@@ -17,7 +17,7 @@ [Defines]
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = ARM AARCH64
+#  VALID_ARCHITECTURES   = ARM AARCH64 IA32 X64
 #
 
 [Sources]
@@ -27,6 +27,9 @@ [Sources]
 [Sources.ARM, Sources.AARCH64]
   ArmDynamicTableManagerDxe.c
 
+[Sources.IA32, Sources.X64]
+  X86DynamicTableManagerDxe.c
+
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/X86DynamicTableManagerDxe.c 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/X86DynamicTableManagerDxe.c
new file mode 100644
index ..f8b35eeb1c3c
--- /dev/null
+++ 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/X86DynamicTableManagerDxe.c
@@ -0,0 +1,44 @@
+/** @file
+  X86 Dynamic Table Manager Dxe
+
+  Copyright (c) 2024, Ventana Micro Systems Inc. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include "DynamicTableManagerDxe.h"
+
+// TODO: Dummy interfaces for X86 for now.
+
+/** The function checks if the Configuration Manager has provided the
+mandatory ACPI tables for installation.
+
+  @param [in]  AcpiTableInfo  Pointer to the ACPI Table Info list.
+  @param [in]  AcpiTableCount Count of ACPI Table Info.
+
+  @retval EFI_SUCCESS Success.
+**/
+EFI_STATUS
+EFIAPI
+VerifyMandatoryTablesArePresent (
+  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO  *CONST  AcpiTableInfo,
+  IN   UINT32  AcpiTableCount
+  )
+{
+  return EFI_SUCCESS;
+}
+
+/** The function checks if the FADT table is present and installed
+
+  @retval TRUE  FADT is present and installed.
+**/
+BOOLEAN
+IsFadtPresentInstalled (
+  VOID
+  )
+{
+  return TRUE;
+}
-- 
2.34.1



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




[edk2-devel] [RFC PATCH v1 17/20] DynamicTablesPkg: DynamicTableManagerDxe: Refactor to allow other archs

2024-01-09 Thread Sunil V L
mAcpiVerifyTables is an arch specific structure. So, move the structure
and the function which refers this structure to ARM specific file.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../DynamicTableManagerDxe.inf|   4 +
 .../DynamicTableManagerDxe.h  |  65 
 .../ArmDynamicTableManagerDxe.c   | 154 ++
 .../DynamicTableManagerDxe.c  | 145 +
 4 files changed, 225 insertions(+), 143 deletions(-)
 create mode 100644 
DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.h
 create mode 100644 
DynamicTablesPkg/Drivers/DynamicTableManagerDxe/ArmDynamicTableManagerDxe.c

diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
index ad8b3d037c16..b49f6b811691 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
@@ -22,6 +22,10 @@ [Defines]
 
 [Sources]
   DynamicTableManagerDxe.c
+  DynamicTableManagerDxe.h
+
+[Sources.ARM, Sources.AARCH64]
+  ArmDynamicTableManagerDxe.c
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.h 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.h
new file mode 100644
index ..0149d9de1bdc
--- /dev/null
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.h
@@ -0,0 +1,65 @@
+/** @file
+
+  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
+  Copyright (c) 2024, Ventana Micro Systems Inc. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef DYNAMIC_TABLE_MANAGER_DXE_H_
+#define DYNAMIC_TABLE_MANAGER_DXE_H_
+
+#include 
+
+///
+/// Bit definitions for acceptable ACPI table presence formats.
+/// Currently only ACPI tables present in the ACPI info list and
+/// already installed will count towards "Table Present" during
+/// verification routine.
+///
+#define ACPI_TABLE_PRESENT_INFO_LIST  BIT0
+#define ACPI_TABLE_PRESENT_INSTALLED  BIT1
+
+///
+/// Private data structure to verify the presence of mandatory
+/// or optional ACPI tables.
+///
+typedef struct {
+  /// ESTD ID for the ACPI table of interest.
+  ESTD_ACPI_TABLE_IDEstdTableId;
+  /// Standard UINT32 ACPI signature.
+  UINT32AcpiTableSignature;
+  /// 4 character ACPI table name (the 5th char8 is for null terminator).
+  CHAR8 AcpiTableName[sizeof (UINT32) + 1];
+  /// Indicator on whether the ACPI table is required.
+  BOOLEAN   IsMandatory;
+  /// Formats of verified presences, as defined by ACPI_TABLE_PRESENT_*
+  /// This field should be initialized to 0 and will be populated during
+  /// verification routine.
+  UINT16Presence;
+} ACPI_TABLE_PRESENCE_INFO;
+
+BOOLEAN
+IsFadtPresentInstalled (
+  VOID
+  );
+
+/** The function checks if the Configuration Manager has provided the
+mandatory ACPI tables for installation.
+
+  @param [in]  AcpiTableInfo  Pointer to the ACPI Table Info list.
+  @param [in]  AcpiTableCount Count of ACPI Table Info.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_NOT_FOUND If mandatory table is not found.
+  @retval EFI_ALREADY_STARTED   If mandatory table found in AcpiTableInfo is 
already installed.
+**/
+EFI_STATUS
+EFIAPI
+VerifyMandatoryTablesArePresent (
+  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO  *CONST  AcpiTableInfo,
+  IN   UINT32  AcpiTableCount
+  );
+
+#endif // DYNAMIC_TABLE_MANAGER_DXE_H_
diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/ArmDynamicTableManagerDxe.c 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/ArmDynamicTableManagerDxe.c
new file mode 100644
index ..19ba501752b9
--- /dev/null
+++ 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/ArmDynamicTableManagerDxe.c
@@ -0,0 +1,154 @@
+/** @file
+  ARM Dynamic Table Manager Dxe
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "DynamicTableManagerDxe.h"
+
+///
+/// Order of ACPI table being verified during presence inspection.
+///
+#define ACPI_TABLE_VERIFY_FADT   0
+#define ACPI_TABLE_VERIFY_MADT   1
+#define ACPI_TABLE_VERIFY_GTDT   2
+#define ACPI_TABLE_VERIFY_DSDT   3
+#define ACPI_TABLE_VERIFY_DBG2   4
+#define ACPI_TABLE_VERIFY_SPCR   5
+#define ACPI_TABLE_VERIFY_COUNT  6
+
+///
+/// We require the FADT, MADT, GTDT and the DSDT tables to boot.
+/// This list also include optional ACPI tables: DBG2, SPCR.
+///
+ACPI_TABLE_PRESENCE_INFO  mAcpiVerifyT

[edk2-devel] [RFC PATCH v1 15/20] DynamicTablesPkg: AcpiSsdtCpuTopologyLib: Move GICC from common code

2024-01-09 Thread Sunil V L
GICC is ARM specific structure. Different architectures have different
local interrupt controller structures from which CPU topology can be
created. Avoid the GICC reference in common code by,

- creating a wrapper CreateTopologyFromIntC() instead of
  CreateTopologyFromGicC() so that different archs can implement
  it differently.
- Implement arch specific functions to get AcpiProcessorUid,
  CpcToken, EtToken and use them instead of using GICC directly.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../SsdtCpuTopologyLib.inf|   3 +
 .../SsdtCpuTopologyGenerator.h|  48 +
 .../ArmSsdtCpuTopologyGenerator.c | 179 +
 .../SsdtCpuTopologyGenerator.c| 184 +-
 4 files changed, 274 insertions(+), 140 deletions(-)
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/ArmSsdtCpuTopologyGenerator.c

diff --git 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf
 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf
index 2d38fb30fb09..6ec4aeeae159 100644
--- 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf
+++ 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf
@@ -16,6 +16,9 @@ [Defines]
   CONSTRUCTOR= AcpiSsdtCpuTopologyLibConstructor
   DESTRUCTOR = AcpiSsdtCpuTopologyLibDestructor
 
+[Sources.ARM, Sources.AARCH64]
+  ArmSsdtCpuTopologyGenerator.c
+
 [Sources]
   SsdtCpuTopologyGenerator.c
   SsdtCpuTopologyGenerator.h
diff --git 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyGenerator.h
 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyGenerator.h
index 57ff8009b59d..872c5c010d5c 100644
--- 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyGenerator.h
+++ 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyGenerator.h
@@ -144,4 +144,52 @@ typedef struct AcpiCpuTopologyGenerator {
 
 #pragma pack()
 
+EFI_STATUS
+EFIAPI
+GetIntCUidTokens (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  IN  CM_OBJECT_TOKEN IntCToken,
+  OUT UINT32  *AcpiProcessorUid,
+  OUT CM_OBJECT_TOKEN *CpcToken,
+  OUT CM_OBJECT_TOKEN *EtToken
+  );
+
+EFI_STATUS
+EFIAPI
+CreateAmlEtNode (
+  IN  ACPI_CPU_TOPOLOGY_GENERATOR *Generator,
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  IN  UINT32  AcpiProcessorUid,
+  IN  CM_OBJECT_TOKEN EtToken,
+  IN  UINT32  CpuName,
+  IN  AML_OBJECT_NODE_HANDLE  *Node
+  );
+
+EFI_STATUS
+EFIAPI
+CreateAmlCpcNode (
+  IN  ACPI_CPU_TOPOLOGY_GENERATOR *Generator,
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  IN  CM_OBJECT_TOKEN CpcToken,
+  IN  AML_OBJECT_NODE_HANDLE  *Node
+  );
+
+EFI_STATUS
+EFIAPI
+CreateAmlCpu (
+  IN   ACPI_CPU_TOPOLOGY_GENERATOR  *Generator,
+  IN   AML_NODE_HANDLE  ParentNode,
+  IN   UINT32   Uid,
+  IN   UINT32   CpuName,
+  OUT  AML_OBJECT_NODE_HANDLE   *CpuNodePtr OPTIONAL
+  );
+
+EFI_STATUS
+EFIAPI
+CreateTopologyFromIntC (
+  INACPI_CPU_TOPOLOGY_GENERATOR   *Generator,
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  INAML_OBJECT_NODE_HANDLEScopeNode
+  );
+
 #endif // SSDT_CPU_TOPOLOGY_GENERATOR_H_
diff --git 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/ArmSsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/ArmSsdtCpuTopologyGenerator.c
new file mode 100644
index ..3078c206224f
--- /dev/null
+++ 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/ArmSsdtCpuTopologyGenerator.c
@@ -0,0 +1,179 @@
+/** @file
+  ARM SSDT Cpu Topology Table Generator Helpers.
+
+  Copyright (c) 2021 - 2023, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+- ACPI 6.3 Specification - January 2019 - s8.4 Declaring Processors
+- ACPI for CoreSight version 1.2 Platform Design Document
+  (https://developer.arm.com/documentation/den0067/a/?lang=en)
+
+  @par Glossary:
+- ETE - Embedded Trace Extension.
+- ETM - Embedded Trace Macrocell.
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#inc

[edk2-devel] [RFC PATCH v1 16/20] DynamicTablesPkg: AcpiFadtLib: Move ArmBootArch to ARM specific file

2024-01-09 Thread Sunil V L
ArmBootArch field in FADT is specific to ARM. To leverage most of the
code in FADT generator for other architectures, this needs to be moved
into ARM specific file. There may be other fields in future (ex:
IA_PC_BOOT_ARCH) that need to be created in similar way. So, instead of
adding the function only to create BootArch, make this function generic
to add all arch specific functions into FADT.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf   |  4 +
 .../Acpi/Common/AcpiFadtLib/FadtGenerator.h   | 32 
 .../Common/AcpiFadtLib/ArmFadtGenerator.c | 80 +++
 .../Acpi/Common/AcpiFadtLib/FadtGenerator.c   | 71 ++--
 .../Arm/BootArch/ArmBootArchParser.c  |  8 +-
 5 files changed, 125 insertions(+), 70 deletions(-)
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/ArmFadtGenerator.c

diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
index c9cd850faac0..1ea47aefc3e1 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
@@ -18,6 +18,10 @@ [Defines]
 
 [Sources]
   FadtGenerator.c
+  FadtGenerator.h
+
+[Sources.ARM, Sources.AARCH64]
+  ArmFadtGenerator.c
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h
new file mode 100644
index ..bb98ea4c8854
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h
@@ -0,0 +1,32 @@
+/** @file
+
+  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
+  Copyright (c) 2024, Ventana Micro Systems Inc. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FADT_GENERATOR_H_
+#define FADT_GENERATOR_H_
+
+/** Updates the Architecture specific information in the FADT Table.
+
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+  Protocol Interface.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object was not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+Manager is less than the Object size for the
+requested object.
+**/
+EFI_STATUS
+EFIAPI
+FadtAddArchInfo (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE   *Fadt
+  );
+
+#endif // FADT_GENERATOR_H_
diff --git 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/ArmFadtGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/ArmFadtGenerator.c
new file mode 100644
index ..ca4f6958a5b9
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/ArmFadtGenerator.c
@@ -0,0 +1,80 @@
+/** @file
+  ARM FADT Table Helpers
+
+  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+  - ACPI 6.5 Specification, Aug 29, 2022
+
+**/
+
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "FadtGenerator.h"
+
+/** This macro expands to a function that retrieves the Boot
+Architecture Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArch,
+  EArchObjBootArchInfo,
+  CM_ARCH_BOOT_ARCH_INFO
+  );
+
+/** Updates the Architecture specific information in the FADT Table.
+
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+  Protocol Interface.
+  @param [out] Fadt   Pointer to the FADT table
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_NOT_FOUND The required object was not found.
+**/
+EFI_STATUS
+EFIAPI
+FadtAddArchInfo (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE   *Fadt
+  )
+{
+  EFI_STATUS  Status;
+  CM_ARCH_BOOT_ARCH_INFO  *BootArchInfo;
+
+  ASSERT (CfgMgrProtocol != NULL);
+
+  // Get the Boot Architecture flags from the Platform Configuration Manager
+  Status = GetEArchObjBootArchInfo (
+ CfgMgrProtocol,
+ CM_NULL_TOKEN,
+ &BootArchInfo,
+ NULL
+ );
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "ERROR: FADT: Failed to get Boot Architecture flags. Status = %r\n",
+  Status
+  ));
+goto error_handler;
+  }
+
+  DEBUG ((
+DEBUG_INFO,
+"FADT BootArchFlag = 0x%x\n",
+BootArchInfo->

[edk2-devel] [RFC PATCH v1 14/20] DynamicTablesPkg/FdtHwInfoParserLib: Add function for INTC address cells

2024-01-09 Thread Sunil V L
Parent interrupt controller's address cells is arch specific. So,
create a function which can be implemented differently for
different archs. Move current implementation to ARM specific file.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../Library/FdtHwInfoParserLib/FdtUtility.h   |  9 ++
 .../FdtHwInfoParserLib/Arm/ArmFdtUtility.c| 29 +++
 .../Pci/PciConfigSpaceParser.c|  2 +-
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h
index 3f5d131d9ae5..1d56d044a73e 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h
@@ -455,4 +455,13 @@ FdtGetParentAddressInfo (
   OUT   INT32 *SizeCells   OPTIONAL
   );
 
+EFI_STATUS
+EFIAPI
+FdtGetIntcAddressCells (
+  IN  CONST VOID *Fdt,
+  ININT32 Node,
+  OUT   INT32 *AddressCells, OPTIONAL
+  OUT   INT32 *SizeCells   OPTIONAL
+  );
+
 #endif // FDT_UTILITY_H_
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
index 21b1306e577d..1b2196ef1734 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
@@ -83,3 +83,32 @@ FdtGetInterruptFlags (
 
   return AcpiIrqFlags;
 }
+
+/** Get the Address cell info of the INTC node
+
+  @param [in]  Fdt  Pointer to a Flattened Device Tree.
+  @param [in]  Node Offset of the node having to get the
+"#address-cells" and "#size-cells"
+properties from.
+  @param [out] AddressCells If success, number of address-cells.
+If the property is not available,
+default value is 2.
+  @param [out] SizeCellsIf success, number of size-cells.
+If the property is not available,
+default value is 1.
+
+  @retval EFI_SUCCESS The function completed successfully.
+  @retval EFI_ABORTED An error occurred.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+FdtGetIntcAddressCells (
+  IN  CONST VOID *Fdt,
+  ININT32 Node,
+  OUT   INT32 *AddressCells, OPTIONAL
+  OUT   INT32 *SizeCells OPTIONAL
+  )
+{
+  return FdtGetAddressInfo (Fdt, Node, AddressCells, SizeCells);
+}
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
index afe756bcedab..766f784da13c 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
@@ -365,7 +365,7 @@ ParseIrqMap (
   }
 
   // Get the "address-cells" property of the IntcNode.
-  Status = FdtGetAddressInfo (Fdt, IntcNode, &IntcAddressCells, NULL);
+  Status = FdtGetIntcAddressCells (Fdt, IntcNode, &IntcAddressCells, NULL);
   if (EFI_ERROR (Status)) {
 ASSERT (0);
 return Status;
-- 
2.34.1



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




[edk2-devel] [RFC PATCH v1 13/20] DynamicTablesPkg: FdtHwInfoParserLib: Move ARM utilities to separate file

2024-01-09 Thread Sunil V L
The SPI/PPI ranges are ARM specific and the number of entries in
"interrupt-map" property can be different across architectures. Hence,
move these utility functions to ARM specific file so that common code is
clean and other architectures can easily implement their version.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf |  1 +
 .../FdtHwInfoParserLib/Arm/ArmFdtUtility.c| 85 +++
 .../Library/FdtHwInfoParserLib/FdtUtility.c   | 71 
 3 files changed, 86 insertions(+), 71 deletions(-)
 create mode 100644 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c

diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
index d3010af527c1..8e1ea100bd34 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
@@ -28,6 +28,7 @@ [Sources]
   Serial/SerialPortParser.h
 
 [Sources.ARM, Sources.AARCH64]
+  Arm/ArmFdtUtility.c
   Arm/ArmFdtHwInfoParser.c
   Arm/BootArch/ArmBootArchParser.c
   Arm/BootArch/ArmBootArchParser.h
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
new file mode 100644
index ..21b1306e577d
--- /dev/null
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
@@ -0,0 +1,85 @@
+/** @file
+  Flattened device tree utility.
+
+  Copyright (c) 2021, ARM Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+  - Device tree Specification - Release v0.3
+  - linux/Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic.yaml
+  - 
linux//Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic.yaml
+**/
+
+#include 
+#include "FdtUtility.h"
+
+/** Get the interrupt Id of an interrupt described in a fdt.
+
+  Data must describe a GIC interrupt. A GIC interrupt is on at least
+  3 UINT32 cells.
+  This function DOES NOT SUPPORT extended SPI range and extended PPI range.
+
+  @param [in]  Data   Pointer to the first cell of an "interrupts" property.
+
+  @retval  The interrupt id.
+**/
+UINT32
+EFIAPI
+FdtGetInterruptId (
+  UINT32 CONST  *Data
+  )
+{
+  UINT32  IrqType;
+  UINT32  IrqId;
+
+  ASSERT (Data != NULL);
+
+  IrqType = fdt32_to_cpu (Data[IRQ_TYPE_OFFSET]);
+  IrqId   = fdt32_to_cpu (Data[IRQ_NUMBER_OFFSET]);
+
+  switch (IrqType) {
+case DT_SPI_IRQ:
+  IrqId += SPI_OFFSET;
+  break;
+
+case DT_PPI_IRQ:
+  IrqId += PPI_OFFSET;
+  break;
+
+default:
+  ASSERT (0);
+  IrqId = 0;
+  }
+
+  return IrqId;
+}
+
+/** Get the ACPI interrupt flags of an interrupt described in a fdt.
+
+  Data must describe a GIC interrupt. A GIC interrupt is on at least
+  3 UINT32 cells.
+
+  PPI interrupt cpu mask on bits [15:8] are ignored.
+
+  @param [in]  Data   Pointer to the first cell of an "interrupts" property.
+
+  @retval  The interrupt flags (for ACPI).
+**/
+UINT32
+EFIAPI
+FdtGetInterruptFlags (
+  UINT32 CONST  *Data
+  )
+{
+  UINT32  IrqFlags;
+  UINT32  AcpiIrqFlags;
+
+  ASSERT (Data != NULL);
+
+  IrqFlags = fdt32_to_cpu (Data[IRQ_FLAGS_OFFSET]);
+
+  AcpiIrqFlags  = DT_IRQ_IS_EDGE_TRIGGERED (IrqFlags) ? BIT0 : 0;
+  AcpiIrqFlags |= DT_IRQ_IS_ACTIVE_LOW (IrqFlags) ? BIT1 : 0;
+
+  return AcpiIrqFlags;
+}
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
index 5314cf3808c2..bab228575938 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
@@ -13,77 +13,6 @@
 #include 
 #include "FdtUtility.h"
 
-/** Get the interrupt Id of an interrupt described in a fdt.
-
-  Data must describe a GIC interrupt. A GIC interrupt is on at least
-  3 UINT32 cells.
-  This function DOES NOT SUPPORT extended SPI range and extended PPI range.
-
-  @param [in]  Data   Pointer to the first cell of an "interrupts" property.
-
-  @retval  The interrupt id.
-**/
-UINT32
-EFIAPI
-FdtGetInterruptId (
-  UINT32 CONST  *Data
-  )
-{
-  UINT32  IrqType;
-  UINT32  IrqId;
-
-  ASSERT (Data != NULL);
-
-  IrqType = fdt32_to_cpu (Data[IRQ_TYPE_OFFSET]);
-  IrqId   = fdt32_to_cpu (Data[IRQ_NUMBER_OFFSET]);
-
-  switch (IrqType) {
-case DT_SPI_IRQ:
-  IrqId += SPI_OFFSET;
-  break;
-
-case DT_PPI_IRQ:
-  IrqId += PPI_OFFSET;
-  break;
-
-default:
-  ASSERT (0);
-  IrqId = 0;
-  }
-
-  return IrqId;
-}
-
-/** Get the ACPI interrupt flags of an interrupt described in a fdt.
-
-  Data must describe a GIC interrupt. A GIC interrupt is on at least
-  3 UINT32 cells.
-
-  PPI interrupt cpu mask on bits [15:8] are ignored.
-
-  @param [in]  Data   Pointer to the first cell of an "interrupts" property

[edk2-devel] [RFC PATCH v1 12/20] DynamicTablesPkg: Add CreatorId in CM_STD_OBJ_CONFIGURATION_MANAGER_INFO

2024-01-09 Thread Sunil V L
To support multiple CPU architectures and platforms, it is better to
have the flexibility for the platforms to define their Creator ID in the
ACPI tables. So, add a new field in the structure and use it while
creating the ACPI tables instead of default ARM.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h  | 1 +
 DynamicTablesPkg/Include/StandardNameSpaceObjects.h   | 1 +
 .../Library/Common/AmlLib/CodeGen/AmlCodeGen.c| 3 ++-
 .../Library/Common/TableHelperLib/TableHelper.c   | 8 +++-
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 043ec3d8428f..dc1fab534030 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -1061,6 +1061,7 @@ AmlCodeGenDefinitionBlock (
   IN  CONST CHAR8 *OemId,
   IN  CONST CHAR8 *OemTableId,
   INUINT32OemRevision,
+  IN  CONST CHAR8 *CreatorId,
   OUT   AML_ROOT_NODE_HANDLE  *NewRootNode
   );
 
diff --git a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h 
b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
index 8ec3238225ab..d894b9cbb6f9 100644
--- a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
@@ -60,6 +60,7 @@ typedef struct CmStdObjConfigurationManagerInfo {
   populate the ACPI table header information.
   */
   UINT8 OemId[6];
+  UINT8 CreatorId[4];
 } CM_STD_OBJ_CONFIGURATION_MANAGER_INFO;
 
 /** A structure used to describe the ACPI table generators to be invoked.
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index d4e3e252cbe6..e1d72ec9444e 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -95,6 +95,7 @@ AmlCodeGenDefinitionBlock (
   IN  CONST CHAR8  *OemId,
   IN  CONST CHAR8  *OemTableId,
   INUINT32 OemRevision,
+  IN  CONST CHAR8  *CreatorId,
   OUT   AML_ROOT_NODE  **NewRootNode
   )
 {
@@ -115,8 +116,8 @@ AmlCodeGenDefinitionBlock (
   AcpiHeader.Revision = 2;
   CopyMem (&AcpiHeader.OemId, OemId, 6);
   CopyMem (&AcpiHeader.OemTableId, OemTableId, 8);
+  CopyMem (&AcpiHeader.CreatorId, CreatorId, 4);
   AcpiHeader.OemRevision = OemRevision;
-  AcpiHeader.CreatorId   = TABLE_GENERATOR_CREATOR_ID_ARM;
   AcpiHeader.CreatorRevision = CREATE_REVISION (1, 0);
 
   Status = AmlCreateRootNode (&AcpiHeader, NewRootNode);
diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c 
b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
index 219f94e0dbcc..a2ad480b9b3b 100644
--- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
+++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
@@ -180,7 +180,12 @@ AddAcpiHeader (
   }
 
   // UINT32  CreatorId
-  AcpiHeader->CreatorId = Generator->CreatorId;
+  AcpiHeader->CreatorId = SIGNATURE_32 (
+CfgMfrInfo->CreatorId[0],
+CfgMfrInfo->CreatorId[1],
+CfgMfrInfo->CreatorId[2],
+CfgMfrInfo->CreatorId[3]
+);
   // UINT32  CreatorRevision
   AcpiHeader->CreatorRevision = Generator->CreatorRevision;
 
@@ -270,6 +275,7 @@ AddSsdtAcpiHeader (
  (CONST CHAR8 *)&CfgMfrInfo->OemId,
  (CONST CHAR8 *)&OemTableId,
  OemRevision,
+ (CONST CHAR8 *)&CfgMfrInfo->CreatorId,
  RootNode
  );
   ASSERT_EFI_ERROR (Status);
-- 
2.34.1



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




[edk2-devel] [RFC PATCH v1 11/20] DynamicTablesPkg: TableHelperLib: Populate OemTableId using ConfigManager

2024-01-09 Thread Sunil V L
To support multiple CPU architectures/vendors, it is better to create
OemTableId using the platform provided value instead of default ARM.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../Common/TableHelperLib/TableHelper.c   | 24 ---
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c 
b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
index 549cee1b3fd5..219f94e0dbcc 100644
--- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
+++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
@@ -161,20 +161,16 @@ AddAcpiHeader (
   CopyMem (AcpiHeader->OemId, CfgMfrInfo->OemId, sizeof (AcpiHeader->OemId));
 
   // UINT64  OemTableId
-  if (AcpiTableInfo->OemTableId != 0) {
-AcpiHeader->OemTableId = AcpiTableInfo->OemTableId;
-  } else {
-AcpiHeader->OemTableId = SIGNATURE_32 (
-   CfgMfrInfo->OemId[0],
-   CfgMfrInfo->OemId[1],
-   CfgMfrInfo->OemId[2],
-   CfgMfrInfo->OemId[3]
-   ) |
- LShiftU64 (
-   (UINT64)Generator->AcpiTableSignature,
-   32
-   );
-  }
+  AcpiHeader->OemTableId = SIGNATURE_32 (
+ CfgMfrInfo->OemId[0],
+ CfgMfrInfo->OemId[1],
+ CfgMfrInfo->OemId[2],
+ CfgMfrInfo->OemId[3]
+ ) |
+   LShiftU64 (
+ (UINT64)Generator->AcpiTableSignature,
+ 32
+ );
 
   // UINT32  OemRevision
   if (AcpiTableInfo->OemRevision != 0) {
-- 
2.34.1



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




[edk2-devel] [RFC PATCH v1 10/20] DynamicTablesPkg: FdtHwInfoParserLib: Move ArmLib.h to ArmGicCParser.c

2024-01-09 Thread Sunil V L
ArmLib.h is required only for building GIC in ARM. So, move it to ARM
specific file. Otherwise, FdtHwInfoParserInclude.h being a common header
across architectures will have issue on other architectures.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h  | 1 -
 .../Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c   | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h
index 583f290095d9..60f671eccc3f 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h
@@ -10,7 +10,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c
index e5cf5c776d0f..bd4de8811963 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c
@@ -11,6 +11,7 @@
   - linux/Documentation/devicetree/bindings/arm/pmu.yaml
 **/
 
+#include 
 #include "FdtHwInfoParser.h"
 #include "CmObjectDescUtility.h"
 #include "Arm/Gic/ArmGicCParser.h"
-- 
2.34.1



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




[edk2-devel] [RFC PATCH v1 09/20] DynamicTablesPkg: FdtHwInfoParserLib: Make Serial parser arch neutral

2024-01-09 Thread Sunil V L
SerialPortParser is a generic concept and can be used by other
architectures. Hence, rename to reflect it is common and updates the
consumers.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf  |  4 ++--
 ...rmSerialPortParser.h => SerialPortParser.h} |  8 
 .../Arm/ArmFdtHwInfoParser.c   |  2 +-
 ...rmSerialPortParser.c => SerialPortParser.c} | 18 +-
 4 files changed, 16 insertions(+), 16 deletions(-)
 rename 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/{ArmSerialPortParser.h => 
SerialPortParser.h} (89%)
 rename 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/{ArmSerialPortParser.c => 
SerialPortParser.c} (94%)

diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
index 55ec7d97fa18..d3010af527c1 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
@@ -24,8 +24,8 @@ [Sources]
   FdtUtility.h
   Pci/PciConfigSpaceParser.c
   Pci/PciConfigSpaceParser.h
-  Serial/ArmSerialPortParser.c
-  Serial/ArmSerialPortParser.h
+  Serial/SerialPortParser.c
+  Serial/SerialPortParser.h
 
 [Sources.ARM, Sources.AARCH64]
   Arm/ArmFdtHwInfoParser.c
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/ArmSerialPortParser.h 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.h
similarity index 89%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/ArmSerialPortParser.h
rename to DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.h
index b3e227472772..e5f151ded329 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/ArmSerialPortParser.h
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.h
@@ -1,5 +1,5 @@
 /** @file
-  Arm Serial Port Parser.
+  Serial Port Parser.
 
   Copyright (c) 2021, ARM Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -9,8 +9,8 @@
   - linux/Documentation/devicetree/bindings/serial/8250.txt
 **/
 
-#ifndef ARM_SERIAL_PORT_PARSER_H_
-#define ARM_SERIAL_PORT_PARSER_H_
+#ifndef SERIAL_PORT_PARSER_H_
+#define SERIAL_PORT_PARSER_H_
 
 /** SerialPort dispatcher.
 
@@ -44,4 +44,4 @@ SerialPortDispatcher (
   ININT32  FdtBranch
   );
 
-#endif // ARM_SERIAL_PORT_PARSER_H_
+#endif // SERIAL_PORT_PARSER_H_
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
index 8dd6546e62f0..2700e9a2a5fe 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
@@ -10,7 +10,7 @@
 #include "Arm/GenericTimer/ArmGenericTimerParser.h"
 #include "Arm/Gic/ArmGicDispatcher.h"
 #include "Pci/PciConfigSpaceParser.h"
-#include "Serial/ArmSerialPortParser.h"
+#include "Serial/SerialPortParser.h"
 
 /** Ordered table of parsers/dispatchers.
 
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/ArmSerialPortParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.c
similarity index 94%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/ArmSerialPortParser.c
rename to DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.c
index 47df82c4ba63..6d233fefa85f 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/ArmSerialPortParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.c
@@ -1,5 +1,5 @@
 /** @file
-  Arm Serial Port Parser.
+  Serial Port Parser.
 
   Copyright (c) 2021 - 2023, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -15,7 +15,7 @@
 
 #include "CmObjectDescUtility.h"
 #include "FdtHwInfoParser.h"
-#include "Serial/ArmSerialPortParser.h"
+#include "Serial/SerialPortParser.h"
 
 /** List of "compatible" property values for serial port nodes.
 
@@ -329,7 +329,7 @@ GetSerialConsoleNode (
 STATIC
 EFI_STATUS
 EFIAPI
-ArmSerialPortInfoDispatch (
+SerialPortInfoDispatch (
   IN  CONST FDT_HW_INFO_PARSER_HANDLE  FdtParserHandle,
   IN  CM_ARCH_SERIAL_PORT_INFO *GenericSerialInfo,
   IN  INT32NodeCount,
@@ -396,7 +396,7 @@ ArmSerialPortInfoDispatch (
   @param [in]  FdtParserHandle A handle to the parser instance.
   @param [in]  FdtBranch   When searching for DT node name, restrict
the search to this Device Tree branch.
-  @param [in]  SerialObjectId  ArmNamespace Object ID for the serial port.
+  @param [in]  SerialObjectId  ArchNamespace Object ID for the serial port.
 
   @retval EFI_SUCCESS The function completed successfully.
   @retval EFI_ABORTED An error occurred.
@@ -407,7 +407,7 @@ ArmSerialPortInf

[edk2-devel] [RFC PATCH v1 08/20] DynamicTablesPkg: FdtHwInfoParserLib: Pci: Make it common for architectures

2024-01-09 Thread Sunil V L
PciConfigParser is a generic concept and can be used by other
architectures. Hence, rename to reflect it is common and updates the
consumers.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf   |  4 ++--
 ...nfigSpaceParser.h => PciConfigSpaceParser.h} | 10 +-
 .../FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c |  4 ++--
 ...nfigSpaceParser.c => PciConfigSpaceParser.c} | 17 -
 4 files changed, 13 insertions(+), 22 deletions(-)
 rename 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/{ArmPciConfigSpaceParser.h => 
PciConfigSpaceParser.h} (93%)
 rename 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/{ArmPciConfigSpaceParser.c => 
PciConfigSpaceParser.c} (95%)

diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
index 3abc6a0fd274..55ec7d97fa18 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
@@ -22,8 +22,8 @@ [Sources]
   FdtHwInfoParser.h
   FdtUtility.c
   FdtUtility.h
-  Pci/ArmPciConfigSpaceParser.c
-  Pci/ArmPciConfigSpaceParser.h
+  Pci/PciConfigSpaceParser.c
+  Pci/PciConfigSpaceParser.h
   Serial/ArmSerialPortParser.c
   Serial/ArmSerialPortParser.h
 
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.h 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.h
similarity index 93%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.h
rename to DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.h
index bfe724a69e55..106a7a92af47 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.h
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.h
@@ -1,5 +1,5 @@
 /** @file
-  Arm PCI Configuration Space Parser.
+  PCI Configuration Space Parser.
 
   Copyright (c) 2021, ARM Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -12,8 +12,8 @@
   - linux kernel code
 **/
 
-#ifndef ARM_PCI_CONFIG_SPACE_PARSER_H_
-#define ARM_PCI_CONFIG_SPACE_PARSER_H_
+#ifndef PCI_CONFIG_SPACE_PARSER_H_
+#define PCI_CONFIG_SPACE_PARSER_H_
 
 /** Read LEN bits at OFF offsets bits of the ADDR.
 
@@ -135,9 +135,9 @@ typedef struct PciParserTable {
 **/
 EFI_STATUS
 EFIAPI
-ArmPciConfigInfoParser (
+PciConfigInfoParser (
   IN  CONST FDT_HW_INFO_PARSER_HANDLE  FdtParserHandle,
   ININT32  FdtBranch
   );
 
-#endif // ARM_PCI_CONFIG_SPACE_PARSER_H_
+#endif // PCI_CONFIG_SPACE_PARSER_H_
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
index 4b1f5eeea423..8dd6546e62f0 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
@@ -9,7 +9,7 @@
 #include "Arm/BootArch/ArmBootArchParser.h"
 #include "Arm/GenericTimer/ArmGenericTimerParser.h"
 #include "Arm/Gic/ArmGicDispatcher.h"
-#include "Pci/ArmPciConfigSpaceParser.h"
+#include "Pci/PciConfigSpaceParser.h"
 #include "Serial/ArmSerialPortParser.h"
 
 /** Ordered table of parsers/dispatchers.
@@ -25,7 +25,7 @@ STATIC CONST FDT_HW_INFO_PARSER_FUNC  HwInfoParserTable[] = {
   ArmBootArchInfoParser,
   ArmGenericTimerInfoParser,
   ArmGicDispatcher,
-  ArmPciConfigInfoParser,
+  PciConfigInfoParser,
   SerialPortDispatcher
 };
 
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
similarity index 95%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.c
rename to DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
index d6a08c47b7d5..afe756bcedab 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
@@ -1,5 +1,5 @@
 /** @file
-  Arm PCI Configuration Space Parser.
+  PCI Configuration Space Parser.
 
   Copyright (c) 2021, ARM Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -16,8 +16,7 @@
 #include 
 
 #include "FdtHwInfoParser.h"
-#include "Pci/ArmPciConfigSpaceParser.h"
-#include "Arm/Gic/ArmGicDispatcher.h"
+#include "Pci/PciConfigSpaceParser.h"
 
 /** List of "compatible" property values for host PCIe bridges nodes.
 
@@ -306,8 +305,7 @@ ParseIrqMap (
   CONST UINT8  *IrqMapMask;
   INT32IrqMapMaskSize;
 
-  INT32   PHandleOffset;
-  UINT32  GicVersion;
+  INT32  PHandleOffset;
 
   UINT32  PciAddressAttr;
 
@@ -366,13 +364,6 @@ ParseIrqMap (
 return EFI_ABORTED;
   }
 
-  // Only support Gic(s) for now.
-  Status = GetGicVersion (Fdt, IntcNode, &G

[edk2-devel] [RFC PATCH v1 07/20] DynamicTablesPkg: FdtHwInfoParserLib: Separate ARM specific code

2024-01-09 Thread Sunil V L
HwInfoParserTable is an architecture specific structure. Hence, move it
and the MainDispatcher function to ARCH specific file. Update INF file.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf | 15 ++--
 .../FdtHwInfoParserLib/FdtHwInfoParser.h  | 27 ++
 .../Arm/ArmFdtHwInfoParser.c  | 83 +++
 .../FdtHwInfoParserLib/FdtHwInfoParser.c  | 78 +
 4 files changed, 121 insertions(+), 82 deletions(-)
 create mode 100644 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c

diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
index fa768cf664df..3abc6a0fd274 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
@@ -22,6 +22,13 @@ [Sources]
   FdtHwInfoParser.h
   FdtUtility.c
   FdtUtility.h
+  Pci/ArmPciConfigSpaceParser.c
+  Pci/ArmPciConfigSpaceParser.h
+  Serial/ArmSerialPortParser.c
+  Serial/ArmSerialPortParser.h
+
+[Sources.ARM, Sources.AARCH64]
+  Arm/ArmFdtHwInfoParser.c
   Arm/BootArch/ArmBootArchParser.c
   Arm/BootArch/ArmBootArchParser.h
   Arm/GenericTimer/ArmGenericTimerParser.c
@@ -38,13 +45,11 @@ [Sources]
   Arm/Gic/ArmGicMsiFrameParser.h
   Arm/Gic/ArmGicRParser.c
   Arm/Gic/ArmGicRParser.h
-  Pci/ArmPciConfigSpaceParser.c
-  Pci/ArmPciConfigSpaceParser.h
-  Serial/ArmSerialPortParser.c
-  Serial/ArmSerialPortParser.h
 
-[Packages]
+[Packages.ARM, Packages.AARCH64]
   ArmPkg/ArmPkg.dec
+
+[Packages]
   DynamicTablesPkg/DynamicTablesPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
   MdeModulePkg/MdeModulePkg.dec
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h
index 8a8cf38581e0..f8766236c492 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h
@@ -60,4 +60,31 @@ EFI_STATUS
   ININT32 FdtBranch
   );
 
+/** Main dispatcher: sequentially call the parsers/dispatchers
+of the HwInfoParserTable.
+
+  A parser parses a Device Tree to populate a specific CmObj type. None,
+  one or many CmObj can be created by the parser.
+  The created CmObj are then handed to the parser's caller through the
+  HW_INFO_ADD_OBJECT interface.
+  This can also be a dispatcher. I.e. a function that not parsing a
+  Device Tree but calling other parsers.
+
+  @param [in]  FdtParserHandle A handle to the parser instance.
+  @param [in]  FdtBranch   When searching for DT node name, restrict
+   the search to this Device Tree branch.
+
+  @retval EFI_SUCCESS The function completed successfully.
+  @retval EFI_ABORTED An error occurred.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_NOT_FOUND   Not found.
+  @retval EFI_UNSUPPORTED Unsupported.
+**/
+EFI_STATUS
+EFIAPI
+FdtHwInfoMainDispatcher (
+  IN  CONST FDT_HW_INFO_PARSER_HANDLE  FdtParserHandle,
+  ININT32  FdtBranch
+  );
+
 #endif // FDT_HW_INFO_PARSER_H_
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
new file mode 100644
index ..4b1f5eeea423
--- /dev/null
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
@@ -0,0 +1,83 @@
+/** @file
+  Flattened Device Tree parser library for KvmTool.
+
+  Copyright (c) 2021, ARM Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "FdtHwInfoParser.h"
+#include "Arm/BootArch/ArmBootArchParser.h"
+#include "Arm/GenericTimer/ArmGenericTimerParser.h"
+#include "Arm/Gic/ArmGicDispatcher.h"
+#include "Pci/ArmPciConfigSpaceParser.h"
+#include "Serial/ArmSerialPortParser.h"
+
+/** Ordered table of parsers/dispatchers.
+
+  A parser parses a Device Tree to populate a specific CmObj type. None,
+  one or many CmObj can be created by the parser.
+  The created CmObj are then handed to the parser's caller through the
+  HW_INFO_ADD_OBJECT interface.
+  This can also be a dispatcher. I.e. a function that not parsing a
+  Device Tree but calling other parsers.
+*/
+STATIC CONST FDT_HW_INFO_PARSER_FUNC  HwInfoParserTable[] = {
+  ArmBootArchInfoParser,
+  ArmGenericTimerInfoParser,
+  ArmGicDispatcher,
+  ArmPciConfigInfoParser,
+  SerialPortDispatcher
+};
+
+/** Main dispatcher: sequentially call the parsers/dispatchers
+of the HwInfoParserTable.
+
+  A parser parses a Device Tree to populate a specific CmObj type. None,
+  one or many CmObj can be created by the parser.
+  The created CmObj are then handed to the parser's caller through the
+  HW_INFO_ADD_OBJECT interf

[edk2-devel] [RFC PATCH v1 06/20] DynamicTablesPkg: Rename EObjNameSpaceArm to EObjNameSpaceArch

2024-01-09 Thread Sunil V L
To support other architectures, it is better to use an architecture
neutral name instead of EObjNameSpaceArm. Rename it as EObjNameSpaceArch
and update its consumers.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../Include/ConfigurationManagerObject.h  |  4 ++--
 .../KvmtoolCfgMgrDxe/ConfigurationManager.c   |  2 +-
 .../Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c   |  8 +++
 .../Acpi/Arm/AcpiIortLibArm/IortGenerator.c   | 22 +--
 .../Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c   | 10 -
 .../SsdtCmn600Generator.c |  2 +-
 .../Acpi/Common/AcpiDbg2Lib/Dbg2Generator.c   |  2 +-
 .../Acpi/Common/AcpiFadtLib/FadtGenerator.c   |  8 +++
 .../Acpi/Common/AcpiMcfgLib/McfgGenerator.c   |  2 +-
 .../Acpi/Common/AcpiPcctLib/PcctGenerator.c   | 12 +-
 .../Acpi/Common/AcpiPpttLib/PpttGenerator.c   |  8 +++
 .../Acpi/Common/AcpiSpcrLib/SpcrGenerator.c   |  2 +-
 .../Acpi/Common/AcpiSratLib/SratGenerator.c   | 12 +-
 .../SsdtCpuTopologyGenerator.c| 12 +-
 .../AcpiSsdtPcieLib/SsdtPcieGenerator.c   |  8 +++
 .../SsdtSerialPortGenerator.c |  2 +-
 .../DynamicPlatRepoLib/CmObjectTokenFixer.c   |  2 +-
 .../DynamicPlatRepoLib/DynamicPlatRepo.c  |  2 +-
 .../Common/DynamicPlatRepoLib/TokenMapper.c   |  2 +-
 .../ConfigurationManagerObjectParser.c|  2 +-
 20 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h 
b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
index e7f888f12eee..b0254b3ad4e5 100644
--- a/DynamicTablesPkg/Include/ConfigurationManagerObject.h
+++ b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
@@ -106,7 +106,7 @@ typedef UINT32 CM_OBJECT_ID;
 */
 typedef enum ObjectNameSpaceID {
   EObjNameSpaceStandard,  ///< Standard Objects Namespace
-  EObjNameSpaceArm,   ///< ARM Objects Namespace
+  EObjNameSpaceArch,  ///< ARCH Objects Namespace
   EObjNameSpaceOem = 0x8, ///< OEM Objects Namespace
   EObjNameSpaceMax
 } EOBJECT_NAMESPACE_ID;
@@ -180,7 +180,7 @@ typedef struct CmObjDescriptor {
   @retval Returns an ARM Configuration Manager Object ID.
 **/
 #define CREATE_CM_ARCH_OBJECT_ID(ObjectId) \
-  (CREATE_CM_OBJECT_ID (EObjNameSpaceArm, ObjectId))
+  (CREATE_CM_OBJECT_ID (EObjNameSpaceArch, ObjectId))
 
 /** This macro returns a Configuration Manager Object ID
 in the OEM Object Namespace.
diff --git a/ArmVirtPkg/KvmtoolCfgMgrDxe/ConfigurationManager.c 
b/ArmVirtPkg/KvmtoolCfgMgrDxe/ConfigurationManager.c
index 342d068f94fc..ede776fe9a46 100644
--- a/ArmVirtPkg/KvmtoolCfgMgrDxe/ConfigurationManager.c
+++ b/ArmVirtPkg/KvmtoolCfgMgrDxe/ConfigurationManager.c
@@ -929,7 +929,7 @@ ArmKvmtoolPlatformGetObject (
 case EObjNameSpaceStandard:
   Status = GetStandardNameSpaceObject (This, CmObjectId, Token, CmObject);
   break;
-case EObjNameSpaceArm:
+case EObjNameSpaceArch:
   Status = GetArmNameSpaceObject (This, CmObjectId, Token, CmObject);
   break;
 case EObjNameSpaceOem:
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c
index a9b9d30d9f73..77c913190f78 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c
@@ -36,7 +36,7 @@
 Timer Information from the Configuration Manager.
 */
 GET_OBJECT_LIST (
-  EObjNameSpaceArm,
+  EObjNameSpaceArch,
   EArchObjGenericTimerInfo,
   CM_ARCH_GENERIC_TIMER_INFO
   );
@@ -45,7 +45,7 @@ GET_OBJECT_LIST (
 Watchdog Timer Information from the Configuration Manager.
 */
 GET_OBJECT_LIST (
-  EObjNameSpaceArm,
+  EObjNameSpaceArch,
   EArchObjPlatformGenericWatchdogInfo,
   CM_ARCH_GENERIC_WATCHDOG_INFO
   );
@@ -54,7 +54,7 @@ GET_OBJECT_LIST (
 Timer Block Information from the Configuration Manager.
 */
 GET_OBJECT_LIST (
-  EObjNameSpaceArm,
+  EObjNameSpaceArch,
   EArchObjPlatformGTBlockInfo,
   CM_ARCH_GTBLOCK_INFO
   );
@@ -63,7 +63,7 @@ GET_OBJECT_LIST (
   Timer Block Timer Frame Information from the Configuration Manager.
 */
 GET_OBJECT_LIST (
-  EObjNameSpaceArm,
+  EObjNameSpaceArch,
   EArchObjGTBlockTimerFrameInfo,
   CM_ARCH_GTBLOCK_TIMER_FRAME_INFO
   );
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
index 3075b6a137b3..c0c68fcc26da 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
@@ -48,7 +48,7 @@
 Group node information from the Configuration Manager.
 */
 GET_OBJECT_LIST (
-  EObjNameSpaceArm,
+  EObjNameSpaceArch,
   EArchObjItsGroup,
   CM_ARCH_ITS_GROUP_NODE
   );
@@ -57,7 +57,7 @@ GET_OBJECT_LIST (
 Named Component node inf

[edk2-devel] [RFC PATCH v1 05/20] DynamicTablesPkg: DynamicPlatRepoLib: Rename ArmObjList as ArchObjList

2024-01-09 Thread Sunil V L
DynamicPlatRepoLib maintains list of CmObjs and named as ArmObjList.
However, to support other architectures, it is better to name this in a
architecture neutral way.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../DynamicPlatRepoLib/DynamicPlatRepoInternal.h   |  4 ++--
 .../Common/DynamicPlatRepoLib/DynamicPlatRepo.c| 14 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git 
a/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepoInternal.h 
b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepoInternal.h
index 2b09f2ad882d..cc0acfffecbb 100644
--- 
a/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepoInternal.h
+++ 
b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepoInternal.h
@@ -60,12 +60,12 @@ typedef struct DynamicPlatformRepositoryInfo {
 
   /// Link lists of CmObj from the ArmNameSpace
   /// that are added in the Transient state.
-  LIST_ENTRY ArmCmObjList[EArchObjMax];
+  LIST_ENTRY ArchCmObjList[EArchObjMax];
 
   /// Structure Members used in Finalized state.
   /// An array of CmObj Descriptors from the ArmNameSpace
   /// This array is populated when the Repo is finalized.
-  CM_OBJ_DESCRIPTOR  ArmCmObjArray[EArchObjMax];
+  CM_OBJ_DESCRIPTOR  ArchCmObjArray[EArchObjMax];
 
   /// A token mapper for the objects in the ArmNamespaceObjectArray
   /// The Token mapper is populated when the Repo is finalized in
diff --git 
a/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepo.c 
b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepo.c
index ae5c18bb..e095e358dc82 100644
--- a/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepo.c
+++ b/DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/DynamicPlatRepo.c
@@ -174,7 +174,7 @@ DynPlatRepoAddObject (
   }
 
   // Add to link list.
-  InsertTailList (&This->ArmCmObjList[ArmNamespaceObjId], &ObjNode->Link);
+  InsertTailList (&This->ArchCmObjList[ArmNamespaceObjId], &ObjNode->Link);
   This->ObjectCount += 1;
 
   if (Token != NULL) {
@@ -223,7 +223,7 @@ GroupCmObjNodes (
   Count= 0;
   Size = 0;
   CmObjId  = CREATE_CM_ARCH_OBJECT_ID (ArchObjIndex);
-  ListHead = &This->ArmCmObjList[ArchObjIndex];
+  ListHead = &This->ArchCmObjList[ArchObjIndex];
   Link = GetFirstNode (ListHead);
 
   // Compute the total count and size of the CmObj in the list.
@@ -286,7 +286,7 @@ GroupCmObjNodes (
 Link  = GetNextNode (ListHead, Link);
   } // while
 
-  CmObjDesc   = &This->ArmCmObjArray[ArchObjIndex];
+  CmObjDesc   = &This->ArchCmObjArray[ArchObjIndex];
   CmObjDesc->ObjectId = CmObjId;
   CmObjDesc->Size = (UINT32)Size;
   CmObjDesc->Count= (UINT32)Count;
@@ -412,7 +412,7 @@ DynamicPlatRepoGetObject (
 return EFI_INVALID_PARAMETER;
   }
 
-  Desc = &This->ArmCmObjArray[ArmNamespaceObjId];
+  Desc = &This->ArchCmObjArray[ArmNamespaceObjId];
 
   // Nothing here.
   if (Desc->Count == 0) {
@@ -459,7 +459,7 @@ DynamicPlatRepoInit (
 
   // Initialise the CmObject List.
   for (Index = 0; Index < EArchObjMax; Index++) {
-InitializeListHead (&Repo->ArmCmObjList[Index]);
+InitializeListHead (&Repo->ArchCmObjList[Index]);
   }
 
   Repo->ObjectCount = 0;
@@ -499,14 +499,14 @@ DynamicPlatRepoShutdown (
   // Free the list of objects.
   for (Index = 0; Index < EArchObjMax; Index++) {
 // Free all the nodes with this object Id.
-ListHead = &DynPlatRepo->ArmCmObjList[Index];
+ListHead = &DynPlatRepo->ArchCmObjList[Index];
 while (!IsListEmpty (ListHead)) {
   FreeCmObjNode ((CM_OBJ_NODE *)GetFirstNode (ListHead));
 } // while
   } // for
 
   // Free the arrays.
-  CmObjDesc = DynPlatRepo->ArmCmObjArray;
+  CmObjDesc = DynPlatRepo->ArchCmObjArray;
   for (Index = 0; Index < EArchObjMax; Index++) {
 Data = CmObjDesc[Index].Data;
 if (Data != NULL) {
-- 
2.34.1



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




[edk2-devel] [RFC PATCH v1 03/20] DynamicTablesPkg: Update ACPI common libraries BASE_NAME

2024-01-09 Thread Sunil V L
Update the BASE_NAME in the libraries moved out of ARM.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf   | 15 +++
 .../Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf   |  9 +
 .../Acpi/Common/AcpiMcfgLib/AcpiMcfgLib.inf   |  9 +
 .../Acpi/Common/AcpiPcctLib/AcpiPcctLib.inf   |  2 +-
 .../Acpi/Common/AcpiPpttLib/AcpiPpttLib.inf   |  2 +-
 .../Library/Acpi/Common/AcpiRawLib/AcpiRawLib.inf |  9 +
 .../Acpi/Common/AcpiSpcrLib/AcpiSpcrLib.inf   |  9 +
 .../Acpi/Common/AcpiSratLib/AcpiSratLib.inf   |  2 +-
 .../AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf |  6 --
 .../Acpi/Common/AcpiSsdtPcieLib/SsdtPcieLib.inf   |  2 +-
 .../AcpiSsdtSerialPortLib/SsdtSerialPortLib.inf   |  6 --
 11 files changed, 23 insertions(+), 48 deletions(-)

diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf
index f7b7c1c025a6..32dcd20c082b 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf
@@ -8,7 +8,7 @@
 
 [Defines]
   INF_VERSION= 0x00010019
-  BASE_NAME  = AcpiDbg2LibArm
+  BASE_NAME  = AcpiDbg2Lib
   FILE_GUID  = A17BA4F0-3DEB-4FE5-BD27-EC008E541B22
   VERSION_STRING = 1.0
   MODULE_TYPE= DXE_DRIVER
@@ -19,16 +19,20 @@ [Defines]
 [Sources]
   Dbg2Generator.c
 
+[Packages.ARM, Packages.AARCH64]
+  ArmPlatformPkg/ArmPlatformPkg.dec
+
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
-  ArmPlatformPkg/ArmPlatformPkg.dec
   DynamicTablesPkg/DynamicTablesPkg.dec
 
+[LibraryClasses.ARM, LibraryClasses.AARCH64]
+  PL011UartLib
+
 [LibraryClasses]
   BaseLib
-  PL011UartLib
   SsdtSerialPortFixupLib
 
 [FixedPcd]
@@ -36,8 +40,3 @@ [FixedPcd]
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
-
-[Protocols]
-
-[Guids]
-
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
index 8fe34013d420..c9cd850faac0 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
@@ -8,7 +8,7 @@
 
 [Defines]
   INF_VERSION= 0x00010019
-  BASE_NAME  = AcpiFadtLibArm
+  BASE_NAME  = AcpiFadtLib
   FILE_GUID  = 686FE5FE-B944-485F-8B1C-7D60E0056487
   VERSION_STRING = 1.0
   MODULE_TYPE= DXE_DRIVER
@@ -27,10 +27,3 @@ [Packages]
 
 [LibraryClasses]
   BaseLib
-
-[Pcd]
-
-[Protocols]
-
-[Guids]
-
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiMcfgLib/AcpiMcfgLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiMcfgLib/AcpiMcfgLib.inf
index 1c7f085274e6..36c343d3875a 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiMcfgLib/AcpiMcfgLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiMcfgLib/AcpiMcfgLib.inf
@@ -8,7 +8,7 @@
 
 [Defines]
   INF_VERSION= 0x00010019
-  BASE_NAME  = AcpiMcfgLibArm
+  BASE_NAME  = AcpiMcfgLib
   FILE_GUID  = 8C9BDCB2-72D4-4F30-A12D-1145C3807FF7
   VERSION_STRING = 1.0
   MODULE_TYPE= DXE_DRIVER
@@ -27,10 +27,3 @@ [Packages]
 
 [LibraryClasses]
   BaseLib
-
-[Pcd]
-
-[Protocols]
-
-[Guids]
-
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/AcpiPcctLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/AcpiPcctLib.inf
index da54585c2dd9..666bdcab2225 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/AcpiPcctLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/AcpiPcctLib.inf
@@ -8,7 +8,7 @@
 
 [Defines]
   INF_VERSION= 0x0001001B
-  BASE_NAME  = AcpiPcctLibArm
+  BASE_NAME  = AcpiPcctLib
   FILE_GUID  = 38FE945C-D6ED-4CD6-8D20-FCEF3260D15A
   VERSION_STRING = 1.0
   MODULE_TYPE= DXE_DRIVER
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiPpttLib/AcpiPpttLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiPpttLib/AcpiPpttLib.inf
index 2c7d19513d6c..a1c91a6eab74 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiPpttLib/AcpiPpttLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiPpttLib/AcpiPpttLib.inf
@@ -8,7 +8,7 @@
 
 [Defines]
   INF_VERSION= 0x0001001B
-  BASE_NAME  = AcpiPpttLibArm
+  BASE_NAME  = AcpiPpttLib
   FILE_GUID  = FA102D52-5A92-4F95-A097-1D53F9CF5959
   VERSION_STRING = 1.0
   MODULE_TYPE= DXE_DRIVER
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiRawLib/AcpiRawLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiRawLib/AcpiRawLib.inf
index f2ab1b7111fb..8b461ea05b86 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiRawLib/AcpiRawLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiRawLib/AcpiRawLib.inf
@@ -8,7 +8,7 @@
 
 [Defines]
   INF_VERSION= 0x00010019
-  

[edk2-devel] [RFC PATCH v1 02/20] DynamicTablesPkg: Move common ACPI libraries from folder

2024-01-09 Thread Sunil V L
Several ACPI tables are common across architectures. Move below common
ACPI table generator libraries which are common for architectures out of
Arm folder so that they can be used by other architectures like RISC-V.

Common tables are: DBG2, FADT, MCFG, PCCT, PPTT, SPCR, SRAT, SSDT (CPU,
PCIe)

Arm specific are: MADT, GTDT, IORT

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 DynamicTablesPkg/DynamicTables.dsc.inc| 45 +--
 .../AcpiDbg2Lib/AcpiDbg2Lib.inf}  |  0
 .../AcpiFadtLib/AcpiFadtLib.inf}  |  0
 .../AcpiMcfgLib/AcpiMcfgLib.inf}  |  0
 .../AcpiPcctLib/AcpiPcctLib.inf}  |  0
 .../AcpiPpttLib/AcpiPpttLib.inf}  |  0
 .../AcpiRawLib/AcpiRawLib.inf}|  0
 .../AcpiSpcrLib/AcpiSpcrLib.inf}  |  0
 .../AcpiSratLib/AcpiSratLib.inf}  |  0
 .../SsdtCpuTopologyLib.inf}   |  0
 .../AcpiSsdtPcieLib/SsdtPcieLib.inf}  |  0
 .../SsdtSerialPortLib.inf}|  0
 .../AcpiPcctLib}/PcctGenerator.h  |  0
 .../AcpiPpttLib}/PpttGenerator.h  |  0
 .../SsdtCpuTopologyGenerator.h|  0
 .../AcpiSsdtPcieLib}/SsdtPcieGenerator.h  |  0
 .../AcpiDbg2Lib}/Dbg2Generator.c  |  0
 .../AcpiFadtLib}/FadtGenerator.c  |  0
 .../AcpiMcfgLib}/McfgGenerator.c  |  0
 .../AcpiPcctLib}/PcctGenerator.c  |  0
 .../AcpiPpttLib}/PpttGenerator.c  |  0
 .../AcpiRawLib}/RawGenerator.c|  0
 .../AcpiSpcrLib}/SpcrGenerator.c  |  0
 .../AcpiSratLib}/SratGenerator.c  |  0
 .../SsdtCpuTopologyGenerator.c|  0
 .../AcpiSsdtPcieLib}/SsdtPcieGenerator.c  |  0
 .../SsdtSerialPortGenerator.c |  0
 27 files changed, 22 insertions(+), 23 deletions(-)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf => 
Common/AcpiDbg2Lib/AcpiDbg2Lib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf => 
Common/AcpiFadtLib/AcpiFadtLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf => 
Common/AcpiMcfgLib/AcpiMcfgLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPcctLibArm/AcpiPcctLibArm.inf => 
Common/AcpiPcctLib/AcpiPcctLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPpttLibArm/AcpiPpttLibArm.inf => 
Common/AcpiPpttLib/AcpiPpttLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiRawLibArm/AcpiRawLibArm.inf => 
Common/AcpiRawLib/AcpiRawLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf => 
Common/AcpiSpcrLib/AcpiSpcrLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSratLibArm/AcpiSratLibArm.inf => 
Common/AcpiSratLib/AcpiSratLib.inf} (100%)
 rename 
DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyLibArm.inf
 => Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf} (100%)
 rename 
DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf => 
Common/AcpiSsdtPcieLib/SsdtPcieLib.inf} (100%)
 rename 
DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPortLibArm.inf
 => Common/AcpiSsdtSerialPortLib/SsdtSerialPortLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPcctLibArm => 
Common/AcpiPcctLib}/PcctGenerator.h (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPpttLibArm => 
Common/AcpiPpttLib}/PpttGenerator.h (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtCpuTopologyLibArm => 
Common/AcpiSsdtCpuTopologyLib}/SsdtCpuTopologyGenerator.h (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtPcieLibArm => 
Common/AcpiSsdtPcieLib}/SsdtPcieGenerator.h (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiDbg2LibArm => 
Common/AcpiDbg2Lib}/Dbg2Generator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiFadtLibArm => 
Common/AcpiFadtLib}/FadtGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiMcfgLibArm => 
Common/AcpiMcfgLib}/McfgGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPcctLibArm => 
Common/AcpiPcctLib}/PcctGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPpttLibArm => 
Common/AcpiPpttLib}/PpttGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiRawLibArm => 
Common/AcpiRawLib}/RawGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSpcrLibArm => 
Common/AcpiSpcrLib}/SpcrGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSratLibArm => 
Common/AcpiSratLib}/SratGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtCpuTopologyLibArm => 
Common/AcpiSsdtCpuTopologyLib}/SsdtCpuTopologyGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtPcieLibArm => 
Common/AcpiSsdtPcieLib}/SsdtPcieGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtSerialPortLibArm => 
Common/AcpiSsdt

[edk2-devel] [RFC PATCH v1 01/20] DynamicTablesPkg: FdtHwInfoParserLib: Move ARM parsers to Arm directory

2024-01-09 Thread Sunil V L
GIC, GenericTimer and BootArch are ARM specific concepts. Move them to
Arm folder and update the references.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Sunil V L 
---
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf | 32 +--
 .../{ => Arm}/BootArch/ArmBootArchParser.h|  0
 .../GenericTimer/ArmGenericTimerParser.h  |  0
 .../{ => Arm}/Gic/ArmGicCParser.h |  0
 .../{ => Arm}/Gic/ArmGicDParser.h |  0
 .../{ => Arm}/Gic/ArmGicDispatcher.h  |  0
 .../{ => Arm}/Gic/ArmGicItsParser.h   |  0
 .../{ => Arm}/Gic/ArmGicMsiFrameParser.h  |  0
 .../{ => Arm}/Gic/ArmGicRParser.h |  0
 .../{ => Arm}/BootArch/ArmBootArchParser.c|  2 +-
 .../GenericTimer/ArmGenericTimerParser.c  |  4 +--
 .../{ => Arm}/Gic/ArmGicCParser.c |  4 +--
 .../{ => Arm}/Gic/ArmGicDParser.c |  4 +--
 .../{ => Arm}/Gic/ArmGicDispatcher.c  | 12 +++
 .../{ => Arm}/Gic/ArmGicItsParser.c   |  4 +--
 .../{ => Arm}/Gic/ArmGicMsiFrameParser.c  |  4 +--
 .../{ => Arm}/Gic/ArmGicRParser.c |  4 +--
 .../FdtHwInfoParserLib/FdtHwInfoParser.c  |  6 ++--
 .../Pci/ArmPciConfigSpaceParser.c |  2 +-
 19 files changed, 39 insertions(+), 39 deletions(-)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/BootArch/ArmBootArchParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/GenericTimer/ArmGenericTimerParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicCParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicDParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicDispatcher.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicItsParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicMsiFrameParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicRParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/BootArch/ArmBootArchParser.c (95%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/GenericTimer/ArmGenericTimerParser.c (95%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicCParser.c (96%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicDParser.c (95%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicDispatcher.c (92%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicItsParser.c (95%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicMsiFrameParser.c (95%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicRParser.c (95%)

diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
index d2c171accaa5..fa768cf664df 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
@@ -22,22 +22,22 @@ [Sources]
   FdtHwInfoParser.h
   FdtUtility.c
   FdtUtility.h
-  BootArch/ArmBootArchParser.c
-  BootArch/ArmBootArchParser.h
-  GenericTimer/ArmGenericTimerParser.c
-  GenericTimer/ArmGenericTimerParser.h
-  Gic/ArmGicCParser.c
-  Gic/ArmGicCParser.h
-  Gic/ArmGicDispatcher.c
-  Gic/ArmGicDispatcher.h
-  Gic/ArmGicDParser.c
-  Gic/ArmGicDParser.h
-  Gic/ArmGicItsParser.c
-  Gic/ArmGicItsParser.h
-  Gic/ArmGicMsiFrameParser.c
-  Gic/ArmGicMsiFrameParser.h
-  Gic/ArmGicRParser.c
-  Gic/ArmGicRParser.h
+  Arm/BootArch/ArmBootArchParser.c
+  Arm/BootArch/ArmBootArchParser.h
+  Arm/GenericTimer/ArmGenericTimerParser.c
+  Arm/GenericTimer/ArmGenericTimerParser.h
+  Arm/Gic/ArmGicCParser.c
+  Arm/Gic/ArmGicCParser.h
+  Arm/Gic/ArmGicDispatcher.c
+  Arm/Gic/ArmGicDispatcher.h
+  Arm/Gic/ArmGicDParser.c
+  Arm/Gic/ArmGicDParser.h
+  Arm/Gic/ArmGicItsParser.c
+  Arm/Gic/ArmGicItsParser.h
+  Arm/Gic/ArmGicMsiFrameParser.c
+  Arm/Gic/ArmGicMsiFrameParser.h
+  Arm/Gic/ArmGicRParser.c
+  Arm/Gic/ArmGicRParser.h
   Pci/ArmPciConfigSpaceParser.c
   Pci/ArmPciConfigSpaceParser.h
   Serial/ArmSerialPortParser.c
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/BootArch/ArmBootArchParser.h 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.h
similarity index 100%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/BootArch/ArmBootArchParser.h
rename to 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.h
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/GenericTimer/ArmGenericTimerParser.h
 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/GenericTimer/ArmGenericTimerParser.h
similarity index 100%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/GenericTimer/ArmGenericTimerParser.h
rename to 
DynamicTablesPkg/Library/F

[edk2-devel] [RFC PATCH v1 00/20] DynamicTablesPkg: Prepare to add RISC-V support

2024-01-09 Thread Sunil V L
DynamicTablesPkg can be used by RISC-V platforms to generate ACPI tables
from FDT passed from previous stage FW. However, DynamicTablesPkg
currently is ARM specific even though several parsers and ACPI
generators can be used across architectures. For ex: SSDT (PCIe), SSDT
(CPU), MCFG, SPCR, DBG2, FADT, SRAT, Raw (DSDT) are mostly common across
architectures. Only MADT, IORT and GTDT are ARM specific.

This series tries to refactor the DynamicTablesPkg so that RISC-V
support can be added fairly easily later.

While the approach taken in this series reduces the code duplication as
much as possible, it has the side effect of large changes and impacts
platforms that support DynamicTablesPkg today (ex: JunoPkg,
ArmKvmTool etc). Other approach I tried initially was to duplicate most
of the things from Arm to RISC-V. But it was too much of
code duplication which is bad in my opinion.

To help the review, the series is also available at
https://github.com/vlsunil/edk2/tree/dyn_tables_refactor_rfc_v1

Corresponding changes in edk2-platforms are at
https://github.com/vlsunil/edk2-platforms/tree/dyn_tables_approach2_v1

I have built tested the changes for following platforms enabling
DYNAMIC_TABLES_FRAMEWORK.
  - ArmJuno.dsc
  - ArmVExpress-FVP-AArch64.dsc 
  - ArmVirtKvmTool.dsc

But due to the nature of the changes, if the approach is fine, I will
need some help to test those platforms which support DynamicTables.

The series passes CI tests.

Looking forward for your feedback!. I am happy to try if there are any
better methods to add support for other architectures.

Addition of RISC-V support PoC code (on top of this series) is available
at 
https://github.com/vlsunil/edk2/tree/dyn_tables_riscv_rfc_v1

PS: PoC code for the code duplication approach is available at
https://github.com/vlsunil/edk2/commits/dyn_tables_approch1_v1/.
This was just quick work. It has the advantage of lesser impact on
existing ARM platforms. But looks too bad to me because of code
duplication.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Cc: Andrei Warkentin 
Cc: Laszlo Ersek 
Cc: AbdulLateef Attar (Abdul Lateef) 
Cc: Jeff Brasen 

Sunil V L (20):
  DynamicTablesPkg: FdtHwInfoParserLib: Move ARM parsers to Arm
directory
  DynamicTablesPkg: Move common ACPI libraries from folder
  DynamicTablesPkg: Update ACPI common libraries BASE_NAME
  DynamicTablesPkg: Rename ArmNameSpaceObjects to ArchNameSpaceObjects
  DynamicTablesPkg: DynamicPlatRepoLib: Rename ArmObjList as ArchObjList
  DynamicTablesPkg: Rename EObjNameSpaceArm to EObjNameSpaceArch
  DynamicTablesPkg: FdtHwInfoParserLib: Separate ARM specific code
  DynamicTablesPkg: FdtHwInfoParserLib: Pci: Make it common for
architectures
  DynamicTablesPkg: FdtHwInfoParserLib: Make Serial parser arch neutral
  DynamicTablesPkg: FdtHwInfoParserLib: Move ArmLib.h to ArmGicCParser.c
  DynamicTablesPkg: TableHelperLib: Populate OemTableId using
ConfigManager
  DynamicTablesPkg: Add CreatorId in
CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
  DynamicTablesPkg: FdtHwInfoParserLib: Move ARM utilities to separate
file
  DynamicTablesPkg/FdtHwInfoParserLib: Add function for INTC address
cells
  DynamicTablesPkg: AcpiSsdtCpuTopologyLib: Move GICC from common code
  DynamicTablesPkg: AcpiFadtLib: Move ArmBootArch to ARM specific file
  DynamicTablesPkg: DynamicTableManagerDxe: Refactor to allow other
archs
  DynamicTablesPkg: X86: Add interfaces to succeed CI tests
  DynamicTablesPkg/AmlLib: Fix typo
  DynamicTablesPkg.ci.yaml: Update exception and ignore list

 DynamicTablesPkg/DynamicTables.dsc.inc|  45 +-
 .../DynamicTableManagerDxe.inf|   9 +-
 .../AcpiDbg2Lib/AcpiDbg2Lib.inf}  |  15 +-
 .../AcpiFadtLib/AcpiFadtLib.inf}  |  13 +-
 .../AcpiMcfgLib/AcpiMcfgLib.inf}  |   9 +-
 .../AcpiPcctLib/AcpiPcctLib.inf}  |   2 +-
 .../AcpiPpttLib/AcpiPpttLib.inf}  |   2 +-
 .../AcpiRawLib/AcpiRawLib.inf}|   9 +-
 .../AcpiSpcrLib/AcpiSpcrLib.inf}  |   9 +-
 .../AcpiSratLib/AcpiSratLib.inf}  |   2 +-
 .../SsdtCpuTopologyLib.inf}   |   9 +-
 .../AcpiSsdtPcieLib/SsdtPcieLib.inf}  |   2 +-
 .../SsdtSerialPortLib.inf}|   6 +-
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf |  48 +-
 .../KvmtoolCfgMgrDxe/ConfigurationManager.h   |  10 +-
 .../DynamicTableManagerDxe.h  |  65 +++
 ...eSpaceObjects.h => ArchNameSpaceObjects.h} | 428 
 .../Include/ConfigurationManagerObject.h  |   8 +-
 .../Include/Library/AmlLib/AmlLib.h   |   1 +
 .../Include/Library/SsdtPcieSupportLib.h  |  12 +-
 .../Include/Library/SsdtSerialPortFixupLib.h  |   8 +-
 .../Include/StandardNameSpaceObjects.h|   1 +
 .../Acpi/Common/AcpiFadtLib/FadtGenerator.h   |  32 ++
 .../AcpiPcctLib}/PcctGenerator.h  |   4 +-
 .../AcpiPpttLib}/PpttGenerator.h  |   0
 .../Ss

Re: [edk2-devel] [PATCH v2 4/4] OvmfPkg/RiscVVirt: Override Sstc extension

2024-01-09 Thread Andrei Warkentin
Reviewed-by: Andrei Warkentin 

> -Original Message-
> From: Sunil V L 
> Sent: Monday, January 8, 2024 5:37 AM
> To: devel@edk2.groups.io
> Cc: Sunil V L ; Warkentin, Andrei
> ; Ard Biesheuvel ;
> Gerd Hoffmann ; Yao, Jiewen ;
> Laszlo Ersek 
> Subject: [PATCH v2 4/4] OvmfPkg/RiscVVirt: Override Sstc extension
> 
> Override Sstc extension and use SBI calls itself by default for RISC-V qemu 
> virt
> platform.
> 
> Cc: Andrei Warkentin 
> Cc: Ard Biesheuvel 
> Cc: Gerd Hoffmann 
> Cc: Jiewen Yao 
> Cc: Laszlo Ersek 
> Signed-off-by: Sunil V L 
> Reviewed-by: Laszlo Ersek 
> ---
>  OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc
> b/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc
> index d3624e899e8d..6bc7c90f31dc 100644
> --- a/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc
> +++ b/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc
> @@ -203,7 +203,7 @@ [PcdsFeatureFlag]
>gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
> 
>  [PcdsFixedAtBuild.common]
> -  gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride|0xFFFE
> +
> gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride|0xFFFC
>gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|100
>gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|100
>gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0
> --
> 2.34.1



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




Re: [edk2-devel] [PATCH v2 3/4] UefiCpuPkg/CpuTimerDxeRiscV64: Add support for Sstc

2024-01-09 Thread Andrei Warkentin
Reviewed-by: Andrei Warkentin 

> -Original Message-
> From: Sunil V L 
> Sent: Monday, January 8, 2024 5:37 AM
> To: devel@edk2.groups.io
> Cc: Sunil V L ; Gerd Hoffmann
> ; Kumar, Rahul R ; Laszlo
> Ersek ; Ni, Ray ; Warkentin, Andrei
> 
> Subject: [PATCH v2 3/4] UefiCpuPkg/CpuTimerDxeRiscV64: Add support for
> Sstc
> 
> Sstc extension allows to program the timer and receive the interrupt without
> using an SBI call. This reduces the latency to generate the timer interrupt. 
> So,
> detect whether Sstc extension is supported and use the stimecmp register
> directly to program the timer interrupt.
> 
> Cc: Gerd Hoffmann 
> Cc: Rahul Kumar 
> Cc: Laszlo Ersek 
> Cc: Ray Ni 
> Cc: Andrei Warkentin 
> Signed-off-by: Sunil V L 
> ---
>  .../CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf |  1 +
>  UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h |  2 +
>  UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c | 49 +--
>  3 files changed, 49 insertions(+), 3 deletions(-)
> 
> diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
> b/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
> index aba660186dc0..f2a2cf12caef 100644
> --- a/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
> +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
> @@ -41,6 +41,7 @@ [Sources.RISCV64]
>Timer.c
> 
>  [Pcd]
> +  gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride   ## CONSUMES
>gUefiCpuPkgTokenSpaceGuid.PcdCpuCoreCrystalClockFrequency  ##
> CONSUMES
> 
>  [Protocols]
> diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h
> b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h
> index 9b3542230cb5..067bbd29f377 100644
> --- a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h
> +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h
> @@ -26,6 +26,8 @@
>  //
>  #define DEFAULT_TIMER_TICK_DURATION  10
> 
> +#define RISCV_CPU_FEATURE_SSTC_BITMASK  BIT1
> +
>  extern VOID
>  RiscvSetTimerPeriod (
>UINT32  TimerPeriod
> diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
> b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
> index 30e48061cd06..216f48a52931 100644
> --- a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
> +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
> @@ -44,6 +44,45 @@ STATIC EFI_TIMER_NOTIFY  mTimerNotifyFunction;
>  STATIC UINT64  mTimerPeriod = 0;
>  STATIC UINT64  mLastPeriodStart = 0;
> 
> +//
> +// Sstc support
> +//
> +STATIC BOOLEAN  mSstcEnabled = FALSE;
> +
> +/**
> +  Program the timer.
> +
> +  Program either using stimecmp (when Sstc extension is enabled) or
> + using SBI  TIME call.
> +
> +  @param NextValue Core tick value the timer should expire.
> +**/
> +STATIC
> +VOID
> +RiscVProgramTimer (
> +  UINT64  NextValue
> +  )
> +{
> +  if (mSstcEnabled) {
> +RiscVSetSupervisorTimeCompareRegister (NextValue);
> +  } else {
> +SbiSetTimer (NextValue);
> +  }
> +}
> +
> +/**
> +  Check whether Sstc is enabled in PCD.
> +
> +**/
> +STATIC
> +BOOLEAN
> +RiscVIsSstcEnabled (
> +  VOID
> +  )
> +{
> +  return ((PcdGet64 (PcdRiscVFeatureOverride) &
> +RISCV_CPU_FEATURE_SSTC_BITMASK) != 0); }
> +
>  /**
>Timer Interrupt Handler.
> 
> @@ -94,7 +133,7 @@ TimerInterruptHandler (
>   ),
> 100u
> );  // convert to tick
> -  SbiSetTimer (PeriodStart);
> +  RiscVProgramTimer (PeriodStart);
>RiscVEnableTimerInterrupt (); // enable SMode timer int
>gBS->RestoreTPL (OriginalTPL);
>  }
> @@ -197,8 +236,7 @@ TimerDriverSetTimerPeriod (
>   ),
> 100u
> ); // convert to tick
> -  SbiSetTimer (PeriodStart);
> -
> +  RiscVProgramTimer (PeriodStart);
>mCpu->EnableInterrupt (mCpu);
>RiscVEnableTimerInterrupt (); // enable SMode timer int
>return EFI_SUCCESS;
> @@ -282,6 +320,11 @@ TimerDriverInitialize (
>//
>mTimerNotifyFunction = NULL;
> 
> +  if (RiscVIsSstcEnabled ()) {
> +mSstcEnabled = TRUE;
> +DEBUG ((DEBUG_INFO, "TimerDriverInitialize: Timer interrupt is via
> + Sstc extension\n"));  }
> +
>//
>// Make sure the Timer Architectural Protocol is not already installed in 
> the
> system
>//
> --
> 2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113460): https://edk2.groups.io/g/devel/message/113460
Mute This Topic: https://groups.io/mt/103595210/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 2/4] MdePkg/BaseLib: RISC-V: Add function to update stimecmp register

2024-01-09 Thread Andrei Warkentin
Reviewed-by: Andrei Warkentin 

> -Original Message-
> From: Sunil V L 
> Sent: Monday, January 8, 2024 5:37 AM
> To: devel@edk2.groups.io
> Cc: Sunil V L ; Kinney, Michael D
> ; Gao, Liming ;
> Liu, Zhiguang ; Warkentin, Andrei
> 
> Subject: [PATCH v2 2/4] MdePkg/BaseLib: RISC-V: Add function to update
> stimecmp register
> 
> stimecmp is a CSR supported only when Sstc extension is supported by the
> platform. This register can be used to set the timer interrupt directly in 
> S-mode
> instead of going via SBI call. Add a function to update this register.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Cc: Andrei Warkentin 
> Signed-off-by: Sunil V L 
> ---
>  MdePkg/Include/Library/BaseLib.h| 5 +
>  MdePkg/Include/Register/RiscV64/RiscVEncoding.h | 3 +++
>  MdePkg/Library/BaseLib/RiscV64/ReadTimer.S  | 7 +++
>  3 files changed, 15 insertions(+)
> 
> diff --git a/MdePkg/Include/Library/BaseLib.h
> b/MdePkg/Include/Library/BaseLib.h
> index b71e47f41b7f..ca0d06c7f335 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -191,6 +191,11 @@ RiscVReadTimer (
>VOID
>);
> 
> +VOID
> +RiscVSetSupervisorTimeCompareRegister (
> +  IN UINT64
> +  );
> +
>  VOID
>  RiscVEnableTimerInterrupt (
>VOID
> diff --git a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h
> b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h
> index 2bde8db478ff..8ccdea2f4fcd 100644
> --- a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h
> +++ b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h
> @@ -96,6 +96,9 @@
>  /* Supervisor Protection and Translation */  #define CSR_SATP  0x180
> 
> +/* Sstc extension */
> +#define CSR_STIMECMP  0x14D
> +
>  /* Trap/Exception Causes */
>  #define CAUSE_MISALIGNED_FETCH  0x0
>  #define CAUSE_FETCH_ACCESS  0x1
> diff --git a/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S
> b/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S
> index 39a06efa51ef..36781c29c0b9 100644
> --- a/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S
> +++ b/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S
> @@ -21,3 +21,10 @@
>  ASM_FUNC (RiscVReadTimer)
>  csrr a0, CSR_TIME
>  ret
> +
> +//
> +// Set Supervisor Time Compare Register // ASM_FUNC
> +(RiscVSetSupervisorTimeCompareRegister)
> +csrw  CSR_STIMECMP, a0
> +ret
> --
> 2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113459): https://edk2.groups.io/g/devel/message/113459
Mute This Topic: https://groups.io/mt/103595209/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/4] MdePkg.dec: RISC-V: Define override bit for Sstc extension

2024-01-09 Thread Andrei Warkentin
Reviewed-by: Andrei Warkentin 

> -Original Message-
> From: Sunil V L 
> Sent: Monday, January 8, 2024 5:37 AM
> To: devel@edk2.groups.io
> Cc: Sunil V L ; Gao, Liming
> ; Kinney, Michael D
> ; Liu, Zhiguang ;
> Warkentin, Andrei 
> Subject: [PATCH v2 1/4] MdePkg.dec: RISC-V: Define override bit for Sstc
> extension
> 
> Define the BIT 1 as the override bit for Sstc extension. This will be used by 
> the
> timer driver to decide whether to use SBI calls or direct CSR access to 
> configure
> the timer.
> 
> Cc: Liming Gao 
> Cc: Michael D Kinney 
> Cc: Zhiguang Liu 
> Cc: Andrei Warkentin 
> Signed-off-by: Sunil V L 
> ---
>  MdePkg/MdePkg.dec | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index
> 2ee112cc087a..0459418906f8 100644
> --- a/MdePkg/MdePkg.dec
> +++ b/MdePkg/MdePkg.dec
> @@ -2405,6 +2405,8 @@ [PcdsFixedAtBuild.RISCV64,
> PcdsPatchableInModule.RISCV64]
># Configurability to override RISC-V CPU Features
># BIT 0 = Cache Management Operations. This bit is relevant only if
># previous stage has feature enabled and user wants to disable it.
> +  # BIT 1 = Supervisor Time Compare (Sstc). This bit is relevant only
> + if  # previous stage has feature enabled and user wants to disable it.
>#
> 
> gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride|0x|
> UINT64|0x69
> 
> --
> 2.34.1



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




Re: [edk2-devel] [PATCH v10 4/5] MdePkg: Utilize Cache Management Operations Implementation For RISC-V

2024-01-09 Thread Andrei Warkentin
For now, this is really something that ought to be hidden by DmaLib abstraction 
(Map/Unmap). This would allow the driver to be minimally aware of how the IP is 
integrated into the SoC.

A

> -Original Message-
> From: Sunil V L 
> Sent: Monday, January 8, 2024 11:32 PM
> To: Pedro Falcato 
> Cc: devel@edk2.groups.io; dha...@rivosinc.com; yorange
> ; Warkentin, Andrei
> ; Ard Biesheuvel ;
> Leif Lindholm 
> Subject: Re: [edk2-devel] [PATCH v10 4/5] MdePkg: Utilize Cache
> Management Operations Implementation For RISC-V
> 
> On Mon, Jan 08, 2024 at 09:53:46PM +, Pedro Falcato wrote:
> > On Mon, Jan 8, 2024 at 4:23 PM Dhaval Sharma 
> wrote:
> > >
> > > Hi yangcheng/Pedro,
> >
> > +CC a bunch of relevant people
> >
> > Hi, (FYI you did not CC me)
> >
> > Looking at yangcheng's example:
> >
> >   Status = PrepareDmaData (gpIdmacDesc, Length, Buffer); <-- We write
> > to the IDMAC desc
> >   if (EFI_ERROR (Status)) {
> > goto out;
> >   }
> >
> >   WriteBackDataCacheRange (gpIdmacDesc, DescPages * EFI_PAGE_SIZE);
> > <-- Make sure it's DMA-coherent
> >   StartDma (Length); <-- We've flushed the cache, everything is now in
> > DRAM and DMA-coherent, start DMA
> >
> > which screams of "bad abstractions" because you don't actually need to
> > write data back, if the device and platform are DMA coherent.
> >
> > So what we want here really depends. My local "Volume I: RISC-V
> > Unprivileged ISA V20191213" says, section A.5:
> >
> > "Table A.5 provides a mapping of Linux memory ordering macros onto
> > RISC-V memory instructions.
> > The Linux fences dma rmb() and dma wmb() map onto FENCE R,R and FENCE
> > W,W, respectively, since the RISC-V Unix Platform requires coherent
> > DMA, but would be mapped onto FENCE RI,RI and FENCE WO,WO,
> > respectively, on a platform with non-coherent DMA.
> > Platforms with non-
> > coherent DMA may also require a mechanism by which cache lines can be
> > flushed and/or invalidated.
> > Such mechanisms will be device-specific and/or standardized in a
> > future extension to the ISA."
> >
> > The (current date) RISCV Platform Spec also says: "Memory accesses by
> > I/O masters can be coherent or non-coherent with respect to all
> > hart-related caches."
> > which is brilliantly useless.
> >
> > so I think the best solution here is to:
> >
> > 1) Add a new PCD for platform DMA coherency, and test that on
> > WriteBackDataCacheRange's ASSERT (if (!Coherent) ASSERT() else
> > return;)
> > 2) Add a more abstracting API that doesn't necessarily map to
> > WriteBackDataCache when all we wanted was to assert DMA coherency
> >
> > but, alas, I've seen a lot less funky platforms than many of you, and
> > DMA/cache-coherency is not really my thing, so I'll defer to others..
> >
> My preference is just remove the assertion and add the debug verbose
> message instead of changing drivers/introduce new interfaces. It is a nop in
> linux as well if CMO is not present.
> 
> Thanks,
> Sunil


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




Re: [edk2-devel] [PATCH] DynamicTablesPkg/SSDT: Remove incorrect root node check

2024-01-09 Thread PierreGondois




On 1/9/24 16:47, Jeshua Smith wrote:

From: Pierre Gondois 
Sent: Tuesday, January 9, 2024 1:22 AM



On 1/8/24 19:12, Jeshua Smith wrote:

The code was incorrectly assuming that root nodes had to be physical
package nodes and vice versa. This is not always true, so the check is
being removed.


Does it mean that you have a topology where the top-level node is not a
physical package ? If yes, does it also mean that multiple physical packages
share a resource (which belong to the top-level node) ?


Yes, this change is due to the check incorrectly flagging our topology as 
invalid. Simply removing the check fixed the problem for us.
  

It is correct that the check is a bit stronger than what the specification 
states,
but it was handling all topologies so far, so would it be possible to describe 
the
topology that you have ?


Two physical packages are on a multi-chip module and share resources on the 
module. The module then plugs into the baseboard/motherboard.


Is it possible to elaborate on the resource being shared ?
Does it fall into the subject of this thread ? Some resources might be aswell 
described in other ACPI tables.
https://edk2.groups.io/g/devel/message/89121



Note: While investigating this we noticed that another vendor also has a 
similar PPTT topology to what is being flagged as invalid, so either that 
vendor isn't using EDK2 or they have done something to avoid this check without 
submitting a patch to EDK2.


This check is only present in the DynamicTablesPkg, so it shouldn't be too 
restrictive.
If the platform is known to use it, is it possible to share which platform it 
is ?

Regards,
Pierre


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




Re: [edk2-devel] [PATCH] DynamicTablesPkg/SSDT: Remove incorrect root node check

2024-01-09 Thread Jeshua Smith via groups.io
> From: Pierre Gondois 
> Sent: Tuesday, January 9, 2024 1:22 AM

> On 1/8/24 19:12, Jeshua Smith wrote:
> > The code was incorrectly assuming that root nodes had to be physical
> > package nodes and vice versa. This is not always true, so the check is
> > being removed.
> 
> Does it mean that you have a topology where the top-level node is not a
> physical package ? If yes, does it also mean that multiple physical packages
> share a resource (which belong to the top-level node) ?

Yes, this change is due to the check incorrectly flagging our topology as 
invalid. Simply removing the check fixed the problem for us.
 
> It is correct that the check is a bit stronger than what the specification 
> states,
> but it was handling all topologies so far, so would it be possible to 
> describe the
> topology that you have ?

Two physical packages are on a multi-chip module and share resources on the 
module. The module then plugs into the baseboard/motherboard. 

Note: While investigating this we noticed that another vendor also has a 
similar PPTT topology to what is being flagged as invalid, so either that 
vendor isn't using EDK2 or they have done something to avoid this check without 
submitting a patch to EDK2.


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




[edk2-devel] [PATCH V2] FmpDevicePkg: GetImageInfo Add missing condition

2024-01-09 Thread Pethaiyan Madhan
From: "Pethaiyan, Madhan" 

UEFI Spec 2.10 , 23.1 Firmware Management Protocol , Added missing condition 
check under GetImageInfo function,
if the PackageVersionName is NULL return EFI_INVALID_PARAMETER

Signed-off-by: Pethaiyan Madhan 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Wei6 Xu 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 1e7ec4a09e..e87094f84c 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -495,7 +495,7 @@ GetTheImageInfo (
   // Confirm that buffer isn't null
   //
   if (  (ImageInfo == NULL) || (DescriptorVersion == NULL) || (DescriptorCount 
== NULL) || (DescriptorSize == NULL)
- || (PackageVersion == NULL))
+ || (PackageVersion == NULL) || (PackageVersionName == NULL))
   {
 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImageInfo() - Pointer Parameter is 
NULL.\n", mImageIdName));
 Status = EFI_INVALID_PARAMETER;
-- 
2.38.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113453): https://edk2.groups.io/g/devel/message/113453
Mute This Topic: https://groups.io/mt/103620853/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] MdePkg:Updated the comments of EFI_FIRMWARE_MANAGEMENT_PROTOCOL

2024-01-09 Thread Xu, GuoX
Hi all, any comments about this patch?

-Original Message-
From: devel@edk2.groups.io  On Behalf Of GuoX Xu
Sent: Monday, December 25, 2023 9:21 AM
To: devel@edk2.groups.io
Cc: Kinney, Michael D ; Gao, Liming 
; Liu, Zhiguang ; Li, Yi1 

Subject: [edk2-devel] [PATCH 1/1] MdePkg:Updated the comments of 
EFI_FIRMWARE_MANAGEMENT_PROTOCOL

1.For EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetImage():
Add the following sentence at the end of the Image parameter description. "May 
be NULL with a zero ImageSize in order to determine the size of the buffer 
needed".

Modify the description of "EFI_INVALID_PARAMETER" return code as "The ImageSize 
is not too small and Image is NULL."

2.For EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetImageInfo():
Add the following sentence at the end of the ImageInfo parameter 
description."May be NULL with a zero ImageInfoSize in order to determine the 
size of the buffer needed".

Modify the description of "EFI_INVALID_PARAMETER" return code as "The 
ImageInfoSize is not too small and Image is NULL." and add new descriptions for 
"EFI_INVALID_PARAMETER" return code.

REF: UEFI Spec 2.7B Chapter 23.1.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Yi Li 
Signed-off-by: GuoX Xu 
---
 MdePkg/Include/Protocol/FirmwareManagement.h | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Protocol/FirmwareManagement.h 
b/MdePkg/Include/Protocol/FirmwareManagement.h
index f37067df3455..93c8b7658e1a 100644
--- a/MdePkg/Include/Protocol/FirmwareManagement.h
+++ b/MdePkg/Include/Protocol/FirmwareManagement.h
@@ -293,6 +293,8 @@ EFI_STATUS
  to contain the image(s) information if 
the buffer was too small.
   @param[in, out] ImageInfo  A pointer to the buffer in which firmware 
places the current image(s)
  information. The information is an array 
of EFI_FIRMWARE_IMAGE_DESCRIPTORs.
+ May be NULL with a zero ImageInfoSize in 
order to determine the size of the
+ buffer needed.
   @param[out] DescriptorVersion  A pointer to the location in which 
firmware returns the version number
  associated with the 
EFI_FIRMWARE_IMAGE_DESCRIPTOR.
   @param[out] DescriptorCountA pointer to the location in which 
firmware returns the number of
@@ -313,7 +315,12 @@ EFI_STATUS
   @retval EFI_SUCCESSThe device was successfully updated with 
the new image.
   @retval EFI_BUFFER_TOO_SMALL   The ImageInfo buffer was too small. The 
current buffer size
  needed to hold the image(s) information 
is returned in ImageInfoSize.
-  @retval EFI_INVALID_PARAMETER  ImageInfoSize is NULL.
+  @retval EFI_INVALID_PARAMETER  ImageInfoSize is not too small and 
ImageInfo is NULL.
+  @retval EFI_INVALID_PARAMETER  ImageInfoSize is non-zero and 
DescriptorVersion is NULL.
+  @retval EFI_INVALID_PARAMETER  ImageInfoSize is non-zero and 
DescriptorCount is NULL.
+  @retval EFI_INVALID_PARAMETER  ImageInfoSize is non-zero and 
DescriptorSize is NULL.
+  @retval EFI_INVALID_PARAMETER  ImageInfoSize is non-zero and 
PackageVersion is NULL.
+  @retval EFI_INVALID_PARAMETER  ImageInfoSize is non-zero and 
PackageVersionName is NULL.
   @retval EFI_DEVICE_ERROR   Valid information could not be returned. 
Possible corrupted image.
 
 **/
@@ -340,6 +347,8 @@ EFI_STATUS
   @param[in]  ImageIndex A unique number identifying the firmware 
image(s) within the device.
  The number is between 1 and DescriptorCount.
   @param[out] Image  Points to the buffer where the current image 
is copied to.
+ May be NULL with a zero ImageSize in order to 
determine the size of the
+ buffer needed.
   @param[in, out] ImageSize  On entry, points to the size of the buffer 
pointed to by Image, in bytes.
  On return, points to the length of the image, 
in bytes.
 
@@ -347,7 +356,7 @@ EFI_STATUS
   @retval EFI_BUFFER_TOO_SMALL   The buffer specified by ImageSize is too 
small to hold the
  image. The current buffer size needed to hold 
the image is returned
  in ImageSize.
-  @retval EFI_INVALID_PARAMETER  The Image was NULL.
+  @retval EFI_INVALID_PARAMETER  The ImageSize is not too small and Image is 
NULL.
   @retval EFI_NOT_FOUND  The current image is not copied to the buffer.
   @retval EFI_UNSUPPORTEDThe operation is not supported.
   @retval EFI_SECURITY_VIOLATION The operation could not be performed due to 
an authentication failure.
--
2.29.2.windows.3








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113454): https://edk2.groups.i

Re: [edk2-devel] [PATCH] BaseTools: Remove Duplicate sets of SkuName and SkuId from allskuset

2024-01-09 Thread Chan, Amy
Reviewed-by: Amy Chan 

> -Original Message-
> From: Chen, Christine 
> Sent: Monday, January 8, 2024 8:29 AM
> To: S, Ashraf Ali ; devel@edk2.groups.io
> Cc: Rebecca Cran ; Gao, Liming
> ; Feng, Bob C ; Chan,
> Amy ; Chaganty, Rangasai V
> 
> Subject: RE: [PATCH] BaseTools: Remove Duplicate sets of SkuName and SkuId
> from allskuset
> 
> Reviewed-by: Yuwei Chen 
> 
> > -Original Message-
> > From: S, Ashraf Ali 
> > Sent: Monday, December 25, 2023 11:28 PM
> > To: devel@edk2.groups.io
> > Cc: S, Ashraf Ali ; Chen, Christine
> > ; Rebecca Cran ; Gao,
> Liming
> > ; Feng, Bob C ; Chan,
> > Amy ; Chaganty, Rangasai V
> > 
> > Subject: [PATCH] BaseTools: Remove Duplicate sets of SkuName and SkuId
> > from allskuset
> >
> > Currently when the platform has many SKUs then allskuset will be having so
> > many duplicate. and while parsing the allskuset will take longer time while
> > assing Pcd.SkuInfoList.
> > This patch is to eliminate those duplicate entires to reduce the build time
> >
> > Cc: Yuwei Chen 
> > Cc: Rebecca Cran 
> > Cc: Liming Gao 
> > Cc: Bob Feng 
> > Cc: Amy Chan 
> > Cc: Sai Chaganty 
> > Signed-off-by: Ashraf Ali S 
> > ---
> >  BaseTools/Source/Python/AutoGen/PlatformAutoGen.py | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
> > b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
> > index 592d4824a4..dac81454a9 100644
> > --- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
> > +++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
> > @@ -707,6 +707,8 @@ class PlatformAutoGen(AutoGen):
> >  self._DynamicPcdList.extend(list(OtherPcdArray))
> >  self._DynamicPcdList.sort()
> >  allskuset = [(SkuName, Sku.SkuId) for pcd in self._DynamicPcdList 
> > for
> > (SkuName, Sku) in pcd.SkuInfoList.items()]
> > +# Remove duplicate sets in the list
> > +allskuset = list(set(allskuset))
> >  for pcd in self._DynamicPcdList:
> >  if len(pcd.SkuInfoList) == 1:
> >  for (SkuName, SkuId) in allskuset:
> > --
> > 2.39.1.windows.1



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




[edk2-devel] [PATCH] FmpDevicePkg: GetImageInfo Add missing condition

2024-01-09 Thread Pethaiyan Madhan
From: "Pethaiyan, Madhan" 

23.1 Firmware Management Protocol , Added missing condition check under 
GetImageInfo function,
if the PackageVersionName is NULL return EFI_INVALID_PARAMETER

Signed-off-by: Pethaiyan Madhan 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Wei6 Xu 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 1e7ec4a09e..e87094f84c 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -495,7 +495,7 @@ GetTheImageInfo (
   // Confirm that buffer isn't null
   //
   if (  (ImageInfo == NULL) || (DescriptorVersion == NULL) || (DescriptorCount 
== NULL) || (DescriptorSize == NULL)
- || (PackageVersion == NULL))
+ || (PackageVersion == NULL) || (PackageVersionName == NULL))
   {
 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImageInfo() - Pointer Parameter is 
NULL.\n", mImageIdName));
 Status = EFI_INVALID_PARAMETER;
-- 
2.38.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113452): https://edk2.groups.io/g/devel/message/113452
Mute This Topic: https://groups.io/mt/103620852/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] RedfishPkg/RedfishDebugLib: add function to print buffer.

2024-01-09 Thread Igor Kulchytskyy via groups.io
Reviewed-by: Igor Kulchytskyy 

Regards,
Igor

-Original Message-
From: Nickle Wang 
Sent: Tuesday, January 9, 2024 6:13 AM
To: devel@edk2.groups.io
Cc: Abner Chang ; Igor Kulchytskyy ; Nick 
Ramirez 
Subject: [EXTERNAL] [PATCH v2] RedfishPkg/RedfishDebugLib: add function to 
print buffer.


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

Introduce DumpBuffer function to print the buffer content. This helps
developer to debug Redfish issue.

Signed-off-by: Nickle Wang 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
---
 RedfishPkg/Include/Library/RedfishDebugLib.h  | 20 -
 .../Library/RedfishDebugLib/RedfishDebugLib.c | 45 +--
 2 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h 
b/RedfishPkg/Include/Library/RedfishDebugLib.h
index 5f75bad12a..3430cf1d14 100644
--- a/RedfishPkg/Include/Library/RedfishDebugLib.h
+++ b/RedfishPkg/Include/Library/RedfishDebugLib.h
@@ -1,7 +1,7 @@
 /** @file
   This file defines the Redfish debug library interface.

-  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights 
reserved.

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

@@ -138,4 +138,22 @@ DumpIpv4Address (
   IN EFI_IPv4_ADDRESS  *Ipv4Address
   );

+/**
+  Debug output raw data buffer.
+
+  @param[in]ErrorLevel  DEBUG macro error level
+  @param[in]Buffer  Debug output data buffer.
+  @param[in]BufferSize  The size of Buffer in byte.
+
+  @retval EFI_SUCCESS Debug dump finished.
+  @retval EFI_INVALID_PARAMETER   Buffer is NULL.
+
+**/
+EFI_STATUS
+DumpBuffer (
+  IN  UINTN  ErrorLevel,
+  IN  UINT8  *Buffer,
+  IN  UINTN  BufferSize
+  );
+
 #endif
diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c 
b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
index efa9a5ca13..3728f51213 100644
--- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
+++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
@@ -1,7 +1,7 @@
 /** @file
   Redfish debug library to debug Redfish application.

-  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights 
reserved.

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

@@ -19,8 +19,9 @@
 #define IS_EMPTY_STRING(a)  ((a) == NULL || (a)[0] == '\0')
 #endif

-#define REDFISH_JSON_STRING_LENGTH  200
-#define REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT | EDKII_JSON_INDENT(2))
+#define REDFISH_JSON_STRING_LENGTH  200
+#define REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT | 
EDKII_JSON_INDENT(2))
+#define REDFISH_PRINT_BUFFER_BYTES_PER_ROW  16

 /**
   Debug print the value of StatementValue.
@@ -366,3 +367,41 @@ DumpIpv4Address (

   return EFI_SUCCESS;
 }
+
+/**
+  Debug output raw data buffer.
+
+  @param[in]ErrorLevel  DEBUG macro error level
+  @param[in]Buffer  Debug output data buffer.
+  @param[in]BufferSize  The size of Buffer in byte.
+
+  @retval EFI_SUCCESS Debug dump finished.
+  @retval EFI_INVALID_PARAMETER   Buffer is NULL.
+
+**/
+EFI_STATUS
+DumpBuffer (
+  IN  UINTN  ErrorLevel,
+  IN  UINT8  *Buffer,
+  IN  UINTN  BufferSize
+  )
+{
+  UINTN  Index;
+
+  if (Buffer == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  DEBUG ((ErrorLevel, "Address: 0x%p size: %d\n", Buffer, BufferSize));
+  for (Index = 0; Index < BufferSize; Index++) {
+if (Index % REDFISH_PRINT_BUFFER_BYTES_PER_ROW == 0) {
+  DEBUG ((ErrorLevel, "\n%04X: ", Index));
+}
+
+DEBUG ((ErrorLevel, "%02X ", Buffer[Index]));
+  }
+
+  DEBUG ((ErrorLevel, "\n"));
+
+  return EFI_SUCCESS;
+}
--
2.34.1

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


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




Re: [edk2-devel] [PATCH v5 3/3] OvmfPkg/VirtNorFlashDxe: sanity-check variables

2024-01-09 Thread Gerd Hoffmann
  Hi,

> Nit: to my knowledge, the coding style forbids initialization of "auto"
> storage class variables (more commonly put, "non-static local
> variables"). IOW, we should spell the above as:
> 
> | diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c 
> b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> | index ca2e40743dfd..8fcd999ac6df 100644
> | --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> | +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> | @@ -283,7 +283,9 @@ ValidateFvHeader (
> |
> |  if (VarHeaderEnd >= VariableStoreHeader->Size) {
> |if (VarOffset <= VariableStoreHeader->Size - sizeof (UINT16)) {
> | -CONST UINT16  *StartId = (VOID *)((UINTN)VariableStoreHeader + 
> VarOffset);
> | +CONST UINT16  *StartId;
> | +
> | +StartId = (VOID *)((UINTN)VariableStoreHeader + VarOffset);
> |  if (*StartId == 0x55aa) {
> |DEBUG ((DEBUG_ERROR, "%a: startid at invalid location\n", 
> __func__));
> |return EFI_NOT_FOUND;
> 
> Do you want me to fix up the patch upon merge for you,

I happily accept that service offer ;)

thanks,
  Gerd



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




Re: [edk2-devel] Updates to .mailmap needed for Jeff Brasen, Jake Garver, Joey Vagades and Michael Roth?

2024-01-09 Thread Laszlo Ersek
On 1/9/24 13:28, Michael Brown wrote:
> On 09/01/2024 12:13, Laszlo Ersek wrote:
>> On 1/9/24 11:45, Ard Biesheuvel wrote:
>>> Note that git am does support a 'From: ' header as the first line of
>>> the commit log, and will use it correctly to supersede the From:
>>> header in the SMTP envelope.
>>
>> OTOH, that doesn't help in this case, IIUC. When the poster originally
>> formats and sends the patch, their gitconfig says
>> user.email=foo...@example.com, and the author meta-datum on the patch
>> most likely *also* says foo...@example.com. (I.e., they are formatting a
>> patch they have authored themselves.) Therefore
>> git-format-patch/git-send-email have no reason to include an explicit
>> "From:" line at the top of the commit message body. I agree that
>> "From:", if present, mitigates the issue, but in most cases, I reckon,
>> it's not present.
> 
> Is there a way to configure git to force git-format-patch to
> unconditionally include the inline "From:" header?  I tried:
> 
>   git config format.forceInBodyFrom true
> 
> which is described in the man page as "may help if the mailing list
> software mangles the sender’s identity", but it seems to have an effect
> only if "--from" is also specified.

That still sounds great; I (and I expect many others) use alias(es)
around git-format-patch anyway (because of [1] eg.), so wiring "--from"
into that could work. (Not that I personally need this quirk right at
the moment.)

[1]
https://github.com/tianocore/tianocore.github.io/wiki/Laszlo%27s-unkempt-git-guide-for-edk2-contributors-and-maintainers#contrib-23

What confuses me is that git-format-patch(1) specifically advises
against the "--from" option "if you are feeding the result to git
send-email". Huh.

Thanks!
Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113448): https://edk2.groups.io/g/devel/message/113448
Mute This Topic: https://groups.io/mt/103534194/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 v5 3/3] OvmfPkg/VirtNorFlashDxe: sanity-check variables

2024-01-09 Thread Laszlo Ersek
On 1/9/24 12:29, Gerd Hoffmann wrote:
> Extend the ValidateFvHeader function, additionally to the header checks
> walk over the list of variables and sanity check them.
>
> In case we find inconsistencies indicating variable store corruption
> return EFI_NOT_FOUND so the variable store will be re-initialized.
>
> Signed-off-by: Gerd Hoffmann 
> ---
>  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf |   1 +
>  OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c   | 147 +++-
>  2 files changed, 143 insertions(+), 5 deletions(-)
>
> diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf 
> b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
> index 2a3d4a218e61..f549400280a1 100644
> --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
> +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
> @@ -34,6 +34,7 @@ [LibraryClasses]
>DxeServicesTableLib
>HobLib
>IoLib
> +  SafeIntLib
>UefiBootServicesTableLib
>UefiDriverEntryPoint
>UefiLib
> diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c 
> b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> index 9a614ae4b24d..ca2e40743dfd 100644
> --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  #include 
> @@ -185,11 +186,12 @@ ValidateFvHeader (
>IN  NOR_FLASH_INSTANCE  *Instance
>)
>  {
> -  UINT16  Checksum;
> -  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;
> -  VARIABLE_STORE_HEADER   *VariableStoreHeader;
> -  UINTN   VariableStoreLength;
> -  UINTN   FvLength;
> +  UINT16Checksum;
> +  CONST EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;
> +  CONST VARIABLE_STORE_HEADER   *VariableStoreHeader;
> +  UINTN VarOffset;
> +  UINTN VariableStoreLength;
> +  UINTN FvLength;
>
>FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Instance->RegionBaseAddress;
>
> @@ -258,6 +260,141 @@ ValidateFvHeader (
>  return EFI_NOT_FOUND;
>}
>
> +  //
> +  // check variables
> +  //
> +  DEBUG ((DEBUG_INFO, "%a: checking variables\n", __func__));
> +  VarOffset = sizeof (*VariableStoreHeader);
> +  for ( ; ;) {
> +UINTNVarHeaderEnd;
> +UINTNVarNameEnd;
> +UINTNVarEnd;
> +UINTNVarPadding;
> +CONST AUTHENTICATED_VARIABLE_HEADER  *VarHeader;
> +CONST CHAR16 *VarName;
> +CONST CHAR8  *VarState;
> +RETURN_STATUSStatus;
> +
> +Status = SafeUintnAdd (VarOffset, sizeof (*VarHeader), &VarHeaderEnd);
> +if (RETURN_ERROR (Status)) {
> +  DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__));
> +  return EFI_NOT_FOUND;
> +}
> +
> +if (VarHeaderEnd >= VariableStoreHeader->Size) {
> +  if (VarOffset <= VariableStoreHeader->Size - sizeof (UINT16)) {
> +CONST UINT16  *StartId = (VOID *)((UINTN)VariableStoreHeader + 
> VarOffset);
> +if (*StartId == 0x55aa) {
> +  DEBUG ((DEBUG_ERROR, "%a: startid at invalid location\n", 
> __func__));
> +  return EFI_NOT_FOUND;
> +}
> +  }
> +
> +  DEBUG ((DEBUG_INFO, "%a: end of var list (no space left)\n", 
> __func__));
> +  break;
> +}

I didn't think of this, but it certainly makes sense. Continues
accepting trailing garbage, unless the tail starts with 0x55aa, which
indicates that it's indeed either a truncated variable header, or one
that's not truncated, but just fits (and has no room for subsequent
name/data).

Furthermore, we consider "VariableStoreHeader->Size" trusted & valid
here, therefore the subtraction of sizeof (UINT16) is not supposed to
wrap under. (The field is documented with: "Size of entire variable
store, including size of variable store header but not including the
size of FvHeader". The varstore hdr structure is larger than 2 bytes.)

Reviewed-by: Laszlo Ersek 

Nit: to my knowledge, the coding style forbids initialization of "auto"
storage class variables (more commonly put, "non-static local
variables"). IOW, we should spell the above as:

| diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
| index ca2e40743dfd..8fcd999ac6df 100644
| --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
| +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
| @@ -283,7 +283,9 @@ ValidateFvHeader (
|
|  if (VarHeaderEnd >= VariableStoreHeader->Size) {
|if (VarOffset <= VariableStoreHeader->Size - sizeof (UINT16)) {
| -CONST UINT16  *StartId = (VOID *)((UINTN)VariableStoreHeader + 
VarOffset);
| +CONST UINT16  *StartId;
| +
| +StartId = (VOID *)((UINTN)VariableStoreHeader + VarOffset);
|  if (*StartId == 0x55aa) {
|DEBUG ((DE

Re: [edk2-devel] Updates to .mailmap needed for Jeff Brasen, Jake Garver, Joey Vagades and Michael Roth?

2024-01-09 Thread Michael Brown

On 09/01/2024 12:13, Laszlo Ersek wrote:

On 1/9/24 11:45, Ard Biesheuvel wrote:

Note that git am does support a 'From: ' header as the first line of
the commit log, and will use it correctly to supersede the From:
header in the SMTP envelope.


OTOH, that doesn't help in this case, IIUC. When the poster originally
formats and sends the patch, their gitconfig says
user.email=foo...@example.com, and the author meta-datum on the patch
most likely *also* says foo...@example.com. (I.e., they are formatting a
patch they have authored themselves.) Therefore
git-format-patch/git-send-email have no reason to include an explicit
"From:" line at the top of the commit message body. I agree that
"From:", if present, mitigates the issue, but in most cases, I reckon,
it's not present.


Is there a way to configure git to force git-format-patch to 
unconditionally include the inline "From:" header?  I tried:


  git config format.forceInBodyFrom true

which is described in the man page as "may help if the mailing list 
software mangles the sender’s identity", but it seems to have an effect 
only if "--from" is also specified.


Thanks,

Michael



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




Re: [edk2-devel] Updates to .mailmap needed for Jeff Brasen, Jake Garver, Joey Vagades and Michael Roth?

2024-01-09 Thread Laszlo Ersek
On 1/9/24 11:45, Ard Biesheuvel wrote:
> On Tue, 9 Jan 2024 at 10:17, Laszlo Ersek  wrote:
>>
>> On 1/5/24 01:05, Rebecca Cran via groups.io wrote:
>>> I noticed recent commits by Jeff Brasen, Jake Garver, Joey Vagades and
>>> Michael Roth have funky Author lines, which I think means .mailmap needs
>>> updated?
>>>
>>> Author: Jeff Brasen via groups.io 
>>> Author: Joey Vagedes via groups.io 
>>> Author: Jake Garver via groups.io 
>>> Author: Roth, Michael via groups.io 
>>
>> I'm sure I'm confusing the terms here, but this is a consequence of
>> DMARC / DKIM / whatever, for some senders. groups.io cannot resend some
>> kind of messages to list subscribers where the original sender domain
>> (such as nvidia.com, microsoft.com, amd.com) is cryptographically
>> authenticated. If groups.io resent those messages with identical "from",
>> then the recipients (list subscribers) would reject those messages,
>> because they'd perceive the messages as fakes (the crypto check would
>> catch that the messages came from groups.io but claimed to originate
>> from nvidia.com, microsoft.com, amd.com -- that's exactly what DKIM /
>> DMARC etc etc are supposed to prevent). Therefore groups.io rewrites the
>> sender email addresses like seen above, and then "git-am" picks up those
>> rewritten addresses verbatim. That's how they end up in the git commit
>> history.
>>
>> This can be manually fixed by whoever applies such patches from the
>> list: after the initial "git-am", a git-rebase is needed, and each patch
>> needs to have its author meta-datum fixed with "git commit --amend
>> --author='corrected email address'". It's a lot of manual and error
>> prone work (unless someone scripts it, effectively "decoding" the
>> rewriting format that groups.io employs). As much as it pains me to
>> admit it, this is definitely an argument in favor of git forge-based
>> contributions, and against mailing list-based patches.
>>
>> ".mailmap" can be used to mitigate this issue, per gitmailmap(5); it'd
>> be better just not to permit such mangled "From:" fields to seep into
>> the git log, in the future. :/
>>
> 
> Agreed, and I think this came up somewhere last year perhaps? Mike
> Kinney (cc'ed) might remember if that went anywhere, but the idea was
> for PatchCheck.py (which is also used in CI) to reject patches using
> an email address in this format.

Oh, great idea. When CI runs PatchCheck.py on the final "push" PR, that
would definitely catch this issue just in time!

> 
> Note that git am does support a 'From: ' header as the first line of
> the commit log, and will use it correctly to supersede the From:
> header in the SMTP envelope.

OTOH, that doesn't help in this case, IIUC. When the poster originally
formats and sends the patch, their gitconfig says
user.email=foo...@example.com, and the author meta-datum on the patch
most likely *also* says foo...@example.com. (I.e., they are formatting a
patch they have authored themselves.) Therefore
git-format-patch/git-send-email have no reason to include an explicit
"From:" line at the top of the commit message body. I agree that
"From:", if present, mitigates the issue, but in most cases, I reckon,
it's not present.

Laszlo



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




[edk2-devel] [PATCH v5 1/3] OvmfPkg/RiscVVirt: use gEfiAuthenticatedVariableGuid unconditionally

2024-01-09 Thread Gerd Hoffmann
ArmVirt and OVMF are doing the same.

See commit d92eaabefbe0 ("OvmfPkg: simplify VARIABLE_STORE_HEADER
generation") for details.

Suggested-by: László Érsek 
Signed-off-by: Gerd Hoffmann 
Reviewed-by: Sunil V L 
Reviewed-by: Laszlo Ersek 
---
 OvmfPkg/RiscVVirt/VarStore.fdf.inc | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/OvmfPkg/RiscVVirt/VarStore.fdf.inc 
b/OvmfPkg/RiscVVirt/VarStore.fdf.inc
index aba32315cc37..6679c246b3ea 100644
--- a/OvmfPkg/RiscVVirt/VarStore.fdf.inc
+++ b/OvmfPkg/RiscVVirt/VarStore.fdf.inc
@@ -36,19 +36,12 @@
   # Blockmap[1]: End
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   ## This is the VARIABLE_STORE_HEADER
-!if $(SECURE_BOOT_ENABLE) == TRUE
+  # It is compatible with SECURE_BOOT_ENABLE == FALSE as well.
   # Signature: gEfiAuthenticatedVariableGuid =
   #   { 0xaaf32c78, 0x947b, 0x439a,
   # { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 }}
   0x78, 0x2c, 0xf3, 0xaa, 0x7b, 0x94, 0x9a, 0x43,
   0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92,
-!else
-  # Signature: gEfiVariableGuid =
-  #   { 0xddcf3616, 0x3275, 0x4164,
-  # { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d }}
-  0x16, 0x36, 0xcf, 0xdd, 0x75, 0x32, 0x64, 0x41,
-  0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d,
-!endif
   # Size: 0x4 
(gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize) -
   # 0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) = 0x3FFB8
   # This can speed up the Variable Dispatch a bit.
-- 
2.43.0



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




[edk2-devel] [PATCH v5 0/3] OvmfPkg/VirtNorFlashDxe: sanity-check variables

2024-01-09 Thread Gerd Hoffmann
v5:
 - pick up review tags
 - more variable check fine tuning.
v4:
 - turn into a little patch series.
 - stop using gEfiVariableGuid in risc-v.
 - stop accepting gEfiVariableGuid in VirtNorFlashDxe.
 - refine variable checking.

Gerd Hoffmann (3):
  OvmfPkg/RiscVVirt: use gEfiAuthenticatedVariableGuid unconditionally
  OvmfPkg/VirtNorFlashDxe: stop accepting gEfiVariableGuid
  OvmfPkg/VirtNorFlashDxe: sanity-check variables

 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf |   1 +
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c   | 151 ++--
 OvmfPkg/RiscVVirt/VarStore.fdf.inc  |   9 +-
 3 files changed, 145 insertions(+), 16 deletions(-)

-- 
2.43.0



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




[edk2-devel] [PATCH v5 2/3] OvmfPkg/VirtNorFlashDxe: stop accepting gEfiVariableGuid

2024-01-09 Thread Gerd Hoffmann
Only accept gEfiAuthenticatedVariableGuid when checking the variable
store header in ValidateFvHeader().

The edk2 code base has been switched to use the authenticated varstore
format unconditionally (even in case secure boot is not used or
supported) a few years ago.

Suggested-by: László Érsek 
Signed-off-by: Gerd Hoffmann 
Reviewed-by: Laszlo Ersek 
---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
index 5ee98e9b595a..9a614ae4b24d 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
@@ -239,9 +239,7 @@ ValidateFvHeader (
   VariableStoreHeader = (VARIABLE_STORE_HEADER *)((UINTN)FwVolHeader + 
FwVolHeader->HeaderLength);
 
   // Check the Variable Store Guid
-  if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) &&
-  !CompareGuid (&VariableStoreHeader->Signature, 
&gEfiAuthenticatedVariableGuid))
-  {
+  if (!CompareGuid (&VariableStoreHeader->Signature, 
&gEfiAuthenticatedVariableGuid)) {
 DEBUG ((
   DEBUG_INFO,
   "%a: Variable Store Guid non-compatible\n",
-- 
2.43.0



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




[edk2-devel] [PATCH v5 3/3] OvmfPkg/VirtNorFlashDxe: sanity-check variables

2024-01-09 Thread Gerd Hoffmann
Extend the ValidateFvHeader function, additionally to the header checks
walk over the list of variables and sanity check them.

In case we find inconsistencies indicating variable store corruption
return EFI_NOT_FOUND so the variable store will be re-initialized.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf |   1 +
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c   | 147 +++-
 2 files changed, 143 insertions(+), 5 deletions(-)

diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
index 2a3d4a218e61..f549400280a1 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
@@ -34,6 +34,7 @@ [LibraryClasses]
   DxeServicesTableLib
   HobLib
   IoLib
+  SafeIntLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
   UefiLib
diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
index 9a614ae4b24d..ca2e40743dfd 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -185,11 +186,12 @@ ValidateFvHeader (
   IN  NOR_FLASH_INSTANCE  *Instance
   )
 {
-  UINT16  Checksum;
-  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;
-  VARIABLE_STORE_HEADER   *VariableStoreHeader;
-  UINTN   VariableStoreLength;
-  UINTN   FvLength;
+  UINT16Checksum;
+  CONST EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;
+  CONST VARIABLE_STORE_HEADER   *VariableStoreHeader;
+  UINTN VarOffset;
+  UINTN VariableStoreLength;
+  UINTN FvLength;
 
   FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Instance->RegionBaseAddress;
 
@@ -258,6 +260,141 @@ ValidateFvHeader (
 return EFI_NOT_FOUND;
   }
 
+  //
+  // check variables
+  //
+  DEBUG ((DEBUG_INFO, "%a: checking variables\n", __func__));
+  VarOffset = sizeof (*VariableStoreHeader);
+  for ( ; ;) {
+UINTNVarHeaderEnd;
+UINTNVarNameEnd;
+UINTNVarEnd;
+UINTNVarPadding;
+CONST AUTHENTICATED_VARIABLE_HEADER  *VarHeader;
+CONST CHAR16 *VarName;
+CONST CHAR8  *VarState;
+RETURN_STATUSStatus;
+
+Status = SafeUintnAdd (VarOffset, sizeof (*VarHeader), &VarHeaderEnd);
+if (RETURN_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__));
+  return EFI_NOT_FOUND;
+}
+
+if (VarHeaderEnd >= VariableStoreHeader->Size) {
+  if (VarOffset <= VariableStoreHeader->Size - sizeof (UINT16)) {
+CONST UINT16  *StartId = (VOID *)((UINTN)VariableStoreHeader + 
VarOffset);
+if (*StartId == 0x55aa) {
+  DEBUG ((DEBUG_ERROR, "%a: startid at invalid location\n", __func__));
+  return EFI_NOT_FOUND;
+}
+  }
+
+  DEBUG ((DEBUG_INFO, "%a: end of var list (no space left)\n", __func__));
+  break;
+}
+
+VarHeader = (VOID *)((UINTN)VariableStoreHeader + VarOffset);
+if (VarHeader->StartId != 0x55aa) {
+  DEBUG ((DEBUG_INFO, "%a: end of var list (no startid)\n", __func__));
+  break;
+}
+
+VarName = NULL;
+switch (VarHeader->State) {
+  // usage: State = VAR_HEADER_VALID_ONLY
+  case VAR_HEADER_VALID_ONLY:
+VarState = "header-ok";
+VarName  = L"";
+break;
+
+  // usage: State = VAR_ADDED
+  case VAR_ADDED:
+VarState = "ok";
+break;
+
+  // usage: State &= VAR_IN_DELETED_TRANSITION
+  case VAR_ADDED &VAR_IN_DELETED_TRANSITION:
+VarState = "del-in-transition";
+break;
+
+  // usage: State &= VAR_DELETED
+  case VAR_ADDED &VAR_DELETED:
+  case VAR_ADDED &VAR_DELETED &VAR_IN_DELETED_TRANSITION:
+VarState = "deleted";
+break;
+
+  default:
+DEBUG ((
+  DEBUG_ERROR,
+  "%a: invalid variable state: 0x%x\n",
+  __func__,
+  VarHeader->State
+  ));
+return EFI_NOT_FOUND;
+}
+
+Status = SafeUintnAdd (VarHeaderEnd, VarHeader->NameSize, &VarNameEnd);
+if (RETURN_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__));
+  return EFI_NOT_FOUND;
+}
+
+Status = SafeUintnAdd (VarNameEnd, VarHeader->DataSize, &VarEnd);
+if (RETURN_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__));
+  return EFI_NOT_FOUND;
+}
+
+if (VarEnd > VariableStoreHeader->Size) {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: invalid variable size: 0x%Lx + 0x%Lx + 0x%x + 0x%x > 0x%x\n",
+__func__,
+(UINT64)VarOffset,
+(UINT64)(sizeof 

Re: [edk2-devel] [PATCH] RedfishPkg/RedfishDebugLib: add function to print buffer.

2024-01-09 Thread Nickle Wang via groups.io
Thanks for your review, @Chang, Abner!  Version 2 
patch is sent for review here: https://edk2.groups.io/g/devel/message/113439



Regards,

Nickle



> -Original Message-

> From: Chang, Abner 

> Sent: Tuesday, January 9, 2024 4:00 PM

> To: Nickle Wang ; devel@edk2.groups.io

> Cc: Igor Kulchytskyy ; Nick Ramirez 

> Subject: RE: [PATCH] RedfishPkg/RedfishDebugLib: add function to print buffer.

>

> External email: Use caution opening links or attachments

>

>

> [AMD Official Use Only - General]

>

> > -Original Message-

> > From: Nickle Wang mailto:nick...@nvidia.com>>

> > Sent: Tuesday, January 9, 2024 3:15 PM

> > To: devel@edk2.groups.io

> > Cc: Chang, Abner mailto:abner.ch...@amd.com>>; Igor 
> > Kulchytskyy

> > mailto:ig...@ami.com>>; Nick Ramirez 
> > mailto:nrami...@nvidia.com>>

> > Subject: [PATCH] RedfishPkg/RedfishDebugLib: add function to print buffer.

> >

> > Caution: This message originated from an External Source. Use proper

> > caution when opening attachments, clicking links, or responding.

> >

> >

> > Introduce DumpBuffer function to print the buffer content. This helps

> > developer to debug Redfish issue.

> >

> > Signed-off-by: Nickle Wang mailto:nick...@nvidia.com>>

> > Cc: Abner Chang mailto:abner.ch...@amd.com>>

> > Cc: Igor Kulchytskyy mailto:ig...@ami.com>>

> > Cc: Nick Ramirez mailto:nrami...@nvidia.com>>

> > ---

> >  RedfishPkg/Include/Library/RedfishDebugLib.h  | 20 -

> > .../Library/RedfishDebugLib/RedfishDebugLib.c | 41 ++-

> >  2 files changed, 59 insertions(+), 2 deletions(-)

> >

> > diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h

> > b/RedfishPkg/Include/Library/RedfishDebugLib.h

> > index 5f75bad12a..3430cf1d14 100644

> > --- a/RedfishPkg/Include/Library/RedfishDebugLib.h

> > +++ b/RedfishPkg/Include/Library/RedfishDebugLib.h

> > @@ -1,7 +1,7 @@

> >  /** @file

> >This file defines the Redfish debug library interface.

> >

> > -  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

> > +  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All

> > + rights

> > reserved.

> >

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

> >

> > @@ -138,4 +138,22 @@ DumpIpv4Address (

> >IN EFI_IPv4_ADDRESS  *Ipv4Address

> >);

> >

> > +/**

> > +  Debug output raw data buffer.

> > +

> > +  @param[in]ErrorLevel  DEBUG macro error level

> > +  @param[in]Buffer  Debug output data buffer.

> > +  @param[in]BufferSize  The size of Buffer in byte.

> > +

> > +  @retval EFI_SUCCESS Debug dump finished.

> > +  @retval EFI_INVALID_PARAMETER   Buffer is NULL.

> > +

> > +**/

> > +EFI_STATUS

> > +DumpBuffer (

> > +  IN  UINTN  ErrorLevel,

> > +  IN  UINT8  *Buffer,

> > +  IN  UINTN  BufferSize

> > +  );

> > +

> >  #endif

> > diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c

> > b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c

> > index efa9a5ca13..5fd40ad955 100644

> > --- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c

> > +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c

> > @@ -1,7 +1,7 @@

> >  /** @file

> >Redfish debug library to debug Redfish application.

> >

> > -  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

> > +  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All

> > + rights

> > reserved.

> >

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

> >

> > @@ -21,6 +21,7 @@

> >

> >  #define REDFISH_JSON_STRING_LENGTH  200  #define

> > REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT |

> > EDKII_JSON_INDENT(2))

> > +#define REDFISH_SIZE_PER_ROW16

>

> How about name this as REDFISH_PRINT_BUFFER_BYTES_PER_ROW, looks more

> clear.

>

> Abner

>

> >

> >  /**

> >Debug print the value of StatementValue.

> > @@ -366,3 +367,41 @@ DumpIpv4Address (

> >

> >return EFI_SUCCESS;

> >  }

> > +

> > +/**

> > +  Debug output raw data buffer.

> > +

> > +  @param[in]ErrorLevel  DEBUG macro error level

> > +  @param[in]Buffer  Debug output data buffer.

> > +  @param[in]BufferSize  The size of Buffer in byte.

> > +

> > +  @retval EFI_SUCCESS Debug dump finished.

> > +  @retval EFI_INVALID_PARAMETER   Buffer is NULL.

> > +

> > +**/

> > +EFI_STATUS

> > +DumpBuffer (

> > +  IN  UINTN  ErrorLevel,

> > +  IN  UINT8  *Buffer,

> > +  IN  UINTN  BufferSize

> > +  )

> > +{

> > +  UINTN  Index;

> > +

> > +  if (Buffer == NULL) {

> > +return EFI_INVALID_PARAMETER;

> > +  }

> > +

> > +  DEBUG ((ErrorLevel, "Address: 0x%p size: %d\n", Buffer,

> > + BufferSize));  for (Index = 0; Index < BufferSize; Index++) {

> > +if (Index % REDFISH_SIZE_PER_ROW == 0) {

> > +  DEBUG ((ErrorLevel, "\n%04X: ", Index));

> > +}

> > +

> > +DEBUG ((ErrorLevel, "%02X ", Buffer[Index]));  }

> > +

> > +  DEBUG (

[edk2-devel] [PATCH v2] RedfishPkg/RedfishDebugLib: add function to print buffer.

2024-01-09 Thread Nickle Wang via groups.io
Introduce DumpBuffer function to print the buffer content. This helps
developer to debug Redfish issue.

Signed-off-by: Nickle Wang 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
---
 RedfishPkg/Include/Library/RedfishDebugLib.h  | 20 -
 .../Library/RedfishDebugLib/RedfishDebugLib.c | 45 +--
 2 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h 
b/RedfishPkg/Include/Library/RedfishDebugLib.h
index 5f75bad12a..3430cf1d14 100644
--- a/RedfishPkg/Include/Library/RedfishDebugLib.h
+++ b/RedfishPkg/Include/Library/RedfishDebugLib.h
@@ -1,7 +1,7 @@
 /** @file
   This file defines the Redfish debug library interface.
 
-  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights 
reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -138,4 +138,22 @@ DumpIpv4Address (
   IN EFI_IPv4_ADDRESS  *Ipv4Address
   );
 
+/**
+  Debug output raw data buffer.
+
+  @param[in]ErrorLevel  DEBUG macro error level
+  @param[in]Buffer  Debug output data buffer.
+  @param[in]BufferSize  The size of Buffer in byte.
+
+  @retval EFI_SUCCESS Debug dump finished.
+  @retval EFI_INVALID_PARAMETER   Buffer is NULL.
+
+**/
+EFI_STATUS
+DumpBuffer (
+  IN  UINTN  ErrorLevel,
+  IN  UINT8  *Buffer,
+  IN  UINTN  BufferSize
+  );
+
 #endif
diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c 
b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
index efa9a5ca13..3728f51213 100644
--- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
+++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
@@ -1,7 +1,7 @@
 /** @file
   Redfish debug library to debug Redfish application.
 
-  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights 
reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -19,8 +19,9 @@
 #define IS_EMPTY_STRING(a)  ((a) == NULL || (a)[0] == '\0')
 #endif
 
-#define REDFISH_JSON_STRING_LENGTH  200
-#define REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT | EDKII_JSON_INDENT(2))
+#define REDFISH_JSON_STRING_LENGTH  200
+#define REDFISH_JSON_OUTPUT_FORMAT  (EDKII_JSON_COMPACT | 
EDKII_JSON_INDENT(2))
+#define REDFISH_PRINT_BUFFER_BYTES_PER_ROW  16
 
 /**
   Debug print the value of StatementValue.
@@ -366,3 +367,41 @@ DumpIpv4Address (
 
   return EFI_SUCCESS;
 }
+
+/**
+  Debug output raw data buffer.
+
+  @param[in]ErrorLevel  DEBUG macro error level
+  @param[in]Buffer  Debug output data buffer.
+  @param[in]BufferSize  The size of Buffer in byte.
+
+  @retval EFI_SUCCESS Debug dump finished.
+  @retval EFI_INVALID_PARAMETER   Buffer is NULL.
+
+**/
+EFI_STATUS
+DumpBuffer (
+  IN  UINTN  ErrorLevel,
+  IN  UINT8  *Buffer,
+  IN  UINTN  BufferSize
+  )
+{
+  UINTN  Index;
+
+  if (Buffer == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  DEBUG ((ErrorLevel, "Address: 0x%p size: %d\n", Buffer, BufferSize));
+  for (Index = 0; Index < BufferSize; Index++) {
+if (Index % REDFISH_PRINT_BUFFER_BYTES_PER_ROW == 0) {
+  DEBUG ((ErrorLevel, "\n%04X: ", Index));
+}
+
+DEBUG ((ErrorLevel, "%02X ", Buffer[Index]));
+  }
+
+  DEBUG ((ErrorLevel, "\n"));
+
+  return EFI_SUCCESS;
+}
-- 
2.34.1



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




Re: [edk2-devel] Updates to .mailmap needed for Jeff Brasen, Jake Garver, Joey Vagades and Michael Roth?

2024-01-09 Thread Ard Biesheuvel
On Tue, 9 Jan 2024 at 10:17, Laszlo Ersek  wrote:
>
> On 1/5/24 01:05, Rebecca Cran via groups.io wrote:
> > I noticed recent commits by Jeff Brasen, Jake Garver, Joey Vagades and
> > Michael Roth have funky Author lines, which I think means .mailmap needs
> > updated?
> >
> > Author: Jeff Brasen via groups.io 
> > Author: Joey Vagedes via groups.io 
> > Author: Jake Garver via groups.io 
> > Author: Roth, Michael via groups.io 
>
> I'm sure I'm confusing the terms here, but this is a consequence of
> DMARC / DKIM / whatever, for some senders. groups.io cannot resend some
> kind of messages to list subscribers where the original sender domain
> (such as nvidia.com, microsoft.com, amd.com) is cryptographically
> authenticated. If groups.io resent those messages with identical "from",
> then the recipients (list subscribers) would reject those messages,
> because they'd perceive the messages as fakes (the crypto check would
> catch that the messages came from groups.io but claimed to originate
> from nvidia.com, microsoft.com, amd.com -- that's exactly what DKIM /
> DMARC etc etc are supposed to prevent). Therefore groups.io rewrites the
> sender email addresses like seen above, and then "git-am" picks up those
> rewritten addresses verbatim. That's how they end up in the git commit
> history.
>
> This can be manually fixed by whoever applies such patches from the
> list: after the initial "git-am", a git-rebase is needed, and each patch
> needs to have its author meta-datum fixed with "git commit --amend
> --author='corrected email address'". It's a lot of manual and error
> prone work (unless someone scripts it, effectively "decoding" the
> rewriting format that groups.io employs). As much as it pains me to
> admit it, this is definitely an argument in favor of git forge-based
> contributions, and against mailing list-based patches.
>
> ".mailmap" can be used to mitigate this issue, per gitmailmap(5); it'd
> be better just not to permit such mangled "From:" fields to seep into
> the git log, in the future. :/
>

Agreed, and I think this came up somewhere last year perhaps? Mike
Kinney (cc'ed) might remember if that went anywhere, but the idea was
for PatchCheck.py (which is also used in CI) to reject patches using
an email address in this format.

Note that git am does support a 'From: ' header as the first line of
the commit log, and will use it correctly to supersede the From:
header in the SMTP envelope.


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




Re: [edk2-devel] [PATCH V3 0/2] Change the comments RFC1323 to RFC7323

2024-01-09 Thread Ren, Suqiang
Hi Liming,

Thanks for review this Pull Request: 
https://github.com/tianocore/edk2/pull/5190.

Since All checks have passed. Could you please help to push it?

Thanks
Ren, Suqiang

-Original Message-
From: devel@edk2.groups.io  On Behalf Of gaoliming via 
groups.io
Sent: Monday, January 8, 2024 9:15 AM
To: devel@edk2.groups.io; Ren, SuqiangX 
Cc: Kinney, Michael D ; Liu, Zhiguang 
; Kasbekar, Saloni ; 
Clark-williams, Zachary 
Subject: 回复: [edk2-devel] [PATCH V3 0/2] Change the comments RFC1323 to RFC7323

This change looks good to me. Reviewed-by: Liming Gao 

I will merge it. 

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Ren, Suqiang
> 发送时间: 2024年1月3日 20:38
> 收件人: devel@edk2.groups.io; Gao, Liming 
> 抄送: Kinney, Michael D ; Liu, Zhiguang 
> ; Kasbekar, Saloni 
> ; Clark-williams, Zachary 
> 
> 主题: Re: [edk2-devel] [PATCH V3 0/2] Change the comments RFC1323 to
> RFC7323
> 
> Add the Pull Request link: https://github.com/tianocore/edk2/pull/5190.
> 
> Thanks
> Ren, Suqiang
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ren, 
> Suqiang
> Sent: Tuesday, January 2, 2024 2:33 PM
> To: devel@edk2.groups.io; Ren, SuqiangX 
> Cc: Kinney, Michael D ; Gao, Liming 
> ; Liu, Zhiguang ; 
> Kasbekar, Saloni ; Clark-williams, Zachary 
> 
> Subject: Re: [edk2-devel] [PATCH V3 0/2] Change the comments RFC1323 
> to
> RFC7323
> 
> Hi Liming,
> 
>   This patch has reviewed by Kasbekar, Saloni:
> https://edk2.groups.io/g/devel/message/112933
> 
>   Could you help to merge this patch?
> 
> 
> Thanks
> Ren, Suqiang
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ren, 
> Suqiang
> Sent: Tuesday, December 26, 2023 5:02 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D ; Gao, Liming 
> ; Liu, Zhiguang ; 
> Kasbekar, Saloni ; Clark-williams, Zachary 
> 
> Subject: [edk2-devel] [PATCH V3 0/2] Change the comments RFC1323 to
> RFC7323
> 
> REF: UEFI spec 2.10 Table 28.2.5
> 
> Change the description of RFC1323 to align with UEFI spec 2.10.
> 
> v3:
> Add the NetworkPkg change for RFC1323.
> 
> v2:
> Update the commit message.
> 
> Signed-off-by: Suqiang Ren 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Cc: Saloni Kasbekar 
> Cc: Zachary Clark-williams 
> 
> Suqiang Ren (2):
>   MdePkg: RFC1323 definition changed to RFC7323
>   NetworkPkg: RFC1323 definition changed to RFC7323
> 
>  MdePkg/Include/Protocol/Tcp6.h | 4 ++--
>  NetworkPkg/TcpDxe/TcpInput.c   | 2 +-
>  NetworkPkg/TcpDxe/TcpProto.h   | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> --
> 2.26.2.windows.1
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 










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




Re: [edk2-devel] Updates to .mailmap needed for Jeff Brasen, Jake Garver, Joey Vagades and Michael Roth?

2024-01-09 Thread Laszlo Ersek
On 1/5/24 01:05, Rebecca Cran via groups.io wrote:
> I noticed recent commits by Jeff Brasen, Jake Garver, Joey Vagades and
> Michael Roth have funky Author lines, which I think means .mailmap needs
> updated?
> 
> Author: Jeff Brasen via groups.io 
> Author: Joey Vagedes via groups.io 
> Author: Jake Garver via groups.io 
> Author: Roth, Michael via groups.io 

I'm sure I'm confusing the terms here, but this is a consequence of
DMARC / DKIM / whatever, for some senders. groups.io cannot resend some
kind of messages to list subscribers where the original sender domain
(such as nvidia.com, microsoft.com, amd.com) is cryptographically
authenticated. If groups.io resent those messages with identical "from",
then the recipients (list subscribers) would reject those messages,
because they'd perceive the messages as fakes (the crypto check would
catch that the messages came from groups.io but claimed to originate
from nvidia.com, microsoft.com, amd.com -- that's exactly what DKIM /
DMARC etc etc are supposed to prevent). Therefore groups.io rewrites the
sender email addresses like seen above, and then "git-am" picks up those
rewritten addresses verbatim. That's how they end up in the git commit
history.

This can be manually fixed by whoever applies such patches from the
list: after the initial "git-am", a git-rebase is needed, and each patch
needs to have its author meta-datum fixed with "git commit --amend
--author='corrected email address'". It's a lot of manual and error
prone work (unless someone scripts it, effectively "decoding" the
rewriting format that groups.io employs). As much as it pains me to
admit it, this is definitely an argument in favor of git forge-based
contributions, and against mailing list-based patches.

".mailmap" can be used to mitigate this issue, per gitmailmap(5); it'd
be better just not to permit such mangled "From:" fields to seep into
the git log, in the future. :/

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113436): https://edk2.groups.io/g/devel/message/113436
Mute This Topic: https://groups.io/mt/103534194/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 v4 3/3] OvmfPkg/VirtNorFlashDxe: sanity-check variables

2024-01-09 Thread Laszlo Ersek
On 1/8/24 20:21, Gerd Hoffmann wrote:
> Extend the ValidateFvHeader function, additionally to the header checks
> walk over the list of variables and sanity check them.
> 
> In case we find inconsistencies indicating variable store corruption
> return EFI_NOT_FOUND so the variable store will be re-initialized.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf |   1 +
>  OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c   | 139 +++-
>  2 files changed, 135 insertions(+), 5 deletions(-)
> 
> diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf 
> b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
> index 2a3d4a218e61..f549400280a1 100644
> --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
> +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
> @@ -34,6 +34,7 @@ [LibraryClasses]
>DxeServicesTableLib
>HobLib
>IoLib
> +  SafeIntLib
>UefiBootServicesTableLib
>UefiDriverEntryPoint
>UefiLib
> diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c 
> b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> index 9a614ae4b24d..56148e9f1f95 100644
> --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include 
> @@ -185,11 +186,13 @@ ValidateFvHeader (
>IN  NOR_FLASH_INSTANCE  *Instance
>)
>  {
> -  UINT16  Checksum;
> -  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;
> -  VARIABLE_STORE_HEADER   *VariableStoreHeader;
> -  UINTN   VariableStoreLength;
> -  UINTN   FvLength;
> +  UINT16Checksum;
> +  CONST EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;
> +  CONST VARIABLE_STORE_HEADER   *VariableStoreHeader;
> +  UINTN VarOffset;
> +  UINTN VariableStoreLength;
> +  UINTN FvLength;
> +  RETURN_STATUS Status;

(1) Status could have been moved in the "for" loop, AFAICT -- also
mentioned in my previous review --, but it's not a sticking point.

>  
>FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Instance->RegionBaseAddress;
>  
> @@ -258,6 +261,132 @@ ValidateFvHeader (
>  return EFI_NOT_FOUND;
>}
>  
> +  //
> +  // check variables
> +  //
> +  DEBUG ((DEBUG_INFO, "%a: checking variables\n", __func__));
> +  VarOffset = sizeof (*VariableStoreHeader);
> +  for ( ; ;) {
> +UINTNVarHeaderEnd;
> +UINTNVarNameEnd;
> +UINTNVarEnd;
> +UINTNVarPadding;
> +CONST AUTHENTICATED_VARIABLE_HEADER  *VarHeader;
> +CHAR16   *VarName;

(2) Should have noticed in my previous review: VarName could be
CONST-ified as well.

Totally minor.

> +CONST CHAR8  *VarState;
> +
> +Status = SafeUintnAdd (VarOffset, sizeof (*VarHeader), &VarHeaderEnd);
> +if (RETURN_ERROR (Status)) {
> +  DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__));
> +  return EFI_NOT_FOUND;
> +}
> +
> +if (VarHeaderEnd >= VariableStoreHeader->Size) {
> +  DEBUG ((DEBUG_INFO, "%a: end of var list (no space left)\n", 
> __func__));
> +  break;
> +}

(3) I *still* don't understand this.

In the v3 discussion:

- we agreed that the ">" case was clearly unacceptable,

- and you convinced me that the "=" case was also unacceptable (because
that could only potentially accommodate a VAR_HEADER_VALID_ONLY state
header without subsequent space for name & data, and we agreed that a
var header like that, residing *permanently* in the varstore, was not
acceptable).

Fine: that's reason for keeping the unified ">=" condition. But my point
in turn (which you didn't reflect upon, and seem not to have addressed
in this patch) was that this condition means that the varstore is
*bogus*, and should be reformatted. In my previous review I recommended
that we replace the "break" here -- which leads to the function
returning EFI_SUCCESS -- with "return EFI_NOT_FOUND" -- which causes the
varstore to be reformatted.

And then, as I wrote, the only successful exit from the loop would be
the subsequent "break" below:

> +
> +VarHeader = (VOID *)((UINTN)VariableStoreHeader + VarOffset);
> +if (VarHeader->StartId != 0x55aa) {
> +  DEBUG ((DEBUG_INFO, "%a: end of var list (no startid)\n", __func__));
> +  break;
> +}

So: what's wrong with returning EFI_NOT_FOUND if

  VarHeaderEnd >= VariableStoreHeader->Size

evaluates to true?

> +
> +VarName = NULL;
> +switch (VarHeader->State) {
> +  // usage: State = VAR_HEADER_VALID_ONLY
> +  case VAR_HEADER_VALID_ONLY:
> +VarState = "header-ok";
> +VarName  = L"";
> +break;
> +
> +  // usage: State = VAR_ADDED
> +  case VAR_ADDED:
> +VarState = "ok";

Re: [edk2-devel] [Patch V3 2/2] UefiCpuPkg: Check lower 24 bits of ProcessorNumber

2024-01-09 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Tan, Dun 
> Sent: Monday, January 8, 2024 1:08 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray ; Laszlo Ersek ; Kumar,
> Rahul R ; Gerd Hoffmann ;
> Xu, Min M 
> Subject: [Patch V3 2/2] UefiCpuPkg: Check lower 24 bits of ProcessorNumber
> 
> Check lower 24 bits of ProcessorNumber instead of
> the value of ProcessorNumber in the API
> MpInitLibGetProcessorInfo() of MpInitLibUp instance.
> Lower 24 bits of ProcessorNumber contains the actual
> processor number.
> The BIT24 of input ProcessorNumber might be set to
> indicate if the EXTENDED_PROCESSOR_INFORMATION will
> be retrived.
> 
> Signed-off-by: Dun Tan 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Cc: Min Xu 
> ---
>  UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> index d4f8611af8..35590fb4e7 100644
> --- a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> +++ b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> @@ -107,7 +107,10 @@ MpInitLibGetProcessorInfo (
>  return EFI_INVALID_PARAMETER;
>}
> 
> -  if (ProcessorNumber != 0) {
> +  //
> +  // Lower 24 bits contains the actual processor number.
> +  //
> +  if ((ProcessorNumber & (BIT24 - 1)) != 0) {
>  return EFI_NOT_FOUND;
>}
> 
> --
> 2.31.1.windows.1



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




Re: [edk2-devel] [Patch V3 1/2] UefiCpuPkg: set EXTENDED_PROCESSOR_INFORMATION to 0

2024-01-09 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Tan, Dun 
> Sent: Monday, January 8, 2024 1:08 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray ; Laszlo Ersek ; Kumar,
> Rahul R ; Gerd Hoffmann ;
> Xu, Min M 
> Subject: [Patch V3 1/2] UefiCpuPkg: set
> EXTENDED_PROCESSOR_INFORMATION to 0
> 
> Set EXTENDED_PROCESSOR_INFORMATION to 0 in API
> MpInitLibGetProcessorInfo() of MpInitLibUp. This
> commit use ZeroMem() to set all fileds in output
> EFI_PROCESSOR_INFORMATION to 0 before StatusFlag
> field is reassigned.
> 
> Previously EXTENDED_PROCESSOR_INFORMATION in the API
> MpInitLibGetProcessorInfo() of MpInitLibUp is ignored.
> In PEI/DXE MpInitLib, EXTENDED_PROCESSOR_INFORMATION
> will be retrived when BIT24 of input ProcessorNumber
> is set. This commit can avoid garbage in the output
> structure in MpInitLibGetProcessorInfo() of MpInitLibUp.
> 
> Signed-off-by: Dun Tan 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Cc: Min Xu 
> ---
>  UefiCpuPkg/Include/Library/MpInitLib.h |  2 ++
>  UefiCpuPkg/Library/MpInitLib/MpLib.c   |  2 ++
>  UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c   | 15 ---
>  UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf |  1 +
>  4 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/UefiCpuPkg/Include/Library/MpInitLib.h
> b/UefiCpuPkg/Include/Library/MpInitLib.h
> index 1853c46415..842c6f7ff9 100644
> --- a/UefiCpuPkg/Include/Library/MpInitLib.h
> +++ b/UefiCpuPkg/Include/Library/MpInitLib.h
> @@ -63,6 +63,8 @@ MpInitLibGetNumberOfProcessors (
>instant this call is made. This service may only be called from the BSP.
> 
>@param[in]  ProcessorNumber   The handle number of processor.
> +Lower 24 bits contains the actual 
> processor number.
> +BIT24 indicates if the
> EXTENDED_PROCESSOR_INFORMATION will be retrived.
>@param[out] ProcessorInfoBuffer   A pointer to the buffer where
> information for
>  the requested processor is deposited.
>@param[out] HealthDataReturn processor health data.
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index a359906923..cdfb570e61 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -2333,6 +2333,8 @@ MpInitLibInitialize (
>instant this call is made. This service may only be called from the BSP.
> 
>@param[in]  ProcessorNumber   The handle number of processor.
> +Lower 24 bits contains the actual 
> processor number.
> +BIT24 indicates if the
> EXTENDED_PROCESSOR_INFORMATION will be retrived.
>@param[out] ProcessorInfoBuffer   A pointer to the buffer where
> information for
>  the requested processor is deposited.
>@param[out]  HealthDataReturn processor health data.
> diff --git a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> index 86f9fbf903..d4f8611af8 100644
> --- a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> +++ b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  /**
>MP Initialize Library initialization.
> @@ -77,6 +78,8 @@ MpInitLibGetNumberOfProcessors (
>instant this call is made. This service may only be called from the BSP.
> 
>@param[in]  ProcessorNumber   The handle number of processor.
> +Lower 24 bits contains the actual 
> processor number.
> +BIT24 indicates if the
> EXTENDED_PROCESSOR_INFORMATION will be retrived.
>@param[out] ProcessorInfoBuffer   A pointer to the buffer where
> information for
>  the requested processor is deposited.
>@param[out] HealthDataReturn processor health data.
> @@ -108,13 +111,11 @@ MpInitLibGetProcessorInfo (
>  return EFI_NOT_FOUND;
>}
> 
> -  ProcessorInfoBuffer->ProcessorId = 0;
> -  ProcessorInfoBuffer->StatusFlag  = PROCESSOR_AS_BSP_BIT  |
> - PROCESSOR_ENABLED_BIT |
> - PROCESSOR_HEALTH_STATUS_BIT;
> -  ProcessorInfoBuffer->Location.Package = 0;
> -  ProcessorInfoBuffer->Location.Core= 0;
> -  ProcessorInfoBuffer->Location.Thread  = 0;
> +  ZeroMem (ProcessorInfoBuffer, sizeof (*ProcessorInfoBuffer));
> +  ProcessorInfoBuffer->StatusFlag = PROCESSOR_AS_BSP_BIT  |
> +PROCESSOR_ENABLED_BIT |
> +PROCESSOR_HEALTH_STATUS_BIT;
> +
>if (HealthData != NULL) {
>  GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformationPpiGuid);
>  if (GuidHob != NULL) {
> diff --git a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf
> b/UefiCpuP

Re: [edk2-devel] [PATCH v4 2/3] OvmfPkg/VirtNorFlashDxe: stop accepting gEfiVariableGuid

2024-01-09 Thread Laszlo Ersek
On 1/8/24 20:21, Gerd Hoffmann wrote:
> Only accept gEfiAuthenticatedVariableGuid when checking the variable
> store header in ValidateFvHeader().
> 
> The edk2 code base has been switched to use the authenticated varstore
> format unconditionally (even in case secure boot is not used or
> supported) a few years ago.
> 
> Suggested-by: László Érsek 
> Signed-off-by: Gerd Hoffmann 
> ---
>  OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c 
> b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> index 5ee98e9b595a..9a614ae4b24d 100644
> --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> @@ -239,9 +239,7 @@ ValidateFvHeader (
>VariableStoreHeader = (VARIABLE_STORE_HEADER *)((UINTN)FwVolHeader + 
> FwVolHeader->HeaderLength);
>  
>// Check the Variable Store Guid
> -  if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) &&
> -  !CompareGuid (&VariableStoreHeader->Signature, 
> &gEfiAuthenticatedVariableGuid))
> -  {
> +  if (!CompareGuid (&VariableStoreHeader->Signature, 
> &gEfiAuthenticatedVariableGuid)) {
>  DEBUG ((
>DEBUG_INFO,
>"%a: Variable Store Guid non-compatible\n",

Reviewed-by: Laszlo Ersek 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113432): https://edk2.groups.io/g/devel/message/113432
Mute This Topic: https://groups.io/mt/103605076/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 v4 1/3] OvmfPkg/RiscVVirt: use gEfiAuthenticatedVariableGuid unconditionally

2024-01-09 Thread Laszlo Ersek
On 1/8/24 20:21, Gerd Hoffmann wrote:
> ArmVirt and OVMF are doing the same.
> 
> See commit d92eaabefbe0 ("OvmfPkg: simplify VARIABLE_STORE_HEADER
> generation") for details.
> 
> Suggested-by: László Érsek 
> Signed-off-by: Gerd Hoffmann 
> ---
>  OvmfPkg/RiscVVirt/VarStore.fdf.inc | 9 +
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/OvmfPkg/RiscVVirt/VarStore.fdf.inc 
> b/OvmfPkg/RiscVVirt/VarStore.fdf.inc
> index aba32315cc37..6679c246b3ea 100644
> --- a/OvmfPkg/RiscVVirt/VarStore.fdf.inc
> +++ b/OvmfPkg/RiscVVirt/VarStore.fdf.inc
> @@ -36,19 +36,12 @@
># Blockmap[1]: End
>0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>## This is the VARIABLE_STORE_HEADER
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> +  # It is compatible with SECURE_BOOT_ENABLE == FALSE as well.
># Signature: gEfiAuthenticatedVariableGuid =
>#   { 0xaaf32c78, 0x947b, 0x439a,
># { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 }}
>0x78, 0x2c, 0xf3, 0xaa, 0x7b, 0x94, 0x9a, 0x43,
>0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92,
> -!else
> -  # Signature: gEfiVariableGuid =
> -  #   { 0xddcf3616, 0x3275, 0x4164,
> -  # { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d }}
> -  0x16, 0x36, 0xcf, 0xdd, 0x75, 0x32, 0x64, 0x41,
> -  0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d,
> -!endif
># Size: 0x4 
> (gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize) -
># 0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) = 0x3FFB8
># This can speed up the Variable Dispatch a bit.

Reviewed-by: Laszlo Ersek 



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




Re: [edk2-devel] [edk2-stable202311][PATCH] BaseTools: Python VfrCompiler implementation

2024-01-09 Thread Yuwei Chen
Hi Liming,

Have you tried with the new python tool? Any comments or concerns?

Thanks,
Christine

> -Original Message-
> From: Kinney, Michael D 
> Sent: Saturday, December 16, 2023 1:31 AM
> To: Pedro Falcato ; devel@edk2.groups.io; Chen,
> Christine 
> Cc: Gao, Liming ; Rebecca Cran
> ; Zimmer, Vincent ; Leif
> Lindholm ; Andrew Fish ;
> Feng, Bob C ; Yang, Yuting2
> ; Hartung, Stephen ;
> Kinney, Michael D 
> Subject: RE: [edk2-devel] [edk2-stable202311][PATCH] BaseTools: Python
> VfrCompiler implementation
> 
> There are several advantages for this direction:
> 
> 
> * Current VFR compiler in C has dependencies on very old libs that
>   have not been updated.
> 
> * The movement to python will remove the pre-build step that requires
>   some of the build tools to be built using host C compiler before
>   running edk2 build command.
> 
> * The other element is moving all the python code into edk2-basetools
>   repo with a published pip package.  This enables the use of
>   pip-requirements.txt to provide developers all the content needed
>   to build.
> 
> I agree that we should not have both VFR compilers.  We need to make sure
> the new one in Python is 100% compatible with the C version and make the
> decision to simultaneously add Python one and delete the C one and commit
> to the Python one.  I provided this feedback to the VFR developers in the
> TianoCore Tools/CI meeting earlier this year.
> 
> The perf question is very good. It would be good for the VFR developers to
> provide some perf comparisons.  I do not expect any significant different that
> would impact overall platform build times.
> 
> Mike
> 
> > -Original Message-
> > From: Pedro Falcato 
> > Sent: Friday, December 15, 2023 9:04 AM
> > To: devel@edk2.groups.io; Chen, Christine 
> > Cc: Gao, Liming ; Rebecca Cran
> > ; Zimmer, Vincent ;
> > Kinney, Michael D ; Leif Lindholm
> > ; Andrew Fish ; Feng, Bob
> > C ; Yang, Yuting2 ;
> > Hartung, Stephen 
> > Subject: Re: [edk2-devel] [edk2-stable202311][PATCH] BaseTools: Python
> > VfrCompiler implementation
> >
> > On Thu, Dec 7, 2023 at 9:08 AM Yuwei Chen 
> wrote:
> > >
> > > Hi Liming,
> > >
> > >
> > >
> > > Is this feature been tested and reviewed these two weeks? 😊
> >
> > Two questions:
> >
> > 1) What testing strategy do you have to test for regressions in such a
> > huge rewrite?
> > 2) What's the point in shipping this to upstream if you're not aiming
> > for the replacement of the original VfrCompiler?
> > 3) What's the value of rewriting this in Python? If the existing
> > VfrCompiler is already working fine (AFAIK?), a python version will
> > likely just be slower (unless the original C version is super badly
> > written).
> > I *seriously* struggle to understand what this Python movement is
> > supposed to do, except gratuitously rewrite large bits of BaseTools
> > for a net loss (performance)
> >
> > --
> > Pedro


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




Re: [edk2-devel] [PATCH] DynamicTablesPkg/SSDT: Remove incorrect root node check

2024-01-09 Thread PierreGondois

Hello Jeshua,

On 1/8/24 19:12, Jeshua Smith wrote:

The code was incorrectly assuming that root nodes had to be physical
package nodes and vice versa. This is not always true, so the check
is being removed.


Does it mean that you have a topology where the top-level node is not
a physical package ? If yes, does it also mean that multiple physical
packages share a resource (which belong to the top-level node) ?

It is correct that the check is a bit stronger than what the specification
states, but it was handling all topologies so far, so would it be possible
to describe the topology that you have ?

Regards,
Pierre



Signed-off-by: Jeshua Smith 
Tested-by: Ashish Singhal 
Reviewed-by: Ashish Singhal 
---
  .../SsdtCpuTopologyGenerator.c| 23 ---
  1 file changed, 5 insertions(+), 18 deletions(-)

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
index 724f33c660..4ad9508f57 100644
--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
@@ -983,7 +983,6 @@ CreateAmlProcessorContainer (
@param [in]  NodeFlagsFlags of the ProcNode to check.
@param [in]  IsLeaf   The ProcNode is a leaf.
@param [in]  NodeTokenNodeToken of the ProcNode.
-  @param [in]  ParentNodeToken  Parent NodeToken of the ProcNode.
  
@retval EFI_SUCCESS Success.

@retval EFI_INVALID_PARAMETER   Invalid parameter.
@@ -994,26 +993,16 @@ EFIAPI
  CheckProcNode (
UINT32   NodeFlags,
BOOLEAN  IsLeaf,
-  CM_OBJECT_TOKEN  NodeToken,
-  CM_OBJECT_TOKEN  ParentNodeToken
+  CM_OBJECT_TOKEN  NodeToken
)
  {
BOOLEAN  InvalidFlags;
-  BOOLEAN  HasPhysicalPackageBit;
-  BOOLEAN  IsTopLevelNode;
-
-  HasPhysicalPackageBit = (NodeFlags & EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL) ==
-  EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL;
-  IsTopLevelNode = (ParentNodeToken == CM_NULL_TOKEN);
-
-  // A top-level node is a Physical Package and conversely.
-  InvalidFlags = HasPhysicalPackageBit ^ IsTopLevelNode;
  
// Check Leaf specific flags.

if (IsLeaf) {
-InvalidFlags |= ((NodeFlags & PPTT_LEAF_MASK) != PPTT_LEAF_MASK);
+InvalidFlags = ((NodeFlags & PPTT_LEAF_MASK) != PPTT_LEAF_MASK);
} else {
-InvalidFlags |= ((NodeFlags & PPTT_LEAF_MASK) != 0);
+InvalidFlags = ((NodeFlags & PPTT_LEAF_MASK) != 0);
}
  
if (InvalidFlags) {

@@ -1086,8 +1075,7 @@ CreateAmlCpuTopologyTree (
  Status = CheckProcNode (
 Generator->ProcNodeList[Index].Flags,
 TRUE,
-   Generator->ProcNodeList[Index].Token,
-   NodeToken
+   Generator->ProcNodeList[Index].Token
 );
  if (EFI_ERROR (Status)) {
ASSERT (0);
@@ -1119,8 +1107,7 @@ CreateAmlCpuTopologyTree (
  Status = CheckProcNode (
 Generator->ProcNodeList[Index].Flags,
 FALSE,
-   Generator->ProcNodeList[Index].Token,
-   NodeToken
+   Generator->ProcNodeList[Index].Token
 );
  if (EFI_ERROR (Status)) {
ASSERT (0);



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




Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings containing valid escape characters

2024-01-09 Thread Yuwei Chen
Liming:
PR has been created: BaseTools: Fix raw strings containing valid escape 
characters by YuweiChen1110 · Pull Request #5238 · tianocore/edk2 
(github.com)
Thanks for reviewing.

Thanks,
Christine
From: gaoliming 
Sent: Tuesday, January 9, 2024 10:01 AM
To: devel@edk2.groups.io; joeyvage...@microsoft.com; Huang, Yanbo 

Cc: Chen, Christine ; Feng, Bob C ; 
Kinney, Michael D ; 'Rebecca Cran' 

Subject: 回复: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings containing 
valid escape characters

Joey and Yanbo:
 Thanks for your update. So, this one is new introduced issue. I agree to 
resolve it asap.

Christine:
 Can you create Pull Request to merge it?

Thanks
Liming
发件人: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> 代表 Joey Vagedes via 
groups.io
发送时间: 2024年1月8日 23:09
收件人: Huang, Yanbo mailto:yanbo.hu...@intel.com>>
抄送: Chen, Christine mailto:yuwei.c...@intel.com>>; Feng, 
Bob C mailto:bob.c.f...@intel.com>>; Gao, Liming 
mailto:gaolim...@byosoft.com.cn>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; Rebecca Cran 
mailto:rebe...@bsdio.com>>; 
devel@edk2.groups.io
主题: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings containing valid 
escape characters

Hi Liming,

It was introduced due to the fact that a few of the regex strings with invalid 
escape sequences (due to regex using their own escape sequences) also included 
valid escape sequences - for handling new lines. I did not see the valid escape 
characters in the strings, and the virtual platforms (Ovmf, etc) did not have 
the circumstances to catch this, so it slipped through the cracks.

Some platform DSCs do, and cause the break that the patch is resolving. I’ve 
already verified this fix resolves the issue on numerous platforms.

thanks,
Joey

On Mon, Jan 8, 2024 at 5:59 AM Huang, Yanbo 
mailto:yanbo.hu...@intel.com>> wrote:
Hi Liming,

This issue is introduced by this commit:
SHA-1: 9f0061a03b61d282fbc0ba5be22155d06a5e64a1

* BaseTools: Resolve regex syntax warnings

Switches regex patterns to raw text to resolve python 3.12 syntax
warnings in regards to invalid escape sequences, as is suggested by the
re (regex) module in python.

Best Regards,
Yanbo Huang

-Original Message-
From: gaoliming mailto:gaolim...@byosoft.com.cn>>
Sent: Monday, January 8, 2024 9:25 PM
To: devel@edk2.groups.io; Chen, Christine 
mailto:yuwei.c...@intel.com>>; 'Joey Vagedes' 
mailto:joey.vage...@gmail.com>>
Cc: 'Rebecca Cran' mailto:rebe...@bsdio.com>>; Feng, Bob C 
mailto:bob.c.f...@intel.com>>; Huang, Yanbo 
mailto:yanbo.hu...@intel.com>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Subject: 回复: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings containing 
valid escape characters

Christine:
  Is this a regression issue? Or does it resolve new usage? I am curious why it 
is not reported before.

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io 
> mailto:devel@edk2.groups.io>> 代表 Yuwei Chen
> 发送时间: 2024年1月8日 13:37
> 收件人: devel@edk2.groups.io; Chen, Christine 
> mailto:yuwei.c...@intel.com>>;
> Joey Vagedes mailto:joey.vage...@gmail.com>>
> 抄送: Rebecca Cran mailto:rebe...@bsdio.com>>; Gao, Liming
> mailto:gaolim...@byosoft.com.cn>>; Feng, Bob C 
> mailto:bob.c.f...@intel.com>>; Huang,
> Yanbo mailto:yanbo.hu...@intel.com>>; Kinney, Michael D
> mailto:michael.d.kin...@intel.com>>
> 主题: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings
containing
> valid escape characters
>
> Hi Liming and Cran,
>
> We should merge this fixing patch asap as it influences BaseTool's usage.
>
> Thanks,
> Christine
>
> > -Original Message-
> > From: devel@edk2.groups.io 
> > mailto:devel@edk2.groups.io>> On Behalf Of Yuwei
> > Chen
> > Sent: Monday, January 8, 2024 9:16 AM
> > To: Joey Vagedes mailto:joey.vage...@gmail.com>>; 
> > devel@edk2.groups.io
> > Cc: Rebecca Cran mailto:rebe...@bsdio.com>>; Gao, Liming
> > mailto:gaolim...@byosoft.com.cn>>; Feng, Bob C 
> > mailto:bob.c.f...@intel.com>>
> > Subject: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Fix raw strings
> containing
> > valid escape characters
> >
> > Hi Joey,
> >
> > Thanks for fixing.
> >
> > Reviewed-by: Yuwei Chen mailto:yuwei.c...@intel.com>>
> >
> > > -Original Message-
> > > From: Joey Vagedes mailto:joey.vage...@gmail.com>>
> > > Sent: Friday, December 29, 2023 12:48 AM
> > > To: devel@edk2.groups.io
> > > Cc: Rebecca Cran mailto:rebe...@bsdio.com>>; Gao, 
> > > Liming
> > > mailto:gaolim...@byosoft.com.cn>>; Feng, Bob C 
> > > mailto:bob.c.f...@intel.com>>;
> Chen,
> > > Christine mailto:yuwei.c...@intel.com>>
> > > Subject: [PATCH v1 1/1] BaseTools: Fix raw strings containing
> > > valid escape characters
> > >
> > > Fixes raw regex strings that contain val

Re: [edk2-devel] [PATCH v6 24/36] ArmVirtPkg: Move PlatformBootManagerLib to OvmfPkg

2024-01-09 Thread Laszlo Ersek
On 1/9/24 07:40, Chao Li wrote:
> Hi Laszlo,
> 
> 
> Thanks,
> Chao
> On 2024/1/8 22:02, Laszlo Ersek wrote:
>> On 1/5/24 10:45, Chao Li wrote:
>>> Moved the PlatformBootManagerLib to OvmfPkg and renamed to
>>> PlatformBootManagerLibLight for easy use by other ARCH.
>>>
>>> Build-tested only (with "ArmVirtQemu.dsc").
>>>
>>> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584
>>>
>>> Cc: Ard Biesheuvel 
>>> Cc: Leif Lindholm 
>>> Cc: Sami Mujawar 
>>> Cc: Gerd Hoffmann 
>>> Cc: Jiewen Yao 
>>> Cc: Lazlo Ersek 
>>> Signed-off-by: Chao Li 
>>> ---
>>>  ArmVirtPkg/ArmVirtPkg.ci.yaml  | 1 -
>>>  ArmVirtPkg/ArmVirtPkg.dec  | 1 -
>>>  ArmVirtPkg/ArmVirtQemu.dsc | 2 +-
>>>  ArmVirtPkg/ArmVirtQemuKernel.dsc   | 2 +-
>>>  .../Library/PlatformBootManagerLibLight}/PlatformBm.c  | 0
>>>  .../Library/PlatformBootManagerLibLight}/PlatformBm.h  | 0
>>>  .../PlatformBootManagerLib.inf | 7 +++
>>>  .../Library/PlatformBootManagerLibLight}/QemuKernel.c  | 0
>>>  OvmfPkg/OvmfPkg.dec| 4 
>>>  9 files changed, 9 insertions(+), 8 deletions(-)
>>>  rename {ArmVirtPkg/Library/PlatformBootManagerLib => 
>>> OvmfPkg/Library/PlatformBootManagerLibLight}/PlatformBm.c (100%)
>>>  rename {ArmVirtPkg/Library/PlatformBootManagerLib => 
>>> OvmfPkg/Library/PlatformBootManagerLibLight}/PlatformBm.h (100%)
>>>  rename {ArmVirtPkg/Library/PlatformBootManagerLib => 
>>> OvmfPkg/Library/PlatformBootManagerLibLight}/PlatformBootManagerLib.inf 
>>> (92%)
>>>  rename {ArmVirtPkg/Library/PlatformBootManagerLib => 
>>> OvmfPkg/Library/PlatformBootManagerLibLight}/QemuKernel.c (100%)
>>>
>>> diff --git a/ArmVirtPkg/ArmVirtPkg.ci.yaml b/ArmVirtPkg/ArmVirtPkg.ci.yaml
>>> index 506b0e72f0..b186d4eb42 100644
>>> --- a/ArmVirtPkg/ArmVirtPkg.ci.yaml
>>> +++ b/ArmVirtPkg/ArmVirtPkg.ci.yaml
>>> @@ -24,7 +24,6 @@
>>>  ],
>>>  ## Both file path and directory path are accepted.
>>>  "IgnoreFiles": [
>>> -"Library/PlatformBootManagerLib/PlatformBm.c"
>>>  ]
>>>  },
>>>  ## options defined .pytool/Plugin/CompilerPlugin
>> You don't seem to be reinstating this under OvmfPkg, so I think the same 
>> source file under OvmfPkg will cause a CI failure.
> 
> There was no CI failure, there was a PR for edk2 in the cover letter,
> all of the CI are passed.
> 
> https://github.com/tianocore/edk2/pull/5208

My mistake -- and looking closer, I understand the reason (for the
successful build). In OvmfPkg.ci.yaml, EccCheck is skipped altogether.

Thanks
Laszlo



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