Re: [edk2-devel] [PATCH v1] CryptoPkg: Add new hash algorithm ParallelHash256HashAll in BaseCryptLib.

2022-02-15 Thread Yao, Jiewen
But I don’t understand why we need sha3.h and xkcp.h at all.


> -Original Message-
> From: Li, Zhihao 
> Sent: Wednesday, February 16, 2022 3:43 PM
> To: Yao, Jiewen ; devel@edk2.groups.io
> Cc: Wang, Jian J ; Lu, Xiaoyu1 ;
> Jiang, Guomin ; Fu, Siyuan 
> Subject: RE: [PATCH v1] CryptoPkg: Add new hash algorithm
> ParallelHash256HashAll in BaseCryptLib.
> 
> With your comment, we plan do some modification for parallelhash.
> 1. Plan to add  a parameter (BlockSize) on  ParallelHash256HashAll  function 
> to
> replace PcdParallelHashBlockNumber.
> 2. Plan to move sha3.h and xkcp.h to CryptoPkg\Library\BaseCryptLib\Hash
> folder.
> 
> 
> > -Original Message-
> > From: Yao, Jiewen 
> > Sent: Tuesday, February 15, 2022 2:09 PM
> > To: Li, Zhihao ; devel@edk2.groups.io
> > Cc: Wang, Jian J ; Lu, Xiaoyu1
> > ; Jiang, Guomin ; Fu,
> > Siyuan 
> > Subject: RE: [PATCH v1] CryptoPkg: Add new hash algorithm
> > ParallelHash256HashAll in BaseCryptLib.
> >
> > Thanks for the update.
> >
> > Feedback below:
> >
> > 1) How block size is determined for below API?
> >
> > BOOLEAN
> > EFIAPI
> > ParallelHash256HashAll (
> >   IN CONST VOID*Input,
> >   IN   UINTN   InputByteLen,
> >   OUT  VOID*Output,
> >   IN   UINTN   OutputByteLen,
> >   IN CONST VOID*Customization,
> >   IN   UINTN   CustomByteLen
> >   );
> >
> > Is that determined by PcdParallelHashBlockNumber ?
> >
> > I don’t think it is good idea to let a crypto library determine a platform 
> > PCD.
> > For example, how do you support binary crypto module ?
> Plan to add  a parameter (BlockSize) to replace PcdParallelHashBlockNumber.
> >
> > 2) Why we need "sha3.h" and "xkcp.h" ?
> > These are openssl specific structure. It shall not be put to EDKII file 
> > header.
> >
> > CryptoPkg\Library\Include shall only contain generic dependency header.
> Plan to move sha3.h and xkcp.h to CryptoPkg\Library\BaseCryptLib\Hash folder.
> >
> >
> >
> >
> > Thank you
> > Yao, Jiewen
> >
> > > -Original Message-
> > > From: Li, Zhihao 
> > > Sent: Friday, February 11, 2022 5:05 PM
> > > To: devel@edk2.groups.io
> > > Cc: Yao, Jiewen ; Wang, Jian J
> > > ; Lu, Xiaoyu1 ; Jiang,
> > > Guomin ; Fu, Siyuan 
> > > Subject: [PATCH v1] CryptoPkg: Add new hash algorithm
> > > ParallelHash256HashAll in BaseCryptLib.
> > >
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3596
> > >
> > > Parallel hash function ParallelHash256HashAll, as defined in NIST's
> > > Special Publication 800-185, published December 2016. It utilizes
> > > multi-process to calculate the digest.
> > >
> > > Cc: Jiewen Yao 
> > > Cc: Jian J Wang 
> > > Cc: Xiaoyu Lu 
> > > Cc: Guomin Jiang 
> > > Cc: Siyuan Fu 
> > >
> > > Signed-off-by: Zhihao Li 
> > > ---
> > >  CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c   | 
> > > 313
> > > 
> > >  CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHash.c| 
> > > 275
> > > +
> > >  CryptoPkg/Library/BaseCryptLib/Hash/CryptSha3.c| 
> > > 102
> > +++
> > >  CryptoPkg/Library/BaseCryptLib/Hash/CryptXkcp.c| 
> > >  53 
> > >  CryptoPkg/Test/UnitTest/Library/BaseCryptLib/ParallelhashTests.c   |
> > 152
> > > ++
> > >  CryptoPkg/CryptoPkg.dec| 
> > >   9 +-
> > >  CryptoPkg/Include/Library/BaseCryptLib.h   | 
> > >  29 +-
> > >  CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf | 
> > >  12 +-
> > >  CryptoPkg/Library/Include/CrtLibSupport.h  | 
> > >   5 +-
> > >  CryptoPkg/Library/Include/sha3.h   | 
> > >  32 ++
> > >  CryptoPkg/Library/Include/xkcp.h   | 
> > >  23 ++
> > >  CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLib.h| 
> > >   3
> > +-
> > >  CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.inf
> > |   7 +
> > >  CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibShell.inf |
> > 6 +
> > >  14 files changed, 1016 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c
> > > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c
> > > new file mode 100644
> > > index 00..5efced3f46
> > > --- /dev/null
> > > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c
> > > @@ -0,0 +1,313 @@
> > > +/** @file
> > >
> > > +  cSHAKE-256 Digest Wrapper Implementations.
> > >
> > > +
> > >
> > > +Copyright (c) 2022, Intel Corporation. All rights reserved.
> > >
> > > +SPDX-License-Identifier: BSD-2-Clause-Patent
> > >
> > > +
> > >
> > > +**/
> > >
> > > +
> > >
> > > +#include "InternalCryptLib.h"
> > >
> > > +#include "sha3.h"
> > >
> > > +#include "xkcp.h"
> > >
> > > +
> > >
> > > +#define  CSHAKE256_SECURITY_STRENGTH256
> > >

Re: [edk2-devel] [PATCH v1] CryptoPkg: Add new hash algorithm ParallelHash256HashAll in BaseCryptLib.

2022-02-15 Thread Li, Zhihao
With your comment, we plan do some modification for parallelhash.
1. Plan to add  a parameter (BlockSize) on  ParallelHash256HashAll  function to 
replace PcdParallelHashBlockNumber.
2. Plan to move sha3.h and xkcp.h to CryptoPkg\Library\BaseCryptLib\Hash folder.


