Re: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER bitfield parser

2022-01-20 Thread Gao, Zhichao
Hi Sami,

Thanks for the clarification. You’re right.
#1 it is better to add error message before skip this item.
#2 I miss the variable check. Local variable would be release when exit the 
function. And there is no way to make the ItemPtr to point to the specific bit 
field.

Abdul, can you address the issue that Sami point out?

Thanks,
Zhichao

From: Sami Mujawar 
Sent: Thursday, January 20, 2022 8:32 PM
To: Gao, Zhichao ; Attar, AbdulLateef (Abdul Lateef) 
; devel@edk2.groups.io
Cc: Ni, Ray ; nd 
Subject: Re: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER 
bitfield parser

Hi Zhichao, Abdul,

Please find my response inline marked [SAMI].

Regards,

Sami Mujawar

From: "Gao, Zhichao" mailto:zhichao@intel.com>>
Date: Thursday, 20 January 2022 at 08:37
To: "Attar, AbdulLateef (Abdul Lateef)" 
mailto:abdullateef.at...@amd.com>>, 
"devel@edk2.groups.io" 
mailto:devel@edk2.groups.io>>, Sami Mujawar 
mailto:sami.muja...@arm.com>>
Cc: "Ni, Ray" mailto:ray...@intel.com>>, nd 
mailto:n...@arm.com>>
Subject: RE: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER 
bitfield parser

Hi,

Sorry for the late response. Many works interrupt my review plan.
The BZ creation and update is part of edk2 develop process EDK II Development 
Process · tianocore/tianocore.github.io Wiki · 
GitHub.
It give a good history of the code change and it can be traced by the edk2 
stable release page.

Back to the patch itself. Because it is a reuse the structure of the 
ACPI_PARSER, I think it is fine to take Length check into consideration for 
security thinking.
[SAMI] I agree that the Length check is required from a security perspective. 
If Parser[Index].Length is 0, this means the parser has not been described 
correctly, and logging an error message would be helpful (which I think would 
happen as part of the default case in the Switch statement).
I am fine with keeping this check (as done in the patch) but would recommend 
logging an error message before continuing.
[/SAMI]

For the ItemPtr, it is used to be used outside the parser. So the patch looks  
fine to me.
[SAMI] The ItemPtr is designed to get a reference to the field data in the ACPI 
table memory area. This allows the ItemPtr to be used outside the function 
(e.g. to examine the field). This patch is setting up the ItemPtr to point to a 
local variable, which is not right and would result in accessing an invalid 
memory area.

To give an example on how ItemPtr is designed to work see:

  *   Declaration of ItemPtr for Flags field at 
https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c#L20
  *   Initialisation of FadtParser with ItemPtr for Flags field at 
https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c#L176
  *   Invocation of ParseAcpi() for FadtParser at 
https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c#L226-L233
  *   Usage of ItemPtr for Flags field at 
https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c#L260-L261

[/SAMI]

Anything I miss consideration, please feel free to point out.

Thanks,
Zhichao


From: Attar, AbdulLateef (Abdul Lateef) 
mailto:abdullateef.at...@amd.com>>
Sent: Thursday, January 20, 2022 11:25 AM
To: devel@edk2.groups.io; 
sami.muja...@arm.com
Cc: Ni, Ray mailto:ray...@intel.com>>; Gao, Zhichao 
mailto:zhichao@intel.com>>; nd 
mailto:n...@arm.com>>
Subject: RE: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER 
bitfield parser


[Public]

Hi Sami,
Why Bugzilla ticket required?
Also please see inline for my response [Abdul].
Thanks
AbduL

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Sami Mujawar 
via groups.io
Sent: 19 January 2022 22:17
To: Attar, AbdulLateef (Abdul Lateef) 
mailto:abdullateef.at...@amd.com>>; 
devel@edk2.groups.io
Cc: Ray Ni mailto:ray...@intel.com>>; Zhichao Gao 
mailto:zhichao@intel.com>>; nd 
mailto:n...@arm.com>>
Subject: Re: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER 
bitfield parser

[CAUTION: External Email]

Hi Abdul,

Please also create a bugzilla ticket and add a reference to it in the commit 
message.

Regards,

Sami Mujawar

On 19/01/2022 04:44 PM, Sami Mujawar wrote:

Hi Abdul,

Thank you for providing a patch to add this feature to Acpiview.

I have some minor feedback marked inline as [SAMI].

Regards,

Sami Mujawar

On 19/12/2021 02:44 PM, Abdul Lateef Attar wrote:

Adds ParseAcpiBitFields() which is based on

ParseAcpi() and capable of parsing the bit fields.

Supports parsing of UINT8, UINT16, UINT32 and 

回复: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add Support for authenticated variable

2022-01-20 Thread gaoliming
Di:

