Re: 回复: [edk2-devel] [PATCH] UsbNetworkPkg: add USB network devices support

2022-09-22 Thread RichardHo [何明忠] via groups . io
Hi Liming,

RNDIS specification is not defines this.
We're follow the ECM (5.4 Ethernet Networking Functional Descriptor) and NCM 
(5.2.1 NCM Functional Descriptor)specification to implement RNDIS driver.

If RNDIS device has other way to know the networking functional information.
We could implement the code to GetUsbHeaderFunDescriptor, 
GetUsbUnionFunDescriptor, and GetUsbRndisFunDescriptor routine.

Thanks,
Richard

-Original Message-
From: gaoliming 
Sent: 2022年9月23日 1:03 PM
To: devel@edk2.groups.io; RichardHo [何明忠] ; 'Rebecca Cran' 

Cc: 'Andrew Fish' ; 'Leif Lindholm' 
; 'Michael D Kinney' ; 
'Michael Kubacki' ; 'Zhiguang Liu' 
; TonyLo [羅金松] 
Subject: [EXTERNAL] 回复: [edk2-devel] [PATCH] UsbNetworkPkg: add USB network 
devices support


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

Richard:
  We also verify USB RNDIS module with open BMC. It reports USB RNDIS device 
descriptor type is USB_DESC_TYPE_INTERFACE (0x04). It is not supported by Rndis 
module.

  But in UsbNetworkPkg\Include\Protocol\UsbEthernetProtocol.h, it defines 
CS_INTERFACE as 0x24. Rndis module only supports this descriptor type.

  So, I want to confirm which specification defines device descriptor type
0x24 and its related structure HEADER_FUN_DESCRIPTOR/ UNION_FUN_DESCRIPTOR/ 
ETHERNET_FUN_DESCRIPTOR.

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 RichardHo
> [何明忠] via groups.io
> 发送时间: 2022年9月7日 13:31
> 收件人: Rebecca Cran ; devel@edk2.groups.io
> 抄送: Andrew Fish ; Leif Lindholm
> ; Michael D Kinney
> ; Michael Kubacki
> ; Zhiguang Liu
> ; Liming Gao ;
> TonyLo [羅金松]
> 
> 主题: Re: [edk2-devel] [PATCH] UsbNetworkPkg: add USB network devices
> support
>
> Hi Rebecca,
>
> We didn't check it in QEMU.
> Is QEMU report standard USB RNDIS protocol?
>
> We only test it in physical device. Below is device lists.
>
> USB RNDIS:
> AST2500: BMC report the RNDIS device
>
> USB NCM:
> DisplayLink HIS USB3.0 Portable Dock(DisplayLink (UK) Ltd.) Vendor ID:
> 0x17E9 Product ID: 0x4301
>
> USB ECM:
> DM9621(Davicom Semiconductor, Inc.)
> Vendor ID: 0x0A46
> Product ID: 0x1269
>
> Thanks,
> Richard
>
> -Original Message-
> From: Rebecca Cran 
> Sent: 2022年9月6日 11:05 PM
> To: devel@edk2.groups.io; RichardHo [何明忠] 
> Cc: Andrew Fish ; Leif Lindholm
> ; Michael D Kinney
> ; Michael Kubacki
> ; Zhiguang Liu
> ; Liming Gao ;
> TonyLo [羅金松]
> 
> Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] UsbNetworkPkg: add USB
> network devices support
>
>
> **CAUTION: The e-mail below is from an external source. Please
> exercise caution before opening attachments, clicking links, or following 
> guidance.
**
>
> Is it expected that this will work with QEMU (with the usb-net fixes
> from
> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> u b.com%2Fmcb30%2Fqemu%2Ftree%2Fusbnet3data=05%7C01%7Crich
> ardho%40ami.com%7C1dd20e124cd64659b4e908da90193dd3%7C27e97857
> e15f486cb58e86c2b3040f93%7C1%7C0%7C637980735342252066%7CUnkno
> wn%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1h
> aWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=xHRQc%2Fnv7fP
> k%2BPEVavIlfFpaXj6Gq8NiHUsRdd5HD%2Fc%3Dreserved=0),
> for example using the SBSA-REF machine for Arm or OVMF for X64?
>
> I'm adding the following parameters to QEMU:
>
> -netdev user,id=net0,net=192.168.10.0/24,dhcpstart=192.168.10.1
> -device
> usb-net,netdev=net0
>
>
> On OVMF I get the following crash when loading UsbRndis.efi after
> NetworkCommon.efi:
>
> Support(): UNDI3.1 found on handle 6550D18
> Support(): supported on 6550D18
> Start(): UNDI3.1 found
>  X64 Exception Type - 06(#UD - Invalid Opcode)  CPU Apic ID -
>  
> RIP  - 000B0001, CS  - 0038, RFLAGS -
> 0283 RAX  - 0653AF80, RCX - 065DC382, RDX
> - 5441 RBX  - 065D8000, RSP - 07E8EA48,
> RBP - 065DB001 RSI  - 0048, RDI - 06CE82C0
> R8   - 07E8EA60, R9  - 07E8EAD0, R10 -
> 07E8E804
> R11  - , R12 - 8003, R13 -
> 0001
> R14  - 06CEE640, R15 - 0006
> DS   - 0030, ES  - 0030, FS  -
> 0030
> GS   - 0030, SS  - 0030
> CR0  - 80010033, CR2 - , CR3 -
> 07C01000
> CR4  - 0668, CR8 - 
> DR0  - , DR1 - , DR2 -
> 
> DR3  - , DR6 - 0FF0, DR7 -
> 0400 GDTR - 079DE000 0047, LDTR -
> 
> IDTR - 0753C018 0FFF,   TR - 
> FXSAVE_STATE - 07E8E6A0
>  Can't find image information. 
>
>
> On Arm, I don't get a crash but no network interface gets created.
> I've checked the QEMU RNDIS interface is working: if I boot to Linux I
> can

Re: [edk2-devel] [PATCH 1/1] OvmfPkg: Store PageTablePool in TdxWorkArea

2022-09-22 Thread Gerd Hoffmann
On Thu, Sep 22, 2022 at 04:43:04AM +, Xu, Min M wrote:
> Hi, Gerd
> Do you have any comments on this patch?

Looks ok to me.

But I'm increasingly wondering whenever it actually was that a smart
move to ditch the PEI phase for the IntelTdx builds.  Anything which
can't be handled in DXE must be done in SEC, and the SEC restrictions
seem to be a constant struggle.

We had that when adding tdx measurement support which required sha*
hash support for SEC.  And this looks like another case ...

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#94166): https://edk2.groups.io/g/devel/message/94166
Mute This Topic: https://groups.io/mt/93517163/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/3] CryptoPkg: Add EC support

2022-09-22 Thread Michael D Kinney
Hi Yi,

I agree there are some complex interactions in the opensll sources.

Since you are defining a family for EC, can we use the EC Family != 0 instead of
PcdOpensslEcEnabled and remove PcdOpensslEcEnabled.

I want to make sure developers do not run into strange build failures if
they do not keep the 2 different PCDs aligned.  I prefer a single PCD 
setting to enable use of EC services.

I also noticed that the use of a PCD expression in an INF to select source
files does not work if the PCD value is specified with the --pcd flag on
the build command line.  This looks like a significant bug with the PCD
expression in an INF file.  This also needs to be fixed.

Mike

> -Original Message-
> From: Li, Yi1 
> Sent: Thursday, September 22, 2022 8:02 PM
> To: Kinney, Michael D ; devel@edk2.groups.io
> Cc: Yao, Jiewen ; Wang, Jian J ; 
> Lu, Xiaoyu1 ; Jiang,
> Guomin 
> Subject: RE: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support
> 
> Hi Mike,
> 
> 1. Yes, it matches.
> By Intel side, 100+kb(20%+) FV size increase will be a big concern, please 
> refer to another internal email.
> 
> 2. Additional size is coming from modules may consumed EC APIs, eg. TLS PEM 
> X509  ...
> 
> If we added EC source to OpensslLib.inf and disabled macro OPENSSL_NO_EC, 
> those modules will link EC APIs and increase binary
> size,
> This an example from x509/x_pubkey.c , other modules is similar:
> #ifndef OPENSSL_NO_EC
> EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length)
> {
> EVP_PKEY *pkey;
> EC_KEY *key = NULL;
> // call EC functions
> }
> #endif
> 
> If we added EC source to OpensslLib.inf and enable macro OPENSSL_NO_EC, EC 
> module will throw build error,
> Since some EC internal APIs or structs have been disabled by OPENSSL_NO_EC 
> but  not another.
> This an example from ec/ec_local.h , other error is similar:
> 
> #ifndef OPENSSL_NO_EC
> typedef struct ec_group_st EC_GROUP;
> typedef struct ec_point_st EC_POINT;
> #endif
> 
> // but this function not been enclosed by OPENSSL_NO_EC, and will throw build 
> error
> int (*point_set_Jprojective_coordinates_GFp) (const EC_GROUP *,
>   EC_POINT *, const BIGNUM *x,
>   const BIGNUM *y,
>   const BIGNUM *z, BN_CTX *);
> 
> To avoid this annoying openssl error, we introduced conditional EC.
> 
> Thanks,
> Yi
> 
> -Original Message-
> From: Kinney, Michael D 
> Sent: Friday, September 23, 2022 6:47 AM
> To: Li, Yi1 ; devel@edk2.groups.io; Kinney, Michael D 
> 
> Cc: Yao, Jiewen ; Wang, Jian J ; 
> Lu, Xiaoyu1 ; Jiang,
> Guomin 
> Subject: RE: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support
> 
> Hi Yi,
> 
> I agree EC is an important feature.
> 
> I did some analysis of the size impact to the CryptoPkg modules on current 
> trunk
> with EC on and off. Uncompressed size is important for PEI Phase.  For DXE and
> SMM phase, the Crypto services can always be compressed.  From the table 
> below,
> building all the EC services in the OpensslLib has no size impact to the NONE
> profile and the MIN_PEI profile.  It has ~105 KB impact to compressed DXE/SMM
> usages that may use the MIN_DXE_MIN_SMM or ALL profiles.
> 
>Uncompressed  LZMA Compressed
> CPU   CRYPTO_SERVICESModule  EC=FALSE  EC=TRUE  EC=FALSE  EC=TRUE  
> Increase
>   ===      ===    ===  
> 
> IA32  NONE CryptoPei2153621568 0 
> KB
> IA32  NONE CryptoDxe2163221696 0 
> KB
> IA32  NONE CryptoSmm2297623072 0 
> KB
> IA32  MIN_PEI  CryptoPei   248992   249120 0 
> KB
> IA32  MIN_DXE_MIN_SMM  CryptoDxe   636672   829568288520   401034113 
> KB
> IA32  MIN_DXE_MIN_SMM  CryptoSmm   426048   601472191517   296022105 
> KB
> IA32  ALL  CryptoPei   423840   598976189047   293759104 
> KB
> IA32  ALL  CryptoDxe   645280   838144292955   405277113 
> KB
> IA32  ALL  CryptoSmm   441888   617184198779   303628105 
> KB
> X64   NONE CryptoPei2963229664 0 
> KB
> X64   NONE CryptoDxe2979229792 0 
> KB
> X64   NONE CryptoSmm3129631296 0 
> KB
> X64   MIN_PEI  CryptoPei   310784   310848 0 
> KB
> X64   MIN_DXE_MIN_SMM  CryptoDxe   804288  1016256311436   426596115 
> KB
> X64   MIN_DXE_MIN_SMM  CryptoSmm   543776   733920204483   310775106 
> KB
> X64   ALL  CryptoPei   540384   730240202494   308467106 
> KB
> X64   ALL  CryptoDxe   815392  1027296316228   431321115 
> KB
> X64  

回复: [edk2-devel] [PATCH] UsbNetworkPkg: add USB network devices support

2022-09-22 Thread gaoliming via groups.io
Richard:
  We also verify USB RNDIS module with open BMC. It reports USB RNDIS device
descriptor type is USB_DESC_TYPE_INTERFACE (0x04). It is not supported by
Rndis module.

  But in UsbNetworkPkg\Include\Protocol\UsbEthernetProtocol.h, it defines
CS_INTERFACE as 0x24. Rndis module only supports this descriptor type. 

  So, I want to confirm which specification defines device descriptor type