> -Original Message-
> From: Yao, Jiewen 
> Sent: Tuesday, February 15, 2022 2:09 PM
> To: Li, Zhihao ; devel@edk2.groups.io
> Cc: Wang, Jian J ; Lu, Xiaoyu1
> ; Jiang, Guomin ; Fu,
> Siyuan 
> Subject: RE: [PATCH v1] CryptoPkg: Add new hash algorithm
> ParallelHash256HashAll in BaseCryptLib.
> 
> Thanks for the update.
> 
> Feedback below:
> 
> 1) How block size is determined for below API?
> 
> BOOLEAN
> EFIAPI
> ParallelHash256HashAll (
>   IN CONST VOID*Input,
>   IN   UINTN   InputByteLen,
>   OUT  VOID*Output,
>   IN   UINTN   OutputByteLen,
>   IN CONST VOID*Customization,
>   IN   UINTN   CustomByteLen
>   );
> 
> Is that determined by PcdParallelHashBlockNumber ?
> 
> I don’t think it is good idea to let a crypto library determine a platform 
> PCD.
> For example, how do you support binary crypto module ?
Plan to add  a parameter (BlockSize) to replace PcdParallelHashBlockNumber.
> 
> 2) Why we need "sha3.h" and "xkcp.h" ?
> These are openssl specific structure. It shall not be put to EDKII file 
> header.
> 
> CryptoPkg\Library\Include shall only contain generic dependency header.
Plan to move sha3.h and xkcp.h to CryptoPkg\Library\BaseCryptLib\Hash folder.
> 
> 
> 
> 
> Thank you
> Yao, Jiewen
> 
> > -Original Message-
> > From: Li, Zhihao 
> > Sent: Friday, February 11, 2022 5:05 PM
> > To: devel@edk2.groups.io
> > Cc: Yao, Jiewen ; Wang, Jian J
> > ; Lu, Xiaoyu1 ; Jiang,
> > Guomin ; Fu, Siyuan 
> > Subject: [PATCH v1] CryptoPkg: Add new hash algorithm
> > ParallelHash256HashAll in BaseCryptLib.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3596
> >
> > Parallel hash function ParallelHash256HashAll, as defined in NIST's
> > Special Publication 800-185, published December 2016. It utilizes
> > multi-process to calculate the digest.
> >
> > Cc: Jiewen Yao 
> > Cc: Jian J Wang 
> > Cc: Xiaoyu Lu 
> > Cc: Guomin Jiang 
> > Cc: Siyuan Fu 
> >
> > Signed-off-by: Zhihao Li 
> > ---
> >  CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c   | 
> > 313
> > 
> >  CryptoPkg/Library/BaseCryptLib/Hash/CryptParallelHash.c| 
> > 275
> > +
> >  CryptoPkg/Library/BaseCryptLib/Hash/CryptSha3.c| 
> > 102
> +++
> >  CryptoPkg/Library/BaseCryptLib/Hash/CryptXkcp.c|  
> > 53 
> >  CryptoPkg/Test/UnitTest/Library/BaseCryptLib/ParallelhashTests.c   |
> 152
> > ++
> >  CryptoPkg/CryptoPkg.dec|   
> > 9 +-
> >  CryptoPkg/Include/Library/BaseCryptLib.h   |  
> > 29 +-
> >  CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf |  
> > 12 +-
> >  CryptoPkg/Library/Include/CrtLibSupport.h  |   
> > 5 +-
> >  CryptoPkg/Library/Include/sha3.h   |  
> > 32 ++
> >  CryptoPkg/Library/Include/xkcp.h   |  
> > 23 ++
> >  CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLib.h|   
> > 3
> +-
> >  CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.inf
> |   7 +
> >  CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibShell.inf |
> 6 +
> >  14 files changed, 1016 insertions(+), 5 deletions(-)
> >
> > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c
> > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c
> > new file mode 100644
> > index 00..5efced3f46
> > --- /dev/null
> > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptCShake256.c
> > @@ -0,0 +1,313 @@
> > +/** @file
> >
> > +  cSHAKE-256 Digest Wrapper Implementations.
> >
> > +
> >
> > +Copyright (c) 2022, Intel Corporation. All rights reserved.
> >
> > +SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > +
> >
> > +**/
> >
> > +
> >
> > +#include "InternalCryptLib.h"
> >
> > +#include "sha3.h"
> >
> > +#include "xkcp.h"
> >
> > +
> >
> > +#define  CSHAKE256_SECURITY_STRENGTH256
> >
> > +#define  CSHAKE256_RATE_IN_BYTES136
> >
> > +
> >
> > +const CHAR8 mZeroPadding[CSHAKE256_RATE_IN_BYTES] = {0};
> >
> > +
> >
> > +UINTN
> >
> > +EFIAPI
> >
> > +LeftEncode (
> >
> > +  OUT UINT8 *Encbuf,
> >
> > +  IN  UINTN Value
> >
> > +  )
> >
> > +{
> >
> > +  return left_encode (Encbuf, Value);
> >
> > +}
> >
> > +
> >
> > +UINTN
> >
> > +EFIAPI
> >
> > +RightEncode (
> >
> > +  OUT UINT8 *Encbuf,
> >
> > +  IN  UINTN Value
> >
> > +  )
> >
> > +{
> >
> > +  return right_encode (Encbuf, Value);
> >
> > +}
> >
> > +
> >
> > +/**
> >
> > +  Retrieves the size, in bytes, of the context buffer required for
> 

[edk2-devel] [PATCH 1/1] OvmfPkg/AmdSev: reserve snp pages

2022-02-15 Thread Gerd Hoffmann
The SNP patch series updated the OvmfPkgX64 build but forgot the AmdSev
variant, resulting in a broken OvmfSevMetadata table.

Fixes: cca9cd3dd6bf ("OvmfPkg: reserve CPUID page")
Fixes: 707c71a01b9d ("OvmfPkg: reserve SNP secrets page")
Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/AmdSev/AmdSevX64.fdf | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf
index 14b5b5593f97..31f2be66361f 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.fdf
+++ b/OvmfPkg/AmdSev/AmdSevX64.fdf
@@ -68,6 +68,12 @@ [FD.MEMFD]
 0x00D000|0x001000
 
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupSize
 
+0x00E000|0x001000
+gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize
+
+0x00F000|0x001000
+gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidSize
+
 0x01|0x01
 
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
 
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86699): https://edk2.groups.io/g/devel/message/86699
Mute This Topic: https://groups.io/mt/89180886/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/FvbServicesSmm: use the VmgExitLibNull

2022-02-15 Thread Yao, Jiewen
Merged https://github.com/tianocore/edk2/pull/2525

https://github.com/tianocore/edk2/commit/c28e376edc46e6db6e4a551c94b6ac90df0d8d6e

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Yao, Jiewen
> Sent: Wednesday, February 16, 2022 1:57 PM
> To: devel@edk2.groups.io; Gao, Liming ; 'Brijesh
> Singh' 
> Cc: 'James Bottomley' ; Xu, Min M ;
> 'Tom Lendacky' ; Justen, Jordan L
> ; 'Ard Biesheuvel' ;
> Aktas, Erdem ; 'Michael Roth'
> ; 'Gerd Hoffmann' ; 'Aaron
> Young' ; 'Dann Frazier'
> 
> Subject: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the
> VmgExitLibNull
> 
> Yes. Will do it soon.
> 
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of gaoliming
> > Sent: Wednesday, February 16, 2022 1:55 PM
> > To: devel@edk2.groups.io; Yao, Jiewen ; 'Brijesh
> Singh'
> > 
> > Cc: 'James Bottomley' ; Xu, Min M
> ;
> > 'Tom Lendacky' ; Justen, Jordan L
> > ; 'Ard Biesheuvel' ;
> > Aktas, Erdem ; 'Michael Roth'
> > ; 'Gerd Hoffmann' ; 'Aaron
> > Young' ; 'Dann Frazier'
> > 
> > Subject: 回复: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the
> > VmgExitLibNull
> >
> > Jiewen:
> >   I agree to merge this patch for this stable tag 202202. Can you create PR
> > for it?
> >
> > Thanks
> > Liming
> > > -邮件原件-
> > > 发件人: devel@edk2.groups.io  代表 Yao, Jiewen
> > > 发送时间: 2022年2月16日 10:55
> > > 收件人: devel@edk2.groups.io; Yao, Jiewen ;
> Brijesh
> > > Singh 
> > > 抄送: James Bottomley ; Xu, Min M
> > > ; Tom Lendacky ;
> > > Justen, Jordan L ; Ard Biesheuvel
> > > ; Aktas, Erdem ;
> > > Michael Roth ; Gerd Hoffmann
> > > ; Aaron Young ; Dann
> > > Frazier ; Gao, Liming
> > > 
> > > 主题: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the
> > > VmgExitLibNull
> > >
> > > + Liming
> > >
> > > Since it is an issue https://bugzilla.tianocore.org/show_bug.cgi?id=3835
> > in
> > > RC1, I assume we need merge it soon.
> > >
> > > Please double confirm.
> > >
> > > Thank you
> > > Yao, Jiewen
> > >
> > >
> > > > -Original Message-
> > > > From: devel@edk2.groups.io  On Behalf Of Yao,
> > > Jiewen
> > > > Sent: Wednesday, February 16, 2022 10:52 AM
> > > > To: Brijesh Singh ; devel@edk2.groups.io
> > > > Cc: James Bottomley ; Xu, Min M
> > > ;
> > > > Tom Lendacky ; Justen, Jordan L
> > > > ; Ard Biesheuvel
> ;
> > > > Aktas, Erdem ; Michael Roth
> > > > ; Gerd Hoffmann ; Aaron
> > > > Young ; Dann Frazier
> > > > ; Michael Roth 
> > > > Subject: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the
> > > > VmgExitLibNull
> > > >
> > > > Reviewed-by: Jiewen Yao 
> > > >
> > > > > -Original Message-
> > > > > From: Brijesh Singh 
> > > > > Sent: Tuesday, February 15, 2022 11:17 PM
> > > > > To: devel@edk2.groups.io
> > > > > Cc: James Bottomley ; Xu, Min M
> > > > ;
> > > > > Yao, Jiewen ; Tom Lendacky
> > > > > ; Justen, Jordan L
> > > ;
> > > > > Ard Biesheuvel ; Aktas, Erdem
> > > > > ; Michael Roth ;
> > > Gerd
> > > > > Hoffmann ; Brijesh Singh
> ;
> > > > > Aaron Young ; Dann Frazier
> > > > > ; Michael Roth 
> > > > > Subject: [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the VmgExitLibNull
> > > > >
> > > > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3835
> > > > >
> > > > > The commit ade62c18f4742301bbef474ac10518bde5972fba caused a
> > > boot
> > > > > failure
> > > > > when OVMF is build with SECURE_BOOT/SMM enabled.
> > > > >
> > > > > This happen because the above commit extended the
> > > > > BaseMemEncryptSevLib.inf
> > > > > to include VmgExitLib. The FvbServicesSmm uses the functions provided
> > > > > by the MemEncryptSevLib to clear the memory encryption mask from the
> > > > > page table. It created a dependency, as shown below
> > > > >
> > > > > OvmfPkg/FvbServicesSmm.inf
> > > > >  ---> MemEncryptSevLib   class
> > > > >  ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"
> > > instance
> > > > >  ---> VmgExitLib
> > > > >  ---> "OvmfPkg/VmgExitLib"instance
> > > > >  ---> LocalApicLib   class
> > > > >  ---> UefiCpuPkg/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
> > > instance
> > > > >  ---> TimerLib   class
> > > > >  ---> "OvmfPkg/AcpiTimerLib/DxeAcpiTimerLib.inf"
> > > instance
> > > > >  ---> PciLib class
> > > > >  ---> "OvmfPkg/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf"
> > > instance
> > > > >
> > > > > The LocalApicLib provides a constructor, execution of the constructor
> > > > > causes an exception. The SEV-ES and SEV-SNP do not support the SMM,
> so
> > > > > skip including the VmgExitLib chain. Use the module override to use
> > the
> > > > > VmgExitLibNull to avoid the inclusion of unneeded LocalApicLib
> > > dependency
> > > > > chain in FvbServicesSmm. We ran similar issue for AmdSevDxe driver,
> > > > > see commit 19914edc5a0202cc7830f819ffac7e7b2368166a
> > > > >
> > > > > After the patch, the dependency look like this:
> > > > >
> > > > > OvmfPkg/FvbServicesSmm.inf
> > > > >  ---> 

Re: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-02-15 Thread Ni, Ray
Deepthi,
Can you please help to review the changes and provide comments?

Thanks,
Ray

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jeff Brasen via 
groups.io
Sent: Tuesday, February 15, 2022 2:46 AM
To: devel@edk2.groups.io
Cc: Wu, Hao A ; Ni, Ray ; Jeff Brasen 

Subject: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: 
Allow partial FreeBuffer

Add support for partial free of non cached buffers.
If a request for less than the full size is requested new allocations for the 
remaining head and tail of the buffer are added to the list.
Added verification that Buffer is EFI_PAGE_SIZE aligned.
The XHCI driver does this if the page size for the controller is >4KB.

Signed-off-by: Jeff Brasen 
---
 .../NonDiscoverablePciDeviceIo.c  | 53 ++-
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
index c1c5c6267c..77809cfedf 100644
--- 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
+++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePc
+++ iDeviceIo.c
@@ -960,12 +960,23 @@ NonCoherentPciIoFreeBuffer (
   LIST_ENTRY   *Entry;
   EFI_STATUS   Status;
   NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *Alloc;
+  NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocHead;  
+ NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocTail;
   BOOLEAN  Found;
+  UINTNStartPages;
+  UINTNEndPages;
+
+  if (HostAddress != ALIGN_POINTER (HostAddress, EFI_PAGE_SIZE)) {
+ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
+return EFI_INVALID_PARAMETER;
+  }
 
   Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
 
   Found = FALSE;
   Alloc = NULL;
+  AllocHead = NULL;
+  AllocTail = NULL;
 
   //
   // Find the uncached allocation list entry associated @@ -976,9 +987,13 @@ 
NonCoherentPciIoFreeBuffer (
Entry = Entry->ForwardLink)
   {
 Alloc = BASE_CR (Entry, NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION, List);
-if ((Alloc->HostAddress == HostAddress) && (Alloc->NumPages == Pages)) {
+StartPages = 0;
+if (Alloc->HostAddress < HostAddress) {
+  StartPages = (HostAddress - Alloc->HostAddress) / EFI_PAGE_SIZE;
+}
+if ((Alloc->HostAddress <= HostAddress) && (Alloc->NumPages >= 
+ (Pages + StartPages))) {
   //
-  // We are freeing the exact allocation we were given
+  // We are freeing at least part of what we were given
   // before by AllocateBuffer()
   //
   Found = TRUE;
@@ -991,7 +1006,41 @@ NonCoherentPciIoFreeBuffer (
 return EFI_NOT_FOUND;
   }
 
+  EndPages = Alloc->NumPages - (Pages + StartPages);
+
+  if (StartPages != 0) {
+AllocHead = AllocatePool (sizeof *AllocHead);
+if (AllocHead == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
+
+AllocHead->HostAddress = Alloc->HostAddress;
+AllocHead->NumPages = StartPages;
+AllocHead->Attributes = Alloc->Attributes;  }
+
+  if (EndPages != 0) {
+AllocTail = AllocatePool (sizeof *AllocTail);
+if (AllocTail == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
+
+AllocTail->HostAddress = Alloc->HostAddress + ((Pages + StartPages) * 
EFI_PAGE_SIZE);
+AllocTail->NumPages = EndPages;
+AllocTail->Attributes = Alloc->Attributes;  }
+
   RemoveEntryList (>List);
+  //
+  // Record this new sub allocations in the linked list, so we  // can 
+ restore the memory space attributes later  //  if (AllocHead != NULL) 
+ {
+InsertHeadList (>UncachedAllocationList, >List);  }  
+ if (AllocTail != NULL) {
+InsertHeadList (>UncachedAllocationList, >List);  }
 
   Status = gDS->SetMemorySpaceAttributes (
   (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress,
--
2.17.1








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




Re: [edk2-devel] [PATCH] UefiPayloadPkg: Add PlatformGopPolicy

2022-02-15 Thread Ni, Ray
gPlatformGOPPolicyGuid is installed by this driver. Then who is producing GOP?

Thanks,
Ray

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Sean Rhodes
Sent: Friday, February 11, 2022 6:24 AM
To: devel@edk2.groups.io
Cc: Dong, Guo ; Matt DeVillier ; 
Ni, Ray ; Ma, Maurice ; You, Benjamin 

Subject: [edk2-devel] [PATCH] UefiPayloadPkg: Add PlatformGopPolicy

From: Matt DeVillier 

Add PlatformGopPolicy to use external GOP driver

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Signed-off-by: Matt DeVillier 
---
 .../PlatformGopPolicy/PlatformGopPolicy.c | 161 ++
 .../PlatformGopPolicy/PlatformGopPolicy.h |  62 +++
 .../PlatformGopPolicy/PlatformGopPolicy.inf   |  47 +
 UefiPayloadPkg/UefiPayloadPkg.dsc |   5 +
 UefiPayloadPkg/UefiPayloadPkg.fdf |  14 ++
 5 files changed, 289 insertions(+)
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf

diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c 
b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
new file mode 100644
index 00..31c61d967e
--- /dev/null
+++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
@@ -0,0 +1,161 @@
+/** @file

+

+  Copyright (c) 2021, Intel Corporation. All rights reserved.

+

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

+

+**/