> -邮件原件-
> 发件人: Zhang, Di 
> 发送时间: 2022年1月20日 14:05
> 收件人: Gao, Liming ; Chen, Lin Z
> ; devel@edk2.groups.io; Huang, Long1
> 
> 抄送: Bi, Dandan ; Feng, Bob C
> ; Li, Zhuangzhi 
> 主题: RE: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add
> Support for authenticated variable
> 
> 
> Liming:
> 
> > -Original Message-
> > From: gaoliming 
> > Sent: Wednesday, January 19, 2022 10:57 AM
> > To: Chen, Lin Z ; devel@edk2.groups.io; Huang,
> Long1
> > 
> > Cc: Bi, Dandan ; Feng, Bob C
> ;
> > Zhang, Di ; Li, Zhuangzhi 
> > Subject: 回复: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add
> > Support for authenticated variable
> >
> > Lin:
> >
> > > -邮件原件-
> > > 发件人: Chen, Lin Z 
> > > 发送时间: 2022年1月18日 8:42
> > > 收件人: Gao, Liming ;
> devel@edk2.groups.io;
> > > Huang, Long1 
> > > 抄送: Bi, Dandan ; Feng, Bob C
> > > ; Zhang, Di ; Li, Zhuangzhi
> > > 
> > > 主题: RE: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add
> > > Support for authenticated variable
> > >
> > > Hi Liming,
> > >
> > >Pls see my comments below.
> > >
> > > 1.
> > > PcdNvStoreDefaultValueBuffer type is DynamicEx. Its PcdGetPtr is same
> to
> > > PcdGetExPtr. This change is not required.
> > >
> > > [Lin] It'll get alignment with PEI phase reference If using PcdGetExPtr
> > version.
> > > Edk2/MdeModulePkg/Universal/PCD/Pei/Pcd.c#166
> > > DataBuffer = (UINT8 *)PeiPcdGetPtrEx
> (&gEfiMdeModulePkgTokenSpaceGuid,
> > > PcdToken (PcdNvStoreDefaultValueBuffer));
> > >
> > PcdPei is different. It is Pcd driver. It can't consume the real PcdLib.
> > So, it doesn't use PcdLib PcdGetPtr() API.
> > It uses the internal function PeiPcdGetPtrEx() to get PCD value and size.
> >
> > HiiDataBase is normal DXE driver. It can depend on the real PcdLib. So, it
> > uses PcdLib PcdGetPtr() API.
> > Seemly, current code brings confuse. If so, I am OK to make this change.
> > And, please also update PcdGetSize (PcdNvStoreDefaultValueBuffer) with
> > LibPcdGetExSize()
> >
> > > 2.
> > > VariableStorage data buffer is from PcdNvStoreDefaultValueBuffer.
> > > PcdNvStoreDefaultValueBuffer is auto generated by BaseTools.
> > > By design, its data format is always normal variable storage format.
> > > So, its value can't be auth variable format.
> > >
> > > [Lin] BaseTools can generate authenticated variable storage format now
> > (see
> > > https://edk2.groups.io/g/devel/message/83329),
> > >  since previous FCE tool generates authenticated format, we want to
> keep
> > > variable storage format no changes after switching to StructurePcd.
> > >
> > Sorry, I miss the previous change in BaseTools. Normal variable storage is
> > enough for Tools and Code.
> > The default setting format can be always normal variable storage. The
> > consumer code logic can be simple.
> > I don't know what purpose to keep the alignment with FCE tool behavior. Is
> > there other tool or code to use
> > the generated PcdNvStoreDefaultValueBuffer?
> >
> 
> We have the usage that writing the entire VPD (which has default setup value)
> to variable region upon first boot. And the variable region needs to be in
> authenticated format when secure boot is enabled, so we also need the VPD
> in
> authenticated format. Hope it clarifies your question.
> 
Current usage is to build VariableHob based on PcdNvStoreDefaultValueBuffer 
data in PEI, 
and write VariableHob into NV space in DXE. Variable driver is responsible to 
convert 
normal variable format to the auth variable format.

Have you another usage model to write entire VPD data to variable region? How 
is 
VPD data placed into variable region? Is VPD data wrapped as the variable 
format? 
If so, VPD data is also variable data. I think Variable driver should check NV 
region 
to decide the variable format instead of VPD data.

Can you add the background about new usage model into 
https://bugzilla.tianocore.org/show_bug.cgi?id=3796?

Thanks
Liming
> > Thanks
> > Liming
> > > Thanks,
> > > Lin
> > >
> > > -Original Message-
> > > From: gaoliming 
> > > Sent: Monday, January 17, 2022 6:56 PM
> > > To: devel@edk2.groups.io; Huang, Long1 
> > > Cc: Chen, Lin Z ; Bi, Dandan
> ;
> > > Feng, Bob C 
> > > Subject: 回复: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe:
> Add
> > > Support for authenticated variable
> > >
> > > Long:
> > >   I add my comments below.
> > >
> > > > -邮件原件-
> > > > 发件人: devel@edk2.groups.io  代表 Long1
> > > Huang
> > > > 发送时间: 2022年1月11日 1:03
> > > > 收件人: devel@edk2.groups.io
> > > > 抄送: Huang Long ; Liming Gao
> > > > ; Chen Lin Z ;
> Dandan
> > > > Bi 
> > > > 主题: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add
> Support
> > > for
> > > > authenticated variable
> > > >
> > > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3796
> > > >
> > > > Database.c:
> > > > 1. Replace PcdGetExPtr with PcdGetExPtr.
> > > > 2. Add FindAuthVariableData function to parse authenticated
> variable
> > > > type for getting a correct default value in
> > PcdNvStoreDefa

Re: [edk2-devel][edk2-platforms][PATCH V1 1/1] UserAuthFeaturePkg/PlatformPasswordLibNull: Add UEFI app support

2022-01-20 Thread Dandan Bi
Reviewed-by: Dandan Bi 


Thanks,
Dandan

> -Original Message-
> From: Oram, Isaac W 
> Sent: Friday, January 21, 2022 3:55 AM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan ; Gao, Liming
> ; Palomino Sosa, Guillermo A
> 
> Subject: [edk2-devel][edk2-platforms][PATCH V1 1/1]
> UserAuthFeaturePkg/PlatformPasswordLibNull: Add UEFI app support
> 
> Enable library use with UEFI_APPLICATION components similarly to the other
> libraries in the package.
> 
> Cc: Dandan Bi 
> Cc: Liming Gao 
> Cc: Guillermo Antonio Palomino Sosa 
> 
> Signed-off-by: Isaac Oram 
> ---
> 
> Features/Intel/UserInterface/UserAuthFeaturePkg/Library/PlatformPasswo
> rdLibNull/PlatformPasswordLibNull.inf | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git
> a/Features/Intel/UserInterface/UserAuthFeaturePkg/Library/PlatformPass
> wordLibNull/PlatformPasswordLibNull.inf
> b/Features/Intel/UserInterface/UserAuthFeaturePkg/Library/PlatformPass
> wordLibNull/PlatformPasswordLibNull.inf
> index 00be14df8a..b95849cc61 100644
> ---
> a/Features/Intel/UserInterface/UserAuthFeaturePkg/Library/PlatformPass
> wordLibNull/PlatformPasswordLibNull.inf
> +++
> b/Features/Intel/UserInterface/UserAuthFeaturePkg/Library/PlatformPa
> +++ sswordLibNull/PlatformPasswordLibNull.inf
> @@ -18,7 +18,7 @@
>FILE_GUID  = 27417BCA-0CCD-4089-9711-AD069A33C555
>MODULE_TYPE= DXE_DRIVER
>VERSION_STRING = 1.0
> -  LIBRARY_CLASS  = PlatformPasswordLib|DXE_RUNTIME_DRIVER
> DXE_SMM_DRIVER DXE_DRIVER
> +  LIBRARY_CLASS  = PlatformPasswordLib|DXE_RUNTIME_DRIVER
> DXE_SMM_DRIVER DXE_DRIVER UEFI_APPLICATION
>CONSTRUCTOR= PlatformPasswordLibNullConstructor
> 
>  #
> --
> 2.27.0.windows.1



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




Re: [edk2-devel] [PATCH V4 25/31] OvmfPkg/BaseMemEncryptTdxLib: Add TDX helper library

2022-01-20 Thread Min Xu
Hi
> > +++
> b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemoryEncryptionNull.c
> > @@ -0,0 +1,90 @@
> > +/** @file
> > +
> > +  Virtual Memory Management Services to set or clear the memory
> > + encryption
> > +
> > +  Copyright (c) 2006 - 2018, Intel Corporation. All rights
> > + reserved.  Copyright (c) 2017, AMD Incorporated. All rights
> > + reserved.
> > +
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +  Code is derived from
> > + MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> 
> Can we move most of the code to a (x64) page table library instead of
> cut+pasting like this, please?
As I explained in https://edk2.groups.io/g/devel/message/85582, there has 
already been a same feature requirement. 
https://bugzilla.tianocore.org/show_bug.cgi?id=847 . (Create page table library 
to abstract all page table manipulations)
I discussed with the feature owner (Ni, Ray).  He said this feature is in his 
plan of 2022. He suggest I can wait for the library.

Thanks
Min


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




[edk2-devel] Now: TianoCore Design Meeting - APAC/NAMO - 01/21/2022 #cal-notice

2022-01-20 Thread devel@edk2.groups.io Calendar
*TianoCore Design Meeting - APAC/NAMO*

*When:*
01/21/2022
9:30am to 10:30am
(UTC+08:00) Asia/Shanghai

*Where:*
Microsoft Teams

*Organizer:* Ray Ni ray...@intel.com ( 
ray...@intel.com?subject=Re:%20Event:%20TianoCore%20Design%20Meeting%20-%20APAC%2FNAMO
 )

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

*Description:*

-
TOPIC
-

* NA

For more info, see here: https://www.tianocore.org/design-meeting/

---
Microsoft Teams meeting
---

Join on your computer or mobile app
---

Click here to join the meeting ( 
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTNmZTNhMWEtOWQwNi00ZTdkLWI5NDgtYTFmYjNkOWI0ZDg4%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%2255d36a50-78be-4ced-bc27-3d06c576cc19%22%7d
 )

Join with a video conferencing device
-

te...@conf.intel.com

Video Conference ID: 119 715 416 0

Alternate VTC dialing instructions ( 
https://conf.intel.com/teams/?conf=1197154160&ivr=teams&d=conf.intel.com&test=test_call
 )

Learn More ( https://aka.ms/JoinTeamsMeeting ) | Meeting options ( 
https://teams.microsoft.com/meetingOptions/?organizerId=55d36a50-78be-4ced-bc27-3d06c576cc19&tenantId=46c98d88-e344-4ed4-8496-4ed7712e255d&threadId=19_meeting_OTNmZTNhMWEtOWQwNi00ZTdkLWI5NDgtYTFmYjNkOWI0ZDg4@thread.v2&messageId=0&language=en-US
 )


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




[edk2-devel] Event: TianoCore Design Meeting - APAC/NAMO - 01/21/2022 #cal-reminder

2022-01-20 Thread devel@edk2.groups.io Calendar
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Groups.io Inc//Groups.io Calendar//EN
METHOD:PUBLISH
REFRESH-INTERVAL;VALUE=DURATION:PT1H
X-PUBLISHED-TTL:PT1H
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Asia/Shanghai
LAST-MODIFIED:20201011T015911Z
TZURL:http://tzurl.org/zoneinfo-outlook/Asia/Shanghai
X-LIC-LOCATION:Asia/Shanghai
BEGIN:STANDARD
TZNAME:CST
TZOFFSETFROM:+0800
TZOFFSETTO:+0800
DTSTART:19700101T00
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
X-GIOIDS:Event:1238701 
UID:ccyo.1615368347866508187.a...@groups.io
DTSTAMP:20220121T011501Z
ORGANIZER;CN=Ray Ni:mailto:ray...@intel.com
DTSTART:20220121T013000Z
DTEND:20220121T023000Z
SUMMARY:TianoCore Design Meeting - APAC/NAMO
DESCRIPTION:## TOPIC\n\n1. NA\n\nFor more info\, see here: https://www.ti
 anocore.org/design-meeting/\n\n---\n## Microsoft Teams meeting\n\n### Joi
 n on your computer or mobile app\n\n[Click here to join the meeting](http
 s://teams.microsoft.com/l/meetup-join/19%3ameeting_OTNmZTNhMWEtOWQwNi00ZT
 dkLWI5NDgtYTFmYjNkOWI0ZDg4%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d
 88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%2255d36a50-78be-4ced-bc2
 7-3d06c576cc19%22%7d)\n\n### Join with a video conferencing device\n\ntea
 m...@conf.intel.com\n\nVideo Conference ID: 119 715 416 0\n\n[Alternate VTC
  dialing instructions](https://conf.intel.com/teams/?conf=1197154160&ivr=
 teams&d=conf.intel.com&test=test_call)\n\n[Learn More](https://aka.ms/Joi
 nTeamsMeeting) | [Meeting options](https://teams.microsoft.com/meetingOpt
 ions/?organizerId=55d36a50-78be-4ced-bc27-3d06c576cc19&tenantId=46c98d88-
 e344-4ed4-8496-4ed7712e255d&threadId=19_meeting_OTNmZTNhMWEtOWQwNi00ZTdkL
 WI5NDgtYTFmYjNkOWI0ZDg4@thread.v2&messageId=0&language=en-US)
LOCATION:Microsoft Teams
SEQUENCE:1
END:VEVENT
END:VCALENDAR


invite.ics
Description: application/ics


[edk2-devel] [ed2-platforms][PATCH 2/2] Platform/Intel: Remove All UGA Support

2022-01-20 Thread Guomin Jiang
From: GuoMinJ 

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

Remove all UGA Support in INTEL platform.

Cc: Nate DeSimone 
Cc: Zailiang Sun 
Cc: Yi Qian 
Signed-off-by: Guomin Jiang 
---
 .../Library/DxePlatformBootManagerLib/BdsPlatform.h  | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/Platform/Intel/Vlv2TbltDevicePkg/Library/DxePlatformBootManagerLib/BdsPlatform.h
 
b/Platform/Intel/Vlv2TbltDevicePkg/Library/DxePlatformBootManagerLib/BdsPlatform.h
index 0bdc11bdd824..6cc4e3acf279 100644
--- 
a/Platform/Intel/Vlv2TbltDevicePkg/Library/DxePlatformBootManagerLib/BdsPlatform.h
+++ 
b/Platform/Intel/Vlv2TbltDevicePkg/Library/DxePlatformBootManagerLib/BdsPlatform.h
@@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.30.0.windows.2



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




[edk2-devel] [ed2-platforms][PATCH 1/2] Platform/Intel/SimicsOpenBoardPkg: Remove all UGA support

2022-01-20 Thread Guomin Jiang
From: GuoMinJ 

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

Cc: Nate DeSimone 
Signed-off-by: Guomin Jiang 
---
 .../BoardX58Ich10/OpenBoardPkgPcd.dsc |  4 +-
 .../Library/DxeLogoLib/DxeLogoLib.inf |  6 +--
 .../Library/DxeLogoLib/Logo.c | 45 +--
 3 files changed, 3 insertions(+), 52 deletions(-)

diff --git 
a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc 
b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
index 88009b8f1022..9b81726623dc 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  PCD configuration build description file for the X58Ich10 board.
 #
-# Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved. 
+# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved. 
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -31,8 +31,6 @@ [PcdsFeatureFlag.common]
   # Edk2 Configuration
   ##
   gEfiMdeModulePkgTokenSpaceGuid.PcdBrowerGrayOutReadOnlyMenu|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
diff --git 
a/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/DxeLogoLib.inf 
b/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/DxeLogoLib.inf
index ff08c385b3a0..cd9565e123db 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/DxeLogoLib.inf
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/DxeLogoLib.inf
@@ -6,7 +6,7 @@
 # 2) BDS boot device connect interface;
 # 3) BDS Misc interfaces for mainting boot variable, ouput string, etc.
 #
-# Copyright (c) 2007 - 2019 Intel Corporation. All rights reserved. 
+# Copyright (c) 2007 - 2022 Intel Corporation. All rights reserved. 
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -41,15 +41,11 @@ [Packages]
   MdeModulePkg/MdeModulePkg.dec
   SimicsOpenBoardPkg/OpenBoardPkg.dec
 
-[FeaturePcd]
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
-
 [Sources]
   Logo.c
 
 [Protocols]
   gEfiGraphicsOutputProtocolGuid## SOMETIMES_CONSUMES
-  gEfiUgaDrawProtocolGuid   ## SOMETIMES_CONSUMES
   gEfiBootLogoProtocolGuid  ## SOMETIMES_CONSUMES
   gEfiUserManagerProtocolGuid   ## CONSUMES
   gEfiOemBadgingProtocolGuid## CONSUMES
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/Logo.c 
b/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/Logo.c
index 48a718a90d46..9cea5f4665d0 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/Logo.c
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/Logo.c
@@ -1,7 +1,7 @@
 /** @file
   BDS Lib functions which contain all the code to connect console device
 
-  Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved. 
+  Copyright (c) 2006 - 2022 Intel Corporation. All rights reserved. 
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -300,9 +299,6 @@ EnableBootLogo (
   UINTN Height;
   UINTN Width;
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
-  EFI_UGA_DRAW_PROTOCOL *UgaDraw;
-  UINT32ColorDepth;
-  UINT32RefreshRate;
   EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;
   EFI_BOOT_LOGO_PROTOCOL*BootLogo;
   UINTN NumberOfLogos;
@@ -317,18 +313,10 @@ EnableBootLogo (
   UINTN NewWidth;
   UINT64BufferSize;
 
-  UgaDraw = NULL;
   //
   // Try to open GOP first
   //
   Status = gBS->HandleProtocol (gST->ConsoleOutHandle, 
&gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);
-  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
-GraphicsOutput = NULL;
-//
-// Open GOP failed, try to open UGA
-//
-Status = gBS->HandleProtocol (gST->ConsoleOutHandle, 
&gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);
-  }
   if (EFI_ERROR (Status)) {
 return EFI_UNSUPPORTED;
   }
@@ -351,11 +339,6 @@ EnableBootLogo (
 SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
 SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
 
-  } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
-Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, 
&RefreshRate);
-if (EFI_ERROR (Status)) {
-  return EFI_UNSUPPORTED;
-}
   } else {
 return EFI_UNSUPPORTED;
   }
@@ -503,19 +486,6 @@ EnableBootLogo (
 Height,

[edk2-devel] [ed2-platforms][PATCH 0/2] Remove all UGA support

2022-01-20 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove all UGA support

GuoMinJ (2):
  Platform/Intel/SimicsOpenBoardPkg: Remove all UGA support
  Platform/Intel: Remove All UGA Support

 .../BoardX58Ich10/OpenBoardPkgPcd.dsc |  4 +-
 .../Library/DxeLogoLib/DxeLogoLib.inf |  6 +--
 .../DxePlatformBootManagerLib/BdsPlatform.h   |  1 -
 .../Library/DxeLogoLib/Logo.c | 45 +--
 4 files changed, 3 insertions(+), 53 deletions(-)

-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#85884): https://edk2.groups.io/g/devel/message/85884
Mute This Topic: https://groups.io/mt/88573986/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] MdeModulePkg: Enabling OS boot from SD card through UEFI payload

2022-01-20 Thread Wu, Hao A
(Add missing maintainers/reviewers)

Reviewed-by: Hao A Wu 
Will wait until early next week for the merging to see if any comment from 
other reviewers.

Best Regards,
Hao Wu

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Aiman
> Rosli
> Sent: Friday, January 21, 2022 2:53 AM
> To: devel@edk2.groups.io
> Cc: Rosli, Muhammad Aiman 
> Subject: [edk2-devel] [PATCH v3] MdeModulePkg: Enabling OS boot from SD
> card through UEFI payload
> 
> This changes is by adding 50ms delay during voltage switching from 3.3V to
> 1.8V, plus adding a goto Voltage33Retry for 3.3V checking and retrying.
> 
> Signed-off-by: Aiman Rosli 
> ---
>  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c | 39
> +--
>  1 file changed, 36 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
> b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
> index 662f9f483c..f5a3607e47 100644
> --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
> +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
> @@ -1213,9 +1213,14 @@ SdCardIdentification (
>UINT32 PresentState;
>UINT8  HostCtrl2;
>UINTN  Retry;
> +  BOOLEANForceVoltage33;
> +
> +  ForceVoltage33 = FALSE;
> 
>PciIo= Private->PciIo;
>PassThru = &Private->PassThru;
> +
> +Voltage33Retry:
>//
>// 1. Send Cmd0 to the device
>//
> @@ -1294,6 +1299,13 @@ SdCardIdentification (
>  return EFI_UNSUPPORTED;
>}
> 
> +  //
> +  // 1.8V had failed in the previous run, forcing a retry with 3.3V
> + instead  //  if (ForceVoltage33 == TRUE) {
> +S18r = FALSE;
> +  }
> +
>//
>// 5. Repeatly send Acmd41 with supply voltage window to the device.
>//Note here we only support the cards complied with SD physical
> @@ -1366,9 +1378,30 @@ SdCardIdentification (
> 
>SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE,
> sizeof (PresentState), &PresentState);
>if (((PresentState >> 20) & 0xF) != 0xF) {
> -DEBUG ((DEBUG_ERROR, "SdCardIdentification: SwitchVoltage fails with
> PresentState = 0x%x, It should be 0xF\n", PresentState));
> -Status = EFI_DEVICE_ERROR;
> -goto Error;
> +//
> +// Delay 50 milliseconds in order for clock to stabilize, retry 
> reading the
> SD_MMC_HC_PRESENT_STATE
> +//
> +gBS->Stall (5);
> +SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE,
> sizeof (PresentState), &PresentState);
> +if (((PresentState >> 20) & 0xF) != 0xF) {
> +  DEBUG ((DEBUG_ERROR, "SdCardIdentification: SwitchVoltage fails
> with PresentState = 0x%x, It should be 0xF\n", PresentState));
> +  //
> +  // Reset and reinitialize the slot before the 3.3V retry.
> +  //
> +  Status = SdMmcHcReset (Private, Slot);
> +  if (EFI_ERROR (Status)) {
> +goto Error;
> +  }
> +
> +  Status = SdMmcHcInitHost (Private, Slot);
> +  if (EFI_ERROR (Status)) {
> +goto Error;
> +  }
> +
> +  DEBUG ((DEBUG_ERROR, "SdCardIdentification: Switching to 1.8V
> failed, forcing a retry with 3.3V instead\n"));
> +  ForceVoltage33 = TRUE;
> +  goto Voltage33Retry;
> +}
>}
>  }
> 
> --
> 2.34.1.windows.1
> 
> 
> 
> 
> 



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




[edk2-devel] [PATCH] BaseTools: Fix error leg in DscBuildData.py

2022-01-20 Thread Jake Garver via groups.io
Fix a Edk2Logger.warn() message format to match the arguments.

We ran into this after a failure in PcdValueInit.  The failure was
masked by a new exception, "TypeError: not all arguments converted
during string formatting".

Signed-off-by: Jake Garver 
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 35ec5b37ff..d29b9bf13d 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -3033,7 +3033,7 @@ class DscBuildData(PlatformBuildClassObject):
 returncode, StdOut, StdErr = DscBuildData.ExecuteCommand (Command)
 EdkLogger.verbose ('%s\n%s\n%s' % (Command, StdOut, StdErr))
 if returncode != 0:
-EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not collect 
output from command: %s\n%s\n' % (Command, StdOut, StdErr))
+EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not collect 
output from command: %s\n%s\n%s\n' % (Command, StdOut, StdErr))
 
 #start update structure pcd final value
 File = open (OutputValueFile, 'r')
-- 
2.17.1



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




[edk2-devel][edk2-platforms][PATCH V1 1/1] UserAuthFeaturePkg/PlatformPasswordLibNull: Add UEFI app support

2022-01-20 Thread Oram, Isaac W
Enable library use with UEFI_APPLICATION components similarly to the
other libraries in the package.

Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Guillermo Antonio Palomino Sosa 

Signed-off-by: Isaac Oram 
---
 
Features/Intel/UserInterface/UserAuthFeaturePkg/Library/PlatformPasswordLibNull/PlatformPasswordLibNull.inf
 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/Features/Intel/UserInterface/UserAuthFeaturePkg/Library/PlatformPasswordLibNull/PlatformPasswordLibNull.inf
 
b/Features/Intel/UserInterface/UserAuthFeaturePkg/Library/PlatformPasswordLibNull/PlatformPasswordLibNull.inf
index 00be14df8a..b95849cc61 100644
--- 
a/Features/Intel/UserInterface/UserAuthFeaturePkg/Library/PlatformPasswordLibNull/PlatformPasswordLibNull.inf
+++ 
b/Features/Intel/UserInterface/UserAuthFeaturePkg/Library/PlatformPasswordLibNull/PlatformPasswordLibNull.inf
@@ -18,7 +18,7 @@
   FILE_GUID  = 27417BCA-0CCD-4089-9711-AD069A33C555
   MODULE_TYPE= DXE_DRIVER
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = PlatformPasswordLib|DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER DXE_DRIVER
+  LIBRARY_CLASS  = PlatformPasswordLib|DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER DXE_DRIVER UEFI_APPLICATION
   CONSTRUCTOR= PlatformPasswordLibNullConstructor
 
 #
-- 
2.27.0.windows.1



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




[edk2-devel] [PATCH v3] MdeModulePkg: Enabling OS boot from SD card through UEFI payload

2022-01-20 Thread Aiman Rosli
This changes is by adding 50ms delay during voltage switching from 3.3V to 1.8V,
plus adding a goto Voltage33Retry for 3.3V checking and retrying.

Signed-off-by: Aiman Rosli 
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c | 39 +--
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
index 662f9f483c..f5a3607e47 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
@@ -1213,9 +1213,14 @@ SdCardIdentification (
   UINT32 PresentState;
   UINT8  HostCtrl2;
   UINTN  Retry;
+  BOOLEANForceVoltage33;
+
+  ForceVoltage33 = FALSE;
 
   PciIo= Private->PciIo;
   PassThru = &Private->PassThru;
+
+Voltage33Retry:
   //
   // 1. Send Cmd0 to the device
   //
@@ -1294,6 +1299,13 @@ SdCardIdentification (
 return EFI_UNSUPPORTED;
   }
 
+  //
+  // 1.8V had failed in the previous run, forcing a retry with 3.3V instead
+  //
+  if (ForceVoltage33 == TRUE) {
+S18r = FALSE;
+  }
+
   //
   // 5. Repeatly send Acmd41 with supply voltage window to the device.
   //Note here we only support the cards complied with SD physical
@@ -1366,9 +1378,30 @@ SdCardIdentification (
 
   SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof 
(PresentState), &PresentState);
   if (((PresentState >> 20) & 0xF) != 0xF) {
-DEBUG ((DEBUG_ERROR, "SdCardIdentification: SwitchVoltage fails with 
PresentState = 0x%x, It should be 0xF\n", PresentState));
-Status = EFI_DEVICE_ERROR;
-goto Error;
+//
+// Delay 50 milliseconds in order for clock to stabilize, retry 
reading the SD_MMC_HC_PRESENT_STATE
+//
+gBS->Stall (5);
+SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof 
(PresentState), &PresentState);
+if (((PresentState >> 20) & 0xF) != 0xF) {
+  DEBUG ((DEBUG_ERROR, "SdCardIdentification: SwitchVoltage fails with 
PresentState = 0x%x, It should be 0xF\n", PresentState));
+  //
+  // Reset and reinitialize the slot before the 3.3V retry.
+  //
+  Status = SdMmcHcReset (Private, Slot);
+  if (EFI_ERROR (Status)) {
+goto Error;
+  }
+
+  Status = SdMmcHcInitHost (Private, Slot);
+  if (EFI_ERROR (Status)) {
+goto Error;
+  }
+
+  DEBUG ((DEBUG_ERROR, "SdCardIdentification: Switching to 1.8V 
failed, forcing a retry with 3.3V instead\n"));
+  ForceVoltage33 = TRUE;
+  goto Voltage33Retry;
+}
   }
 }
 
-- 
2.34.1.windows.1



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




[edk2-devel] [PATCH v2 7/8] MdeModulePkg/Pci MdePkg: Create service to retrieve PCI base addresses

2022-01-20 Thread Ojeda Leon, Nicolas via groups.io
Extend the PCI host bridge resource allocation protocol to include one
more service that retrieves the base addresses of all resources of a
given root bridge.
The service is defined to provide, on runtime, the possibility to fetch
the base addresses of a root bridge, replicating the address alignment
used when placing the host bridge's resources in the Gcd memory map.

The intention of this service, initially, is to allow the PCI allocation
process to get the base addresses before allocating the individual BARs
grouped under a root bridge. This enables the placing logic to be
enhanced to account and calculate offsets for pre-populated BARs (PCI
devices' BARs that are already configured and need to be respected).

Cc: Alexander Graf 
Cc: Gerd Hoffmann 

Signed-off-by: Nicolas Ojeda Leon 
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c   | 10 +++
 .../Bus/Pci/PciHostBridgeDxe/PciHostBridge.c  | 81 +++
 .../Bus/Pci/PciHostBridgeDxe/PciHostBridge.h  | 29 +++
 .../PciHostBridgeResourceAllocation.h | 33 
 4 files changed, 153 insertions(+)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
index 63d149b3b8..2ffbc08256 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
@@ -582,6 +582,16 @@ PciHostBridgeResourceAllocator (
PciResUsageTypical
);
 
+  Status = PciResAlloc->GetResourcesBases (
+  PciResAlloc,
+  RootBridgeDev->Handle,
+  &IoBase,
+  &Mem32Base,
+  &PMem32Base,
+  &Mem64Base,
+  &PMem64Base
+  );
+
   //
   // Get the max ROM size that the root bridge can process
   // Insert to resource map so that there will be dedicate MEM32 resource 
range for Option ROM.
diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c 
b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
index b20bcd310a..ddd31f78d6 100644
--- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
+++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
@@ -591,6 +591,7 @@ InitializePciHostBridge (
 HostBridge->ResAlloc.SubmitResources  = SubmitResources;
 HostBridge->ResAlloc.GetProposedResources = GetProposedResources;
 HostBridge->ResAlloc.PreprocessController = PreprocessController;
+HostBridge->ResAlloc.GetResourcesBases= GetResourcesBases;
 
 Status = gBS->InstallMultipleProtocolInterfaces (
 &HostBridge->Handle,
@@ -1734,3 +1735,83 @@ PreprocessController (
 
   return EFI_INVALID_PARAMETER;
 }
+
+/**
+
+  Retrieve the aligned base addresses for all resources of a root bridge.
+
+  @param This  The 
EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
+  @param RootBridgeHandle  RootBridgeHandle returned by GetNextRootBridge to 
locate the
+   root bridge of interest among the list of root 
bridges.
+  @param IoBaseReturns the PIO aperture base address.
+  @param Mem32Base Returns the 32-bit aperture base address.
+  @param PMem32BaseReturns the 32-bit prefetchable aperture base 
address.
+  @param Mem64Base Returns the 64-bit aperture base address.
+  @param PMem64BaseReturns the 64-bit prefetchable aperture base 
address.
+
+  @retval EFI_SUCCESS  Succeed.
+  @retval EFI_NOT_FOUNDRoot bridge was not found.
+
+**/
+EFI_STATUS
+EFIAPI
+GetResourcesBases (
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  *This,
+  IN EFI_HANDLERootBridgeHandle,
+  OUT UINT64   *IoBase,
+  OUT UINT64   *Mem32Base,
+  OUT UINT64   *PMem32Base,
+  OUT UINT64   *Mem64Base,
+  OUT UINT64   *PMem64Base
+  )
+{
+  PCI_HOST_BRIDGE_INSTANCE  *HostBridge;
+  PCI_ROOT_BRIDGE_INSTANCE  *RootBridge;
+  LIST_ENTRY*Link;
+  UINT64Alignment;
+  UINTN BitsOfAlignment;
+
+  HostBridge = PCI_HOST_BRIDGE_FROM_THIS (This);
+
+  for (Link = GetFirstNode (&HostBridge->RootBridges)
+   ; !IsNull (&HostBridge->RootBridges, Link)
+   ; Link = GetNextNode (&HostBridge->RootBridges, Link)
+   )
+  {
+RootBridge = ROOT_BRIDGE_FROM_LINK (Link);
+
+if (RootBridgeHandle == RootBridge->Handle) {
+  //
+  // Have to make sure Alignment is handled since we are doing direct 
address allocation
+  //
+  Alignment   = RootBridge->ResAllocNode[TypeIo].Alignment;
+  BitsOfAlignment = MIN (15, LowBitSet64 (Alignment + 1));
+  *IoBase = ALIGN_VALUE (RootBridge->Io.Base, 

[edk2-devel] [PATCH v2 6/8] MdeModulePkg, OvmfPkg: Add Pcd token for PCI pre-populated BARs

2022-01-20 Thread Ojeda Leon, Nicolas via groups.io
Create a new PCD boolean token in MdeModulePkg for global use.
We use this token to indicate if the configuration, parsed from
fw-cfg, requires pre-populated BARs to be preserved.

During creation of root bridges configurations, the flag is set
according to the "pre-populated-bars" item in fw-cfg. The Pcd token
is created as a dynamic item so it can be modified at runtime and
it is consumed in both Pei and Dxe PCI modules.

In virtualized environments, the hypervisor provides a layer of
isolation between the VMs and the hardware. This isolation may
include address translations and shadowing of configurations that
prevent guests directly modifying hardware registers. The hypervisor
then takes care of emulating the hardware accesses requested by
the guest. In some cases, the host may want the guest to use a
specific value for some or all PCI BARs so that transactions in
GPA level (particularly DMA) can make use of the controlled set
of addresses. The host then indicates the guest to preserve
those BARs that are pre-populated, that is, BARs that already
report a value even before guest's firmware BAR placement.

The token provides a globally accessible configuration flag to
determine, during PCI BAR allocation, if pre-populated BARs must
be respected. The pre-allocated PCI BARs are used in platforms in
which MMIO resources are configured with the same host physical
addresses in the guest so that DMA transactions can happen between
PCI devices without packets going through the IOMMU. Performance is
improved due to PCI packets travelling shorter distances and
avoiding links reaching the Root Complex, which can get busy during
I/O intensive periods.

Cc: Alexander Graf 
Cc: Gerd Hoffmann 

Signed-off-by: Nicolas Ojeda Leon 
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf|  1 +
 MdeModulePkg/MdeModulePkg.dec   |  6 ++
 .../PciHostBridgeUtilityLib.c   | 17 +
 .../PciHostBridgeUtilityLib.inf |  4 
 OvmfPkg/OvmfPkgX64.dsc  |  1 +
 OvmfPkg/PlatformPei/PlatformPei.inf |  1 +
 6 files changed, 30 insertions(+)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
index e317169d9c..046876bb3b 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
@@ -107,6 +107,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration## 
SOMETIMES_CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableBarSupport ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPciPreservePopulatedMappings## CONSUMES
 
 [UserExtensions.TianoCore."ExtraFiles"]
   PciBusDxeExtra.uni
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 463e889e9a..078877ba7f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1902,6 +1902,12 @@
   # @Prompt Disable full PCI enumeration.
   
gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|FALSE|BOOLEAN|0x1048
 
+  ## The flag to control preservation of pre-populated PCI BARs
+  #   TRUE  - Respect pre-populated PCI BARs
+  #   FALSE - No pre-populated BARs, place all BARs
+  # @Prompt Enable preservsation of pre-populated PCI BARs
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdPciPreservePopulatedMappings|FALSE|BOOLEAN|0x1050
+
   ## Disk I/O - Number of Data Buffer block.
   # Define the size in block of the pre-allocated buffer. It provide better
   # performance for large Disk I/O requests.
diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c 
b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c
index b0e3b5e3cf..5c86f67f76 100644
--- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c
+++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -260,6 +261,7 @@ PciHostBridgeUtilityGetRootBridges (
   PCI_ROOT_BRIDGE_APERTURE  HwInfoMemAbove4G;
   PCI_ROOT_BRIDGE_APERTURE  HwInfoPMem;
   PCI_ROOT_BRIDGE_APERTURE  HwInfoPMemAbove4G;
+  UINT64PrePopulatedBars;
 
   *Count = 0;
 
@@ -312,6 +314,21 @@ PciHostBridgeUtilityGetRootBridges (
   ));
   }
 
+  //
+  // Find file for pre-populated bars and set Pcd token if enabled
+  //
+  Status   = QemuFwCfgFindFile ("etc/pre-populated-bars", &FwCfgItem, 
&FwCfgSize);
+  PrePopulatedBars = 0;
+  if (!EFI_ERROR (Status) && (FwCfgSize == sizeof (PrePopulatedBars))) {
+QemuFwCfgSelectItem (FwCfgItem);
+QemuFwCfgReadBytes (FwCfgSize, &PrePopulatedBars);
+
+if (PrePopulatedBars) {
+  PcdSetBoolS (PcdPciPreservePopulatedMappings, TRUE);
+  DEBUG ((DEBUG_INFO, "%a: Pre-populated BARs present\n", __FUNCTION__));
+}
+  }
+
   //
   // Initialize the Hardware Info list head to start with an e

[edk2-devel] [PATCH v2 5/8] OvmfPkg/PciHostBridgeUtilityLib: Initialize RootBridges apertures with spec

2022-01-20 Thread Ojeda Leon, Nicolas via groups.io
Consume the host-provided specification of PCI host bridges if
available. Using the Hardware Info library, populate a list of
hardware descriptors based on the content of the "hardware-info"
fw-cfg file, if provided. In the affirmative case, use the
resources and attributes specified by the hypervisor for each
Host Bridge to create the RootBridge elements.

In Ovmf platforms, the host can provide the specification of
non-discoverable hardware resources like PCI host bridges. If the
proper fw-cfg file is found, parse the contents provided by the
host into a linked list by using the Hardware Info library. Then,
using the list of PCI host bridges' descriptions, populate the
PCI_ROOT_BRIDGES array with the resources and attributes specified
by the host. If the file is not provided or no Host Bridge is found
in it, fold back to the legacy method based on pre-defined
apertures and rules.

In some use cases, the host requires additional control over the
hardware resources' configurations in the guest for performance and
discoverability reasons. For instance, to disclose information about
the PCI hierarchy to the guest so that this can profit from
optimized accesses. In this case, the host can decide to describe
multiple PCI Host Bridges and provide a specific set of resources
(e.g. MMIO apertures) so that the guest uses the values provided.
Using the provided values may entitle the guest to added performance,
for example by using specific MMIO mappings that can enable peer-to-peer
communication across the PCI hierarchy or by allocating memory closer
to a device for faster DMA transactions.

Cc: Alexander Graf 
Cc: Gerd Hoffmann 

Signed-off-by: Nicolas Ojeda Leon 
---
 .../PciHostBridgeUtilityLib.c | 345 ++
 .../PciHostBridgeUtilityLib.inf   |   1 +
 2 files changed, 268 insertions(+), 78 deletions(-)

diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c 
b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c
index 92e1ea812f..b0e3b5e3cf 100644
--- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c
+++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c
@@ -12,13 +12,16 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #pragma pack(1)
 typedef struct {
@@ -234,14 +237,29 @@ PciHostBridgeUtilityGetRootBridges (
   IN  PCI_ROOT_BRIDGE_APERTURE  *PMemAbove4G
   )
 {
-  EFI_STATUSStatus;
-  FIRMWARE_CONFIG_ITEM  FwCfgItem;
-  UINTN FwCfgSize;
-  UINT64ExtraRootBridges;
-  PCI_ROOT_BRIDGE   *Bridges;
-  UINTN Initialized;
-  UINTN LastRootBridgeNumber;
-  UINTN RootBridgeNumber;
+  EFI_STATUSStatus;
+  FIRMWARE_CONFIG_ITEM  FwCfgItem;
+  UINTN FwCfgSize;
+  UINT64ExtraRootBridges;
+  PCI_ROOT_BRIDGE   *Bridges;
+  UINTN Initialized;
+  UINTN LastRootBridgeNumber;
+  UINTN RootBridgeNumber;
+  UINTN PciHostBridgeCount;
+  UINT8 *HardwareInfoBlob;
+  LIST_ENTRYHwInfoList;
+  LIST_ENTRY*HwLink;
+  HARDWARE_INFO *HwInfo;
+  UINT64HwInfoAttributes;
+  UINT64HwInfoAllocationAttributes;
+  BOOLEAN   HwInfoDmaAbove4G;
+  BOOLEAN   HwInfoNoExtendedConfigSpace;
+  BOOLEAN   HwInfoCombineMemPMem;
+  PCI_ROOT_BRIDGE_APERTURE  HwInfoIo;
+  PCI_ROOT_BRIDGE_APERTURE  HwInfoMem;
+  PCI_ROOT_BRIDGE_APERTURE  HwInfoMemAbove4G;
+  PCI_ROOT_BRIDGE_APERTURE  HwInfoPMem;
+  PCI_ROOT_BRIDGE_APERTURE  HwInfoPMemAbove4G;
 
   *Count = 0;
 
@@ -294,103 +312,266 @@ PciHostBridgeUtilityGetRootBridges (
   ));
   }
 
+  //
+  // Initialize the Hardware Info list head to start with an empty but valid
+  // list head.
+  //
+  InitializeListHead (&HwInfoList);
+  HardwareInfoBlob   =  NULL;
+  Initialized= 0;
+  Bridges= NULL;
+  PciHostBridgeCount = 0;
+
+  //
+  // Hypervisor can provide the specifications (resources) for one or more
+  // PCI host bridges. Such information comes through fw-cfg as part of
+  // the hardware-info file.
+  //
+  Status = QemuFwCfgFindFile ("etc/hardware-info", &FwCfgItem, &FwCfgSize);
+
+  if (!EFI_ERROR (Status)) {
+HardwareInfoBlob = AllocatePool (FwCfgSize);
+
+if (HardwareInfoBlob == NULL) {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: Failed to allocate memory for hardware resources info\n",
+__FUNCTION__
+));
+  return NULL;
+}
+
+QemuFwCfgSelectItem (FwCfgItem);
+QemuFwCfgReadBytes (FwCfgSize, HardwareInfoBlob);
+
+//
+// Create the list of hardware info devices filtering for PCI host
+// bridges
+//
+Status = CreateHardwareInfo

[edk2-devel] [PATCH v2 8/8] MdeModulePkg/PciBusDxe: Handling of pre-populated PCI BARs

2022-01-20 Thread Ojeda Leon, Nicolas via groups.io
Extend the PCI BAR placement logic in order to consider pre-populated
resources first, if indicated by the Pcd token for such purpose.

The PCI_BAR type is augmented by one field for mapping the absolute
address of prepopulated BARs into a root bridge relative offset.
As part of the CreateResourceMap stage of the PCI resource allocation
process, all the resources belonging to a root bridge are analyzed and
if a BaseAddress (absolute address read from the PCI device during
enumeration) is present, it is translated into a root-bridge relative
offset and the space occupied by it is marked as used in the root
bridge's aperture. This process is performed before the regular
placement logic is executed.

The remaining unassigned BARs are then placed according to default
logic starting after the last pre-populated resource.

The motivation behind respecting pre-populated BARs is that the
hypervisor can decide on placement of some resources and the guest must
use the same values to benefit from performance optimizations or
specific requirements.

Cc: Alexander Graf 
Cc: Gerd Hoffmann 

Signed-off-by: Nicolas Ojeda Leon 
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h   |   1 +
 .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c  |   5 +-
 MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c   |  11 +
 .../Bus/Pci/PciBusDxe/PciResourceSupport.c| 277 +-
 .../Bus/Pci/PciBusDxe/PciResourceSupport.h|  20 ++
 5 files changed, 310 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
index 4b58c3ea9b..9218566bf6 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
@@ -94,6 +94,7 @@ typedef enum {
 //
 struct _PCI_BAR {
   UINT64  BaseAddress;
+  UINT64  BaseAddressOffset;
   UINT64  Length;
   UINT64  Alignment;
   PCI_BAR_TYPEBarType;
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
index 9251388bc2..91caf162e0 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
@@ -1776,8 +1776,9 @@ PciParseBar (
 return Offset + 4;
   }
 
-  PciIoDevice->PciBar[BarIndex].BarTypeFixed = FALSE;
-  PciIoDevice->PciBar[BarIndex].Offset   = (UINT8)Offset;
+  PciIoDevice->PciBar[BarIndex].BarTypeFixed  = FALSE;
+  PciIoDevice->PciBar[BarIndex].Offset= (UINT8)Offset;
+  PciIoDevice->PciBar[BarIndex].BaseAddressOffset = 0;
   if ((Value & 0x01) != 0) {
 //
 // Device I/Os
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
index 2ffbc08256..452ca10540 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
@@ -605,6 +605,17 @@ PciHostBridgeResourceAllocator (
 GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, 
PMem32Bridge, Mem64Bridge, PMem64Bridge);
   }
 
+  //
+  // Handle pre-populated resources
+  //
+  PopulateResourceAperture (
+Mem32Base,
+PMem32Base,
+Mem64Base,
+PMem64Base,
+RootBridgeDev
+);
+
   //
   // Create resourcemap by going through all the devices subject to this 
root bridge
   //
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
index 8ffd05f327..e2a550bf8e 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
@@ -324,6 +324,266 @@ CalculateApertureIo16 (
   Bridge->Length = MAX (Bridge->Length, PaddingAperture);
 }
 
+/**
+  Analyze a single BAR and if it is pre-populated (its baseAddress is already
+  set), calculate the offset inside the root bridge.
+
+  @param BarPCI BAR to be placed if pre-populated
+  @param Base   Base address of the root bridge
+
+**/
+STATIC
+VOID
+PrePopulateBAR (
+  IN OUT PCI_BAR  *Bar,
+  IN UINT64   Base
+  )
+{
+  if (Base == gAllOne) {
+return;
+  }
+
+  //
+  // Pre-populated IO space BARs are not supported
+  //
+  if ((Bar->BarType == PciBarTypeIo16) || (Bar->BarType == PciBarTypeIo32)) {
+return;
+  }
+
+  if (Bar->BaseAddress < Base) {
+return;
+  }
+
+  if (Bar->BaseAddress != 0) {
+Bar->BaseAddressOffset = Bar->BaseAddress - Base;
+  }
+}
+
+/**
+  Calculate and set the address offset inside the root bridge of device
+  BARs that are pre-populated.
+
+  @param Dev  PCI device whose BARs are to be analyzed
+  @param Base Base address of the root bridge under which the device
+  is located.
+
+ */
+STATIC
+VOID
+PopulateDeviceBars (
+  IN UINT64 Mem32Base,
+  IN UINT64 PMem32Base,
+  IN UINT64 Mem64Base,
+  IN UINT64 PMem64Base,
+  IN PCI_IO_DEVICE  *Dev
+  )
+{
+  UINTN  Index;
+
+  for (Index = 0; Index < PCI_MAX_BAR; Index++) {
+switch (D

[edk2-devel] [PATCH v2 4/8] Ovmf/PlatformPei: Extend 64-bit MMIO range to fit resources

2022-01-20 Thread Ojeda Leon, Nicolas via groups.io
Read the "hardware-info" item from fw-cfg to extract specifications
of PCI host bridges and analyze the 64-bit apertures of them to
find out if 64-bit PCI size needs to be increased in order to
allocate enough address space to fit all the host bridges in a
valid region.

Using the static Hardware Info Lib API, read the fw-cfg file of
hardware information to extract, one by one, all the host
bridges. Find the last 64-bit MMIO address of each host bridge,
using the HardwareInfoPciHostBridgeLib API, and compare it to an
accumulate value to discover the highest address used, which
corresponds to the highest value that must be covered by the
64-bit PCI MMIO window.

Given that platforms with multiple host bridges may provide the PCI
apertures' addresses, the PCD token used to initialize the available
address space (PcdPciMmio64Size) must include those addresses for
the allocation process to be able to place resources in the
intended regions. Since the Pcd entry defining the 64-bit PCI MMIO
size is dynamic and initialized with a platform-dependent value,
it is updated to a higher value if that is required for all
high memory PCI host bridge apertures to fit in the valid address
space.

As an example, if the PcdPciMmio64Size is initialized to 0x8
and the runtime calculated base address produces the value 0x8,
the last 64-bit MMIO address a PCI host bridge may use would be
0xF. If one of the host-specified bridges defines a high
memory window 0x10 - 0x17 (inclusive) it would be
outside of the valid range defined by the Base address + PcdPciMmio64Size.
Therefore, parsing the HardwwareInfo resource allows to notice the higher
requirement and increase the size to 0x10 so that the MMIO
address space solicited by the host can be met and the range effectively
extended to 0x17.

Cc: Alexander Graf 
Cc: Gerd Hoffmann 

Signed-off-by: Nicolas Ojeda Leon 
---
 OvmfPkg/PlatformPei/MemDetect.c | 110 
 OvmfPkg/PlatformPei/PlatformPei.inf |   1 +
 2 files changed, 111 insertions(+)

diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index 1bcb5a08bc..b0bdd435cb 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -36,6 +36,7 @@ Module Name:
 #include 
 #include 
 #include 
+#include 
 
 #include "Platform.h"
 #include "Cmos.h"
@@ -369,6 +370,110 @@ GetSystemMemorySizeAbove4gb (
   return LShiftU64 (Size, 16);
 }
 
+/**
+  Iterate over the PCI host bridges resources information optionally provided
+  in fw-cfg.
+
+  Find the highest address used by the PCI bridges in 64-bit MMIO space to
+  calculate and modify the PCI aperture size accordingly (PciMmio64Size)
+
+  @param[in] PciMmio64BaseBase address (start) of the 64-bit PCI MMIO
+  address space.
+
+  @param[inout] PciMmio64Size Size of the PCI 64-bit MMIO aperture provided
+  as input and modified (output) if the resources
+  indicated by fw_cfg require a larger address
+  space.
+
+  @retval EFI_SUCCESS The fw_cfg host-bridges-info was found and
+  processed.
+
+  @retval EFI_PROTOCOL_ERROR  The host bridges information file was found,
+  but its size wasn't a whole multiple of
+  sizeof(HOST_BRIDGE_INFO). No entry was processed.
+
+  @retval EFI_NOT_FOUND   fw-cfg file with host bridges information was not
+  found. Does not constitute an errro since the 
file
+  is optional and used in special cases.
+
+  @retval EFI_UNSUPPORTED fw-cfg is unavailable
+
+**/
+STATIC
+EFI_STATUS
+ScanPci64BitApertureSize (
+  IN UINT64  PciMmio64Base,
+  IN OUT UINT64  *PciMmio64Size
+  )
+{
+  EFI_STATUSStatus;
+  HOST_BRIDGE_INFO  HostBridge;
+  FIRMWARE_CONFIG_ITEM  FwCfgItem;
+  UINTN FwCfgSize;
+  UINTN FwCfgReadIndex;
+  UINTN ReadDataSize;
+  UINT64PciEnd;
+  UINT64PcdPciEnd;
+  UINT64Above4GMmioEnd;
+
+  PciEnd = 0;
+  Above4GMmioEnd = 0;
+  PcdPciEnd  = PciMmio64Base + *PciMmio64Size - 1;
+
+  Status = QemuFwCfgFindFile ("etc/hardware-info", &FwCfgItem, &FwCfgSize);
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  QemuFwCfgSelectItem (FwCfgItem);
+
+  FwCfgReadIndex = 0;
+  while (FwCfgReadIndex < FwCfgSize) {
+Status = QemuFwCfgReadNextHardwareInfoByType (
+   HardwareInfoTypeHostBridge,
+   sizeof (HostBridge),
+   FwCfgSize,
+   &HostBridge,
+   &ReadDataSize,
+   &FwCfgReadIndex
+   );
+
+if (Status != EFI_SUCCESS) {
+  //
+  // No more data available to read in the file, break
+  // loop and finish process
+  //
+  bre

[edk2-devel] [PATCH v2 0/8] Handling of multiple PCI host bridges specified

2022-01-20 Thread Ojeda Leon, Nicolas via groups.io
Increased control is provided in Ovmf platforms to define and configure
the specifications of multiple PCI host bridges in the hypervisor. The
host propagates this information to the guest, initially through fw-cfg
interface.

In some AWS EC2 platforms, we expose a PCI topology including several
root bridges portraying information about physical distribution that
enables the guest to optimize accesses. Current PCI driver for Ovmf
enables the explicit definition of multiple root bridges and contains
the logic to fix their resources based on a platform-specific PCD entries.
However, we need a way to control, from the hypervisor, how many and which
resources each PCI host bridge can use. For this reason, this patch series
introduces a mechanism to provide PCI host bridges information like bus
number range, attributes, allocation attributes, PIO aperture as well as
32 and 64- bit prefetchable and non-prefetchable MMIO ranges through a
fw-cfg item created by the hypervisor and consumed by the guest firmware.
In order to offer a generic and extensible way to disclose non-discoverable
hardware information from the host to the guest, a new library called
HardwareInfoLib is created in the OvmfPkg. In essence, this library offers
the functionality to parse a generic BLOB into a list as well as the methods
to iterate over such list, including filtering options. The library is
conceived in a generic way so that further hardware elements can also be
described using it. For such purpose the length of the BLOB is not
restricted but instead regarded as a sequence of header-info elements that
allow the parsing during runtime. Furthermore, specific functionality is
provided wrapping QemuFwCfgReadBytes to extract hardware descriptions, in
the aforementioned format, in a static way so that early in the Pei stage
the library can be used to identify address space requirements. The core of
the library offers enough flexibility to process as many elements, even from
different hardware types (heterogenous), as needed in a single run. This
library is extended for the particular use case already exposed, PCI host
bridges, and this same code offers an example of how to tailor it for
further hardware components.

Furthermore, in this kind of high-performance platforms, we exploit PCIe
features like Access Control Services to configure peer-to-peer channels
between devices. This allows us to create direct communication channels
that do not require packets to reach the Root Complex but instead can
follow a direct path from source to target. To enable Guest Virtual Machines
to profit from this performance improvement, we configure resources (BARs)
of peer-to-peer intended devices with Host Physical Addresses. In this
scenario, devices can be instructed, from the guest VM, to perform DMA
operations targeting a peer address space, and the PCIe fabric can take
care of directly routing them. Therefore, long and busy links towards the
Root Complex are avoided. When we configure resources this way, the guest
must respect the pre-populated BARs so that devices preserve the address
ranges configured in the apertures of physical PCIe ports that enable
routing at the hardware level. Similarly, revealing details about the
underlying PCI hierarchy empowers the guest to perform topology-aware
optimizations and benefit from an enhanced performance.

Nicolas Ojeda Leon (8):
  OvmfPkg/Library: Create base HardwareInfoLib for PCI Host Bridges
  Ovmf/HardwareInfoLib: Parse data directly from fw-cfg
  Ovmf/HardwareInfoLib: Add core to parse heterogenous data
  Ovmf/PlatformPei: Extend 64-bit MMIO range to fit resources
  OvmfPkg/PciHostBridgeUtilityLib: Initialize RootBridges apertures with
spec
  MdeModulePkg, OvmfPkg: Add Pcd token for PCI pre-populated BARs
  MdeModulePkg/Pci MdePkg: Create service to retrieve PCI base addresses
  MdeModulePkg/PciBusDxe: Handling of pre-populated PCI BARs

 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h   |   1 +
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf  |   1 +
 .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c  |   5 +-
 MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c   |  21 +
 .../Bus/Pci/PciBusDxe/PciResourceSupport.c| 277 +-
 .../Bus/Pci/PciBusDxe/PciResourceSupport.h|  20 +
 .../Bus/Pci/PciHostBridgeDxe/PciHostBridge.c  |  81 +++
 .../Bus/Pci/PciHostBridgeDxe/PciHostBridge.h  |  29 +
 MdeModulePkg/MdeModulePkg.dec |   6 +
 .../PciHostBridgeResourceAllocation.h |  33 ++
 OvmfPkg/Include/Library/HardwareInfoLib.h | 128 +
 .../Library/QemuFwCfgHardwareInfoLib.h|  59 ++
 .../Library/HardwareInfoLib/HardwareInfoLib.c | 256 +
 .../HardwareInfoLib/HardwareInfoLib.inf   |  43 ++
 .../HardwareInfoPciHostBridgeLib.c| 515 ++
 .../HardwareInfoPciHostBridgeLib.h| 262 +
 .../HardwareInfoLib/HardwareInfoTypesLib.h|  64 +++
 .../QemuFwCfgHardwareInfoLib.c|  89 +++
 .../QemuFwCfgHardwareInfoLib.inf 

[edk2-devel] [PATCH v2 2/8] Ovmf/HardwareInfoLib: Parse data directly from fw-cfg

2022-01-20 Thread Ojeda Leon, Nicolas via groups.io
Create QemuFwCfgHardwareInfoLib which extends the base HardwareInfoLib
and provide fw-cfg wrappers to read hardware info elements out of a
fw-cfg file.

The Hardware Info library is intended to describe non-discoverable
hardware information and share that from the host to the guest in Ovmf
platforms. The QEMU fw-cfg extension for this library provides a first
variation to parse hardware info by reading it directly from a fw-cfg
file. This library offers a wrapper function to the plain
QmeuFwCfgReadBytes which, specifically, parses header-data pairs out
of the binary values in the file. For this purpose, the approach is
incremental, reading the file block by block and outputting the values
only for a specific known hardware type (e.g. PCI host bridges). One
element is returned in each call until the end of the file is reached.

Considering fw-cfg as the first means to transport hardware info from
the host to the guest, this wrapping library offers the possibility
to statically, and in steps, read a specific type of hardware info
elements out of the file. This method reads one hardware element of a
specific type at a time, without the need to pre-allocate memory and
read the whole file or dynamically allocate memory for each new
element found.

As a usage example, the static approach followed by this library
enables early UEFI stages to use and read hardware information
supplied by the host. For instance, in early times of the PEI stage,
hardware information can be parsed out from a fw-cfg file prescinding
from memory services, that may not yet be available, and avoiding
dynamic memory allocations.

Cc: Alexander Graf 
Cc: Gerd Hoffmann 

Signed-off-by: Nicolas Ojeda Leon 
---
 .../Library/QemuFwCfgHardwareInfoLib.h| 59 
 .../QemuFwCfgHardwareInfoLib.c| 89 +++
 .../QemuFwCfgHardwareInfoLib.inf  | 42 +
 OvmfPkg/OvmfPkgX64.dsc|  1 +
 4 files changed, 191 insertions(+)
 create mode 100644 OvmfPkg/Include/Library/QemuFwCfgHardwareInfoLib.h
 create mode 100644 OvmfPkg/Library/HardwareInfoLib/QemuFwCfgHardwareInfoLib.c
 create mode 100644 OvmfPkg/Library/HardwareInfoLib/QemuFwCfgHardwareInfoLib.inf

diff --git a/OvmfPkg/Include/Library/QemuFwCfgHardwareInfoLib.h 
b/OvmfPkg/Include/Library/QemuFwCfgHardwareInfoLib.h
new file mode 100644
index 00..f6c351a4e4
--- /dev/null
+++ b/OvmfPkg/Include/Library/QemuFwCfgHardwareInfoLib.h
@@ -0,0 +1,59 @@
+/*/@file
+  Qemu fw-cfg wrappers for hardware info parsing.
+  Provides an alternative to parse hardware information from a fw-cfg
+  file without relying on dynamic memory allocations.
+
+  Copyright 2021 Amazon.com, Inc. or its affiliates. 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.
+**/
+
+#ifndef __QEMU_FW_CFG_HARDWARE_INFO_LIB_H__
+#define __QEMU_FW_CFG_HARDWARE_INFO_LIB_H__
+
+#include "../Library/HardwareInfoLib/HardwareInfoTypesLib.h"
+
+/**
+  Read, if available, the next Type element in the FwCfg file.
+  The FwCfg item must already be selected, this is a wrapper around
+  QemuFwCfgReadBytes and the Data pointer should be set to an existent
+  memory location with TypeSize bytes allocated for the date to be
+  properly written. If a Type element is found in the file which has a
+  size (in the header) greater than TypeSize, it is skipped.
+
+  @param[in]Type Hardware Info Type to search for
+  @param[in]TypeSize Size (in bytes) of the structure intended to
+ be used to dereference the data
+  @param[in]TotalFileSizeTotal size (in bytes) of the FwCfg file from
+ which the data is read.
+  @param[out]   Data Pointer to a memory allocated instance into
+ which the data is written to.
+  @param[out]   DataSize Size in bytes of the actually filled
+ data available in the Data object after a
+ successful operation
+  @param[inout] ReadIndexIndex of the next byte to be read. Incremented
+ accordingly after a read operation to reflect
+ up to date status
+
+  @retval EFI_SUCCESS Next element found and read into Data
+  @retval EFI_INVALID_PARAMETER   Operation failed
+  @retval EFI_END_OF_FILE End of the file reached, no more elements
+  to read.
+**/
+EFI_STATUS
+QemuFwCfgReadNextHardwareInfoByType (
+  IN  HARDWARE_INFO_TYPE  Type,
+ 

Re: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add Support for authenticated variable

2022-01-20 Thread Zhang, Di

Liming:

> -Original Message-
> From: gaoliming 
> Sent: Wednesday, January 19, 2022 10:57 AM
> To: Chen, Lin Z ; devel@edk2.groups.io; Huang, Long1
> 
> Cc: Bi, Dandan ; Feng, Bob C ;
> Zhang, Di ; Li, Zhuangzhi 
> Subject: 回复: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add
> Support for authenticated variable
> 
> Lin:
> 
> > -邮件原件-
> > 发件人: Chen, Lin Z 
> > 发送时间: 2022年1月18日 8:42
> > 收件人: Gao, Liming ; devel@edk2.groups.io;
> > Huang, Long1 
> > 抄送: Bi, Dandan ; Feng, Bob C
> > ; Zhang, Di ; Li, Zhuangzhi
> > 
> > 主题: RE: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add
> > Support for authenticated variable
> >
> > Hi Liming,
> >
> >Pls see my comments below.
> >
> > 1.
> > PcdNvStoreDefaultValueBuffer type is DynamicEx. Its PcdGetPtr is same to
> > PcdGetExPtr. This change is not required.
> >
> > [Lin] It'll get alignment with PEI phase reference If using PcdGetExPtr
> version.
> > Edk2/MdeModulePkg/Universal/PCD/Pei/Pcd.c#166
> > DataBuffer = (UINT8 *)PeiPcdGetPtrEx (&gEfiMdeModulePkgTokenSpaceGuid,
> > PcdToken (PcdNvStoreDefaultValueBuffer));
> >
> PcdPei is different. It is Pcd driver. It can't consume the real PcdLib.
> So, it doesn't use PcdLib PcdGetPtr() API.
> It uses the internal function PeiPcdGetPtrEx() to get PCD value and size.
> 
> HiiDataBase is normal DXE driver. It can depend on the real PcdLib. So, it
> uses PcdLib PcdGetPtr() API.
> Seemly, current code brings confuse. If so, I am OK to make this change.
> And, please also update PcdGetSize (PcdNvStoreDefaultValueBuffer) with
> LibPcdGetExSize()
> 
> > 2.
> > VariableStorage data buffer is from PcdNvStoreDefaultValueBuffer.
> > PcdNvStoreDefaultValueBuffer is auto generated by BaseTools.
> > By design, its data format is always normal variable storage format.
> > So, its value can't be auth variable format.
> >
> > [Lin] BaseTools can generate authenticated variable storage format now
> (see
> > https://edk2.groups.io/g/devel/message/83329),
> >  since previous FCE tool generates authenticated format, we want to keep
> > variable storage format no changes after switching to StructurePcd.
> >
> Sorry, I miss the previous change in BaseTools. Normal variable storage is
> enough for Tools and Code.
> The default setting format can be always normal variable storage. The
> consumer code logic can be simple.
> I don't know what purpose to keep the alignment with FCE tool behavior. Is
> there other tool or code to use
> the generated PcdNvStoreDefaultValueBuffer?
> 

We have the usage that writing the entire VPD (which has default setup value)
to variable region upon first boot. And the variable region needs to be in
authenticated format when secure boot is enabled, so we also need the VPD in
authenticated format. Hope it clarifies your question.

> Thanks
> Liming
> > Thanks,
> > Lin
> >
> > -Original Message-
> > From: gaoliming 
> > Sent: Monday, January 17, 2022 6:56 PM
> > To: devel@edk2.groups.io; Huang, Long1 
> > Cc: Chen, Lin Z ; Bi, Dandan ;
> > Feng, Bob C 
> > Subject: 回复: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add
> > Support for authenticated variable
> >
> > Long:
> >   I add my comments below.
> >
> > > -邮件原件-
> > > 发件人: devel@edk2.groups.io  代表 Long1
> > Huang
> > > 发送时间: 2022年1月11日 1:03
> > > 收件人: devel@edk2.groups.io
> > > 抄送: Huang Long ; Liming Gao
> > > ; Chen Lin Z ; Dandan
> > > Bi 
> > > 主题: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add Support
> > for
> > > authenticated variable
> > >
> > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3796
> > >
> > > Database.c:
> > >   1. Replace PcdGetExPtr with PcdGetExPtr.
> > >   2. Add FindAuthVariableData function to parse authenticated variable
> > > type for getting a correct default value in
> PcdNvStoreDefaultValueBuffer.
> > >
> > > Cc: Liming Gao 
> > > Cc: Chen Lin Z 
> > > Cc: Dandan Bi 
> > >
> > > Signed-off-by: Huang Long 
> > > ---
> > >  .../Universal/HiiDatabaseDxe/Database.c   | 147
> > +-
> > >  .../HiiDatabaseDxe/HiiDatabaseDxe.inf |   3 +
> > >  2 files changed, 114 insertions(+), 36 deletions(-)
> > >
> > > diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
> > > b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
> > > index 0b09c24d52..c055fa0f29 100644
> > > --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
> > > +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
> > > @@ -603,6 +603,45 @@ FindVariableData (
> > >return NULL;
> > >
> > >  }
> > >
> > >
> > >
> > > +/**
> > >
> > > +  Find the matched authenticated variable from the input variable
> > storage.
> > >
> > > +
> > >
> > > +  @param[in] VariableStorage Point to the variable storage header.
> > >
> > > +  @param[in] VarGuid A unique identifier for the variable.
> > >
> > > +  @param[in] VarAttributeThe attributes bitmask for the variable.
> > >
> > > +  @param[in] VarName A Null-terminated ascii string that is
> > the
> > > name of the variable.

Re: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER bitfield parser

2022-01-20 Thread Attar, AbdulLateef (Abdul Lateef) via groups.io
[Public]

Hi Sami,
Why Bugzilla ticket required?
Also please see inline for my response [Abdul].
Thanks
AbduL

From: devel@edk2.groups.io  On Behalf Of Sami Mujawar via 
groups.io
Sent: 19 January 2022 22:17
To: Attar, AbdulLateef (Abdul Lateef) ; 
devel@edk2.groups.io
Cc: Ray Ni ; Zhichao Gao ; nd 

Subject: Re: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER 
bitfield parser

[CAUTION: External Email]

Hi Abdul,

Please also create a bugzilla ticket and add a reference to it in the commit 
message.

Regards,

Sami Mujawar

On 19/01/2022 04:44 PM, Sami Mujawar wrote:

Hi Abdul,

Thank you for providing a patch to add this feature to Acpiview.

I have some minor feedback marked inline as [SAMI].

Regards,

Sami Mujawar

On 19/12/2021 02:44 PM, Abdul Lateef Attar wrote:

Adds ParseAcpiBitFields() which is based on

ParseAcpi() and capable of parsing the bit fields.

Supports parsing of UINT8, UINT16, UINT32 and UINT64 byte data.



Cc: Ray Ni 

Cc: Zhichao Gao 

Cc: Sami Mujawar 

Signed-off-by: Abdul Lateef Attar 

---

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h |  45 +

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 185 


 2 files changed, 230 insertions(+)



diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

index 5c916a4720b8..83266e8ec2d3 100644

--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

@@ -2,6 +2,7 @@

   Header file for ACPI parser







   Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.



+  Copyright (c) 2021, AMD Incorporated. All rights reserved.



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



 **/







@@ -251,6 +252,11 @@ typedef VOID (EFIAPI *FNPTR_FIELD_VALIDATOR)(UINT8 *Ptr, 
VOID *Context);

   the field data. If the field is more complex and requires additional



   processing for formatting and representation a print formatter function



   can be specified in 'PrintFormatter'.



+



+  ParseAcpiBitFields() uses AcpiParser structure to parse the bit fields.



+  It considers Length as a number of bits that need to be parsed.



+  Also, the Offset field will be considered as starting offset of the bitfield.



+



   The PrintFormatter function may choose to use the format string



   specified by 'Format' or use its own internal format string.







@@ -264,10 +270,12 @@ typedef struct AcpiParser {





   /// The length of the field.



   /// (Byte Length column from ACPI table spec)



+  /// Length(in bits) of the bitfield if used with ParseAcpiBitFields().



   UINT32   Length;







   /// The offset of the field from the start of the table.



   /// (Byte Offset column from ACPI table spec)



+  /// The Bit offset of the field if used with ParseAcpiBitFields().



   UINT32   Offset;







   /// Optional Print() style format string for tracing the data. If not



@@ -364,6 +372,43 @@ ParseAcpi (

   IN UINT32 ParserItems



   );







+/**



+  This function is used to parse an ACPI table bitfield buffer.



+



+  The ACPI table buffer is parsed using the ACPI table parser information



+  specified by a pointer to an array of ACPI_PARSER elements. This parser



+  function iterates through each item on the ACPI_PARSER array and logs the 
ACPI table bitfields.



+



+  This function can optionally be used to parse ACPI tables and fetch specific



+  field values. The ItemPtr member of the ACPI_PARSER structure (where used)



+  is updated by this parser function to point to the selected field data



+  (e.g. useful for variable length nested fields).



+



+  @param [in] TraceTrace the ACPI fields TRUE else only parse the



+   table.



+  @param [in] Indent   Number of spaces to indent the output.



+  @param [in] AsciiNameOptional pointer to an ASCII string that describes



+   the table being parsed.



+  @param [in] Ptr  Pointer to the start of the buffer.



+  @param [in] Length   Length of the buffer pointed by Ptr.



+  @param [in] Parser   Pointer to an array of ACPI_PARSER structure that



+   describes the table being parsed.



+  @param [in] ParserItems  Number of items in the ACPI_PARSER array.



+



+  @retval Number of bits parsed.



+**/



+UINT32



+EFIAPI



+ParseAcpiBitFields (



+  IN BOOLEANTrace,



+  IN UINT32 Indent,



+  IN CONST CHAR8*AsciiName OPTIONAL,



+  IN UINT8  *Ptr,



+  IN UINT32 Length,



+  IN CONST ACPI_PARSER  *Parser,



+  IN UINT32 ParserItems



+  );



+



 /**



This is a helper macro t

[edk2-devel] [Patch] BaseTools/Conf: Add new macro for customizing dll file reduction.

2022-01-20 Thread Xu, Wei6
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3810

New macro OBJCOPY_STRIPFLAG is added in build_rule.template to replace
'--strip-unneeded -R .eh_frame', so that module can have some unique
objcopy flags for its own purpose.
In tools_def.template, set '--strip-unneeded -R .eh_frame' as default
value of OBJCOPY_STRIPFLAG.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yuwei Chen 
Signed-off-by: Wei6 Xu 
---
 BaseTools/Conf/build_rule.template | 2 +-
 BaseTools/Conf/tools_def.template  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index 3add1029f2..f401182344 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -373,11 +373,11 @@
 $(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
 -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
 -$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR) 
 
 $(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).debug
-$(OBJCOPY) --strip-unneeded -R .eh_frame ${src}
+$(OBJCOPY) $(OBJCOPY_STRIPFLAG) ${src}
 
 #
 #The below 2 lines are only needed for UNIXGCC tool chain, which 
generates PE image directly
 #
 -$(OBJCOPY) $(OBJCOPY_ADDDEBUGFLAG) ${src}
diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 2e6b382ab6..85b8afbb2d 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1860,10 +1860,11 @@ NOOPT_VS2019_AARCH64_DLINK_FLAGS   = /NOLOGO 
/NODEFAULTLIB /IGNORE:4001 /OPT:REF
 *_*_*_SYMRENAME_PATH= echo
 *_*_*_SYMRENAME_FLAGS   = Symbol renaming not needed for
 DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG = 
--add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
 RELEASE_*_*_OBJCOPY_ADDDEBUGFLAG   =
 NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = 
--add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
+*_*_*_OBJCOPY_STRIPFLAG= --strip-unneeded -R .eh_frame
 *_*_*_DTC_FLAGS= -H epapr
 *_*_*_DTCPP_PATH   = DEF(DTCPP_BIN)
 *_*_*_DTC_PATH = DEF(DTC_BIN)
 
 DEFINE GCC_ALL_CC_FLAGS= -g -Os -fshort-wchar -fno-builtin 
-fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h 
-fno-common
-- 
2.16.2.windows.1



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




[edk2-devel] Cancelled Event: TianoCore Design Meeting - APAC/NAMO - Friday, January 7, 2022 #cal-cancelled

2022-01-20 Thread devel@edk2.groups.io Calendar
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Groups.io Inc//Groups.io Calendar//EN
METHOD:CANCELLED
REFRESH-INTERVAL;VALUE=DURATION:PT1H
X-PUBLISHED-TTL:PT1H
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Asia/Shanghai
LAST-MODIFIED:20201011T015911Z
TZURL:http://tzurl.org/zoneinfo-outlook/Asia/Shanghai
X-LIC-LOCATION:Asia/Shanghai
BEGIN:STANDARD
TZNAME:CST
TZOFFSETFROM:+0800
TZOFFSETTO:+0800
DTSTART:19700101T00
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
X-GIOIDS:Event:1238691 
UID:ccyo.1615368347866508187.a...@groups.io
DTSTAMP:20220120T145250Z
ORGANIZER;CN=Ray Ni:mailto:ray...@intel.com
DTSTART:20220107T013000Z
DTEND:20220107T023000Z
SUMMARY:TianoCore Design Meeting - APAC/NAMO
DESCRIPTION:## TOPIC\n\n1. NA\n\nFor more info\, see here: https://www.ti
 anocore.org/design-meeting/\n\n---\n## Microsoft Teams meeting\n\n### Joi
 n on your computer or mobile app\n\n[Click here to join the meeting](http
 s://teams.microsoft.com/l/meetup-join/19%3ameeting_OTNmZTNhMWEtOWQwNi00ZT
 dkLWI5NDgtYTFmYjNkOWI0ZDg4%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d
 88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%2255d36a50-78be-4ced-bc2
 7-3d06c576cc19%22%7d)\n\n### Join with a video conferencing device\n\ntea
 m...@conf.intel.com\n\nVideo Conference ID: 119 715 416 0\n\n[Alternate VTC
  dialing instructions](https://conf.intel.com/teams/?conf=1197154160&ivr=
 teams&d=conf.intel.com&test=test_call)\n\n[Learn More](https://aka.ms/Joi
 nTeamsMeeting) | [Meeting options](https://teams.microsoft.com/meetingOpt
 ions/?organizerId=55d36a50-78be-4ced-bc27-3d06c576cc19&tenantId=46c98d88-
 e344-4ed4-8496-4ed7712e255d&threadId=19_meeting_OTNmZTNhMWEtOWQwNi00ZTdkL
 WI5NDgtYTFmYjNkOWI0ZDg4@thread.v2&messageId=0&language=en-US)
LOCATION:Microsoft Teams
SEQUENCE:2
STATUS:CANCELLED
END:VEVENT
END:VCALENDAR


invite.ics
Description: application/ics


Re: [edk2-devel] [PATCH EDK2 v1 0/1] RedfishPkg/RedfishRestExDxe:Simplify status check

2022-01-20 Thread Abner Chang
Merged.
Thanks to helping on this.
Abner


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




Re: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER bitfield parser

2022-01-20 Thread Sami Mujawar
Hi Zhichao, Abdul,

Please find my response inline marked [SAMI].

Regards,

Sami Mujawar

From: "Gao, Zhichao" 
Date: Thursday, 20 January 2022 at 08:37
To: "Attar, AbdulLateef (Abdul Lateef)" , 
"devel@edk2.groups.io" , Sami Mujawar 

Cc: "Ni, Ray" , nd 
Subject: RE: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER 
bitfield parser

Hi,

Sorry for the late response. Many works interrupt my review plan.
The BZ creation and update is part of edk2 develop process EDK II Development 
Process · tianocore/tianocore.github.io Wiki · 
GitHub.
It give a good history of the code change and it can be traced by the edk2 
stable release page.

Back to the patch itself. Because it is a reuse the structure of the 
ACPI_PARSER, I think it is fine to take Length check into consideration for 
security thinking.
[SAMI] I agree that the Length check is required from a security perspective. 
If Parser[Index].Length is 0, this means the parser has not been described 
correctly, and logging an error message would be helpful (which I think would 
happen as part of the default case in the Switch statement).
I am fine with keeping this check (as done in the patch) but would recommend 
logging an error message before continuing.
[/SAMI]

For the ItemPtr, it is used to be used outside the parser. So the patch looks  
fine to me.
[SAMI] The ItemPtr is designed to get a reference to the field data in the ACPI 
table memory area. This allows the ItemPtr to be used outside the function 
(e.g. to examine the field). This patch is setting up the ItemPtr to point to a 
local variable, which is not right and would result in accessing an invalid 
memory area.

To give an example on how ItemPtr is designed to work see:

  *   Declaration of ItemPtr for Flags field at 
https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c#L20
  *   Initialisation of FadtParser with ItemPtr for Flags field at 
https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c#L176
  *   Invocation of ParseAcpi() for FadtParser at 
https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c#L226-L233
  *   Usage of ItemPtr for Flags field at 
https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c#L260-L261

[/SAMI]

Anything I miss consideration, please feel free to point out.

Thanks,
Zhichao


From: Attar, AbdulLateef (Abdul Lateef) 
Sent: Thursday, January 20, 2022 11:25 AM
To: devel@edk2.groups.io; sami.muja...@arm.com
Cc: Ni, Ray ; Gao, Zhichao ; nd 

Subject: RE: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER 
bitfield parser


[Public]

Hi Sami,
Why Bugzilla ticket required?
Also please see inline for my response [Abdul].
Thanks
AbduL

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Sami Mujawar 
via groups.io
Sent: 19 January 2022 22:17
To: Attar, AbdulLateef (Abdul Lateef) 
mailto:abdullateef.at...@amd.com>>; 
devel@edk2.groups.io
Cc: Ray Ni mailto:ray...@intel.com>>; Zhichao Gao 
mailto:zhichao@intel.com>>; nd 
mailto:n...@arm.com>>
Subject: Re: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER 
bitfield parser

[CAUTION: External Email]

Hi Abdul,

Please also create a bugzilla ticket and add a reference to it in the commit 
message.

Regards,

Sami Mujawar

On 19/01/2022 04:44 PM, Sami Mujawar wrote:

Hi Abdul,

Thank you for providing a patch to add this feature to Acpiview.

I have some minor feedback marked inline as [SAMI].

Regards,

Sami Mujawar

On 19/12/2021 02:44 PM, Abdul Lateef Attar wrote:

Adds ParseAcpiBitFields() which is based on

ParseAcpi() and capable of parsing the bit fields.

Supports parsing of UINT8, UINT16, UINT32 and UINT64 byte data.



Cc: Ray Ni 

Cc: Zhichao Gao 

Cc: Sami Mujawar 

Signed-off-by: Abdul Lateef Attar 

---

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h |  45 +

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 185 


 2 files changed, 230 insertions(+)



diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

index 5c916a4720b8..83266e8ec2d3 100644

--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

@@ -2,6 +2,7 @@

   Header file for ACPI parser







   Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.



+  Copyright (c) 2021, AMD Incorporated. All rights reserved.



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



 **/







Re: [edk2-devel] [PATCH EDK2 v1 0/1] RedfishPkg/RedfishRestExDxe:Simplify status check

2022-01-20 Thread wenyi,xie via groups.io


On 2022/1/20 10:30, Chang, Abner (HPS SW/FW Technologist) wrote:
> Hi Wenyi,
> Could you please create PR for this change? So we can have core CI on this 
> patch and I can also merge this patch later when the core CI is finished 
> successfully.
> Just send me the link to PR once you create it.
> 

Sure, here's the link.
https://github.com/tianocore/edk2/pull/2429

Thanks
Wenyi

> Thanks
> Abner
> --
> *From:* xiewenyi (A) 
> *Sent:* Wednesday, January 19, 2022 3:39 PM
> *To:* Chang, Abner (HPS SW/FW Technologist) ; 
> devel@edk2.groups.io ; Wang, Nickle (Server BIOS) 
> 
> *Cc:* songdongku...@huawei.com 
> *Subject:* Re: [PATCH EDK2 v1 0/1] RedfishPkg/RedfishRestExDxe:Simplify 
> status check
>  
> 
> 
> On 2022/1/19 15:29, Chang, Abner (HPS SW/FW Technologist) wrote:
>> Hi Wenyi,
>> May I know what is the problem you encountered and what environment causes 
>> the issue? Is that under edk2 emulation or the real Redfish service?
>> 
> Hi Abner,
> I didn't encounter any issue and there's no functional change in this patch, 
> just try to simplify the code. Please review whether it's OK or not.
> 
> Thanks
> Wenyi
>> Thanks
>> Abner
>> --
>> *From:* Wenyi Xie 
>> *Sent:* Wednesday, January 19, 2022 2:12 PM
>> *To:* devel@edk2.groups.io ; Chang, Abner (HPS SW/FW 
>> Technologist) ; Wang, Nickle (Server BIOS) 
>> 
>> *Cc:* songdongku...@huawei.com ; 
>> xiewen...@huawei.com 
>> *Subject:* [PATCH EDK2 v1 0/1] RedfishPkg/RedfishRestExDxe:Simplify status 
>> check
>>  
>> Main Changes :
>> 1.Remove redundant if statement.
>> 
>> Wenyi Xie (1):
>>   RedfishPkg/RedfishRestExDxe:Simplify status check
>> 
>>  RedfishPkg/RedfishRestExDxe/RedfishRestExImpl.c | 38 +---
>>  1 file changed, 17 insertions(+), 21 deletions(-)
>> 
>> -- 
>> 2.20.1.windows.1
>> 


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




Re: [edk2-devel] [PATCH V4 22/31] OvmfPkg: Update PlatformPei to support TDX

2022-01-20 Thread Min Xu
Hi
> > +/**
> > +  Check if it is Tdx guest
> > +
> > +  @retvalTRUE   It is Tdx guest
> > +  @retvalFALSE  It is not Tdx guest
> > +**/
> > +BOOLEAN
> > +PlatformPeiIsTdxGuest (
> > +  VOID
> > +  )
> > +{
> > +  CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER
> *CcWorkAreaHeader;
> > +
> > +  CcWorkAreaHeader =
> (CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER
> > +*)FixedPcdGet32 (PcdOvmfWorkAreaBase);
> > +  return (CcWorkAreaHeader != NULL && CcWorkAreaHeader->GuestType
> ==
> > +GUEST_TYPE_INTEL_TDX); }
> 
> fwcfg patch adds a similar function.  Can't we have a single function
> somewhere, or have a #define for this check, instead of doing this
> cut+paste programming?
There is TdIsEnabled() in BaseLib. So PlatformPeiIsTdxGuest is deprecated in 
the next version.
> 
> > +VOID
> > +EFIAPI
> > +DEBUG_HOBLIST (
> > +  IN CONST VOID  *HobStart
> > +  )
> > +{
> > +  EFI_PEI_HOB_POINTERS  Hob;
> > +
> > +  Hob.Raw = (UINT8 *)HobStart;
> > +  //
> > +  // Parse the HOB list until end of list or matching type is found.
> > +  //
> > +  while (!END_OF_HOB_LIST (Hob)) {
> > +DEBUG ((DEBUG_INFO, "HOB(%p) : %x %x\n", Hob, Hob.Header-
> >HobType, Hob.Header->HobLength));
> > +switch (Hob.Header->HobType) {
> > +  case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR:
> > +DEBUG ((
> > +  DEBUG_INFO,
> > +  "\t: %x %x %llx %llx\n",
> > +  Hob.ResourceDescriptor->ResourceType,
> > +  Hob.ResourceDescriptor->ResourceAttribute,
> > +  Hob.ResourceDescriptor->PhysicalStart,
> > +  Hob.ResourceDescriptor->ResourceLength
> > +  ));
> > +
> > +break;
> > +  case EFI_HOB_TYPE_MEMORY_ALLOCATION:
> > +DEBUG ((
> > +  DEBUG_INFO,
> > +  "\t: %llx %llx %x\n",
> > +  Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress,
> > +  Hob.MemoryAllocation->AllocDescriptor.MemoryLength,
> > +  Hob.MemoryAllocation->AllocDescriptor.MemoryType
> > +  ));
> > +break;
> > +  default:
> > +break;
> > +}
> > +
> > +Hob.Raw = GET_NEXT_HOB (Hob);
> > +  }
> > +}
> 
> Likewise, I've seen this before in another patch of this series.
This will be deprecated in the next version.
> 
> > diff --git a/OvmfPkg/PlatformPei/MemDetect.c
> > b/OvmfPkg/PlatformPei/MemDetect.c index 934d5c196570..9227fa260ccd
> > 100644
> > --- a/OvmfPkg/PlatformPei/MemDetect.c
> > +++ b/OvmfPkg/PlatformPei/MemDetect.c
> > @@ -36,6 +36,7 @@ Module Name:
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  #include "Platform.h"
> >  #include "Cmos.h"
> > @@ -556,7 +557,19 @@ AddressWidthInitialization (
> >  mPhysMemAddressWidth = 36;
> >}
> >
> > + #if defined (MDE_CPU_X64)
> > +  if (PlatformPeiIsTdxGuest ()) {
> > +if (TdSharedPageMask () == (1ULL << 47)) {
> > +  mPhysMemAddressWidth = 48;
> > +} else {
> > +  mPhysMemAddressWidth = 52;
> > +}
> > +  }
> > +
> > +  ASSERT (mPhysMemAddressWidth <= 52); #else
> 
> Making this TDX-specific looks wrong to me.  5-level paging exists outside TDX
> too.
> 
> Given we don't support 5-level paging (yet) I think we can just drop this and
> revisit in case 5-level paging support is added in the future.
> 
> > +  UINT32   Pml5Entries;
> 
> Same here.
mPhysMemAddressWidth indicates the physical memory address width. Tdx guest 
supports GPAW of 52 or 48. So I think here mPhysMemAddresWidth is correct.
Even mPhysMemAddress is 52, we can still use 4-level paging. So I am going to 
update GetPeiMemoryCap() like below:

  if (mPhysMemAddressWidth <= 39) {
Pml4Entries = 1;
PdpEntries = 1 << (mPhysMemAddressWidth - 30);
ASSERT (PdpEntries <= 0x200);
  } else {
if (TdIsEnabled ()) {   <-- If it is td guest, then Pml4Entries is 
set to 0x200.
  Pml4Entries = 0x200;
} else {
  Pml4Entries = 1 << (mPhysMemAddressWidth - 39);
}
ASSERT (Pml4Entries <= 0x200);
PdpEntries = 512;
  }

Thanks
Min


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




Re: [edk2-devel] [PATCH v4 2/2] ShellPkg/AcpiView: PrintFormatter for FADT Flags field

2022-01-20 Thread Gao, Zhichao
Reviewed-by: Zhichao Gao 

Thanks,
Zhichao

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Sami
> Mujawar
> Sent: Thursday, January 20, 2022 12:45 AM
> To: Abdul Lateef Attar ; devel@edk2.groups.io
> Cc: Ni, Ray ; Gao, Zhichao ; nd
> 
> Subject: Re: [edk2-devel] [PATCH v4 2/2] ShellPkg/AcpiView: PrintFormatter
> for FADT Flags field
> 
> Hi Abdul,
> 
> Thank you for this patch.
> 
> These changes look good to me.
> 
> Reviewed-by: Sami Mujawar 
> 
> Regards,
> 
> Sami Mujawar
> 
> 
> On 19/12/2021 02:44 PM, Abdul Lateef Attar wrote:
> > Adds PrintFormatter function to the FADT flags field.
> > Prints indivisual flag name along with flag value.
> >
> > Cc: Ray Ni 
> > Cc: Zhichao Gao 
> > Cc: Sami Mujawar 
> > Signed-off-by: Abdul Lateef Attar 
> > ---
> >
> ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
> | 167 +---
> >   1 file changed, 112 insertions(+), 55 deletions(-)
> >
> > diff --git
> >
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser
> > .c
> >
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser
> > .c index f8fbb4bcb8e9..5ff02f3d38a1 100644
> > ---
> >
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser
> > .c
> > +++
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPa
> > +++ rser.c
> > @@ -2,6 +2,7 @@
> > FADT table parser
> >
> >
> >
> > Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
> >
> > +  Copyright (c) 2021, AMD Incorporated. All rights reserved.
> >
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >
> >
> > @par Reference(s):
> >
> > @@ -130,69 +131,125 @@ ValidateFlags (
> >#endif
> >
> >   }
> >
> >
> >
> > +STATIC CONST ACPI_PARSER  FadtFlagParser[] = {
> >
> > +  { L"WBINVD",   1,  0,  L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"WBINVD_FLUSH", 1,  1,  L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"PROC_C1",  1,  2,  L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"P_LVL2_UP",1,  3,  L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"PWR_BUTTON",   1,  4,  L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"SLP_BUTTON",   1,  5,  L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"FIX_RTC",  1,  6,  L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"RTC_S4",   1,  7,  L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"TMR_VAL_EXT",  1,  8,  L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"DCK_CAP",  1,  9,  L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"RESET_REG_SUP",1,  10, L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"SEALED_CASE",  1,  11, L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"HEADLESS", 1,  12, L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"CPU_SW_SLP",   1,  13, L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"PCI_EXP_WAK",  1,  14, L"%d", NULL, NULL, 
> > NULL, NULL },
> >
> > +  { L"USE_PLATFORM_CLOCK",   1,  15, L"%d", NULL, NULL, 
> > NULL,
> NULL },
> >
> > +  { L"S4_RTC_STS_VALID", 1,  16, L"%d", NULL, NULL, 
> > NULL,
> NULL },
> >
> > +  { L"REMOTE_POWER_ON_CAPABLE",  1,  17, L"%d", NULL, NULL,
> NULL, NULL },
> >
> > +  { L"FORCE_APIC_CLUSTER_MODEL", 1,  18, L"%d", NULL, NULL,
> NULL, NULL },
> >
> > +  { L"FORCE_APIC_PHYSICAL_DESTINATION_MODE", 1,  19, L"%d", NULL,
> > + NULL, NULL, NULL },
> >
> > +  { L"HW_REDUCED_ACPI",  1,  20, L"%d", NULL, NULL, 
> > NULL,
> NULL },
> >
> > +  { L"LOW_POWER_S0_IDLE_CAPABLE",1,  21, L"%d", NULL, NULL,
> NULL, NULL },
> >
> > +  { L"Reserved", 10, 22, L"%d", NULL, NULL, 
> > NULL, NULL }
> >
> > +};
> >
> > +
> >
> > +/**
> >
> > +  This function traces FADT Flags fields.
> >
> > +  If no format string is specified the Format must be NULL.
> >
> > +
> >
> > +  @param [in] Format  Optional format string for tracing the data.
> >
> > +  @param [in] Ptr Pointer to the start of the buffer.
> >
> > +**/
> >
> > +VOID
> >
> > +EFIAPI
> >
> > +DumpFadtFlags (
> >
> > +  IN CONST CHAR16  *Format OPTIONAL,
> >
> > +  IN UINT8 *Ptr
> >
> > +  )
> >
> > +{
> >
> > +  if (Format != NULL) {
> >
> > +Print (Format, *(UINT32 *)Ptr);
> >
> > +return;
> >
> > +  }
> >
> > +
> >
> > +  Print (L"0x%X\n", *(UINT32 *)Ptr);
> >
> > +  ParseAcpiBitFields (
> >
> > +TRUE,
> >
> > +2,
> >
> > +NULL,
> >
> > +Ptr,
> >
> > +4,
> >
> > +PARSER_PARAMS (FadtFlagParser)
> >
> > +);
> >
> > +}
> >
> > +
> >
> >   /**
> >
> > An ACPI_PARSER array describing the A

Re: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER bitfield parser

2022-01-20 Thread Gao, Zhichao
Hi,

Sorry for the late response. Many works interrupt my review plan.
The BZ creation and update is part of edk2 develop process EDK II Development 
Process * tianocore/tianocore.github.io Wiki * 
GitHub.
It give a good history of the code change and it can be traced by the edk2 
stable release page.

Back to the patch itself. Because it is a reuse the structure of the 
ACPI_PARSER, I think it is fine to take Length check into consideration for 
security thinking.
For the ItemPtr, it is used to be used outside the parser. So the patch looks  
fine to me.

Anything I miss consideration, please feel free to point out.

Thanks,
Zhichao


From: Attar, AbdulLateef (Abdul Lateef) 
Sent: Thursday, January 20, 2022 11:25 AM
To: devel@edk2.groups.io; sami.muja...@arm.com
Cc: Ni, Ray ; Gao, Zhichao ; nd 

Subject: RE: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER 
bitfield parser


[Public]

Hi Sami,
Why Bugzilla ticket required?
Also please see inline for my response [Abdul].
Thanks
AbduL

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Sami Mujawar 
via groups.io
Sent: 19 January 2022 22:17
To: Attar, AbdulLateef (Abdul Lateef) 
mailto:abdullateef.at...@amd.com>>; 
devel@edk2.groups.io
Cc: Ray Ni mailto:ray...@intel.com>>; Zhichao Gao 
mailto:zhichao@intel.com>>; nd 
mailto:n...@arm.com>>
Subject: Re: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER 
bitfield parser

[CAUTION: External Email]

Hi Abdul,

Please also create a bugzilla ticket and add a reference to it in the commit 
message.

Regards,

Sami Mujawar

On 19/01/2022 04:44 PM, Sami Mujawar wrote:

Hi Abdul,

Thank you for providing a patch to add this feature to Acpiview.

I have some minor feedback marked inline as [SAMI].

Regards,

Sami Mujawar

On 19/12/2021 02:44 PM, Abdul Lateef Attar wrote:

Adds ParseAcpiBitFields() which is based on

ParseAcpi() and capable of parsing the bit fields.

Supports parsing of UINT8, UINT16, UINT32 and UINT64 byte data.



Cc: Ray Ni 

Cc: Zhichao Gao 

Cc: Sami Mujawar 

Signed-off-by: Abdul Lateef Attar 

---

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h |  45 +

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 185 


 2 files changed, 230 insertions(+)



diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

index 5c916a4720b8..83266e8ec2d3 100644

--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

@@ -2,6 +2,7 @@

   Header file for ACPI parser







   Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.



+  Copyright (c) 2021, AMD Incorporated. All rights reserved.



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



 **/







@@ -251,6 +252,11 @@ typedef VOID (EFIAPI *FNPTR_FIELD_VALIDATOR)(UINT8 *Ptr, 
VOID *Context);

   the field data. If the field is more complex and requires additional



   processing for formatting and representation a print formatter function



   can be specified in 'PrintFormatter'.



+



+  ParseAcpiBitFields() uses AcpiParser structure to parse the bit fields.



+  It considers Length as a number of bits that need to be parsed.



+  Also, the Offset field will be considered as starting offset of the bitfield.



+



   The PrintFormatter function may choose to use the format string



   specified by 'Format' or use its own internal format string.







@@ -264,10 +270,12 @@ typedef struct AcpiParser {





   /// The length of the field.



   /// (Byte Length column from ACPI table spec)



+  /// Length(in bits) of the bitfield if used with ParseAcpiBitFields().



   UINT32   Length;







   /// The offset of the field from the start of the table.



   /// (Byte Offset column from ACPI table spec)



+  /// The Bit offset of the field if used with ParseAcpiBitFields().



   UINT32   Offset;







   /// Optional Print() style format string for tracing the data. If not



@@ -364,6 +372,43 @@ ParseAcpi (

   IN UINT32 ParserItems



   );







+/**



+  This function is used to parse an ACPI table bitfield buffer.



+



+  The ACPI table buffer is parsed using the ACPI table parser information



+  specified by a pointer to an array of ACPI_PARSER elements. This parser



+  function iterates through each item on the ACPI_PARSER array and logs the 
ACPI table bitfields.



+



+  This function can optionally be used to parse ACPI tables and fetch specific



+  field values. The ItemPtr member of the ACPI_PARSER structure (where used)



+  is updated by this parser function to p