0x24 and its related structure HEADER_FUN_DESCRIPTOR/ UNION_FUN_DESCRIPTOR/
ETHERNET_FUN_DESCRIPTOR.

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 RichardHo
> [何明忠] via groups.io
> 发送时间: 2022年9月7日 13:31
> 收件人: Rebecca Cran ; devel@edk2.groups.io
> 抄送: Andrew Fish ; Leif Lindholm
> ; Michael D Kinney
> ; Michael Kubacki
> ; Zhiguang Liu ;
> Liming Gao ; TonyLo [�_金松]
> 
> 主题: Re: [edk2-devel] [PATCH] UsbNetworkPkg: add USB network devices
> support
> 
> Hi Rebecca,
> 
> We didn't check it in QEMU.
> Is QEMU report standard USB RNDIS protocol?
> 
> We only test it in physical device. Below is device lists.
> 
> USB RNDIS:
> AST2500: BMC report the RNDIS device
> 
> USB NCM:
> DisplayLink HIS USB3.0 Portable Dock(DisplayLink (UK) Ltd.)
> Vendor ID: 0x17E9
> Product ID: 0x4301
> 
> USB ECM:
> DM9621(Davicom Semiconductor, Inc.)
> Vendor ID: 0x0A46
> Product ID: 0x1269
> 
> Thanks,
> Richard
> 
> -Original Message-
> From: Rebecca Cran 
> Sent: 2022年9月6日 11:05 PM
> To: devel@edk2.groups.io; RichardHo [何明忠] 
> Cc: Andrew Fish ; Leif Lindholm
> ; Michael D Kinney
> ; Michael Kubacki
> ; Zhiguang Liu ;
> Liming Gao ; TonyLo [�_金松]
> 
> Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] UsbNetworkPkg: add USB
> network devices support
> 
> 
> **CAUTION: The e-mail below is from an external source. Please exercise
> caution before opening attachments, clicking links, or following guidance.
**
> 
> Is it expected that this will work with QEMU (with the usb-net fixes from
> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithu
> b.com%2Fmcb30%2Fqemu%2Ftree%2Fusbnet3data=05%7C01%7Crich
> ardho%40ami.com%7C1dd20e124cd64659b4e908da90193dd3%7C27e97857
> e15f486cb58e86c2b3040f93%7C1%7C0%7C637980735342252066%7CUnkno
> wn%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1h
> aWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=xHRQc%2Fnv7fP
> k%2BPEVavIlfFpaXj6Gq8NiHUsRdd5HD%2Fc%3Dreserved=0),
> for example using the SBSA-REF machine for Arm or OVMF for X64?
> 
> I'm adding the following parameters to QEMU:
> 
> -netdev user,id=net0,net=192.168.10.0/24,dhcpstart=192.168.10.1 -device
> usb-net,netdev=net0
> 
> 
> On OVMF I get the following crash when loading UsbRndis.efi after
> NetworkCommon.efi:
> 
> Support(): UNDI3.1 found on handle 6550D18
> Support(): supported on 6550D18
> Start(): UNDI3.1 found
>  X64 Exception Type - 06(#UD - Invalid Opcode)  CPU Apic ID -
>  
> RIP  - 000B0001, CS  - 0038, RFLAGS -
> 0283 RAX  - 0653AF80, RCX - 065DC382,
> RDX - 5441 RBX  - 065D8000, RSP -
> 07E8EA48, RBP - 065DB001 RSI  - 0048,
> RDI - 06CE82C0
> R8   - 07E8EA60, R9  - 07E8EAD0, R10 -
> 07E8E804
> R11  - , R12 - 8003, R13 -
> 0001
> R14  - 06CEE640, R15 - 0006
> DS   - 0030, ES  - 0030, FS  -
> 0030
> GS   - 0030, SS  - 0030
> CR0  - 80010033, CR2 - , CR3 -
> 07C01000
> CR4  - 0668, CR8 - 
> DR0  - , DR1 - , DR2 -
> 
> DR3  - , DR6 - 0FF0, DR7 -
> 0400 GDTR - 079DE000 0047, LDTR -
> 
> IDTR - 0753C018 0FFF,   TR - 
> FXSAVE_STATE - 07E8E6A0
>  Can't find image information. 
> 
> 
> On Arm, I don't get a crash but no network interface gets created.
> I've checked the QEMU RNDIS interface is working: if I boot to Linux I can
get
> an IP address and communicate with the outside world.
> 
> --
> Rebecca Cran
> 
> 
> On 9/1/22 23:24, RichardHo [何明忠] via groups.io wrote:
> > UsbNetworkPkg provides network functions for USB ACM, USB NCM, and
> USB
> > RNDIS network device.
> >
> > Signed-off-by: Richard Ho 
> > Cc: Andrew Fish 
> > Cc: Leif Lindholm 
> > Cc: Michael D Kinney 
> > Cc: Michael Kubacki 
> > Cc: Zhiguang Liu 
> > Cc: Liming Gao 
> > Reviewed-by: Tony Lo 
> > ---
> >   UsbNetworkPkg/Config/UsbNetworkPkg.inc.dsc|9 +
> >   .../Config/UsbNetworkPkgComponentsDxe.inc.dsc |   20 +
> >   .../Config/UsbNetworkPkgComponentsDxe.inc.fdf |   20 +
> >   .../Config/UsbNetworkPkgDefines.inc.dsc   |   23 +
> >   .../Include/Protocol/UsbEthernetProtocol.h|  872 +
> >   UsbNetworkPkg/NetworkCommon/ComponentName.c   |  264 +++
> >   UsbNetworkPkg/NetworkCommon/DriverBinding.c   |  583 ++
> >   

Re: [edk2-devel] [PATCH v2 24/34] MdePkg/BaseCacheMaintenanceLib: LoongArch cache maintenance implementation.

2022-09-22 Thread Chao Li
Hi Mike,
I have converted the cache opeartion to .S, the implementation please refer to 
the patch 0023, can you review it again?

Thanks,
Chao


On 9月 14 2022, at 5:41 下午, Chao Li  wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4053
>
> Implement LoongArch cache maintenance functions in
> BaseCacheMaintenanceLib.
>
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
>
> Signed-off-by: Chao Li 
> ---
> .../BaseCacheMaintenanceLib.inf | 6 +-
> .../BaseCacheMaintenanceLib/LoongArchCache.c | 254 ++
> 2 files changed, 259 insertions(+), 1 deletion(-)
> create mode 100644 MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>
> diff --git 
> a/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf 
> b/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> index 33114243d5..6fd9cbe5f6 100644
> --- a/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> @@ -7,6 +7,7 @@
> # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
>
> # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights 
> reserved.
> +# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights 
> reserved.
> #
> # SPDX-License-Identifier: BSD-2-Clause-Patent
> #
> @@ -24,7 +25,7 @@
>
>
>
> #
> -# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64
> +# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64 RISCV64 LOONGARCH64
> #
>
>
> [Sources.IA32]
> @@ -45,6 +46,9 @@
> [Sources.RISCV64]
>
> RiscVCache.c
>
>
> +[Sources.LOONGARCH64]
> + LoongArchCache.c
> +
> [Packages]
> MdePkg/MdePkg.dec
>
>
> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c 
> b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> new file mode 100644
> index 00..4c8773278c
> --- /dev/null
> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> @@ -0,0 +1,254 @@
> +/** @file
>
> + Cache Maintenance Functions for LoongArch.
> + LoongArch cache maintenance functions has not yet been completed, and will 
> added in later.
> + Functions are null functions now.
> +
> + Copyright (c) 2022, Loongson Technology Corporation Limited. All rights 
> reserved.
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +//
> +// Include common header file for this module.
> +//
> +#include 
> +#include 
> +#include 
> +
> +/**
> + LoongArch data barrier operation.
> +**/
> +VOID
> +EFIAPI
> +AsmDataBarrierLoongArch (
> + VOID
> + );
> +
> +/**
> + LoongArch instruction barrier operation.
> +**/
> +VOID
> +EFIAPI
> +AsmInstructionBarrierLoongArch (
> + VOID
> + );
> +
> +/**
> + Invalidates the entire instruction cache in cache coherency domain of the
> + calling CPU.
> +
> +**/
> +VOID
> +EFIAPI
> +InvalidateInstructionCache (
> + VOID
> + )
> +{
> + AsmInstructionBarrierLoongArch ();
> +}
> +
> +/**
> + Invalidates a range of instruction cache lines in the cache coherency domain
> + of the calling CPU.
> +
> + Invalidates the instruction cache lines specified by Address and Length. If
> + Address is not aligned on a cache line boundary, then entire instruction
> + cache line containing Address is invalidated. If Address + Length is not
> + aligned on a cache line boundary, then the entire instruction cache line
> + containing Address + Length -1 is invalidated. This function may choose to
> + invalidate the entire instruction cache if that is more efficient than
> + invalidating the specified range. If Length is 0, the no instruction cache
> + lines are invalidated. Address is returned.
> +
> + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
> +
> + @param[in] Address The base address of the instruction cache lines to
> + invalidate. If the CPU is in a physical addressing mode, then
> + Address is a physical address. If the CPU is in a virtual
> + addressing mode, then Address is a virtual address.
> +
> + @param[in] Length The number of bytes to invalidate from the instruction 
> cache.
> +
> + @return Address.
> +
> +**/
> +VOID *
> +EFIAPI
> +InvalidateInstructionCacheRange (
> + IN VOID *Address,
> + IN UINTN Length
> + )
> +{
> + AsmInstructionBarrierLoongArch ();
> + return Address;
> +}
> +
> +/**
> + Writes Back and Invalidates the entire data cache in cache coherency domain
> + of the calling CPU.
> +
> + Writes Back and Invalidates the entire data cache in cache coherency domain
> + of the calling CPU. This function guarantees that all dirty cache lines are
> + written back to system memory, and also invalidates all the data cache lines
> + in the cache coherency domain of the calling CPU.
> +
> +**/
> +VOID
> +EFIAPI
> +WriteBackInvalidateDataCache (
> + VOID
> + )
> +{
> + DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", 
> __FUNCTION__));
> +}
> +
> +/**
> + Writes Back and Invalidates a range of data cache 

Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Edk2ToolsBuild: Fixing pipeline build due to path too long

2022-09-22 Thread Kun Qin
Thanks for the help, Bob. It seems that one of the "Reviewed-by" tags 
are breaking the pipeline patchcheck: 
https://dev.azure.com/tianocore/edk2-ci/_build/results?buildId=62531=logs=12f1170f-54f2-53f3-20dd-22fc7dff55f9=9c939e41-62c2-5605-5e05-fc3554afc9f5


Would like me to send a v2 patch?

Regards,
Kun

On 09/22/2022 04:26, Bob Feng wrote:

Create PR https://github.com/tianocore/edk2/pull/3378 for merge.

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Bob Feng
Sent: Thursday, September 22, 2022 7:11 PM
To: Kun Qin ; devel@edk2.groups.io
Cc: Gao, Liming ; Chen, Christine ; 
Sean Brogan 
Subject: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Edk2ToolsBuild: Fixing 
pipeline build due to path too long

Reviewed-by: Bob Feng 

-Original Message-
From: Kun Qin 
Sent: Thursday, September 22, 2022 4:45 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C ; Gao, Liming ; Chen, 
Christine ; Sean Brogan 
Subject: [PATCH v1 1/1] BaseTools: Edk2ToolsBuild: Fixing pipeline build due to 
path too long

From: Sean Brogan 

Current implementation of looking up toolchain will _insert_ the findings from 
vsvarsall.bat to existing path and potentially stuff the variable to exceed the 
length of maximal path length accepted by Windows.

This change updated the logic to use the discovered shell varialbes to replace 
the existing path, which is desirable in the specific use case.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yuwei Chen 

Co-authored-by: Sean Brogan 
Signed-off-by: Kun Qin 
---
  BaseTools/Edk2ToolsBuild.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Edk2ToolsBuild.py b/BaseTools/Edk2ToolsBuild.py index 
1ea8187de693..f862468ce275 100644
--- a/BaseTools/Edk2ToolsBuild.py
+++ b/BaseTools/Edk2ToolsBuild.py
@@ -122,7 +122,7 @@ class Edk2ToolsBuild(BaseAbstractInvocable):
  for key in vc_vars.keys(): logging.debug(f"Var - {key} 
= {vc_vars[key]}") if key.lower() == 'path':-
shell_env.insert_path(vc_vars[key])+shell_env.set_path(vc_vars[key])  
   else: shell_env.set_shell_var(key, vc_vars[key]) --
2.37.1.windows.1














-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#94162): https://edk2.groups.io/g/devel/message/94162
Mute This Topic: https://groups.io/mt/93835889/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 23/34] MdePkg/BaseLib: BaseLib for LOONGARCH64 architecture.

2022-09-22 Thread Chao Li
Hi Mike,
In the V2, I removed the unaligned read/write functions in LoongArch library 
and used the generic implementation, can you review it again?

Thanks,
Chao


On 9月 14 2022, at 5:41 下午, Chao Li  wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4053
>
> Add LoongArch LOONGARCH64 BaseLib functions.
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
>
> Signed-off-by: Chao Li 
> Co-authored-by: Baoqi Zhang 
> ---
> MdePkg/Include/Library/BaseLib.h | 24 
> MdePkg/Library/BaseLib/BaseLib.inf | 16 -
> MdePkg/Library/BaseLib/LoongArch64/Barrier.S | 28 +
> .../BaseLib/LoongArch64/CpuBreakpoint.S | 24 
> MdePkg/Library/BaseLib/LoongArch64/CpuPause.S | 31 ++
> .../BaseLib/LoongArch64/DisableInterrupts.S | 21 +++
> .../BaseLib/LoongArch64/EnableInterrupts.S | 21 +++
> .../BaseLib/LoongArch64/GetInterruptState.S | 35 +++
> .../BaseLib/LoongArch64/InternalSwitchStack.c | 58 +++
> .../Library/BaseLib/LoongArch64/MemoryFence.S | 18 ++
> .../BaseLib/LoongArch64/SetJumpLongJump.S | 49 
> .../Library/BaseLib/LoongArch64/SwitchStack.S | 39 +
> 12 files changed, 363 insertions(+), 1 deletion(-)
> create mode 100644 MdePkg/Library/BaseLib/LoongArch64/Barrier.S
> create mode 100644 MdePkg/Library/BaseLib/LoongArch64/CpuBreakpoint.S
> create mode 100644 MdePkg/Library/BaseLib/LoongArch64/CpuPause.S
> create mode 100644 MdePkg/Library/BaseLib/LoongArch64/DisableInterrupts.S
> create mode 100644 MdePkg/Library/BaseLib/LoongArch64/EnableInterrupts.S
> create mode 100644 MdePkg/Library/BaseLib/LoongArch64/GetInterruptState.S
> create mode 100644 MdePkg/Library/BaseLib/LoongArch64/InternalSwitchStack.c
> create mode 100644 MdePkg/Library/BaseLib/LoongArch64/MemoryFence.S
> create mode 100644 MdePkg/Library/BaseLib/LoongArch64/SetJumpLongJump.S
> create mode 100644 MdePkg/Library/BaseLib/LoongArch64/SwitchStack.S
>
> diff --git a/MdePkg/Include/Library/BaseLib.h 
> b/MdePkg/Include/Library/BaseLib.h
> index a6f9a194ef..f3f59f21c2 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -6,6 +6,7 @@ Copyright (c) 2006 - 2021, Intel Corporation. All rights 
> reserved.
> Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>
> Copyright (c) Microsoft Corporation.
> Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All 
> rights reserved.
> +Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All 
> rights reserved.
>
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
> @@ -152,6 +153,29 @@ typedef struct {
>
> #endif // defined (MDE_CPU_RISCV64)
>
>
> +#if defined (MDE_CPU_LOONGARCH64)
> +///
> +/// The LoongArch architecture context buffer used by SetJump() and 
> LongJump()
> +///
> +typedef struct {
> + UINT64 S0;
> + UINT64 S1;
> + UINT64 S2;
> + UINT64 S3;
> + UINT64 S4;
> + UINT64 S5;
> + UINT64 S6;
> + UINT64 S7;
> + UINT64 S8;
> + UINT64 SP;
> + UINT64 FP;
> + UINT64 RA;
> +} BASE_LIBRARY_JUMP_BUFFER;
> +
> +#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
> +
> +#endif // defined (MDE_CPU_LOONGARCH64)
> +
> //
> // String Services
> //
> diff --git a/MdePkg/Library/BaseLib/BaseLib.inf 
> b/MdePkg/Library/BaseLib/BaseLib.inf
> index 6be5be9428..9ed46a584a 100644
> --- a/MdePkg/Library/BaseLib/BaseLib.inf
> +++ b/MdePkg/Library/BaseLib/BaseLib.inf
> @@ -21,7 +21,7 @@
> LIBRARY_CLASS = BaseLib
>
>
>
> #
> -# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64 RISCV64
> +# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64 RISCV64 LOONGARCH64
> #
>
>
> [Sources]
> @@ -402,6 +402,20 @@
> RiscV64/RiscVInterrupt.S | GCC
>
> RiscV64/FlushCache.S | GCC
>
>
> +[Sources.LOONGARCH64]
> + Math64.c
> + Unaligned.c
> + LoongArch64/InternalSwitchStack.c
> + LoongArch64/GetInterruptState.S | GCC
> + LoongArch64/EnableInterrupts.S | GCC
> + LoongArch64/DisableInterrupts.S | GCC
> + LoongArch64/Barrier.S | GCC
> + LoongArch64/MemoryFence.S | GCC
> + LoongArch64/CpuBreakpoint.S | GCC
> + LoongArch64/CpuPause.S | GCC
> + LoongArch64/SetJumpLongJump.S | GCC
> + LoongArch64/SwitchStack.S | GCC
> +
> [Packages]
> MdePkg/MdePkg.dec
>
>
> diff --git a/MdePkg/Library/BaseLib/LoongArch64/Barrier.S 
> b/MdePkg/Library/BaseLib/LoongArch64/Barrier.S
> new file mode 100644
> index 00..58f21ad725
> --- /dev/null
> +++ b/MdePkg/Library/BaseLib/LoongArch64/Barrier.S
> @@ -0,0 +1,28 @@
> +#--
> +#
> +# LoongArch Barrier Operations
> +#
> +# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights 
> reserved.
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#--
> +
> +ASM_GLOBAL ASM_PFX(AsmDataBarrierLoongArch)
> +ASM_GLOBAL ASM_PFX(AsmInstructionBarrierLoongArch)
> +
> +#
> +# Data barrier operation for LoongArch.
> +#
> +ASM_PFX(AsmDataBarrierLoongArch):
> + 

Re: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support

2022-09-22 Thread yi1 li
Hi Mike,

1. Yes, it matches.
By Intel side, 100+kb(20%+) FV size increase will be a big concern, please 
refer to another internal email.

2. Additional size is coming from modules may consumed EC APIs, eg. TLS PEM 
X509  ...

If we added EC source to OpensslLib.inf and disabled macro OPENSSL_NO_EC, those 
modules will link EC APIs and increase binary size,
This an example from x509/x_pubkey.c , other modules is similar:
#ifndef OPENSSL_NO_EC
EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length)
{
EVP_PKEY *pkey;
EC_KEY *key = NULL;
// call EC functions
}
#endif

If we added EC source to OpensslLib.inf and enable macro OPENSSL_NO_EC, EC 
module will throw build error,
Since some EC internal APIs or structs have been disabled by OPENSSL_NO_EC but  
not another.
This an example from ec/ec_local.h , other error is similar:

#ifndef OPENSSL_NO_EC
typedef struct ec_group_st EC_GROUP;
typedef struct ec_point_st EC_POINT;
#endif

// but this function not been enclosed by OPENSSL_NO_EC, and will throw build 
error
int (*point_set_Jprojective_coordinates_GFp) (const EC_GROUP *,
  EC_POINT *, const BIGNUM *x,
  const BIGNUM *y,
  const BIGNUM *z, BN_CTX *);

To avoid this annoying openssl error, we introduced conditional EC.

Thanks,
Yi

-Original Message-
From: Kinney, Michael D  
Sent: Friday, September 23, 2022 6:47 AM
To: Li, Yi1 ; devel@edk2.groups.io; Kinney, Michael D 

Cc: Yao, Jiewen ; Wang, Jian J ; 
Lu, Xiaoyu1 ; Jiang, Guomin 
Subject: RE: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support

Hi Yi,

I agree EC is an important feature.

I did some analysis of the size impact to the CryptoPkg modules on current trunk
with EC on and off. Uncompressed size is important for PEI Phase.  For DXE and
SMM phase, the Crypto services can always be compressed.  From the table below,
building all the EC services in the OpensslLib has no size impact to the NONE 
profile and the MIN_PEI profile.  It has ~105 KB impact to compressed DXE/SMM 
usages that may use the MIN_DXE_MIN_SMM or ALL profiles.

   Uncompressed  LZMA Compressed
CPU   CRYPTO_SERVICESModule  EC=FALSE  EC=TRUE  EC=FALSE  EC=TRUE  Increase
  ===      ===    ===  
IA32  NONE CryptoPei2153621568 0 KB
IA32  NONE CryptoDxe2163221696 0 KB
IA32  NONE CryptoSmm2297623072 0 KB
IA32  MIN_PEI  CryptoPei   248992   249120 0 KB
IA32  MIN_DXE_MIN_SMM  CryptoDxe   636672   829568288520   401034113 KB
IA32  MIN_DXE_MIN_SMM  CryptoSmm   426048   601472191517   296022105 KB
IA32  ALL  CryptoPei   423840   598976189047   293759104 KB
IA32  ALL  CryptoDxe   645280   838144292955   405277113 KB
IA32  ALL  CryptoSmm   441888   617184198779   303628105 KB
X64   NONE CryptoPei2963229664 0 KB
X64   NONE CryptoDxe2979229792 0 KB
X64   NONE CryptoSmm3129631296 0 KB
X64   MIN_PEI  CryptoPei   310784   310848 0 KB
X64   MIN_DXE_MIN_SMM  CryptoDxe   804288  1016256311436   426596115 KB
X64   MIN_DXE_MIN_SMM  CryptoSmm   543776   733920204483   310775106 KB
X64   ALL  CryptoPei   540384   730240202494   308467106 KB
X64   ALL  CryptoDxe   815392  1027296316228   431321115 KB
X64   ALL  CryptoSmm   563648   753696213488   319644106 KB

NOTE: Even if multiple modules in an FV use static linking of Crypto libs, if 
the
  entire FV is compressed, the total size impact is typically the size of a
  single instance of a compressed CryptoLib.  The sizes of the Crypto* 
modules
  in the table above should be a close approximation of the size impact to a
  single FV.

Does this match your previous size analysis?

The critical issue to evaluate here is why adding the EC sources to 
OpensllLib.inf
causes the modules that do not use any EC services to grow by ~105KB.  Has any
detailed analysis of the final linked images been performed to see where this 
additional size is coming from?

Thanks,

Mike

> -Original Message-
> From: Li, Yi1 
> Sent: Thursday, September 22, 2022 5:54 AM
> To: Kinney, Michael D ; devel@edk2.groups.io; 
> Kishore, Shelly 
> Cc: Yao, Jiewen ; Wang, Jian J ; 
> Lu, Xiaoyu1 ; Jiang,
> Guomin 
> Subject: RE: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support
> 
> Hi Mike,
> I have did some POC that seems existed structured PCD is hard to control 
> binary size,
> Here is the previous 

Re: [edk2-devel] [PATCH] SecurityPkg: Remove enforcement of final GoIdle transition for CRB commands

2022-09-22 Thread Yao, Jiewen
Would you please describe:
1) What test you have done? Which TPM chips you have tested?
2) Which specific section/sentence you are following to remove the goIde? I 
would like to double check spec. 

Thank you
Yao, Jiewen


> -Original Message-
> From: Gonzalez Del Cueto, Rodrigo 
> Sent: Thursday, September 22, 2022 3:36 PM
> To: devel@edk2.groups.io
> Cc: Gonzalez Del Cueto, Rodrigo ;
> Yao, Jiewen ; Wang, Jian J 
> Subject: [PATCH] SecurityPkg: Remove enforcement of final GoIdle
> transition for CRB commands
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4077
> 
> Following the design described in the TCG specification,
> the driver implementation of the CRB protocol does not require
> enforcing completing the transition to goIdle at the end of a command
> sequence.
> 
> Signed-off-by: "Gonzalez Del Cueto, Rodrigo"
> 
> Cc: Jiewen Yao 
> Cc: Jian J Wang 
> ---
>  SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c | 13 -
>  1 file changed, 13 deletions(-)
> 
> diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
> b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
> index 840265292a..1f9ac5ab5a 100644
> --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
> +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
> @@ -381,19 +381,6 @@ GoIdle_Exit:
>//
>MmioWrite32 ((UINTN)>CrbControlRequest,
> PTP_CRB_CONTROL_AREA_REQUEST_GO_IDLE);
> 
> -  //
> -  // Only enforce Idle state transition if execution fails when
> CRBIdleBypass==1
> -  // Leave regular Idle delay at the beginning of next command execution
> -  //
> -  if (GetCachedIdleByPass () == 1) {
> -Status = PtpCrbWaitRegisterBits (
> -   >CrbControlStatus,
> -   PTP_CRB_CONTROL_AREA_STATUS_TPM_IDLE,
> -   0,
> -   PTP_TIMEOUT_C
> -   );
> -  }
> -
>return Status;
>  }
> 
> --
> 2.25.1



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




[edk2-devel] Now: EDKII Open Design Meeting - 09/23/2022 #cal-notice

2022-09-22 Thread Group Notification
*EDKII Open Design Meeting*

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

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

*Organizer:* Ray Ni ray...@intel.com ( 
ray...@intel.com?subject=Re:%20Event:%20EDKII%20Open%20Design%20Meeting )

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

*Description:*

TOPIC: How to add support for RISC-V in edk2? ( 
https://edk2.groups.io/g/devel/files/Designs/2022/0923//How%20to%20add%20support%20for%20RISC-V%20in%20edk2.pdf
 ) - Sunil V L


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#94158): https://edk2.groups.io/g/devel/message/94158
Mute This Topic: https://groups.io/mt/93862031/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] [PATCH v2 5/5] CryptoPkg: add Hmac Sha384 to host UnitTest.

2022-09-22 Thread Qi Zhang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4025

Signed-off-by: Qi Zhang 
Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Reviewed-by: Jiewen Yao 
---
 .../BaseCryptLib/UnitTestHostBaseCryptLib.inf |  2 +-
 .../UnitTest/Library/BaseCryptLib/HmacTests.c | 19 +++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf
index 11ff1c6931..63282dc5ab 100644
--- a/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf
@@ -28,7 +28,7 @@
   Hash/CryptSha256.c
   Hash/CryptSha512.c
   Hash/CryptSm3.c
-  Hmac/CryptHmacSha256.c
+  Hmac/CryptHmac.c
   Kdf/CryptHkdf.c
   Cipher/CryptAes.c
   Pk/CryptRsaBasic.c
diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c 
b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c
index 595729424b..9c5b39410d 100644
--- a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c
+++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c
@@ -64,6 +64,23 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8  
HmacSha256Digest[] = {
   0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, 0x26, 0xe9, 0x37, 0x6c, 
0x2e, 0x32, 0xcf, 0xf7
 };
 
+//
+// Key value for HMAC-SHA-384 validation. (From "4. Test Vectors" of IETF 
RFC4231)
+//
+GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8  HmacSha384Key[20] = {
+  0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 
0x0b, 0x0b, 0x0b, 0x0b,
+  0x0b, 0x0b, 0x0b, 0x0b
+};
+
+//
+// Result for HMAC-SHA-384 ("Hi There"). (From "4. Test Vectors" of IETF 
RFC4231)
+//
+GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8  HmacSha384Digest[] = {
+  0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62, 0x6b, 0x08, 0x25, 0xf4, 
0xab, 0x46, 0x90, 0x7f,
+  0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6, 0x82, 0xaa, 0x03, 0x4c, 
0x7c, 0xeb, 0xc5, 0x9c,
+  0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f, 0x4a, 0xf1, 0x52, 0xe8, 
0xb2, 0xfa, 0x9c, 0xb6
+};
+
 typedef
 VOID *
 (EFIAPI *EFI_HMAC_NEW)(
@@ -109,6 +126,7 @@ typedef struct {
 // HMAC_TEST_CONTEXT   mHmacMd5TestCtx= {MD5_DIGEST_SIZE,
HmacMd5New,HmacMd5SetKey,HmacMd5Update,HmacMd5Final,HmacMd5Key, 
   sizeof(HmacMd5Key),HmacMd5Digest};
 // HMAC_TEST_CONTEXT   mHmacSha1TestCtx   = {SHA1_DIGEST_SIZE,   
HmacSha1New,   HmacSha1SetKey,   HmacSha1Update,   HmacSha1Final,   
HmacSha1Key,   sizeof(HmacSha1Key),   HmacSha1Digest};
 HMAC_TEST_CONTEXT  mHmacSha256TestCtx = { SHA256_DIGEST_SIZE, HmacSha256New, 
HmacSha256SetKey, HmacSha256Update, HmacSha256Final, HmacSha256Key, sizeof 
(HmacSha256Key), HmacSha256Digest };
+HMAC_TEST_CONTEXT  mHmacSha384TestCtx = { SHA384_DIGEST_SIZE, HmacSha384New, 
HmacSha384SetKey, HmacSha384Update, HmacSha384Final, HmacSha384Key, sizeof 
(HmacSha384Key), HmacSha384Digest };
 
 UNIT_TEST_STATUS
 EFIAPI
@@ -174,6 +192,7 @@ TEST_DESC  mHmacTest[] = {
   // 
-Description-Class-Function---Pre--PostContext
   //
   { "TestVerifyHmacSha256()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHmac, 
TestVerifyHmacPreReq, TestVerifyHmacCleanUp,  },
+  { "TestVerifyHmacSha384()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHmac, 
TestVerifyHmacPreReq, TestVerifyHmacCleanUp,  },
   // These functions have been deprecated but they've been left commented out 
for future reference
   // {"TestVerifyHmacMd5()","CryptoPkg.BaseCryptLib.Hmac",   
TestVerifyHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, },
   // {"TestVerifyHmacSha1()",   "CryptoPkg.BaseCryptLib.Hmac",   
TestVerifyHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, },
-- 
2.26.2.windows.1



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




[edk2-devel] [PATCH v2 4/5] CryptoPkg: Add new hmac SHA api to Crypto Service.

2022-09-22 Thread Qi Zhang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4025

Signed-off-by: Qi Zhang 
Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Reviewed-by: Jiewen Yao 
---
 CryptoPkg/CryptoPkg.dsc   |   3 +
 CryptoPkg/Driver/Crypto.c | 224 +-
 .../BaseCryptLibOnProtocolPpi/CryptLib.c  | 212 +
 3 files changed, 438 insertions(+), 1 deletion(-)

diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index 50e7721f25..417804f64f 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -147,6 +147,7 @@
 
 !if $(CRYPTO_SERVICES) IN "PACKAGE ALL"
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha384.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Md5.Family  
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Family 
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Dh.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
@@ -172,6 +173,7 @@
 
 !if $(CRYPTO_SERVICES) == MIN_PEI
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family   
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha384.Family   
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family 
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family   
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Family   
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
@@ -186,6 +188,7 @@
 
 !if $(CRYPTO_SERVICES) == MIN_DXE_MIN_SMM
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha384.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Services.Pkcs1v2Encrypt
 | TRUE
   
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Services.Pkcs5HashPassword
  | TRUE
   
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Services.Pkcs7Verify
| TRUE
diff --git a/CryptoPkg/Driver/Crypto.c b/CryptoPkg/Driver/Crypto.c
index 76cb9f4da0..d99be08022 100644
--- a/CryptoPkg/Driver/Crypto.c
+++ b/CryptoPkg/Driver/Crypto.c
@@ -1847,6 +1847,218 @@ CryptoServiceHmacSha256Final (
   return CALL_BASECRYPTLIB (HmacSha256.Services.Final, HmacSha256Final, 
(HmacSha256Context, HmacValue), FALSE);
 }
 
+/**
+  Computes the HMAC-SHA256 digest of a input data buffer.
+
+  This function performs the HMAC-SHA256 digest of a given data buffer, and 
places
+  the digest value into the specified memory.
+
+  If this interface is not supported, then return FALSE.
+
+  @param[in]   DataPointer to the buffer containing the data to be 
digested.
+  @param[in]   DataSizeSize of Data buffer in bytes.
+  @param[in]   Key Pointer to the user-supplied key.
+  @param[in]   KeySize Key size in bytes.
+  @param[out]  HmacValue   Pointer to a buffer that receives the HMAC-SHA256 
digest
+   value (32 bytes).
+
+  @retval TRUE   HMAC-SHA256 digest computation succeeded.
+  @retval FALSE  HMAC-SHA256 digest computation failed.
+  @retval FALSE  This interface is not supported.
+
+**/
+BOOLEAN
+EFIAPI
+CryptoServiceHmacSha256All (
+  IN   CONST VOID   *Data,
+  IN   UINTNDataSize,
+  IN   CONST UINT8  *Key,
+  IN   UINTNKeySize,
+  OUT  UINT8*HmacValue
+  )
+{
+  return CALL_BASECRYPTLIB (HmacSha256.Services.All, HmacSha256All, (Data, 
DataSize, Key, KeySize, HmacValue), FALSE);
+}
+
+/**
+  Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA384 
use.
+
+  @return  Pointer to the HMAC_CTX context that has been initialized.
+   If the allocations fails, HmacSha384New() returns NULL.
+
+**/
+VOID *
+EFIAPI
+CryptoServiceHmacSha384New (
+  VOID
+  )
+{
+  return CALL_BASECRYPTLIB (HmacSha384.Services.New, HmacSha384New, (), NULL);
+}
+
+/**
+  Release the specified HMAC_CTX context.
+
+  @param[in]  HmacSha384Ctx  Pointer to the HMAC_CTX context to be released.
+
+**/
+VOID
+EFIAPI
+CryptoServiceHmacSha384Free (
+  IN  VOID  *HmacSha384Ctx
+  )
+{
+  CALL_VOID_BASECRYPTLIB (HmacSha384.Services.Free, HmacSha384Free, 
(HmacSha384Ctx));
+}
+
+/**
+  Set user-supplied key for subsequent use. It must be done before any
+  calling to HmacSha384Update().
+

[edk2-devel] [PATCH v2 2/5] CryptoPkg: Add HMAC-SHA384 cipher support.

2022-09-22 Thread Qi Zhang
Rename file from CryptHmacSha256 to CryptHmac and
add HmacSha384 and HmacSha256All funcitons.

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

Signed-off-by: Qi Zhang 
Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Reviewed-by: Jiewen Yao 
---
 .../Library/BaseCryptLib/Hmac/CryptHmac.c | 629 ++
 .../Library/BaseCryptLib/Hmac/CryptHmacNull.c | 359 ++
 .../BaseCryptLib/Hmac/CryptHmacSha256.c   | 217 --
 .../BaseCryptLib/Hmac/CryptHmacSha256Null.c   | 139 
 .../BaseCryptLibNull/Hmac/CryptHmacNull.c | 359 ++
 .../Hmac/CryptHmacSha256Null.c| 139 
 6 files changed, 1347 insertions(+), 495 deletions(-)
 create mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmac.c
 create mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacNull.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c
 create mode 100644 CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacNull.c
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha256Null.c

diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmac.c 
b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmac.c
new file mode 100644
index 00..2786267a0b
--- /dev/null
+++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmac.c
@@ -0,0 +1,629 @@
+/** @file
+  HMAC-SHA256/SHA384 Wrapper Implementation over OpenSSL.
+
+Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "InternalCryptLib.h"
+#include 
+
+/**
+  Allocates and initializes one HMAC_CTX context for subsequent HMAC-MD use.
+
+  @return  Pointer to the HMAC_CTX context that has been initialized.
+   If the allocations fails, HmacMdNew() returns NULL.
+
+**/
+VOID *
+HmacMdNew (
+  VOID
+  )
+{
+  //
+  // Allocates & Initializes HMAC_CTX Context by OpenSSL HMAC_CTX_new()
+  //
+  return (VOID *)HMAC_CTX_new ();
+}
+
+/**
+  Release the specified HMAC_CTX context.
+
+  @param[in]  HmacMdCtx  Pointer to the HMAC_CTX context to be released.
+
+**/
+VOID
+HmacMdFree (
+  IN  VOID  *HmacMdCtx
+  )
+{
+  //
+  // Free OpenSSL HMAC_CTX Context
+  //
+  HMAC_CTX_free ((HMAC_CTX *)HmacMdCtx);
+}
+
+/**
+  Set user-supplied key for subsequent use. It must be done before any
+  calling to HmacMdUpdate().
+
+  If HmacMdContext is NULL, then return FALSE.
+
+  @param[in]   Md Message Digest.
+  @param[out]  HmacMdContext  Pointer to HMAC-MD context.
+  @param[in]   KeyPointer to the user-supplied key.
+  @param[in]   KeySizeKey size in bytes.
+
+  @retval TRUE   The Key is set successfully.
+  @retval FALSE  The Key is set unsuccessfully.
+
+**/
+BOOLEAN
+HmacMdSetKey (
+  IN   CONST EVP_MD  *Md,
+  OUT  VOID  *HmacMdContext,
+  IN   CONST UINT8   *Key,
+  IN   UINTN KeySize
+  )
+{
+  //
+  // Check input parameters.
+  //
+  if ((HmacMdContext == NULL) || (KeySize > INT_MAX)) {
+return FALSE;
+  }
+
+  if (HMAC_Init_ex ((HMAC_CTX *)HmacMdContext, Key, (UINT32)KeySize, Md, NULL) 
!= 1) {
+return FALSE;
+  }
+
+  return TRUE;
+}
+
+/**
+  Makes a copy of an existing HMAC-MD context.
+
+  If HmacMdContext is NULL, then return FALSE.
+  If NewHmacMdContext is NULL, then return FALSE.
+
+  @param[in]  HmacMdContext Pointer to HMAC-MD context being copied.
+  @param[out] NewHmacMdContext  Pointer to new HMAC-MD context.
+
+  @retval TRUE   HMAC-MD context copy succeeded.
+  @retval FALSE  HMAC-MD context copy failed.
+
+**/
+BOOLEAN
+HmacMdDuplicate (
+  IN   CONST VOID  *HmacMdContext,
+  OUT  VOID*NewHmacMdContext
+  )
+{
+  //
+  // Check input parameters.
+  //
+  if ((HmacMdContext == NULL) || (NewHmacMdContext == NULL)) {
+return FALSE;
+  }
+
+  if (HMAC_CTX_copy ((HMAC_CTX *)NewHmacMdContext, (HMAC_CTX *)HmacMdContext) 
!= 1) {
+return FALSE;
+  }
+
+  return TRUE;
+}
+
+/**
+  Digests the input data and updates HMAC-MD context.
+
+  This function performs HMAC-MD digest on a data buffer of the specified size.
+  It can be called multiple times to compute the digest of long or 
discontinuous data streams.
+  HMAC-MD context should be initialized by HmacMdNew(), and should not be 
finalized
+  by HmacMdFinal(). Behavior with invalid context is undefined.
+
+  If HmacMdContext is NULL, then return FALSE.
+
+  @param[in, out]  HmacMdContext Pointer to the HMAC-MD context.
+  @param[in]   Data  Pointer to the buffer containing the data 
to be digested.
+  @param[in]   DataSize  Size of Data buffer in bytes.
+
+  @retval TRUE   HMAC-MD data digest succeeded.
+  @retval FALSE  HMAC-MD data digest failed.
+
+**/
+BOOLEAN
+HmacMdUpdate (
+  IN OUT  VOID*HmacMdContext,
+  IN  CONST VOID  *Data,
+  IN  UINTN   DataSize
+  )
+{
+  //
+  // Check input parameters.
+  //
+  if (HmacMdContext == NULL) {
+  

[edk2-devel] [PATCH v2 3/5] CryptoPkg: Update CryptLib inf as the file name changed.

2022-09-22 Thread Qi Zhang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4025

Signed-off-by: Qi Zhang 
Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Reviewed-by: Jiewen Yao 
---
 CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf | 2 +-
 CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf  | 2 +-
 CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf  | 2 +-
 CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf  | 2 +-
 CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf  | 2 +-
 CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
index 3d7b917103..2a9664ad3e 100644
--- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
@@ -35,7 +35,7 @@
   Hash/CryptSha512.c
   Hash/CryptSm3.c
   Hash/CryptParallelHashNull.c
-  Hmac/CryptHmacSha256.c
+  Hmac/CryptHmac.c
   Kdf/CryptHkdf.c
   Cipher/CryptAes.c
   Pk/CryptRsaBasic.c
diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
index 01de27e037..f88f8312f6 100644
--- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
@@ -41,7 +41,7 @@
   Hash/CryptSm3.c
   Hash/CryptSha512.c
   Hash/CryptParallelHashNull.c
-  Hmac/CryptHmacSha256.c
+  Hmac/CryptHmac.c
   Kdf/CryptHkdf.c
   Cipher/CryptAesNull.c
   Pk/CryptRsaBasic.c
diff --git a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
index d28fb98b66..9213952701 100644
--- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
@@ -41,7 +41,7 @@
   Hash/CryptSm3.c
   Hash/CryptSha512.c
   Hash/CryptParallelHashNull.c
-  Hmac/CryptHmacSha256.c
+  Hmac/CryptHmac.c
   Kdf/CryptHkdf.c
   Cipher/CryptAes.c
   Pk/CryptRsaBasic.c
diff --git a/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
index 070b7e..0b1dd31c41 100644
--- a/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
@@ -34,7 +34,7 @@
   Hash/CryptSha256Null.c
   Hash/CryptSm3Null.c
   Hash/CryptParallelHashNull.c
-  Hmac/CryptHmacSha256Null.c
+  Hmac/CryptHmacNull.c
   Kdf/CryptHkdfNull.c
   Cipher/CryptAesNull.c
   Pk/CryptRsaBasicNull.c
diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
index 91a1715095..ed76520fcc 100644
--- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
@@ -42,7 +42,7 @@
   Hash/CryptXkcp.c
   Hash/CryptCShake256.c
   Hash/CryptParallelHash.c
-  Hmac/CryptHmacSha256.c
+  Hmac/CryptHmac.c
   Kdf/CryptHkdfNull.c
   Cipher/CryptAes.c
   Pk/CryptRsaBasic.c
diff --git a/CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf 
b/CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf
index 63d1d82d19..728e0793ac 100644
--- a/CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf
+++ b/CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf
@@ -35,7 +35,7 @@
   Hash/CryptSha512Null.c
   Hash/CryptSm3Null.c
   Hash/CryptParallelHashNull.c
-  Hmac/CryptHmacSha256Null.c
+  Hmac/CryptHmacNull.c
   Kdf/CryptHkdfNull.c
   Cipher/CryptAesNull.c
   Pk/CryptRsaBasicNull.c
-- 
2.26.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#94155): https://edk2.groups.io/g/devel/message/94155
Mute This Topic: https://groups.io/mt/93861902/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/5] CryptoPkg: Add new hmac definition to cryptlib

2022-09-22 Thread Qi Zhang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4025

Signed-off-by: Qi Zhang 
Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Reviewed-by: Jiewen Yao 
---
 CryptoPkg/Include/Library/BaseCryptLib.h  | 188 
 .../Pcd/PcdCryptoServiceFamilyEnable.h|  13 ++
 CryptoPkg/Private/Protocol/Crypto.h   | 200 +-
 3 files changed, 400 insertions(+), 1 deletion(-)

diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h 
b/CryptoPkg/Include/Library/BaseCryptLib.h
index 7d1499350a..3a42e3494f 100644
--- a/CryptoPkg/Include/Library/BaseCryptLib.h
+++ b/CryptoPkg/Include/Library/BaseCryptLib.h
@@ -1045,6 +1045,194 @@ HmacSha256Final (
   OUT UINT8  *HmacValue
   );
 
+/**
+  Computes the HMAC-SHA256 digest of a input data buffer.
+
+  This function performs the HMAC-SHA256 digest of a given data buffer, and 
places
+  the digest value into the specified memory.
+
+  If this interface is not supported, then return FALSE.
+
+  @param[in]   DataPointer to the buffer containing the data to be 
digested.
+  @param[in]   DataSizeSize of Data buffer in bytes.
+  @param[in]   Key Pointer to the user-supplied key.
+  @param[in]   KeySize Key size in bytes.
+  @param[out]  HashValue   Pointer to a buffer that receives the HMAC-SHA256 
digest
+   value (32 bytes).
+
+  @retval TRUE   HMAC-SHA256 digest computation succeeded.
+  @retval FALSE  HMAC-SHA256 digest computation failed.
+  @retval FALSE  This interface is not supported.
+
+**/
+BOOLEAN
+EFIAPI
+HmacSha256All (
+  IN   CONST VOID   *Data,
+  IN   UINTNDataSize,
+  IN   CONST UINT8  *Key,
+  IN   UINTNKeySize,
+  OUT  UINT8*HmacValue
+  );
+
+/**
+  Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA384 
use.
+
+  @return  Pointer to the HMAC_CTX context that has been initialized.
+   If the allocations fails, HmacSha384New() returns NULL.
+
+**/
+VOID *
+EFIAPI
+HmacSha384New (
+  VOID
+  );
+
+/**
+  Release the specified HMAC_CTX context.
+
+  @param[in]  HmacSha384Ctx  Pointer to the HMAC_CTX context to be released.
+
+**/
+VOID
+EFIAPI
+HmacSha384Free (
+  IN  VOID  *HmacSha384Ctx
+  );
+
+/**
+  Set user-supplied key for subsequent use. It must be done before any
+  calling to HmacSha384Update().
+
+  If HmacSha384Context is NULL, then return FALSE.
+  If this interface is not supported, then return FALSE.
+
+  @param[out]  HmacSha384Context  Pointer to HMAC-SHA384 context.
+  @param[in]   KeyPointer to the user-supplied key.
+  @param[in]   KeySizeKey size in bytes.
+
+  @retval TRUE   The Key is set successfully.
+  @retval FALSE  The Key is set unsuccessfully.
+  @retval FALSE  This interface is not supported.
+
+**/
+BOOLEAN
+EFIAPI
+HmacSha384SetKey (
+  OUT  VOID *HmacSha384Context,
+  IN   CONST UINT8  *Key,
+  IN   UINTNKeySize
+  );
+
+/**
+  Makes a copy of an existing HMAC-SHA384 context.
+
+  If HmacSha384Context is NULL, then return FALSE.
+  If NewHmacSha384Context is NULL, then return FALSE.
+  If this interface is not supported, then return FALSE.
+
+  @param[in]  HmacSha384Context Pointer to HMAC-SHA384 context being 
copied.
+  @param[out] NewHmacSha384Context  Pointer to new HMAC-SHA384 context.
+
+  @retval TRUE   HMAC-SHA384 context copy succeeded.
+  @retval FALSE  HMAC-SHA384 context copy failed.
+  @retval FALSE  This interface is not supported.
+
+**/
+BOOLEAN
+EFIAPI
+HmacSha384Duplicate (
+  IN   CONST VOID  *HmacSha384Context,
+  OUT  VOID*NewHmacSha384Context
+  );
+
+/**
+  Digests the input data and updates HMAC-SHA384 context.
+
+  This function performs HMAC-SHA384 digest on a data buffer of the specified 
size.
+  It can be called multiple times to compute the digest of long or 
discontinuous data streams.
+  HMAC-SHA384 context should be initialized by HmacSha384New(), and should not 
be finalized
+  by HmacSha384Final(). Behavior with invalid context is undefined.
+
+  If HmacSha384Context is NULL, then return FALSE.
+  If this interface is not supported, then return FALSE.
+
+  @param[in, out]  HmacSha384Context Pointer to the HMAC-SHA384 context.
+  @param[in]   Data  Pointer to the buffer containing the data 
to be digested.
+  @param[in]   DataSize  Size of Data buffer in bytes.
+
+  @retval TRUE   HMAC-SHA384 data digest succeeded.
+  @retval FALSE  HMAC-SHA384 data digest failed.
+  @retval FALSE  This interface is not supported.
+
+**/
+BOOLEAN
+EFIAPI
+HmacSha384Update (
+  IN OUT  VOID*HmacSha384Context,
+  IN  CONST VOID  *Data,
+  IN  UINTN   DataSize
+  );
+
+/**
+  Completes computation of the HMAC-SHA384 digest value.
+
+  This function completes HMAC-SHA384 hash computation and retrieves the 
digest value into
+  the specified memory. After this function has been called, the HMAC-SHA384 
context cannot
+  be used again.
+  HMAC-SHA384 context 

[edk2-devel] [PATCH v2 0/5] CryptoPkg: Add HMAC-SHA384 cipher support.

2022-09-22 Thread Qi Zhang
HmacSha256 is already supported on Edk2. This patchset is to add
HmacSha384 support.

With this change, the size increase of BaseCyrptLib is about 7K bytes.
HmacSha384 function is verifed by the Host UnitTest.
And also it has been integratd in
https://github.com/tianocore/edk2-staging/tree/DeviceSecurity and been
verified.

All the code change is on the PR https://github.com/tianocore/edk2/pull/3224.

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

V2: address the comments to V1 change.

Signed-off-by: Qi Zhang 
Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Reviewed-by: Jiewen Yao 

Qi Zhang (5):
  CryptoPkg: Add new hmac definition to cryptlib
  CryptoPkg: Add HMAC-SHA384 cipher support.
  CryptoPkg: Update CryptLib inf as the file name changed.
  CryptoPkg: Add new hmac SHA api to Crypto Service.
  CryptoPkg: add Hmac Sha384 to host UnitTest.

 CryptoPkg/CryptoPkg.dsc   |   3 +
 CryptoPkg/Driver/Crypto.c | 224 ++-
 CryptoPkg/Include/Library/BaseCryptLib.h  | 188 ++
 .../Pcd/PcdCryptoServiceFamilyEnable.h|  13 +
 .../Library/BaseCryptLib/BaseCryptLib.inf |   2 +-
 .../Library/BaseCryptLib/Hmac/CryptHmac.c | 629 ++
 .../Library/BaseCryptLib/Hmac/CryptHmacNull.c | 359 ++
 .../BaseCryptLib/Hmac/CryptHmacSha256.c   | 217 --
 .../BaseCryptLib/Hmac/CryptHmacSha256Null.c   | 139 
 .../Library/BaseCryptLib/PeiCryptLib.inf  |   2 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.inf  |   2 +-
 .../Library/BaseCryptLib/SecCryptLib.inf  |   2 +-
 .../Library/BaseCryptLib/SmmCryptLib.inf  |   2 +-
 .../BaseCryptLib/UnitTestHostBaseCryptLib.inf |   2 +-
 .../BaseCryptLibNull/BaseCryptLibNull.inf |   2 +-
 .../BaseCryptLibNull/Hmac/CryptHmacNull.c | 359 ++
 .../Hmac/CryptHmacSha256Null.c| 139 
 .../BaseCryptLibOnProtocolPpi/CryptLib.c  | 212 ++
 CryptoPkg/Private/Protocol/Crypto.h   | 200 +-
 .../UnitTest/Library/BaseCryptLib/HmacTests.c |  19 +
 20 files changed, 2211 insertions(+), 504 deletions(-)
 create mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmac.c
 create mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacNull.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c
 create mode 100644 CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacNull.c
 delete mode 100644 
CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha256Null.c

-- 
2.26.2.windows.1



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




Re: [edk2-devel] [PATCH v2 3/6] IntelFsp2Pkg: Add CI YAML file

2022-09-22 Thread Michael Kubacki

Review reminder

On 9/15/2022 3:41 PM, Michael Kubacki wrote:

Hi Chasel,

Your CI YAML file feedback in v1 is addressed now in v2.

Can you please provide your review on this patch and [PATCH v2 5/6]?

Note that I updated the commit message for this patch to remove the info 
about the build being broken since that was recently fixed. That update 
is in the branch:


https://github.com/makubacki/edk2/commit/c37e6dfa482ed075cd4ab6712e6d17b3cf17786a 



With these reviews, the series will be covered.

Thanks,
Michael

On 9/15/2022 2:55 PM, Michael Kubacki wrote:

From: Michael Kubacki 

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

Adds IntelFsp2Pkg to the list of supported build packages for edk2
CI and defines an initial set of CI configuration options.

The compiler plugin is disabled as the package currently does not
build due to some changes in the FSP 2.4 interface addition.

Specifically, in commit df25a54 "Fsp24SecCore.inf" files were
added to IntelFspPkg.dsc but the actual files were not added.

Simply removing these files from the DSC exposes a linker failure.

Recommendation:

1. Enable package CI (accept this change)
2. Add IntelFsp2Pkg.dsc to the "CompilerPlugin" "DscPath" in
    IntelFsp2Pkg/IntelFsp2Pkg.ci.yaml to enable compilation
3. Verify compilation and all currently enabled package CI checks
    pass
4. Check-in fixes in (3) with change in (2)

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Signed-off-by: Michael Kubacki 
---
  .pytool/CISettings.py |  1 +
  IntelFsp2Pkg/IntelFsp2Pkg.ci.yaml | 90 
  2 files changed, 91 insertions(+)

diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py
index cf9e0d77b19b..0205c26a58f8 100644
--- a/.pytool/CISettings.py
+++ b/.pytool/CISettings.py
@@ -54,6 +54,7 @@ class Settings(CiBuildSettingsManager, 
UpdateSettingsManager, SetupSettingsManag

  "ArmVirtPkg",
  "DynamicTablesPkg",
  "EmulatorPkg",
+    "IntelFsp2Pkg",
  "MdePkg",
  "MdeModulePkg",
  "NetworkPkg",
diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.ci.yaml 
b/IntelFsp2Pkg/IntelFsp2Pkg.ci.yaml

new file mode 100644
index ..9ce401b20164
--- /dev/null
+++ b/IntelFsp2Pkg/IntelFsp2Pkg.ci.yaml
@@ -0,0 +1,90 @@
+## @file
+# Core CI configuration for IntelFsp2Pkg
+#
+# Copyright (c) Microsoft Corporation
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+{
+    ## options defined .pytool/Plugin/LicenseCheck
+    "LicenseCheck": {
+    "IgnoreFiles": []
+    },
+
+    "EccCheck": {
+    ## Exception sample looks like below:
+    ## "ExceptionList": [
+    ## "", ""
+    ## ]
+    "ExceptionList": [
+    ],
+    ## Both file path and directory path are accepted.
+    "IgnoreFiles": []
+    },
+
+    ## options defined .pytool/Plugin/CompilerPlugin
+    "CompilerPlugin": {
+    "DscPath": "IntelFsp2Pkg.dsc"
+    },
+
+    ## options defined .pytool/Plugin/HostUnitTestCompilerPlugin
+    "HostUnitTestCompilerPlugin": {
+    "DscPath": "" # Don't support this test
+    },
+
+    ## options defined .pytool/Plugin/CharEncodingCheck
+    "CharEncodingCheck": {
+    "IgnoreFiles": []
+    },
+
+    ## options defined .pytool/Plugin/DependencyCheck
+    "DependencyCheck": {
+    "AcceptableDependencies": [
+  "IntelFsp2Pkg/IntelFsp2Pkg.dec",
+  "MdeModulePkg/MdeModulePkg.dec",
+  "MdePkg/MdePkg.dec",
+  "UefiCpuPkg/UefiCpuPkg.dec"
+    ],
+    # For host based unit tests
+    "AcceptableDependencies-HOST_APPLICATION":[
+  "UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec"
+    ],
+    # For UEFI shell based apps
+    "AcceptableDependencies-UEFI_APPLICATION":[],
+    "IgnoreInf": []
+    },
+
+    ## options defined .pytool/Plugin/DscCompleteCheck
+    "DscCompleteCheck": {
+    "IgnoreInf": [""],
+    "DscPath": "IntelFsp2Pkg.dsc"
+    },
+
+    ## options defined .pytool/Plugin/HostUnitTestDscCompleteCheck
+    "HostUnitTestDscCompleteCheck": {
+    "IgnoreInf": [""],
+    "DscPath": "" # Don't support this test
+    },
+
+    ## options defined .pytool/Plugin/GuidCheck
+    "GuidCheck": {
+    "IgnoreGuidName": [],
+    "IgnoreGuidValue": [],
+    "IgnoreFoldersAndFiles": [],
+    "IgnoreDuplicates": [],
+    },
+
+    ## options defined .pytool/Plugin/LibraryClassCheck
+    "LibraryClassCheck": {
+    "IgnoreHeaderFile": []
+    },
+
+    ## options defined .pytool/Plugin/SpellCheck
+    "SpellCheck": {
+    "AuditOnly": True,   # Fails right now with over 270 
errors
+    "IgnoreFiles": [],   # use gitignore syntax to ignore 
errors in matching files
+    "ExtendWords": [],   # words to extend to the 
dictionary for this package
+    "IgnoreStandardPaths": [],   # Standard Plugin defined paths 
that should be ignore
+    

Re: [edk2-devel] [PATCH v1 1/2] SignedCapsulePkg: Add package CI YAML file

2022-09-22 Thread Michael Kubacki

Review reminder

On 9/15/2022 3:36 PM, Michael Kubacki wrote:

Hi Jian,

Can you please provide a review for this patch?

Mike Kinney has already given an R-b for [PATCH v1 2/2] so the series 
will be ready once this patch is reviewed.


Thanks,
Michael

On 9/7/2022 1:05 AM, Michael Kubacki wrote:

From: Michael Kubacki 

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

Adds the package as a supported package to .pytool/CISettings.py
and adds a CI YAML for the package so it can be run in CI.

Cc: Jian J Wang 
Signed-off-by: Michael Kubacki 
---
  .pytool/CISettings.py |  1 +
  SignedCapsulePkg/SignedCapsulePkg.ci.yaml | 90 
  2 files changed, 91 insertions(+)

diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py
index cf9e0d77b19b..306e27893e58 100644
--- a/.pytool/CISettings.py
+++ b/.pytool/CISettings.py
@@ -62,6 +62,7 @@ class Settings(CiBuildSettingsManager, 
UpdateSettingsManager, SetupSettingsManag

  "UefiCpuPkg",
  "FmpDevicePkg",
  "ShellPkg",
+    "SignedCapsulePkg",
  "StandaloneMmPkg",
  "FatPkg",
  "CryptoPkg",
diff --git a/SignedCapsulePkg/SignedCapsulePkg.ci.yaml 
b/SignedCapsulePkg/SignedCapsulePkg.ci.yaml

new file mode 100644
index ..5f48613bd79f
--- /dev/null
+++ b/SignedCapsulePkg/SignedCapsulePkg.ci.yaml
@@ -0,0 +1,90 @@
+## @file
+# Core CI configuration for SignedCapsulePkg
+#
+# Copyright (c) Microsoft Corporation
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+{
+    ## options defined .pytool/Plugin/LicenseCheck
+    "LicenseCheck": {
+    "IgnoreFiles": []
+    },
+
+    "EccCheck": {
+    ## Exception sample looks like below:
+    ## "ExceptionList": [
+    ## "", ""
+    ## ]
+    "ExceptionList": [
+    ],
+    ## Both file path and directory path are accepted.
+    "IgnoreFiles": []
+    },
+
+    ## options defined .pytool/Plugin/CompilerPlugin
+    "CompilerPlugin": {
+    "DscPath": "SignedCapsulePkg.dsc"
+    },
+
+    ## options defined .pytool/Plugin/HostUnitTestCompilerPlugin
+    "HostUnitTestCompilerPlugin": {
+    "DscPath": "" # Don't support this test
+    },
+
+    ## options defined .pytool/Plugin/CharEncodingCheck
+    "CharEncodingCheck": {
+    "IgnoreFiles": []
+    },
+
+    ## options defined .pytool/Plugin/DependencyCheck
+    "DependencyCheck": {
+    "AcceptableDependencies": [
+  "MdeModulePkg/MdeModulePkg.dec",
+  "MdePkg/MdePkg.dec",
+  "SecurityPkg/SecurityPkg.dec",
+  "SignedCapsulePkg/SignedCapsulePkg.dec"
+    ],
+    # For host based unit tests
+    "AcceptableDependencies-HOST_APPLICATION":[
+  "UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec"
+    ],
+    # For UEFI shell based apps
+    "AcceptableDependencies-UEFI_APPLICATION":[],
+    "IgnoreInf": []
+    },
+
+    ## options defined .pytool/Plugin/DscCompleteCheck
+    "DscCompleteCheck": {
+    "IgnoreInf": [""],
+    "DscPath": "SignedCapsulePkg.dsc"
+    },
+
+    ## options defined .pytool/Plugin/HostUnitTestDscCompleteCheck
+    "HostUnitTestDscCompleteCheck": {
+    "IgnoreInf": [""],
+    "DscPath": "" # Don't support this test
+    },
+
+    ## options defined .pytool/Plugin/GuidCheck
+    "GuidCheck": {
+    "IgnoreGuidName": [],
+    "IgnoreGuidValue": [],
+    "IgnoreFoldersAndFiles": [],
+    "IgnoreDuplicates": [],
+    },
+
+    ## options defined .pytool/Plugin/LibraryClassCheck
+    "LibraryClassCheck": {
+    "IgnoreHeaderFile": []
+    },
+
+    ## options defined .pytool/Plugin/SpellCheck
+    "SpellCheck": {
+    "AuditOnly": True,   # Failures need to be reviewed 
and resolved in the future
+    "IgnoreFiles": [],   # use gitignore syntax to ignore 
errors in matching files
+    "ExtendWords": [],   # words to extend to the 
dictionary for this package
+    "IgnoreStandardPaths": [],   # Standard Plugin defined paths 
that should be ignore
+    "AdditionalIncludePaths": [] # Additional paths to spell 
check (wildcards supported)

+    }
+}



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




Re: [edk2-devel] How to guard CAR's stack overflow

2022-09-22 Thread Tiger Liu(BJ-RD)
Hi, Johnson:
Thanks a lot.

Usually stack locates on top of heap area,
After swapping stack and heap’s location, your method seems ok.

Thanks
发件人: Brian J. Johnson 
发送时间: 2022年9月23日 5:07
收件人: Tiger Liu(BJ-RD) ; devel@edk2.groups.io; Ni, Ray 

主题: Re: [edk2-devel] How to guard CAR's stack overflow

I've never tried protecting the stack like this, so I'm not sure exactly what 
you're running in to.  The documentation says the base address is specified a 
bit differently for expand-down descriptors.  It needs to point to the page 
below the stack (lower addresses.)  The descriptors for the other segments 
would still need to cover the entire address space (limit 0x, 
page-granular, expand-up.)  And you'd need to use a different segment selector 
(and hence a different GDT entry) for the stack segment (ss register) than for 
the regular data segments.  Most of the early PEI code I've seen uses the same 
selector for ds, ef, fs, gs, and ss.

Hope that helps.  This is mostly theoretical.  I don't actually have a lot of 
experience with x86 segment programming.

Brian J. Johnson

From: Tiger Liu(BJ-RD) [mailto:tiger...@zhaoxin.com]
Sent: Wednesday, September 21, 2022, 10:32 PM
To: devel@edk2.groups.io 
, Ni, Ray 
, 
brian.john...@hpe.com 

Subject: [edk2-devel] How to guard CAR's stack overflow

Hi, Johnson:
Thanks for your reply!

I tried and found it seemed causing some other problems.

It hang in eary pei stage.

It seems below code could also cause an exception if using expand-down mode in 
CAR phase’s stack established.
mov eax, ss:[ebx]
 mov eax, [ebp]
  mov eax, [esp]

Thanks
发件人: Brian J. Johnson mailto:brian.john...@hpe.com>
发送时间: 2022年9月20日 7:10
收件人: devel@edk2.groups.io; 
ray...@intel.com; Tiger Liu(BJ-RD) 
mailto:tiger...@zhaoxin.com>
抄送: Fan, Jeff mailto:fanjianf...@byosoft.com.cn>
主题: Re: [edk2-devel] How to guard CAR's stack overflow

You could also try modifying the Ia32 segment descriptors to mark the stack 
segment as an "expand down" type with a limit set just below the low end of the 
stack area.  That should generate a stack-fault exception if the stack 
overflows, and wouldn't require building page tables.  See sections 5.1 - 5.3 
of the Intel SDM, volume 3.

Brian J. Johnson


From: Ni, Ray [mailto:ray...@intel.com]
Sent: Wednesday, September 14, 2022, 10:25 PM
To: devel@edk2.groups.io 
, 
tiger...@zhaoxin.com 

Cc: Fan, Jeff 
Subject: [edk2-devel] How to guard CAR's stack overflow

It’s doable.
You need to enable paging and mark the very low 4K area of the stack as 
not-present.
You could use the UefiCpuPkg/Library/CpuPageTableLib to help you create the 1:1 
page table with the specific
4K area as not-present (if you are using x86 processors).

Thanks,
Ray

From: devel@edk2.groups.io 
 On Behalf Of Tiger 
Liu(BJ-RD)
Sent: Thursday, September 15, 2022 8:50 AM
To: devel@edk2.groups.io
Subject: [edk2-devel] How to guard CAR's stack overflow

Hi, Experts:
Usually, we use Cache As Ram to setup stack and heap for C language running 
environment before permanent memory has been initialized.

So, is there a method to guard this phase’s stack overflow?

Note:
I find udk has introduced a method to guard stack overflow after memory has 
been initialized and discovered.

Thanks

保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for 
the sole use of its intended recipient. Any unauthorized review, use, copying 
or forwarding of this email or the content of this email is strictly prohibited.
_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#93797) | | 
Mute This Topic | New 
Topic
Your Subscription | Contact 
Group Owner | 
Unsubscribe 
[brian.john...@hpe.com]
_


保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for 
the sole use of its intended recipient. Any unauthorized review, use, copying 
or forwarding of this email or the content of this email is strictly prohibited.



保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This 

Re: [edk2-devel] OvmfPkgX64: PlatformInitLib.lib(IntelTdx.obj): in function `ValidateHobList': undefined reference to `memcpy' (CLANG38 NOOPT)

2022-09-22 Thread Rebecca Cran

On 9/22/22 15:32, Ard Biesheuvel wrote:

This appears to be due to the use of initializers for the arrays.
Could you please check if the patch below makes the issue go away?

diff --git a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c
b/OvmfPkg/Library/PlatformInitLib/IntelTdx.c
index c6d7c8bb6e0e..0e0e13343b16 100644
--- a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c
+++ b/OvmfPkg/Library/PlatformInitLib/IntelTdx.c
@@ -153,7 +153,7 @@ BOOLEAN
  EFIAPI
  IsInValidList (
IN UINT32  Value,
-  IN UINT32  *ValidList,
+  IN CONST UINT32  *ValidList,
IN UINT32  ValidListLength
)
  {
@@ -188,7 +188,7 @@ ValidateHobList (
)
  {
EFI_PEI_HOB_POINTERS  Hob;
-  UINT32EFI_BOOT_MODE_LIST[] = {
+  STATIC CONST UINT32   EFI_BOOT_MODE_LIST[] = {
  BOOT_WITH_FULL_CONFIGURATION,
  BOOT_WITH_MINIMAL_CONFIGURATION,
  BOOT_ASSUMING_NO_CONFIGURATION_CHANGES,
@@ -203,7 +203,7 @@ ValidateHobList (
  BOOT_IN_RECOVERY_MODE
};

-  UINT32  EFI_RESOURCE_TYPE_LIST[] = {
+  STATIC CONST UINT32  EFI_RESOURCE_TYPE_LIST[] = {
  EFI_RESOURCE_SYSTEM_MEMORY,
  EFI_RESOURCE_MEMORY_MAPPED_IO,
  EFI_RESOURCE_IO,


Yes, that fixes it.

--

Rebecca Cran



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#94147): https://edk2.groups.io/g/devel/message/94147
Mute This Topic: https://groups.io/mt/93858052/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/3] CryptoPkg: Add EC support

2022-09-22 Thread Michael D Kinney
Hi Yi,

I agree EC is an important feature.

I did some analysis of the size impact to the CryptoPkg modules on current trunk
with EC on and off. Uncompressed size is important for PEI Phase.  For DXE and
SMM phase, the Crypto services can always be compressed.  From the table below,
building all the EC services in the OpensslLib has no size impact to the NONE 
profile and the MIN_PEI profile.  It has ~105 KB impact to compressed DXE/SMM 
usages that may use the MIN_DXE_MIN_SMM or ALL profiles.

   Uncompressed  LZMA Compressed
CPU   CRYPTO_SERVICESModule  EC=FALSE  EC=TRUE  EC=FALSE  EC=TRUE  Increase
  ===      ===    ===  
IA32  NONE CryptoPei2153621568 0 KB
IA32  NONE CryptoDxe2163221696 0 KB
IA32  NONE CryptoSmm2297623072 0 KB
IA32  MIN_PEI  CryptoPei   248992   249120 0 KB
IA32  MIN_DXE_MIN_SMM  CryptoDxe   636672   829568288520   401034113 KB
IA32  MIN_DXE_MIN_SMM  CryptoSmm   426048   601472191517   296022105 KB
IA32  ALL  CryptoPei   423840   598976189047   293759104 KB
IA32  ALL  CryptoDxe   645280   838144292955   405277113 KB
IA32  ALL  CryptoSmm   441888   617184198779   303628105 KB
X64   NONE CryptoPei2963229664 0 KB
X64   NONE CryptoDxe2979229792 0 KB
X64   NONE CryptoSmm3129631296 0 KB
X64   MIN_PEI  CryptoPei   310784   310848 0 KB
X64   MIN_DXE_MIN_SMM  CryptoDxe   804288  1016256311436   426596115 KB
X64   MIN_DXE_MIN_SMM  CryptoSmm   543776   733920204483   310775106 KB
X64   ALL  CryptoPei   540384   730240202494   308467106 KB
X64   ALL  CryptoDxe   815392  1027296316228   431321115 KB
X64   ALL  CryptoSmm   563648   753696213488   319644106 KB

NOTE: Even if multiple modules in an FV use static linking of Crypto libs, if 
the
  entire FV is compressed, the total size impact is typically the size of a
  single instance of a compressed CryptoLib.  The sizes of the Crypto* 
modules
  in the table above should be a close approximation of the size impact to a
  single FV.

Does this match your previous size analysis?

The critical issue to evaluate here is why adding the EC sources to 
OpensllLib.inf
causes the modules that do not use any EC services to grow by ~105KB.  Has any
detailed analysis of the final linked images been performed to see where this 
additional size is coming from?

Thanks,

Mike

> -Original Message-
> From: Li, Yi1 
> Sent: Thursday, September 22, 2022 5:54 AM
> To: Kinney, Michael D ; devel@edk2.groups.io; 
> Kishore, Shelly 
> Cc: Yao, Jiewen ; Wang, Jian J ; 
> Lu, Xiaoyu1 ; Jiang,
> Guomin 
> Subject: RE: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support
> 
> Hi Mike,
> I have did some POC that seems existed structured PCD is hard to control 
> binary size,
> Here is the previous discussion for reference.
> https://bugzilla.tianocore.org/show_bug.cgi?id=3679
> https://edk2.groups.io/g/devel/topic/86257810#81814
> https://bugzilla.tianocore.org/show_bug.cgi?id=1446
> 
> Anyway EC is an important feature which consumed by vary modern security 
> features such WPA3 , SPDM, TLS1.3 etc.
> Hope it can be added to edk2, and I am glad to take the code and test work if 
> there are other ways to control the size.
> 
> Thanks,
> Yi
> 
> -Original Message-
> From: Kinney, Michael D 
> Sent: Thursday, September 22, 2022 11:56 AM
> To: Li, Yi1 ; devel@edk2.groups.io; Kishore, Shelly 
> 
> Cc: Yao, Jiewen ; Wang, Jian J ; 
> Lu, Xiaoyu1 ; Jiang,
> Guomin 
> Subject: RE: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support
> 
> That change to OpensslLib.inf should not have been done either.
> 
> Looks like this EC feature needs more evaluation to fit into the
> structured PCD control of the lib sizes.
> 
> Mike
> 
> > -Original Message-
> > From: Li, Yi1 
> > Sent: Wednesday, September 21, 2022 7:16 PM
> > To: Kinney, Michael D ; devel@edk2.groups.io
> > Cc: Yao, Jiewen ; Wang, Jian J 
> > ; Lu, Xiaoyu1 ; Jiang,
> > Guomin 
> > Subject: RE: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support
> >
> > Hi Mike,
> > Thanks for review.
> >
> > Even PCD_CRYPTO_SERVICE_FAMILY_ENABLE is set to 0, CryptoEc.c will also be 
> > compiled and throw build error:
> >
> > d:\workspace\tianocore\edk2\CryptoPkg\Library\BaseCryptLib\Pk\CryptEc.c(77):
> >  error C2220: the following warning is treated
> as
> > an error
> > 1 file(s) copied.
> > d:\workspace\tianocore\edk2\CryptoPkg\Library\BaseCryptLib\Pk\CryptEc.c(77):
> >  warning C4013: 'EC_GROUP_new_by_curve_name'
> > 

Re: [edk2-devel] [PATCH v3] EmbeddedPkg/PrePiMemoryAllocationLib: Add check for space on offset allocation

2022-09-22 Thread Ard Biesheuvel
On Thu, 22 Sept 2022 at 22:40, Jeff Brasen  wrote:
>
> Update check for enough space to occur prior to alignment offset.
> This prevents cases where EfiFreeMemoryTop < EfiFreeMemoryBottom.
>
> Change-Id: I58c5d378523c881a4afc655e7ace4c009130c781

Thanks for respinning this. Care to add a signed-off-by ?


> ---
>  .../MemoryAllocationLib.c | 48 ---
>  1 file changed, 21 insertions(+), 27 deletions(-)
>
> diff --git 
> a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c 
> b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> index 2cc2a71121..08a0add340 100644
> --- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> +++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> @@ -23,41 +23,35 @@ InternalAllocatePages (
>)
>  {
>EFI_PEI_HOB_POINTERS  Hob;
> -  EFI_PHYSICAL_ADDRESS  Offset;
> +  EFI_PHYSICAL_ADDRESS  NewTop;
>
>Hob.Raw = GetHobList ();
>
> -  // Check to see if on 4k boundary
> -  Offset = Hob.HandoffInformationTable->EfiFreeMemoryTop & 0xFFF;
> -  if (Offset != 0) {
> -// If not aligned, make the allocation aligned.
> -Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset;
> -  }
> +  NewTop  = Hob.HandoffInformationTable->EfiFreeMemoryTop & 
> ~(EFI_PHYSICAL_ADDRESS)EFI_PAGE_MASK;
> +  NewTop -= Pages * EFI_PAGE_SIZE;
>
>//
>// Verify that there is sufficient memory to satisfy the allocation
>//
> -  if (Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages * 
> EFI_PAGE_SIZE) + sizeof (EFI_HOB_MEMORY_ALLOCATION)) < 
> Hob.HandoffInformationTable->EfiFreeMemoryBottom) {
> -return 0;
> -  } else {
> -//
> -// Update the PHIT to reflect the memory usage
> -//
> -Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages * EFI_PAGE_SIZE;
> -
> -// This routine used to create a memory allocation HOB a la PEI, but 
> that's not
> -// necessary for us.
> -
> -//
> -// Create a memory allocation HOB.
> -//
> -BuildMemoryAllocationHob (
> -  Hob.HandoffInformationTable->EfiFreeMemoryTop,
> -  Pages * EFI_PAGE_SIZE,
> -  MemoryType
> -  );
> -return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;
> +  if (NewTop < (Hob.HandoffInformationTable->EfiFreeMemoryBottom + sizeof 
> (EFI_HOB_MEMORY_ALLOCATION))) {
> +return NULL;
>}
> +
> +  //
> +  // Update the PHIT to reflect the memory usage
> +  //
> +  Hob.HandoffInformationTable->EfiFreeMemoryTop = NewTop;
> +
> +  //
> +  // Create a memory allocation HOB.
> +  //
> +  BuildMemoryAllocationHob (
> +Hob.HandoffInformationTable->EfiFreeMemoryTop,
> +Pages * EFI_PAGE_SIZE,
> +MemoryType
> +);
> +
> +  return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;
>  }
>
>  /**
> --
> 2.25.1
>


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




Re: [edk2-devel] OvmfPkgX64: PlatformInitLib.lib(IntelTdx.obj): in function `ValidateHobList': undefined reference to `memcpy' (CLANG38 NOOPT)

2022-09-22 Thread Ard Biesheuvel
On Thu, 22 Sept 2022 at 23:12, Rebecca Cran  wrote:
>
> I just noticed that edk2 master seems broken when building OvmfPkgX64.dsc 
> with -t CLANG38 -b NOOPT (using Debian clang version 11.0.1-2).
>
> "clang" -o
> /home/rcran/src/upstream/uefi/edk2/Build/OvmfX64/NOOPT_CLANG38/X64/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe/DEBUG/DiskIoDxe.dll
> -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x40
> -Wl,--entry,_ModuleEntryPoint -u _ModuleEntryPoint
> -Wl,-Map,/home/rcran/src/upstream/uefi/edk2/Build/OvmfX64/NOOPT_CLANG38/X64/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe/DEBUG/DiskIoDxe.map,--whole-archive
> -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie
> -mcmodel=small
> -Wl,--start-group,@/home/rcran/src/upstream/uefi/edk2/Build/OvmfX64/NOOPT_CLANG38/X64/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe/OUTPUT/static_library_files.lst,--end-group
> -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror
> -Wno-array-bounds -include AutoGen.h -fno-common -ffunction-sections
> -fdata-sections -DSTRING_ARRAY_NAME=DiskIoDxeStrings
> -Wno-parentheses-equality -Wno-tautological-compare
> -Wno-tautological-constant-out-of-range-compare -Wno-empty-body
> -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option
> -Wno-unused-but-set-variable -Wno-unused-const-variable
> -fno-stack-protector -mms-bitfields -Wno-address
> -Wno-shift-negative-value -Wno-unknown-pragmas
> -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables
> -mno-sse -mno-mmx -msoft-float -mno-implicit-float
> -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang
> -funsigned-char -fno-ms-extensions -Wno-null-dereference -m64
> "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie
> -O0 -target x86_64-pc-linux-gnu -g -mno-mmx -mno-sse -D
> DISABLE_NEW_DEPRECATED_INTERFACES -D TDX_GUEST_SUPPORTED -D
> ENABLE_MD5_DEPRECATED_INTERFACES -Wl,--defsym=PECOFF_HEADER_SIZE=0x228
> -Wl,--script=/home/rcran/src/upstream/uefi/edk2/BaseTools/Scripts/GccBase.lds
> -Wno-error -O0
> /usr/bin/ld:
> /home/rcran/src/upstream/uefi/edk2/Build/OvmfX64/NOOPT_CLANG38/X64/OvmfPkg/Library/PlatformInitLib/PlatformInitLib/OUTPUT/PlatformInitLib.lib(IntelTdx.obj):
> in function `ValidateHobList':
> /home/rcran/src/upstream/uefi/edk2/OvmfPkg/Library/PlatformInitLib/IntelTdx.c:191:
> undefined reference to `memcpy'
>

Hello Rebecca,

This appears to be due to the use of initializers for the arrays.
Could you please check if the patch below makes the issue go away?

diff --git a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c
b/OvmfPkg/Library/PlatformInitLib/IntelTdx.c
index c6d7c8bb6e0e..0e0e13343b16 100644
--- a/OvmfPkg/Library/PlatformInitLib/IntelTdx.c
+++ b/OvmfPkg/Library/PlatformInitLib/IntelTdx.c
@@ -153,7 +153,7 @@ BOOLEAN
 EFIAPI
 IsInValidList (
   IN UINT32  Value,
-  IN UINT32  *ValidList,
+  IN CONST UINT32  *ValidList,
   IN UINT32  ValidListLength
   )
 {
@@ -188,7 +188,7 @@ ValidateHobList (
   )
 {
   EFI_PEI_HOB_POINTERS  Hob;
-  UINT32EFI_BOOT_MODE_LIST[] = {
+  STATIC CONST UINT32   EFI_BOOT_MODE_LIST[] = {
 BOOT_WITH_FULL_CONFIGURATION,
 BOOT_WITH_MINIMAL_CONFIGURATION,
 BOOT_ASSUMING_NO_CONFIGURATION_CHANGES,
@@ -203,7 +203,7 @@ ValidateHobList (
 BOOT_IN_RECOVERY_MODE
   };

-  UINT32  EFI_RESOURCE_TYPE_LIST[] = {
+  STATIC CONST UINT32  EFI_RESOURCE_TYPE_LIST[] = {
 EFI_RESOURCE_SYSTEM_MEMORY,
 EFI_RESOURCE_MEMORY_MAPPED_IO,
 EFI_RESOURCE_IO,


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




[edk2-devel] OvmfPkgX64: PlatformInitLib.lib(IntelTdx.obj): in function `ValidateHobList': undefined reference to `memcpy' (CLANG38 NOOPT)

2022-09-22 Thread Rebecca Cran

I just noticed that edk2 master seems broken when building OvmfPkgX64.dsc with 
-t CLANG38 -b NOOPT (using Debian clang version 11.0.1-2).

"clang" -o 
/home/rcran/src/upstream/uefi/edk2/Build/OvmfX64/NOOPT_CLANG38/X64/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe/DEBUG/DiskIoDxe.dll 
-nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x40 
-Wl,--entry,_ModuleEntryPoint -u _ModuleEntryPoint 
-Wl,-Map,/home/rcran/src/upstream/uefi/edk2/Build/OvmfX64/NOOPT_CLANG38/X64/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe/DEBUG/DiskIoDxe.map,--whole-archive 
-Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie 
-mcmodel=small 
-Wl,--start-group,@/home/rcran/src/upstream/uefi/edk2/Build/OvmfX64/NOOPT_CLANG38/X64/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe/OUTPUT/static_library_files.lst,--end-group 
-g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror 
-Wno-array-bounds -include AutoGen.h -fno-common -ffunction-sections 
-fdata-sections -DSTRING_ARRAY_NAME=DiskIoDxeStrings 
-Wno-parentheses-equality -Wno-tautological-compare 
-Wno-tautological-constant-out-of-range-compare -Wno-empty-body 
-Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option 
-Wno-unused-but-set-variable -Wno-unused-const-variable 
-fno-stack-protector -mms-bitfields -Wno-address 
-Wno-shift-negative-value -Wno-unknown-pragmas 
-Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables 
-mno-sse -mno-mmx -msoft-float -mno-implicit-float 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang 
-funsigned-char -fno-ms-extensions -Wno-null-dereference -m64 
"-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie 
-O0 -target x86_64-pc-linux-gnu -g -mno-mmx -mno-sse -D 
DISABLE_NEW_DEPRECATED_INTERFACES -D TDX_GUEST_SUPPORTED -D 
ENABLE_MD5_DEPRECATED_INTERFACES -Wl,--defsym=PECOFF_HEADER_SIZE=0x228 
-Wl,--script=/home/rcran/src/upstream/uefi/edk2/BaseTools/Scripts/GccBase.lds 
-Wno-error -O0
/usr/bin/ld: 
/home/rcran/src/upstream/uefi/edk2/Build/OvmfX64/NOOPT_CLANG38/X64/OvmfPkg/Library/PlatformInitLib/PlatformInitLib/OUTPUT/PlatformInitLib.lib(IntelTdx.obj): 
in function `ValidateHobList':
/home/rcran/src/upstream/uefi/edk2/OvmfPkg/Library/PlatformInitLib/IntelTdx.c:191: 
undefined reference to `memcpy'


--
Rebecca Cran



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




Re: [edk2-devel] How to guard CAR's stack overflow

2022-09-22 Thread Brian J. Johnson
I've never tried protecting the stack like this, so I'm not sure exactly 
what you're running in to. The documentation says the base address is 
specified a bit differently for expand-down descriptors.  It needs to 
point to the page below the stack (lower addresses.)  The descriptors 
for the other segments would still need to cover the entire address 
space (limit 0x, page-granular, expand-up.)  And you'd need to use a 
different segment selector (and hence a different GDT entry) for the 
stack segment (ss register) than for the regular data segments.  Most of 
the early PEI code I've seen uses the same selector for ds, ef, fs, gs, 
and ss.


Hope that helps.  This is mostly theoretical.  I don't actually have a 
lot of experience with x86 segment programming.


Brian J. Johnson

*From:* Tiger Liu(BJ-RD) [mailto:tiger...@zhaoxin.com]
*Sent:* Wednesday, September 21, 2022, 10:32 PM
*To:* devel@edk2.groups.io , Ni, Ray 
, brian.john...@hpe.com 

*Subject:* [edk2-devel] How to guard CAR's stack overflow


Hi, Johnson:

Thanks for your reply!

I tried and found it seemed causing some other problems.

It hang in eary pei stage.

It seems below code could also cause an exception if using expand-down 
mode in CAR phase’s stack established.


mov eax, ss:[ebx]

 mov eax, [ebp]

mov eax, [esp]

Thanks

*发件人:*Brian J. Johnson *收件人:*devel@edk2.groups.io; ray...@intel.com; Tiger Liu(BJ-RD) 

*抄送:*Fan, Jeff You could also try modifying the Ia32 segment descriptors to mark the 
stack segment as an "expand down" type with a limit set just below the 
low end of the stack area. That should generate a stack-fault 
exception if the stack overflows, and wouldn't require building page 
tables. See sections 5.1 - 5.3 of the Intel SDM, volume 3.


Brian J. Johnson



*From:*Ni, Ray [mailto:ray...@intel.com ]

*Sent:*Wednesday, September 14, 2022, 10:25 PM

*To:*devel@edk2.groups.io  
, tiger...@zhaoxin.com 
 


*Cc:*Fan, Jeff  



*Subject:*[edk2-devel] How to guard CAR's stack overflow

It’s doable.

You need to enable paging and mark the very low 4K area of the
stack as not-present.

You could use the UefiCpuPkg/Library/CpuPageTableLib to help you
create the 1:1 page table with the specific
4K area as not-present (if you are using x86 processors).

Thanks,

Ray

*From:*devel@edk2.groups.io 
 *On Behalf Of *Tiger Liu(BJ-RD)
*Sent:* Thursday, September 15, 2022 8:50 AM
*To:* devel@edk2.groups.io
*Subject:* [edk2-devel] How to guard CAR's stack overflow

Hi, Experts:

Usually, we use Cache As Ram to setup stack and heap for C
language running environment before permanent memory has been
initialized.

So, is there a method to guard this phase’s stack overflow?

Note:

I find udk has introduced a method to guard stack overflow after
memory has been initialized and discovered.

Thanks

保密声明:

本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。

/CONFIDENTIAL NOTE: /

/This email contains confidential or legally privileged
information and is for the sole use of its intended recipient. Any
unauthorized review, use, copying or forwarding of this email or
the content of this email is strictly prohibited./

_._,_._,_



Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#93797)

| | Mute This Topic

| New Topic

Your Subscription

| Contact Group Owner  |
Unsubscribe

[brian.john...@hpe.com]

_



保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
/CONFIDENTIAL NOTE: /
/This email contains confidential or legally privileged information 
and is for the sole use of its intended recipient. Any unauthorized 
review, use, copying or forwarding of this email or the content of 
this email is strictly prohibited./




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




[edk2-devel] [PATCH 3/3] MdeModulePkg: add EnableUnacceptedMemoryProtocol

2022-09-22 Thread Dionna Glaze via groups.io
Add a simple protocol that enables the use of the unaccepted memory
type. Must be called before ExitBootServices to be effective.

Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Cc: Ard Biesheuvel 

Signed-off-by: Dionna Glaze 
---
 MdeModulePkg/Core/Dxe/DxeMain.h | 22 
 MdeModulePkg/Core/Dxe/DxeMain.inf   |  3 ++-
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c |  5 
 MdeModulePkg/Core/Dxe/Mem/Page.c| 35 +
 MdeModulePkg/MdeModulePkg.dec   |  3 +++
 5 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h
index ac943c87a3..5f0114b04f 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.h
+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
@@ -2708,6 +2708,28 @@ CoreResolveUnacceptedMemory (
   VOID
   );
 
+
+typedef struct _ENABLE_UNACCEPTED_MEMORY_PROTOCOL
+ENABLE_UNACCEPTED_MEMORY_PROTOCOL;
+
+typedef EFI_STATUS (EFIAPI *ENABLE_UNACCEPTED_MEMORY)(
+  IN ENABLE_UNACCEPTED_MEMORY_PROTOCOL *
+  );
+
+struct _ENABLE_UNACCEPTED_MEMORY_PROTOCOL {
+  ENABLE_UNACCEPTED_MEMORY Enable;
+};
+
+extern EFI_GUID gEnableUnacceptedMemoryProtocolGuid;
+
+/**
+   Implement the protocol for enabling unaccepted memory.
+ **/
+VOID
+InstallEnableUnacceptedMemoryProtocol (
+  VOID
+  );
+
 /**
   Install MemoryAttributesTable on memory allocation.
 
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf 
b/MdeModulePkg/Core/Dxe/DxeMain.inf
index deb8bb2ba8..39dcac98bb 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -122,6 +122,7 @@
   gEfiMemoryAttributesTableGuid ## SOMETIMES_PRODUCES   ## 
SystemTable
   gEfiEndOfDxeEventGroupGuid## SOMETIMES_CONSUMES   ## 
Event
   gEfiHobMemoryAllocStackGuid   ## SOMETIMES_CONSUMES   ## 
SystemTable
+  gEnableUnacceptedMemoryProtocolGuid   ## PRODUCES ## 
GUID # Install protocol
 
 [Ppis]
   gEfiVectorHandoffInfoPpiGuid  ## UNDEFINED # HOB
@@ -187,7 +188,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask   ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard   ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth   ## 
CONSUMES
-  gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory  ## 
CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory  ## 
CONSUMES ## SOMETIMES_PRODUCES
 
 # [Hob]
 # RESOURCE_DESCRIPTOR   ## CONSUMES
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c 
b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
index 8d1de32fe7..bc1a8ab6b2 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
@@ -354,6 +354,11 @@ DxeMain (
   Status = CoreInstallConfigurationTable (, 
);
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Install unaccepted memory configuration protocol
+  //
+  InstallEnableUnacceptedMemoryProtocol();
+
   //
   // If Loading modules At fixed address feature is enabled, install Load 
moduels at fixed address
   // Configuration Table so that user could easily to retrieve the top address 
to load Dxe and PEI
diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c
index cbebe62a28..10e152d80d 100644
--- a/MdeModulePkg/Core/Dxe/Mem/Page.c
+++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
@@ -96,6 +96,14 @@ EFI_MEMORY_TYPE_INFORMATION  
gMemoryTypeInformation[EfiMaxMemoryType + 1] = {
 //
 GLOBAL_REMOVE_IF_UNREFERENCED   BOOLEAN  gLoadFixedAddressCodeMemoryReady = 
FALSE;
 
+EFI_STATUS EFIAPI CoreEnableUnacceptedMemory(IN 
ENABLE_UNACCEPTED_MEMORY_PROTOCOL *);
+
+struct {
+  ENABLE_UNACCEPTED_MEMORY enable;
+} mEnableUnacceptedMemoryProtocol = {
+  CoreEnableUnacceptedMemory,
+};
+
 /**
   Enter critical section by gaining lock on gMemoryLock.
 
@@ -2205,6 +2213,33 @@ CoreResolveUnacceptedMemory (
   return AcceptAllUnacceptedMemory(AcceptMemory);
 }
 
+EFI_STATUS
+EFIAPI
+CoreEnableUnacceptedMemory (
+  IN ENABLE_UNACCEPTED_MEMORY_PROTOCOL *This
+  )
+{
+  return PcdSetBoolS(PcdEnableUnacceptedMemory, TRUE);
+}
+
+VOID
+InstallEnableUnacceptedMemoryProtocol (
+  VOID
+  )
+{
+  EFI_HANDLE  Handle;
+  EFI_STATUS  Status;
+
+  Handle = NULL;
+  Status = CoreInstallMultipleProtocolInterfaces (
+ ,
+ ,
+ ,
+ NULL
+ );
+  ASSERT_EFI_ERROR (Status);
+}
+
 /**
   Make sure the memory map is following all the construction rules,
   it is the last time to check memory map error before exit boot services.
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index dd07b3725a..ce72c06a93 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -244,6 +244,9 @@
   gEdkiiPerformanceMeasurementProtocolGuid  = { 0xc85d06be, 0x5f75, 
0x48ce, { 0xa8, 0x0f, 0x12, 0x36, 0xba, 0x3b, 0x87, 0xb1 } }
   

[edk2-devel] [PATCH v1 0/3] CryptoPkg/OpensslLib: Add native instruction support for IA32

2022-09-22 Thread Christopher Zurcher
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3654
PR: https://github.com/tianocore/edk2/pull/3352

This patch adds support for building the native instruction algorithms for
the IA32 architecture in OpensslLib. The base variant has been tested
with VS2019 and CLANGPDB toolchains, and a GCC variant is also provided.

The implementation here follows the previous implementation of X64
native instructions as committed in 878a92a887.

Cc: Yi Li 
Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 

Christopher Zurcher (3):
  CryptoPkg/OpensslLib: Add native instruction support for IA32
  CryptoPkg/OpensslLib: Commit the auto-generated assembly files for
IA32
  CryptoPkg/OpensslLib: Update generated files for native X64

 CryptoPkg/CryptoPkg.ci.yaml   |4 +
 CryptoPkg/Library/OpensslLib/IA32/crypto/aes/aesni-x86.nasm   | 3212 
+++
 CryptoPkg/Library/OpensslLib/IA32/crypto/aes/vpaes-x86.nasm   |  651 
 CryptoPkg/Library/OpensslLib/IA32/crypto/modes/ghash-x86.nasm |  700 
 CryptoPkg/Library/OpensslLib/IA32/crypto/sha/sha1-586.nasm| 1394 
 CryptoPkg/Library/OpensslLib/IA32/crypto/sha/sha256-586.nasm  | 3364 

 CryptoPkg/Library/OpensslLib/IA32/crypto/sha/sha512-586.nasm  |  579 
 CryptoPkg/Library/OpensslLib/IA32/crypto/x86cpuid.nasm|  433 +++
 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/aes/aesni-x86.S   | 3247 
+++
 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/aes/vpaes-x86.S   |  670 
 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/modes/ghash-x86.S |  703 
 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/sha/sha1-586.S| 1389 
 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/sha/sha256-586.S  | 3356 
+++
 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/sha/sha512-586.S  |  574 
 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/x86cpuid.S|  449 +++
 CryptoPkg/Library/OpensslLib/OpensslLibIa32.inf   |  699 
 CryptoPkg/Library/OpensslLib/OpensslLibIa32Gcc.inf|  699 
 CryptoPkg/Library/OpensslLib/OpensslLibX64.inf|   53 +
 CryptoPkg/Library/OpensslLib/OpensslLibX64Gcc.inf |   53 +
 CryptoPkg/Library/OpensslLib/UefiAsm.conf |   18 +
 CryptoPkg/Library/OpensslLib/process_files.pl |   12 +
 21 files changed, 22259 insertions(+)
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32/crypto/aes/aesni-x86.nasm
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32/crypto/aes/vpaes-x86.nasm
 create mode 100644 
CryptoPkg/Library/OpensslLib/IA32/crypto/modes/ghash-x86.nasm
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32/crypto/sha/sha1-586.nasm
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32/crypto/sha/sha256-586.nasm
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32/crypto/sha/sha512-586.nasm
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32/crypto/x86cpuid.nasm
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/aes/aesni-x86.S
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/aes/vpaes-x86.S
 create mode 100644 
CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/modes/ghash-x86.S
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/sha/sha1-586.S
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/sha/sha256-586.S
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/sha/sha512-586.S
 create mode 100644 CryptoPkg/Library/OpensslLib/IA32Gcc/crypto/x86cpuid.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslLibIa32.inf
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslLibIa32Gcc.inf

-- 
2.29.2.windows.2



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




[edk2-devel] [PATCH v1 3/3] CryptoPkg/OpensslLib: Update generated files for native X64

2022-09-22 Thread Christopher Zurcher
Cc: Yi Li 
Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Signed-off-by: Christopher Zurcher 
---
 CryptoPkg/Library/OpensslLib/OpensslLibX64.inf| 53 
 CryptoPkg/Library/OpensslLib/OpensslLibX64Gcc.inf | 53 
 2 files changed, 106 insertions(+)

diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibX64.inf 
b/CryptoPkg/Library/OpensslLib/OpensslLibX64.inf
index b92feaf1bf..5e92ba0844 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLibX64.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLibX64.inf
@@ -215,6 +215,43 @@
   $(OPENSSL_PATH)/crypto/dso/dso_vms.c
   $(OPENSSL_PATH)/crypto/dso/dso_win32.c
   $(OPENSSL_PATH)/crypto/ebcdic.c
+  $(OPENSSL_PATH)/crypto/ec/curve25519.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/curve448/arch_32/f_impl.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/curve448/curve448.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/curve448/curve448_tables.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/curve448/eddsa.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/curve448/f_generic.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/curve448/scalar.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec2_oct.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec2_smpl.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_ameth.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_asn1.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_check.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_curve.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_cvt.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_err.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_key.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_kmeth.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_lib.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_mult.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_oct.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_pmeth.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ec_print.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecdh_kdf.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecdh_ossl.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecdsa_ossl.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecdsa_sign.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecdsa_vrf.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/eck_prn.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecp_mont.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecp_nist.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistp224.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistp256.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistp521.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistputil.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecp_oct.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecp_smpl.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/ec/ecx_meth.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
   $(OPENSSL_PATH)/crypto/err/err.c
   $(OPENSSL_PATH)/crypto/err/err_prn.c
   $(OPENSSL_PATH)/crypto/evp/bio_b64.c
@@ -399,6 +436,10 @@
   $(OPENSSL_PATH)/crypto/siphash/siphash.c
   $(OPENSSL_PATH)/crypto/siphash/siphash_ameth.c
   $(OPENSSL_PATH)/crypto/siphash/siphash_pmeth.c
+  $(OPENSSL_PATH)/crypto/sm2/sm2_crypt.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  $(OPENSSL_PATH)/crypto/sm2/sm2_err.c  
|*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  

[edk2-devel] [PATCH v1 1/3] CryptoPkg/OpensslLib: Add native instruction support for IA32

2022-09-22 Thread Christopher Zurcher
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3654

Adding native instruction support for accelerated OpenSSL features for
IA32 architecture, following the pattern set by the previous commits for
X64 native support.

Cc: Yi Li 
Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Signed-off-by: Christopher Zurcher 
---
 CryptoPkg/CryptoPkg.ci.yaml|   4 +
 CryptoPkg/Library/OpensslLib/OpensslLibIa32.inf| 699 
 CryptoPkg/Library/OpensslLib/OpensslLibIa32Gcc.inf | 699 
 CryptoPkg/Library/OpensslLib/UefiAsm.conf  |  18 +
 CryptoPkg/Library/OpensslLib/process_files.pl  |  12 +
 5 files changed, 1432 insertions(+)

diff --git a/CryptoPkg/CryptoPkg.ci.yaml b/CryptoPkg/CryptoPkg.ci.yaml
index bb52ceb547..2fa3a3d5ee 100644
--- a/CryptoPkg/CryptoPkg.ci.yaml
+++ b/CryptoPkg/CryptoPkg.ci.yaml
@@ -9,6 +9,8 @@
 "LicenseCheck": {
 "IgnoreFiles": [
 # These directories contain auto-generated OpenSSL content
+"Library/OpensslLib/IA32",
+"Library/OpensslLib/IA32Gcc",
 "Library/OpensslLib/X64",
 "Library/OpensslLib/X64Gcc",
 "Library/Include/openssl"
@@ -72,6 +74,8 @@
 "DscPath": "CryptoPkg.dsc",
 "IgnoreInf": [
 # These are alternatives to OpensslLib.inf
+"CryptoPkg/Library/OpensslLib/OpensslLibIa32.inf",
+"CryptoPkg/Library/OpensslLib/OpensslLibIa32Gcc.inf",
 "CryptoPkg/Library/OpensslLib/OpensslLibX64.inf",
 "CryptoPkg/Library/OpensslLib/OpensslLibX64Gcc.inf"
 ]
diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibIa32.inf 
b/CryptoPkg/Library/OpensslLib/OpensslLibIa32.inf
new file mode 100644
index 00..b6ee718ede
--- /dev/null
+++ b/CryptoPkg/Library/OpensslLib/OpensslLibIa32.inf
@@ -0,0 +1,699 @@
+## @file
+#  This module provides OpenSSL Library implementation.
+#
+#  Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.
+#  (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = OpensslLibIa32
+  MODULE_UNI_FILE= OpensslLib.uni
+  FILE_GUID  = 5805D1D4-F8EE-4FBA-BDD8-74465F16A534
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = OpensslLib
+  DEFINE OPENSSL_PATH= openssl
+  DEFINE OPENSSL_FLAGS   = -DL_ENDIAN -DOPENSSL_SMALL_FOOTPRINT 
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
+  DEFINE OPENSSL_FLAGS_CONFIG= -DOPENSSL_CPUID_OBJ -DSHA1_ASM -DSHA256_ASM 
-DSHA512_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM
+  CONSTRUCTOR= OpensslLibConstructor
+
+#
+#  VALID_ARCHITECTURES   = IA32
+#
+
+[Sources.IA32]
+  OpensslLibConstructor.c
+  $(OPENSSL_PATH)/e_os.h
+  $(OPENSSL_PATH)/ms/uplink.h
+# Autogenerated files list starts here
+  IA32/crypto/aes/aesni-x86.nasm
+  IA32/crypto/aes/vpaes-x86.nasm
+  IA32/crypto/modes/ghash-x86.nasm
+  IA32/crypto/sha/sha1-586.nasm
+  IA32/crypto/sha/sha256-586.nasm
+  IA32/crypto/sha/sha512-586.nasm
+  IA32/crypto/x86cpuid.nasm
+  $(OPENSSL_PATH)/crypto/aes/aes_cbc.c
+  $(OPENSSL_PATH)/crypto/aes/aes_cfb.c
+  $(OPENSSL_PATH)/crypto/aes/aes_core.c
+  $(OPENSSL_PATH)/crypto/aes/aes_ige.c
+  $(OPENSSL_PATH)/crypto/aes/aes_misc.c
+  $(OPENSSL_PATH)/crypto/aes/aes_ofb.c
+  $(OPENSSL_PATH)/crypto/aes/aes_wrap.c
+  $(OPENSSL_PATH)/crypto/aria/aria.c
+  $(OPENSSL_PATH)/crypto/asn1/a_bitstr.c
+  $(OPENSSL_PATH)/crypto/asn1/a_d2i_fp.c
+  $(OPENSSL_PATH)/crypto/asn1/a_digest.c
+  $(OPENSSL_PATH)/crypto/asn1/a_dup.c
+  $(OPENSSL_PATH)/crypto/asn1/a_gentm.c
+  $(OPENSSL_PATH)/crypto/asn1/a_i2d_fp.c
+  $(OPENSSL_PATH)/crypto/asn1/a_int.c
+  $(OPENSSL_PATH)/crypto/asn1/a_mbstr.c
+  $(OPENSSL_PATH)/crypto/asn1/a_object.c
+  $(OPENSSL_PATH)/crypto/asn1/a_octet.c
+  $(OPENSSL_PATH)/crypto/asn1/a_print.c
+  $(OPENSSL_PATH)/crypto/asn1/a_sign.c
+  $(OPENSSL_PATH)/crypto/asn1/a_strex.c
+  $(OPENSSL_PATH)/crypto/asn1/a_strnid.c
+  $(OPENSSL_PATH)/crypto/asn1/a_time.c
+  $(OPENSSL_PATH)/crypto/asn1/a_type.c
+  $(OPENSSL_PATH)/crypto/asn1/a_utctm.c
+  $(OPENSSL_PATH)/crypto/asn1/a_utf8.c
+  $(OPENSSL_PATH)/crypto/asn1/a_verify.c
+  $(OPENSSL_PATH)/crypto/asn1/ameth_lib.c
+  $(OPENSSL_PATH)/crypto/asn1/asn1_err.c
+  $(OPENSSL_PATH)/crypto/asn1/asn1_gen.c
+  $(OPENSSL_PATH)/crypto/asn1/asn1_item_list.c
+  $(OPENSSL_PATH)/crypto/asn1/asn1_lib.c
+  $(OPENSSL_PATH)/crypto/asn1/asn1_par.c
+  $(OPENSSL_PATH)/crypto/asn1/asn_mime.c
+  $(OPENSSL_PATH)/crypto/asn1/asn_moid.c
+  $(OPENSSL_PATH)/crypto/asn1/asn_mstbl.c
+  $(OPENSSL_PATH)/crypto/asn1/asn_pack.c
+  $(OPENSSL_PATH)/crypto/asn1/bio_asn1.c
+  $(OPENSSL_PATH)/crypto/asn1/bio_ndef.c
+  $(OPENSSL_PATH)/crypto/asn1/d2i_pr.c
+  $(OPENSSL_PATH)/crypto/asn1/d2i_pu.c
+  

[edk2-devel] [PATCH 2/3] DxeMain accepts all memory at EBS if needed

2022-09-22 Thread Dionna Glaze via groups.io
With the addition of the EfiUnacceptedMemory memory type, it is possible
the EFI-enlightened guests do not themselves support the new memory
type. This commit adds a dynamic Pcd that can be set to enable
unaccepted memory support before ExitBootServices is called.

The expected usage is to set the new Pcd with a protocol that is usable
by bootloaders and directly-booted OSes when they can determine that the
OS does indeed support unaccepted memory.

Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Cc: Ard Biesheuvel 

Signed-off-by: Dionna Glaze 
---
 MdeModulePkg/Core/Dxe/DxeMain.h | 10 +++
 MdeModulePkg/Core/Dxe/DxeMain.inf   |  2 +
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 14 +++-
 MdeModulePkg/Core/Dxe/Mem/Page.c| 87 +
 MdeModulePkg/MdeModulePkg.dec   |  6 ++
 MdeModulePkg/MdeModulePkg.uni   |  6 ++
 OvmfPkg/AmdSev/AmdSevX64.dsc|  1 +
 OvmfPkg/Bhyve/BhyveX64.dsc  |  2 +
 OvmfPkg/CloudHv/CloudHvX64.dsc  |  2 +
 OvmfPkg/IntelTdx/IntelTdxX64.dsc|  2 +
 OvmfPkg/OvmfPkgIa32X64.dsc  |  2 +
 OvmfPkg/OvmfPkgX64.dsc  |  2 +
 OvmfPkg/OvmfXen.dsc |  2 +
 13 files changed, 137 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h
index 815a6b4bd8..ac943c87a3 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.h
+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
@@ -2698,6 +2698,16 @@ CoreInitializeMemoryProtection (
   VOID
   );
 
+/**
+   Accept and convert unaccepted memory to conventional memory if unaccepted
+   memory is not enabled and there is an implementation of MemoryAcceptProtocol
+   installed.
+ **/
+EFI_STATUS
+CoreResolveUnacceptedMemory (
+  VOID
+  );
+
 /**
   Install MemoryAttributesTable on memory allocation.
 
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf 
b/MdeModulePkg/Core/Dxe/DxeMain.inf
index e4bca89577..deb8bb2ba8 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -153,6 +153,7 @@
   gEfiHiiPackageListProtocolGuid## SOMETIMES_PRODUCES
   gEfiSmmBase2ProtocolGuid  ## SOMETIMES_CONSUMES
   gEdkiiPeCoffImageEmulatorProtocolGuid ## SOMETIMES_CONSUMES
+  gEfiMemoryAcceptProtocolGuid  ## SOMETIMES_CONSUMES
 
   # Arch Protocols
   gEfiBdsArchProtocolGuid   ## CONSUMES
@@ -186,6 +187,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask   ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard   ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth   ## 
CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory  ## 
CONSUMES
 
 # [Hob]
 # RESOURCE_DESCRIPTOR   ## CONSUMES
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c 
b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
index 5733f0c8ec..8d1de32fe7 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
@@ -768,13 +768,25 @@ CoreExitBootServices (
   //
   gTimer->SetTimerPeriod (gTimer, 0);
 
+  //
+  // Accept all memory if unaccepted memory isn't enabled.
+  //
+  Status = CoreResolveUnacceptedMemory();
+  if (EFI_ERROR (Status)) {
+//
+// Notify other drivers that ExitBootServices failed
+//
+CoreNotifySignalList ();
+return Status;
+  }
+
   //
   // Terminate memory services if the MapKey matches
   //
   Status = CoreTerminateMemoryMap (MapKey);
   if (EFI_ERROR (Status)) {
 //
-// Notify other drivers that ExitBootServices fail
+// Notify other drivers that ExitBootServices failed
 //
 CoreNotifySignalList ();
 return Status;
diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c
index ffe79dcca9..cbebe62a28 100644
--- a/MdeModulePkg/Core/Dxe/Mem/Page.c
+++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
@@ -9,6 +9,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include "DxeMain.h"
 #include "Imem.h"
 #include "HeapGuard.h"
+#include 
+#include 
 
 //
 // Entry for tracking the memory regions for each memory type to coalesce 
similar memory types
@@ -2118,6 +2120,91 @@ CoreFreePoolPages (
   CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);
 }
 
+EFI_EVENT gExitBootServiceEvent = NULL;
+
+STATIC
+EFI_STATUS
+AcceptAllUnacceptedMemory (
+  IN EFI_MEMORY_ACCEPT_PROTOCOL *AcceptMemory
+  )
+{
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR  *AllDescMap;
+  UINTNNumEntries;
+  UINTNIndex;
+  EFI_STATUS   Status;
+
+  /*
+   * Get a copy of the memory space map to iterate over while
+   * changing the map.
+   */
+  Status = CoreGetMemorySpaceMap (, );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  for (Index = 0; Index < NumEntries; Index++) {
+CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR  *Desc;
+
+Desc = [Index];

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

2022-09-22 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 implementated /
Installed in AmdSevDxe for AMD SEV-SNP memory acceptance.

Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 

Signed-off-by: Sophia Wolf 
---
 OvmfPkg/AmdSevDxe/AmdSevDxe.c | 27 ++
 OvmfPkg/AmdSevDxe/AmdSevDxe.inf   |  3 ++
 OvmfPkg/Include/Library/MemEncryptSevLib.h| 14 
 .../Ia32/MemEncryptSevLib.c   | 17 +
 .../X64/DxeSnpSystemRamValidate.c | 35 +++
 .../X64/PeiSnpSystemRamValidate.c | 17 +
 .../X64/SecSnpSystemRamValidate.c | 18 ++
 7 files changed, 131 insertions(+)

diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c
index 662d3c4ccb..74b82a5814 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,25 @@ STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION  
mSnpBootDxeTable = {
   FixedPcdGet32 (PcdOvmfCpuidSize),
 };
 
+EFI_HANDLE mAmdSevDxeHandle = NULL;
+
+EFI_STATUS
+EFIAPI
+AmdSevMemoryAccept (
+  IN EFI_MEMORY_ACCEPT_PROTOCOL *This,
+  IN EFI_PHYSICAL_ADDRESS StartAddress,
+  IN UINTN Size
+)
+{
+  MemEncryptSnpAcceptPages (StartAddress, Size / SIZE_4KB);
+
+  return EFI_SUCCESS;
+}
+
+EFI_MEMORY_ACCEPT_PROTOCOL  mMemoryAcceptProtocol = {
+  AmdSevMemoryAccept
+};
+
 EFI_STATUS
 EFIAPI
 AmdSevDxeEntryPoint (
@@ -147,6 +167,13 @@ AmdSevDxeEntryPoint (
 }
   }
 
+  Status = gBS->InstallProtocolInterface (,
+  , EFI_NATIVE_INTERFACE,
+  );
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "Install EfiMemoryAcceptProtocol failed.\n"));
+  }
+
   //
   // 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.
diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf
index 9acf860cf2..5abc32 100644
--- a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf
+++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf
@@ -47,6 +47,9 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize
 
+[Protocols]
+  gEfiMemoryAcceptProtocolGuid
+
 [Guids]
   gConfidentialComputingSevSnpBlobGuid
 
diff --git a/OvmfPkg/Include/Library/MemEncryptSevLib.h 
b/OvmfPkg/Include/Library/MemEncryptSevLib.h
index 4fa9c0d700..05ec10471d 100644
--- a/OvmfPkg/Include/Library/MemEncryptSevLib.h
+++ b/OvmfPkg/Include/Library/MemEncryptSevLib.h
@@ -228,4 +228,18 @@ MemEncryptSevSnpPreValidateSystemRam (
   IN UINTN NumPages
   );
 
+/**
+  Accept pages system RAM when SEV-SNP is enabled in the guest VM.
+
+  @param[in]  BaseAddress Base address
+  @param[in]  NumPagesNumber of pages starting from the base 
address
+
+**/
+VOID
+EFIAPI
+MemEncryptSnpAcceptPages (
+  IN PHYSICAL_ADDRESS   BaseAddress,
+  IN UINTN  NumPages
+  );
+
 #endif // _MEM_ENCRYPT_SEV_LIB_H_
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c 
b/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c
index f92299fc77..f0747d792e 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c
@@ -153,3 +153,20 @@ MemEncryptSevSnpPreValidateSystemRam (
 {
   ASSERT (FALSE);
 }
+
+/**
+  Accept pages system RAM when SEV-SNP is enabled in the guest VM.
+
+  @param[in]  BaseAddress Base address
+  @param[in]  NumPagesNumber of pages starting from the base 
address
+
+**/
+VOID
+EFIAPI
+MemEncryptSnpAcceptPages (
+  IN PHYSICAL_ADDRESS   BaseAddress,
+  IN UINTN  NumPages
+  )
+{
+  ASSERT (FALSE);
+}
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c 
b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c
index d3a95e4913..7693e0ca66 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.
@@ -38,3 +39,37 @@ MemEncryptSevSnpPreValidateSystemRam (
   //
   ASSERT (FALSE);
 }
+
+/**
+  Accept pages system RAM when SEV-SNP is enabled in the guest VM.
+
+  @param[in]  BaseAddress Base address
+  @param[in]  NumPagesNumber of pages starting from the base 
address
+
+**/
+VOID
+EFIAPI

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

2022-09-22 Thread Dionna Glaze via groups.io
These three 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.

For unaccepted memory to be enabled, we must know that the booted image
supports the unaccepted memory type. We add a trivial protocol that sets
a dynamic Pcd to true when called in order for the booted image to
signal its support for unaccepted memory. This does not need to be an
OsIndications bit because it does not need to be persisted.

We use the Pcd to disable a new ExitBootServices notification that
accepts all unaccepted memory, removes the unaccepted memory entries in
the memory space map, and then add the same memory ranges back as
conventional memory.

All images that support unaccepted memory must now locate and call this
new ENABLE_UNACCEPTED_MEMORY_PROTOCOL.

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 

Dionna Glaze (3):
  OvmfPkg: Realize EfiMemoryAcceptProtocol in AmdSevDxe
  DxeMain accepts all memory at EBS if needed
  MdeModulePkg: add EnableUnacceptedMemoryProtocol

 MdeModulePkg/Core/Dxe/DxeMain.h   |  32 +
 MdeModulePkg/Core/Dxe/DxeMain.inf |   3 +
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c   |  19 ++-
 MdeModulePkg/Core/Dxe/Mem/Page.c  | 122 ++
 MdeModulePkg/MdeModulePkg.dec |   9 ++
 MdeModulePkg/MdeModulePkg.uni |   6 +
 OvmfPkg/AmdSev/AmdSevX64.dsc  |   1 +
 OvmfPkg/AmdSevDxe/AmdSevDxe.c |  27 
 OvmfPkg/AmdSevDxe/AmdSevDxe.inf   |   3 +
 OvmfPkg/Bhyve/BhyveX64.dsc|   2 +
 OvmfPkg/CloudHv/CloudHvX64.dsc|   2 +
 OvmfPkg/Include/Library/MemEncryptSevLib.h|  14 ++
 OvmfPkg/IntelTdx/IntelTdxX64.dsc  |   2 +
 .../Ia32/MemEncryptSevLib.c   |  17 +++
 .../X64/DxeSnpSystemRamValidate.c |  35 +
 .../X64/PeiSnpSystemRamValidate.c |  17 +++
 .../X64/SecSnpSystemRamValidate.c |  18 +++
 OvmfPkg/OvmfPkgIa32X64.dsc|   2 +
 OvmfPkg/OvmfPkgX64.dsc|   2 +
 OvmfPkg/OvmfXen.dsc   |   2 +
 20 files changed, 334 insertions(+), 1 deletion(-)

-- 
2.37.3.998.g577e59143f-goog



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




[edk2-devel] [PATCH v3] EmbeddedPkg/PrePiMemoryAllocationLib: Add check for space on offset allocation

2022-09-22 Thread Jeff Brasen via groups.io
Update check for enough space to occur prior to alignment offset.

This prevents cases where EfiFreeMemoryTop < EfiFreeMemoryBottom.



Change-Id: I58c5d378523c881a4afc655e7ace4c009130c781

---

 .../MemoryAllocationLib.c | 48 ---

 1 file changed, 21 insertions(+), 27 deletions(-)



diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c 
b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

index 2cc2a71121..08a0add340 100644

--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

@@ -23,41 +23,35 @@ InternalAllocatePages (

   )

 {

   EFI_PEI_HOB_POINTERS  Hob;

-  EFI_PHYSICAL_ADDRESS  Offset;

+  EFI_PHYSICAL_ADDRESS  NewTop;

 

   Hob.Raw = GetHobList ();

 

-  // Check to see if on 4k boundary

-  Offset = Hob.HandoffInformationTable->EfiFreeMemoryTop & 0xFFF;

-  if (Offset != 0) {

-// If not aligned, make the allocation aligned.

-Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset;

-  }

+  NewTop  = Hob.HandoffInformationTable->EfiFreeMemoryTop & 
~(EFI_PHYSICAL_ADDRESS)EFI_PAGE_MASK;

+  NewTop -= Pages * EFI_PAGE_SIZE;

 

   //

   // Verify that there is sufficient memory to satisfy the allocation

   //

-  if (Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages * EFI_PAGE_SIZE) 
+ sizeof (EFI_HOB_MEMORY_ALLOCATION)) < 
Hob.HandoffInformationTable->EfiFreeMemoryBottom) {

-return 0;

-  } else {

-//

-// Update the PHIT to reflect the memory usage

-//

-Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages * EFI_PAGE_SIZE;

-

-// This routine used to create a memory allocation HOB a la PEI, but 
that's not

-// necessary for us.

-

-//

-// Create a memory allocation HOB.

-//

-BuildMemoryAllocationHob (

-  Hob.HandoffInformationTable->EfiFreeMemoryTop,

-  Pages * EFI_PAGE_SIZE,

-  MemoryType

-  );

-return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;

+  if (NewTop < (Hob.HandoffInformationTable->EfiFreeMemoryBottom + sizeof 
(EFI_HOB_MEMORY_ALLOCATION))) {

+return NULL;

   }

+

+  //

+  // Update the PHIT to reflect the memory usage

+  //

+  Hob.HandoffInformationTable->EfiFreeMemoryTop = NewTop;

+

+  //

+  // Create a memory allocation HOB.

+  //

+  BuildMemoryAllocationHob (

+Hob.HandoffInformationTable->EfiFreeMemoryTop,

+Pages * EFI_PAGE_SIZE,

+MemoryType

+);

+

+  return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;

 }

 

 /**

-- 

2.25.1





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




[edk2-devel] [PATCH v5 2/3] DynamicTablesPkg: AML Code generation to add _CPC entries

2022-09-22 Thread Jeff Brasen via groups.io
_CPC entries can describe CPU performance information.

The object is described in ACPI 6.4 s8.4.7.1.

"_CPC (Continuous Performance Control)".



Add AmlCreateCpcNode() helper function to add _CPC entries to an

existing CPU object.



Signed-off-by: Jeff Brasen 

---

 .../Include/Library/AmlLib/AmlLib.h   |  54 ++

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 475 ++

 2 files changed, 529 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 39968660f2..ebaccba811 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -37,6 +37,7 @@

 */

 

 #include 