+

+#include 

+#include 

+#include 

+#include "PlatformGopPolicy.h"

+

+#include 

+#include 

+

+PLATFORM_GOP_POLICY_PROTOCOL  mPlatformGOPPolicy;

+

+/**

+  The function will execute with as the platform policy, and gives

+  the Platform Lid Status. IBV/OEM can customize this code for their specific

+  policy action.

+

+  @param  CurrentLidStatus  Gives the current LID Status

+

+  @retval EFI_SUCCESS.

+**/

+EFI_STATUS

+EFIAPI

+GetPlatformLidStatus (

+  OUT LID_STATUS  *CurrentLidStatus

+  )

+{

+  *CurrentLidStatus = LidOpen;

+

+  return EFI_SUCCESS;

+}

+

+/**

+  The function will execute and gives the Video Bios Table Size and Address.

+

+  @param  VbtAddress  Gives the Physical Address of Video BIOS Table

+

+  @param  VbtSize Gives the Size of Video BIOS Table

+

+  @retval EFI_STATUS.

+**/

+EFI_STATUS

+EFIAPI

+GetVbtData (

+  OUT EFI_PHYSICAL_ADDRESS  *VbtAddress,

+  OUT UINT32*VbtSize

+  )

+{

+  EFI_STATUS Status;

+  UINTN  FvProtocolCount;

+  EFI_HANDLE *FvHandles;

+  EFI_FIRMWARE_VOLUME2_PROTOCOL  *Fv;

+  UINTN  Index;

+  UINT32 AuthenticationStatus;

+

+  UINT8  *Buffer;

+  UINTN  VbtBufferSize;

+

+  Buffer= 0;

+  FvHandles = NULL;

+

+  if ((VbtAddress == NULL) || (VbtSize == NULL)) {

+return EFI_INVALID_PARAMETER;

+  }

+

+  Status = gBS->LocateHandleBuffer (

+  ByProtocol,

+  ,

+  NULL,

+  ,

+  

+  );

+

+  if (!EFI_ERROR (Status)) {

+for (Index = 0; Index < FvProtocolCount; Index++) {

+  Status = gBS->HandleProtocol (

+  FvHandles[Index],

+  ,

+  (VOID **)

+  );

+  VbtBufferSize = 0;

+  Status= Fv->ReadSection (

+Fv,

+,

+EFI_SECTION_RAW,

+0,

+(void **),

+,

+

+);

+

+  if (!EFI_ERROR (Status)) {

+*VbtAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;

+*VbtSize= (UINT32)VbtBufferSize;

+Status  = EFI_SUCCESS;

+break;

+  }

+}

+  } else {

+Status = EFI_NOT_FOUND;

+  }

+

+  if (FvHandles != NULL) {

+gBS->FreePool (FvHandles);

+FvHandles = NULL;

+  }

+

+  return Status;

+}

+

+/**

+  Entry point for the Platform GOP Policy Driver.

+

+  @param ImageHandle   Image handle of this driver.

+  @param SystemTable   Global system service table.

+

+  @retval EFI_SUCCESS   Initialization complete.

+  @retval EFI_OUT_OF_RESOURCES  Do not have enough resources to initialize the 
driver.

+**/

+EFI_STATUS

+EFIAPI

+PlatformGOPPolicyEntryPoint (

+  IN EFI_HANDLEImageHandle,

+  IN EFI_SYSTEM_TABLE  *SystemTable

+  )

+

