Re: [edk2-devel] [PATCH] Ps2KbdCtrller: Make wait for SUCCESS after BAT non-fatal

2022-10-24 Thread Ni, Ray
Can you update the PR to rebase to latest trunk?
Also please modify commit message to capture Reviewed-by tags.

From: devel@edk2.groups.io  On Behalf Of Sheng Lean Tan
Sent: Tuesday, October 25, 2022 10:49 AM
To: devel@edk2.groups.io; Tan, Lean Sheng 
Subject: Re: [edk2-devel] [PATCH] Ps2KbdCtrller: Make wait for SUCCESS after 
BAT non-fatal

Hi Ray please help to merge this if no concerns, thanks.

On Tue 11. Oct 2022 at 01:50, Sheng Lean Tan via groups.io 
mailto:9elements@groups.io>> wrote:

Thanks Ray for the review.
FYI Sean has also push the github PR here:

https://github.com/tianocore/edk2/pull/3389
--
Best Regards,
Lean Sheng Tan

[http://static.9elements.com/logo-signature.png]
9elements GmbH, Kortumstraße 19-21, 44787 Bochum, Germany
Email: sheng@9elements.com
Phone: +49 234 68 94 188
Mobile: +49 176 76 113842

Registered office: Bochum
Commercial register: Amtsgericht Bochum, HRB 17519
Management: Sebastian German, Eray Bazaar

Data protection information according to Art. 13 
GDPR



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




Re: [edk2-devel] [PATCH] Ps2KbdCtrller: Make wait for SUCCESS after BAT non-fatal

2022-10-24 Thread Sheng Lean Tan
Hi Ray please help to merge this if no concerns, thanks.

On Tue 11. Oct 2022 at 01:50, Sheng Lean Tan via groups.io  wrote:

> Thanks Ray for the review.
> FYI Sean has also push the github PR here:
>
> https://github.com/tianocore/edk2/pull/3389
> 
>
> --
Best Regards,
*Lean Sheng Tan*



9elements GmbH, Kortumstraße 19-21, 44787 Bochum, Germany
Email: sheng@9elements.com
Phone: *+49 234 68 94 188 <+492346894188>*
Mobile: *+49 176 76 113842 <+4917676113842>*

Registered office: Bochum
Commercial register: Amtsgericht Bochum, HRB 17519
Management: Sebastian German, Eray Bazaar

Data protection information according to Art. 13 GDPR



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




[edk2-devel] Event: TianoCore Bug Triage - APAC / NAMO - 10/25/2022 #cal-reminder

2022-10-24 Thread Group Notification
*Reminder: TianoCore Bug Triage - APAC / NAMO*

*When:*
10/25/2022
6:30pm to 7:30pm
(UTC-07:00) America/Los Angeles

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

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

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

*Description:*

TianoCore Bug Triage - APAC / NAMO

Hosted by Liming Gao



Microsoft Teams meeting

*Join on your computer or mobile app*

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

*Join with a video conferencing device*

te...@conf.intel.com

Video Conference ID: 116 062 094 0

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

*Or call in (audio only)*

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

Phone Conference ID: 774 638 21#

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

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


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




Re: [edk2-devel] 回复: [PATCH V4 00/10] Introduce Lazy-accept for Tdx guest

2022-10-24 Thread Min Xu
Hi, Liming
In Dionna's latest patch-sets the name of accept_all_unaccepted_memory has been 
changed to BZ3987_MEMORY_ACCEPTANCE_PROTOCOL.
https://edk2.groups.io/g/devel/message/95525 
https://edk2.groups.io/g/devel/message/95530

So now these 2 protocols are named as "BZ3987_MEMORY_ACCEPTANCE_PROTOCOL" and " 
EDKII_MEMORY_ACCEPT_PROTOCOL".
Do you think they have addressed your concern?

Thanks
Min

> -Original Message-
> From: Dionna Amalie Glaze 
> Sent: Friday, October 21, 2022 11:59 PM
> To: Xu, Min M 
> Cc: devel@edk2.groups.io; Gao, Liming ; Gao,
> Zhichao ; Ni, Ray ; Aktas, Erdem
> ; Gerd Hoffmann ; James
> Bottomley ; Yao, Jiewen ; Tom
> Lendacky ; Gao, Jiaqi ;
> Wang, Jian J ; Liu, Zhiguang
> ; Kinney, Michael D ;
> Ard Biesheuvel 
> Subject: Re: [edk2-devel] 回复: [PATCH V4 00/10] Introduce Lazy-accept for
> Tdx guest
> 
> > > Min:
> > >   I understand that they are for the different purpose and usage.
> > > But, their protocol name are very similar.
> > Yes. They do look very similar.
> >
> > >   If there is no better protocol name, I will also be fine.
> > Dionna, what's your thought?
> >
> 
> The accept_all_unaccepted_memory name came from Ard's suggestion on
> an earlier patch series where I was using a Pcd.
> We're talking about the name over on the spec bug
> https://bugzilla.tianocore.org/show_bug.cgi?id=3987#c26
> 
> I think that any name concerning unaccepted memory is going to look a little
> same-y to others, so it's going to be troublesome if we require that they all
> strongly differ in name. I'm not strongly attached to the name, I just want to
> be conservative about what the name implies about the expected overall
> behavior of the system when that has not actually been decided upon.
> 
> --
> -Dionna Glaze, PhD (she/her)


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




Re: [edk2-devel] [PATCH v1 1/2] DynamicTablesPkg: Define a SMBIOS Structure/Table type

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

Acked-by: Abner Chang 

> -Original Message-
> From: Sami Mujawar 
> Sent: Tuesday, October 18, 2022 11:34 PM
> To: devel@edk2.groups.io
> Cc: Sami Mujawar ; alexei.fedo...@arm.com;
> pierre.gond...@arm.com; gmahade...@nvidia.com; Chang, Abner
> ; jbra...@nvidia.com; ashishsin...@nvidia.com;
> nrami...@nvidia.com; wwat...@nvidia.com; matteo.carl...@arm.com;
> akanksha.ja...@arm.com; ben.adder...@arm.com; Samer.El-Haj-
> mahm...@arm.com; n...@arm.com
> Subject: [PATCH v1 1/2] DynamicTablesPkg: Define a SMBIOS Structure/Table
> type
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> SMBIOS Structure Types 0 through 127 (7Fh) are reserved for and defined by
> the SMBIOS specification. Types 128 through 256 (80h to FFh) are available
> for system and OEM-specific information.
> 
> Therefore, define a new type 'SMBIOS_TABLE_TYPE' that represents a
> SMBIOS structure type and include it in the definition of
> CM_STD_OBJ_SMBIOS_TABLE_INFO.
> 
> Signed-off-by: Sami Mujawar 
> Cc: Alexei Fedorov 
> Cc: Pierre Gondois 
> Cc: Girish Mahadevan 
> Cc: Jeff Brasen 
> Cc: Ashish Singhal 
> Cc: Nick Ramirez 
> Cc: William Watson 
> Cc: Abner Chang 
> Cc: Samer El-Haj-Mahmoud 
> ---
>  DynamicTablesPkg/Include/StandardNameSpaceObjects.h | 17
> +
>  1 file changed, 17 insertions(+)
> 
> diff --git a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
> b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
> index
> 8ec3238225abe4fc16a7337c29ecd655590b408f..c81efbc237779c305abc3c4dd0
> 7f6b705563e2a1 100644
> --- a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
> +++ b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
> @@ -40,6 +40,20 @@
>  **/
>  typedef UINTN CM_OBJECT_TOKEN;
> 
> +/**
> +  A type representing a SMBIOS structure/table type.
> +
> +  Types 0 through 127 (7Fh) are reserved for and defined by the  SMBIOS
> + specification.
> +  Types 128 through 256 (80h to FFh) are available for system and
> + OEM-specific information.
> +
> +  Note: This Dynamic SMBIOS table generation implementation defines
> +  TableType FFh as a NULL table which is used by the Dynamic
> +  SMBIOS table dispatcher to terminate the dependency sequence.
> +*/
> +typedef UINT8 SMBIOS_TABLE_TYPE;
> +
>  /** The ESTD_OBJECT_ID enum describes the Object IDs
>  in the Standard Namespace.
>  */
> @@ -127,6 +141,9 @@ typedef struct CmAStdObjAcpiTableInfo {
>to NULL.
>  */
>  typedef struct CmStdObjSmbiosTableInfo {
> +  /// SMBIOS Structure/Table Type
> +  SMBIOS_TABLE_TYPETableType;
> +
>/// The SMBIOS Table Generator ID
>SMBIOS_TABLE_GENERATOR_IDTableGeneratorId;
> 
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


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




Re: [edk2-devel] [PATCH v1 2/2] DynamicTablesPkg: Add SMBIOS table dispatcher

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



> -Original Message-
> From: Sami Mujawar 
> Sent: Tuesday, October 18, 2022 11:34 PM
> To: devel@edk2.groups.io
> Cc: Sami Mujawar ; alexei.fedo...@arm.com;
> pierre.gond...@arm.com; gmahade...@nvidia.com; Chang, Abner
> ; jbra...@nvidia.com; ashishsin...@nvidia.com;
> nrami...@nvidia.com; wwat...@nvidia.com; matteo.carl...@arm.com;
> akanksha.ja...@arm.com; ben.adder...@arm.com; Samer.El-Haj-
> mahm...@arm.com; n...@arm.com
> Subject: [PATCH v1 2/2] DynamicTablesPkg: Add SMBIOS table dispatcher
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Some SMBIOS structure/table fields have dependency on other SMBIOS
> structures/tables. These dependencies are established using handles
> pointing to the dependent tables.
> 
> A SMBIOS table handle can be obtained by either installing a SMBIOS table or
> by allocating a handle, which requires complex management to avoid any
> clashes.
> 
> Obtaining a SMBIOS handle by installation requires that the dependent table
> is installed before the parent SMBIOS table can be installed.
> Therefore, introduce a SMBIOS table dispatcher that walks the SMBIOS
> dependency list and schedules the dependent tables to be installed before
> the parent table is installed.
> 
> Signed-off-by: Sami Mujawar 
> Cc: Alexei Fedorov 
> Cc: Pierre Gondois 
> Cc: Girish Mahadevan 
> Cc: Jeff Brasen 
> Cc: Ashish Singhal 
> Cc: Nick Ramirez 
> Cc: William Watson 
> Cc: Abner Chang 
> Cc: Samer El-Haj-Mahmoud 
> ---
> 
> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManag
> erDxe.inf |   4 +-
> 
> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatch
> er.c| 304 
> 
> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatch
> er.h| 133 +
>  3 files changed, 440 insertions(+), 1 deletion(-)
> 
> diff --git
> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMan
> agerDxe.inf
> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMan
> agerDxe.inf
> index
> ad8b3d037c169ca848b5ea84fd1086b83f37876f..b09272d883c6f4f05eb03dcdab
> 3efeda92b2fbb6 100644
> ---
> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMan
> agerDxe.inf
> +++
> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMan
> age
> +++ rDxe.inf
> @@ -1,7 +1,7 @@
>  ## @file
>  # Module that drives the table generation and installation process.
>  #
> -#  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
> +#  Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent  ## @@ -22,6 +22,8 @@
> [Defines]
> 
>  [Sources]
>DynamicTableManagerDxe.c
> +  SmbiosTableDispatcher.c
> +  SmbiosTableDispatcher.h
> 
>  [Packages]
>MdePkg/MdePkg.dec
> diff --git
> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispat
> cher.c
> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispat
> cher.c
> new file mode 100644
> index
> ..88907fecdde5e36d40ac22cd4
> 86391abbb853e38
> --- /dev/null
> +++
> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispat
> c
> +++ her.c
> @@ -0,0 +1,304 @@
> +/** @file
> +  Dynamic Smbios Table Dispatcher
> +
> +  Copyright (c) 2022, Arm Limited. All rights reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +extern
> +EFI_STATUS
> +EFIAPI
> +BuildAndInstallSmbiosTable (
> +  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST
> +TableFactoryProtocol,
> +  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST
> CfgMgrProtocol,
> +  IN   EFI_SMBIOS_PROTOCOL   *SmbiosProtocol,
> +  IN   CM_STD_OBJ_SMBIOS_TABLE_INFO  *CONST  SmbiosTableInfo
> +  );
You can move above external reference to the header file.

> +
> +#if !defined (MDEPKG_NDEBUG)
> +
> +/**
> +  A string table describing the SMBIOS dispatcher states.
> +*/
> +STATIC
> +CONST CHAR8  *SmbiosTableStateTxt[] = {
> +  "StUnknown",
> +  "StNotPresent",
> +  "StPresent",
> +  "StDispatched"
> +};
> +
> +#endif
You can merge above #if block with below #if !defined (MDEPKG_NDEBUG).

Other looks good to me.
Abner
> +
> +/**
> +  The SMBIOS dispatcher state table.
> +
> +  The SMBIOS dispatcher state table is used to establish the dependency
> +  order in which the SMBIOS tables are installed. This allows the
> +SMBIOS
> +  dispatcher to dispatch the dependent tables for installation before
> +the
> +  parent table is installed.
> +  The SMBIOS_TABLE_DISPATCHER.Dependency[] field is used to establish
> +the
> +  dependency list.
> +  Elements in the Dependency list are resolved by increasing index.
> +However,
> +  all orders are equivalent as:
> +  - the Parent SMBIOS table will only be installed once all dependencies
> +have been sati

Re: [edk2-devel] [edk2-platforms][PATCH v2 0/3] Silicon/Intel: Fix invalid DEBUG() macros

2022-10-24 Thread Nate DeSimone
The series has been pushed as ba4318a~..8ea6ec3

Thanks,
Nate

-Original Message-
From: mikub...@linux.microsoft.com  
Sent: Wednesday, October 12, 2022 7:16 AM
To: devel@edk2.groups.io
Cc: Chiu, Chasel ; Luo, Heng ; 
Desimone, Nathaniel L ; Chaganty, Rangasai V 

Subject: [edk2-platforms][PATCH v2 0/3] Silicon/Intel: Fix invalid DEBUG() 
macros

From: Michael Kubacki 

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

Fixes several debug macros in Silicon/Intel that have a mismatched number of 
print specifiers to arguments.

The original author's intention is not always 100% obvious. Though, this series 
is relatively straightforward.

v2 changes:
  - Applied debug macro suggestions in Nate's feedback

Cc: Chasel Chiu 
Cc: Heng Luo 
Cc: Nate DeSimone 
Cc: Sai Chaganty 
Signed-off-by: Michael Kubacki 

Michael Kubacki (3):
  CoffeelakeSiliconPkg: Fix invalid debug macros
  KabylakeSiliconPkg: Fix invalid debug macros
  TigerlakeSiliconPkg: Fix invalid debug macros

 
Silicon/Intel/CoffeelakeSiliconPkg/Cpu/Library/PeiCpuPolicyLib/CpuPrintPolicy.c 
  |  2 +-
 Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/PeiDxeSmmGbeMdiLib/GbeMdiLib.c  
   |  2 +-
 Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/PeiOcWdtLib/PeiOcWdtLib.c   
   |  4 ++--
 
Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/Private/PeiDxeSmmPchPciExpressHelpersLib/PchPciExpressHelpersLibrary.c
 |  2 +-
 Silicon/Intel/KabylakeSiliconPkg/Cpu/Library/PeiCpuPolicyLib/CpuPrintPolicy.c  
   | 19 +++
 Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiOcWdtLib/PeiOcWdtLib.c 
   |  4 ++--
 
Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Gbe/LibraryPrivate/PeiDxeSmmGbeMdiLib/GbeMdiLib.c
   |  2 +-
 
Silicon/Intel/TigerlakeSiliconPkg/IpBlock/PcieRp/LibraryPrivate/PciExpressHelpersLibrary/PciExpressHelpersLibrary.c
   |  2 +-
 8 files changed, 20 insertions(+), 17 deletions(-)

--
2.28.0.windows.1



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




Re: [edk2-devel] [edk2-platforms][PATCH v2 0/3] Silicon/Intel: Fix invalid DEBUG() macros

2022-10-24 Thread Nate DeSimone
For the series...

Reviewed-by: Nate DeSimone 

-Original Message-
From: mikub...@linux.microsoft.com  
Sent: Wednesday, October 12, 2022 7:16 AM
To: devel@edk2.groups.io
Cc: Chiu, Chasel ; Luo, Heng ; 
Desimone, Nathaniel L ; Chaganty, Rangasai V 

Subject: [edk2-platforms][PATCH v2 0/3] Silicon/Intel: Fix invalid DEBUG() 
macros

From: Michael Kubacki 

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

Fixes several debug macros in Silicon/Intel that have a mismatched number of 
print specifiers to arguments.

The original author's intention is not always 100% obvious. Though, this series 
is relatively straightforward.

v2 changes:
  - Applied debug macro suggestions in Nate's feedback

Cc: Chasel Chiu 
Cc: Heng Luo 
Cc: Nate DeSimone 
Cc: Sai Chaganty 
Signed-off-by: Michael Kubacki 

Michael Kubacki (3):
  CoffeelakeSiliconPkg: Fix invalid debug macros
  KabylakeSiliconPkg: Fix invalid debug macros
  TigerlakeSiliconPkg: Fix invalid debug macros

 
Silicon/Intel/CoffeelakeSiliconPkg/Cpu/Library/PeiCpuPolicyLib/CpuPrintPolicy.c 
  |  2 +-
 Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/PeiDxeSmmGbeMdiLib/GbeMdiLib.c  
   |  2 +-
 Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/PeiOcWdtLib/PeiOcWdtLib.c   
   |  4 ++--
 
Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/Private/PeiDxeSmmPchPciExpressHelpersLib/PchPciExpressHelpersLibrary.c
 |  2 +-
 Silicon/Intel/KabylakeSiliconPkg/Cpu/Library/PeiCpuPolicyLib/CpuPrintPolicy.c  
   | 19 +++
 Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiOcWdtLib/PeiOcWdtLib.c 
   |  4 ++--
 
Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Gbe/LibraryPrivate/PeiDxeSmmGbeMdiLib/GbeMdiLib.c
   |  2 +-
 
Silicon/Intel/TigerlakeSiliconPkg/IpBlock/PcieRp/LibraryPrivate/PciExpressHelpersLibrary/PciExpressHelpersLibrary.c
   |  2 +-
 8 files changed, 20 insertions(+), 17 deletions(-)

--
2.28.0.windows.1



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




Re: [edk2-devel] [PATCH] IntelFsp2Pkg: FSP should support input UPD as NULL.

2022-10-24 Thread Nate DeSimone
Reviewed-by: Nate DeSimone 

-Original Message-
From: Chiu, Chasel  
Sent: Sunday, October 23, 2022 9:05 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel ; Desimone, Nathaniel L 
; Zeng, Star 
Subject: [PATCH] IntelFsp2Pkg: FSP should support input UPD as NULL.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4114
FSP specification supports input UPD as NULL cases which FSP will use built-in 
UPD region instead.
FSP should not return INVALID_PARAMETER in such cases.

Cc: Nate DeSimone 
Cc: Star Zeng 
Signed-off-by: Chasel Chiu 
---
 IntelFsp2Pkg/FspSecCore/SecFspApiChk.c | 11 +--
 IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm |  8   
IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm  |  7 ---
 3 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c 
b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
index a44fbf2a50..bfbdf70083 100644
--- a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
+++ b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
@@ -44,6 +44,8 @@ FspApiCallingCheck (
 // if (((UINTN)FspData != MAX_ADDRESS) && ((UINTN)FspData != 
MAX_UINT32)) {   Status = EFI_UNSUPPORTED;+} else if (ApiParam == NULL) 
{+  Status = EFI_SUCCESS; } else if (EFI_ERROR (FspUpdSignatureCheck 
(ApiIdx, ApiParam))) {   Status = EFI_INVALID_PARAMETER; }@@ -67,9 
+69,12 @@ FspApiCallingCheck (
 } else {   if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {  
   Status = EFI_UNSUPPORTED;-  } else if (EFI_ERROR (FspUpdSignatureCheck 
(FspSiliconInitApiIndex, ApiParam))) {-Status = EFI_INVALID_PARAMETER;  
 } else if (ApiIdx == FspSiliconInitApiIndex) {+if (ApiParam == 
NULL) {+  Status = EFI_SUCCESS;+} else if (EFI_ERROR 
(FspUpdSignatureCheck (FspSiliconInitApiIndex, ApiParam))) {+  Status = 
EFI_INVALID_PARAMETER;+} // // Reset MultiPhase 
NumberOfPhases to zero //@@ -89,6 +94,8 @@ FspApiCallingCheck (
 } else {   if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {  
   Status = EFI_UNSUPPORTED;+  } else if (ApiParam == NULL) {+
Status = EFI_SUCCESS;   } else if (EFI_ERROR (FspUpdSignatureCheck 
(FspSmmInitApiIndex, ApiParam))) { Status = EFI_INVALID_PARAMETER;  
 }diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm 
b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm
index 61030a843b..52e1ff6f1f 100644
--- a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm
+++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm
@@ -555,14 +555,6 @@ ASM_PFX(TempRamInitApi):
   SAVE_EAX   SAVE_EDX -  ;-  ; Check Parameter-  ;-  mov   eax, dword [esp 
+ 4]-  cmp   eax, 0-  mov   eax, 8002h-  jzTempRamInitExit- 
  ;   ; Sec Platform Init   ;diff --git 
a/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm 
b/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm
index 7dd89c531a..23bb2b0481 100644
--- a/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm
+++ b/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm
@@ -441,13 +441,6 @@ ASM_PFX(TempRamInitApi):
   orrax, rdx   SAVE_TS   rax -  ;-  ; Check Parameter-  ;-  cmp   
rcx, 0-  mov   rcx, 08002h-  jzTempRamInitExit-   ;   ; 
Sec Platform Init   ;-- 
2.35.0.windows.1



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




[edk2-devel] Now: Tools, CI, Code base construction meeting series - 10/24/2022 #cal-notice

2022-10-24 Thread Group Notification
*Tools, CI, Code base construction meeting series*

*When:*
10/24/2022
4:30pm to 5:30pm
(UTC-07:00) America/Los Angeles

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

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

*Description:*

TianoCore community,

Microsoft and Intel will be hosting a series of open meetings to discuss build, 
CI, tools, and other related topics. If you are interested, have ideas/opinions 
please join us. These meetings will be Monday 4:30pm Pacific Time on Microsoft 
Teams.

MS Teams Link in following discussion: * 
https://github.com/tianocore/edk2/discussions/2614

Anyone is welcome to join.

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

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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95539): https://edk2.groups.io/g/devel/message/95539
Mute This Topic: https://groups.io/mt/94547863/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] [edk2-libc Patch 0/1] Py3 UEFI help built-in function issue fix

2022-10-24 Thread Ajay Kadapathri
This patch fixes help built-in function issue which reported by following
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4107

Ajay Kadapathri (1):
  Python/Python3.6.8: help built-in function issue fix

 .../Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h   | 5 +
 1 file changed, 5 insertions(+)

-- 
2.37.1.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] Python/Python3.6.8: help built-in function issue fix

2022-10-24 Thread Ajay Kadapathri
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4107

Observed that help built-in function in Python UEFI interpreter is
not giving the full help text information of python constructs such
as functions, objects , class and etc.

This patch request fixes this issue, once this patch is applied
We can get full text help information of python constructs

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Ajay Kadapathri 
---
 .../Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h   | 5 +
 1 file changed, 5 insertions(+)

diff --git 
a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h 
b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h
index c447614..f1cb309 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h
@@ -1155,8 +1155,13 @@
 /* Define if WINDOW in curses.h offers a field _flags. */
 #undef WINDOW_HAS_FLAGS
 
+#ifdef UEFI_C_SOURCE
+/* Define if you want documentation strings in extension modules */
+#define WITH_DOC_STRINGS 1
+#else
 /* Define if you want documentation strings in extension modules */
 #undef WITH_DOC_STRINGS
+#endif
 
 /* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic
linker (dyld) instead of the old-style (NextStep) dynamic linker (rld).
-- 
2.37.1.windows.1



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




Re: [edk2-devel] [PATCH v7 0/7] Add safe unaccepted memory behavior

2022-10-24 Thread aik
Hey!

Sorry if this was asked. I was wondering if this patchset is in some git repo 
which I pull from as I struggle to get a buildable tree by applying this 
patchset to whatever I can find.

I tried https://github.com/deeglaze/edk2.git ( 
https://github.com/deeglaze/edk2.git ) enable_umv7 but it does not build 
(missing ExitBootServicesCallback.h and PrePiHob.h).
I tried rebasing it on top of https://github.com/mxu9/edk2.git 
lazyaccept.v1/2/3/4 but it seems only v1 kinda works but see the above and 
other versions have some reworks (EFI_RESOURCE_MEMORY_UNACCEPTED vs. 
BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED.

Thanks!


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




[edk2-devel] [PATCH v2 1/1] MdePkg/BaseLib: Fix out-of-bounds reads in SafeString

2022-10-24 Thread Pedro Falcato
OpenCore folks established an ASAN-equipped project to fuzz Ext4Dxe,
which was able to catch these (mostly harmless) issues.

Signed-off-by: Pedro Falcato 
Cc: Vitaly Cheptsov 
Cc: Marvin Häuser 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
---
 MdePkg/Library/BaseLib/SafeString.c | 24 
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Library/BaseLib/SafeString.c 
b/MdePkg/Library/BaseLib/SafeString.c
index f338a32a3a41..77a2585ad56d 100644
--- a/MdePkg/Library/BaseLib/SafeString.c
+++ b/MdePkg/Library/BaseLib/SafeString.c
@@ -863,6 +863,9 @@ StrHexToUintnS (
   OUT   UINTN   *Data
   )
 {
+  BOOLEAN  FoundLeadingZero;
+
+  FoundLeadingZero = FALSE;
   ASSERT (((UINTN)String & BIT0) == 0);
 
   //
@@ -893,11 +896,12 @@ StrHexToUintnS (
   // Ignore leading Zeros after the spaces
   //
   while (*String == L'0') {
+FoundLeadingZero = TRUE;
 String++;
   }
 
   if (CharToUpper (*String) == L'X') {
-if (*(String - 1) != L'0') {
+if (!FoundLeadingZero) {
   *Data = 0;
   return RETURN_SUCCESS;
 }
@@ -992,6 +996,9 @@ StrHexToUint64S (
   OUT   UINT64  *Data
   )
 {
+  BOOLEAN  FoundLeadingZero;
+
+  FoundLeadingZero = FALSE;
   ASSERT (((UINTN)String & BIT0) == 0);
 
   //
@@ -1022,11 +1029,12 @@ StrHexToUint64S (
   // Ignore leading Zeros after the spaces
   //
   while (*String == L'0') {
+FoundLeadingZero = TRUE;
 String++;
   }
 
   if (CharToUpper (*String) == L'X') {
-if (*(String - 1) != L'0') {
+if (!FoundLeadingZero) {
   *Data = 0;
   return RETURN_SUCCESS;
 }
@@ -2393,6 +2401,9 @@ AsciiStrHexToUintnS (
   OUT   UINTN  *Data
   )
 {
+  BOOLEAN  FoundLeadingZero;
+
+  FoundLeadingZero = FALSE;
   //
   // 1. Neither String nor Data shall be a null pointer.
   //
@@ -2421,11 +2432,12 @@ AsciiStrHexToUintnS (
   // Ignore leading Zeros after the spaces
   //
   while (*String == '0') {
+FoundLeadingZero = TRUE;
 String++;
   }
 
   if (AsciiCharToUpper (*String) == 'X') {
-if (*(String - 1) != '0') {
+if (!FoundLeadingZero) {
   *Data = 0;
   return RETURN_SUCCESS;
 }
@@ -2517,6 +2529,9 @@ AsciiStrHexToUint64S (
   OUT   UINT64  *Data
   )
 {
+  BOOLEAN  FoundLeadingZero;
+
+  FoundLeadingZero = FALSE;
   //
   // 1. Neither String nor Data shall be a null pointer.
   //
@@ -2545,11 +2560,12 @@ AsciiStrHexToUint64S (
   // Ignore leading Zeros after the spaces
   //
   while (*String == '0') {
+FoundLeadingZero = TRUE;
 String++;
   }
 
   if (AsciiCharToUpper (*String) == 'X') {
-if (*(String - 1) != '0') {
+if (!FoundLeadingZero) {
   *Data = 0;
   return RETURN_SUCCESS;
 }
-- 
2.38.1



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




[edk2-devel] Event: Tools, CI, Code base construction meeting series - 10/24/2022 #cal-reminder

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

*When:*
10/24/2022
4:30pm to 5:30pm
(UTC-07:00) America/Los Angeles

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

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

*Description:*

TianoCore community,

Microsoft and Intel will be hosting a series of open meetings to discuss build, 
CI, tools, and other related topics. If you are interested, have ideas/opinions 
please join us. These meetings will be Monday 4:30pm Pacific Time on Microsoft 
Teams.

MS Teams Link in following discussion: * 
https://github.com/tianocore/edk2/discussions/2614

Anyone is welcome to join.

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

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


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




[edk2-devel] [PATCH 1/1] MdePkg/BaseLib: Fix out-of-bounds reads in SafeString

2022-10-24 Thread Pedro Falcato
OpenCore folks established an ASAN-equipped project to fuzz Ext4Dxe,
which was able to catch these (mostly harmless) issues.

Signed-off-by: Pedro Falcato 
Cc: Vitaly Cheptsov 
Cc: Marvin Häuser 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
---
 MdePkg/Library/BaseLib/SafeString.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Library/BaseLib/SafeString.c 
b/MdePkg/Library/BaseLib/SafeString.c
index f338a32a3a41..9bf86d32e1d6 100644
--- a/MdePkg/Library/BaseLib/SafeString.c
+++ b/MdePkg/Library/BaseLib/SafeString.c
@@ -863,6 +863,9 @@ StrHexToUintnS (
   OUT   UINTN   *Data
   )
 {
+  CONST CHAR16  *StartString;
+
+  StartString = String;
   ASSERT (((UINTN)String & BIT0) == 0);
 
   //
@@ -897,7 +900,7 @@ StrHexToUintnS (
   }
 
   if (CharToUpper (*String) == L'X') {
-if (*(String - 1) != L'0') {
+if ((String != StartString) && (*(String - 1) != L'0')) {
   *Data = 0;
   return RETURN_SUCCESS;
 }
@@ -992,6 +995,9 @@ StrHexToUint64S (
   OUT   UINT64  *Data
   )
 {
+  CONST CHAR16  *StartString;
+
+  StartString = String;
   ASSERT (((UINTN)String & BIT0) == 0);
 
   //
@@ -1026,7 +1032,7 @@ StrHexToUint64S (
   }
 
   if (CharToUpper (*String) == L'X') {
-if (*(String - 1) != L'0') {
+if ((String != StartString) && (*(String - 1) != L'0')) {
   *Data = 0;
   return RETURN_SUCCESS;
 }
@@ -2393,6 +2399,9 @@ AsciiStrHexToUintnS (
   OUT   UINTN  *Data
   )
 {
+  CONST CHAR8  *StartString;
+
+  StartString = String;
   //
   // 1. Neither String nor Data shall be a null pointer.
   //
@@ -2425,7 +2434,7 @@ AsciiStrHexToUintnS (
   }
 
   if (AsciiCharToUpper (*String) == 'X') {
-if (*(String - 1) != '0') {
+if ((String != StartString) && (*(String - 1) != '0')) {
   *Data = 0;
   return RETURN_SUCCESS;
 }
@@ -2517,6 +2526,9 @@ AsciiStrHexToUint64S (
   OUT   UINT64  *Data
   )
 {
+  CONST CHAR8  *StartString;
+
+  StartString = String;
   //
   // 1. Neither String nor Data shall be a null pointer.
   //
@@ -2549,7 +2561,7 @@ AsciiStrHexToUint64S (
   }
 
   if (AsciiCharToUpper (*String) == 'X') {
-if (*(String - 1) != '0') {
+if ((String != StartString) && (*(String - 1) != '0')) {
   *Data = 0;
   return RETURN_SUCCESS;
 }
-- 
2.38.1



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




[edk2-devel] [PATCH v8 3/7] MdeModulePkg: Notify BeforeExitBootServices in CoreExitBootServices

2022-10-24 Thread Dionna Glaze via groups.io
Location of notification is has been specified in UEFI v2.9.

Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Cc: Ard Biesheuvel 
Cc: "Min M. Xu" 
Cc: Andrew Fish 
Cc: "Michael D. Kinney" 
Cc: Ray Ni 

Signed-off-by: Dionna Glaze 
---
 MdeModulePkg/Core/Dxe/DxeMain.inf   | 1 +
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 6 ++
 2 files changed, 7 insertions(+)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf 
b/MdeModulePkg/Core/Dxe/DxeMain.inf
index e4bca89577..35d5bf0dee 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -100,6 +100,7 @@
   gEfiEventVirtualAddressChangeGuid ## CONSUMES ## 
Event
   ## CONSUMES   ## Event
   ## PRODUCES   ## Event
+  gEfiEventBeforeExitBootServicesGuid
   gEfiEventExitBootServicesGuid
   gEfiHobMemoryAllocModuleGuid  ## SOMETIMES_CONSUMES   ## HOB
   gEfiFirmwareFileSystem2Guid   ## CONSUMES ## 
GUID # Used to compare with FV's file system guid and get the FV's file system 
format
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c 
b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
index 5733f0c8ec..4683016ed7 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
@@ -763,6 +763,12 @@ CoreExitBootServices (
 {
   EFI_STATUS  Status;
 
+  //
+  // Notify other drivers of their last chance to use boot services
+  // before the memory map is terminated.
+  //
+  CoreNotifySignalList (&gEfiEventBeforeExitBootServicesGuid);
+
   //
   // Disable Timer
   //
-- 
2.38.0.135.g90850a2211-goog



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




[edk2-devel] [PATCH v8 7/7] OvmfPkg/PlatformPei: SEV-SNP make >=4GB unaccepted

2022-10-24 Thread Dionna Glaze via groups.io
Instead of eagerly accepting all memory in PEI, only accept memory under
the 4GB address. This allows a loaded image to use the
MEMORY_ACCEPTANCE_PROTOCOL to disable the accept behavior and indicate
that it can interpret the memory type accordingly.

This classification is safe since ExitBootServices will accept and
reclassify the memory as conventional if the disable protocol is not
used.

Cc: Ard Biescheuvel 
Cc: "Min M. Xu" 
Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Tom Lendacky 
Cc: Jiewen Yao 
Cc: Erdem Aktas 

Signed-off-by: Dionna Glaze 
---
 OvmfPkg/PlatformPei/AmdSev.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c
index 385562b44c..4cb6da4437 100644
--- a/OvmfPkg/PlatformPei/AmdSev.c
+++ b/OvmfPkg/PlatformPei/AmdSev.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -63,6 +64,10 @@ AmdSevSnpInitialize (
   for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB 
(Hob)) {
 if ((Hob.Raw != NULL) && (GET_HOB_TYPE (Hob) == 
EFI_HOB_TYPE_RESOURCE_DESCRIPTOR)) {
   ResourceHob = Hob.ResourceDescriptor;
+  if (ResourceHob->PhysicalStart >= SIZE_4GB) {
+ResourceHob->ResourceType = BZ3937_RESOURCE_MEMORY_UNACCEPTED;
+continue;
+  }
 
   if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {
 MemEncryptSevSnpPreValidateSystemRam (
-- 
2.38.0.135.g90850a2211-goog



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




[edk2-devel] [PATCH v8 6/7] OvmfPkg: Implement AcceptAllUnacceptedMemory in CocoDxe

2022-10-24 Thread Dionna Glaze via groups.io
This protocol implementation disables the accept-all-memory behavior
of the BeforeExitBootServices event this driver adds.

Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Cc: Ard Biesheuvel 
Cc: "Min M. Xu" 
Cc: Andrew Fish 
Cc: "Michael D. Kinney" 

Signed-off-by: Dionna Glaze 
---
 OvmfPkg/CocoDxe/CocoDxe.c   | 28 
 OvmfPkg/CocoDxe/CocoDxe.inf |  1 +
 2 files changed, 29 insertions(+)

diff --git a/OvmfPkg/CocoDxe/CocoDxe.c b/OvmfPkg/CocoDxe/CocoDxe.c
index 98874e6cfc..14fbcf60d7 100644
--- a/OvmfPkg/CocoDxe/CocoDxe.c
+++ b/OvmfPkg/CocoDxe/CocoDxe.c
@@ -17,11 +17,14 @@
 #include 
 #include 
 #include 
+#include 
 
 STATIC BOOLEAN  mAcceptAllMemoryAtEBS = TRUE;
 
 STATIC EFI_EVENT  mAcceptAllMemoryEvent = NULL;
 
+STATIC EFI_HANDLE  mCocoDxeHandle = NULL;
+
 STATIC
 EFI_STATUS
 AcceptAllMemory (
@@ -110,6 +113,21 @@ ResolveUnacceptedMemory (
   ASSERT_EFI_ERROR (Status);
 }
 
+STATIC
+EFI_STATUS
+EFIAPI
+AllowUnacceptedMemory (
+  IN  BZ3987_MEMORY_ACCEPTANCE_PROTOCOL  *This
+  )
+{
+  mAcceptAllMemoryAtEBS = FALSE;
+  return EFI_SUCCESS;
+}
+
+STATIC
+BZ3987_MEMORY_ACCEPTANCE_PROTOCOL
+  mMemoryAcceptanceProtocol = { AllowUnacceptedMemory };
+
 EFI_STATUS
 EFIAPI
 CocoDxeEntryPoint (
@@ -142,5 +160,15 @@ CocoDxeEntryPoint (
 DEBUG ((DEBUG_ERROR, "AllowUnacceptedMemory event creation for 
EventBeforeExitBootServices failed.\n"));
   }
 
+  Status = gBS->InstallProtocolInterface (
+  &mCocoDxeHandle,
+  &gBz3987MemoryAcceptanceProtocolGuid,
+  EFI_NATIVE_INTERFACE,
+  &mMemoryAcceptanceProtocol
+  );
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "Install Bz3987MemoryAcceptanceProtocol failed.\n"));
+  }
+
   return EFI_SUCCESS;
 }
diff --git a/OvmfPkg/CocoDxe/CocoDxe.inf b/OvmfPkg/CocoDxe/CocoDxe.inf
index 8d4452e94d..05c2651a89 100644
--- a/OvmfPkg/CocoDxe/CocoDxe.inf
+++ b/OvmfPkg/CocoDxe/CocoDxe.inf
@@ -42,4 +42,5 @@
   gEfiEventBeforeExitBootServicesGuid
 
 [Protocols]
+  gBz3987MemoryAcceptanceProtocolGuid
   gEdkiiMemoryAcceptProtocolGuid
-- 
2.38.0.135.g90850a2211-goog



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




[edk2-devel] [PATCH v8 5/7] MdePkg: Introduce the MemoryAcceptance protocol

2022-10-24 Thread Dionna Glaze via groups.io
The default behavior for unaccepted memory is to accept all memory
when ExitBootServices is called. An OS loader can use this protocol to
disable this behavior to assume responsibility for memory acceptance and
to affirm that the OS can handle the unaccepted memory type.

This is a candidate for standardization.

Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Cc: Ard Biesheuvel 
Cc: "Min M. Xu" 
Cc: Andrew Fish 
Cc: "Michael D. Kinney" 

Signed-off-by: Dionna Glaze 
---
 MdePkg/Include/Protocol/MemoryAcceptance.h | 40 
 MdePkg/MdePkg.dec  |  3 ++
 2 files changed, 43 insertions(+)

diff --git a/MdePkg/Include/Protocol/MemoryAcceptance.h 
b/MdePkg/Include/Protocol/MemoryAcceptance.h
new file mode 100644
index 00..0b305b016f
--- /dev/null
+++ b/MdePkg/Include/Protocol/MemoryAcceptance.h
@@ -0,0 +1,40 @@
+/** @file
+  The file provides the protocol that disables the behavior that all memory
+  gets accepted at ExitBootServices(). This protocol is only meant to be called
+  by the OS loader, and not EDK2 itself.
+
+  Copyright (c) 2022, Google LLC. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef MEMORY_ACCEPTANCE_H_
+#define MEMORY_ACCEPTANCE_H_
+
+#define BZ3987_MEMORY_ACCEPTANCE_PROTOCOL_GUID \
+  {0xc5a010fe, \
+   0x38a7, \
+   0x4531, \
+   {0x8a, 0x4a, 0x05, 0x00, 0xd2, 0xfd, 0x16, 0x49}}
+
+typedef struct _BZ3987_MEMORY_ACCEPTANCE_PROTOCOL 
BZ3987_MEMORY_ACCEPTANCE_PROTOCOL;
+
+/**
+  @param This A pointer to a BZ3987_MEMORY_ACCEPTANCE_PROTOCOL.
+**/
+typedef
+  EFI_STATUS
+(EFIAPI *BZ3987_ALLOW_UNACCEPTED_MEMORY)(
+  IN  BZ3987_MEMORY_ACCEPTANCE_PROTOCOL  *This
+  );
+
+///
+/// The BZ3987_MEMORY_ACCEPTANCE_PROTOCOL allows the OS loader to
+/// indicate to EDK2 that ExitBootServices should not accept all memory.
+///
+struct _BZ3987_MEMORY_ACCEPTANCE_PROTOCOL {
+  BZ3987_ALLOW_UNACCEPTED_MEMORYAllowUnacceptedMemory;
+};
+
+extern EFI_GUID  gBz3987MemoryAcceptanceProtocolGuid;
+
+#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 359a85ea10..5c639c1b98 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -1022,6 +1022,9 @@
   gEfiPeiDelayedDispatchPpiGuid  = { 0x869c711d, 0x649c, 0x44fe, { 0x8b, 0x9e, 
0x2c, 0xbb, 0x29, 0x11, 0xc3, 0xe6 }}
 
 [Protocols]
+  ## Include/Protocol/Bz3987MemoryAcceptance.h
+  gBz3987MemoryAcceptanceProtocolGuid = { 0xc5a010fe, 0x38a7, 0x4531, {0x8a, 
0x4a, 0x05, 0x00, 0xd2, 0xfd, 0x16, 0x49 }}
+
   ## Include/Protocol/MemoryAccept.h
   gEdkiiMemoryAcceptProtocolGuid = { 0x38c74800, 0x5590, 0x4db4, { 0xa0, 0xf3, 
0x67, 0x5d, 0x9b, 0x8e, 0x80, 0x26 }}
 
-- 
2.38.0.135.g90850a2211-goog



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




[edk2-devel] [PATCH v8 4/7] OvmfPkg: Introduce CocoDxe driver

2022-10-24 Thread Dionna Glaze via groups.io
This driver is meant as a join point for all Confidential Compute
technologies to put shared behavior that doesn't belong anywhere else.

The first behavior added here is to accept all unaccepted memory at
ExitBootServices if the behavior is not disabled. This allows safe
upgrades for OS loaders to affirm their support for the unaccepted
memory type.

Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Cc: Ard Biesheuvel 
Cc: "Min M. Xu" 
Cc: Andrew Fish 
Cc: "Michael D. Kinney" 

Signed-off-by: Dionna Glaze 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc |   1 +
 OvmfPkg/AmdSev/AmdSevX64.fdf |   1 +
 OvmfPkg/CocoDxe/CocoDxe.c| 146 
 OvmfPkg/CocoDxe/CocoDxe.inf  |  45 ++
 OvmfPkg/IntelTdx/IntelTdxX64.dsc |   1 +
 OvmfPkg/IntelTdx/IntelTdxX64.fdf |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc   |   1 +
 OvmfPkg/OvmfPkgIa32X64.fdf   |   1 +
 OvmfPkg/OvmfPkgX64.dsc   |   1 +
 OvmfPkg/OvmfPkgX64.fdf   |   1 +
 10 files changed, 199 insertions(+)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index 90e8a213ef..ad6b73ca4a 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -747,6 +747,7 @@
 
 PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
   }
+  OvmfPkg/CocoDxe/CocoDxe.inf
   OvmfPkg/IoMmuDxe/IoMmuDxe.inf
 
   #
diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf
index 4658e1d30e..3717ec9094 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.fdf
+++ b/OvmfPkg/AmdSev/AmdSevX64.fdf
@@ -302,6 +302,7 @@ INF  OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf
 INF  OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
 INF  OvmfPkg/PlatformDxe/Platform.inf
 INF  OvmfPkg/AmdSevDxe/AmdSevDxe.inf
+INF  OvmfPkg/CocoDxe/CocoDxe.inf
 INF  OvmfPkg/IoMmuDxe/IoMmuDxe.inf
 
 
diff --git a/OvmfPkg/CocoDxe/CocoDxe.c b/OvmfPkg/CocoDxe/CocoDxe.c
new file mode 100644
index 00..98874e6cfc
--- /dev/null
+++ b/OvmfPkg/CocoDxe/CocoDxe.c
@@ -0,0 +1,146 @@
+/** @file
+
+  Confidential Compute Dxe driver. This driver installs protocols that are
+  generic over confidential compute techonology.
+
+  Copyright (c) 2022, Google LLC. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+STATIC BOOLEAN  mAcceptAllMemoryAtEBS = TRUE;
+
+STATIC EFI_EVENT  mAcceptAllMemoryEvent = NULL;
+
+STATIC
+EFI_STATUS
+AcceptAllMemory (
+  IN EDKII_MEMORY_ACCEPT_PROTOCOL  *AcceptMemory
+  )
+{
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR  *AllDescMap;
+  UINTNNumEntries;
+  UINTNIndex;
+  EFI_STATUS   Status;
+
+  DEBUG ((DEBUG_INFO, "Accepting all memory\n"));
+
+  /*
+   * Get a copy of the memory space map to iterate over while
+   * changing the map.
+   */
+  Status = gDS->GetMemorySpaceMap (&NumEntries, &AllDescMap);
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  for (Index = 0; Index < NumEntries; Index++) {
+CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR  *Desc;
+
+Desc = &AllDescMap[Index];
+if (Desc->GcdMemoryType != EfiGcdMemoryTypeUnaccepted) {
+  continue;
+}
+
+Status = AcceptMemory->AcceptMemory (
+ AcceptMemory,
+ Desc->BaseAddress,
+ Desc->Length
+ );
+if (EFI_ERROR (Status)) {
+  break;
+}
+
+Status = gDS->RemoveMemorySpace (Desc->BaseAddress, Desc->Length);
+if (EFI_ERROR (Status)) {
+  break;
+}
+
+Status = gDS->AddMemorySpace (
+EfiGcdMemoryTypeSystemMemory,
+Desc->BaseAddress,
+Desc->Length,
+EFI_MEMORY_CPU_CRYPTO | EFI_MEMORY_XP | EFI_MEMORY_RO | 
EFI_MEMORY_RP
+);
+if (EFI_ERROR (Status)) {
+  break;
+}
+  }
+
+  gBS->FreePool (AllDescMap);
+  return Status;
+}
+
+VOID
+EFIAPI
+ResolveUnacceptedMemory (
+  IN EFI_EVENT  Event,
+  IN VOID   *Context
+  )
+{
+  EDKII_MEMORY_ACCEPT_PROTOCOL  *AcceptMemory;
+  EFI_STATUSStatus;
+
+  if (!mAcceptAllMemoryAtEBS) {
+return;
+  }
+
+  Status = gBS->LocateProtocol (
+  &gEdkiiMemoryAcceptProtocolGuid,
+  NULL,
+  (VOID **)&AcceptMemory
+  );
+  if (Status == EFI_NOT_FOUND) {
+return;
+  }
+
+  ASSERT_EFI_ERROR (Status);
+
+  Status = AcceptAllMemory (AcceptMemory);
+  ASSERT_EFI_ERROR (Status);
+}
+
+EFI_STATUS
+EFIAPI
+CocoDxeEntryPoint (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+
+  //
+  // Do nothing when confidential compute technologies that require memory
+  // acceptance are not enabled.
+  //
+  if (!MemEncryptSevSnpIsEnabled () &&
+  !MemEncryptTdxIsEnabled ())
+  {
+return EFI_UNSUPPORTED;
+  }
+
+  Status = gBS->CreateEventEx (
+   

[edk2-devel] [PATCH v8 2/7] MdePkg: Add EFI_EVENT_BEFORE_EXIT_BOOT_SERVICES_GUID

2022-10-24 Thread Dionna Glaze via groups.io
Event group as defined in UEFI standard v2.9.

Cc: Ard Biescheuvel 
Cc: "Min M. Xu" 
Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Tom Lendacky 
Cc: Jiewen Yao 
Cc: Erdem Aktas 

Signed-off-by: Dionna Glaze 
---
 MdePkg/Include/Guid/EventGroup.h | 5 +
 MdePkg/MdePkg.dec| 5 -
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/Guid/EventGroup.h b/MdePkg/Include/Guid/EventGroup.h
index 063d1f7157..64bfd4bab9 100644
--- a/MdePkg/Include/Guid/EventGroup.h
+++ b/MdePkg/Include/Guid/EventGroup.h
@@ -14,6 +14,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 extern EFI_GUID  gEfiEventExitBootServicesGuid;
 
+#define EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES \
+  { 0x8be0e274, 0x3970, 0x4b44, { 0x80, 0xc5, 0x1a, 0xb9, 0x50, 0x2f, 0x3b, 
0xfc } }
+
+extern EFI_GUID  gEfiEventBeforeExitBootServicesGuid;
+
 #define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \
   { 0x13fa7698, 0xc831, 0x49c7, { 0x87, 0xea, 0x8f, 0x43, 0xfc, 0xc2, 0x51, 
0x96 } }
 
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 6b6bfbec29..359a85ea10 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -408,7 +408,10 @@
   gEfiEventMemoryMapChangeGuid   = { 0x78BEE926, 0x692F, 0x48FD, { 0x9E, 0xDB, 
0x01, 0x42, 0x2E, 0xF0, 0xD7, 0xAB }}
 
   ## Include/Guid/EventGroup.h
-  gEfiEventVirtualAddressChangeGuid = { 0x13FA7698, 0xC831, 0x49C7, { 0x87, 
0xEA, 0x8F, 0x43, 0xFC, 0xC2, 0x51, 0x96 }}
+  gEfiEventVirtualAddressChangeGuid   = { 0x13FA7698, 0xC831, 0x49C7, { 0x87, 
0xEA, 0x8F, 0x43, 0xFC, 0xC2, 0x51, 0x96 }}
+
+  ## Include/Guid/EventGroup.h
+  gEfiEventBeforeExitBootServicesGuid = { 0x8BE0E274, 0x3970, 0x4B44, { 0x80, 
0xC5, 0x1A, 0xB9, 0x50, 0x2F, 0x3B, 0xFC }}
 
   ## Include/Guid/EventGroup.h
   gEfiEventExitBootServicesGuid  = { 0x27ABF055, 0xB1B8, 0x4C26, { 0x80, 0x48, 
0x74, 0x8F, 0x37, 0xBA, 0xA2, 0xDF }}
-- 
2.38.0.135.g90850a2211-goog



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




[edk2-devel] [PATCH v8 1/7] OvmfPkg: Realize EfiMemoryAcceptProtocol in AmdSevDxe

2022-10-24 Thread Dionna Glaze via groups.io
From: Sophia Wolf 

When a guest OS does not support unaccepted memory, the unaccepted
memory must be accepted before returning a memory map to the caller.

EfiMemoryAcceptProtocol is defined in MdePkg and is implemented /
Installed in AmdSevDxe for AMD SEV-SNP memory acceptance.

Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Signed-off-by: Dionna Glaze 
---
 OvmfPkg/AmdSevDxe/AmdSevDxe.c  | 55 
++--
 OvmfPkg/AmdSevDxe/AmdSevDxe.inf|  3 ++
 OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c | 24 
+++--
 3 files changed, 74 insertions(+), 8 deletions(-)

diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c
index 662d3c4ccb..f7600c3c81 100644
--- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c
+++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION  mSnpBootDxeTable = {
   SIGNATURE_32 ('A','M', 'D', 'E'),
@@ -31,6 +32,40 @@ STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION  
mSnpBootDxeTable = {
   FixedPcdGet32 (PcdOvmfCpuidSize),
 };
 
+STATIC EFI_HANDLE  mAmdSevDxeHandle = NULL;
+
+#define IS_ALIGNED(x, y)  x) & ((y) - 1)) == 0))
+
+STATIC
+EFI_STATUS
+EFIAPI
+AmdSevMemoryAccept (
+  IN EDKII_MEMORY_ACCEPT_PROTOCOL  *This,
+  IN EFI_PHYSICAL_ADDRESS  StartAddress,
+  IN UINTN Size
+  )
+{
+  //
+  // The StartAddress must be page-aligned, and the Size must be a positive
+  // multiple of SIZE_4KB. Use an assert instead of returning an erros since
+  // this is an EDK2-internal protocol.
+  //
+  ASSERT (IS_ALIGNED (StartAddress, SIZE_4KB));
+  ASSERT (IS_ALIGNED (Size, SIZE_4KB));
+  ASSERT (Size != 0);
+
+  MemEncryptSevSnpPreValidateSystemRam (
+StartAddress,
+EFI_SIZE_TO_PAGES (Size)
+);
+
+  return EFI_SUCCESS;
+}
+
+STATIC EDKII_MEMORY_ACCEPT_PROTOCOL  mMemoryAcceptProtocol = {
+  AmdSevMemoryAccept
+};
+
 EFI_STATUS
 EFIAPI
 AmdSevDxeEntryPoint (
@@ -147,11 +182,23 @@ AmdSevDxeEntryPoint (
 }
   }
 
-  //
-  // If its SEV-SNP active guest then install the 
CONFIDENTIAL_COMPUTING_SEV_SNP_BLOB.
-  // It contains the location for both the Secrets and CPUID page.
-  //
   if (MemEncryptSevSnpIsEnabled ()) {
+//
+// Memory acceptance began being required in SEV-SNP, so install the
+// memory accept protocol implementation for a SEV-SNP active guest.
+//
+Status = gBS->InstallProtocolInterface (
+&mAmdSevDxeHandle,
+&gEdkiiMemoryAcceptProtocolGuid,
+EFI_NATIVE_INTERFACE,
+&mMemoryAcceptProtocol
+);
+ASSERT_EFI_ERROR (Status);
+
+//
+// If its SEV-SNP active guest then install the 
CONFIDENTIAL_COMPUTING_SEV_SNP_BLOB.
+// It contains the location for both the Secrets and CPUID page.
+//
 return gBS->InstallConfigurationTable (
   &gConfidentialComputingSevSnpBlobGuid,
   &mSnpBootDxeTable
diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf
index 9acf860cf2..cd1b686c53 100644
--- a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf
+++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf
@@ -47,6 +47,9 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize
 
+[Protocols]
+  gEdkiiMemoryAcceptProtocolGuid
+
 [Guids]
   gConfidentialComputingSevSnpBlobGuid
 
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c 
b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c
index d3a95e4913..cbcdd46f52 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c
@@ -14,6 +14,7 @@
 #include 
 
 #include "SnpPageStateChange.h"
+#include "VirtualMemory.h"
 
 /**
   Pre-validate the system RAM when SEV-SNP is enabled in the guest VM.
@@ -29,12 +30,27 @@ MemEncryptSevSnpPreValidateSystemRam (
   IN UINTN NumPages
   )
 {
+  EFI_STATUS  Status;
+
   if (!MemEncryptSevSnpIsEnabled ()) {
 return;
   }
 
-  //
-  // All the pre-validation must be completed in the PEI phase.
-  //
-  ASSERT (FALSE);
+  // DXE pre-validation may happen with the memory accept protocol.
+  // The protocol should only be called outside the prevalidated ranges
+  // that the PEI stage code explicitly skips. Specifically, only memory
+  // ranges that are classified as unaccepted.
+  if (BaseAddress >= SIZE_4GB) {
+Status = InternalMemEncryptSevCreateIdentityMap1G (
+   0,
+   BaseAddress,
+   EFI_PAGES_TO_SIZE (NumPages)
+   );
+if (EFI_ERROR (Status)) {
+  ASSERT (FALSE);
+  CpuDeadLoop ();
+}
+  }
+
+  InternalSetPageState (BaseAddress, NumPages, SevSnpPagePrivate, TRUE);
 }
-- 
2.38.0.135.g90850a2211-goog

[edk2-devel] [PATCH v8 0/7] Add safe unaccepted memory behavior

2022-10-24 Thread Dionna Glaze via groups.io
These seven patches build on the lazy-accept patch series

"Introduce Lazy-accept for Tdx guest"

by adding SEV-SNP support for the MemoryAccept protocol, and
importantly making eager memory acceptance the default behavior.

We implement a standardized event group from UEFI v2.9,
EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES, since it provides exactly
the right invocation point for eagerly accepting memory if eager
acceptance has not been disabled.

To make use of this event group, we add a new driver that is meant to
carry behavior that is needed for all confidential compute technologies,
not just specific platforms, CocoDxe. In CocoDxe we implement the
default safe behavior to accept all unaccepted memory and invalidate
the MemoryMap on ExitBootServices.

To allow the OS loader to prevent the eager acceptance, we add a new
protocol, up for standardization, AcceptAllUnacceptedMemoryProtocol.
This protocol has one interface, Disable(). The OS loader can inform the
UEFI that it supports the unaccepted memory type and accepts the
responsibility to accept it.

All images that support unaccepted memory must now locate and call this
new BZ3987_ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL and call the Disable
function.

Changes since v7:
 - Rebased onto lazy accept v4 patch series, so memory accept protocol
   has the EDKII prefix, and the unaccepted memory type has the BZ3937
   prefix.
 - Removed a bad #include to a header removed in v7.
 - Renamed the protocol to BZ3987_MEMORY_ACCEPTANCE_PROTOCOL as per the
   discussion on the buganizer issue.
 - Uncrustify formatting

Changes since v6:
 - Added implementation of EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES.
 - Changed callback protocol of v5 to instead use the standardized event
   group for before_exit_boot_services.

Changes since v5:
 - Generic callback protocol moved to MdeModulePkg
 - Removed use of EFI_WARN_STALE_DATA and added comment that the callback
   should only return EFI_SUCCESS or EFI_INVALID_PARAMETER.
 - Removed errant log statement and fixed formatting.

Changes since v4:
 - Commit message wording
 - Replaced direct change to DxeMain with a more generic callback
   protocol.
 - Implemented the direct change as an instance of the callback protocol
   from a new CocoDxe driver.
 - Replaced "enable" protocol with a "disable" protocol, since the name
   was confusing. The AcceptAllUnacceptedMemory protocol directly names
   the behavior that is disabling.

Changes since v3:
 - "DxeMain accepts all memory" patch split into 3 to make each patch
   affect only one package at a time.

Changes since v2:
 - Removed the redundant memory accept interface and added the accept
   behavior to the DXE implementation of
   MemEncryptSevSnpPreValidateSystemRam.
 - Fixed missing #include in >=4GB patch.

Changes since v1:
 - Added a patch to classify SEV-SNP memory above 4GB unaccepted.
 - Fixed style problems in EfiMemoryAcceptProtocol implementation.

Cc: Ard Biescheuvel 
Cc: "Min M. Xu" 
Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Tom Lendacky 
Cc: Jiewen Yao 
Cc: Erdem Aktas 
Cc: Andrew Fish 
Cc: "Michael D. Kinney" 

Signed-off-by: Dionna Glaze 

Dionna Glaze (7):
  OvmfPkg: Realize EfiMemoryAcceptProtocol in AmdSevDxe
  MdePkg: Add EFI_EVENT_BEFORE_EXIT_BOOT_SERVICES_GUID
  MdeModulePkg: Notify BeforeExitBootServices in CoreExitBootServices
  OvmfPkg: Introduce CocoDxe driver
  MdePkg: Introduce the MemoryAcceptance protocol
  OvmfPkg: Implement AcceptAllUnacceptedMemory in CocoDxe
  OvmfPkg/PlatformPei: SEV-SNP make >=4GB unaccepted

 MdeModulePkg/Core/Dxe/DxeMain.inf  |   1 +
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c|   6 +
 MdePkg/Include/Guid/EventGroup.h   |   5 +
 MdePkg/Include/Protocol/MemoryAcceptance.h |  40 +
 MdePkg/MdePkg.dec  |   8 +-
 OvmfPkg/AmdSev/AmdSevX64.dsc   |   1 +
 OvmfPkg/AmdSev/AmdSevX64.fdf   |   1 +
 OvmfPkg/AmdSevDxe/AmdSevDxe.c  |  55 
++-
 OvmfPkg/AmdSevDxe/AmdSevDxe.inf|   3 +
 OvmfPkg/CocoDxe/CocoDxe.c  | 174 

 OvmfPkg/CocoDxe/CocoDxe.inf|  46 ++
 OvmfPkg/IntelTdx/IntelTdxX64.dsc   |   1 +
 OvmfPkg/IntelTdx/IntelTdxX64.fdf   |   1 +
 OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c |  24 ++-
 OvmfPkg/OvmfPkgIa32X64.dsc |   1 +
 OvmfPkg/OvmfPkgIa32X64.fdf |   1 +
 OvmfPkg/OvmfPkgX64.dsc |   1 +
 OvmfPkg/OvmfPkgX64.fdf |   1 +
 OvmfPkg/PlatformPei/AmdSev.c   

Re: [edk2-devel] [Patch v2 00/11] Remove all UGA support

2022-10-24 Thread Michael D Kinney
Hi,

What is the status of this patch series and BZ? I think it would be really good 
to remove
UGA usage from edk2 for the next stable tag release.

Thanks,

Mike



> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Guomin Jiang
> Sent: Thursday, July 14, 2022 6:51 PM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [Patch v2 00/11] Remove all UGA support
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368
> 
> The Plan:
> 1. Remove the upstream UGA code first but keep definition in Edk2 at
> first
> 2. Then downstream owner to remove UGA related code
> 3. Remove Edk2 definition last.
> 
> GuoMinJ (9):
>   UefiPayloadPkg: Remove All UGA Support
>   ArmVirtPkg: Remove All UGA Support
>   ArmPkg: Remove All UGA Support
>   EmulatorPkg: Remove All UGA Support
>   ShellPkg: Remove All UGA Support
>   OvmfPkg: Remove All UGA Support
>   MdeModulePkg/ConSplitterDxe: Remove All UGA Support
>   MdeModulePkg/GraphicsConsoleDxe: Remove All UGA Support
>   MdeModulePkg: Remove All UGA Support
> 
> Guomin Jiang (2):
>   BaseTools: Remove all UGA support
>   MdePkg/UefiLib: Remove all UGA support
> 
>  .../PlatformBootManagerLib/PlatformBm.h   |   4 +-
>  .../PlatformBootManagerLib.inf|   5 +-
>  ArmVirtPkg/ArmVirtQemu.dsc|   7 +-
>  ArmVirtPkg/ArmVirtQemuKernel.dsc  |   7 +-
>  .../Source/C/Include/Protocol/HiiFramework.h  |  53 +--
>  BaseTools/Source/C/Include/Protocol/UgaDraw.h | 161 ---
>  EmulatorPkg/EmuGopDxe/Gop.h   |  10 +-
>  EmulatorPkg/EmuGopDxe/GopScreen.c |  14 +-
>  EmulatorPkg/Include/Protocol/EmuFileSystem.h  |  24 +-
>  .../Include/Protocol/EmuGraphicsWindow.h  |  18 +-
>  .../Library/PlatformBmLib/PlatformBm.h|   4 +-
>  .../Library/PlatformBmLib/PlatformBmData.c|   6 +-
>  EmulatorPkg/Unix/Host/Gasket.h|  12 +-
>  EmulatorPkg/Unix/Host/Host.h  |   3 +-
>  EmulatorPkg/Unix/Host/Ia32/Gasket.S   |   2 +-
>  EmulatorPkg/Unix/Host/X11GraphicsWindow.c |  82 ++--
>  EmulatorPkg/Unix/Host/X64/Gasket.S|   2 +-
>  EmulatorPkg/Win/Host/WinGopScreen.c   |  10 +-
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c   |   4 +-
>  MdeModulePkg/Include/Library/BootLogoLib.h|   4 +-
>  .../Library/BootLogoLib/BootLogoLib.c | 228 +++---
>  .../Library/BootLogoLib/BootLogoLib.inf   |   6 +-
>  .../Console/ConSplitterDxe/ConSplitter.c  | 405 +++---
>  .../Console/ConSplitterDxe/ConSplitter.h  | 138 +-
>  .../Console/ConSplitterDxe/ConSplitterDxe.inf |  17 +-
>  .../Console/ConSplitterDxe/ConSplitterDxe.uni |  12 +-
>  .../ConSplitterDxe/ConSplitterGraphics.c  | 310 +-
>  .../GraphicsConsoleDxe/GraphicsConsole.c  | 300 +
>  .../GraphicsConsoleDxe/GraphicsConsole.h  |  21 +-
>  .../GraphicsConsoleDxe/GraphicsConsoleDxe.inf |   8 +-
>  .../GraphicsConsoleDxe/GraphicsConsoleDxe.uni |   6 +-
>  MdeModulePkg/Universal/HiiDatabaseDxe/Image.c |   4 +-
>  MdePkg/Library/UefiLib/UefiLib.inf|   4 +-
>  MdePkg/Library/UefiLib/UefiLibInternal.h  |   3 +-
>  MdePkg/Library/UefiLib/UefiLibPrint.c |  91 +---
>  MdePkg/MdePkg.dsc |   3 -
>  OvmfPkg/AmdSev/AmdSevX64.dsc  |   4 +-
>  OvmfPkg/Bhyve/BhyveX64.dsc|   4 +-
>  OvmfPkg/Microvm/MicrovmX64.dsc|   4 +-
>  OvmfPkg/OvmfPkgIa32.dsc   |   2 -
>  OvmfPkg/OvmfPkgIa32X64.dsc|   2 -
>  OvmfPkg/OvmfPkgX64.dsc|   2 -
>  OvmfPkg/OvmfXen.dsc   |   4 +-
>  .../UefiHandleParsingLib.c|   4 +-
>  .../UefiHandleParsingLib.h|   4 +-
>  .../UefiHandleParsingLib.inf  |   4 +-
>  .../UefiHandleParsingLib.uni  |   4 +-
>  .../PlatformBootManager.h |   4 +-
>  .../PlatformBootManagerLib.inf|   4 +-
>  UefiPayloadPkg/UefiPayloadPkg.dsc |   2 -
>  50 files changed, 276 insertions(+), 1760 deletions(-)
>  delete mode 100644 BaseTools/Source/C/Include/Protocol/UgaDraw.h
> 
> --
> 2.26.2.windows.1
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH V1 0/2] CryptoPkg bug fixes

2022-10-24 Thread Michael D Kinney
Hi Judah,

There was an update to CryptoPkg pushed yesterday.

1) There is a CryptoPkg/Readme.md with tables and DSC content for services that 
are
   enabled in each phase.  I think that needs updates too for the AES and KDF 
features.
2) The CryptoPkg.dsc file has recommended settings for PEI, DXE, SMM.  I think
   they need to be updated for the AES and KDF features.
3) It looks like the SHA1 disable caused a build break.  I would like to see the
   standard package builds for EDK II CI be updated to cover the failure case so
   we know that this case is covered in the future.  It looks like the default 
is
   for SHA1 enabled and the build break is when define for SHA1 disabled is 
   asserted.
4) There is an overlap between the defines to deprecate MD5 and SH1 and the
   structured PCD that allows those services to be disabled in the Crypto 
   Protocol/PPI.  The defines to deprecate MD5 and SH1 extend into the 
BaseCryptLib
   instance implementations such that a call to those services when static 
linking
   will generate a build error instead of a runtime ASSERT().  Which behavior do
   you prefer?

Best regards,

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Judah Vang
> Sent: Monday, October 24, 2022 9:42 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [PATCH V1 0/2] CryptoPkg bug fixes
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=3991
> https://bugzilla.tianocore.org/show_bug.cgi?id=3992
> 
> There is a #define to deprecate Sha1 functions but not
> all the Sha1 function are wrapped around this #define causing
> a build error. The fix is to wrap all Sha1 functions with
> the #define.
> 
> Need crypto AES to be supported for PEI phase and need
> crypto KDF to be supported for SMM phase.
> 
> Judah Vang (2):
>   CryptoPkg: Sha1 functions causing build errors
>   CryptoPkg: Need to enable crypto functions
> 
>  CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf|  2 +-
>  CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf|  2 +-
>  CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c | 14 +-
>  3 files changed, 15 insertions(+), 3 deletions(-)
> 
> --
> 2.35.1.windows.2
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH v2] edk2Platforms-Silicon:Add VAB FIT record types support in FitGen.c

2022-10-24 Thread Hv, Pavamana
@Gao, Liming,

Can you please review the patch and let me know if this can be merged?

Thanks in advance for your help.

Regards,

Pavamana



-Original Message-
From: Hv, Pavamana 
Sent: Wednesday, October 19, 2022 8:57 PM
To: devel@edk2.groups.io
Cc: Hv, Pavamana 
Subject: [PATCH v2] edk2Platforms-Silicon:Add VAB FIT record types support in 
FitGen.c



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



This commit adds support for new FIT record type for Vendor Authorized Boot 
(VAB) security technology(FIT spec revision 1.4).

VAB defines 3 new following types

Vendor Authorized Boot Provisioning Table (Type 0x1A) Vendor Authorized Boot 
Image Manifest (Type 0x1B) Vendor Authorized Boot Key Manifest (Type 0x1C) The 
code has been updated to align these binaries on 64 byte boundary and not to 
overlap with other regions, similar to Key manifest, Boot Policy manifest and 
other optional types.



Also added macros to define FIT spec Major and Minor version numbers and print 
the same instead of hardcoded string.



Signed-off-by: Pavamana Holavanahalli 
mailto:pavamana...@intel.com>>

---

Silicon/Intel/Tools/FitGen/FitGen.c | 61 +++--  
Silicon/Intel/Tools/FitGen/FitGen.h |  5 ++-

2 files changed, 44 insertions(+), 22 deletions(-)



diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c 
b/Silicon/Intel/Tools/FitGen/FitGen.c

index 21dfcf1ebb..87123f9922 100644

--- a/Silicon/Intel/Tools/FitGen/FitGen.c

+++ b/Silicon/Intel/Tools/FitGen/FitGen.c

@@ -234,20 +234,24 @@ typedef struct {

#define FLASH_TO_MEMORY(Address, FvBuffer, FvSize)  \  (VOID 
*)(UINTN)((UINTN)(FvBuffer) + (UINTN)(FvSize) - (TOP_FLASH_ADDRESS - 
(UINTN)(Address))) -#define FIT_TABLE_TYPE_HEADER 0-#define 
FIT_TABLE_TYPE_MICROCODE  1-#define FIT_TABLE_TYPE_STARTUP_ACM  
  2-#define FIT_TABLE_TYPE_DIAGNST_ACM3-#define 
FIT_TABLE_TYPE_BIOS_MODULE7-#define FIT_TABLE_TYPE_TPM_POLICY   
  8-#define FIT_TABLE_TYPE_BIOS_POLICY9-#define 
FIT_TABLE_TYPE_TXT_POLICY 10-#define FIT_TABLE_TYPE_KEY_MANIFEST
   11-#define FIT_TABLE_TYPE_BOOT_POLICY_MANIFEST   12-#define 
FIT_TABLE_TYPE_BIOS_DATA_AREA 13-#define FIT_TABLE_TYPE_CSE_SECURE_BOOT 
   16-#define FIT_TABLE_SUBTYPE_FIT_PATCH_MANIFEST  12-#define 
FIT_TABLE_SUBTYPE_ACM_MANIFEST13+#define FIT_TABLE_TYPE_HEADER  
0+#define FIT_TABLE_TYPE_MICROCODE   1+#define 
FIT_TABLE_TYPE_STARTUP_ACM 2+#define FIT_TABLE_TYPE_DIAGNST_ACM 
3+#define FIT_TABLE_TYPE_BIOS_MODULE 7+#define 
FIT_TABLE_TYPE_TPM_POLICY  8+#define FIT_TABLE_TYPE_BIOS_POLICY 
9+#define FIT_TABLE_TYPE_TXT_POLICY  10+#define 
FIT_TABLE_TYPE_KEY_MANIFEST11+#define 
FIT_TABLE_TYPE_BOOT_POLICY_MANIFEST12+#define 
FIT_TABLE_TYPE_BIOS_DATA_AREA  13+#define 
FIT_TABLE_TYPE_CSE_SECURE_BOOT 16+#define 
FIT_TABLE_SUBTYPE_FIT_PATCH_MANIFEST   12+#define 
FIT_TABLE_SUBTYPE_ACM_MANIFEST 13+#define 
FIT_TABLE_TYPE_VAB_PROVISION_TABLE 26+#define 
FIT_TABLE_TYPE_VAB_BOOT_IMAGE_MANIFEST 27+#define 
FIT_TABLE_TYPE_VAB_BOOT_KEY_MANIFEST   28+  // // With OptionalModule 
Address isn't known until free space has been@@ -322,8 +326,10 @@ Returns:

--*/ {   printf (-"%s - Tiano IA32/X64 FIT table generation Utility for FIT 
spec revision 1.2."" Version %i.%i\n\n",+"%s - Tiano IA32/X64 FIT table 
generation Utility for FIT spec revision %i.%i."" Version %i.%i\n\n", 
UTILITY_NAME,+FIT_SPEC_VERSION_MAJOR,+FIT_SPEC_VERSION_MINOR, 
UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION );@@ -1956,7 +1962,10 @@ 
Returns:

 (gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_KEY_MANIFEST) || 
(gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_BOOT_POLICY_MANIFEST) || 
(gFitTableContext.OptionalModule[Index].Type == FIT_TABLE_TYPE_BIOS_DATA_AREA) 
||-(gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_CSE_SECURE_BOOT)) {+
(gFitTableContext.OptionalModule[Index].Type == FIT_TABLE_TYPE_CSE_SECURE_BOOT) 
||+(gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_VAB_PROVISION_TABLE) ||+
(gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_VAB_BOOT_IMAGE_MANIFEST) ||+
(gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_VAB_BOOT_KEY_MANIFEST)) {   // NOTE: It might be virtual 
address now. Just put a place holder.   FitEntryNumber ++; }@@ -2154,8 
+2163,11 @@ Returns:

   (gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_KEY_MANIFEST) ||   
(gFitTableContext.OptionalModule[Index].Type == 
FIT_TABLE_TYPE_BOOT_POLICY_MANIFEST) ||   
(gFitTableContext.OptionalModu

[edk2-devel] [PATCH 11/11] ArmPlatformPkg: Retire NorFlashDxe driver

2022-10-24 Thread Ard Biesheuvel
The NorFlashDxe driver in ArmPlatformPkg was shared between development
platforms built by ARM Ltd, and virtual platforms that were once modeled
after Versatile Express, but have very little in common with actual bare
metal implementations.

Both sides have migrated to a domain specific version of the driver, so
we can retire the old one.

Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/ArmPlatformPkg.dec  |   
6 -
 ArmPlatformPkg/ArmPlatformPkg.dsc  |   
6 -
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c  | 
991 
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.h  | 
422 -
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c| 
123 ---
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c   | 
506 --
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf |  
71 --
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c   | 
777 ---
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c  | 
383 
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf|  
66 --
 ArmPlatformPkg/Include/Library/NorFlashPlatformLib.h   |  
30 -
 ArmPlatformPkg/Library/NorFlashPlatformNullLib/NorFlashPlatformNullLib.c   |  
28 -
 ArmPlatformPkg/Library/NorFlashPlatformNullLib/NorFlashPlatformNullLib.inf |  
24 -
 13 files changed, 3433 deletions(-)

diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec 
b/ArmPlatformPkg/ArmPlatformPkg.dec
index dd6e78f62aa1..7b5d7e6cb520 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -38,10 +38,6 @@ [LibraryClasses]
   #
   LcdPlatformLib|Include/Library/LcdPlatformLib.h
 
-  ##  @libraryclass  Provides a Nor flash interface.
-  #
-  NorFlashPlatformLib|Include/Library/NorFlashPlatformLib.h
-
   ##  @libraryclass  Provides an interface to the clock of a PL011 device.
   #
   PL011UartClockLib|Include/Library/PL011UartClockLib.h
@@ -56,8 +52,6 @@ [Guids.common]
 [PcdsFeatureFlag.common]
   
gArmPlatformTokenSpaceGuid.PcdSendSgiToBringUpSecondaryCores|FALSE|BOOLEAN|0x0004
 
-  
gArmPlatformTokenSpaceGuid.PcdNorFlashCheckBlockLocked|FALSE|BOOLEAN|0x003C
-
   # Disable the GOP controller on ExitBootServices(). By default the value is 
FALSE,
   # we assume the OS will handle the FrameBuffer from the UEFI GOP information.
   
gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices|FALSE|BOOLEAN|0x003D
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc 
b/ArmPlatformPkg/ArmPlatformPkg.dsc
index 661a4cea220d..ddd128f9e606 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
@@ -55,7 +55,6 @@ [LibraryClasses.common]
   
LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
   
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   MemoryInitPeiLib|ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf
-  
NorFlashPlatformLib|ArmPlatformPkg/Library/NorFlashPlatformNullLib/NorFlashPlatformNullLib.inf
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
   
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
@@ -100,7 +99,6 @@ [LibraryClasses.AARCH64.MM_STANDALONE]
 
 [Components.common]
   ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
   ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf
 
@@ -109,7 +107,6 @@ [Components.common]
   ArmPlatformPkg/Library/HdLcd/HdLcd.inf
   ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.inf
   ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.inf
-  ArmPlatformPkg/Library/NorFlashPlatformNullLib/NorFlashPlatformNullLib.inf
   ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf
   ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf
   ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
@@ -130,6 +127,3 @@ [Components.common]
   ArmPlatformPkg/PrePi/PeiUniCore.inf
 
   ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
-
-[Components.AARCH64]
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf
diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c 
b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c
deleted file mode 100644
index 1b431073ee93..
--- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c
+++ /dev/null
@@ -1,991 +0,0 @@
-/** @file  NorFlash.c
-
-  Copyright (c) 2011 - 2020, Arm Limited. All rights reserved.
-  Copyright (c) 2020, Linaro, Ltd. All rights reserved.
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include 
-
-#include "NorFlash.h"
-
-//
-// Global variable declara

[edk2-devel] [PATCH 10/11] ArmVirtPkg/ArmVirtKvmTool: Migrate to OVMF's VirtNorFlashDxe

2022-10-24 Thread Ard Biesheuvel
Migrate to the virt specific NOR flash driver as the ArmPlatformPkg is
going away.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirtKvmTool.dsc|  4 ++--
 ArmVirtPkg/ArmVirtKvmTool.fdf|  2 +-
 ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtool.c  | 20 
++--
 ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf |  4 ++--
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc
index 3bd3ebd6e0b3..c598903b33d2 100644
--- a/ArmVirtPkg/ArmVirtKvmTool.dsc
+++ b/ArmVirtPkg/ArmVirtKvmTool.dsc
@@ -50,7 +50,7 @@ [LibraryClasses.common]
   
ArmVirtMemInfoLib|ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf
 
   TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
-  
NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf
+  
VirtNorFlashPlatformLib|ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf
 
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
 
@@ -291,7 +291,7 @@ [Components.common]
   
NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
   }
 
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
 
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 
diff --git a/ArmVirtPkg/ArmVirtKvmTool.fdf b/ArmVirtPkg/ArmVirtKvmTool.fdf
index 9e006e83ee5c..b696bffc7ccb 100644
--- a/ArmVirtPkg/ArmVirtKvmTool.fdf
+++ b/ArmVirtPkg/ArmVirtKvmTool.fdf
@@ -154,7 +154,7 @@ [FV.FvMain]
   INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
   INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
   INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
-  INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  INF OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
 
   #
   # FAT filesystem + GPT/MBR partitioning + UDF filesystem
diff --git a/ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtool.c 
b/ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtool.c
index 39d2615b5409..129c16b7110c 100644
--- a/ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtool.c
+++ b/ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtool.c
@@ -9,8 +9,8 @@
 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 
 /** Macro defining the NOR block size configured in Kvmtool.
@@ -25,10 +25,10 @@
 */
 #define LABEL_UEFI_VAR_STORE  "System-firmware"
 
-STATIC NOR_FLASH_DESCRIPTION  mNorFlashDevices[MAX_FLASH_DEVICES];
-STATIC UINTN  mNorFlashDeviceCount = 0;
-STATIC INT32  mUefiVarStoreNode= MAX_INT32;
-STATIC FDT_CLIENT_PROTOCOL*mFdtClient;
+STATIC VIRT_NOR_FLASH_DESCRIPTION  mNorFlashDevices[MAX_FLASH_DEVICES];
+STATIC UINTN   mNorFlashDeviceCount = 0;
+STATIC INT32   mUefiVarStoreNode= MAX_INT32;
+STATIC FDT_CLIENT_PROTOCOL *mFdtClient;
 
 /** This function performs platform specific actions to initialise
 the NOR flash, if required.
@@ -36,7 +36,7 @@ STATIC FDT_CLIENT_PROTOCOL*mFdtClient;
   @retval EFI_SUCCESS   Success.
 **/
 EFI_STATUS
-NorFlashPlatformInitialization (
+VirtNorFlashPlatformInitialization (
   VOID
   )
 {
@@ -89,7 +89,7 @@ NorFlashPlatformInitialization (
 STATIC
 EFI_STATUS
 SetupVariableStore (
-  IN NOR_FLASH_DESCRIPTION  *FlashDevice
+  IN VIRT_NOR_FLASH_DESCRIPTION  *FlashDevice
   )
 {
   UINTN  FlashRegion;
@@ -187,9 +187,9 @@ SetupVariableStore (
   @retval EFI_NOT_FOUND Flash device not found.
 **/
 EFI_STATUS
-NorFlashPlatformGetDevices (
-  OUT NOR_FLASH_DESCRIPTION  **NorFlashDescriptions,
-  OUT UINT32 *Count
+VirtNorFlashPlatformGetDevices (
+  OUT VIRT_NOR_FLASH_DESCRIPTION  **NorFlashDescriptions,
+  OUT UINT32  *Count
   )
 {
   if (mNorFlashDeviceCount > 0) {
diff --git a/ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf 
b/ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf
index 04d672329537..b5f35d478289 100644
--- a/ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf
+++ b/ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf
@@ -12,7 +12,7 @@ [Defines]
   FILE_GUID  = E75F07A1-B160-4893-BDD4-09E32FF847DC
   MODULE_TYPE= DXE_DRIVER
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = NorFlashPlatformLib
+  LIBRARY_CLASS  = VirtNorFlashPlatformLib
   CONSTRUCTOR= NorFlashPlatformLibConstructor
 
 [Sources.common]
@@ -20,11 +20,11 @@ [Sources.common]
 
 [Packages]
   ArmPkg/ArmPkg.dec
-  ArmPlatformPkg/ArmPlatformPkg.dec
   ArmVirtPkg/ArmVirtPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
+  OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
   BaseLib
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#9

[edk2-devel] [PATCH 09/11] ArmVirtPkg/ArmVirtQemu: migrate to OVMF's VirtNorFlashDxe

2022-10-24 Thread Ard Biesheuvel
Switch to the virt specific NorFlashDxe driver implementation that was
added recently.

Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirtQemu.dsc |  4 ++--
 ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc   |  2 +-
 ArmVirtPkg/ArmVirtQemuKernel.dsc   |  4 ++--
 ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c   | 12 ++--
 ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf |  4 ++--
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 9369a88858fd..a13297997434 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -67,7 +67,7 @@ [LibraryClasses.common]
   
ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf
 
   TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
-  NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
+  
VirtNorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
 
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
   BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
@@ -397,7 +397,7 @@ [Components.common]
 
   
NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
   }
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 
   #
diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc 
b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
index d4df6dede0fe..771921dffd74 100644
--- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
+++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
@@ -73,7 +73,7 @@ [FV.FvMain]
 
   INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
   INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
-  INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  INF OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
   INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 
   #
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index 7f7d15d6eee3..5bf6c02a3141 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -65,7 +65,7 @@ [LibraryClasses.common]
   
ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
 
   TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
-  NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
+  
VirtNorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
 
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
   BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
@@ -331,7 +331,7 @@ [Components.common]
 
   
NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
   }
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 
   #
diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c 
b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
index 2b39f021d0ae..55bce88bc8dd 100644
--- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
+++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
@@ -8,8 +8,8 @@
 
 #include 
 #include 
-#include 
 #include 
+#include 
 
 #include 
 
@@ -18,19 +18,19 @@
 #define MAX_FLASH_BANKS  4
 
 EFI_STATUS
-NorFlashPlatformInitialization (
+VirtNorFlashPlatformInitialization (
   VOID
   )
 {
   return EFI_SUCCESS;
 }
 
-NOR_FLASH_DESCRIPTION  mNorFlashDevices[MAX_FLASH_BANKS];
+STATIC VIRT_NOR_FLASH_DESCRIPTION  mNorFlashDevices[MAX_FLASH_BANKS];
 
 EFI_STATUS
-NorFlashPlatformGetDevices (
-  OUT NOR_FLASH_DESCRIPTION  **NorFlashDescriptions,
-  OUT UINT32 *Count
+VirtNorFlashPlatformGetDevices (
+  OUT VIRT_NOR_FLASH_DESCRIPTION  **NorFlashDescriptions,
+  OUT UINT32  *Count
   )
 {
   FDT_CLIENT_PROTOCOL  *FdtClient;
diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf 
b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
index 4c3683bf5d0d..a6b5865be91c 100644
--- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
+++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
@@ -14,17 +14,17 @@ [Defines]
   FILE_GUID  = 339B7829-4C5F-4EFC-B2DD-5050E530DECE
   MODULE_TYPE= DXE_DRIVER
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = NorFlashPlatformLib
+  LIBRARY_CLASS  = VirtNorFlashPlatformLib
 
 [Sources.common]
   NorFlashQemuLib.c
 
 [Packages]
   MdePkg/MdePkg.dec
-  ArmPlatformPkg/ArmPlatformPkg.dec
   ArmPkg/ArmPkg.dec
   ArmVirtPkg/ArmVirtPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
+  OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
   BaseLib
-- 
2.35.1



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

[edk2-devel] [PATCH 08/11] OvmfPkg/VirtNorFlashDxe: use EFI_MEMORY_WC and drop AlignedCopyMem()

2022-10-24 Thread Ard Biesheuvel
NOR flash emulation under KVM involves switching between two modes,
where array mode is backed by a read-only memslot, and programming mode
is fully emulated, i.e., the memory region is not backed by anything,
and the faulting accesses are forwarded to the VMM by the hypervisor,
which translates them into NOR flash programming commands.

Normally, we are limited to the use of device attributes when mapping
such regions, given that the programming mode has MMIO semantics.
However, when running under KVM, the chosen memory attributes only take
effect when in array mode, since no memory mapping exists otherwise.

This means we can tune the memory mapping so it behaves a bit more like
a ROM, by switching to EFI_MEMORY_WC attributes. This means we no longer
need a special CopyMem() implementation that avoids unaligned accesses
at all cost.

Signed-off-by: Ard Biesheuvel 
---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c| 65 +---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c |  4 +-
 2 files changed, 4 insertions(+), 65 deletions(-)

diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
index d87cdd49d6a6..392e17988472 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
@@ -401,67 +401,6 @@ NorFlashWriteBlocks (
   return Status;
 }
 
-#define BOTH_ALIGNED(a, b, align)  UINTN)(a) | (UINTN)(b)) & ((align) - 
1)) == 0)
-
-/**
-  Copy Length bytes from Source to Destination, using aligned accesses only.
-  Note that this implementation uses memcpy() semantics rather then memmove()
-  semantics, i.e., SourceBuffer and DestinationBuffer should not overlap.
-
-  @param  DestinationBuffer The target of the copy request.
-  @param  SourceBuffer  The place to copy from.
-  @param  LengthThe number of bytes to copy.
-
-  @return Destination
-
-**/
-STATIC
-VOID *
-AlignedCopyMem (
-  OUT VOID*DestinationBuffer,
-  IN  CONST VOID  *SourceBuffer,
-  IN  UINTN   Length
-  )
-{
-  UINT8 *Destination8;
-  CONST UINT8   *Source8;
-  UINT32*Destination32;
-  CONST UINT32  *Source32;
-  UINT64*Destination64;
-  CONST UINT64  *Source64;
-
-  if (BOTH_ALIGNED (DestinationBuffer, SourceBuffer, 8) && (Length >= 8)) {
-Destination64 = DestinationBuffer;
-Source64  = SourceBuffer;
-while (Length >= 8) {
-  *Destination64++ = *Source64++;
-  Length  -= 8;
-}
-
-Destination8 = (UINT8 *)Destination64;
-Source8  = (CONST UINT8 *)Source64;
-  } else if (BOTH_ALIGNED (DestinationBuffer, SourceBuffer, 4) && (Length >= 
4)) {
-Destination32 = DestinationBuffer;
-Source32  = SourceBuffer;
-while (Length >= 4) {
-  *Destination32++ = *Source32++;
-  Length  -= 4;
-}
-
-Destination8 = (UINT8 *)Destination32;
-Source8  = (CONST UINT8 *)Source32;
-  } else {
-Destination8 = DestinationBuffer;
-Source8  = SourceBuffer;
-  }
-
-  while (Length-- != 0) {
-*Destination8++ = *Source8++;
-  }
-
-  return DestinationBuffer;
-}
-
 EFI_STATUS
 NorFlashReadBlocks (
   IN NOR_FLASH_INSTANCE  *Instance,
@@ -516,7 +455,7 @@ NorFlashReadBlocks (
   SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY);
 
   // Readout the data
-  AlignedCopyMem (Buffer, (VOID *)StartAddress, BufferSizeInBytes);
+  CopyMem (Buffer, (VOID *)StartAddress, BufferSizeInBytes);
 
   return EFI_SUCCESS;
 }
@@ -558,7 +497,7 @@ NorFlashRead (
   SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY);
 
   // Readout the data
-  AlignedCopyMem (Buffer, (VOID *)(StartAddress + Offset), BufferSizeInBytes);
+  CopyMem (Buffer, (VOID *)(StartAddress + Offset), BufferSizeInBytes);
 
   return EFI_SUCCESS;
 }
diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
index f9a41f6aab0f..ff3121af2a40 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
@@ -394,14 +394,14 @@ NorFlashFvbInitialize (
   EfiGcdMemoryTypeMemoryMappedIo,
   Instance->DeviceBaseAddress,
   RuntimeMmioRegionSize,
-  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
+  EFI_MEMORY_WC | EFI_MEMORY_RUNTIME
   );
   ASSERT_EFI_ERROR (Status);
 
   Status = gDS->SetMemorySpaceAttributes (
   Instance->DeviceBaseAddress,
   RuntimeMmioRegionSize,
-  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
+  EFI_MEMORY_WC | EFI_MEMORY_RUNTIME
   );
   ASSERT_EFI_ERROR (Status);
 
-- 
2.35.1



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

[edk2-devel] [PATCH 07/11] OvmfPkg/VirtNorFlashDxe: avoid switching between modes in a tight loop

2022-10-24 Thread Ard Biesheuvel
Currently, when dealing with small updates that can be written out
directly (i.e., if they only involve clearing bits and not setting bits,
as the latter requires a block level erase), we iterate over the data
one word at a time, read the old value, compare it, write the new value,
and repeat, unless we encountered a value that we cannot write (0->1
transition), in which case we fall back to a block level operation.

This is inefficient for two reasons:
- reading and writing a word at a time involves switching between array
and programming mode for every word of data, which is
disproportionately costly when running under KVM;
- we end up writing some data twice, as we may not notice that a block
erase is needed until after some data has been written to flash.

So replace this sequence with a single read of up to twice the buffered
write maximum size, followed by one or two buffered writes if the data
can be written directly. Otherwise, fall back to the existing block
level sequence, but without writing out part of the data twice.

Signed-off-by: Ard Biesheuvel 
---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 208 +++-
 1 file changed, 71 insertions(+), 137 deletions(-)

diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
index 0a5c5d48c738..d87cdd49d6a6 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
@@ -576,23 +576,20 @@ NorFlashWriteSingleBlock (
   INUINT8   *Buffer
   )
 {
-  EFI_STATUS  TempStatus;
-  UINT32  Tmp;
-  UINT32  TmpBuf;
-  UINT32  WordToWrite;
-  UINT32  Mask;
-  BOOLEAN DoErase;
-  UINTN   BytesToWrite;
+  EFI_STATUS  Status;
   UINTN   CurOffset;
-  UINTN   WordAddr;
   UINTN   BlockSize;
   UINTN   BlockAddress;
-  UINTN   PrevBlockAddress;
-
-  PrevBlockAddress = 0;
+  UINT8   *OrigData;
 
   DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=%ld, 
Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Lba, Offset, *NumBytes, 
Buffer));
 
+  // Check we did get some memory. Buffer is BlockSize.
+  if (Instance->ShadowBuffer == NULL) {
+DEBUG ((DEBUG_ERROR, "FvbWrite: ERROR - Buffer not ready\n"));
+return EFI_DEVICE_ERROR;
+  }
+
   // Cache the block size to avoid de-referencing pointers all the time
   BlockSize = Instance->BlockSize;
 
@@ -612,148 +609,85 @@ NorFlashWriteSingleBlock (
 return EFI_BAD_BUFFER_SIZE;
   }
 
-  // Pick 128bytes as a good start for word operations as opposed to erasing 
the
-  // block and writing the data regardless if an erase is really needed.
-  // It looks like most individual NV variable writes are smaller than 
128bytes.
-  if (*NumBytes <= 128) {
+  // Pick P30_MAX_BUFFER_SIZE_IN_BYTES (== 128 bytes) as a good start for word
+  // operations as opposed to erasing the block and writing the data regardless
+  // if an erase is really needed.  It looks like most individual NV variable
+  // writes are smaller than 128 bytes.
+  // To avoid pathological cases were a 2 byte write is disregarded because it
+  // occurs right at a 128 byte buffered write alignment boundary, permit up to
+  // twice the max buffer size, and perform two writes if needed.
+  if ((*NumBytes + (Offset & BOUNDARY_OF_32_WORDS)) <= (2 * 
P30_MAX_BUFFER_SIZE_IN_BYTES)) {
 // Check to see if we need to erase before programming the data into NOR.
 // If the destination bits are only changing from 1s to 0s we can just 
write.
 // After a block is erased all bits in the block is set to 1.
 // If any byte requires us to erase we just give up and rewrite all of it.
-DoErase  = FALSE;
-BytesToWrite = *NumBytes;
-CurOffset= Offset;
 
-while (BytesToWrite > 0) {
-  // Read full word from NOR, splice as required. A word is the smallest
-  // unit we can write.
-  TempStatus = NorFlashRead (Instance, Lba, CurOffset & ~(0x3), sizeof 
(Tmp), &Tmp);
-  if (EFI_ERROR (TempStatus)) {
-return EFI_DEVICE_ERROR;
-  }
-
-  // Physical address of word in NOR to write.
-  WordAddr = (CurOffset & ~(0x3)) + GET_NOR_BLOCK_ADDRESS (
-  Instance->RegionBaseAddress,
-  Lba,
-  BlockSize
-  );
-  // The word of data that is to be written.
-  TmpBuf = *((UINT32 *)(Buffer + (*NumBytes - BytesToWrite)));
-
-  // First do word aligned chunks.
-  if ((CurOffset & 0x3) == 0) {
-if (BytesToWrite >= 4) {
-  // Is the destination still in 'erased' state?
-  if (~Tmp != 0) {
-// Check to see if we are only changing bits to zero.
-if ((Tmp ^ TmpBuf) & TmpBuf) {
-  DoErase = TRUE;
-  break;
-}
-  }
-
-  // Write this word to NOR
-  WordToWrite   = TmpBuf;
-  CurOffset   

[edk2-devel] [PATCH 05/11] OvmfPkg/VirtNorFlashDxe: drop block I/O protocol implementation

2022-10-24 Thread Ard Biesheuvel
We never boot from NOR flash, and generally rely on the firmware volume
PI protocols to expose the contents. So drop the block I/O protocol
implementation from VirtNorFlashDxe.

Signed-off-by: Ard Biesheuvel 
---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c  | 49 ++
 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h  | 52 +---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c   | 40 +++
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf |  1 -
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c   | 52 
 5 files changed, 44 insertions(+), 150 deletions(-)

diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
index 1094d48f7de4..f41d9d372f49 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
@@ -366,10 +366,6 @@ NorFlashWriteBlocks (
 return EFI_INVALID_PARAMETER;
   }
 
-  if (Instance->Media.ReadOnly == TRUE) {
-return EFI_WRITE_PROTECTED;
-  }
-
   // We must have some bytes to read
   DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BufferSizeInBytes=0x%x\n", 
BufferSizeInBytes));
   if (BufferSizeInBytes == 0) {
@@ -377,22 +373,22 @@ NorFlashWriteBlocks (
   }
 
   // The size of the buffer must be a multiple of the block size
-  DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BlockSize in bytes =0x%x\n", 
Instance->Media.BlockSize));
-  if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) {
+  DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BlockSize in bytes =0x%x\n", 
Instance->BlockSize));
+  if ((BufferSizeInBytes % Instance->BlockSize) != 0) {
 return EFI_BAD_BUFFER_SIZE;
   }
 
   // All blocks must be within the device
-  NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize;
+  NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->BlockSize;
 
-  DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: NumBlocks=%d, LastBlock=%ld, 
Lba=%ld.\n", NumBlocks, Instance->Media.LastBlock, Lba));
+  DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: NumBlocks=%d, LastBlock=%ld, 
Lba=%ld.\n", NumBlocks, Instance->LastBlock, Lba));
 
-  if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) {
+  if ((Lba + NumBlocks) > (Instance->LastBlock + 1)) {
 DEBUG ((DEBUG_ERROR, "NorFlashWriteBlocks: ERROR - Write will exceed last 
block.\n"));
 return EFI_INVALID_PARAMETER;
   }
 
-  BlockSizeInWords = Instance->Media.BlockSize / 4;
+  BlockSizeInWords = Instance->BlockSize / 4;
 
   // Because the target *Buffer is a pointer to VOID, we must put all the data 
into a pointer
   // to a proper data type, so use *ReadBuffer
@@ -489,8 +485,8 @@ NorFlashReadBlocks (
 DEBUG_BLKIO,
 "NorFlashReadBlocks: BufferSize=0x%xB BlockSize=0x%xB LastBlock=%ld, 
Lba=%ld.\n",
 BufferSizeInBytes,
-Instance->Media.BlockSize,
-Instance->Media.LastBlock,
+Instance->BlockSize,
+Instance->LastBlock,
 Lba
 ));
 
@@ -505,14 +501,14 @@ NorFlashReadBlocks (
   }
 
   // The size of the buffer must be a multiple of the block size
-  if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) {
+  if ((BufferSizeInBytes % Instance->BlockSize) != 0) {
 return EFI_BAD_BUFFER_SIZE;
   }
 
   // All blocks must be within the device
-  NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize;
+  NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->BlockSize;
 
-  if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) {
+  if ((Lba + NumBlocks) > (Instance->LastBlock + 1)) {
 DEBUG ((DEBUG_ERROR, "NorFlashReadBlocks: ERROR - Read will exceed last 
block\n"));
 return EFI_INVALID_PARAMETER;
   }
@@ -521,7 +517,7 @@ NorFlashReadBlocks (
   StartAddress = GET_NOR_BLOCK_ADDRESS (
Instance->RegionBaseAddress,
Lba,
-   Instance->Media.BlockSize
+   Instance->BlockSize
);
 
   // Put the device into Read Array mode
@@ -554,7 +550,7 @@ NorFlashRead (
 return EFI_SUCCESS;
   }
 
-  if (((Lba * Instance->Media.BlockSize) + Offset + BufferSizeInBytes) > 
Instance->Size) {
+  if (((Lba * Instance->BlockSize) + Offset + BufferSizeInBytes) > 
Instance->Size) {
 DEBUG ((DEBUG_ERROR, "NorFlashRead: ERROR - Read will exceed device 
size.\n"));
 return EFI_INVALID_PARAMETER;
   }
@@ -563,7 +559,7 @@ NorFlashRead (
   StartAddress = GET_NOR_BLOCK_ADDRESS (
Instance->RegionBaseAddress,
Lba,
-   Instance->Media.BlockSize
+   Instance->BlockSize
);
 
   // Put the device into Read Array mode
@@ -577,7 +573,7 @@ NorFlashRead (
 
 /*
   Write a full or portion of a block. It must not span block boundaries; that 
is,
-  Offset + *NumBytes <= Instance->Media.BlockSize.
+  Offset + *NumBytes <= Instance->BlockSize.
 */
 EFI_STATUS
 NorFlashWriteSingleBlock (
@@ -605,15 +601,8 @@ NorFlashWriteSingleBlock (
 
   DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=%ld, 
Offset=0x%x, *NumBytes=0x%x,

[edk2-devel] [PATCH 06/11] OvmfPkg/VirtNorFlashDxe: avoid array mode switch after each word write

2022-10-24 Thread Ard Biesheuvel
NorFlashWriteSingleWord() switches into programming mode and back into
array mode for every single word that it writes. Under KVM, this
involves tearing down the read-only memslot, and setting it up again,
which is costly and unnecessary.

Instead, move the array mode switch into the callers, and only make the
switch when the writing is done.

Signed-off-by: Ard Biesheuvel 
---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c| 12 +++-
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c |  3 +++
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
index f41d9d372f49..0a5c5d48c738 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
@@ -205,9 +205,6 @@ NorFlashWriteSingleWord (
 SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, 
P30_CMD_CLEAR_STATUS_REGISTER);
   }
 
-  // Put device back into Read Array mode
-  SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY);
-
   return Status;
 }
 
@@ -286,8 +283,7 @@ NorFlashWriteBuffer (
 
   // The buffer was not available for writing
   if (WaitForBuffer == 0) {
-Status = EFI_DEVICE_ERROR;
-goto EXIT;
+return EFI_DEVICE_ERROR;
   }
 
   // From now on we work in 32-bit words
@@ -337,10 +333,6 @@ NorFlashWriteBuffer (
 SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, 
P30_CMD_CLEAR_STATUS_REGISTER);
   }
 
-EXIT:
-  // Put device back into Read Array mode
-  SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY);
-
   return Status;
 }
 
@@ -739,6 +731,8 @@ NorFlashWriteSingleBlock (
   }
 
   TempStatus = NorFlashWriteSingleWord (Instance, WordAddr, WordToWrite);
+  // Put device back into Read Array mode
+  SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY);
   if (EFI_ERROR (TempStatus)) {
 return EFI_DEVICE_ERROR;
   }
diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
index 2ceda226359c..f9a41f6aab0f 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
@@ -280,6 +280,9 @@ NorFlashWriteFullBlock (
   }
 
 EXIT:
+  // Put device back into Read Array mode
+  SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY);
+
   if (!EfiAtRuntime ()) {
 // Interruptions can resume.
 gBS->RestoreTPL (OriginalTPL);
-- 
2.35.1



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




[edk2-devel] [PATCH 02/11] OvmfPkg/VirtNorFlashDxe: clone ArmPlatformPkg's NOR flash driver

2022-10-24 Thread Ard Biesheuvel
QEMU's mach-virt is loosely based on ARM Versatile Express, and inherits
its NOR flash driver, which is now being used on other QEMU emulated
architectures as well.

In order to permit ourselves the freedom to optimize this driver for
use under KVM emulation, let's clone it into OvmfPkg, so we have a
version we can hack without the risk of regressing bare metal platforms.

The cloned version is mostly identical to the original, but it depends
on the newly added VirtNorFlashPlatformLib library class instead of the
original one from ArmPlatformPkg. Beyond that, only cosmetic changes
related to #include order etc were made.

Signed-off-by: Ard Biesheuvel 
---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c   | 991 
 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h   | 422 +
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c | 123 +++
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c| 506 ++
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf  |  72 ++
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c| 777 +++
 6 files changed, 2891 insertions(+)

diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
new file mode 100644
index ..12fa720dad84
--- /dev/null
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
@@ -0,0 +1,991 @@
+/** @file  NorFlash.c
+
+  Copyright (c) 2011 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2020, Linaro, Ltd. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+
+#include "VirtNorFlash.h"
+
+//
+// Global variable declarations
+//
+extern NOR_FLASH_INSTANCE  **mNorFlashInstances;
+extern UINT32  mNorFlashDeviceCount;
+
+UINT32
+NorFlashReadStatusRegister (
+  IN NOR_FLASH_INSTANCE  *Instance,
+  IN UINTN   SR_Address
+  )
+{
+  // Prepare to read the status register
+  SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, 
P30_CMD_READ_STATUS_REGISTER);
+  return MmioRead32 (Instance->DeviceBaseAddress);
+}
+
+STATIC
+BOOLEAN
+NorFlashBlockIsLocked (
+  IN NOR_FLASH_INSTANCE  *Instance,
+  IN UINTN   BlockAddress
+  )
+{
+  UINT32  LockStatus;
+
+  // Send command for reading device id
+  SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID);
+
+  // Read block lock status
+  LockStatus = MmioRead32 (CREATE_NOR_ADDRESS (BlockAddress, 2));
+
+  // Decode block lock status
+  LockStatus = FOLD_32BIT_INTO_16BIT (LockStatus);
+
+  if ((LockStatus & 0x2) != 0) {
+DEBUG ((DEBUG_ERROR, "NorFlashBlockIsLocked: WARNING: Block LOCKED 
DOWN\n"));
+  }
+
+  return ((LockStatus & 0x1) != 0);
+}
+
+STATIC
+EFI_STATUS
+NorFlashUnlockSingleBlock (
+  IN NOR_FLASH_INSTANCE  *Instance,
+  IN UINTN   BlockAddress
+  )
+{
+  UINT32  LockStatus;
+
+  // Raise the Task Priority Level to TPL_NOTIFY to serialise all its 
operations
+  // and to protect shared data structures.
+
+  if (FeaturePcdGet (PcdNorFlashCheckBlockLocked) == TRUE) {
+do {
+  // Request a lock setup
+  SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_LOCK_BLOCK_SETUP);
+
+  // Request an unlock
+  SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_UNLOCK_BLOCK);
+
+  // Send command for reading device id
+  SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID);
+
+  // Read block lock status
+  LockStatus = MmioRead32 (CREATE_NOR_ADDRESS (BlockAddress, 2));
+
+  // Decode block lock status
+  LockStatus = FOLD_32BIT_INTO_16BIT (LockStatus);
+} while ((LockStatus & 0x1) == 1);
+  } else {
+// Request a lock setup
+SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_LOCK_BLOCK_SETUP);
+
+// Request an unlock
+SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_UNLOCK_BLOCK);
+
+// Wait until the status register gives us the all clear
+do {
+  LockStatus = NorFlashReadStatusRegister (Instance, BlockAddress);
+} while ((LockStatus & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE);
+  }
+
+  // Put device back into Read Array mode
+  SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_READ_ARRAY);
+
+  DEBUG ((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x\n", 
BlockAddress));
+
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+NorFlashUnlockSingleBlockIfNecessary (
+  IN NOR_FLASH_INSTANCE  *Instance,
+  IN UINTN   BlockAddress
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = EFI_SUCCESS;
+
+  if (NorFlashBlockIsLocked (Instance, BlockAddress)) {
+Status = NorFlashUnlockSingleBlock (Instance, BlockAddress);
+  }
+
+  return Status;
+}
+
+/**
+ * The following function presumes that the block has already been unlocked.
+ **/
+EFI_STATUS
+NorFlashEraseSingleBlock (
+  IN NOR_FLASH_INSTANCE  *Instance,
+  IN UINTN   BlockAddress
+  )
+{
+  EFI_STATUS  Status;
+  UINT32  StatusRegister;
+
+  Status = EFI_SUCCESS;
+
+  // Request a block erase and then confirm it
+  SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_BLOCK_ERASE_SETUP);
+  SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_BLOCK_ERASE_CONFIRM);
+

[edk2-devel] [PATCH 03/11] OvmfPkg/VirtNorFlashDxe: remove CheckBlockLocked feature

2022-10-24 Thread Ard Biesheuvel
We inherited a feature from the ArmPlatformPkg version of this driver
that never gets enabled. Let's remove it.

Signed-off-by: Ard Biesheuvel 
---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c  | 35 +---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf |  3 --
 2 files changed, 8 insertions(+), 30 deletions(-)

diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
index 12fa720dad84..59a562efdf36 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
@@ -65,35 +65,16 @@ NorFlashUnlockSingleBlock (
   // Raise the Task Priority Level to TPL_NOTIFY to serialise all its 
operations
   // and to protect shared data structures.
 
-  if (FeaturePcdGet (PcdNorFlashCheckBlockLocked) == TRUE) {
-do {
-  // Request a lock setup
-  SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_LOCK_BLOCK_SETUP);
+  // Request a lock setup
+  SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_LOCK_BLOCK_SETUP);
 
-  // Request an unlock
-  SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_UNLOCK_BLOCK);
+  // Request an unlock
+  SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_UNLOCK_BLOCK);
 
-  // Send command for reading device id
-  SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID);
-
-  // Read block lock status
-  LockStatus = MmioRead32 (CREATE_NOR_ADDRESS (BlockAddress, 2));
-
-  // Decode block lock status
-  LockStatus = FOLD_32BIT_INTO_16BIT (LockStatus);
-} while ((LockStatus & 0x1) == 1);
-  } else {
-// Request a lock setup
-SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_LOCK_BLOCK_SETUP);
-
-// Request an unlock
-SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_UNLOCK_BLOCK);
-
-// Wait until the status register gives us the all clear
-do {
-  LockStatus = NorFlashReadStatusRegister (Instance, BlockAddress);
-} while ((LockStatus & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE);
-  }
+  // Wait until the status register gives us the all clear
+  do {
+LockStatus = NorFlashReadStatusRegister (Instance, BlockAddress);
+  } while ((LockStatus & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE);
 
   // Put device back into Read Array mode
   SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_READ_ARRAY);
diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
index 1bf50e482391..53e9d5820488 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
@@ -24,7 +24,6 @@ [Sources.common]
   VirtNorFlashFvb.c
 
 [Packages]
-  ArmPlatformPkg/ArmPlatformPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
@@ -66,7 +65,5 @@ [Pcd.common]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
 
-  gArmPlatformTokenSpaceGuid.PcdNorFlashCheckBlockLocked
-
 [Depex]
   gEfiCpuArchProtocolGuid
-- 
2.35.1



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




[edk2-devel] [PATCH 04/11] OvmfPkg/VirtNorFlashDxe: remove disk I/O protocol implementation

2022-10-24 Thread Ard Biesheuvel
We only use NOR flash for firmware volumes, either for executable images
or for the variable store. So we have no need for exposing disk I/O on
top of the NOR flash partitions so let's remove it.

Signed-off-by: Ard Biesheuvel 
---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c   | 129 
 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h   |  29 -
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c | 123 ---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c|   8 --
 4 files changed, 289 deletions(-)

diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
index 59a562efdf36..1094d48f7de4 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c
@@ -788,135 +788,6 @@ NorFlashWriteSingleBlock (
   return EFI_SUCCESS;
 }
 
-/*
-  Although DiskIoDxe will automatically install the DiskIO protocol whenever
-  we install the BlockIO protocol, its implementation is sub-optimal as it 
reads
-  and writes entire blocks using the BlockIO protocol. In fact we can access
-  NOR flash with a finer granularity than that, so we can improve performance
-  by directly producing the DiskIO protocol.
-*/
-
-/**
-  Read BufferSize bytes from Offset into Buffer.
-
-  @param  This  Protocol instance pointer.
-  @param  MediaId   Id of the media, changes every time the media 
is replaced.
-  @param  OffsetThe starting byte offset to read from
-  @param  BufferSizeSize of Buffer
-  @param  BufferBuffer containing read data
-
-  @retval EFI_SUCCESS   The data was read correctly from the device.
-  @retval EFI_DEVICE_ERROR  The device reported an error while performing 
the read.
-  @retval EFI_NO_MEDIA  There is no media in the device.
-  @retval EFI_MEDIA_CHANGED The MediaId does not match the current device.
-  @retval EFI_INVALID_PARAMETER The read request contains device addresses 
that are not
-valid for the device.
-
-**/
-EFI_STATUS
-EFIAPI
-NorFlashDiskIoReadDisk (
-  IN EFI_DISK_IO_PROTOCOL  *This,
-  IN UINT32MediaId,
-  IN UINT64DiskOffset,
-  IN UINTN BufferSize,
-  OUT VOID *Buffer
-  )
-{
-  NOR_FLASH_INSTANCE  *Instance;
-  UINT32  BlockSize;
-  UINT32  BlockOffset;
-  EFI_LBA Lba;
-
-  Instance = INSTANCE_FROM_DISKIO_THIS (This);
-
-  if (MediaId != Instance->Media.MediaId) {
-return EFI_MEDIA_CHANGED;
-  }
-
-  BlockSize = Instance->Media.BlockSize;
-  Lba   = (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, 
&BlockOffset);
-
-  return NorFlashRead (Instance, Lba, BlockOffset, BufferSize, Buffer);
-}
-
-/**
-  Writes a specified number of bytes to a device.
-
-  @param  This   Indicates a pointer to the calling context.
-  @param  MediaIdID of the medium to be written.
-  @param  Offset The starting byte offset on the logical block I/O device 
to write.
-  @param  BufferSize The size in bytes of Buffer. The number of bytes to write 
to the device.
-  @param  Buffer A pointer to the buffer containing the data to be written.
-
-  @retval EFI_SUCCESS   The data was written correctly to the device.
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.
-  @retval EFI_DEVICE_ERROR  The device reported an error while performing 
the write.
-  @retval EFI_NO_MEDIA  There is no media in the device.
-  @retval EFI_MEDIA_CHANGED The MediaId does not match the current device.
-  @retval EFI_INVALID_PARAMETER The write request contains device addresses 
that are not
- valid for the device.
-
-**/
-EFI_STATUS
-EFIAPI
-NorFlashDiskIoWriteDisk (
-  IN EFI_DISK_IO_PROTOCOL  *This,
-  IN UINT32MediaId,
-  IN UINT64DiskOffset,
-  IN UINTN BufferSize,
-  IN VOID  *Buffer
-  )
-{
-  NOR_FLASH_INSTANCE  *Instance;
-  UINT32  BlockSize;
-  UINT32  BlockOffset;
-  EFI_LBA Lba;
-  UINTN   RemainingBytes;
-  UINTN   WriteSize;
-  EFI_STATUS  Status;
-
-  Instance = INSTANCE_FROM_DISKIO_THIS (This);
-
-  if (MediaId != Instance->Media.MediaId) {
-return EFI_MEDIA_CHANGED;
-  }
-
-  BlockSize = Instance->Media.BlockSize;
-  Lba   = (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, 
&BlockOffset);
-
-  RemainingBytes = BufferSize;
-
-  // Write either all the remaining bytes, or the number of bytes that bring
-  // us up to a block boundary, whichever is less.
-  // (DiskOffset | (BlockSize - 1)) + 1) rounds DiskOffset up to the next
-  // block boundary (even if it is already on one).
-  WriteSize = MIN (RemainingBytes, ((DiskOffset | (BlockSize - 1)) + 1) - 
DiskOffset);
-
-  do {
-if (WriteSize == BlockSize) {
-  // Write a full block
-  Status = NorFlashWriteF

[edk2-devel] [PATCH 01/11] OvmfPkg: clone NorFlashPlatformLib into VirtNorFlashPlatformLib

2022-10-24 Thread Ard Biesheuvel
Create a new library class in Ovmf that duplicates the existing
NorFlashPlatformLib, but which will be tied to the VirtNorFlashDxe
driver that will be introduced in a subsequent patch. This allows us to
retire the original from ArmPlatformPkg.

Signed-off-by: Ard Biesheuvel 
---
 OvmfPkg/Include/Library/VirtNorFlashPlatformLib.h | 30 
 OvmfPkg/OvmfPkg.dec   |  4 +++
 2 files changed, 34 insertions(+)

diff --git a/OvmfPkg/Include/Library/VirtNorFlashPlatformLib.h 
b/OvmfPkg/Include/Library/VirtNorFlashPlatformLib.h
new file mode 100644
index ..d2128a032714
--- /dev/null
+++ b/OvmfPkg/Include/Library/VirtNorFlashPlatformLib.h
@@ -0,0 +1,30 @@
+/** @file
+
+ Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ **/
+
+#ifndef _VIRTNORFLASHPLATFORMLIB_H_
+#define _VIRTNORFLASHPLATFORMLIB_H_
+
+typedef struct {
+  UINTNDeviceBaseAddress;   // Start address of the Device Base 
Address (DBA)
+  UINTNRegionBaseAddress;   // Start address of one single region
+  UINTNSize;
+  UINTNBlockSize;
+} VIRT_NOR_FLASH_DESCRIPTION;
+
+EFI_STATUS
+VirtNorFlashPlatformInitialization (
+  VOID
+  );
+
+EFI_STATUS
+VirtNorFlashPlatformGetDevices (
+  OUT VIRT_NOR_FLASH_DESCRIPTION  **NorFlashDescriptions,
+  OUT UINT32  *Count
+  );
+
+#endif /* _VIRTNORFLASHPLATFORMLIB_H_ */
diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index f13dd4a61f01..5f5556c67c6c 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -101,6 +101,10 @@ [LibraryClasses]
   #  transports.
   VirtioMmioDeviceLib|Include/Library/VirtioMmioDeviceLib.h
 
+  ##  @libraryclass  Provides a Nor flash interface.
+  #
+  VirtNorFlashPlatformLib|Include/Library/VirtNorFlashPlatformLib.h
+
   ##  @libraryclass  Invoke Xen hypercalls
   #
   XenHypercallLib|Include/Library/XenHypercallLib.h
-- 
2.35.1



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




[edk2-devel] [PATCH 00/11] ArmVirtPkg: introduce VirtNorFlashDxe

2022-10-24 Thread Ard Biesheuvel
Create a new driver VirtNorFlashDxe that targets QEMU and KvmTool's NOR
flash emulation specifically, and retire the ArmPlatformPkg one.

This permits new virt implementations to wire up QEMU's NOR flash
emulation without having to rely on ARM specific packages. It also
permits us to implement some tweaks to work around some rough
performance edges of KVM memslot backed NOR flash.

Cc: Gerd Hoffmann 
Cc: Sunil V L 
Cc: Sami Mujawar 
Cc: Leif Lindholm 

Ard Biesheuvel (11):
  OvmfPkg: clone NorFlashPlatformLib into VirtNorFlashPlatformLib
  OvmfPkg/VirtNorFlashDxe: clone ArmPlatformPkg's NOR flash driver
  OvmfPkg/VirtNorFlashDxe: remove CheckBlockLocked feature
  OvmfPkg/VirtNorFlashDxe: remove disk I/O protocol implementation
  OvmfPkg/VirtNorFlashDxe: drop block I/O protocol implementation
  OvmfPkg/VirtNorFlashDxe: avoid array mode switch after each word write
  OvmfPkg/VirtNorFlashDxe: avoid switching between modes in a tight loop
  OvmfPkg/VirtNorFlashDxe: use EFI_MEMORY_WC and drop AlignedCopyMem()
  ArmVirtPkg/ArmVirtQemu: migrate to OVMF's VirtNorFlashDxe
  ArmVirtPkg/ArmVirtKvmTool: Migrate to OVMF's VirtNorFlashDxe
  ArmPlatformPkg: Retire NorFlashDxe driver

 ArmPlatformPkg/ArmPlatformPkg.dec  
   |   6 -
 ArmPlatformPkg/ArmPlatformPkg.dsc  
   |   6 -
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c
   | 123 -
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c  
   | 383 ---
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf
   |  66 ---
 ArmPlatformPkg/Library/NorFlashPlatformNullLib/NorFlashPlatformNullLib.c   
   |  28 --
 ArmPlatformPkg/Library/NorFlashPlatformNullLib/NorFlashPlatformNullLib.inf 
   |  24 -
 ArmVirtPkg/ArmVirtKvmTool.dsc  
   |   4 +-
 ArmVirtPkg/ArmVirtKvmTool.fdf  
   |   2 +-
 ArmVirtPkg/ArmVirtQemu.dsc 
   |   4 +-
 ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc   
   |   2 +-
 ArmVirtPkg/ArmVirtQemuKernel.dsc   
   |   4 +-
 ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtool.c
   |  20 +-
 ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf   
   |   4 +-
 ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c   
   |  12 +-
 ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf 
   |   4 +-
 ArmPlatformPkg/Include/Library/NorFlashPlatformLib.h => 
OvmfPkg/Include/Library/VirtNorFlashPlatformLib.h |  16 +-
 OvmfPkg/OvmfPkg.dec
   |   4 +
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c => 
OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c   | 492 

 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.h => 
OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h   |  83 +---
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c => 
OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c |  77 +--
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf => 
OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf |  39 +-
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c => 
OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c |  62 +--
 23 files changed, 205 insertions(+), 1260 deletions(-)
 delete mode 100644 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c
 delete mode 100644 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c
 delete mode 100644 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf
 delete mode 100644 
ArmPlatformPkg/Library/NorFlashPlatformNullLib/NorFlashPlatformNullLib.c
 delete mode 100644 
ArmPlatformPkg/Library/NorFlashPlatformNullLib/NorFlashPlatformNullLib.inf
 rename ArmPlatformPkg/Include/Library/NorFlashPlatformLib.h => 
OvmfPkg/Include/Library/VirtNorFlashPlatformLib.h (52%)
 rename ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c => 
OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c (54%)
 rename ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.h => 
OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h (78%)
 rename ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c => 
OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c (85%)
 rename ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf => 
OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf (78%)
 rename ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.

[edk2-devel] [PATCH V1 2/2] CryptoPkg: Need to enable crypto functions

2022-10-24 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3992

Enable CryptAes for PEI phase.
Enable CryptHkdf for SMM phase.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf | 2 +-
 CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
index b1629647f9c6..ee5f3cd5d4b6 100644
--- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
@@ -43,7 +43,7 @@ [Sources]
   Hash/CryptParallelHashNull.c
   Hmac/CryptHmac.c
   Kdf/CryptHkdf.c
-  Cipher/CryptAesNull.c
+  Cipher/CryptAes.c
   Cipher/CryptAeadAesGcmNull.c
   Pk/CryptRsaBasic.c
   Pk/CryptRsaExtNull.c
diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
index 0af7a3f96e8f..cc5a53ca92cd 100644
--- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
@@ -43,7 +43,7 @@ [Sources]
   Hash/CryptCShake256.c
   Hash/CryptParallelHash.c
   Hmac/CryptHmac.c
-  Kdf/CryptHkdfNull.c
+  Kdf/CryptHkdf.c
   Cipher/CryptAes.c
   Cipher/CryptAeadAesGcmNull.c
   Pk/CryptRsaBasic.c
-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH V1 1/2] CryptoPkg: Sha1 functions causing build errors

2022-10-24 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3991

Fix build issue when DiSABLE_SHA1_DEPRECATED_INTERFACES
is defined. Percolate the #ifndef DiSABLE_SHA1_DEPRECATED_INTERFACES
to all the Sha1 functions.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c 
b/CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c
index f9796b215865..ede9fa8c09ec 100644
--- a/CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c
+++ b/CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c
@@ -6,7 +6,7 @@
   This API, when called, will calculate the Hash using the
   hashing algorithm specified by PcdHashApiLibPolicy.
 
-  Copyright (c) 2020, Intel Corporation. All rights reserved.
+  Copyright (c) 2020-2022, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -33,9 +33,11 @@ HashApiGetContextSize (
   )
 {
   switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ #ifndef DISABLE_SHA1_DEPRECATED_INTERFACES
 case HASH_ALG_SHA1:
   return Sha1GetContextSize ();
   break;
+ #endif
 
 case HASH_ALG_SHA256:
   return Sha256GetContextSize ();
@@ -75,9 +77,11 @@ HashApiInit (
   )
 {
   switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ #ifndef DISABLE_SHA1_DEPRECATED_INTERFACES
 case HASH_ALG_SHA1:
   return Sha1Init (HashContext);
   break;
+ #endif
 
 case HASH_ALG_SHA256:
   return Sha256Init (HashContext);
@@ -119,9 +123,11 @@ HashApiDuplicate (
   )
 {
   switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ #ifndef DISABLE_SHA1_DEPRECATED_INTERFACES
 case HASH_ALG_SHA1:
   return Sha1Duplicate (HashContext, NewHashContext);
   break;
+ #endif
 
 case HASH_ALG_SHA256:
   return Sha256Duplicate (HashContext, NewHashContext);
@@ -165,9 +171,11 @@ HashApiUpdate (
   )
 {
   switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ #ifndef DISABLE_SHA1_DEPRECATED_INTERFACES
 case HASH_ALG_SHA1:
   return Sha1Update (HashContext, DataToHash, DataToHashLen);
   break;
+ #endif
 
 case HASH_ALG_SHA256:
   return Sha256Update (HashContext, DataToHash, DataToHashLen);
@@ -209,9 +217,11 @@ HashApiFinal (
   )
 {
   switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ #ifndef DISABLE_SHA1_DEPRECATED_INTERFACES
 case HASH_ALG_SHA1:
   return Sha1Final (HashContext, Digest);
   break;
+ #endif
 
 case HASH_ALG_SHA256:
   return Sha256Final (HashContext, Digest);
@@ -255,9 +265,11 @@ HashApiHashAll (
   )
 {
   switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ #ifndef DISABLE_SHA1_DEPRECATED_INTERFACES
 case HASH_ALG_SHA1:
   return Sha1HashAll (DataToHash, DataToHashLen, Digest);
   break;
+ #endif
 
 case HASH_ALG_SHA256:
   return Sha256HashAll (DataToHash, DataToHashLen, Digest);
-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH V1 0/2] CryptoPkg bug fixes

2022-10-24 Thread Judah Vang
https://bugzilla.tianocore.org/show_bug.cgi?id=3991
https://bugzilla.tianocore.org/show_bug.cgi?id=3992

There is a #define to deprecate Sha1 functions but not
all the Sha1 function are wrapped around this #define causing
a build error. The fix is to wrap all Sha1 functions with
the #define.

Need crypto AES to be supported for PEI phase and need
crypto KDF to be supported for SMM phase.

Judah Vang (2):
  CryptoPkg: Sha1 functions causing build errors
  CryptoPkg: Need to enable crypto functions

 CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf|  2 +-
 CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf|  2 +-
 CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c | 14 +-
 3 files changed, 15 insertions(+), 3 deletions(-)

-- 
2.35.1.windows.2



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




Re: [edk2-devel] [edk2-libc Patch 1/1] Python/Python3.6.8: help built-in function issue fix

2022-10-24 Thread Michael D Kinney
pushed 01c9d00fef1b086d64c6d0f383e0d299d8cf8fb7

Mike

> -Original Message-
> From: Kinney, Michael D 
> Sent: Monday, October 24, 2022 8:09 AM
> To: Kadapathri, Ajay ; devel@edk2.groups.io; 
> Kinney, Michael D 
> Cc: Rebecca Cran ; Jayaprakash, N 
> 
> Subject: RE: [edk2-libc Patch 1/1] Python/Python3.6.8: help built-in function 
> issue fix
> 
> Reviewed-by: Michael D Kinney 
> 
> 
> > -Original Message-
> > From: Kadapathri, Ajay 
> > Sent: Friday, October 21, 2022 3:57 AM
> > To: devel@edk2.groups.io
> > Cc: Rebecca Cran ; Kinney, Michael D 
> > ; Jayaprakash, N
> > 
> > Subject: [edk2-libc Patch 1/1] Python/Python3.6.8: help built-in function 
> > issue fix
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4107
> >
> > Observed that help built-in function in Python UEFI interpreter is
> > not giving the full help text information of python constructs such
> > as functions, objects , class and etc.
> >
> > This patch request fixes this issue, once this patch is applied
> > We can get full text help information of python constructs
> >
> > Cc: Rebecca Cran 
> > Cc: Michael D Kinney 
> > Cc: Jayaprakash N 
> > Signed-off-by: Ajay Kadapathri 
> > ---
> >  .../Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h   | 5 +
> >  1 file changed, 5 insertions(+)
> >
> > diff --git 
> > a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h 
> > b/AppPkg/Applications/Python/Python-
> > 3.6.8/PyMod-3.6.8/Include/pyconfig.h
> > index c447614..f1cb309 100644
> > --- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h
> > +++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h
> > @@ -1155,8 +1155,13 @@
> >  /* Define if WINDOW in curses.h offers a field _flags. */
> >  #undef WINDOW_HAS_FLAGS
> >
> > +#ifdef UEFI_C_SOURCE
> > +/* Define if you want documentation strings in extension modules */
> > +#define WITH_DOC_STRINGS 1
> > +#else
> >  /* Define if you want documentation strings in extension modules */
> >  #undef WITH_DOC_STRINGS
> > +#endif
> >
> >  /* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) 
> > dynamic
> > linker (dyld) instead of the old-style (NextStep) dynamic linker (rld).
> > --
> > 2.37.1.windows.1



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




Re: [edk2-devel] [PATCH v7 0/7] Add safe unaccepted memory behavior

2022-10-24 Thread Dionna Glaze via groups.io
>
> Hey!
>
> Sorry if this was asked. I was wondering if this patchset is in some git repo 
> which I pull from as I struggle to get a buildable tree by applying this 
> patchset to whatever I can find.
>
> I tried https://github.com/deeglaze/edk2.git   enable_umv7 but it does not 
> build (missing ExitBootServicesCallback.h and PrePiHob.h).
> I tried rebasing it on top of https://github.com/mxu9/edk2.git   
> lazyaccept.v1/2/3/4 but it seems only v1 kinda works but see the above and 
> other versions have some reworks (EFI_RESOURCE_MEMORY_UNACCEPTED vs. 
> BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED.
>
> Thanks!

Oh that would be because I forgot to git add those files (it built on
my machine TM). The callback.h file is from a previous version of this
series that can be removed. PrePiHob.h is from a lazy accept patch,
"MdePkg: Add UEFI Unaccepted memory definition". I can send out a v8
that removes the unnecessary #include and changes the names to those
suggested in the 3987 bug. I'll fix my github branch to include the
missing file.

Thanks for trying this patch series :)

-- 
-Dionna Glaze, PhD (she/her)


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




Re: [edk2-devel] [edk2-libc Patch 1/1] Python/Python3.6.8: help built-in function issue fix

2022-10-24 Thread Michael D Kinney
Reviewed-by: Michael D Kinney 


> -Original Message-
> From: Kadapathri, Ajay 
> Sent: Friday, October 21, 2022 3:57 AM
> To: devel@edk2.groups.io
> Cc: Rebecca Cran ; Kinney, Michael D 
> ; Jayaprakash, N
> 
> Subject: [edk2-libc Patch 1/1] Python/Python3.6.8: help built-in function 
> issue fix
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4107
> 
> Observed that help built-in function in Python UEFI interpreter is
> not giving the full help text information of python constructs such
> as functions, objects , class and etc.
> 
> This patch request fixes this issue, once this patch is applied
> We can get full text help information of python constructs
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Cc: Jayaprakash N 
> Signed-off-by: Ajay Kadapathri 
> ---
>  .../Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h   | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git 
> a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h 
> b/AppPkg/Applications/Python/Python-
> 3.6.8/PyMod-3.6.8/Include/pyconfig.h
> index c447614..f1cb309 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h
> +++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Include/pyconfig.h
> @@ -1155,8 +1155,13 @@
>  /* Define if WINDOW in curses.h offers a field _flags. */
>  #undef WINDOW_HAS_FLAGS
> 
> +#ifdef UEFI_C_SOURCE
> +/* Define if you want documentation strings in extension modules */
> +#define WITH_DOC_STRINGS 1
> +#else
>  /* Define if you want documentation strings in extension modules */
>  #undef WITH_DOC_STRINGS
> +#endif
> 
>  /* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) 
> dynamic
> linker (dyld) instead of the old-style (NextStep) dynamic linker (rld).
> --
> 2.37.1.windows.1



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




Re: [edk2-devel] [PATCH 1/1] OvmfPkg/SmbiosPlatformDxe: use PcdFirmwareVersionString

2022-10-24 Thread Ard Biesheuvel
On Wed, 12 Oct 2022 at 10:52, Gerd Hoffmann  wrote:
>
> On Tue, Oct 11, 2022 at 09:34:17AM -0600, Rebecca Cran wrote:
> > On 10/11/22 01:59, Gerd Hoffmann wrote:
> > >
> > > Next question is how to set them.  I think it makes sense to have some
> > > sensible defaults, but still allow to override them.  MdeModulePkg
> > > defines them to empty strings (except vendor).  Should we set them to
> > > the most recent stable tag instead, i.e. something like this?
> > >
> > > -  
> > > gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L""|VOID*|0x00010052
> > > +  
> > > gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"edk2-stable202208"|VOID*|0x00010052
> > >
> > > -  
> > > gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString|L""|VOID*|0x00010053
> > > +  
> > > gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString|L"26/08/2022"|VOID*|0x00010053
> > >
> > > When doing that:  Can this be overridden on the command line?  Trying to
> > > do so using 'build --pcd PcdFirmwareVersionString=Test' didn't work for
> > > me, the string wasn't translated to unicode ...
> > >
> > > I've noticed ArmVirtPkg/ArmVirtXen.dsc has this line ...
> > >
> > >
> > > gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"$(FIRMWARE_VER)"
> > >
> > > ... which allows to override using 'build -D FIRMWARE_VER=Test'.
> > > Unicode encoding works that way, but it would also override the
> > > MdeModulePkg default (if we add one).
> >
> > The method I've used in the past is to override strings on the command line,
> > just like ArmVirtXen.dsc does, and I like that approach.
>
> After digging around in the source code and experimenting a bit
> I figured how to do it without the FIRMWARE_VER indirection:
>
> build --pcd="PcdFirmwareVersionString=L'${version}\\0'"
>
> > I like the idea of defaulting to the stable tag, though we could perhaps
> > shorten it to "202208" instead?
>
> I'd prefer to keep it identical to the stable tag name.
> Makes it easier to figure where this comes from.
>
> > I'm fairly sure the release date should be
> > in MM/DD/ format for e.g. SMBIOS compatibility (sigh)
>
> Hmm.  At least we tag stable releases close to the end of the month
> (after 12th), so it should be clear what is DD and what is MM ...
>

Is there a conclusion here?


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




Re: [edk2-devel] [PATCH] BaseTools/Tests: Use quotes around PYTHON_COMMAND

2022-10-24 Thread Bob Feng
Reviewed-by: Bob Feng 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Ard Biesheuvel
Sent: Monday, October 24, 2022 2:17 PM
To: devel@edk2.groups.io
Cc: quic_llind...@quicinc.com; Gao, Liming ; Feng, 
Bob C ; rebe...@bsdio.com; Ard Biesheuvel 

Subject: [edk2-devel] [PATCH] BaseTools/Tests: Use quotes around PYTHON_COMMAND

Commit ("2355f0c09c52 BaseTools: Fix check for ${PYTHON_COMMAND} in
Tests/GNUmakefile") fixed a latent issue in the BaseTools/Tests Makefile, but 
inadvertently broke the BaseTools build for cases where PYTHON_COMMAND is not 
set. As it turns out, running 'command' without a command argument makes the 
invocation succeed, causing the empty variable to be evaluated and called later.

Let's put double quotes around PYTHON_COMMAND in the invocation of 'command' 
and force it to fail when PYTHON_COMMAND is not set.

Signed-off-by: Ard Biesheuvel 
---
 BaseTools/Tests/GNUmakefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Tests/GNUmakefile b/BaseTools/Tests/GNUmakefile index 
caa4d26c9ba6..20b387864f74 100644
--- a/BaseTools/Tests/GNUmakefile
+++ b/BaseTools/Tests/GNUmakefile
@@ -8,7 +8,7 @@
 all: test  test:-  @if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then 
${PYTHON_COMMAND} RunTests.py; else python RunTests.py; fi+  @if command -v 
"${PYTHON_COMMAND}" >/dev/null 2>&1; then ${PYTHON_COMMAND} RunTests.py; else 
python RunTests.py; fi  clean: find . -name '*.pyc' -exec rm '{}' ';'-- 
2.35.1



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




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




Re: [edk2-devel] [PATCH] BaseTools/Tests: Use quotes around PYTHON_COMMAND

2022-10-24 Thread Ard Biesheuvel
Liming, Bob: could i get an ack on this please? Our CI is currently
broken due to this issue.


On Mon, 24 Oct 2022 at 08:16, Ard Biesheuvel  wrote:
>
> Commit ("2355f0c09c52 BaseTools: Fix check for ${PYTHON_COMMAND} in
> Tests/GNUmakefile") fixed a latent issue in the BaseTools/Tests
> Makefile, but inadvertently broke the BaseTools build for cases where
> PYTHON_COMMAND is not set. As it turns out, running 'command' without a
> command argument makes the invocation succeed, causing the empty
> variable to be evaluated and called later.
>
> Let's put double quotes around PYTHON_COMMAND in the invocation of
> 'command' and force it to fail when PYTHON_COMMAND is not set.
>
> Signed-off-by: Ard Biesheuvel 
> ---
>  BaseTools/Tests/GNUmakefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/BaseTools/Tests/GNUmakefile b/BaseTools/Tests/GNUmakefile
> index caa4d26c9ba6..20b387864f74 100644
> --- a/BaseTools/Tests/GNUmakefile
> +++ b/BaseTools/Tests/GNUmakefile
> @@ -8,7 +8,7 @@
>  all: test
>
>  test:
> -   @if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then 
> ${PYTHON_COMMAND} RunTests.py; else python RunTests.py; fi
> +   @if command -v "${PYTHON_COMMAND}" >/dev/null 2>&1; then 
> ${PYTHON_COMMAND} RunTests.py; else python RunTests.py; fi
>
>  clean:
> find . -name '*.pyc' -exec rm '{}' ';'
> --
> 2.35.1
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95501): https://edk2.groups.io/g/devel/message/95501
Mute This Topic: https://groups.io/mt/94528814/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 V4 04/14] Platform/Loongson: Add QemuFwCfgLib.

2022-10-24 Thread xianglai
QemuFwCfgLib for PEI phase.
This library obtains the QemuFWCfg base address by
directly parsing the fdt, and reads and writes the data
in the QemuFWCfg by operating on the QemuFWCfg base address.

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

Signed-off-by: xianglai li 
---
 .../Include/IndustryStandard/QemuFwCfg.h  |  95 
 .../Include/Library/QemuFwCfgLib.h| 193 +++
 .../QemuFwCfgLib/QemuFwCfgLibInternal.h   |  64 +++
 .../Library/QemuFwCfgLib/QemuFwCfgPei.c   | 119 +
 .../Library/QemuFwCfgLib/QemuFwCfgPeiLib.c| 477 ++
 .../Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf  |  44 ++
 6 files changed, 992 insertions(+)
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Include/IndustryStandard/QemuFwCfg.h
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Include/Library/QemuFwCfgLib.h
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.c
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf

diff --git 
a/Platform/Loongson/LoongArchQemuPkg/Include/IndustryStandard/QemuFwCfg.h 
b/Platform/Loongson/LoongArchQemuPkg/Include/IndustryStandard/QemuFwCfg.h
new file mode 100644
index 00..a028ca1124
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Include/IndustryStandard/QemuFwCfg.h
@@ -0,0 +1,95 @@
+/** @file
+  Macro and type definitions corresponding to the QEMU fw_cfg interface.
+
+  Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Glossary:
+- FW - FireWare
+- CFG- Configure
+- FNAME- File Name
+- CTL- Contorl
+**/
+
+#ifndef QEMU_FW_CFG_H_
+#define QEMU_FW_CFG_H_
+
+#include 
+
+//
+// The size, in bytes, of names of firmware configuration files, including at
+// least one terminating NUL byte.
+//
+#define QEMU_FW_CFG_FNAME_SIZE  56
+
+//
+// If the following bit is set in the UINT32 fw_cfg revision / feature bitmap
+// -- read from key 0x0001 with the basic IO Port or MMIO method --, then the
+// DMA interface is available.
+//
+#define FW_CFG_F_DMA BIT1
+
+//
+// Macros for the FW_CFG_DMA_ACCESS.Control bitmap (in native encoding).
+//
+#define FW_CFG_DMA_CTL_ERROR BIT0
+#define FW_CFG_DMA_CTL_READ  BIT1
+#define FW_CFG_DMA_CTL_SKIP  BIT2
+#define FW_CFG_DMA_CTL_SELECTBIT3
+#define FW_CFG_DMA_CTL_WRITE BIT4
+
+//
+// The fw_cfg registers can be found at these IO Ports, on the IO-mapped
+// platforms (Ia32 and X64).
+//
+#define FW_CFG_IO_SELECTOR  0x510
+#define FW_CFG_IO_DATA  0x511
+#define FW_CFG_IO_DMA_ADDRESS   0x514
+
+//
+// Numerically defined keys.
+//
+typedef enum {
+  QemuFwCfgItemSignature= 0x,
+  QemuFwCfgItemInterfaceVersion = 0x0001,
+  QemuFwCfgItemSystemUuid   = 0x0002,
+  QemuFwCfgItemRamSize  = 0x0003,
+  QemuFwCfgItemGraphicsEnabled  = 0x0004,
+  QemuFwCfgItemSmpCpuCount  = 0x0005,
+  QemuFwCfgItemMachineId= 0x0006,
+  QemuFwCfgItemKernelAddress= 0x0007,
+  QemuFwCfgItemKernelSize   = 0x0008,
+  QemuFwCfgItemKernelCommandLine= 0x0009,
+  QemuFwCfgItemInitrdAddress= 0x000a,
+  QemuFwCfgItemInitrdSize   = 0x000b,
+  QemuFwCfgItemBootDevice   = 0x000c,
+  QemuFwCfgItemNumaData = 0x000d,
+  QemuFwCfgItemBootMenu = 0x000e,
+  QemuFwCfgItemMaximumCpuCount  = 0x000f,
+  QemuFwCfgItemKernelEntry  = 0x0010,
+  QemuFwCfgItemKernelData   = 0x0011,
+  QemuFwCfgItemInitrdData   = 0x0012,
+  QemuFwCfgItemCommandLineAddress   = 0x0013,
+  QemuFwCfgItemCommandLineSize  = 0x0014,
+  QemuFwCfgItemCommandLineData  = 0x0015,
+  QemuFwCfgItemKernelSetupAddress   = 0x0016,
+  QemuFwCfgItemKernelSetupSize  = 0x0017,
+  QemuFwCfgItemKernelSetupData  = 0x0018,
+  QemuFwCfgItemFileDir  = 0x0019,
+
+} FIRMWARE_CONFIG_ITEM;
+
+//
+// Communication structure for the DMA access method. All fields are encoded in
+// big endian.
+//
+#pragma pack (1)
+typedef struct {
+  UINT32 Control;
+  UINT32 Length;
+  UINT64 Address;
+} FW_CFG_DMA_ACCESS;
+#pragma pack ()
+
+#endif
diff --git a/Platform/Loongson/LoongArchQemuPkg/Include/Library/QemuFwCfgLib.h 
b/Platform/Loongson/LoongArchQemuPkg/Include/Library/QemuFwCfgLib.h
new file mode 100644
index 00..6b42cf3073
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Include/Library/QemuFwCfgLib.h
@@ -0,0 +1,193 @@
+/** @file
+  QEMU/KVM Firmware Configuration access
+
+  Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Glossary:
+- FW or Fw 

[edk2-devel] [edk2-platforms][PATCH V4 05/14] Platform/Loongson: Add MmuLib.

2022-10-24 Thread xianglai
Read the memory map information through the QemuFwCfg interface,
then build the page table through the memory map information,
and finally enable Mmu.

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

Signed-off-by: xianglai li 
---
 .../LoongArchQemuPkg/Include/Library/MmuLib.h |  85 ++
 .../LoongArchQemuPkg/Library/MmuLib/Mmu.S |  35 +
 .../Library/MmuLib/MmuBaseLib.inf |  35 +
 .../Library/MmuLib/MmuBaseLibPei.inf  |  42 +
 .../Library/MmuLib/MmuLibCore.c   | 908 ++
 .../Library/MmuLib/MmuLibCore.h   |  39 +
 .../Library/MmuLib/MmuLibCorePei.c| 236 +
 .../LoongArchQemuPkg/Library/MmuLib/mmu.h | 104 ++
 .../LoongArchQemuPkg/Library/MmuLib/page.h| 267 +
 .../LoongArchQemuPkg/Library/MmuLib/pte.h |  57 ++
 10 files changed, 1808 insertions(+)
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Include/Library/MmuLib.h
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/Mmu.S
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/MmuBaseLib.inf
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/MmuBaseLibPei.inf
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/MmuLibCore.c
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/MmuLibCore.h
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/MmuLibCorePei.c
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/mmu.h
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/page.h
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/pte.h

diff --git a/Platform/Loongson/LoongArchQemuPkg/Include/Library/MmuLib.h 
b/Platform/Loongson/LoongArchQemuPkg/Include/Library/MmuLib.h
new file mode 100644
index 00..6c501eca07
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Include/Library/MmuLib.h
@@ -0,0 +1,85 @@
+/** @file
+
+  Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Glossary:
+- EXC - execute
+**/
+#ifndef MMU_LIB_H_
+#define MMU_LIB_H_
+/**
+  write operation is performed Count times from the first element of Buffer.
+Convert EFI Attributes to Loongarch Attributes.
+  @param[in]  EfiAttributes Efi Attributes.
+
+  @retval  LoongArch Attributes.
+**/
+UINTN
+EfiAttributeToLoongArchAttribute (
+  IN UINTN  EfiAttributes
+  );
+
+/**
+  Finds the length and memory properties of the memory region corresponding to 
the specified base address.
+
+  @param[in]  BaseAddressTo find the base address of the memory region.
+  @param[in]  EndAddress To find the end address of the memory region.
+  @param[out]  RegionLengthThe length of the memory region found.
+  @param[out]  RegionAttributesProperties of the memory region found.
+
+  @retval  EFI_SUCCESSThe corresponding memory area was successfully found
+   EFI_NOT_FOUNDNo memory area found
+**/
+EFI_STATUS
+GetLoongArchMemoryRegion (
+  IN UINTN  BaseAddress,
+  IN UINTN  EndAddress,
+  OUTUINTN  *RegionLength,
+  OUTUINTN  *RegionAttributes
+  );
+
+/**
+  Sets the Attributes  of the specified memory region
+
+  @param[in]  BaseAddress  The base address of the memory region to set the 
Attributes.
+  @param[in]  Length   The length of the memory region to set the 
Attributes.
+  @param[in]  Attributes   The Attributes to be set.
+
+  @retval  EFI_SUCCESSThe Attributes was set successfully
+
+**/
+EFI_STATUS
+LoongArchSetMemoryAttributes (
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN UINTN Length,
+  IN UINTN Attributes
+  );
+
+/**
+  Sets the non-executable Attributes for the specified memory region
+
+  @param[in]  BaseAddress  The base address of the memory region to set the 
Attributes.
+  @param[in]  Length   The length of the memory region to set the 
Attributes.
+
+  @retval  EFI_SUCCESSThe Attributes was set successfully
+**/
+EFI_STATUS
+LoongArchSetMemoryRegionNoExec (
+  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN  UINTNLength
+  );
+/**
+  Create a page table and initialize the MMU.
+
+  @param[] VOID
+
+  @retval  VOID
+**/
+VOID
+EFIAPI
+ConfigureMmu (
+  VOID
+  );
+#endif
diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/Mmu.S 
b/Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/Mmu.S
new file mode 100644
index 00..a697b54e65
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Library/MmuLib/Mmu.S
@@ -0,0 +1,35 @@
+#--
+#
+# LoongArch for LoongArch
+#
+# Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#-
+
+#ifndef _KERNEL
+#define _KERNEL
+#endif
+
+

[edk2-devel] [edk2-platforms][PATCH V4 06/14] Platform/Loongson: Add StableTimerLib.

2022-10-24 Thread xianglai
This library provides a delay interface and a timing interface.

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

Signed-off-by: xianglai li 
---
 .../Include/Library/StableTimer.h |  43 
 .../Library/StableTimerLib/Count.S|  35 +++
 .../Library/StableTimerLib/TimerLib.c | 242 ++
 .../Library/StableTimerLib/TimerLib.inf   |  28 ++
 4 files changed, 348 insertions(+)
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Include/Library/StableTimer.h
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/StableTimerLib/Count.S
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/StableTimerLib/TimerLib.c
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/StableTimerLib/TimerLib.inf

diff --git a/Platform/Loongson/LoongArchQemuPkg/Include/Library/StableTimer.h 
b/Platform/Loongson/LoongArchQemuPkg/Include/Library/StableTimer.h
new file mode 100644
index 00..09a2d07404
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Include/Library/StableTimer.h
@@ -0,0 +1,43 @@
+/** @file
+
+  Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Glossary:
+- Csr- Cpu Status Register
+- Calc   - Calculation
+- Freq   - frequency
+**/
+
+#ifndef STABLE_TIMER_H_
+#define STABLE_TIMER_H_
+#include "Library/Cpu.h"
+
+/**
+  Gets the timer count value.
+
+  @param[] VOID
+
+  @retval  timer count value.
+**/
+extern
+UINTN
+EFIAPI
+LoongArchReadTime (
+  VOID
+  );
+
+/**
+  Calculate the timer frequency.
+
+  @param[] VOID
+
+  @retval  Timer frequency.
+**/
+UINT32
+EFIAPI
+CalcConstFreq (
+  VOID
+  );
+#endif
diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/StableTimerLib/Count.S 
b/Platform/Loongson/LoongArchQemuPkg/Library/StableTimerLib/Count.S
new file mode 100644
index 00..f22635712c
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Library/StableTimerLib/Count.S
@@ -0,0 +1,35 @@
+#--
+#
+# Count for LoongArch
+#
+# Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#--
+
+#ifndef __ASSEMBLY__
+#define  __ASSEMBLY__
+#endif
+
+#include "Library/Cpu.h"
+#include "LoongArchAsmMacro.h"
+#
+# Set cpu interrupts
+# @param A0 The interrupt number
+#
+ASM_FUNC(CpuSetIP)
+csrrd   T0, LOONGARCH_CSR_ECFG
+or  T0, T0, A0
+csrwr   T0, LOONGARCH_CSR_ECFG
+jirlZERO, RA,0
+
+#
+#Gets the timer count value.
+#
+#@param[] VOID
+#
+#@retval  timer count value.
+ASM_FUNC(LoongArchReadTime)
+rdtime.d   A0, ZERO
+jirlZERO, RA,0
diff --git 
a/Platform/Loongson/LoongArchQemuPkg/Library/StableTimerLib/TimerLib.c 
b/Platform/Loongson/LoongArchQemuPkg/Library/StableTimerLib/TimerLib.c
new file mode 100644
index 00..660a5d8b0b
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Library/StableTimerLib/TimerLib.c
@@ -0,0 +1,242 @@
+/** @file
+  Generic LoongArch implementation of TimerLib.h
+
+  Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Glossary:
+- Freq - Frequency
+- Csr  - Cpu Status Register
+- calc - calculate
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include "Library/StableTimer.h"
+#include "Library/Cpu.h"
+
+UINT32 StableTimerFreq = 0;
+
+/**
+  Calculate the timer frequency.
+
+  @param[] VOID
+
+  @retval  Timer frequency.
+**/
+UINT32
+EFIAPI
+CalcConstFreq (
+  VOID
+  )
+{
+  UINT32 Result;
+  UINT32 BaseFreq;
+  UINT32 ClockMultiplier;
+  UINT32 ClockDivide;
+
+  LOONGARCH_GET_CPUCFG (BaseFreq, LOONGARCH_CPUCFG4);
+  LOONGARCH_GET_CPUCFG (Result, LOONGARCH_CPUCFG5);
+  ClockMultiplier = Result & 0x;
+  ClockDivide = (Result >> 16) & 0x;
+
+  if ((!BaseFreq)
+|| (!ClockMultiplier)
+|| (!ClockDivide))
+  {
+return 0;
+  }
+  else {
+return (BaseFreq * ClockMultiplier / ClockDivide);
+  }
+}
+/**
+  Get the timer frequency.
+
+  @param[] VOID
+
+  @retval  Timer frequency.
+**/
+UINT32
+EFIAPI
+GetFreq (
+  VOID
+  )
+{
+  if (StableTimerFreq) {
+  } else {
+StableTimerFreq = CalcConstFreq ();
+  }
+
+  return StableTimerFreq;
+}
+
+/**
+  Stalls the CPU for at least the given number of microseconds.
+
+  Stalls the CPU for the number of microseconds specified by MicroSeconds.
+
+  @param  MicroSeconds  The minimum number of microseconds to delay.
+
+  @return MicroSeconds
+
+**/
+UINTN
+EFIAPI
+MicroSecondDelay (
+  IN  UINTN MicroSeconds
+  )
+{
+
+  UINTN Count;
+  UINTN Ticks;
+  UINTN Start;
+  UINTN End;
+
+  Count = GetFreq ();
+  Count = (Count * MicroSeconds) / 100;
+  Start = LoongArchReadTime ();
+  End = Start + Count;
+
+  do {
+Ticks = LoongArchReadTime ()

[edk2-devel] [edk2-platforms][PATCH V4 02/14] Platform/Loongson: Support SEC And Add Readme.md

2022-10-24 Thread xianglai
Add SEC Code And Readme.md for LoongArchQemu

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

Signed-off-by: xianglai li  
---
 Maintainers.txt   |   4 +
 .../Include/LoongArchAsmMacro.h   |  23 +
 .../Loongson/LoongArchQemuPkg/Loongson.dec|  36 ++
 .../Loongson/LoongArchQemuPkg/Loongson.dsc| 131 +
 .../Loongson/LoongArchQemuPkg/Loongson.fdf|  53 ++
 .../LoongArchQemuPkg/Loongson.fdf.inc |  21 +
 Platform/Loongson/LoongArchQemuPkg/Readme.md  |  59 ++
 .../LoongArchQemuPkg/Sec/LoongArch64/Start.S  |  80 +++
 .../Loongson/LoongArchQemuPkg/Sec/SecMain.c   | 510 ++
 .../Loongson/LoongArchQemuPkg/Sec/SecMain.inf |  47 ++
 Readme.md |   9 +
 11 files changed, 973 insertions(+)
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Include/LoongArchAsmMacro.h
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Loongson.dec
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Loongson.fdf
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Loongson.fdf.inc
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Readme.md
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Sec/LoongArch64/Start.S
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.c
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Sec/SecMain.inf

diff --git a/Maintainers.txt b/Maintainers.txt
index b1adf63dde..017a69df69 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -324,6 +324,10 @@ M: Bob Feng 
 M: Liming Gao 
 R: Yuwei Chen 
 
+Loongson platforms
+F: Platform/Loongson/
+M: xianglai li 
+
 Marvell platforms and silicon
 F: Platform/Marvell/
 F: Platform/SolidRun/Armada80x0McBin/
diff --git a/Platform/Loongson/LoongArchQemuPkg/Include/LoongArchAsmMacro.h 
b/Platform/Loongson/LoongArchQemuPkg/Include/LoongArchAsmMacro.h
new file mode 100644
index 00..366d4308e8
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Include/LoongArchAsmMacro.h
@@ -0,0 +1,23 @@
+/** @file
+   LoongArch ASM macro definition.
+
+   Copyright (c) 2021, Loongson Limited. All rights reserved.
+
+   SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ **/
+
+#ifndef LOONGARCH_ASM_MACRO_H_
+#define LOONGARCH_ASM_MACRO_H_
+
+#include 
+
+#define _ASM_FUNC(Name, Section)\
+  .global   Name  ; \
+  .section  #Section, "ax"; \
+  .type Name, %function   ; \
+  Name:
+
+#define ASM_FUNC(Name)_ASM_FUNC(ASM_PFX(Name), .text. ## Name)
+
+#endif // __LOONGARCH_ASM_MACRO_H__
diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.dec 
b/Platform/Loongson/LoongArchQemuPkg/Loongson.dec
new file mode 100644
index 00..8cfa63ee8a
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.dec
@@ -0,0 +1,36 @@
+## @file
+#
+#  Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  DEC_SPECIFICATION  = 0x00010005
+  PACKAGE_NAME   = LoongArchQemuPkg
+  PACKAGE_GUID   = b51d765a-41da-45fc-a537-de3ee785c0f6
+  PACKAGE_VERSION= 0.1
+
+
+#
+# Include Section - list of Include Paths that are provided by this package.
+#   Comments are used for Keywords and Module Types.
+#
+# Supported Module Types:
+#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
+#
+
+[Includes.common]
+  Include# Root include for the package
+
+[Guids]
+  gLoongArchQemuPkgTokenSpaceGuid  = { 0x0e0383ce, 0x0151, 0x4d01, { 0x80, 
0x0e, 0x3f, 0xef, 0x8b, 0x27, 0x6d, 0x52 } }
+
+[PcdsFixedAtBuild, PcdsDynamic]
+  gLoongArchQemuPkgTokenSpaceGuid.PcdFlashPeiFvBase|0x0|UINT64|0x0003
+  gLoongArchQemuPkgTokenSpaceGuid.PcdFlashPeiFvSize|0x0|UINT32|0x0004
+  gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamBase|0|UINT64|0x001c
+  gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamSize|0|UINT32|0x001d
+  gLoongArchQemuPkgTokenSpaceGuid.PcdFlashSecFvBase|0x0|UINT64|0x0028
+  gLoongArchQemuPkgTokenSpaceGuid.PcdFlashSecFvSize|0x0|UINT32|0x0029
diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc 
b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
new file mode 100644
index 00..52ab11de9a
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
@@ -0,0 +1,131 @@
+## @file
+#
+#  Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+
+#
+# Defines Section - statements that will be processed to create a Ma

[edk2-devel] [edk2-platforms][PATCH V4 03/14] Platform/Loongson: Add PeiServicesTablePointerLib.

2022-10-24 Thread xianglai
Use a register to save PeiServicesTable pointer,
This lib Provides PeiServicesTable pointer saving
and retrieval services.

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

Signed-off-by: xianglai li 
---
 .../PeiServicesTablePointer.c | 78 +++
 .../PeiServicesTablePointerLib.inf| 32 
 2 files changed, 110 insertions(+)
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf

diff --git 
a/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
 
b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
new file mode 100644
index 00..068960d4ce
--- /dev/null
+++ 
b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
@@ -0,0 +1,78 @@
+/** @file
+  PEI Services Table Pointer Library.
+
+  Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include "Library/Cpu.h"
+
+/**
+  Caches a pointer PEI Services Table.
+
+  Caches the pointer to the PEI Services Table specified by 
PeiServicesTablePointer
+  in a platform specific manner.
+
+  If PeiServicesTablePointer is NULL, then ASSERT ().
+
+  @paramPeiServicesTablePointer   The address of PeiServices pointer.
+**/
+VOID
+EFIAPI
+SetPeiServicesTablePointer (
+  IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
+  )
+{
+  LOONGARCH_CSR_WRITEQ ((UINTN)PeiServicesTablePointer, LOONGARCH_CSR_KS0);
+}
+
+/**
+  Retrieves the cached value of the PEI Services Table pointer.
+
+  Returns the cached value of the PEI Services Table pointer in a CPU specific 
manner
+  as specified in the CPU binding section of the Platform Initialization 
Pre-EFI
+  Initialization Core Interface Specification.
+
+  If the cached PEI Services Table pointer is NULL, then ASSERT ().
+
+  @return  The pointer to PeiServices.
+**/
+CONST EFI_PEI_SERVICES **
+EFIAPI
+GetPeiServicesTablePointer (
+  VOID
+  )
+{
+  UINTN  val;
+
+  LOONGARCH_CSR_READQ (val, LOONGARCH_CSR_KS0);
+  return (CONST EFI_PEI_SERVICES **)val;
+}
+
+/**
+Perform CPU specific actions required to migrate the PEI Services Table
+pointer from temporary RAM to permanent RAM.
+
+For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
+immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
+immediately preceding the Interrupt Descriptor Table (IDT) in memory.
+For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
+a dedicated CPU register.  This means that there is no memory storage
+associated with storing the PEI Services Table pointer, so no additional
+migration actions are required for Itanium or ARM CPUs.
+
+**/
+VOID
+EFIAPI
+MigratePeiServicesTablePointer (
+VOID
+)
+{
+  return;
+}
diff --git 
a/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
 
b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
new file mode 100644
index 00..6fe76d1351
--- /dev/null
+++ 
b/Platform/Loongson/LoongArchQemuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
@@ -0,0 +1,32 @@
+## @file
+#  PEI Services Table Pointer Library.
+#
+#  Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = PeiServicesTablePointerLib
+  FILE_GUID  = C3C9C4ED-EB8A-4548-BE1B-ABB0B6F35B1E
+  MODULE_TYPE= PEIM
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = PeiServicesTablePointerLib|PEIM PEI_CORE SEC
+
+#
+#  VALID_ARCHITECTURES   = LOONGARCH64
+#
+
+[Sources]
+  PeiServicesTablePointer.c
+
+[Packages]
+  Platform/Loongson/LoongArchQemuPkg/Loongson.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+
+[Pcd]
+
-- 
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95496): https://edk2.groups.io/g/devel/message/95496
Mute This Topic: https://groups.io/mt/94530573/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 V4 01/14] Platform/Loongson: Add Serial Port library

2022-10-24 Thread xianglai
Serial Port library for LoongarchQemuPkg

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

Signed-off-by: xianglai li 
---
 .../LoongArchQemuPkg/Include/Library/Cpu.h| 387 +++
 .../Include/LoongArchQemuPlatform.h   |  97 +++
 .../Library/SerialPortLib/SerialPortLib.c | 612 ++
 .../Library/SerialPortLib/SerialPortLib.inf   |  36 ++
 4 files changed, 1132 insertions(+)
 create mode 100644 Platform/Loongson/LoongArchQemuPkg/Include/Library/Cpu.h
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Include/LoongArchQemuPlatform.h
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/SerialPortLib/SerialPortLib.c
 create mode 100644 
Platform/Loongson/LoongArchQemuPkg/Library/SerialPortLib/SerialPortLib.inf

diff --git a/Platform/Loongson/LoongArchQemuPkg/Include/Library/Cpu.h 
b/Platform/Loongson/LoongArchQemuPkg/Include/Library/Cpu.h
new file mode 100644
index 00..8c3c21bd96
--- /dev/null
+++ b/Platform/Loongson/LoongArchQemuPkg/Include/Library/Cpu.h
@@ -0,0 +1,387 @@
+/** @file
+
+  Copyright (c) 2021 Loongson Technology Corporation Limited. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Glossary:
+- EXC - Exception
+- INT - Interrupt
+- FPU - Floating Point Unit
+- CSR - CPU Status Register
+- READQ   - Read Quad Word
+**/
+#ifndef LOONGARCH_CPU_H_
+#define LOONGARCH_CPU_H_
+
+/* Exception types decoded by machdep exception decoder */
+#define EXC_INT 0   /* HW interrupt */
+#define EXC_TLBL1   /* TLB miss on a load */
+#define EXC_TLBS2   /* TLB miss on a store */
+#define EXC_TLBI3   /* TLB miss on a ifetch */
+#define EXC_TLBM4   /* TLB modified fault */
+#define EXC_TLBRI   5   /* TLB Read-Inhibit exception */
+#define EXC_TLBXI   6   /* TLB Execution-Inhibit exception 
*/
+#define EXC_TLBPE   7   /* TLB Privilege Error */
+#define EXC_ADE 8   /* Address Error */
+#define EXC_ALE 9   /* Unalign Access */
+#define EXC_OOB 10  /* Out of bounds */
+#define EXC_SYS 11  /* System call */
+#define EXC_BP  12  /* Breakpoint */
+#define EXC_INE 13  /* Inst. Not Exist */
+#define EXC_IPE 14  /* Inst. Privileged Error */
+#define EXC_FPDIS   15  /* FPU Disabled */
+#define EXC_LSXDIS  16  /* LSX Disabled */
+#define EXC_LASXDIS 17  /* LASX Disabled */
+#define EXC_FPE 18  /* Floating Point Exception */
+#define EXC_WATCH   19  /* Watch address reference */
+#define EXC_BAD 255 /* Undecodeable */
+
+#define COPY_SIGCODE// copy sigcode above user stack in exec
+#define ZERO$r0 /* wired zero */
+#define RA  $r1 /* return address */
+#define GP  $r2 /* global pointer - caller saved for 
PIC */
+#define SP  $r3 /* stack pointer */
+#define V0  $r4 /* return value - caller saved */
+#define V1  $r5
+#define A0  $r4 /* argument registers */
+#define A1  $r5
+#define A2  $r6
+#define A3  $r7
+#define A4  $r8 /* arg reg 64 bit; caller saved in 32 
bit */
+#define A5  $r9
+#define A6  $r10
+#define A7  $r11
+#define T0  $r12 /* caller saved */
+#define T1  $r13
+#define T2  $r14
+#define T3  $r15
+#define T4  $r16 /* callee saved */
+#define T5  $r17
+#define T6  $r18
+#define T7  $r19
+#define T8  $r20 /* caller saved */
+#define TP  $r21 /* TLS */
+#define FP  $r22 /* frame pointer */
+#define S0  $r23 /* callee saved */
+#define S1  $r24
+#define S2  $r25
+#define S3  $r26
+#define S4  $r27
+#define S5  $r28
+#define S6  $r29
+#define S7  $r30
+#define S8  $r31 /* callee saved */
+
+#define FCSR0   $r0
+
+//
+// Location of the saved registers relative to ZERO.
+// Usage is p->p_regs[XX].
+//
+#define RA_NUM  1
+#define GP_NUM  2
+#define SP_NUM   

Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V4 32/34] OvmfPkg: RiscVVirt: Add Qemu Virt platform support

2022-10-24 Thread Sunil V L
On Sat, Oct 22, 2022 at 07:16:07AM +, Chang, Abner wrote:
> [AMD Official Use Only - General]
> 
> Acked-by: Abner Chang 
> 
> Thanks for making RiscVVirt happened.
> Abner
> 

Thanks a lot!, Abner. I received some comments from Ard for which I need
to update few patches. I am planning to send the next version of the
patch series AFTER the coding guidelines patch gets merged.

Thanks!
Sunil


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