+#include 

 

 #ifndef AML_HANDLE

 

@@ -1336,6 +1337,59 @@ AmlAddNameIntegerPackage (

   IN AML_OBJECT_NODE_HANDLE  PackageNode

   );

 

+/** Create a _CPC node.

+

+  Creates and optionally adds the following node

+   Name(_CPC, Package()

+   {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer (Resource 
Descriptor)

+NominalPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestPerformance,   // Integer or Buffer (Resource 
Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource Descriptor)

+TimeWindowRegister,  // Buffer (Resource Descriptor)

+CounterWraparoundTime,   // Integer or Buffer (Resource 
Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource Descriptor)

+CPPCEnableRegister   // Buffer (Resource Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer (Resource 
Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource Descriptor)

+ReferencePerformance // Integer or Buffer (Resource 
Descriptor)

+LowestFrequency, // Integer or Buffer (Resource 
Descriptor)

+NominalFrequency // Integer or Buffer (Resource 
Descriptor)

+  })

+

+  If resource buffer is NULL then integer will be used.

+

+  Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control)

+

+  @ingroup CodeGenApis

+

+  @param [in]  CpcInfo   CpcInfo object

+  @param [in]  ParentNodeIf provided, set ParentNode as the parent

+ of the node created.

+  @param [out] NewCpcNodeIf success and provided, contains the 
created node.

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCreateCpcNode (

+  IN  AML_CPC_INFO*CpcInfo,

+  IN  AML_NODE_HANDLE ParentNode   OPTIONAL,

+  OUT AML_OBJECT_NODE_HANDLE  *NewCpcNode   OPTIONAL

+  );

+

 // DEPRECATED APIS

 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES

 

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 5fb39d077b..4dc810c034 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -14,6 +14,7 @@

 #include 

 #include 

 #include 

+#include 

 #include 

 #include 

 #include 

@@ -2850,3 +2851,477 @@ error_handler:

 

   return Status;

 }

+

+/** Adds a register to the package

+

+  @ingroup CodeGenApis

+

+  @param [in]  Register If provided, register that will be added to 
package.

+otherwise NULL register will be added

+  @param [in]  PackageNode  Package to add value to

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+AmlAddRegisterToPackage (

+  IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  *Register OPTIONAL,

+  IN AML_OBJECT_NODE_HANDLE  PackageNode

+  )

+{

+  EFI_STATUS  Status;

+  

[edk2-devel] [PATCH v5 3/3] DynamicTablesPkg: SSDT CPU _CPC generator

2022-09-22 Thread Jeff Brasen via groups.io
Add code to use a token attached to GICC to generate _CPC object on cpus.



Signed-off-by: Jeff Brasen 

---

 .../SsdtCpuTopologyGenerator.c| 133 +-

 1 file changed, 127 insertions(+), 6 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

index 8561f48e1f..22422aef75 100644

--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

@@ -76,6 +76,16 @@ GET_OBJECT_LIST (

   CM_ARM_LPI_INFO

   );

 

+/**

+  This macro expands to a function that retrieves the CPC

+  information from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceArm,

+  EArmObjCpcInfo,

+  CM_ARM_CPC_INFO

+  );

+

 /** Initialize the TokenTable.

 

   One entry should be allocated for each CM_ARM_PROC_HIERARCHY_INFO

@@ -229,6 +239,93 @@ WriteAslName (

   return EFI_SUCCESS;

 }

 

+/** Create and add an _CPC Node to Cpu Node.

+

+  For instance, transform an AML node from:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  }

+

+  To:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  Name(_CPC, Package()

+  {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer 
(Resource Descriptor)

+NominalPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestPerformance,   // Integer or Buffer 
(Resource Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource 
Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource 
Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource 
Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource 
Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource 
Descriptor)

+TimeWindowRegister,  // Buffer (Resource 
Descriptor)

+CounterWraparoundTime,   // Integer or Buffer 
(Resource Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource 
Descriptor)

+CPPCEnableRegister   // Buffer (Resource 
Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer 
(Resource Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource 
Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource 
Descriptor)

+ReferencePerformance // Integer or Buffer 
(Resource Descriptor)

+LowestFrequency, // Integer or Buffer 
(Resource Descriptor)

+NominalFrequency // Integer or Buffer 
(Resource Descriptor)

+  })

+  }

+

+  @param [in]  Generator  The SSDT Cpu Topology generator.

+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager

+  Protocol Interface.

+  @param [in]  ProcHierarchyNodeInfo  CM_ARM_PROC_HIERARCHY_INFO describing

+  the Cpu.

+  @param [in]  Node   CPU Node to which the _CPC node is

+  attached.

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+CreateAmlCpcNode (

+  IN  ACPI_CPU_TOPOLOGY_GENERATOR *Generator,

+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  INCM_ARM_GICC_INFO  *GicCInfo,

+  IN  AML_OBJECT_NODE_HANDLE  *Node

+  )

+{

+  EFI_STATUS   Status;

+  CM_ARM_CPC_INFO  *CpcInfo;

+

+  Status = GetEArmObjCpcInfo (

+ CfgMgrProtocol,

+ GicCInfo->CpcToken,

+ ,

+ NULL

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+return Status;

+  }

+

+  Status = AmlCreateCpcNode (

+ CpcInfo,

+ Node,

+ NULL

+ );

+  ASSERT_EFI_ERROR (Status);

+  return Status;

+}

+

 /** Create and add an _LPI method to Cpu/Cluster Node.

 

   For instance, transform an AML 

[edk2-devel] [PATCH v5 1/3] DynamicTablesPkg: Add CM_ARM_CPC_INFO object

2022-09-22 Thread Jeff Brasen via groups.io
Introduce the CM_ARM_CPC_INFO CmObj in the ArmNameSpaceObjects.

This allows to describe CPC information, as described in ACPI 6.4,

s8.4.7.1 "_CPC (Continuous Performance Control)".



Signed-off-by: Jeff Brasen 

---

 .../Include/ArmNameSpaceObjects.h |  60 ++---

 DynamicTablesPkg/Include/Library/AmlCpcInfo.h | 124 ++

 .../ConfigurationManagerObjectParser.c| 115 +---

 3 files changed, 265 insertions(+), 34 deletions(-)

 create mode 100644 DynamicTablesPkg/Include/Library/AmlCpcInfo.h



diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

index 102e0f96be..ea5bf81070 100644

--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

@@ -14,6 +14,7 @@

 #define ARM_NAMESPACE_OBJECTS_H_

 

 #include 

+#include 

 

 #pragma pack(1)

 

@@ -63,6 +64,7 @@ typedef enum ArmObjectID {

   EArmObjPciInterruptMapInfo,  ///< 39 - Pci Interrupt Map Info

   EArmObjRmr,  ///< 40 - Reserved Memory Range Node

   EArmObjMemoryRangeDescriptor,///< 41 - Memory Range Descriptor

+  EArmObjCpcInfo,  ///< 42 - Continuous Performance 
Control Info

   EArmObjMax

 } EARM_OBJECT_ID;

 

@@ -97,99 +99,105 @@ typedef struct CmArmPowerManagementProfileInfo {

 */

 typedef struct CmArmGicCInfo {

   /// The GIC CPU Interface number.

-  UINT32CPUInterfaceNumber;

+  UINT32 CPUInterfaceNumber;

 

   /** The ACPI Processor UID. This must match the

   _UID of the CPU Device object information described

   in the DSDT/SSDT for the CPU.

   */

-  UINT32AcpiProcessorUid;

+  UINT32 AcpiProcessorUid;

 

   /** The flags field as described by the GICC structure

   in the ACPI Specification.

   */

-  UINT32Flags;

+  UINT32 Flags;

 

   /** The parking protocol version field as described by

 the GICC structure in the ACPI Specification.

   */

-  UINT32ParkingProtocolVersion;

+  UINT32 ParkingProtocolVersion;

 

   /** The Performance Interrupt field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT32PerformanceInterruptGsiv;

+  UINT32 PerformanceInterruptGsiv;

 

   /** The CPU Parked address field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT64ParkedAddress;

+  UINT64 ParkedAddress;

 

   /** The base address for the GIC CPU Interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64PhysicalBaseAddress;

+  UINT64 PhysicalBaseAddress;

 

   /** The base address for GICV interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICV;

+  UINT64 GICV;

 

   /** The base address for GICH interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICH;

+  UINT64 GICH;

 

   /** The GICV maintenance interrupt

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT32VGICMaintenanceInterrupt;

+  UINT32 VGICMaintenanceInterrupt;

 

   /** The base address for GICR interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICRBaseAddress;

+  UINT64 GICRBaseAddress;

 

   /** The MPIDR for the CPU

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64MPIDR;

+  UINT64 MPIDR;

 

   /** The Processor Power Efficiency class

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT8 ProcessorPowerEfficiencyClass;

+  UINT8  ProcessorPowerEfficiencyClass;

 

   /** Statistical Profiling Extension buffer overflow GSIV. Zero if

   unsupported by this processor. This field was introduced in

   ACPI 6.3 (MADT revision 5) and is therefore ignored when

   generating MADT revision 4 or lower.

   */

-  UINT16SpeOverflowInterrupt;

+  UINT16 SpeOverflowInterrupt;

 

   /** The proximity domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ProximityDomain;

+  UINT32 ProximityDomain;

 

   /** The clock domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ClockDomain;

+  UINT32 ClockDomain;

 

   /** The GICC Affinity flags field as described by the GICC Affinity structure

   in the SRAT table.

   */

-  UINT32AffinityFlags;

+  UINT32 AffinityFlags;

+

+  /** Optional field: Reference Token for the Cpc info of this 

[edk2-devel] [PATCH v5 0/3] DynamicTablesPkg: _CPC support

2022-09-22 Thread Jeff Brasen via groups.io
Add generator for creating the _CPC object for CPU nodes.

If viewing this review by a pull request is helpful one exists here:
https://github.com/NVIDIA/edk2/pull/12

Change Log:
v1 - Initial Revision
v2 - Added revision to object, improved error handling, changed to ACPI 6.4 
structures.
v3 - Minor review feedback
v4 - Convert CpcInfo to structure and use that for APIs
v5 - Cleanup parameter checks, add token to parser

Jeff Brasen (3):
  DynamicTablesPkg: Add CM_ARM_CPC_INFO object
  DynamicTablesPkg: AML Code generation to add _CPC entries
  DynamicTablesPkg: SSDT CPU _CPC generator

 .../Include/ArmNameSpaceObjects.h |  60 ++-
 DynamicTablesPkg/Include/Library/AmlCpcInfo.h | 124 +
 .../Include/Library/AmlLib/AmlLib.h   |  54 ++
 .../SsdtCpuTopologyGenerator.c| 133 -
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 475 ++
 .../ConfigurationManagerObjectParser.c| 115 -
 6 files changed, 921 insertions(+), 40 deletions(-)
 create mode 100644 DynamicTablesPkg/Include/Library/AmlCpcInfo.h

-- 
2.25.1



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




Re: [edk2-devel] [PATCH 00/14] Introduce Lazy-accept for Tdx guest

2022-09-22 Thread Dionna Glaze via groups.io
I have a working stack with proposal 5. I was using a version of grub that
didn't use Linux's EFI handover protocol, and I wasn't signalling the
unaccepted memory behavior at the right place (before EBS).

Many thanks to everyone who contributed to this discussion and brought some
creative ideas to the table. Thanks especially to Ard, for multiple
consultations.
With proposal 5, we won't need any control plane annotation for disabling
unaccepted memory, and users will always get safe behavior.

I'll have patches out to OVMF (based on this patch series) and to Linux
shortly.

On Mon, Aug 15, 2022 at 11:47 PM Gerd Hoffmann  wrote:

>   Hi,
>
> > 3.  fw_cfg
> >   - Add new fw_cfg item (opt/ovmf/AcceptAllMemory) to indicate how to
> handle the unaccepted memory.
> >   > True - accept all the memory
> >   > False - don't accept the memory
> >   > Default - It allows the firmware to choose depending on various
> factors.
> >   - Glaze has submit the patch
> https://lore.kernel.org/all/20220620223300.1555849-1-dionnagl...@google.com/
>
> > Proposal 3) only works for QEMU because of fw_cfg.
>
> Well, while that is true for the patch at hand it doesn't have to be
> that way.  We can also simply store the config option in a EFI variable.
> Wire up a HII configuration so it can be changed via firmware setup.
> Allow setting the EFI variable from fw_cfg, so qemu users can set that
> on the qemu command line too (and possibly have similar mechanisms for
> other hypervisors, hello cloudhv).
>
> > I wonder if lazy-accept feature can be split into 2 stages.
> > 1. In first stage there is a config option to indicate if lazy-accept is
> enabled or not.
> > 2. In the second stage the automatic negotiation is introduced so that
> lazy-accept is enabled or not by the negotiation result.
>
> Absolutely.  That is one of the reasons why I suggested to have a
> true/false/default config option instead of just true/false.
>
> When the first stage is implemented "default" behavior would be fixed
> (either hard-coded or a compile-time option).
>
> When the second stage is implemented "default" behavior would be
> dynamic, depending on the negotiation result.
>
> take care,
>   Gerd
>
>

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


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




Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes

2022-09-22 Thread Michael D Kinney
You can add the following to disable all UARTs

-serial none

That gives me a graphics only console.

There is something strange with the Boot Maintenance Manager for OVMF.
The console settings are not preserved across a reset.  They are 
preserved for the current boot.  If you go to the shell after console
changes, then only the currently configured consoles are active.


Mike

> -Original Message-
> From: Konstantin Aladyshev 
> Sent: Thursday, September 22, 2022 9:50 AM
> To: Kinney, Michael D 
> Cc: devel@edk2.groups.io; Gao, Liming ; Wang, Jian 
> J ; Ni, Ray
> 
> Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes
> 
> Yes, I use QEMU to run OVMF in Linux (actually in WSL). Here is a
> command that I use for launch:
> ```
> qemu-system-x86_64 \
>   -drive if=pflash,format=raw,file=Build/OvmfX64/RELEASE_GCC5/FV/OVMF.fd \
>   -drive format=raw,file=fat:rw:~/UEFI_disk
>   -vnc :1
> ```
> So nothing explicit about the UARTs.
> 
> Best regards,
> Konstantin Aladyshev
> 
> On Thu, Sep 22, 2022 at 7:12 PM Kinney, Michael D
>  wrote:
> >
> > If the goal is to support a mix of graphical and serial consoles both with 
> > high text resolutions, then your patch is
> appropriate.
> >
> > It looks like you are observing some unexpected limitations in the OVMF 
> > console management.
> >
> > Perhaps the OVMF maintainers can provide some advice on how to configure 
> > OVMF with serial consoles disabled.
> >
> > Are you using QEMU to run OVMF?  Are you including UARTs in QEMU launch?
> >
> > Mike
> >
> > > -Original Message-
> > > From: Konstantin Aladyshev 
> > > Sent: Thursday, September 22, 2022 1:23 AM
> > > To: Kinney, Michael D 
> > > Cc: devel@edk2.groups.io; Gao, Liming ; Wang, 
> > > Jian J ; Ni, Ray
> > > 
> > > Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes
> > >
> > > > Is the issue that you are trying to solve supporting larger serial 
> > > > console modes or just wanting to use the largest
> possible
> > > text mode at a given graphics resolution?
> > >
> > > I spotted this issue when I wanted to use the largest possible text
> > > mode in UEFI shell at high graphics resolutions. Is it not enough
> > > reason for this commit?
> > >
> > > > The other way to get full screen text on the graphical console is to 
> > > > disable the serial console in the Boot Maintenance
> > > Manager.
> > >
> > > Can you please elaborate this? I've tried to disable UART in "Boot
> > > Maintenance Manager -> Console Options" like this:
> > > ```
> > > Console Input Device Select:
> > > PciRoot(0x0)/Pci(0x1,0x0)/Acpi(PNP0303,0x0) [X]
> > > PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]
> > >
> > > Console Output Device Select:
> > > PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80010100)  [X]
> > > PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]
> > >
> > > Console Standard Error Device Select:
> > > PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80010100)  [X]
> > > PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]
> > > ```
> > > But after reset, the console is 80x25 and all UART options are checked 
> > > again.
> > >
> > > Also there is a menu "Boot Maintenance Manager -> Console Options ->
> > > Console Output Mode Select" that has "Set Console Output Mode", and it
> > > is always "80x25" without any options for me.
> > >
> > > Best regards,
> > > Konstantin Aladyshev
> > >
> > > On Wed, Sep 21, 2022 at 7:28 PM Kinney, Michael D
> > >  wrote:
> > > >
> > > > The other way to get full screen text on graphical console is to 
> > > > disable the serial console
> > > > in the Boot Maintenance Manager.
> > > >
> > > > If the serial console is disabled then ConSplitterDxe will only see the 
> > > > text modes supported
> > > > by GraphicsConsoleDxe which will include these higher text modes.
> > > >
> > > > Is the issue that you are trying to solve supporting larger serial 
> > > > console modes or just
> > > > wanting to use the largest possible text mode at a given graphics 
> > > > resolution?
> > > >
> > > > Mike
> > > >
> > > > > -Original Message-
> > > > > From: devel@edk2.groups.io  On Behalf Of 
> > > > > Konstantin Aladyshev
> > > > > Sent: Wednesday, September 21, 2022 1:24 AM
> > > > > To: Kinney, Michael D 
> > > > > Cc: devel@edk2.groups.io; Gao, Liming ; 
> > > > > Wang, Jian J ; Ni, Ray
> > > > > 
> > > > > Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes
> > > > >
> > > > > I have tested it in the following way:
> > > > > - launch OVMF in Linux and connect with vnc
> > > > > - change resolution via the form browser (Device Manager -> OVMF
> > > > > Platform Configuration) from the default 640x480 to the 1920x1080
> > > > > - "reset"
> > > > > - after the reset the system will boot to the 1920x1080 resolution and
> > > > > text mode 80x25
> > > > > - check "mode" command output
> > > > >
> > > > > Before the commit 

Re: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code coverage support for GCC

2022-09-22 Thread Michael D Kinney
Gua,

Also for the pip modules, do we want to add them to edk2/pip-requirements.txt so
default config for local development includes these additional components that
can be used when running unit tests based on edk2/UnitTestFrameworkPkg?

Thanks,

Mike

> -Original Message-
> From: Guo, Gua 
> Sent: Thursday, September 22, 2022 10:17 AM
> To: Kinney, Michael D ; devel@edk2.groups.io
> Cc: Sean Brogan 
> Subject: RE: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code 
> coverage support for GCC
> 
> Is it installed by default in Azure Pipelines Windows agents?
> Ans: I think no.
> 
> For local developer use cases in Windows, don’t we need to make sure stuart 
> tools install OpenCppCoverage as an external
> dependency?
> Ans: I don't find a good way to auto download and auto install 
> OpenCppCoverage, so choose below way to support it.
> 
> So currently use CODE_COVERAGE=TRUE to optional enable it, if want to enable 
> it have below requirement.
> 
> For VS2019
>   Step1. Download and install 
> https://github.com/OpenCppCoverage/OpenCppCoverage/tags
>   Step2. pip install pycobertura
>   Step3. stuart_ci_build -c .pytool/CISettings.py -a X64 
> TOOL_CHAIN_TAG=VS2019 -p MdePkg CODE_COVERAGE=TRUE CC_HTML=TRUE
> 
> For GCC5
>   Step1. sudo apt-get install -y lcov
>   Step2. pip install lcov_cobertura
>   Step3. pip install pycobertura
>   Step4. stuart_ci_build -c .pytool/CISettings.py -a X64 TOOL_CHAIN_TAG=GCC5 
> -p MdePkg CODE_COVERAGE=TRUE CC_HTML=TRUE
> 
> Thanks,
> Gua
> 
> -Original Message-
> From: Kinney, Michael D 
> Sent: Friday, September 23, 2022 12:15 AM
> To: Guo, Gua ; devel@edk2.groups.io
> Cc: Sean Brogan 
> Subject: RE: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code 
> coverage support for GCC
> 
> This change adds a dependency on OpenCppCoverage.
> 
> However, I do not see any updates to make sure OpenCppCovergae is installed.
> Is it installed by default in Azure Pipelines Windows agents?
> 
> For local developer use cases in Windows, don’t we need to make sure stuart 
> tools install OpenCppCoverage as an external
> dependency?
> 
> Thanks,
> 
> Mike
> 
> 
> > -Original Message-
> > From: Guo, Gua 
> > Sent: Thursday, September 22, 2022 12:13 AM
> > To: devel@edk2.groups.io; Guo, Gua 
> > Cc: Kinney, Michael D ; Sean Brogan
> > 
> > Subject: RE: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add
> > code coverage support for GCC
> >
> > It's PR based on the patch. Have any concern, please also share for me.
> > https://github.com/tianocore/edk2/pull/3349
> >
> > Thanks,
> > Gua
> >
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Guo,
> > Gua
> > Sent: Thursday, September 22, 2022 3:09 PM
> > To: devel@edk2.groups.io
> > Cc: Guo, Gua 
> > Subject: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code
> > coverage support for GCC
> >
> > From: Gua Guo 
> >
> > V1: Add coverage option for GCC
> > V2: Add ReadMe.md for how to generate coverage report
> > V3: Add VS2019 and GCC code coverage support
> >
> > Gua Guo (2):
> >   UnitTestFrameworkPkg: Add code coverage support for GCC
> >   BaseTools/Plugin: Add coverage support for Unit Test
> >
> >  .../HostBasedUnitTestRunner.py| 124 ++
> >  UnitTestFrameworkPkg/ReadMe.md|  42 +-
> >  .../UnitTestFrameworkPkg.ci.yaml  |   2 +
> >  .../UnitTestFrameworkPkgHost.dsc.inc  |   3 +-
> >  4 files changed, 167 insertions(+), 4 deletions(-)
> >
> > --
> > 2.31.1.windows.1
> >
> >
> >
> > 
> >



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




Re: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code coverage support for GCC

2022-09-22 Thread Michael D Kinney
Gua,

You may be able to use chocolatey to install opencppcoverage:

https://community.chocolatey.org/packages/opencppcoverage

We have used it for some other dependencies such as QEMU:


https://github.com/tianocore/edk2/blob/b328bb54c6e5510bc687302e4b717694bd441891/OvmfPkg/PlatformCI/.azurepipelines/Windows-VS2019.yml#L137

We also have the option of putting it in a nuget feed.

Mike


> -Original Message-
> From: Guo, Gua 
> Sent: Thursday, September 22, 2022 10:17 AM
> To: Kinney, Michael D ; devel@edk2.groups.io
> Cc: Sean Brogan 
> Subject: RE: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code 
> coverage support for GCC
> 
> Is it installed by default in Azure Pipelines Windows agents?
> Ans: I think no.
> 
> For local developer use cases in Windows, don’t we need to make sure stuart 
> tools install OpenCppCoverage as an external
> dependency?
> Ans: I don't find a good way to auto download and auto install 
> OpenCppCoverage, so choose below way to support it.
> 
> So currently use CODE_COVERAGE=TRUE to optional enable it, if want to enable 
> it have below requirement.
> 
> For VS2019
>   Step1. Download and install 
> https://github.com/OpenCppCoverage/OpenCppCoverage/tags
>   Step2. pip install pycobertura
>   Step3. stuart_ci_build -c .pytool/CISettings.py -a X64 
> TOOL_CHAIN_TAG=VS2019 -p MdePkg CODE_COVERAGE=TRUE CC_HTML=TRUE
> 
> For GCC5
>   Step1. sudo apt-get install -y lcov
>   Step2. pip install lcov_cobertura
>   Step3. pip install pycobertura
>   Step4. stuart_ci_build -c .pytool/CISettings.py -a X64 TOOL_CHAIN_TAG=GCC5 
> -p MdePkg CODE_COVERAGE=TRUE CC_HTML=TRUE
> 
> Thanks,
> Gua
> 
> -Original Message-
> From: Kinney, Michael D 
> Sent: Friday, September 23, 2022 12:15 AM
> To: Guo, Gua ; devel@edk2.groups.io
> Cc: Sean Brogan 
> Subject: RE: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code 
> coverage support for GCC
> 
> This change adds a dependency on OpenCppCoverage.
> 
> However, I do not see any updates to make sure OpenCppCovergae is installed.
> Is it installed by default in Azure Pipelines Windows agents?
> 
> For local developer use cases in Windows, don’t we need to make sure stuart 
> tools install OpenCppCoverage as an external
> dependency?
> 
> Thanks,
> 
> Mike
> 
> 
> > -Original Message-
> > From: Guo, Gua 
> > Sent: Thursday, September 22, 2022 12:13 AM
> > To: devel@edk2.groups.io; Guo, Gua 
> > Cc: Kinney, Michael D ; Sean Brogan
> > 
> > Subject: RE: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add
> > code coverage support for GCC
> >
> > It's PR based on the patch. Have any concern, please also share for me.
> > https://github.com/tianocore/edk2/pull/3349
> >
> > Thanks,
> > Gua
> >
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Guo,
> > Gua
> > Sent: Thursday, September 22, 2022 3:09 PM
> > To: devel@edk2.groups.io
> > Cc: Guo, Gua 
> > Subject: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code
> > coverage support for GCC
> >
> > From: Gua Guo 
> >
> > V1: Add coverage option for GCC
> > V2: Add ReadMe.md for how to generate coverage report
> > V3: Add VS2019 and GCC code coverage support
> >
> > Gua Guo (2):
> >   UnitTestFrameworkPkg: Add code coverage support for GCC
> >   BaseTools/Plugin: Add coverage support for Unit Test
> >
> >  .../HostBasedUnitTestRunner.py| 124 ++
> >  UnitTestFrameworkPkg/ReadMe.md|  42 +-
> >  .../UnitTestFrameworkPkg.ci.yaml  |   2 +
> >  .../UnitTestFrameworkPkgHost.dsc.inc  |   3 +-
> >  4 files changed, 167 insertions(+), 4 deletions(-)
> >
> > --
> > 2.31.1.windows.1
> >
> >
> >
> > 
> >



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




Re: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code coverage support for GCC

2022-09-22 Thread Guo, Gua
Is it installed by default in Azure Pipelines Windows agents?
Ans: I think no.

For local developer use cases in Windows, don’t we need to make sure stuart 
tools install OpenCppCoverage as an external dependency?
Ans: I don't find a good way to auto download and auto install OpenCppCoverage, 
so choose below way to support it.

So currently use CODE_COVERAGE=TRUE to optional enable it, if want to enable it 
have below requirement.

For VS2019
  Step1. Download and install 
https://github.com/OpenCppCoverage/OpenCppCoverage/tags
  Step2. pip install pycobertura
  Step3. stuart_ci_build -c .pytool/CISettings.py -a X64 TOOL_CHAIN_TAG=VS2019 
-p MdePkg CODE_COVERAGE=TRUE CC_HTML=TRUE

For GCC5
  Step1. sudo apt-get install -y lcov
  Step2. pip install lcov_cobertura
  Step3. pip install pycobertura
  Step4. stuart_ci_build -c .pytool/CISettings.py -a X64 TOOL_CHAIN_TAG=GCC5 -p 
MdePkg CODE_COVERAGE=TRUE CC_HTML=TRUE

Thanks,
Gua

-Original Message-
From: Kinney, Michael D  
Sent: Friday, September 23, 2022 12:15 AM
To: Guo, Gua ; devel@edk2.groups.io
Cc: Sean Brogan 
Subject: RE: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code 
coverage support for GCC

This change adds a dependency on OpenCppCoverage.

However, I do not see any updates to make sure OpenCppCovergae is installed.
Is it installed by default in Azure Pipelines Windows agents?

For local developer use cases in Windows, don’t we need to make sure stuart 
tools install OpenCppCoverage as an external dependency?

Thanks,

Mike


> -Original Message-
> From: Guo, Gua 
> Sent: Thursday, September 22, 2022 12:13 AM
> To: devel@edk2.groups.io; Guo, Gua 
> Cc: Kinney, Michael D ; Sean Brogan 
> 
> Subject: RE: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add 
> code coverage support for GCC
> 
> It's PR based on the patch. Have any concern, please also share for me.
> https://github.com/tianocore/edk2/pull/3349
> 
> Thanks,
> Gua
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Guo, 
> Gua
> Sent: Thursday, September 22, 2022 3:09 PM
> To: devel@edk2.groups.io
> Cc: Guo, Gua 
> Subject: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code 
> coverage support for GCC
> 
> From: Gua Guo 
> 
> V1: Add coverage option for GCC
> V2: Add ReadMe.md for how to generate coverage report
> V3: Add VS2019 and GCC code coverage support
> 
> Gua Guo (2):
>   UnitTestFrameworkPkg: Add code coverage support for GCC
>   BaseTools/Plugin: Add coverage support for Unit Test
> 
>  .../HostBasedUnitTestRunner.py| 124 ++
>  UnitTestFrameworkPkg/ReadMe.md|  42 +-
>  .../UnitTestFrameworkPkg.ci.yaml  |   2 +
>  .../UnitTestFrameworkPkgHost.dsc.inc  |   3 +-
>  4 files changed, 167 insertions(+), 4 deletions(-)
> 
> --
> 2.31.1.windows.1
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes

2022-09-22 Thread Konstantin Aladyshev
Yes, I use QEMU to run OVMF in Linux (actually in WSL). Here is a
command that I use for launch:
```
qemu-system-x86_64 \
  -drive if=pflash,format=raw,file=Build/OvmfX64/RELEASE_GCC5/FV/OVMF.fd \
  -drive format=raw,file=fat:rw:~/UEFI_disk
  -vnc :1
```
So nothing explicit about the UARTs.

Best regards,
Konstantin Aladyshev

On Thu, Sep 22, 2022 at 7:12 PM Kinney, Michael D
 wrote:
>
> If the goal is to support a mix of graphical and serial consoles both with 
> high text resolutions, then your patch is appropriate.
>
> It looks like you are observing some unexpected limitations in the OVMF 
> console management.
>
> Perhaps the OVMF maintainers can provide some advice on how to configure OVMF 
> with serial consoles disabled.
>
> Are you using QEMU to run OVMF?  Are you including UARTs in QEMU launch?
>
> Mike
>
> > -Original Message-
> > From: Konstantin Aladyshev 
> > Sent: Thursday, September 22, 2022 1:23 AM
> > To: Kinney, Michael D 
> > Cc: devel@edk2.groups.io; Gao, Liming ; Wang, 
> > Jian J ; Ni, Ray
> > 
> > Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes
> >
> > > Is the issue that you are trying to solve supporting larger serial 
> > > console modes or just wanting to use the largest possible
> > text mode at a given graphics resolution?
> >
> > I spotted this issue when I wanted to use the largest possible text
> > mode in UEFI shell at high graphics resolutions. Is it not enough
> > reason for this commit?
> >
> > > The other way to get full screen text on the graphical console is to 
> > > disable the serial console in the Boot Maintenance
> > Manager.
> >
> > Can you please elaborate this? I've tried to disable UART in "Boot
> > Maintenance Manager -> Console Options" like this:
> > ```
> > Console Input Device Select:
> > PciRoot(0x0)/Pci(0x1,0x0)/Acpi(PNP0303,0x0) [X]
> > PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]
> >
> > Console Output Device Select:
> > PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80010100)  [X]
> > PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]
> >
> > Console Standard Error Device Select:
> > PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80010100)  [X]
> > PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]
> > ```
> > But after reset, the console is 80x25 and all UART options are checked 
> > again.
> >
> > Also there is a menu "Boot Maintenance Manager -> Console Options ->
> > Console Output Mode Select" that has "Set Console Output Mode", and it
> > is always "80x25" without any options for me.
> >
> > Best regards,
> > Konstantin Aladyshev
> >
> > On Wed, Sep 21, 2022 at 7:28 PM Kinney, Michael D
> >  wrote:
> > >
> > > The other way to get full screen text on graphical console is to disable 
> > > the serial console
> > > in the Boot Maintenance Manager.
> > >
> > > If the serial console is disabled then ConSplitterDxe will only see the 
> > > text modes supported
> > > by GraphicsConsoleDxe which will include these higher text modes.
> > >
> > > Is the issue that you are trying to solve supporting larger serial 
> > > console modes or just
> > > wanting to use the largest possible text mode at a given graphics 
> > > resolution?
> > >
> > > Mike
> > >
> > > > -Original Message-
> > > > From: devel@edk2.groups.io  On Behalf Of 
> > > > Konstantin Aladyshev
> > > > Sent: Wednesday, September 21, 2022 1:24 AM
> > > > To: Kinney, Michael D 
> > > > Cc: devel@edk2.groups.io; Gao, Liming ; Wang, 
> > > > Jian J ; Ni, Ray
> > > > 
> > > > Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes
> > > >
> > > > I have tested it in the following way:
> > > > - launch OVMF in Linux and connect with vnc
> > > > - change resolution via the form browser (Device Manager -> OVMF
> > > > Platform Configuration) from the default 640x480 to the 1920x1080
> > > > - "reset"
> > > > - after the reset the system will boot to the 1920x1080 resolution and
> > > > text mode 80x25
> > > > - check "mode" command output
> > > >
> > > > Before the commit this command displays only these modes:
> > > > ```
> > > > Shell> mode
> > > > Available modes for console output device.
> > > >   Col80 Row25  *
> > > >   Col80 Row50
> > > >   Col   100 Row31
> > > > ```
> > > > But with this commit the high resolution modes are present in the 
> > > > output:
> > > > ```
> > > > Shell> mode
> > > > Available modes for console output device.
> > > >   Col80 Row25  *
> > > >   Col80 Row50
> > > >   Col   100 Row31
> > > >   Col   128 Row40
> > > >   Col   160 Row42
> > > >   Col   240 Row56
> > > > ```
> > > > And in my case setting the appropriate "mode 240 56" at runtime works 
> > > > just fine:
> > > > ```
> > > > Shell> mode 240 56
> > > > ```
> > > > After that the text output starts using the full screen.
> > > >
> > > > Best regards,
> > > > Konstantin Aladyshev
> > > >
> > > > On 

Re: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code coverage support for GCC

2022-09-22 Thread Michael D Kinney
This change adds a dependency on OpenCppCoverage.

However, I do not see any updates to make sure OpenCppCovergae is installed.
Is it installed by default in Azure Pipelines Windows agents?

For local developer use cases in Windows, don’t we need to make sure stuart 
tools
install OpenCppCoverage as an external dependency?

Thanks,

Mike


> -Original Message-
> From: Guo, Gua 
> Sent: Thursday, September 22, 2022 12:13 AM
> To: devel@edk2.groups.io; Guo, Gua 
> Cc: Kinney, Michael D ; Sean Brogan 
> 
> Subject: RE: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code 
> coverage support for GCC
> 
> It's PR based on the patch. Have any concern, please also share for me.
> https://github.com/tianocore/edk2/pull/3349
> 
> Thanks,
> Gua
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Guo, Gua
> Sent: Thursday, September 22, 2022 3:09 PM
> To: devel@edk2.groups.io
> Cc: Guo, Gua 
> Subject: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code coverage 
> support for GCC
> 
> From: Gua Guo 
> 
> V1: Add coverage option for GCC
> V2: Add ReadMe.md for how to generate coverage report
> V3: Add VS2019 and GCC code coverage support
> 
> Gua Guo (2):
>   UnitTestFrameworkPkg: Add code coverage support for GCC
>   BaseTools/Plugin: Add coverage support for Unit Test
> 
>  .../HostBasedUnitTestRunner.py| 124 ++
>  UnitTestFrameworkPkg/ReadMe.md|  42 +-
>  .../UnitTestFrameworkPkg.ci.yaml  |   2 +
>  .../UnitTestFrameworkPkgHost.dsc.inc  |   3 +-
>  4 files changed, 167 insertions(+), 4 deletions(-)
> 
> --
> 2.31.1.windows.1
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes

2022-09-22 Thread Michael D Kinney
If the goal is to support a mix of graphical and serial consoles both with high 
text resolutions, then your patch is appropriate.

It looks like you are observing some unexpected limitations in the OVMF console 
management.

Perhaps the OVMF maintainers can provide some advice on how to configure OVMF 
with serial consoles disabled.

Are you using QEMU to run OVMF?  Are you including UARTs in QEMU launch?

Mike

> -Original Message-
> From: Konstantin Aladyshev 
> Sent: Thursday, September 22, 2022 1:23 AM
> To: Kinney, Michael D 
> Cc: devel@edk2.groups.io; Gao, Liming ; Wang, Jian 
> J ; Ni, Ray
> 
> Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes
> 
> > Is the issue that you are trying to solve supporting larger serial console 
> > modes or just wanting to use the largest possible
> text mode at a given graphics resolution?
> 
> I spotted this issue when I wanted to use the largest possible text
> mode in UEFI shell at high graphics resolutions. Is it not enough
> reason for this commit?
> 
> > The other way to get full screen text on the graphical console is to 
> > disable the serial console in the Boot Maintenance
> Manager.
> 
> Can you please elaborate this? I've tried to disable UART in "Boot
> Maintenance Manager -> Console Options" like this:
> ```
> Console Input Device Select:
> PciRoot(0x0)/Pci(0x1,0x0)/Acpi(PNP0303,0x0) [X]
> PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]
> 
> Console Output Device Select:
> PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80010100)  [X]
> PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]
> 
> Console Standard Error Device Select:
> PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80010100)  [X]
> PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]
> ```
> But after reset, the console is 80x25 and all UART options are checked again.
> 
> Also there is a menu "Boot Maintenance Manager -> Console Options ->
> Console Output Mode Select" that has "Set Console Output Mode", and it
> is always "80x25" without any options for me.
> 
> Best regards,
> Konstantin Aladyshev
> 
> On Wed, Sep 21, 2022 at 7:28 PM Kinney, Michael D
>  wrote:
> >
> > The other way to get full screen text on graphical console is to disable 
> > the serial console
> > in the Boot Maintenance Manager.
> >
> > If the serial console is disabled then ConSplitterDxe will only see the 
> > text modes supported
> > by GraphicsConsoleDxe which will include these higher text modes.
> >
> > Is the issue that you are trying to solve supporting larger serial console 
> > modes or just
> > wanting to use the largest possible text mode at a given graphics 
> > resolution?
> >
> > Mike
> >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of Konstantin 
> > > Aladyshev
> > > Sent: Wednesday, September 21, 2022 1:24 AM
> > > To: Kinney, Michael D 
> > > Cc: devel@edk2.groups.io; Gao, Liming ; Wang, 
> > > Jian J ; Ni, Ray
> > > 
> > > Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes
> > >
> > > I have tested it in the following way:
> > > - launch OVMF in Linux and connect with vnc
> > > - change resolution via the form browser (Device Manager -> OVMF
> > > Platform Configuration) from the default 640x480 to the 1920x1080
> > > - "reset"
> > > - after the reset the system will boot to the 1920x1080 resolution and
> > > text mode 80x25
> > > - check "mode" command output
> > >
> > > Before the commit this command displays only these modes:
> > > ```
> > > Shell> mode
> > > Available modes for console output device.
> > >   Col80 Row25  *
> > >   Col80 Row50
> > >   Col   100 Row31
> > > ```
> > > But with this commit the high resolution modes are present in the output:
> > > ```
> > > Shell> mode
> > > Available modes for console output device.
> > >   Col80 Row25  *
> > >   Col80 Row50
> > >   Col   100 Row31
> > >   Col   128 Row40
> > >   Col   160 Row42
> > >   Col   240 Row56
> > > ```
> > > And in my case setting the appropriate "mode 240 56" at runtime works 
> > > just fine:
> > > ```
> > > Shell> mode 240 56
> > > ```
> > > After that the text output starts using the full screen.
> > >
> > > Best regards,
> > > Konstantin Aladyshev
> > >
> > > On Wed, Sep 21, 2022 at 4:46 AM Kinney, Michael D
> > >  wrote:
> > > >
> > > > Tera Term works.
> > > >
> > > > Mike
> > > >
> > > > > -Original Message-
> > > > > From: devel@edk2.groups.io  On Behalf Of 
> > > > > gaoliming via groups.io
> > > > > Sent: Tuesday, September 20, 2022 6:26 PM
> > > > > To: Kinney, Michael D ; 
> > > > > devel@edk2.groups.io; aladyshe...@gmail.com
> > > > > Cc: Wang, Jian J ; Ni, Ray 
> > > > > Subject: 回复: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes
> > > > >
> > > > > Konstantin:
> > > > >   Do you try the terminal software (such as Putty) to display the 
> > > > > text 

Re: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support

2022-09-22 Thread yi1 li
Hi Mike,
I have did some POC that seems existed structured PCD is hard to control binary 
size, 
Here is the previous discussion for reference.
https://bugzilla.tianocore.org/show_bug.cgi?id=3679
https://edk2.groups.io/g/devel/topic/86257810#81814
https://bugzilla.tianocore.org/show_bug.cgi?id=1446

Anyway EC is an important feature which consumed by vary modern security 
features such WPA3 , SPDM, TLS1.3 etc.
Hope it can be added to edk2, and I am glad to take the code and test work if 
there are other ways to control the size.

Thanks,
Yi

-Original Message-
From: Kinney, Michael D  
Sent: Thursday, September 22, 2022 11:56 AM
To: Li, Yi1 ; devel@edk2.groups.io; Kishore, Shelly 

Cc: Yao, Jiewen ; Wang, Jian J ; 
Lu, Xiaoyu1 ; Jiang, Guomin 
Subject: RE: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support

That change to OpensslLib.inf should not have been done either.

Looks like this EC feature needs more evaluation to fit into the
structured PCD control of the lib sizes.

Mike

> -Original Message-
> From: Li, Yi1 
> Sent: Wednesday, September 21, 2022 7:16 PM
> To: Kinney, Michael D ; devel@edk2.groups.io
> Cc: Yao, Jiewen ; Wang, Jian J ; 
> Lu, Xiaoyu1 ; Jiang,
> Guomin 
> Subject: RE: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support
> 
> Hi Mike,
> Thanks for review.
> 
> Even PCD_CRYPTO_SERVICE_FAMILY_ENABLE is set to 0, CryptoEc.c will also be 
> compiled and throw build error:
> 
> d:\workspace\tianocore\edk2\CryptoPkg\Library\BaseCryptLib\Pk\CryptEc.c(77): 
> error C2220: the following warning is treated as
> an error
> 1 file(s) copied.
> d:\workspace\tianocore\edk2\CryptoPkg\Library\BaseCryptLib\Pk\CryptEc.c(77): 
> warning C4013: 'EC_GROUP_new_by_curve_name'
> undefined; assuming extern returning int
> d:\workspace\tianocore\edk2\CryptoPkg\Library\BaseCryptLib\Pk\CryptEc.c(77): 
> warning C4047: 'return': 'void *' differs in
> levels of indirection from 'int'
> d:\workspace\tianocore\edk2\CryptoPkg\Library\BaseCryptLib\Pk\CryptEc.c(105): 
> warning C4013: 'EC_GROUP_get_curve' undefined;
> assuming extern returning int
> 
> I think the root cause is that we have enabled conditional ec in 
> OpensslLib.inf before by PcdOpensslEcEnabled,
> https://github.com/tianocore/edk2/blob/2c17d676e402d75a3a674499342f7ddaccf387bd/CryptoPkg/Library/OpensslLib/OpensslLib.inf#L2
> 02-L238
>  if PcdOpensslEcEnabled not true, all ec files will not be compiled.
> This will save 200+kb memory on platforms which use dxe driver but do not 
> need ec feature.
> 
> So I add this PCD to BaseCryptLib.inf also to avoid build error, Not sure if 
> there is any other way, other better ideas are
> welcome.
> 
> Thanks,
> Yi
> 
> -Original Message-
> From: Kinney, Michael D 
> Sent: Thursday, September 22, 2022 12:22 AM
> To: devel@edk2.groups.io; Li, Yi1 ; Kinney, Michael D 
> 
> Cc: Yao, Jiewen ; Wang, Jian J ; 
> Lu, Xiaoyu1 ; Jiang,
> Guomin 
> Subject: RE: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support
> 
> Comments embedded below.
> 
> Mike
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of yi1 li
> > Sent: Tuesday, September 20, 2022 9:55 PM
> > To: devel@edk2.groups.io
> > Cc: Li, Yi1 ; Yao, Jiewen ; Wang, 
> > Jian J ; Lu, Xiaoyu1
> > ; Jiang, Guomin 
> > Subject: [edk2-devel] [PATCH V2 1/3] CryptoPkg: Add EC support
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3828
> >
> > This patch is used to add CryptEc library, which is wrapped
> > over OpenSSL.
> >
> > Cc: Jiewen Yao 
> > Cc: Jian J Wang 
> > Cc: Xiaoyu Lu 
> > Cc: Guomin Jiang 
> >
> > Signed-off-by: Yi Li 
> > ---
> >  CryptoPkg/Include/Library/BaseCryptLib.h  | 424 ++
> >  .../Library/BaseCryptLib/BaseCryptLib.inf |   2 +
> >  .../Library/BaseCryptLib/PeiCryptLib.inf  |   1 +
> >  CryptoPkg/Library/BaseCryptLib/Pk/CryptEc.c   | 765 ++
> >  .../Library/BaseCryptLib/Pk/CryptEcNull.c | 496 
> >  .../Library/BaseCryptLib/SmmCryptLib.inf  |   1 +
> >  .../BaseCryptLibNull/BaseCryptLibNull.inf |   1 +
> >  .../Library/BaseCryptLibNull/Pk/CryptEcNull.c | 496 
> >  8 files changed, 2186 insertions(+)
> >  create mode 100644 CryptoPkg/Library/BaseCryptLib/Pk/CryptEc.c
> >  create mode 100644 CryptoPkg/Library/BaseCryptLib/Pk/CryptEcNull.c
> >  create mode 100644 CryptoPkg/Library/BaseCryptLibNull/Pk/CryptEcNull.c
> >
> > diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h 
> > b/CryptoPkg/Include/Library/BaseCryptLib.h
> > index b253923dd8..d74fc21c1e 100644
> > --- a/CryptoPkg/Include/Library/BaseCryptLib.h
> > +++ b/CryptoPkg/Include/Library/BaseCryptLib.h
> > @@ -14,6 +14,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >  #include 
> >
> > +#define CRYPTO_NID_NULL  0x
> > +
> > +// Key Exchange
> > +#define CRYPTO_NID_SECP256R1  0x0204
> > +#define CRYPTO_NID_SECP384R1  0x0205
> > +#define CRYPTO_NID_SECP521R1  0x0206
> > +
> >  ///
> >  /// MD5 digest size in bytes
> >  ///
> > @@ 

[edk2-devel] [PATCH 1/1] CryptoPkg: Fix pem heap-buffer-overflow due to BIO_snprintf()

2022-09-22 Thread yi1 li
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4075

Fake BIO_snprintf() need to return error status -1. 0 will be
considered a correct return value, this may cause crash, please
refer to bugzilla link for details.

Signed-off-by: Yi Li 

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
---
 CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c 
b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
index c1fc33538f..d7d8c206ed 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
@@ -494,7 +494,7 @@ BIO_snprintf (
   ...
   )
 {
-  return 0;
+  return -1;
 }
 
 #ifdef __GNUC__
-- 
2.31.1.windows.1



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




Re: [edk2-devel] [PATCH] UsbNetworkPkg: add USB network devices support

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

Thanks Richard.
Please just send out the v2, I will give my feedback based on that.
Please run PatchCheck and Uncrustify on your patch before sending it out. Also, 
it would be helpful if you can organize your patches on driver based instead of 
having everything all together in one patch. It would be easier for us to 
review and also easier for you to address the comments.
Thanks
Abner

> -Original Message-
> From: RichardHo [何明忠] 
> Sent: Wednesday, September 21, 2022 10:35 AM
> To: devel@edk2.groups.io; Chang, Abner ;
> quic_rc...@quicinc.com
> Cc: Andrew Fish ; Leif Lindholm
> ; Michael D Kinney ;
> Michael Kubacki ; Zhiguang Liu
> ; Liming Gao ; TonyLo
> [羅金松] 
> Subject: RE: [EXTERNAL] Re: [edk2-devel] [PATCH] UsbNetworkPkg: add USB
> network devices support
> 
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
> 
> 
> Hi Abner,
> 
> For #4, To see below code. RNDIS driver provide the RndisUndiStart routine.
>   It could execute RndisUndiStart in UndiStart routine end.
>   The upper layer driver not need to know the USB CDC driver 
> interface
> class.
>   It only provide the USB_ETHERNET_PROTOCOL. The UNDI protocol is
> easy to control by NetworkCommon driver.
> 
> I have convert the USB_ETHERNET_PROTOCOL to
> EDKII_USB_ETHERNET_PROTOCOL, will send the patch next.
> 
>   UsbRndisDevice->Signature  = USB_RNDIS_SIGNATURE;
>   UsbRndisDevice->NumOfInterface = 
> Interface.InterfaceNumber;
>   UsbRndisDevice->UsbRndisHandle = RndisHandle;
>   UsbRndisDevice->UsbCdcDataHandle   = 0;
>   UsbRndisDevice->UsbIo  = UsbIo;
> 
> // -- Below is for USB_ETHERNET_PROTOCOL
>   UsbRndisDevice->UsbEth.UsbEthReceive   = RndisUndiReceive;
>   UsbRndisDevice->UsbEth.UsbEthTransmit  = RndisUndiTransmit;
>   UsbRndisDevice->UsbEth.UsbEthInterrupt = UsbRndisInterrupt;
>   UsbRndisDevice->UsbEth.UsbEthMacAddress= GetUsbEthMacAddress;
>   UsbRndisDevice->UsbEth.UsbEthMaxBulkSize   = UsbEthBulkSize;
>   UsbRndisDevice->UsbEth.UsbHeaderFunDescriptor  =
> GetUsbHeaderFunDescriptor;
>   UsbRndisDevice->UsbEth.UsbUnionFunDescriptor   =
> GetUsbUnionFunDescriptor;
>   UsbRndisDevice->UsbEth.UsbEthFunDescriptor =
> GetUsbRndisFunDescriptor;
>   UsbRndisDevice->UsbEth.SetUsbEthMcastFilter= SetUsbRndisMcastFilter;
>   UsbRndisDevice->UsbEth.SetUsbEthPowerPatternFilter =
> SetUsbRndisPowerFilter;
>   UsbRndisDevice->UsbEth.GetUsbEthPoewrPatternFilter =
> GetUsbRndisPowerFilter;
>   UsbRndisDevice->UsbEth.SetUsbEthPacketFilter   = 
> SetUsbRndisPacketFilter;
>   UsbRndisDevice->UsbEth.GetUsbEthStatistic  = GetRndisStatistic;
> 
> // --- Below is for UNDI Hook
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiGetState=
> RndisDummyReturn;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiStart   = 
> RndisUndiStart;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiStop= RndisUndiStop;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiGetInitInfo =
> RndisUndiGetInitInfo;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiGetConfigInfo   =
> RndisUndiGetConfigInfo;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiInitialize  =
> RndisUndiInitialize;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiReset   = 
> RndisUndiReset;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiShutdown=
> RndisUndiShutdown;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiInterruptEnable =
> RndisDummyReturn;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiReceiveFilter   =
> RndisUndiReceiveFilter;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiStationAddress  =
> RndisDummyReturn;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiStatistics  = NULL;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiMcastIp2Mac =
> RndisDummyReturn;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiNvData  =
> RndisDummyReturn;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiGetStatus   =
> RndisUndiGetStatus;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiFillHeader  =
> RndisDummyReturn;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiTransmit= NULL;
>   UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiReceive = NULL;
> 
> UndiStart (
>   IN  PXE_CDB   *Cdb,
>   IN  NIC_DATA  *Nic
>   )
> {
>   PXE_CPB_START_31  *Cpb;
>   EFI_STATUSStatus;
> 
>   if ((Cdb->OpCode != PXE_OPCODE_START) ||
>   (Cdb->StatCode != PXE_STATCODE_INITIALIZE) ||
>   (Cdb->StatFlags != PXE_STATFLAGS_INITIALIZE) ||
>   (Cdb->IFnum >= (gPxe->IFcnt | gPxe->IFcntExt << 8)) ||
>   (Cdb->CPBsize != sizeof (PXE_CPB_START_31)) ||
>   (Cdb->DBsize != PXE_DBSIZE_NOT_USED) ||
>   (Cdb->DBaddr != PXE_DBADDR_NOT_USED) ||
>   (Cdb->OpFlags 

[edk2-devel] File /Designs/2022/0923//How to add support for RISC-V in edk2 .pdf deleted #file-notice

2022-09-22 Thread Group Notification


The following files and folders have been deleted from the Files area of the 
devel@edk2.groups.io group.

* /Designs/2022/0923//How to add support for RISC-V in edk2 .pdf

*By:* Ni, Ray 







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




Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Edk2ToolsBuild: Fixing pipeline build due to path too long

2022-09-22 Thread Bob Feng
Create PR https://github.com/tianocore/edk2/pull/3378 for merge.

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Bob Feng
Sent: Thursday, September 22, 2022 7:11 PM
To: Kun Qin ; devel@edk2.groups.io
Cc: Gao, Liming ; Chen, Christine 
; Sean Brogan 
Subject: Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Edk2ToolsBuild: Fixing 
pipeline build due to path too long

Reviewed-by: Bob Feng 

-Original Message-
From: Kun Qin  
Sent: Thursday, September 22, 2022 4:45 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C ; Gao, Liming ; 
Chen, Christine ; Sean Brogan 
Subject: [PATCH v1 1/1] BaseTools: Edk2ToolsBuild: Fixing pipeline build due to 
path too long

From: Sean Brogan 

Current implementation of looking up toolchain will _insert_ the findings from 
vsvarsall.bat to existing path and potentially stuff the variable to exceed the 
length of maximal path length accepted by Windows.

This change updated the logic to use the discovered shell varialbes to replace 
the existing path, which is desirable in the specific use case.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yuwei Chen 

Co-authored-by: Sean Brogan 
Signed-off-by: Kun Qin 
---
 BaseTools/Edk2ToolsBuild.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Edk2ToolsBuild.py b/BaseTools/Edk2ToolsBuild.py index 
1ea8187de693..f862468ce275 100644
--- a/BaseTools/Edk2ToolsBuild.py
+++ b/BaseTools/Edk2ToolsBuild.py
@@ -122,7 +122,7 @@ class Edk2ToolsBuild(BaseAbstractInvocable):
 for key in vc_vars.keys(): logging.debug(f"Var - 
{key} = {vc_vars[key]}") if key.lower() == 'path':- 
   shell_env.insert_path(vc_vars[key])+
shell_env.set_path(vc_vars[key]) else: 
shell_env.set_shell_var(key, vc_vars[key]) -- 
2.37.1.windows.1








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




Re: [edk2-devel] [PATCH v1 1/1] BaseTools: Edk2ToolsBuild: Fixing pipeline build due to path too long

2022-09-22 Thread Bob Feng
Reviewed-by: Bob Feng 

-Original Message-
From: Kun Qin  
Sent: Thursday, September 22, 2022 4:45 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C ; Gao, Liming ; 
Chen, Christine ; Sean Brogan 
Subject: [PATCH v1 1/1] BaseTools: Edk2ToolsBuild: Fixing pipeline build due to 
path too long

From: Sean Brogan 

Current implementation of looking up toolchain will _insert_ the findings from 
vsvarsall.bat to existing path and potentially stuff the variable to exceed the 
length of maximal path length accepted by Windows.

This change updated the logic to use the discovered shell varialbes to replace 
the existing path, which is desirable in the specific use case.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yuwei Chen 

Co-authored-by: Sean Brogan 
Signed-off-by: Kun Qin 
---
 BaseTools/Edk2ToolsBuild.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Edk2ToolsBuild.py b/BaseTools/Edk2ToolsBuild.py index 
1ea8187de693..f862468ce275 100644
--- a/BaseTools/Edk2ToolsBuild.py
+++ b/BaseTools/Edk2ToolsBuild.py
@@ -122,7 +122,7 @@ class Edk2ToolsBuild(BaseAbstractInvocable):
 for key in vc_vars.keys(): logging.debug(f"Var - 
{key} = {vc_vars[key]}") if key.lower() == 'path':- 
   shell_env.insert_path(vc_vars[key])+
shell_env.set_path(vc_vars[key]) else: 
shell_env.set_shell_var(key, vc_vars[key]) -- 
2.37.1.windows.1



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




Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes

2022-09-22 Thread Konstantin Aladyshev
> Is the issue that you are trying to solve supporting larger serial console 
> modes or just wanting to use the largest possible text mode at a given 
> graphics resolution?

I spotted this issue when I wanted to use the largest possible text
mode in UEFI shell at high graphics resolutions. Is it not enough
reason for this commit?

> The other way to get full screen text on the graphical console is to disable 
> the serial console in the Boot Maintenance Manager.

Can you please elaborate this? I've tried to disable UART in "Boot
Maintenance Manager -> Console Options" like this:
```
Console Input Device Select:
PciRoot(0x0)/Pci(0x1,0x0)/Acpi(PNP0303,0x0) [X]
PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]

Console Output Device Select:
PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80010100)  [X]
PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]

Console Standard Error Device Select:
PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80010100)  [X]
PciRoot(0x0)/Pci(0x1,0x0)/Serial(0x0)/Uart(115200,8,N,1)[  ]
```
But after reset, the console is 80x25 and all UART options are checked again.

Also there is a menu "Boot Maintenance Manager -> Console Options ->
Console Output Mode Select" that has "Set Console Output Mode", and it
is always "80x25" without any options for me.

Best regards,
Konstantin Aladyshev

On Wed, Sep 21, 2022 at 7:28 PM Kinney, Michael D
 wrote:
>
> The other way to get full screen text on graphical console is to disable the 
> serial console
> in the Boot Maintenance Manager.
>
> If the serial console is disabled then ConSplitterDxe will only see the text 
> modes supported
> by GraphicsConsoleDxe which will include these higher text modes.
>
> Is the issue that you are trying to solve supporting larger serial console 
> modes or just
> wanting to use the largest possible text mode at a given graphics resolution?
>
> Mike
>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Konstantin 
> > Aladyshev
> > Sent: Wednesday, September 21, 2022 1:24 AM
> > To: Kinney, Michael D 
> > Cc: devel@edk2.groups.io; Gao, Liming ; Wang, 
> > Jian J ; Ni, Ray
> > 
> > Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes
> >
> > I have tested it in the following way:
> > - launch OVMF in Linux and connect with vnc
> > - change resolution via the form browser (Device Manager -> OVMF
> > Platform Configuration) from the default 640x480 to the 1920x1080
> > - "reset"
> > - after the reset the system will boot to the 1920x1080 resolution and
> > text mode 80x25
> > - check "mode" command output
> >
> > Before the commit this command displays only these modes:
> > ```
> > Shell> mode
> > Available modes for console output device.
> >   Col80 Row25  *
> >   Col80 Row50
> >   Col   100 Row31
> > ```
> > But with this commit the high resolution modes are present in the output:
> > ```
> > Shell> mode
> > Available modes for console output device.
> >   Col80 Row25  *
> >   Col80 Row50
> >   Col   100 Row31
> >   Col   128 Row40
> >   Col   160 Row42
> >   Col   240 Row56
> > ```
> > And in my case setting the appropriate "mode 240 56" at runtime works just 
> > fine:
> > ```
> > Shell> mode 240 56
> > ```
> > After that the text output starts using the full screen.
> >
> > Best regards,
> > Konstantin Aladyshev
> >
> > On Wed, Sep 21, 2022 at 4:46 AM Kinney, Michael D
> >  wrote:
> > >
> > > Tera Term works.
> > >
> > > Mike
> > >
> > > > -Original Message-
> > > > From: devel@edk2.groups.io  On Behalf Of 
> > > > gaoliming via groups.io
> > > > Sent: Tuesday, September 20, 2022 6:26 PM
> > > > To: Kinney, Michael D ; 
> > > > devel@edk2.groups.io; aladyshe...@gmail.com
> > > > Cc: Wang, Jian J ; Ni, Ray 
> > > > Subject: 回复: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes
> > > >
> > > > Konstantin:
> > > >   Do you try the terminal software (such as Putty) to display the text 
> > > > mode 160, 42 or 240, 56?
> > > >   I try Putty in my desktop. It can't display 240 * 56 in one screen.
> > > >
> > > > Thanks
> > > > Liming
> > > > > -邮件原件-
> > > > > 发件人: Kinney, Michael D 
> > > > > 发送时间: 2022年9月20日 5:02
> > > > > 收件人: devel@edk2.groups.io; aladyshe...@gmail.com; Kinney, Michael D
> > > > > 
> > > > > 抄送: Wang, Jian J ; Gao, Liming
> > > > > ; Ni, Ray 
> > > > > 主题: RE: [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: add modes
> > > > >
> > > > > This looks like a reasonable update to support platforms that have 
> > > > > both
> > > > > graphical consoles and serial consoles.
> > > > >
> > > > > Reviewed-by: Michael D Kinney 
> > > > >
> > > > >
> > > > > > -Original Message-
> > > > > > From: devel@edk2.groups.io  On Behalf Of
> > > > > Konstantin Aladyshev
> > > > > > Sent: Monday, September 19, 2022 1:57 AM
> > > > > > To: devel@edk2.groups.io
> > > > > > Cc: Wang, Jian J ; Gao, Liming
> > > > 

[edk2-devel] [PATCH] SecurityPkg: Remove enforcement of final GoIdle transition for CRB commands

2022-09-22 Thread Rodrigo Gonzalez del Cueto
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4077

Following the design described in the TCG specification,
the driver implementation of the CRB protocol does not require
enforcing completing the transition to goIdle at the end of a command
sequence.

Signed-off-by: "Gonzalez Del Cueto, Rodrigo" 

Cc: Jiewen Yao 
Cc: Jian J Wang 
---
 SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c 
b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
index 840265292a..1f9ac5ab5a 100644
--- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
@@ -381,19 +381,6 @@ GoIdle_Exit:
   //
   MmioWrite32 ((UINTN)>CrbControlRequest, 
PTP_CRB_CONTROL_AREA_REQUEST_GO_IDLE);
 
-  //
-  // Only enforce Idle state transition if execution fails when 
CRBIdleBypass==1
-  // Leave regular Idle delay at the beginning of next command execution
-  //
-  if (GetCachedIdleByPass () == 1) {
-Status = PtpCrbWaitRegisterBits (
-   >CrbControlStatus,
-   PTP_CRB_CONTROL_AREA_STATUS_TPM_IDLE,
-   0,
-   PTP_TIMEOUT_C
-   );
-  }
-
   return Status;
 }
 
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#94113): https://edk2.groups.io/g/devel/message/94113
Mute This Topic: https://groups.io/mt/93843955/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/2] MdeModulePkg/UsbBusDxe: Avoid continuing on error path

2022-09-22 Thread Wu, Hao A
Hello,

1. For “"Avoid continuing on error path" - The reset can happen before 
PortState is zero'd, so running this at the start of the function ensures it 
will”:
My take is that the execution flow is like:
UsbEnumeratePort
Status = HubApi->GetPortStatus (HubIf, Port, );
UsbRootHubGetPortStatus
UsbHcGetRootHubPortStatus
XhcGetRootHubPortStatus
If this is the case, within XhcGetRootHubPortStatus 
(MdeModulePkg\Bus\Pci\XhciDxe\Xhci.c), it does have logic to:
  Offset   = (UINT32)(XHC_PORTSC_OFFSET + (0x10 * 
PortNumber));
  PortStatus->PortStatus   = 0;
  PortStatus->PortChangeStatus = 0;
I am not sure why the below proposed change in UsbEnumeratePort can resolve the 
issue:
  // Zero out PortState in case GetPortStatus does not set it and we
  // continue on the EFI_DEVICE_ERROR path
  PortState.PortStatus   = 0;
  PortState.PortChangeStatus = 0;

Or the test you are performing includes connecting USB devices on a USB Hub?

2. For “" Reset the device on error" - this will only attempt enumeration if 
there isn't an error.”:
As I mentioned in reply of that patch, by the code execution reaches the change 
you made:
if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET) &&
(Status != EFI_DEVICE_ERROR))
‘Status’ will always be EFI_SUCCESS, I do not understand what is the point of 
adding “&& (Status != EFI_DEVICE_ERROR)”.
Could you help to double check if the change is really what you want to do?

Best Regards,
Hao Wu

From: devel@edk2.groups.io  On Behalf Of Sean Rhodes
Sent: Wednesday, September 21, 2022 4:37 PM
To: Wu, Hao A 
Cc: devel@edk2.groups.io; Ni, Ray 
Subject: Re: [edk2-devel] [PATCH 1/2] MdeModulePkg/UsbBusDxe: Avoid continuing 
on error path

Hi Hao

If I just boot a device to the EFI shell and then connect a USB, edk2 will 
constantly try to access the device, fail and reset the port. It won't stop 
doing this, and the USB drive can't be accessed.

I tested 13 USB drives; 8 saw this problem, and 5 worked correctly. It doesn't 
matter which SOC, or if the port is USB 2.0 or 3.0.

" Reset the device on error" - this will only attempt enumeration if there 
isn't an error.
"Avoid continuing on error path" - The reset can happen before PortState is 
zero'd, so running this at the start of the function ensures it will

Hopefully, that makes sense!

Thanks

Sean


On Wed, 21 Sept 2022 at 09:24, Wu, Hao A 
mailto:hao.a...@intel.com>> wrote:
Sorry, could you help to explain more on the endless loop? Like what causes the 
loop and why the proposed change can resolve the issue.
I am not experienced enough in the USB domain to quickly figure out the whole 
picture with only log being provided.

Best Regards,
Hao Wu

From: Sean Rhodes mailto:sean@starlabs.systems>>
Sent: Wednesday, September 21, 2022 4:01 PM
To: Wu, Hao A mailto:hao.a...@intel.com>>
Cc: devel@edk2.groups.io; Ni, Ray 
mailto:ray...@intel.com>>
Subject: Re: [edk2-devel] [PATCH 1/2] MdeModulePkg/UsbBusDxe: Avoid continuing 
on error path

Hi Hao

I've attached a debug log for the problem I'm trying to solve (these two 
patches solve it).

The reset happens before PortState changes, so it's an endless loop.

Thanks

Sean

On Wed, 21 Sept 2022 at 06:31, Wu, Hao A 
mailto:hao.a...@intel.com>> wrote:
Sorry, could you help to share more information on what issue is met for this 
proposed patch?

It seems to me that the change made below is to handle the case where:

  Status = HubApi->GetPortStatus (HubIf, Port, );

  if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: failed to get state of port %d\n", 
Port));
return Status;
  }

GetPortStatus() returns EFI_ SUCCESS, but does not update the output parameter 
'PortState'.
Could you help to check what causes 'PortState' not being updated after a 
success return from GetPortStatus()? Thanks in advance.

Also, one inline comment below:


> -Original Message-
> From: devel@edk2.groups.io 
> mailto:devel@edk2.groups.io>> On Behalf Of Sean
> Rhodes
> Sent: Tuesday, September 20, 2022 9:14 PM
> To: devel@edk2.groups.io
> Cc: Rhodes, Sean mailto:sean@starlabs.systems>>; Wu, 
> Hao A
> mailto:hao.a...@intel.com>>; Ni, Ray 
> mailto:ray...@intel.com>>
> Subject: [edk2-devel] [PATCH 1/2] MdeModulePkg/UsbBusDxe: Avoid
> continuing on error path
>
> Zero out the PortState in case GetPortStatus didn't set it, to avoid
> continuing with EFI_DEVICE_ERROR.
>
> Cc: Hao A Wu mailto:hao.a...@intel.com>>
> Cc: Ray Ni mailto:ray...@intel.com>>
> Signed-off-by: Sean Rhodes 
> mailto:sean@starlabs.systems>>
> ---
>  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
> b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
> index aed34596f4..7fc567898a 100644
> --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
> +++ 

Re: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code coverage support for GCC

2022-09-22 Thread Guo, Gua
It's PR based on the patch. Have any concern, please also share for me.
https://github.com/tianocore/edk2/pull/3349

Thanks,
Gua

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Guo, Gua
Sent: Thursday, September 22, 2022 3:09 PM
To: devel@edk2.groups.io
Cc: Guo, Gua 
Subject: [edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code coverage 
support for GCC

From: Gua Guo 

V1: Add coverage option for GCC
V2: Add ReadMe.md for how to generate coverage report
V3: Add VS2019 and GCC code coverage support

Gua Guo (2):
  UnitTestFrameworkPkg: Add code coverage support for GCC
  BaseTools/Plugin: Add coverage support for Unit Test

 .../HostBasedUnitTestRunner.py| 124 ++
 UnitTestFrameworkPkg/ReadMe.md|  42 +-
 .../UnitTestFrameworkPkg.ci.yaml  |   2 +
 .../UnitTestFrameworkPkgHost.dsc.inc  |   3 +-
 4 files changed, 167 insertions(+), 4 deletions(-)

-- 
2.31.1.windows.1








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




[edk2-devel] [PATCH v3 2/2] BaseTools/Plugin: Add coverage support for Unit Test

2022-09-22 Thread Guo, Gua
From: Gua Guo 

For GCC, use lcov to generate Unit Test code coverage
report

For VS2019, use OpenCppCoverage to generate code
coverage report

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Bret Barkelew 
Cc: Michael D Kinney 
Cc: Sean Brogan 
Signed-off-by: Gua Guo 
---
 .../HostBasedUnitTestRunner.py| 124 ++
 1 file changed, 124 insertions(+)

diff --git 
a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py 
b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
index c1eeaf2625..0b77576f3c 100644
--- a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
+++ b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
@@ -112,4 +112,128 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin):
 "  %s - %s" % 
(case.attrib['name'], result.text))
 failure_count += 1
 
+if thebuilder.env.GetValue("CODE_COVERAGE") == "TRUE":
+if thebuilder.env.GetValue("TOOL_CHAIN_TAG") == "GCC5":
+self.gen_code_coverage_gcc(thebuilder)
+elif thebuilder.env.GetValue("TOOL_CHAIN_TAG") == "VS2019":
+self.gen_code_coverage_msvc(thebuilder)
+else:
+logging.info("Skipping code coverage. Only supported on 
GCC.")
+
 return failure_count
+
+def gen_code_coverage_gcc(self, thebuilder):
+logging.info("Generating UnitTest code coverage")
+
+buildOutputBase = thebuilder.env.GetValue("BUILD_OUTPUT_BASE")
+workspace = thebuilder.env.GetValue("WORKSPACE")
+
+# Generate base code coverage for all source files
+ret = RunCmd("lcov", f"--no-external --capture --initial --directory 
{buildOutputBase} --output-file {buildOutputBase}/cov-base.info --rc 
lcov_branch_coverage=1")
+if(ret != 0):
+logging.error("UnitTest Coverage: Failed to build initial coverage 
data.")
+return 1
+
+# Coverage data for tested files only
+ret = RunCmd("lcov", f"--capture --directory {buildOutputBase}/ 
--output-file {buildOutputBase}/coverage-test.info --rc lcov_branch_coverage=1")
+if(ret != 0):
+logging.error("UnitTest Coverage: Failed to build coverage data 
for tested files.")
+return 1
+
+# Aggregate all coverage data
+ret = RunCmd("lcov", f"--add-tracefile {buildOutputBase}/cov-base.info 
--add-tracefile {buildOutputBase}/coverage-test.info --output-file 
{buildOutputBase}/total-coverage.info --rc lcov_branch_coverage=1")
+if(ret != 0):
+logging.error("UnitTest Coverage: Failed to aggregate coverage 
data.")
+return 1
+
+# Generate coverage XML
+ret = RunCmd("lcov_cobertura",f"{buildOutputBase}/total-coverage.info 
-o {buildOutputBase}/compare.xml")
+if(ret != 0):
+logging.error("UnitTest Coverage: Failed to generate coverage 
XML.")
+return 1
+
+# Filter out auto-generated and test code
+ret = RunCmd("lcov_cobertura",f"{buildOutputBase}/total-coverage.info 
--excludes ^.*UnitTest\|^.*MU\|^.*Mock\|^.*DEBUG -o 
{buildOutputBase}/coverage.xml")
+if(ret != 0):
+logging.error("UnitTest Coverage: Failed generate filtered 
coverage XML.")
+return 1
+
+# Generate all coverage file
+testCoverageList = glob.glob 
(f"{workspace}/Build/**/total-coverage.info", recursive=True)
+
+coverageFile = ""
+for testCoverage in testCoverageList:
+coverageFile += " --add-tracefile " + testCoverage
+ret = RunCmd("lcov", f"{coverageFile} --output-file 
{workspace}/Build/all-coverage.info --rc lcov_branch_coverage=1")
+if(ret != 0):
+logging.error("UnitTest Coverage: Failed generate all coverage 
file.")
+return 1
+
+# Generate and HTML file if requested.by each package
+if thebuilder.env.GetValue("CC_HTML") == "TRUE":
+ret = RunCmd("pycobertura", f"show --format html --output 
{buildOutputBase}/coverage.html {buildOutputBase}/coverage.xml --source 
{workspace}")
+if(ret != 0):
+logging.error("UnitTest Coverage: Failed to generate HTML in 
single package..")
+
+# Generate and HTML file if requested.for all package
+if os.path.isfile(f"{workspace}/Build/coverage.xml"):
+os.remove(f"{workspace}/Build/coverage.xml")
+ret = RunCmd("lcov_cobertura",f"{workspace}/Build/all-coverage.info 
--excludes ^.*UnitTest\|^.*MU\|^.*Mock\|^.*DEBUG -o 
{workspace}/Build/coverage.xml")
+
+if thebuilder.env.GetValue("CC_HTML") == "TRUE":
+if os.path.isfile(f"{workspace}/Build/coverage.html"):
+os.remove(f"{workspace}/Build/coverage.html")
+ret = RunCmd("pycobertura", f"show --format html --output 
{workspace}/Build/coverage.html 

[edk2-devel] [PATCH v3 1/2] UnitTestFrameworkPkg: Add code coverage support for GCC

2022-09-22 Thread Guo, Gua
From: Gua Guo 

In order to collect code coverage after running executable
file, generate *.gcda and *.gcno file that require by lcov tool
to generate code coverage report.

Cc: Michael D Kinney 
Cc: Sean Brogan 
Cc: Bret Barkelew 
Cc: Michael Kubacki 
Signed-off-by: Gua Guo 
---
 UnitTestFrameworkPkg/ReadMe.md| 42 +--
 .../UnitTestFrameworkPkg.ci.yaml  |  2 +
 .../UnitTestFrameworkPkgHost.dsc.inc  |  3 +-
 3 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/UnitTestFrameworkPkg/ReadMe.md b/UnitTestFrameworkPkg/ReadMe.md
index e696412cb3..3c69cfdd97 100644
--- a/UnitTestFrameworkPkg/ReadMe.md
+++ b/UnitTestFrameworkPkg/ReadMe.md
@@ -60,7 +60,7 @@ you should be good to go.
 
 See this example in 'SampleUnitTestUefiShell.inf'...
 
-```
+```inf
 [Packages]
   MdePkg/MdePkg.dec
 
@@ -75,7 +75,7 @@ See this example in 'SampleUnitTestUefiShell.inf'...
 Also, if you want you test to automatically be picked up by the Test Runner 
plugin, you will need
 to make sure that the module `BASE_NAME` contains the word `Test`...
 
-```
+```inf
 [Defines]
   BASE_NAME  = SampleUnitTestUefiShell
 ```
@@ -361,7 +361,7 @@ RUNNING TEST SUITE: Int Safe Conversions Test Suite
 ```
 
 You can also, if you are so inclined, read the output from the exact instance 
of the test that was run during
-`stuart_ci_build`. The ouput file can be found on a path that looks like:
+`stuart_ci_build`. The output file can be found on a path that looks like:
 
 `Build//HostTest//...result.xml`
 
@@ -399,6 +399,42 @@ CMOCKA_XML_FILE=
 
 This mode is used by the test running plugin to aggregate the results for CI 
test status reporting in the web view.
 
+### Code Coverage
+
+Host based Unit Tests will automatically i enable coverage data.
+This is primarily leveraged for pipeline builds, but this can be leveraged 
locally using the
+lcov linux tool, and parsed using the lcov_cobertura python tool. pycobertura 
is used to
+covert this coverage data to a human readable HTML file. These tools must be 
installed
+to parse code coverage.
+
+- Windows Prerequisite
+  ```bash
+  Download and install https://github.com/OpenCppCoverage/OpenCppCoverage/tags
+  pip install pycobertura
+  ```
+
+- Linux Prerequisite
+  ```bash
+  sudo apt-get install -y lcov
+  pip install lcov_cobertura
+  pip install pycobertura
+  ```
+
+During CI builds, use the  ```CODE_COVERAGE=TRUE``` flag to generate the code 
coverage XML files,
+and additionally use the ```CC_HTML=TRUE``` flag to generate the HTML file. 
This will be generated
+in Build/coverage.html.
+
+There is currently no official guidance or support for code coverage when 
compiling
+in Visual Studio at this time.
+During CI builds, use the  ```CODE_COVERAGE=TRUE``` flag to generate the code 
coverage XML files,
+and additionally use the ```CC_HTML=TRUE``` flag to generate the HTML file. 
This will be generated
+in Build/coverage.html.
+
+Example
+```bash
+  stuart_ci_build -c .pytool/CISettings.py  -t NOOPT TOOL_CHAIN_TAG=VS2019 -p 
MdeModulePkg CC_HTML=TRUE CODE_COVERAGE=TRUE
+ ```
+
 ### Important Note
 
 This works on both Windows and Linux, but is currently limited to x64 
architectures. Working on getting others, but we
diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml 
b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml
index 77d51e1348..f68882e1cf 100644
--- a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml
+++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml
@@ -90,6 +90,8 @@
 "pytools",
 "NOFAILURE",
 "cmockery",
+"cobertura",
+"pycobertura",
 "DHAVE", # build flag for cmocka in the INF
 "corthon",  # Contact GitHub account in Readme
 "mdkinney", # Contact GitHub account in Readme
diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc 
b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc
index 4dd8d4ac67..ca46b8513a 100644
--- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc
+++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc
@@ -25,7 +25,8 @@
   GCC:*_*_*_CC_FLAGS   = -D UNIT_TESTING_DEBUG=1
   XCODE:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1
 !endif
-
+  GCC:*_GCC5_*_CC_FLAGS = --coverage
+  GCC:*_GCC5_*_DLINK_FLAGS = --coverage
 [BuildOptions.common.EDKII.HOST_APPLICATION]
   #
   # MSFT
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH v3 0/2] UnitTestFrameworkPkg: Add code coverage support for GCC

2022-09-22 Thread Guo, Gua
From: Gua Guo 

V1: Add coverage option for GCC
V2: Add ReadMe.md for how to generate coverage report
V3: Add VS2019 and GCC code coverage support

Gua Guo (2):
  UnitTestFrameworkPkg: Add code coverage support for GCC
  BaseTools/Plugin: Add coverage support for Unit Test

 .../HostBasedUnitTestRunner.py| 124 ++
 UnitTestFrameworkPkg/ReadMe.md|  42 +-
 .../UnitTestFrameworkPkg.ci.yaml  |   2 +
 .../UnitTestFrameworkPkgHost.dsc.inc  |   3 +-
 4 files changed, 167 insertions(+), 4 deletions(-)

-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#94108): https://edk2.groups.io/g/devel/message/94108
Mute This Topic: https://groups.io/mt/93843728/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] MdeModulePkg/Core: Fix the potential hang of calling SetTimer.

2022-09-22 Thread Ying-Tsun Huang via groups.io
When calling SetTimer with Type is not TimerCancel and TriggerTime is 0,
gTimer is used to get the timer period. However, gTimer is NULL before
EFI_TIMER_ARCH_PROTOCOL is installed. Adding the check of gTimer and
return EFI_NOT_READY to avoid the hang.

Cc: Jian J Wang 
Cc: Dandan Bi 
Cc: Liming Gao 
Signed-off-by: Ying-Tsun Huang 
---
 MdeModulePkg/Core/Dxe/DxeMain.h |  3 +++
 MdeModulePkg/Core/Dxe/Event/Timer.c | 17 +
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h
index 815a6b4bd844..182d9c3537ad 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.h
+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
@@ -3,6 +3,7 @@
   internal structure and functions used by DxeCore module.
 
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2022, AMD Incorporated. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -1538,6 +1539,8 @@ CoreCreateEventInternal (
   @retval EFI_SUCCESSThe event has been set to be signaled at the
  requested time
   @retval EFI_INVALID_PARAMETER  Event or Type is not valid
+  @retval EFI_NOT_READY  Type is not TimerCancel, TriggerTime is 0, but
+ EFI_TIMER_ARCH_PROTOCOL is not installed yet
 
 **/
 EFI_STATUS
diff --git a/MdeModulePkg/Core/Dxe/Event/Timer.c 
b/MdeModulePkg/Core/Dxe/Event/Timer.c
index 29e507c67c50..f630cf5dad61 100644
--- a/MdeModulePkg/Core/Dxe/Event/Timer.c
+++ b/MdeModulePkg/Core/Dxe/Event/Timer.c
@@ -2,6 +2,7 @@
   Core Timer Services
 
 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2022, AMD Incorporated. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -229,6 +230,8 @@ CoreTimerTick (
   @retval EFI_SUCCESSThe event has been set to be signaled at the
  requested time
   @retval EFI_INVALID_PARAMETER  Event or Type is not valid
+  @retval EFI_NOT_READY  Type is not TimerCancel, TriggerTime is 0, but
+ EFI_TIMER_ARCH_PROTOCOL is not installed yet
 
 **/
 EFI_STATUS
@@ -255,6 +258,16 @@ CoreSetTimer (
 return EFI_INVALID_PARAMETER;
   }
 
+  if ((Type != TimerCancel) && (TriggerTime == 0)) {
+if (gTimer) {
+  gTimer->GetTimerPeriod (gTimer, );
+} else {
+  DEBUG ((DEBUG_ERROR, "EFI_TIMER_ARCH_PROTOCOL is not installed. Unable 
to get timer period.\n"));
+  ASSERT (FALSE);
+  return EFI_NOT_READY;
+}
+  }
+
   CoreAcquireLock ();
 
   //
@@ -270,10 +283,6 @@ CoreSetTimer (
 
   if (Type != TimerCancel) {
 if (Type == TimerPeriodic) {
-  if (TriggerTime == 0) {
-gTimer->GetTimerPeriod (gTimer, );
-  }
-
   Event->Timer.Period = TriggerTime;
 }
 
-- 
2.25.1



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




[edk2-devel] [PATCH v2 0/1] MdeModulePkg/Core: Fix the potential hang of calling SetTimer.

2022-09-22 Thread Ying-Tsun Huang via groups.io
When calling SetTimer with Type is not TimerCancel and TriggerTime is 0,
gTimer is used to get the timer period. However, gTimer is NULL before
EFI_TIMER_ARCH_PROTOCOL is installed. Adding the check of gTimer and
return EFI_NOT_READY to avoid the hang.

Ying-Tsun Huang (1):
  MdeModulePkg/Core: Fix the potential hang of calling SetTimer.

 MdeModulePkg/Core/Dxe/DxeMain.h |  3 +++
 MdeModulePkg/Core/Dxe/Event/Timer.c | 17 +
 2 files changed, 16 insertions(+), 4 deletions(-)

-- 
2.25.1



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