+{

+  EFI_STATUS  Status;

+

+  Status = EFI_SUCCESS;

+

+  gBS = SystemTable->BootServices;

+

+  gBS->SetMem (

+ ,

+ sizeof (PLATFORM_GOP_POLICY_PROTOCOL),

+ 0

+ );

+

+  mPlatformGOPPolicy.Revision = 
PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01;

+  mPlatformGOPPolicy.GetPlatformLidStatus = GetPlatformLidStatus;

+  

Re: [edk2-devel] [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure

2022-02-15 Thread Ni, Ray
Reviewed-by: Ray Ni 

-Original Message-
From: Gao, Zhichao  
Sent: Tuesday, February 15, 2022 4:10 PM
To: Rehan, MohammedX ; devel@edk2.groups.io; 
Esakkithevar, Kathappan ; Ni, Ray 
; Pethaiyan, Madhan 
Cc: Thirupugal, MadhaviX 
Subject: RE: [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure

Reviewed-by: Zhichao Gao 

Thanks,
Zhichao

> -Original Message-
> From: Rehan, MohammedX 
> Sent: Tuesday, February 15, 2022 4:07 PM
> To: devel@edk2.groups.io; Esakkithevar, Kathappan 
> ; Gao, Zhichao 
> ; Ni, Ray ; Pethaiyan, Madhan 
> 
> Cc: Thirupugal, MadhaviX ; Rehan, 
> MohammedX 
> Subject: [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3819
> 
> Ping GetTimerPeriod API returns sometime zero value when StallCounter 
> has smaller value than RttTimerTick (divide by zero) which results 
> some failure at ping UEFI shell command
> 
> Signed-off-by: MohammedX Rehan 
> ---
>  ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> index ec1e0a188b..6a002b15e5 100644
> --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> @@ -259,9 +259,11 @@ GetTimerPeriod (
>EFI_EVENT   TimerEvent;   UINT32  StallCounter;   EFI_TPL OldTpl;+
> UINT32  TimerPeriod;RttTimerTick = 0;   StallCounter = 0;+  
> TimerPeriod  =
> 0;Status = gBS->CreateEvent (   EVT_TIMER |
> EVT_NOTIFY_SIGNAL,@@ -295,7 +297,12 @@ GetTimerPeriod (
>gBS->SetTimer (TimerEvent, TimerCancel, 0);   gBS->CloseEvent
> (TimerEvent); -  return StallCounter / RttTimerTick;+  TimerPeriod =
> StallCounter / RttTimerTick;+  if (TimerPeriod != 0) {+return 
> TimerPeriod;+  }
> else {+return 1;+  } }  /**--
> 2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86695): https://edk2.groups.io/g/devel/message/86695
Mute This Topic: https://groups.io/mt/89156648/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/FvbServicesSmm: use the VmgExitLibNull

2022-02-15 Thread Yao, Jiewen
Yes. Will do it soon.


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of gaoliming
> Sent: Wednesday, February 16, 2022 1:55 PM
> To: devel@edk2.groups.io; Yao, Jiewen ; 'Brijesh Singh'
> 
> Cc: 'James Bottomley' ; Xu, Min M ;
> 'Tom Lendacky' ; Justen, Jordan L
> ; 'Ard Biesheuvel' ;
> Aktas, Erdem ; 'Michael Roth'
> ; 'Gerd Hoffmann' ; 'Aaron
> Young' ; 'Dann Frazier'
> 
> Subject: 回复: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the
> VmgExitLibNull
> 
> Jiewen:
>   I agree to merge this patch for this stable tag 202202. Can you create PR
> for it?
> 
> Thanks
> Liming
> > -邮件原件-
> > 发件人: devel@edk2.groups.io  代表 Yao, Jiewen
> > 发送时间: 2022年2月16日 10:55
> > 收件人: devel@edk2.groups.io; Yao, Jiewen ; Brijesh
> > Singh 
> > 抄送: James Bottomley ; Xu, Min M
> > ; Tom Lendacky ;
> > Justen, Jordan L ; Ard Biesheuvel
> > ; Aktas, Erdem ;
> > Michael Roth ; Gerd Hoffmann
> > ; Aaron Young ; Dann
> > Frazier ; Gao, Liming
> > 
> > 主题: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the
> > VmgExitLibNull
> >
> > + Liming
> >
> > Since it is an issue https://bugzilla.tianocore.org/show_bug.cgi?id=3835
> in
> > RC1, I assume we need merge it soon.
> >
> > Please double confirm.
> >
> > Thank you
> > Yao, Jiewen
> >
> >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of Yao,
> > Jiewen
> > > Sent: Wednesday, February 16, 2022 10:52 AM
> > > To: Brijesh Singh ; devel@edk2.groups.io
> > > Cc: James Bottomley ; Xu, Min M
> > ;
> > > Tom Lendacky ; Justen, Jordan L
> > > ; Ard Biesheuvel ;
> > > Aktas, Erdem ; Michael Roth
> > > ; Gerd Hoffmann ; Aaron
> > > Young ; Dann Frazier
> > > ; Michael Roth 
> > > Subject: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the
> > > VmgExitLibNull
> > >
> > > Reviewed-by: Jiewen Yao 
> > >
> > > > -Original Message-
> > > > From: Brijesh Singh 
> > > > Sent: Tuesday, February 15, 2022 11:17 PM
> > > > To: devel@edk2.groups.io
> > > > Cc: James Bottomley ; Xu, Min M
> > > ;
> > > > Yao, Jiewen ; Tom Lendacky
> > > > ; Justen, Jordan L
> > ;
> > > > Ard Biesheuvel ; Aktas, Erdem
> > > > ; Michael Roth ;
> > Gerd
> > > > Hoffmann ; Brijesh Singh ;
> > > > Aaron Young ; Dann Frazier
> > > > ; Michael Roth 
> > > > Subject: [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the VmgExitLibNull
> > > >
> > > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3835
> > > >
> > > > The commit ade62c18f4742301bbef474ac10518bde5972fba caused a
> > boot
> > > > failure
> > > > when OVMF is build with SECURE_BOOT/SMM enabled.
> > > >
> > > > This happen because the above commit extended the
> > > > BaseMemEncryptSevLib.inf
> > > > to include VmgExitLib. The FvbServicesSmm uses the functions provided
> > > > by the MemEncryptSevLib to clear the memory encryption mask from the
> > > > page table. It created a dependency, as shown below
> > > >
> > > > OvmfPkg/FvbServicesSmm.inf
> > > >  ---> MemEncryptSevLib   class
> > > >  ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"
> > instance
> > > >  ---> VmgExitLib
> > > >  ---> "OvmfPkg/VmgExitLib"instance
> > > >  ---> LocalApicLib   class
> > > >  ---> UefiCpuPkg/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
> > instance
> > > >  ---> TimerLib   class
> > > >  ---> "OvmfPkg/AcpiTimerLib/DxeAcpiTimerLib.inf"
> > instance
> > > >  ---> PciLib class
> > > >  ---> "OvmfPkg/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf"
> > instance
> > > >
> > > > The LocalApicLib provides a constructor, execution of the constructor
> > > > causes an exception. The SEV-ES and SEV-SNP do not support the SMM, so
> > > > skip including the VmgExitLib chain. Use the module override to use
> the
> > > > VmgExitLibNull to avoid the inclusion of unneeded LocalApicLib
> > dependency
> > > > chain in FvbServicesSmm. We ran similar issue for AmdSevDxe driver,
> > > > see commit 19914edc5a0202cc7830f819ffac7e7b2368166a
> > > >
> > > > After the patch, the dependency look like this:
> > > >
> > > > OvmfPkg/FvbServicesSmm.inf
> > > >  ---> MemEncryptSevLib   class
> > > >  ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"
> > instance
> > > >  ---> VmgExitLib
> > > >  ---> "UefiCpuPkg/Library/VmgExitLibNull"instance
> > > >
> > > > Fixes: ade62c18f4742301bbef474ac10518bde5972fba
> > > > Reported-by: Aaron Young 
> > > > Cc: Dann Frazier 
> > > > Cc: Michael Roth 
> > > > Cc: James Bottomley 
> > > > Cc: Min Xu 
> > > > Cc: Jiewen Yao 
> > > > Cc: Tom Lendacky 
> > > > Cc: Jordan Justen 
> > > > Cc: Ard Biesheuvel 
> > > > Cc: Erdem Aktas 
> > > > Cc: Gerd Hoffmann 
> > > > Signed-off-by: Brijesh Singh 
> > > > ---
> > > >  OvmfPkg/CloudHv/CloudHvX64.dsc | 5 -
> > > >  OvmfPkg/OvmfPkgIa32.dsc| 5 -
> > > >  OvmfPkg/OvmfPkgIa32X64.dsc | 5 -
> > > >  OvmfPkg/OvmfPkgX64.dsc | 5 -
> > > >  4 files changed, 16 insertions(+), 4 deletions(-)
> > > >

回复: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the VmgExitLibNull

2022-02-15 Thread gaoliming
Jiewen:
  I agree to merge this patch for this stable tag 202202. Can you create PR
for it?

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Yao, Jiewen
> 发送时间: 2022年2月16日 10:55
> 收件人: devel@edk2.groups.io; Yao, Jiewen ; Brijesh
> Singh 
> 抄送: James Bottomley ; Xu, Min M
> ; Tom Lendacky ;
> Justen, Jordan L ; Ard Biesheuvel
> ; Aktas, Erdem ;
> Michael Roth ; Gerd Hoffmann
> ; Aaron Young ; Dann
> Frazier ; Gao, Liming
> 
> 主题: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the
> VmgExitLibNull
> 
> + Liming
> 
> Since it is an issue https://bugzilla.tianocore.org/show_bug.cgi?id=3835
in
> RC1, I assume we need merge it soon.
> 
> Please double confirm.
> 
> Thank you
> Yao, Jiewen
> 
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Yao,
> Jiewen
> > Sent: Wednesday, February 16, 2022 10:52 AM
> > To: Brijesh Singh ; devel@edk2.groups.io
> > Cc: James Bottomley ; Xu, Min M
> ;
> > Tom Lendacky ; Justen, Jordan L
> > ; Ard Biesheuvel ;
> > Aktas, Erdem ; Michael Roth
> > ; Gerd Hoffmann ; Aaron
> > Young ; Dann Frazier
> > ; Michael Roth 
> > Subject: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the
> > VmgExitLibNull
> >
> > Reviewed-by: Jiewen Yao 
> >
> > > -Original Message-
> > > From: Brijesh Singh 
> > > Sent: Tuesday, February 15, 2022 11:17 PM
> > > To: devel@edk2.groups.io
> > > Cc: James Bottomley ; Xu, Min M
> > ;
> > > Yao, Jiewen ; Tom Lendacky
> > > ; Justen, Jordan L
> ;
> > > Ard Biesheuvel ; Aktas, Erdem
> > > ; Michael Roth ;
> Gerd
> > > Hoffmann ; Brijesh Singh ;
> > > Aaron Young ; Dann Frazier
> > > ; Michael Roth 
> > > Subject: [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the VmgExitLibNull
> > >
> > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3835
> > >
> > > The commit ade62c18f4742301bbef474ac10518bde5972fba caused a
> boot
> > > failure
> > > when OVMF is build with SECURE_BOOT/SMM enabled.
> > >
> > > This happen because the above commit extended the
> > > BaseMemEncryptSevLib.inf
> > > to include VmgExitLib. The FvbServicesSmm uses the functions provided
> > > by the MemEncryptSevLib to clear the memory encryption mask from the
> > > page table. It created a dependency, as shown below
> > >
> > > OvmfPkg/FvbServicesSmm.inf
> > >  ---> MemEncryptSevLib   class
> > >  ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"
> instance
> > >  ---> VmgExitLib
> > >  ---> "OvmfPkg/VmgExitLib"instance
> > >  ---> LocalApicLib   class
> > >  ---> UefiCpuPkg/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
> instance
> > >  ---> TimerLib   class
> > >  ---> "OvmfPkg/AcpiTimerLib/DxeAcpiTimerLib.inf"
> instance
> > >  ---> PciLib class
> > >  ---> "OvmfPkg/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf"
> instance
> > >
> > > The LocalApicLib provides a constructor, execution of the constructor
> > > causes an exception. The SEV-ES and SEV-SNP do not support the SMM, so
> > > skip including the VmgExitLib chain. Use the module override to use
the
> > > VmgExitLibNull to avoid the inclusion of unneeded LocalApicLib
> dependency
> > > chain in FvbServicesSmm. We ran similar issue for AmdSevDxe driver,
> > > see commit 19914edc5a0202cc7830f819ffac7e7b2368166a
> > >
> > > After the patch, the dependency look like this:
> > >
> > > OvmfPkg/FvbServicesSmm.inf
> > >  ---> MemEncryptSevLib   class
> > >  ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"
> instance
> > >  ---> VmgExitLib
> > >  ---> "UefiCpuPkg/Library/VmgExitLibNull"instance
> > >
> > > Fixes: ade62c18f4742301bbef474ac10518bde5972fba
> > > Reported-by: Aaron Young 
> > > Cc: Dann Frazier 
> > > Cc: Michael Roth 
> > > Cc: James Bottomley 
> > > Cc: Min Xu 
> > > Cc: Jiewen Yao 
> > > Cc: Tom Lendacky 
> > > Cc: Jordan Justen 
> > > Cc: Ard Biesheuvel 
> > > Cc: Erdem Aktas 
> > > Cc: Gerd Hoffmann 
> > > Signed-off-by: Brijesh Singh 
> > > ---
> > >  OvmfPkg/CloudHv/CloudHvX64.dsc | 5 -
> > >  OvmfPkg/OvmfPkgIa32.dsc| 5 -
> > >  OvmfPkg/OvmfPkgIa32X64.dsc | 5 -
> > >  OvmfPkg/OvmfPkgX64.dsc | 5 -
> > >  4 files changed, 16 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc
> > > b/OvmfPkg/CloudHv/CloudHvX64.dsc
> > > index 8ac9227c5f50..3172100310b1 100644
> > > --- a/OvmfPkg/CloudHv/CloudHvX64.dsc
> > > +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
> > > @@ -906,7 +906,10 @@ [Components]
> > >#
> > ># Variable driver stack (SMM)
> > >#
> > > -  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
> > > +  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
> > > +
> > > +VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> > > +  }
> > >
> >
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
> > >MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
> > >  
> > > diff --git 

Re: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the VmgExitLibNull

2022-02-15 Thread Yao, Jiewen
+ Liming

Since it is an issue https://bugzilla.tianocore.org/show_bug.cgi?id=3835 in 
RC1, I assume we need merge it soon.

Please double confirm.

Thank you
Yao, Jiewen


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Yao, Jiewen
> Sent: Wednesday, February 16, 2022 10:52 AM
> To: Brijesh Singh ; devel@edk2.groups.io
> Cc: James Bottomley ; Xu, Min M ;
> Tom Lendacky ; Justen, Jordan L
> ; Ard Biesheuvel ;
> Aktas, Erdem ; Michael Roth
> ; Gerd Hoffmann ; Aaron
> Young ; Dann Frazier
> ; Michael Roth 
> Subject: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the
> VmgExitLibNull
> 
> Reviewed-by: Jiewen Yao 
> 
> > -Original Message-
> > From: Brijesh Singh 
> > Sent: Tuesday, February 15, 2022 11:17 PM
> > To: devel@edk2.groups.io
> > Cc: James Bottomley ; Xu, Min M
> ;
> > Yao, Jiewen ; Tom Lendacky
> > ; Justen, Jordan L ;
> > Ard Biesheuvel ; Aktas, Erdem
> > ; Michael Roth ; Gerd
> > Hoffmann ; Brijesh Singh ;
> > Aaron Young ; Dann Frazier
> > ; Michael Roth 
> > Subject: [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the VmgExitLibNull
> >
> > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3835
> >
> > The commit ade62c18f4742301bbef474ac10518bde5972fba caused a boot
> > failure
> > when OVMF is build with SECURE_BOOT/SMM enabled.
> >
> > This happen because the above commit extended the
> > BaseMemEncryptSevLib.inf
> > to include VmgExitLib. The FvbServicesSmm uses the functions provided
> > by the MemEncryptSevLib to clear the memory encryption mask from the
> > page table. It created a dependency, as shown below
> >
> > OvmfPkg/FvbServicesSmm.inf
> >  ---> MemEncryptSevLib   class
> >  ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"  instance
> >  ---> VmgExitLib
> >  ---> "OvmfPkg/VmgExitLib"instance
> >  ---> LocalApicLib   class
> >  ---> UefiCpuPkg/BaseXApicX2ApicLib/BaseXApicX2ApicLib.infinstance
> >  ---> TimerLib   class
> >  ---> "OvmfPkg/AcpiTimerLib/DxeAcpiTimerLib.inf"  instance
> >  ---> PciLib class
> >  ---> "OvmfPkg/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf" instance
> >
> > The LocalApicLib provides a constructor, execution of the constructor
> > causes an exception. The SEV-ES and SEV-SNP do not support the SMM, so
> > skip including the VmgExitLib chain. Use the module override to use the
> > VmgExitLibNull to avoid the inclusion of unneeded LocalApicLib dependency
> > chain in FvbServicesSmm. We ran similar issue for AmdSevDxe driver,
> > see commit 19914edc5a0202cc7830f819ffac7e7b2368166a
> >
> > After the patch, the dependency look like this:
> >
> > OvmfPkg/FvbServicesSmm.inf
> >  ---> MemEncryptSevLib   class
> >  ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"  instance
> >  ---> VmgExitLib
> >  ---> "UefiCpuPkg/Library/VmgExitLibNull"instance
> >
> > Fixes: ade62c18f4742301bbef474ac10518bde5972fba
> > Reported-by: Aaron Young 
> > Cc: Dann Frazier 
> > Cc: Michael Roth 
> > Cc: James Bottomley 
> > Cc: Min Xu 
> > Cc: Jiewen Yao 
> > Cc: Tom Lendacky 
> > Cc: Jordan Justen 
> > Cc: Ard Biesheuvel 
> > Cc: Erdem Aktas 
> > Cc: Gerd Hoffmann 
> > Signed-off-by: Brijesh Singh 
> > ---
> >  OvmfPkg/CloudHv/CloudHvX64.dsc | 5 -
> >  OvmfPkg/OvmfPkgIa32.dsc| 5 -
> >  OvmfPkg/OvmfPkgIa32X64.dsc | 5 -
> >  OvmfPkg/OvmfPkgX64.dsc | 5 -
> >  4 files changed, 16 insertions(+), 4 deletions(-)
> >
> > diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc
> > b/OvmfPkg/CloudHv/CloudHvX64.dsc
> > index 8ac9227c5f50..3172100310b1 100644
> > --- a/OvmfPkg/CloudHv/CloudHvX64.dsc
> > +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
> > @@ -906,7 +906,10 @@ [Components]
> >#
> ># Variable driver stack (SMM)
> >#
> > -  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
> > +  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
> > +
> > +VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> > +  }
> >
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
> >MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
> >  
> > diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> > index 29eea82571c5..85abed24c1a7 100644
> > --- a/OvmfPkg/OvmfPkgIa32.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32.dsc
> > @@ -956,7 +956,10 @@ [Components]
> >#
> ># Variable driver stack (SMM)
> >#
> > -  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
> > +  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
> > +
> > +VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> > +  }
> >
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
> >MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
> >  
> > diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> > index 56d3c49ab21a..a9c1daecc1a8 100644
> > --- 

Re: [edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the VmgExitLibNull

2022-02-15 Thread Yao, Jiewen
Reviewed-by: Jiewen Yao 

> -Original Message-
> From: Brijesh Singh 
> Sent: Tuesday, February 15, 2022 11:17 PM
> To: devel@edk2.groups.io
> Cc: James Bottomley ; Xu, Min M ;
> Yao, Jiewen ; Tom Lendacky
> ; Justen, Jordan L ;
> Ard Biesheuvel ; Aktas, Erdem
> ; Michael Roth ; Gerd
> Hoffmann ; Brijesh Singh ;
> Aaron Young ; Dann Frazier
> ; Michael Roth 
> Subject: [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the VmgExitLibNull
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3835
> 
> The commit ade62c18f4742301bbef474ac10518bde5972fba caused a boot
> failure
> when OVMF is build with SECURE_BOOT/SMM enabled.
> 
> This happen because the above commit extended the
> BaseMemEncryptSevLib.inf
> to include VmgExitLib. The FvbServicesSmm uses the functions provided
> by the MemEncryptSevLib to clear the memory encryption mask from the
> page table. It created a dependency, as shown below
> 
> OvmfPkg/FvbServicesSmm.inf
>  ---> MemEncryptSevLib   class
>  ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"  instance
>  ---> VmgExitLib
>  ---> "OvmfPkg/VmgExitLib"instance
>  ---> LocalApicLib   class
>  ---> UefiCpuPkg/BaseXApicX2ApicLib/BaseXApicX2ApicLib.infinstance
>  ---> TimerLib   class
>  ---> "OvmfPkg/AcpiTimerLib/DxeAcpiTimerLib.inf"  instance
>  ---> PciLib class
>  ---> "OvmfPkg/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf" instance
> 
> The LocalApicLib provides a constructor, execution of the constructor
> causes an exception. The SEV-ES and SEV-SNP do not support the SMM, so
> skip including the VmgExitLib chain. Use the module override to use the
> VmgExitLibNull to avoid the inclusion of unneeded LocalApicLib dependency
> chain in FvbServicesSmm. We ran similar issue for AmdSevDxe driver,
> see commit 19914edc5a0202cc7830f819ffac7e7b2368166a
> 
> After the patch, the dependency look like this:
> 
> OvmfPkg/FvbServicesSmm.inf
>  ---> MemEncryptSevLib   class
>  ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"  instance
>  ---> VmgExitLib
>  ---> "UefiCpuPkg/Library/VmgExitLibNull"instance
> 
> Fixes: ade62c18f4742301bbef474ac10518bde5972fba
> Reported-by: Aaron Young 
> Cc: Dann Frazier 
> Cc: Michael Roth 
> Cc: James Bottomley 
> Cc: Min Xu 
> Cc: Jiewen Yao 
> Cc: Tom Lendacky 
> Cc: Jordan Justen 
> Cc: Ard Biesheuvel 
> Cc: Erdem Aktas 
> Cc: Gerd Hoffmann 
> Signed-off-by: Brijesh Singh 
> ---
>  OvmfPkg/CloudHv/CloudHvX64.dsc | 5 -
>  OvmfPkg/OvmfPkgIa32.dsc| 5 -
>  OvmfPkg/OvmfPkgIa32X64.dsc | 5 -
>  OvmfPkg/OvmfPkgX64.dsc | 5 -
>  4 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc
> b/OvmfPkg/CloudHv/CloudHvX64.dsc
> index 8ac9227c5f50..3172100310b1 100644
> --- a/OvmfPkg/CloudHv/CloudHvX64.dsc
> +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
> @@ -906,7 +906,10 @@ [Components]
>#
># Variable driver stack (SMM)
>#
> -  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
> +  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
> +
> +VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> +  }
>MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
>MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
>  
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 29eea82571c5..85abed24c1a7 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -956,7 +956,10 @@ [Components]
>#
># Variable driver stack (SMM)
>#
> -  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
> +  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
> +
> +VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> +  }
>MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
>MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
>  
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 56d3c49ab21a..a9c1daecc1a8 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -974,7 +974,10 @@ [Components.X64]
>#
># Variable driver stack (SMM)
>#
> -  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
> +  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
> +
> +VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> +  }
>MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
>MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
>  
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index f0924c0f9d0a..718399299f57 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -971,7 +971,10 @@ [Components]
>#
># Variable driver stack (SMM)
>#
> -  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
> +  

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

2022-02-15 Thread devel@edk2.groups.io Calendar
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Groups.io Inc//Groups.io Calendar//EN
METHOD:PUBLISH
REFRESH-INTERVAL;VALUE=DURATION:PT1H
X-PUBLISHED-TTL:PT1H
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:America/Los_Angeles
LAST-MODIFIED:20201011T015911Z
TZURL:http://tzurl.org/zoneinfo-outlook/America/Los_Angeles
X-LIC-LOCATION:America/Los_Angeles
BEGIN:DAYLIGHT
TZNAME:PDT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
DTSTART:19700308T02
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:PST
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
DTSTART:19701101T02
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
X-GIOIDS:Event:1238706 
UID:mlda.1580078539586725120.r...@groups.io
DTSTAMP:20220216T021501Z
ORGANIZER;CN=Liming Gao:mailto:gaolim...@byosoft.com.cn
DTSTART:20220216T023000Z
DTEND:20220216T033000Z
SUMMARY:TianoCore Bug Triage - APAC / NAMO
DESCRIPTION:TianoCore Bug Triage - APAC / NAMO\n\nHosted by Liming Gao\n\
 n
 \n\nMicrosoft Teams meeting\n\n*Join on your computer or mobile a
 pp*\n\nClick here to join the meeting ( https://teams.microsoft.com/l/mee
 tup-join/19%3ameeting_OTUyZTg2NjgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh%40
 thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255
 d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d )\n\n*Jo
 in with a video conferencing device*\n\nte...@conf.intel.com\n\nVideo Con
 ference ID: 116 062 094 0\n\nAlternate VTC dialing instructions ( https:/
 /conf.intel.com/teams/?conf=1160620940=teams=conf.intel.com=te
 st_call )\n\n*Or call in (audio only)*\n\n+1 916-245-6934\,\,77463821# ( 
 tel:+19162456934\,\,77463821# ) United States\, Sacramento\n\nPhone Confe
 rence ID: 774 638 21#\n\nFind a local number ( https://dialin.teams.micro
 soft.com/d195d438-2daa-420e-b9ea-da26f9d1d6d5?id=77463821 ) | Reset PIN (
  https://mysettings.lync.com/pstnconferencing )\n\nLearn More ( https://a
 ka.ms/JoinTeamsMeeting ) | Meeting options ( https://teams.microsoft.com/
 meetingOptions/?organizerId=b286b53a-1218-4db3-bfc9-3d4c5aa7669e
 =46c98d88-e344-4ed4-8496-4ed7712e255d=19_meeting_OTUyZTg2NjgtNDh
 lNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh@thread.v2=0=en-US )
LOCATION:https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTUyZTg2N
 jgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh%40thread.v2/0?context=%7b%22Tid%2
 2%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%22b286b53a-
 1218-4db3-bfc9-3d4c5aa7669e%22%7d
SEQUENCE:1
END:VEVENT
END:VCALENDAR


invite.ics
Description: application/ics


[edk2-devel] Updated Event: TianoCore edk2-test Bug Triage Meeting #cal-invite

2022-02-15 Thread devel@edk2.groups.io Calendar
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Groups.io Inc//Groups.io Calendar//EN
METHOD:PUBLISH
REFRESH-INTERVAL;VALUE=DURATION:PT1H
X-PUBLISHED-TTL:PT1H
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Asia/Shanghai
LAST-MODIFIED:20201011T015911Z
TZURL:http://tzurl.org/zoneinfo-outlook/Asia/Shanghai
X-LIC-LOCATION:Asia/Shanghai
BEGIN:STANDARD
TZNAME:CST
TZOFFSETFROM:+0800
TZOFFSETTO:+0800
DTSTART:19700101T00
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
X-GIOIDS:Repeat:39460
UID:uhga.1631071627369023388.p...@groups.io
DTSTAMP:20220216T012039Z
ORGANIZER;CN=Edhaya Chandran:mailto:edhaya.chand...@arm.com
DTSTART;TZID=Asia/Shanghai:20220303T22
DTEND;TZID=Asia/Shanghai:20220303T23
RRULE:FREQ=WEEKLY;INTERVAL=4;BYDAY=TH
SUMMARY:TianoCore edk2-test Bug Triage Meeting
LOCATION:https://armltd.zoom.us/j/93809865843?pwd=dU1hSzk4NHM2RGhaRDRyWWZ
 xUzY5dz09=addon
SEQUENCE:1669
END:VEVENT
END:VCALENDAR


invite.ics
Description: application/ics


[edk2-devel] Cancelled Event: TianoCore edk2-test Bug Triage Meeting - Thursday, February 24, 2022 #cal-cancelled

2022-02-15 Thread devel@edk2.groups.io Calendar
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Groups.io Inc//Groups.io Calendar//EN
METHOD:CANCELLED
REFRESH-INTERVAL;VALUE=DURATION:PT1H
X-PUBLISHED-TTL:PT1H
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Asia/Shanghai
LAST-MODIFIED:20201011T015911Z
TZURL:http://tzurl.org/zoneinfo-outlook/Asia/Shanghai
X-LIC-LOCATION:Asia/Shanghai
BEGIN:STANDARD
TZNAME:CST
TZOFFSETFROM:+0800
TZOFFSETTO:+0800
DTSTART:19700101T00
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
X-GIOIDS:Event:1387973 
UID:uhga.1631071627369023388.p...@groups.io
DTSTAMP:20220216T011902Z
ORGANIZER;CN=Edhaya Chandran:mailto:edhaya.chand...@arm.com
DTSTART:20220224T14Z
DTEND:20220224T15Z
SUMMARY:TianoCore edk2-test Bug Triage Meeting
LOCATION:https://armltd.zoom.us/j/93809865843?pwd=dU1hSzk4NHM2RGhaRDRyWWZ
 xUzY5dz09=addon
SEQUENCE:1
STATUS:CANCELLED
END:VEVENT
END:VCALENDAR


invite.ics
Description: application/ics


[edk2-devel] AArch64 CommonCExceptionHandler() and EFI_SYSTEM_CONTEXT

2022-02-15 Thread Andrew Fish via groups.io
So I’m messing about in a DefaultExceptionHandler() (like [1]) that is called 
from CommonCExceptionHandler() [2]. What I notice is the faulting address is 
special cased. So the stack walking code has to dump the fault address and then 
walk the stack to get a stack trace of the fault. That kind of makes sense, but 
then when I connect with a debugger the stack trace I get is missing the 
faulting frame from the debugger. 

My question is there something architectural that makes the debugger not work 
from this location? Does the exception code need to do some magic on the stack 
so a stack walk back would include the faulting are frame? I’m not 100% sure 
about AArch64. I seem to remember we messed with the X64 stack so the frame 
from the exception handler looked valid and included the faulting code.


[1] 
https://github.com/tianocore/edk2/blob/master/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c#L186
[2] 
https://github.com/tianocore/edk2/blob/master/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c#L296

Thanks,

Andrew Fish



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86687): https://edk2.groups.io/g/devel/message/86687
Mute This Topic: https://groups.io/mt/89175218/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 V1 1/1] BeepDebugFeaturePkg: Enable FixedAtBuild PCD type

2022-02-15 Thread Oram, Isaac W
Pushed as e3e2e71b0a..5757dceecb

-Original Message-
From: Chaganty, Rangasai V  
Sent: Monday, February 14, 2022 11:05 PM
To: Oram, Isaac W ; devel@edk2.groups.io
Cc: Desimone, Nathaniel L ; Gao, Liming 

Subject: RE: [edk2-devel][edk2-platforms][PATCH V1 1/1] BeepDebugFeaturePkg: 
Enable FixedAtBuild PCD type

Reviewed-by: Sai Chaganty 

-Original Message-
From: Oram, Isaac W  
Sent: Friday, February 11, 2022 4:13 PM
To: devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Desimone, Nathaniel L 
; Gao, Liming 
Subject: [edk2-devel][edk2-platforms][PATCH V1 1/1] BeepDebugFeaturePkg: Enable 
FixedAtBuild PCD type

Enable PcdStatusCodeUseBeep to allow FixedAtBuild type for backwards 
compatibility.

Cc: Sai Chaganty 
Cc: Nate DeSimone 
Cc: Liming Gao 
Signed-off-by: Isaac Oram 
---
 Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugFeaturePkg.dec | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git 
a/Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugFeaturePkg.dec 
b/Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugFeaturePkg.dec
index d90611da51..9f44f228d1 100644
--- a/Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugFeaturePkg.dec
+++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugFeaturePkg.d
+++ ec
@@ -34,6 +34,5 @@
 [PcdsFeatureFlag]
   
gBeepDebugFeaturePkgTokenSpaceGuid.PcdBeepDebugFeatureEnable|FALSE|BOOLEAN|0x
 
-[PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
-  # Beep is a legacy feature, disabled it by default
+[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
   
gBeepDebugFeaturePkgTokenSpaceGuid.PcdStatusCodeUseBeep|TRUE|BOOLEAN|0x0001
--
2.27.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86686): https://edk2.groups.io/g/devel/message/86686
Mute This Topic: https://groups.io/mt/89084754/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/FvbServicesSmm: use the VmgExitLibNull

2022-02-15 Thread dann frazier
On Tue, Feb 15, 2022 at 09:16:38AM -0600, Brijesh Singh wrote:
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3835
> 
> The commit ade62c18f4742301bbef474ac10518bde5972fba caused a boot failure
> when OVMF is build with SECURE_BOOT/SMM enabled.
> 
> This happen because the above commit extended the BaseMemEncryptSevLib.inf
> to include VmgExitLib. The FvbServicesSmm uses the functions provided
> by the MemEncryptSevLib to clear the memory encryption mask from the
> page table. It created a dependency, as shown below
> 
> OvmfPkg/FvbServicesSmm.inf
>  ---> MemEncryptSevLib   class
>  ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"  instance
>  ---> VmgExitLib
>  ---> "OvmfPkg/VmgExitLib"instance
>  ---> LocalApicLib   class
>  ---> UefiCpuPkg/BaseXApicX2ApicLib/BaseXApicX2ApicLib.infinstance
>  ---> TimerLib   class
>  ---> "OvmfPkg/AcpiTimerLib/DxeAcpiTimerLib.inf"  instance
>  ---> PciLib class
>  ---> "OvmfPkg/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf" instance
> 
> The LocalApicLib provides a constructor, execution of the constructor
> causes an exception. The SEV-ES and SEV-SNP do not support the SMM, so
> skip including the VmgExitLib chain. Use the module override to use the
> VmgExitLibNull to avoid the inclusion of unneeded LocalApicLib dependency
> chain in FvbServicesSmm. We ran similar issue for AmdSevDxe driver,
> see commit 19914edc5a0202cc7830f819ffac7e7b2368166a
> 
> After the patch, the dependency look like this:
> 
> OvmfPkg/FvbServicesSmm.inf
>  ---> MemEncryptSevLib   class
>  ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"  instance
>  ---> VmgExitLib
>  ---> "UefiCpuPkg/Library/VmgExitLibNull"instance
> 
> Fixes: ade62c18f4742301bbef474ac10518bde5972fba
> Reported-by: Aaron Young 
> Cc: Dann Frazier 
> Cc: Michael Roth 
> Cc: James Bottomley 
> Cc: Min Xu 
> Cc: Jiewen Yao 
> Cc: Tom Lendacky 
> Cc: Jordan Justen 
> Cc: Ard Biesheuvel 
> Cc: Erdem Aktas 
> Cc: Gerd Hoffmann 
> Signed-off-by: Brijesh Singh 

Thanks for the quick fix Brijesh!

Tested-by: dann frazier 

  -dann

> ---
>  OvmfPkg/CloudHv/CloudHvX64.dsc | 5 -
>  OvmfPkg/OvmfPkgIa32.dsc| 5 -
>  OvmfPkg/OvmfPkgIa32X64.dsc | 5 -
>  OvmfPkg/OvmfPkgX64.dsc | 5 -
>  4 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
> index 8ac9227c5f50..3172100310b1 100644
> --- a/OvmfPkg/CloudHv/CloudHvX64.dsc
> +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
> @@ -906,7 +906,10 @@ [Components]
>#
># Variable driver stack (SMM)
>#
> -  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
> +  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
> +
> +VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> +  }
>MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
>MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
>  
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 29eea82571c5..85abed24c1a7 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -956,7 +956,10 @@ [Components]
>#
># Variable driver stack (SMM)
>#
> -  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
> +  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
> +
> +VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> +  }
>MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
>MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
>  
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 56d3c49ab21a..a9c1daecc1a8 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -974,7 +974,10 @@ [Components.X64]
>#
># Variable driver stack (SMM)
>#
> -  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
> +  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
> +
> +VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> +  }
>MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
>MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
>  
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index f0924c0f9d0a..718399299f57 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -971,7 +971,10 @@ [Components]
>#
># Variable driver stack (SMM)
>#
> -  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
> +  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
> +
> +VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> +  }
>MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
>MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
>  


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You 

[edk2-devel] [PATCH 1/1] OvmfPkg/FvbServicesSmm: use the VmgExitLibNull

2022-02-15 Thread Brijesh Singh via groups.io
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3835

The commit ade62c18f4742301bbef474ac10518bde5972fba caused a boot failure
when OVMF is build with SECURE_BOOT/SMM enabled.

This happen because the above commit extended the BaseMemEncryptSevLib.inf
to include VmgExitLib. The FvbServicesSmm uses the functions provided
by the MemEncryptSevLib to clear the memory encryption mask from the
page table. It created a dependency, as shown below

OvmfPkg/FvbServicesSmm.inf
 ---> MemEncryptSevLib   class
 ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"  instance
 ---> VmgExitLib
 ---> "OvmfPkg/VmgExitLib"instance
 ---> LocalApicLib   class
 ---> UefiCpuPkg/BaseXApicX2ApicLib/BaseXApicX2ApicLib.infinstance
 ---> TimerLib   class
 ---> "OvmfPkg/AcpiTimerLib/DxeAcpiTimerLib.inf"  instance
 ---> PciLib class
 ---> "OvmfPkg/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf" instance

The LocalApicLib provides a constructor, execution of the constructor
causes an exception. The SEV-ES and SEV-SNP do not support the SMM, so
skip including the VmgExitLib chain. Use the module override to use the
VmgExitLibNull to avoid the inclusion of unneeded LocalApicLib dependency
chain in FvbServicesSmm. We ran similar issue for AmdSevDxe driver,
see commit 19914edc5a0202cc7830f819ffac7e7b2368166a

After the patch, the dependency look like this:

OvmfPkg/FvbServicesSmm.inf
 ---> MemEncryptSevLib   class
 ---> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"  instance
 ---> VmgExitLib
 ---> "UefiCpuPkg/Library/VmgExitLibNull"instance

Fixes: ade62c18f4742301bbef474ac10518bde5972fba
Reported-by: Aaron Young 
Cc: Dann Frazier 
Cc: Michael Roth 
Cc: James Bottomley 
Cc: Min Xu 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Cc: Jordan Justen 
Cc: Ard Biesheuvel 
Cc: Erdem Aktas 
Cc: Gerd Hoffmann 
Signed-off-by: Brijesh Singh 
---
 OvmfPkg/CloudHv/CloudHvX64.dsc | 5 -
 OvmfPkg/OvmfPkgIa32.dsc| 5 -
 OvmfPkg/OvmfPkgIa32X64.dsc | 5 -
 OvmfPkg/OvmfPkgX64.dsc | 5 -
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index 8ac9227c5f50..3172100310b1 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -906,7 +906,10 @@ [Components]
   #
   # Variable driver stack (SMM)
   #
-  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
+  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
+
+VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
+  }
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
 
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 29eea82571c5..85abed24c1a7 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -956,7 +956,10 @@ [Components]
   #
   # Variable driver stack (SMM)
   #
-  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
+  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
+
+VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
+  }
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
 
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 56d3c49ab21a..a9c1daecc1a8 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -974,7 +974,10 @@ [Components.X64]
   #
   # Variable driver stack (SMM)
   #
-  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
+  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
+
+VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
+  }
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
 
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index f0924c0f9d0a..718399299f57 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -971,7 +971,10 @@ [Components]
   #
   # Variable driver stack (SMM)
   #
-  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
+  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf {
+
+VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
+  }
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
 
-- 
2.25.1



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




Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg/VmgExitLib: Fix uninitialized variable warning with XCODE5

2022-02-15 Thread Ard Biesheuvel
On Fri, 11 Feb 2022 at 02:14, gaoliming  wrote:
>
> Ard:
>  I am OK to merge this issue for this stable tag. It is a clear bug fix.
>

Merged as #2523

Thanks all,


> > -邮件原件-
> > 发件人: Ard Biesheuvel 
> > 发送时间: 2022年2月10日 17:18
> > 收件人: edk2-devel-groups-io ; Rebecca Cran
> > ; Liming Gao (Byosoft address)
> > 
> > 抄送: James Bottomley ; Min Xu
> > ; Jiewen Yao ; Tom Lendacky
> > ; Jordan Justen ;
> > Ard Biesheuvel ; Erdem Aktas
> > ; Michael Roth ; Gerd
> > Hoffmann ; Brijesh Singh 
> > 主题: Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg/VmgExitLib: Fix uninitialized
> > variable warning with XCODE5
> >
> > On Thu, 10 Feb 2022 at 10:17, Ard Biesheuvel  wrote:
> > >
> > > (+ Liming)
> > >
> >
> > ... for real this time.
> >
> > > On Fri, 4 Feb 2022 at 21:28, Rebecca Cran 
> > wrote:
> > > >
> > > > XCODE5 reported the following warning:
> > > >
> > > > OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c:1895:12: note:
> > > > uninitialized use occurs here
> > > >Compacted
> > > >^
> > > >
> > > > Initialize the 'Compacted' variable to fix the warning.
> > > >
> > > > Signed-off-by: Rebecca Cran 
> > > > ---
> > > >  OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
> > b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
> > > > index a40a31f7c275..ccb1300690fa 100644
> > > > --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
> > > > +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
> > > > @@ -1872,6 +1872,7 @@ GetCpuidFw (
> > > >  UINT32 XSaveSize;
> > > >
> > > >  XssMsr.Uint64 = 0;
> > > > +Compacted = 0;
> > >
> > > This should be FALSE not 0. I will fix this up before merging.
> > >
> > > Liming: is it ok if I merge this today?
> > >
> > >
> > > >  if (EcxIn == 1) {
> > > >/*
> > > > * The PPR and APM aren't clear on what size should be
> > encoded in
> > > > --
> > > > 2.34.1
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
>
>
>
>
> 
>
>


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




[edk2-devel] [PATCH v3] MdePkg/Include: Add ARM specific definitions for CPER

2022-02-15 Thread Ming Huang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3838

These definitions are added according UEFI spec 2.9.

Signed-off-by: Ming Huang 
---
 MdePkg/Include/Guid/Cper.h | 522 +
 1 file changed, 522 insertions(+)

diff --git a/MdePkg/Include/Guid/Cper.h b/MdePkg/Include/Guid/Cper.h
index deb96d4af9..249e40d8d7 100644
--- a/MdePkg/Include/Guid/Cper.h
+++ b/MdePkg/Include/Guid/Cper.h
@@ -736,6 +736,528 @@ typedef struct {
 
 #endif
 
+#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
+///
+/// ARM and AARCH64 Specific definitions.
+///
+
+///
+/// The validation bit mask indicates which fields in the processor error
+/// structure are valid.
+///@{
+#define EFI_ERROR_SECTION_MPIDR_VALID   BIT0
+#define EFI_ERROR_SECTION_AFFINITY_LEVEL_VALID  BIT1
+#define EFI_ERROR_SECTION_RUNNING_STATE_VALID   BIT2
+#define EFI_ERROR_SECTION_VENDOR_SPEC_VALID BIT3
+///@}
+
+//
+// ARM Processor Error Section
+//
+typedef struct {
+  UINT32  ValidFields;
+  UINT16  ErrorInfoNum;
+  UINT16  ContextInfoNum;
+  UINT32  SectionLength;
+  UINT8   AffinityLevel;
+  UINT8   Reserved[3];
+  UINT64  Mpidr;
+  UINT64  Midr;
+  UINT32  RunningState;
+  UINT32  PsciState;
+} EFI_ARM_PROCESSOR_ERROR_SECTION;
+
+///
+/// The validation bit mask indicates which fields in the processor error data
+/// structure are valid.
+///@{
+#define EFI_ERROR_DATA_MULTIPLE_ERROR_VALID  BIT0
+#define EFI_ERROR_DATA_FLAGS_VALID   BIT1
+#define EFI_ERROR_DATA_ERROR_INFO_VALID  BIT2
+#define EFI_ERROR_DATA_VIRTUAL_ADDRESS_VALID BIT3
+#define EFI_ERROR_DATA_PHYSICAL_ADDRESS_VALIDBIT3
+///@}
+
+///
+/// The Type error in the processor error data structure.
+///@{
+#define EFI_ERROR_DATA_TYPE_CACHE0
+#define EFI_ERROR_DATA_TYPE_TLB  1
+#define EFI_ERROR_DATA_TYPE_BUS  2
+#define EFI_ERROR_DATA_TYPE_VENDOR_SPEC  3
+///@}
+
+///
+/// The options of multiple error in the processor error data structure.
+///@{
+#define EFI_ERROR_DATA_ERROR_SINGLE  0
+#define EFI_ERROR_DATA_ERROR_MULTIPLE1
+///@}
+
+///
+/// The options of flags in the processor error data structure.
+///@{
+#define EFI_ERROR_DATA_FLAG_FIRST_ERROR   BIT0
+#define EFI_ERROR_DATA_FLAG_LAST_ERRORBIT1
+#define EFI_ERROR_DATA_FLAG_PROPAGATEDBIT2
+#define EFI_ERROR_DATA_FLAG_OVERFLOW  BIT3
+///@}
+
+//
+// ARM Processor Error Information Structure
+//
+typedef struct {
+  UINT8   Version;
+  UINT8   Length;
+  UINT16  ValidFields;
+  UINT8   Type;
+  UINT16  MultipleError;
+  UINT8   Flags;
+  UINT64  ErrorInfo;
+  UINT64  VirtualFaultAddress;
+  UINT64  PhysicalFaultAddress;
+} EFI_ARM_PROCESSOR_ERROR_DATA;
+
+//
+///
+/// The validation bit mask indicates which fields in the Cache info structure
+/// are valid.
+///@{
+#define EFI_CACHE_INFO_TRANSACTION_TYPE_VALID   BIT0
+#define EFI_CACHE_INFO_OPERATION_VALID  BIT1
+#define EFI_CACHE_INFO_LEVEL_VALID  BIT2
+#define EFI_CACHE_INFO_CONTEXT_CORRUPT_VALIDBIT3
+#define EFI_CACHE_INFO_CORRECTED_VALID  BIT4
+#define EFI_CACHE_INFO_PRECISE_PC_VALID BIT5
+#define EFI_CACHE_INFO_RESTARTABLE_PC_VALID BIT6
+///@}
+
+///
+/// Type of cache error in the Cache info structure
+///@{
+#define EFI_CACHE_INFO_ERROR_TYPE_INSTRUCTION   0
+#define EFI_CACHE_INFO_ERROR_TYPE_DATA_ACCESS   1
+#define EFI_CACHE_INFO_ERROR_TYPE_GENERIC   2
+///@}
+
+///
+/// Type of cache operation that caused the error in the Cache info structure
+///@{
+#define EFI_CACHE_INFO_OPERATION_TYPE_GENERIC 0
+#define EFI_CACHE_INFO_OPERATION_TYPE_GENERIC_READ1
+#define EFI_CACHE_INFO_OPERATION_TYPE_GENERIC_WRITE   2
+#define EFI_CACHE_INFO_OPERATION_TYPE_DATA_READ   3
+#define EFI_CACHE_INFO_OPERATION_TYPE_DATA_WRITE  4
+#define EFI_CACHE_INFO_OPERATION_TYPE_INSTRUCTION_FETCH   5
+#define EFI_CACHE_INFO_OPERATION_TYPE_PREFETCH6
+#define EFI_CACHE_INFO_OPERATION_TYPE_EVICTION7
+#define EFI_CACHE_INFO_OPERATION_TYPE_SNOOPING8
+#define EFI_CACHE_INFO_OPERATION_TYPE_SNOOPED 9
+#define EFI_CACHE_INFO_OPERATION_TYPE_MANAGEMENT  10
+///@}
+
+///
+/// Options of Processor context in the Cache info structure
+///@{
+#define EFI_CACHE_INFO_CONTEXT_NOT_CORRUPTED   0
+#define EFI_CACHE_INFO_CONTEXT_CORRUPTED   1
+///@}
+
+///
+/// Error severity in the Cache info structure
+///@{
+#define EFI_CACHE_INFO_ERROR_SEVERITY_UNCORRECTED  0
+#define EFI_CACHE_INFO_ERROR_SEVERITY_CORRECTED1
+///@}
+
+//
+// ARM Processor Cache Error Structure
+//
+typedef struct {
+  UINT64  ValidBit:16;
+  UINT64  CacheType:2;
+  UINT64  Operation:4;
+  UINT64  CacheLevel:3;
+  UINT64  ContextCorrupt:1;
+  UINT64  Corrected:1;
+  UINT64  PrecisePc:1;
+  UINT64  

Re: [edk2-devel] [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure

2022-02-15 Thread Gao, Zhichao
Reviewed-by: Zhichao Gao 

Thanks,
Zhichao

> -Original Message-
> From: Rehan, MohammedX 
> Sent: Tuesday, February 15, 2022 4:07 PM
> To: devel@edk2.groups.io; Esakkithevar, Kathappan
> ; Gao, Zhichao
> ; Ni, Ray ; Pethaiyan, Madhan
> 
> Cc: Thirupugal, MadhaviX ; Rehan,
> MohammedX 
> Subject: [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3819
> 
> Ping GetTimerPeriod API returns sometime zero value when StallCounter has
> smaller value than RttTimerTick (divide by zero) which results some failure at
> ping UEFI shell command
> 
> Signed-off-by: MohammedX Rehan 
> ---
>  ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> index ec1e0a188b..6a002b15e5 100644
> --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
> @@ -259,9 +259,11 @@ GetTimerPeriod (
>EFI_EVENT   TimerEvent;   UINT32  StallCounter;   EFI_TPL OldTpl;+
> UINT32  TimerPeriod;RttTimerTick = 0;   StallCounter = 0;+  
> TimerPeriod  =
> 0;Status = gBS->CreateEvent (   EVT_TIMER |
> EVT_NOTIFY_SIGNAL,@@ -295,7 +297,12 @@ GetTimerPeriod (
>gBS->SetTimer (TimerEvent, TimerCancel, 0);   gBS->CloseEvent
> (TimerEvent); -  return StallCounter / RttTimerTick;+  TimerPeriod =
> StallCounter / RttTimerTick;+  if (TimerPeriod != 0) {+return 
> TimerPeriod;+  }
> else {+return 1;+  } }  /**--
> 2.30.0.windows.2



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




Re: [edk2-devel] Please comment on the XhciDxe driver and UsbMassStorageDxe driver optimization suggestions

2022-02-15 Thread liuyang
Hello,




After verification, the Caton phenomenon of quickly inserting and pulling out 
USB devices under the UEFI shell mentioned in the last email exists on the X86 
platform. 

Please see whether my optimization suggestions in the public code mentioned in 
the last email are feasible.




Best regards,
Look forward to your reply,

Wilhelm

-原始邮件-
发件人:"刘阳" 
发送时间:2022-02-15 14:28:05 (星期二)
收件人: devel@edk2.groups.io
抄送: ray...@intel.com
主题: Please comment on the XhciDxe driver and UsbMassStorageDxe driver 
optimization suggestions






Hello,

Recently, we found that when we plug and remove USB3.0 devices quickly under 
UEFI Shell on LoongArch platform, 

there will be a lag of about 3~15 minutes (the keyboard and mouse do not 
reflect under Setup), which looks like the system has halted.




Here we find two possible areas that can be improved.Please take a look and 
comment.




In xhcidxe driver, XhcBulkTransfer will be called and XhcTransfer  is called 
inside. Its function is to submit a new transaction to a target USB device 

If we unplug the USB device at this time, the xhci driver will call 
RecoveryStatus =  XhcDequeueTrbFromEndpoint(Xhc, Urb); Whose function is Abort 
the transfer 

by dequeueing of the TD. is the function required?  Because the USB device is 
no longer on the USB port at this time, and the process is relatively slow, 

can we change the code of this part into the following form without using this 
function:




diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c 
b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
index 9b26e46a..d877b0f6 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
@@ -716,6 +716,7 @@ ON_EXIT:
   return Status;
 }
 
+#if 0
 /** 
   Submits a new transaction to a target USB device.
 
@@ -784,7 +785,9 @@ XhcTransfer (
 //  
 // The transfer timed out. Abort the transfer by dequeueing of the TD. 
 //  
 RecoveryStatus = XhcDequeueTrbFromEndpoint(Xhc, Urb);
 if (RecoveryStatus == EFI_ALREADY_STARTED) {
   //
   // The URB is finished just before stopping endpoint.
@@ -813,6 +816,7 @@ XhcTransfer (
   XhcFreeUrb (Xhc, Urb);
   return Status;
 }
+#endif
 
 /** 
   Submits control transfer to a target USB device.
@@ -855,6 +859,7 @@ XhcControlTransfer (
   )   
 {
   USB_XHCI_INSTANCE   *Xhc;
+  URB *Urb;
   UINT8   Endpoint;
   UINT8   Index;
   UINT8   DescriptorType;
@@ -865,6 +870,7 @@ XhcControlTransfer (
   EFI_USB_HUB_DESCRIPTOR  *HubDesc;
   EFI_TPL OldTpl;
   EFI_STATUS  Status;
+  EFI_STATUS  RecoveryStatus;
   UINTN   MapSize;
   EFI_USB_PORT_STATUS PortStatus;
   UINT32  State;
@@ -971,6 +977,8 @@ XhcControlTransfer (




   // combination of Ep addr and its direction.
   //
   Endpoint = (UINT8) (0 | ((TransferDirection == EfiUsbDataIn) ? 0x80 : 0));
+
+#if 0
   Status = XhcTransfer (
  Xhc,
  DeviceAddress,
@@ -988,6 +996,49 @@ XhcControlTransfer (
   if (EFI_ERROR (Status)) {
 goto ON_EXIT;
   }
+#endif
+
+#if 1
+  Urb = XhcCreateUrb (
+  Xhc,
+  DeviceAddress,
+  Endpoint,
+  DeviceSpeed,
+  MaximumPacketLength,
+  XHC_CTRL_TRANSFER,
+  Request,
+  Data,
+  *DataLength,
+  NULL,
+  NULL
+  );
+
+  if (Urb == NULL) {
+DEBUG ((DEBUG_ERROR, "XhcControlTransfer: failed to create URB!\n"));
+Status = EFI_OUT_OF_RESOURCES;
+goto ON_EXIT;
+  }
+
+  Status = XhcExecTransfer (Xhc, FALSE, Urb, Timeout);
+
+  *TransferResult = Urb->Result;
+  *DataLength = Urb->Completed;
+
+  if (*TransferResult == EFI_USB_NOERROR) {
+Status = EFI_SUCCESS;
+  } else if (*TransferResult == EFI_USB_ERR_STALL) {
+RecoveryStatus = XhcRecoverHaltedEndpoint(Xhc, Urb);
+
+if (EFI_ERROR (RecoveryStatus)) {
+  DEBUG ((EFI_D_VERBOSE, "XhcControlTransfer: XhcRecoverHaltedEndpoint 
failed\n"));
+}
+Status = EFI_DEVICE_ERROR;
+  }
+
+  Xhc->PciIo->Flush (Xhc->PciIo);
+  XhcFreeUrb (Xhc, Urb);
+
+#endif



   //
   // Hook Get_Descriptor request from UsbBus as we need evaluate context and 
configure endpoint.
@@ -1223,9 +1274,11 @@ XhcBulkTransfer (
   )
 {
   USB_XHCI_INSTANCE   *Xhc;
+  URB *Urb;
   UINT8   SlotId;
   EFI_STATUS  Status;
   EFI_TPL OldTpl;
+  EFI_STATUS  RecoveryStatus;
 
   //
   // Validate the parameters
@@ -1270,6 +1323,7 @@ XhcBulkTransfer (
   // Create a new URB, insert it into the asynchronous
   // schedule list, then poll the execution status.
   //
+#if 0
   Status = XhcTransfer (
  Xhc,
  DeviceAddress,
@@ -1283,6 +1337,46 @@ XhcBulkTransfer (
  Timeout,
  TransferResult
  );
+#endif
+
+  Urb = XhcCreateUrb (
+  Xhc,
+  DeviceAddress,

[edk2-devel] [PATCH] ShellPkg: Fix Ping GetTimerPeriod API failure

2022-02-15 Thread MohammedX Rehan
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3819

Ping GetTimerPeriod API returns sometime zero value when
StallCounter has smaller value than RttTimerTick (divide by zero)
which results some failure at ping UEFI shell command

Signed-off-by: MohammedX Rehan 
---
 ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
index ec1e0a188b..6a002b15e5 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
@@ -259,9 +259,11 @@ GetTimerPeriod (
   EFI_EVENT   TimerEvent;
   UINT32  StallCounter;
   EFI_TPL OldTpl;
+  UINT32  TimerPeriod;
 
   RttTimerTick = 0;
   StallCounter = 0;
+  TimerPeriod  = 0;
 
   Status = gBS->CreateEvent (
   EVT_TIMER | EVT_NOTIFY_SIGNAL,
@@ -295,7 +297,12 @@ GetTimerPeriod (
   gBS->SetTimer (TimerEvent, TimerCancel, 0);
   gBS->CloseEvent (TimerEvent);
 
-  return StallCounter / RttTimerTick;
+  TimerPeriod = StallCounter / RttTimerTick;
+  if (TimerPeriod != 0) {
+return TimerPeriod;
+  } else {
+return 1;
+  }
 }
 
 /**
-- 
2.30.0.windows.2



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