Re: [edk2-devel] edk2-test Release candidate 2: edk2-test-rc2_202405 // RE: [PATCH v2 0/4] TCG2 protocol clean up

2024-05-10 Thread Chao Li

Hi Edhay,

Okay, I will retest using the rc2 today and expect to upload the logs 
tonight or next Monday under edk2-test-rc2-202405.



Thanks,
Chao
On 2024/5/10 22:56, G Edhaya Chandran wrote:


Hi Chao,

Yes, it is best to test based on the new tag at-least on one environment.

Note: The difference between old and new tag is mainly resolving build 
related issues.


There is no change in test coverage.

With WarM Regards,
Edhay

*From:*Chao Li 
*Sent:* Thursday, May 9, 2024 9:56 PM
*To:* devel@edk2.groups.io; G Edhaya Chandran 
; David Wright ; 
Heinrich Schuchardt 
*Cc:* Alex Fox ; Stuart Yoder 
; gao...@byosoft.com.cn
*Subject:* Re: [edk2-devel] edk2-test Release candidate 2: 
edk2-test-rc2_202405 // RE: [PATCH v2 0/4] TCG2 protocol clean up


Hi Edhay,

Do I need to retest based on the edk2-test-rc2_202405 tag?

Thanks,
Chao

On 2024/5/10 10:43, G Edhaya Chandran wrote:

Thank you, David.

The results are well received.

With Warm Regards,
Edhay

*From:*David Wright 

*Sent:* Thursday, May 9, 2024 3:23 PM
*To:* G Edhaya Chandran 
; Heinrich Schuchardt


*Cc:* Alex Fox 
; lic...@loongson.cn; Stuart Yoder
 ;
devel@edk2.groups.io; gao...@byosoft.com.cn
*Subject:* RE: edk2-test Release candidate 2: edk2-test-rc2_202405
// RE: [PATCH v2 0/4] TCG2 protocol clean up

Hi all,

Phoenix has completed testing on *edk2-test-rc2_202405*

Results have been uploaded to their respective folders.

Thanks,

David Wright
QA Team Leader

david_wri...@phoenix.com

503-730-4537 Tel

www.phoenix.com




THIS MESSAGE MAY CONTAIN CONFIDENTIAL INFORMATION. UNLESS YOU ARE
THE INTENDED RECIPIENT OF THIS MESSAGE, ANY USE OF THIS MESSAGE IS
STRICTLY PROHIBITED. IF YOU HAVE RECEIVED THIS MESSAGE IN ERROR,
PLEASE IMMEDIATELY NOTIFY THE SENDER BY TELEPHONE OR REPLY EMAIL,
AND IMMEDIATELY DELETE THIS MESSAGE AND ALL COPIES.

*From:*G Edhaya Chandran 
*Sent:* Friday, May 3, 2024 4:47 PM
*To:* Heinrich Schuchardt 
*Cc:* Alex Fox ; David Wright
; lic...@loongson.cn; Stuart Yoder
; devel@edk2.groups.io; gao...@byosoft.com.cn
*Subject:* edk2-test Release candidate 2: edk2-test-rc2_202405 //
RE: [PATCH v2 0/4] TCG2 protocol clean up

[Caution, this message was sent from an external sender.]

Hi All,

   A new release candidate is published after upstreaming Stuart's
commits on build cleanup.

https://github.com/tianocore/edk2-test/tree/edk2-test-rc2_202405


The updates since the old tag are the following commits in the
patch series:

[PATCH v2 0/4] TCG2 protocol clean up (groups.io)



The release candidate may be used for any further testing.

With Warm Regards,
Edhay

> -Original Message-

> From: G Edhaya Chandran

> Sent: Tuesday, April 23, 2024 4:52 AM

> To: Heinrich Schuchardt 

> Cc: alex_...@phoenix.com; david_wri...@phoenix.com;

> lic...@loongson.cn; Stuart Yoder ;

> devel@edk2.groups.io; gao...@byosoft.com.cn

> Subject: RE: [PATCH v2 0/4] TCG2 protocol clean up

> 


> Hi Heinrich,

> 


>    Yes. A new release candidate shall be published after review and 
upstream

> of the patches.

> Will further send an update.

> 


> With Warm Regards,

> Edhay

> 

> 


> > -Original Message-

> > From: Heinrich Schuchardt 

> > Sent: Tuesday, April 23, 2024 12:46 AM

> > To: G Edhaya Chandran 

> > Cc: alex_...@phoenix.com; david_wri...@phoenix.com;

> > lic...@loongson.cn; Stuart Yoder ;

> > devel@edk2.groups.io; gao...@byosoft.com.cn

> > Subject: Re: [PATCH v2 0/4] TCG2 protocol clean up

> >

> > On 4/16/24 16:53, Stuart Yoder wrote:

> > > This patch series cleans up some issues found when building

> > > edk2-test with a non-GCC compiler:

> > >    -TPMT_HA struct had an error due to incorrect use of C flexible

> > > array

> > member

> > >    -compute struct member offsets using OFFSET_OF, which is not GCC

> specific

> > >    -clean up of #pragma pack in one file

> > >    -resolve type conversion warnings

> > >

> > > Patches are in github here:

> > > 

Re: [edk2-devel] [PATCH v2 07/13] SecurityPkg: RngDxe: Remove incorrect limitation on GetRng

2024-05-10 Thread Yao, Jiewen
Thanks to confirm that.
I am OK on what you have said.

Since the ARM part is added by Pierre Gondois 
pierre.gond...@arm.com, I will let him comment 
if there is any concern on the change for ARM.

Thank you
Yao, Jiewen


From: Doug Flick via groups.io 
Sent: Saturday, May 11, 2024 5:12 AM
To: Yao, Jiewen ; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH v2 07/13] SecurityPkg: RngDxe: Remove 
incorrect limitation on GetRng


So, I'm trying to consult with some RNG experts because I'm by no means an 
expert and anything I say should be taken with huge grain of salt. When I get 
the experts take, I'll share it.

Basically, the way I read this code is that it by no means tries to enforce any 
entropy requirement outside of what you ask for.

My understanding is the 256 Bit Entropy requirements comes from when you are 
using a DRNG algorithm such as:

#define EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID \

 {0xa7af67cb, 0x603b, 0x4d42,\

 {0xba, 0x21, 0x70, 0xbf, 0xb6, 0x29, 0x3f, 0x96}}



#define EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID \

 {0xc5149b43, 0xae85, 0x4f53,\

 {0x99, 0x82, 0xb9, 0x43, 0x35, 0xd3, 0xa9, 0xe7}}



#define EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID \

 {0x44f0de6e, 0x4d8c, 0x4045, \

 {0xa8, 0xc7, 0x4d, 0xd1, 0x68, 0x85, 0x6b, 0x9e}}

"When a Deterministic Random Bit Generator (DRBG) is used on the output of a 
(raw) entropy source, its security level must be at least 256 bits."

https://uefi.org/specs/UEFI/2.10/37_Secure_Technologies.html#random-number-generator-protocol

That is, the seed of these algorithms must be at a minimum 256 bits from your 
entropy source.

Now when you call for instance EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID

On an INTEL CPU it uses the Intel RDRAND Instruction

https://github.com/tianocore/edk2/blob/4b6ee06a090d956f80b4a92fb9bf03098a372f39/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c#L108C45-L108C51

Which from what I can tell the generator takes pairs of 256-bit raw entropy 
samples generated by the hardware entropy source and applies them to an 
Advanced Encryption Standard (AES) (in CBC-MAC mode) conditioner which reduces 
them to a single 256-bit conditioned entropy sample.

https://en.wikipedia.org/wiki/RDRAND

https://www.intel.com/content/www/us/en/developer/articles/guide/intel-digital-random-number-generator-drng-software-implementation-guide.html

Which means, if you are implementing these algorithms in software, you must 
comply with the 256 bit entropy requirement for your source. However in our 
case the CPU is performing that requirement for us.

Again I'm no expert. So if an expert is reading this and I'm completely wrong 
please let me know :)


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118828): https://edk2.groups.io/g/devel/message/118828
Mute This Topic: https://groups.io/mt/105996584/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 07/13] SecurityPkg: RngDxe: Remove incorrect limitation on GetRng

2024-05-10 Thread Doug Flick via groups.io
So, I'm trying to consult with some RNG experts because I'm by no means an 
expert and anything I say should be taken with huge grain of salt. When I get 
the experts take, I'll share it.

Basically, the way I read this code is that it by no means tries to enforce any 
entropy requirement outside of what you ask for.

My understanding is the 256 Bit Entropy requirements comes from when you are 
using a DRNG algorithm such as:
```
#define EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID \
 {0xa7af67cb, 0x603b, 0x4d42,\
 {0xba, 0x21, 0x70, 0xbf, 0xb6, 0x29, 0x3f, 0x96}}

#define EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID \
 {0xc5149b43, 0xae85, 0x4f53,\
 {0x99, 0x82, 0xb9, 0x43, 0x35, 0xd3, 0xa9, 0xe7}}

#define EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID \
 {0x44f0de6e, 0x4d8c, 0x4045, \
 {0xa8, 0xc7, 0x4d, 0xd1, 0x68, 0x85, 0x6b, 0x9e}}
```
> "When a Deterministic Random Bit Generator (DRBG) is used on the output of a 
> (raw) entropy source, its security level must be at least 256 bits." 

https://uefi.org/specs/UEFI/2.10/37_Secure_Technologies.html#random-number-generator-protocol

That is, the seed of these algorithms must be at a minimum 256 bits from your 
entropy source. 

Now when you call for instance EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID

On an INTEL CPU it uses the Intel RDRAND Instruction

https://github.com/tianocore/edk2/blob/4b6ee06a090d956f80b4a92fb9bf03098a372f39/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c#L108C45-L108C51

Which from what I can tell the generator takes pairs of 256-bit raw entropy 
samples generated by the hardware entropy source and applies them to an 
Advanced Encryption Standard (AES) (in CBC-MAC mode) conditioner which reduces 
them to a single 256-bit conditioned entropy sample.

https://en.wikipedia.org/wiki/RDRAND

https://www.intel.com/content/www/us/en/developer/articles/guide/intel-digital-random-number-generator-drng-software-implementation-guide.html

Which means, if you are implementing these algorithms in software, you must 
comply with the 256 bit entropy requirement for your source. However in our 
case the CPU is performing that requirement for us. 

Again I'm no expert. So if an expert is reading this and I'm completely wrong 
please let me know :)


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




Re: [edk2-rfc] [edk2-devel] Proposal to switch TianoCore Code Review from email to GitHub Pull Requests on 5-24-2024

2024-05-10 Thread Brian J. Johnson

On 5/3/24 12:38, Pedro Falcato wrote:

On Thu, May 2, 2024 at 7:17 PM Kinney, Michael D
 wrote:





-Original Message-
From: r...@edk2.groups.io  On Behalf Of Pedro Falcato
Sent: Thursday, May 2, 2024 10:51 AM
To: devel@edk2.groups.io; Kinney, Michael D 
Cc: r...@edk2.groups.io; Leif Lindholm ; Andrew Fish
(af...@apple.com) 
Subject: Re: [edk2-rfc] [edk2-devel] Proposal to switch TianoCore Code
Review from email to GitHub Pull Requests on 5-24-2024

On Wed, May 1, 2024 at 6:44 PM Michael D Kinney via groups.io
 wrote:



* All contributors, maintainers, and reviewers must have GitHub IDs.
* The commit message would no longer require Cc:, Reviewed-by:, Acked-

by:

   or Tested-by: tags.  The only required tag would be Signed-off-by.


I'd just like to note that losing the CC:, Reviewed-by:, etc is a big
loss. Gerrit auto-adds Rb's, github PR's do not (I'd guess there's a
way to pull that off with github actions, but I haven't looked). It'll
be a mess if I have to go through online GH PR backlogs just to find
who to CC/add-to-review. It kills the decentralized bit off of git too
:)



Can you provide more details on the impact of the loss?


In my view, commits should be fairly self-describing. What changes,
why, are obvious, but who looked at it, who reviewed it, who was cc'd
but didn't respond, who tested are also pretty important. Git is
supposed to be decentralized, let's not forget. If we ever migrate
from GH, if GH ever goes down, if the links ever go down, you'll never
be able to know who looked at it. If you're looking at an EDK2 commit
deep into an Intel-internal fork, you won't know what "PR #478" is
(heck, rebase-and-merge doesn't reference PRs either).



Well said.  That's my concern as well:  TianoCore won't use GitHub 
forever, and any GitHub metadata (PR numbers, GitHub IDs, bug numbers, 
etc.) will become meaningless once we change.  Never mind that the code 
can be disassociated from the metadata simply by forking to a new 
repository, as Pedro said



Side-note: How are we supposed to find the PR for a given commit?
Searching doesn't seem to work well. For instance, I picked a random
non-trivial commit out of the current open PRs:
MdeModulePkg/Bus/Spi/SpiBus: Adding SpiBus Drivers.
https://github.com/tianocore/edk2/pulls?q=is%3Apr+is%3Aopen+MdeModulePkg%2FBus%2FSpi%2FSpiBus%3A+Adding+SpiBus+Drivers
has no matches?



I am curious how other GitHub projects handle this topic. I see it


I don't think they do, sadly. But I also don't know many people with a
positive opinion on GH PRs :)


Yeah... my opinions are decidedly mixed.  They are convenient, but have 
some serious gaps around archiving, auditing, and versioning of review 
requests.  They don't even let you review the commit messages (one of 
their most serious flaws!)





It is sad that we're moving to PRs after I finally got a nice and
sane(ish!) email workflow (openfw.io + b4). Otherwise, no objections,
it's better than edk2.git's half-email half-PR frankenprocess.
I'd guess this change only encompasses edk2.git? How about the other
repos? Any timeline for those?


The plan is to apply this to all repos, one at a time.  Need to get the
revised process documented and working in one repo before applying to all.


Gotcha, thanks!



--
Brian J. Johnson
Hewlett Packard Enterprise


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




Re: [edk2-devel] [edk2-platforms] [PATCH v1 2/2] AlderlakeOpenBoardPkg: Include MpInfo2HobPei

2024-05-10 Thread Chaganty, Rangasai V
Reviewed-by: Sai Chaganty 

-Original Message-
From: Desimone, Nathaniel L  
Sent: Wednesday, May 08, 2024 5:09 PM
To: devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Chuang, Rosen 
; Kasbekar, Saloni ; Chiu, 
Chasel ; Liming Gao ; Dong, 
Eric 
Subject: [edk2-platforms] [PATCH v1 2/2] AlderlakeOpenBoardPkg: Include 
MpInfo2HobPei

Because Alder Lake FSP includes an older version of CpuMpPei MpInfo2HobPei is 
needed to boot with newer versions of EDK II.

Accordingly, this change adds MpInfo2HobPei to FvPostMemory.

Cc: Sai Chaganty 
Cc: Rosen Chuang 
Cc: Saloni Kasbekar 
Cc: Chasel Chiu 
Cc: Liming Gao 
Cc: Eric Dong 
Signed-off-by: Nate DeSimone 
---
 .../AlderlakePRvp/OpenBoardPkg.dsc | 10 +-
 .../AlderlakePRvp/OpenBoardPkg.fdf | 10 +-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git 
a/Platform/Intel/AlderlakeOpenBoardPkg/AlderlakePRvp/OpenBoardPkg.dsc 
b/Platform/Intel/AlderlakeOpenBoardPkg/AlderlakePRvp/OpenBoardPkg.dsc
index edd03cba68..092cb34831 100644
--- a/Platform/Intel/AlderlakeOpenBoardPkg/AlderlakePRvp/OpenBoardPkg.dsc
+++ b/Platform/Intel/AlderlakeOpenBoardPkg/AlderlakePRvp/OpenBoardPkg.ds
+++ c
@@ -1,7 +1,7 @@
 ## @file
 #  The main build description file for the AlderlakePRvp board.
 #
-#   Copyright (c) 2022, Intel Corporation. All rights reserved.
+#   Copyright (c) 2022 - 2024, Intel Corporation. All rights reserved.
 #   SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -342,6 +342,14 @@ 
ResetSystemLib|$(PLATFORM_SI_PACKAGE)/Pch/Library/BaseResetSystemLib/BaseResetSy
 
   }
 
+  #
+  # ADL FSP includes an older version of CpuMpPei, so the compatibility 
+PEIM
+  # is needed when using FSP Dispatch mode.
+  #
+!if gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection == 0
+  $(PLATFORM_PACKAGE)/FspWrapper/MpInfo2HobPei/MpInfo2HobPei.inf
+!endif
+
 #
 # Security
 #
diff --git 
a/Platform/Intel/AlderlakeOpenBoardPkg/AlderlakePRvp/OpenBoardPkg.fdf 
b/Platform/Intel/AlderlakeOpenBoardPkg/AlderlakePRvp/OpenBoardPkg.fdf
index ae7896e5e0..c8ceb8684c 100644
--- a/Platform/Intel/AlderlakeOpenBoardPkg/AlderlakePRvp/OpenBoardPkg.fdf
+++ b/Platform/Intel/AlderlakeOpenBoardPkg/AlderlakePRvp/OpenBoardPkg.fd
+++ f
@@ -1,7 +1,7 @@
 ## @file
 #  FDF file of Platform.
 #
-#   Copyright (c) 2022, Intel Corporation. All rights reserved.
+#   Copyright (c) 2022 - 2024, Intel Corporation. All rights reserved.
 #   SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -344,6 +344,14 @@ INF 
$(PLATFORM_BOARD_PACKAGE)/OpenBoardPlatformInit/OpenBoardPlatformInitPei/Ope
 INF 
$(PLATFORM_PACKAGE)/PlatformInit/SiliconPolicyPei/SiliconPolicyPeiPostMem.inf
 INF IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
 
+#
+# ADL FSP includes an older version of CpuMpPei, so the compatibility 
+PEIM # is needed when using FSP Dispatch mode.
+#
+!if gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection == 0
+  INF $(PLATFORM_PACKAGE)/FspWrapper/MpInfo2HobPei/MpInfo2HobPei.inf
+!endif
+
 
 [FV.FvPostMemory]
 BlockSize  = $(FLASH_BLOCK_SIZE)
--
2.44.0.windows.1



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




Re: [edk2-devel] 回复: [edk2-devel] [PATCH v2 03/13] OvmfPkg:PlatformCI: Support virtio-rng-pci

2024-05-10 Thread Doug Flick via groups.io
At a high level, this isn't my project and I would look towards the maintainers 
to provide guidance about the direction they want to go. 

However, 

In my opinion, this is a debate on Security vs Compatibility. I'm biased more 
towards security, and I've tried to make it easy for a platform to understand 
what is happening with `PcdEnforceSecureRngAlgorithms` . If we default to 
`default` the platform never has the chance to understand what Rng Algorithms 
they provide and if that is a problem for them. Default is obviously the most 
compatible but it's also the one that may or may not be backed by something 
insecure. Which is why I would prefer if a platform acknowledges that they know 
it's backed by something secure or if not its an active decision. 


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




回复: [edk2-devel] Soft Feature Freeze starts now for edk2-stable202405

2024-05-10 Thread gaoliming via groups.io
Stewards:

  Now, there are several patches to catch this table tag. Could you give the
comments for them?

 

1.  Adding support for verbose UEFI Table dumping to Dmem.c
(https://edk2.groups.io/g/devel/message/118582)

[Liming] This patch set has been reviewed before soft feature freeze. It
plans to catch this stable tag. 

 

2.  MdePkg/BaseLib: Fix AARCH64 compilation error
(https://edk2.groups.io/g/devel/message/118690)

[Liming] This bug fix is reviewed in soft feature freeze phase. It plans to
catch this stable tag. 

 

3.  MdeModulePkg: Potential UINT32 overflow in S3 ResumeCount (https://edk2.
groups.io/g/devel/message/118745)

[Liming] This security fix is reviewed in soft feature freeze phase. It
plans to catch this stable tag.

 

4.  NetworkPkg: CVE-2023-45236 and CVE-2023-45237
(https://edk2.groups.io/g/devel/message/118768)

[Liming] This security fix is still under code review. It plans to catch
this stable tag.

 

5.  Add more crypt APIs based on Mbedtls
(https://edk2.groups.io/g/devel/message/118772)

[Liming] This patch set passes code review in soft feature freeze phase. It
plans to catch this stable tag.

 

Thanks

Liming

发件人: devel@edk2.groups.io  代表 gaoliming via
groups.io
发送时间: 2024年5月7日 9:25
收件人: devel@edk2.groups.io; annou...@edk2.groups.io
抄送: 'Michael D Kinney' ; 'Andrew Fish'
; 'Leif Lindholm' 
主题: [edk2-devel] Soft Feature Freeze starts now for edk2-stable202405

 

Hi, all

 

  We enter into Soft Feature Freeze phase now. In this phase,

the feature under review will not be allowed to be pushed. The feature

passed review can still be merged.

 

  The patch review can continue without break in edk2 community. If the

patch is sent before Soft Feature Freeze, and plans to catch this stable
tag, the

patch contributor need reply to his patch and notify edk2 community. If the

patch is sent after Soft Feature Freeze, and plans to catch this stable tag,

please add edk2-stable202405 key words in the patch title and BZ, so the

community know this patch target and give the feedback.

 

  To avoid the unnecessary changes to be merged in edk2 stable tag release,

all edk2 maintainers' write access will be temporarily disabled until stable

tag is released on 05-24. That means edk2 maintainer can't set push label in

pull request after soft feature freeze starts.

 

  If the change wants to catch this stable tag 202405, please follow above

rules, then send the merge request to gaolim...@byosoft.com.cn
  or 

michael.d.kin...@intel.com  .

 

  We will help merge the code change in soft feature freeze and hard feature

freeze phase. 

 

Below is edk2-stable202405 tag planning Proposed Schedule

Date (00:00:00 UTC-8) Description

 

2024-02-23 Beginning of development

2024-05-06 Soft Feature Freeze

2024-05-10 Hard Feature Freeze

2024-05-24 Release

 

Thanks

Liming

 





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




Re: [edk2-devel] [PATCH 1/1] MdeModulePkg: Load Serial driver in early DXE

2024-05-10 Thread Borzeszkowski, Alan
Sorry, I did not provide full picture. After this discussion on devel I've 
linked, I spoke to Michael what changes would be in compliance with EDK2 driver 
model guidelines. An agreement was reached: Root Bridge driver that implements 
SIO Protocol and Serial I/O driver (with new entrypoint) that depends on SIO by 
DEPEX.

This way, driver would be a DXE Driver that runs new entrypoint only when SIO 
Protocol is present. I believe this approach doesn't violate UEFI Driver model 
rules since it uses standard DXE methods.

Also, the approach of modifying driver's entrypoint was suggested by Zhichao 
Gao.


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




Re: [edk2-devel] edk2-test Release candidate 2: edk2-test-rc2_202405 // RE: [PATCH v2 0/4] TCG2 protocol clean up

2024-05-10 Thread G Edhaya Chandran
Hi Chao,

   Yes, it is best to test based on the new tag at-least on one environment.

Note: The difference between old and new tag is mainly resolving build related 
issues.
There is no change in test coverage.

With WarM Regards,
Edhay


From: Chao Li 
Sent: Thursday, May 9, 2024 9:56 PM
To: devel@edk2.groups.io; G Edhaya Chandran ; David 
Wright ; Heinrich Schuchardt 

Cc: Alex Fox ; Stuart Yoder ; 
gao...@byosoft.com.cn
Subject: Re: [edk2-devel] edk2-test Release candidate 2: edk2-test-rc2_202405 
// RE: [PATCH v2 0/4] TCG2 protocol clean up


Hi Edhay,

Do I need to retest based on the edk2-test-rc2_202405 tag?

Thanks,
Chao
On 2024/5/10 10:43, G Edhaya Chandran wrote:
Thank you, David.
The results are well received.

With Warm Regards,
Edhay


From: David Wright 
Sent: Thursday, May 9, 2024 3:23 PM
To: G Edhaya Chandran 
; Heinrich Schuchardt 

Cc: Alex Fox ; 
lic...@loongson.cn; Stuart Yoder 
; 
devel@edk2.groups.io; 
gao...@byosoft.com.cn
Subject: RE: edk2-test Release candidate 2: edk2-test-rc2_202405 // RE: [PATCH 
v2 0/4] TCG2 protocol clean up

Hi all,

Phoenix has completed testing on edk2-test-rc2_202405

Results have been uploaded to their respective folders.

[cid:image001.png@01DAA2BF.53E23D80]


Thanks,
David Wright
QA Team Leader
david_wri...@phoenix.com
503-730-4537 Tel
[cid:image002.jpg@01DAA2BF.53E23D80]
www.phoenix.com
THIS MESSAGE MAY CONTAIN CONFIDENTIAL INFORMATION. UNLESS YOU ARE THE INTENDED 
RECIPIENT OF THIS MESSAGE, ANY USE OF THIS MESSAGE IS STRICTLY PROHIBITED. IF 
YOU HAVE RECEIVED THIS MESSAGE IN ERROR, PLEASE IMMEDIATELY NOTIFY THE SENDER 
BY TELEPHONE OR REPLY EMAIL, AND IMMEDIATELY DELETE THIS MESSAGE AND ALL COPIES.




From: G Edhaya Chandran 
mailto:edhaya.chand...@arm.com>>
Sent: Friday, May 3, 2024 4:47 PM
To: Heinrich Schuchardt 
mailto:heinrich.schucha...@canonical.com>>
Cc: Alex Fox mailto:alex_...@phoenix.com>>; David Wright 
mailto:david_wri...@phoenix.com>>; 
lic...@loongson.cn; Stuart Yoder 
mailto:stuart.yo...@arm.com>>; 
devel@edk2.groups.io; 
gao...@byosoft.com.cn
Subject: edk2-test Release candidate 2: edk2-test-rc2_202405 // RE: [PATCH v2 
0/4] TCG2 protocol clean up


[Caution, this message was sent from an external sender.]

Hi All,

   A new release candidate is published after upstreaming Stuart's commits on 
build cleanup.
https://github.com/tianocore/edk2-test/tree/edk2-test-rc2_202405

The updates since the old tag are the following commits in the patch series:
[PATCH v2 0/4] TCG2 protocol clean up 
(groups.io)

The release candidate may be used for any further testing.

With Warm Regards,
Edhay



> -Original Message-
> From: G Edhaya Chandran
> Sent: Tuesday, April 23, 2024 4:52 AM
> To: Heinrich Schuchardt 
> mailto:heinrich.schucha...@canonical.com>>
> Cc: alex_...@phoenix.com; 
> david_wri...@phoenix.com;
> lic...@loongson.cn; Stuart Yoder 
> mailto:stuart.yo...@arm.com>>;
> devel@edk2.groups.io; 
> gao...@byosoft.com.cn
> Subject: RE: [PATCH v2 0/4] TCG2 protocol clean up
>
> Hi Heinrich,
>
>Yes. A new release candidate shall be published after review and upstream
> of the patches.
> Will further send an update.
>
> With Warm Regards,
> Edhay
>
>
> > -Original Message-
> > From: Heinrich Schuchardt 
> > mailto:heinrich.schucha...@canonical.com>>
> > Sent: Tuesday, April 23, 2024 12:46 AM
> > To: G Edhaya Chandran 
> > mailto:edhaya.chand...@arm.com>>
> > Cc: alex_...@phoenix.com; 
> > david_wri...@phoenix.com;
> > lic...@loongson.cn; Stuart Yoder 
> > mailto:stuart.yo...@arm.com>>;
> > devel@edk2.groups.io; 
> > gao...@byosoft.com.cn
> > Subject: Re: [PATCH v2 0/4] TCG2 protocol clean up
> >
> > On 4/16/24 16:53, Stuart Yoder wrote:
> > > This patch series cleans up some issues found when building
> > > edk2-test with a non-GCC compiler:
> > >-TPMT_HA struct had an error due to incorrect use of C flexible
> > > array
> > member
> > >

[edk2-devel] [PATCH v2 1/1] MdeModulePkg: Warn if out of space when writing variables

2024-05-10 Thread Oliver Steffen
Emit a DEBUG_ERROR message if there is not enough flash variable left to
write/update a variable. This condition is currently not logged
appropriately in all cases, given that full variable store can easily
render the system unbootable.
This new message helps identifying this condition.

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Zhiguang Liu 

Signed-off-by: Oliver Steffen 
Reviewed-by: Laszlo Ersek 
Reviewed-by: Gerd Hoffmann 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index d394d237a53f..97317270c4a7 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -2364,6 +2364,8 @@ UpdateVariable (
   );
   ASSERT_EFI_ERROR (Status);
 }
+  } else if (Status == EFI_OUT_OF_RESOURCES) {
+DEBUG ((DEBUG_ERROR, "UpdateVariable failed: Out of variable space\n"));
   }
 
   return Status;
-- 
2.44.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118820): https://edk2.groups.io/g/devel/message/118820
Mute This Topic: https://groups.io/mt/106022074/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: Warn if out of space when writing variables

2024-05-10 Thread Oliver Steffen
Emit a DEBUG_ERROR message if there is not enough space left to
write/update a variable. This condition is currently not logged
appropriately in all cases, given that full variable store can easily
render the system unbootable.
This new message helps identifying this condition quickly.

Background:
We had the case where an OVMF based VM ran out of flash space after a
large number of reboots and hardware configuration changes. The MAC
address of the NIC was changing a lot over the life time of the VM. The
variable store was consumed entirely by networking related non-volatile
variables, written for each network card/MAC address present during
boot. Almost all of those were obsolete, of course, but the error that
presented itself at first was a VM that failed to boot the firmware and
ended up in an rather cryptic ASSERT message.

The hope is that this new message makes it easier for non-experts to
diagnose the situation.

The root cause is of course not addressed by this, but it might also be
hard to solve. One would have to identify obsolete network/hardware
settings somehow, but there is no way to tell if a certain NIC/MAC
might come back at a later point or not.


Launching OVMF with a full variable store then looks like this (Debug
Output):
[...]
CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize = 0x3FF60
UpdateVariable failed: Out of variable space
Select Item: 0xE
Select Item: 0x19
RecordVarErrorFlag (0xEF) Timeout:8BE4DF61-93CA-11D2-AA0D-00E098032B8C - 
0x0007 - 0x4E
CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize = 0x3FF60
UpdateVariable failed: Out of variable space
PlatformBootManagerBeforeConsole: SetVariable(Timeout, 3): Out of Resources
RecordVarErrorFlag (0xEF) BootOrder:8BE4DF61-93CA-11D2-AA0D-00E098032B8C - 
0x0007 - 0x52
CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize = 0x3FF60
UpdateVariable failed: Out of variable space

ASSERT_EFI_ERROR (Status = Out of Resources)
ASSERT OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c(361): 
!(((INTN)(RETURN_STATUS)(Status)) < 0)


PR: https://github.com/tianocore/edk2/pull/5435

Changes since v1:
- Mention "variable space" instead of "flash space"
- Emit DEBUG_ERROR instead of DEBUG_WARN

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Zhiguang Liu 

Oliver Steffen (1):
  MdeModulePkg: Warn if out of space when writing variables

 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 2 ++
 1 file changed, 2 insertions(+)

--
2.44.0



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




[edk2-devel] [PATCH v1 4/4] ShellPkg/Acpiview: Add EINJ Parser

2024-05-10 Thread levi.yun
Add a new parser for the Error Injection Table (EINJ).

The EINJ table provides machinism through which OSPM
can inject hardware errors to the platform without requiring platform
specific OSPM software.

Cc: Zhiguang Liu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Sami Mujawar 
Cc: Pierre Gondois 
Signed-off-by: levi.yun 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf | 
  1 +
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h| 
 21 ++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Einj/EinjParser.c   | 
358 
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c   | 
  1 +
 4 files changed, 381 insertions(+)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
index 
e62366116cb7d90c9202c6f0fd17b3306efd7800..9c2e2b703d267fb3ed9d631469d907106e7d4278
 100644
--- 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+++ 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
@@ -33,6 +33,7 @@ [Sources.common]
   Parsers/Bgrt/BgrtParser.c
   Parsers/Dbg2/Dbg2Parser.c
   Parsers/Dsdt/DsdtParser.c
+  Parsers/Einj/EinjParser.c
   Parsers/Erst/ErstParser.c
   Parsers/Facs/FacsParser.c
   Parsers/Fadt/FadtParser.c
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 
6468fe5d8cddf02d67f2d4705369064046c4a9a1..b41f110f6aa18f4f6806c849737f0b540a11152f
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -616,6 +616,27 @@ ParseAcpiDsdt (
   IN UINT8AcpiTableRevision
   );
 
+/**
+  This function parses the EINJ table.
+  When trace is enabled this function parses the EINJ table and
+  traces the ACPI table fields.
+
+  This function also performs validation of the ACPI table fields.
+
+  @param [in] Trace  If TRUE, trace the ACPI fields.
+  @param [in] PtrPointer to the start of the buffer.
+  @param [in] AcpiTableLengthLength of the ACPI table.
+  @param [in] AcpiTableRevision  Revision of the ACPI table.
+**/
+VOID
+EFIAPI
+ParseAcpiEinj (
+  IN BOOLEAN  Trace,
+  IN UINT8*Ptr,
+  IN UINT32   AcpiTableLength,
+  IN UINT8AcpiTableRevision
+  );
+
 /**
   This function parses the ACPI ERST table.
   When trace is enabled this function parses the ERST table and
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Einj/EinjParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Einj/EinjParser.c
new file mode 100644
index 
..508b082f908d76dc46e6ce92d9b4aa6c15998f95
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Einj/EinjParser.c
@@ -0,0 +1,358 @@
+/** @file
+  EINJ table parser
+
+  Copyright (c) 2024, Arm Limited.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Specification Reference:
+- ACPI 6.5, Table 18.3.2 ACPI Error Source
+**/
+
+#include 
+#include 
+
+#include "AcpiParser.h"
+#include "AcpiTableParser.h"
+#include "AcpiView.h"
+
+STATIC ACPI_DESCRIPTION_HEADER_INFO  mAcpiHdrInfo;
+STATIC UINT32*mEinjInjectionHdrSize;
+STATIC UINT32*mEinjInjectionEntryCnt;
+
+STATIC CONST CHAR16  *InstNameTable[] = {
+  L"READ_REGISTER",
+  L"READ_REGISTER_VALUE",
+  L"WRITE_REGISTER",
+  L"WRITE_REGISTER_VALUE",
+  L"NOOP",
+};
+
+/**
+  This function validates the flags field in the EINJ injection header.
+
+  @param [in] Ptr Pointer to the start of the field data.
+  @param [in] Context Pointer to context specific information e.g. this
+  could be a pointer to the ACPI table header.
+**/
+STATIC
+VOID
+EFIAPI
+ValidateInjectionFlags (
+  IN UINT8  *Ptr,
+  IN VOID   *Context
+  )
+{
+  UINT8  Flags;
+
+  Flags = *(UINT8 *)Ptr;
+
+  if (Flags != 0) {
+IncrementErrorCount ();
+Print (L"\nERROR: Injection Flags must be zero...");
+  }
+}
+
+/**
+  An ACPI_PARSER array describing the ACPI EINJ Table.
+**/
+STATIC CONST ACPI_PARSER  EinjParser[] = {
+  PARSE_ACPI_HEADER (),
+  { L"Injection Header Size",   4,  36, L"%d",   NULL, (VOID 
**),
+NULL,   NULL },
+  { L"Injection Flags", 1,  40, L"0x%x", NULL, NULL,   
 ValidateInjectionFlags,NULL },
+  { L"Reserved",3,  41, NULL,NULL, NULL,   
 NULL,  NULL },
+  { L"Injection Entry Count",   4,  44, L"%d",   NULL, (VOID 
**),
+NULL,   NULL },
+  /// Injection Action Table.
+  /// ...
+};
+
+/**
+  This function validates the injection action field in
+  the EINJ injection instruction entry.
+
+  @param [in] Ptr Pointer to the start of the field data.
+  

[edk2-devel] [PATCH v1 3/4] MdePkg/Include/IndustryStandard: Update EINJ information according to ACPI 6.5

2024-05-10 Thread levi.yun
ACPI 6.5 specification updates EINJ revision to 0x02 and
adds new Error Injection Actions
- EINJV2_SET_ERROR_TYPE
- EINJV2_GET_ERROR_TYPE

This patches updates EINJ information based on ACPI 6.5 specification.
Also, add missing Error Injection Actions too.

Cc: Zhiguang Liu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Sami Mujawar 
Cc: Pierre Gondois 
Signed-off-by: levi.yun 
---
 MdePkg/Include/IndustryStandard/Acpi65.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/Acpi65.h 
b/MdePkg/Include/IndustryStandard/Acpi65.h
index 
264869e86294a0170bcacde2ffb3f3786bd9aaff..387af78cfee07b162307f217f78dcd16c27971ae
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi65.h
+++ b/MdePkg/Include/IndustryStandard/Acpi65.h
@@ -2419,7 +2419,7 @@ typedef struct {
 ///
 /// EINJ Version (as defined in ACPI 6.5 spec.)
 ///
-#define EFI_ACPI_6_5_ERROR_INJECTION_TABLE_REVISION  0x01
+#define EFI_ACPI_6_5_ERROR_INJECTION_TABLE_REVISION  0x02
 
 ///
 /// EINJ Error Injection Actions
@@ -2433,7 +2433,9 @@ typedef struct {
 #define EFI_ACPI_6_5_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_6_5_EINJ_GET_COMMAND_STATUS  0x07
 #define EFI_ACPI_6_5_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
-#define EFI_ACPI_6_4_EINJ_GET_EXECUTE_OPERATION_TIMINGS   0x09
+#define EFI_ACPI_6_5_EINJ_GET_EXECUTE_OPERATION_TIMINGS   0x09
+#define EFI_ACPI_6_5_EINJ_EINJV2_SET_ERROR_TYPE   0x10
+#define EFI_ACPI_6_5_EINJ_EINJV2_GET_ERROR_TYPE   0x11
 #define EFI_ACPI_6_5_EINJ_TRIGGER_ERROR   0xFF
 
 ///
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



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




[edk2-devel] [PATCH v1 2/4] MdePkg/Include/IndustryStandard: Update GET_EXECUTE_OPERATION_TIMINGS Error Injection Actions

2024-05-10 Thread levi.yun


GET_EXECUTE_OPERATION_TIMINGS Error Injection Actions was added from
ACPI 6.1 specification.

Update Error Injection Action with the ACPI spec.

Cc: Zhiguang Liu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Sami Mujawar 
Cc: Pierre Gondois 
Signed-off-by: levi.yun 
---
 MdePkg/Include/IndustryStandard/Acpi61.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi62.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi63.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi64.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi65.h | 1 +
 5 files changed, 5 insertions(+)

diff --git a/MdePkg/Include/IndustryStandard/Acpi61.h 
b/MdePkg/Include/IndustryStandard/Acpi61.h
index 
94d72410138b8c2512586715ac521da3c5d2209d..5100d8b3b4193bbb9a2fd8cd818438190f2b79f1
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi61.h
+++ b/MdePkg/Include/IndustryStandard/Acpi61.h
@@ -1980,6 +1980,7 @@ typedef struct {
 #define EFI_ACPI_6_1_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_6_1_EINJ_GET_COMMAND_STATUS  0x07
 #define EFI_ACPI_6_1_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
+#define EFI_ACPI_6_1_EINJ_GET_EXECUTE_OPERATION_TIMINGS   0x09
 #define EFI_ACPI_6_1_EINJ_TRIGGER_ERROR   0xFF
 
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi62.h 
b/MdePkg/Include/IndustryStandard/Acpi62.h
index 
732e4d16c58df6d79c88f103d048e46d29386913..711b88b758ef0af2e8daf8d1d0fd07751fc634ed
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi62.h
+++ b/MdePkg/Include/IndustryStandard/Acpi62.h
@@ -2293,6 +2293,7 @@ typedef struct {
 #define EFI_ACPI_6_2_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_6_2_EINJ_GET_COMMAND_STATUS  0x07
 #define EFI_ACPI_6_2_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
+#define EFI_ACPI_6_2_EINJ_GET_EXECUTE_OPERATION_TIMINGS   0x09
 #define EFI_ACPI_6_2_EINJ_TRIGGER_ERROR   0xFF
 
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi63.h 
b/MdePkg/Include/IndustryStandard/Acpi63.h
index 
0cf984a840b9798f018f6a01ac0524e08e981175..68798da72576a465ed1950b99e49af696ea25b97
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi63.h
+++ b/MdePkg/Include/IndustryStandard/Acpi63.h
@@ -2253,6 +2253,7 @@ typedef struct {
 #define EFI_ACPI_6_3_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_6_3_EINJ_GET_COMMAND_STATUS  0x07
 #define EFI_ACPI_6_3_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
+#define EFI_ACPI_6_3_EINJ_GET_EXECUTE_OPERATION_TIMINGS   0x09
 #define EFI_ACPI_6_3_EINJ_TRIGGER_ERROR   0xFF
 
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h 
b/MdePkg/Include/IndustryStandard/Acpi64.h
index 
fd7b718ce47ca0d63e9f0b592622ea00dd1b8891..bbe6a3c9eb5c06a00ea1629c4430af4f99e6ed2f
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi64.h
+++ b/MdePkg/Include/IndustryStandard/Acpi64.h
@@ -2336,6 +2336,7 @@ typedef struct {
 #define EFI_ACPI_6_4_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_6_4_EINJ_GET_COMMAND_STATUS  0x07
 #define EFI_ACPI_6_4_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
+#define EFI_ACPI_6_4_EINJ_GET_EXECUTE_OPERATION_TIMINGS   0x09
 #define EFI_ACPI_6_4_EINJ_TRIGGER_ERROR   0xFF
 
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi65.h 
b/MdePkg/Include/IndustryStandard/Acpi65.h
index 
6721c42e475d23ee89c2f3373989a26e52d80d90..264869e86294a0170bcacde2ffb3f3786bd9aaff
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi65.h
+++ b/MdePkg/Include/IndustryStandard/Acpi65.h
@@ -2433,6 +2433,7 @@ typedef struct {
 #define EFI_ACPI_6_5_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_6_5_EINJ_GET_COMMAND_STATUS  0x07
 #define EFI_ACPI_6_5_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
+#define EFI_ACPI_6_4_EINJ_GET_EXECUTE_OPERATION_TIMINGS   0x09
 #define EFI_ACPI_6_5_EINJ_TRIGGER_ERROR   0xFF
 
 ///
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



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




[edk2-devel] [PATCH v1 1/4] MdePkg/Include/IndustryStandard: Update SET_ERROR_TYPE_WITH_ADDRESS Error Injection Actions

2024-05-10 Thread levi.yun
SET_ERROR_TYPE_WITH_ADDRESS Error Injection Actions was added from
ACPI 5.1 specification.

Update Error Injection Action with the ACPI spec.

Cc: Zhiguang Liu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Sami Mujawar 
Cc: Pierre Gondois 
Signed-off-by: levi.yun 
---
 MdePkg/Include/IndustryStandard/Acpi51.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi60.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi61.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi62.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi63.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi64.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi65.h | 1 +
 7 files changed, 7 insertions(+)

diff --git a/MdePkg/Include/IndustryStandard/Acpi51.h 
b/MdePkg/Include/IndustryStandard/Acpi51.h
index 
4241b8f198f1d81cc9b9d6d8797e955ed1211a53..cdf95386d27add7e72f4f8e82b0d23671a3e294d
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi51.h
+++ b/MdePkg/Include/IndustryStandard/Acpi51.h
@@ -1760,6 +1760,7 @@ typedef struct {
 #define EFI_ACPI_5_1_EINJ_EXECUTE_OPERATION   0x05
 #define EFI_ACPI_5_1_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_5_1_EINJ_GET_COMMAND_STATUS  0x07
+#define EFI_ACPI_5_1_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
 #define EFI_ACPI_5_1_EINJ_TRIGGER_ERROR   0xFF
 
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi60.h 
b/MdePkg/Include/IndustryStandard/Acpi60.h
index 
3757d3f82792e812e85a6aef0f9e3e65b96591f8..d545de1ba2be0e30aeb8422dec95358ac364c44b
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi60.h
+++ b/MdePkg/Include/IndustryStandard/Acpi60.h
@@ -1947,6 +1947,7 @@ typedef struct {
 #define EFI_ACPI_6_0_EINJ_EXECUTE_OPERATION   0x05
 #define EFI_ACPI_6_0_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_6_0_EINJ_GET_COMMAND_STATUS  0x07
+#define EFI_ACPI_6_0_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
 #define EFI_ACPI_6_0_EINJ_TRIGGER_ERROR   0xFF
 
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi61.h 
b/MdePkg/Include/IndustryStandard/Acpi61.h
index 
c3facc6e376e715b3e790efa18d9eb75ad0b2ded..94d72410138b8c2512586715ac521da3c5d2209d
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi61.h
+++ b/MdePkg/Include/IndustryStandard/Acpi61.h
@@ -1979,6 +1979,7 @@ typedef struct {
 #define EFI_ACPI_6_1_EINJ_EXECUTE_OPERATION   0x05
 #define EFI_ACPI_6_1_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_6_1_EINJ_GET_COMMAND_STATUS  0x07
+#define EFI_ACPI_6_1_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
 #define EFI_ACPI_6_1_EINJ_TRIGGER_ERROR   0xFF
 
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi62.h 
b/MdePkg/Include/IndustryStandard/Acpi62.h
index 
4dd3e21c232554cb5b3d322f57f55363e2c98ae1..732e4d16c58df6d79c88f103d048e46d29386913
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi62.h
+++ b/MdePkg/Include/IndustryStandard/Acpi62.h
@@ -2292,6 +2292,7 @@ typedef struct {
 #define EFI_ACPI_6_2_EINJ_EXECUTE_OPERATION   0x05
 #define EFI_ACPI_6_2_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_6_2_EINJ_GET_COMMAND_STATUS  0x07
+#define EFI_ACPI_6_2_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
 #define EFI_ACPI_6_2_EINJ_TRIGGER_ERROR   0xFF
 
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi63.h 
b/MdePkg/Include/IndustryStandard/Acpi63.h
index 
7582dccf649b2f0b2308c3e9635b5767e86811ba..0cf984a840b9798f018f6a01ac0524e08e981175
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi63.h
+++ b/MdePkg/Include/IndustryStandard/Acpi63.h
@@ -2252,6 +2252,7 @@ typedef struct {
 #define EFI_ACPI_6_3_EINJ_EXECUTE_OPERATION   0x05
 #define EFI_ACPI_6_3_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_6_3_EINJ_GET_COMMAND_STATUS  0x07
+#define EFI_ACPI_6_3_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
 #define EFI_ACPI_6_3_EINJ_TRIGGER_ERROR   0xFF
 
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h 
b/MdePkg/Include/IndustryStandard/Acpi64.h
index 
faf069a0454e8cf97c4e9767b1c10c37754002a3..fd7b718ce47ca0d63e9f0b592622ea00dd1b8891
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi64.h
+++ b/MdePkg/Include/IndustryStandard/Acpi64.h
@@ -2335,6 +2335,7 @@ typedef struct {
 #define EFI_ACPI_6_4_EINJ_EXECUTE_OPERATION   0x05
 #define EFI_ACPI_6_4_EINJ_CHECK_BUSY_STATUS   0x06
 #define EFI_ACPI_6_4_EINJ_GET_COMMAND_STATUS  0x07
+#define EFI_ACPI_6_4_EINJ_SET_ERROR_TYPE_WITH_ADDRESS 0x08
 #define EFI_ACPI_6_4_EINJ_TRIGGER_ERROR   0xFF
 
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi65.h 
b/MdePkg/Include/IndustryStandard/Acpi65.h
index 
b9616a3e29c26ed20dafca624d08679a60d95d61..6721c42e475d23ee89c2f3373989a26e52d80d90
 100644
--- a/MdePkg/Include/IndustryStandard/Acpi65.h
+++ b/MdePkg/Include/IndustryStandard/Acpi65.h
@@ -2432,6 +2432,7 @@ typedef struct {
 #define EFI_ACPI_6_5_EINJ_EXECUTE_OPERATION   0x05
 #define 

[edk2-devel] [PATCH v1 0/4] Add EINJ table parser.

2024-05-10 Thread levi.yun
Add Error Injection Table (EINJ) parser for AcpiView and
add some missing Error Injection Action definitions in each Acpi*
headers.

The changes can be seen at:
https://github.com/LeviYeoReum/edk2/tree/levi/3075_einj_table_v1


levi.yun (4):
  MdePkg/Include/IndustryStandard: Update SET_ERROR_TYPE_WITH_ADDRESS
Error Injection Actions
  MdePkg/Include/IndustryStandard: Update GET_EXECUTE_OPERATION_TIMINGS
Error Injection Actions
  MdePkg/Include/IndustryStandard: Update EINJ information according to
ACPI 6.5
  ShellPkg/Acpiview: Add EINJ Parser

 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf | 
  1 +
 MdePkg/Include/IndustryStandard/Acpi51.h | 
  1 +
 MdePkg/Include/IndustryStandard/Acpi60.h | 
  1 +
 MdePkg/Include/IndustryStandard/Acpi61.h | 
  2 +
 MdePkg/Include/IndustryStandard/Acpi62.h | 
  2 +
 MdePkg/Include/IndustryStandard/Acpi63.h | 
  2 +
 MdePkg/Include/IndustryStandard/Acpi64.h | 
  2 +
 MdePkg/Include/IndustryStandard/Acpi65.h | 
  6 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h| 
 21 ++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Einj/EinjParser.c   | 
358 
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c   | 
  1 +
 11 files changed, 396 insertions(+), 1 deletion(-)
 create mode 100644 
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Einj/EinjParser.c

--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



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




[edk2-devel] [PATCH] NetworkPkg:HttpDxe:CoverityIssues

2024-05-10 Thread Santhosh Kumar V via groups.io
Resolved Coverity Issues in Http Dxe
1.HttpResponseWorker(DEADCODE)
The result of pointer arithmetic "HttpHeaders + AsciiStrLen("HTTP/1.1") + 1" is 
never null.
2.HttpDns4 (DEAD LOOP)
Coverity reports dead loop error since IsDone is always false ,In Some scenario 
it might not update the to true
3.HttpsSupport.c (NULL_RETURNS)
NetbufAlloc ,NetbufAllocSpace might return null pointer ,so Assigning: "NULL" 
to "PacketOut" and "DataOut" pointer.

Cc: Saloni Kasbekar 
Cc: Zachary Clark-williams 

Signed-off-by: SanthoshKumarV 
---
 NetworkPkg/HttpDxe/HttpDns.c  |  2 +-
 NetworkPkg/HttpDxe/HttpImpl.c |  5 +
 NetworkPkg/HttpDxe/HttpsSupport.c | 21 -
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpDns.c b/NetworkPkg/HttpDxe/HttpDns.c
index 13cbde0f34..b8ac6fba4b 100644
--- a/NetworkPkg/HttpDxe/HttpDns.c
+++ b/NetworkPkg/HttpDxe/HttpDns.c
@@ -150,7 +150,7 @@ HttpDns4 (
 goto Exit;

   }



-  while (!IsDone) {

+  while (!IsDone && (Dns4->Poll != NULL)) {

 Dns4->Poll (Dns4);

   }



diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 6606c29342..6d05c203b0 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -1104,10 +1104,7 @@ HttpResponseWorker (
 // Search for Status Code.

 //

 StatusCodeStr = HttpHeaders + AsciiStrLen (HTTP_VERSION_STR) + 1;

-if (StatusCodeStr == NULL) {

-  Status = EFI_NOT_READY;

-  goto Error;

-}

+



 StatusCode = AsciiStrDecimalToUintn (StatusCodeStr);



diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c 
b/NetworkPkg/HttpDxe/HttpsSupport.c
index 8d7bffe1e9..e40386a99c 100644
--- a/NetworkPkg/HttpDxe/HttpsSupport.c
+++ b/NetworkPkg/HttpDxe/HttpsSupport.c
@@ -732,7 +732,6 @@ TlsConfigureSession (
   // the caller. The failure is pushed back to TLS DXE driver if the

   // HTTP communication actually requires certificate.

   //

-  Status = EFI_SUCCESS;

 } else {

   DEBUG ((DEBUG_ERROR, "TLS Certificate Config Error!\n"));

   return Status;

@@ -1250,6 +1249,10 @@ TlsConnectSession (
   // Transmit ClientHello

   //

   PacketOut = NetbufAlloc ((UINT32)BufferOutSize);

+  if (PacketOut == NULL) {

+  FreePool (BufferOut);

+  return EFI_OUT_OF_RESOURCES;

+  }

   DataOut   = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, 
NET_BUF_TAIL);

   if (DataOut == NULL) {

 FreePool (BufferOut);

@@ -1336,6 +1339,10 @@ TlsConnectSession (
   // Transmit the response packet.

   //

   PacketOut = NetbufAlloc ((UINT32)BufferOutSize);

+  if (PacketOut == NULL) {

+FreePool (BufferOut);

+return EFI_OUT_OF_RESOURCES;

+}

   DataOut   = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, 
NET_BUF_TAIL);

   if (DataOut == NULL) {

 FreePool (BufferOut);

@@ -1493,6 +1500,10 @@ TlsCloseSession (
   }



   PacketOut = NetbufAlloc ((UINT32)BufferOutSize);

+  if (PacketOut == NULL) {

+FreePool (BufferOut);

+return EFI_OUT_OF_RESOURCES;

+  }

   DataOut   = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, 
NET_BUF_TAIL);

   if (DataOut == NULL) {

 FreePool (BufferOut);

@@ -1781,6 +1792,10 @@ HttpsReceive (


 if (BufferOutSize != 0) {

   PacketOut = NetbufAlloc ((UINT32)BufferOutSize);

+  if (PacketOut == NULL) {

+FreePool (BufferOut);

+return EFI_OUT_OF_RESOURCES;

+  }

   DataOut   = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, 
NET_BUF_TAIL);

   if (DataOut == NULL) {

 FreePool (BufferOut);

@@ -1873,6 +1888,10 @@ HttpsReceive (


 if (BufferOutSize != 0) {

   PacketOut = NetbufAlloc ((UINT32)BufferOutSize);

+  if (PacketOut == NULL) {

+FreePool (BufferOut);

+return EFI_OUT_OF_RESOURCES;

+  }

   DataOut   = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, 
NET_BUF_TAIL);

   if (DataOut == NULL) {

 FreePool (BufferOut);

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


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




[edk2-devel] [PATCH] NetworkPkg:HttpDxe:CoverityIssues

2024-05-10 Thread Santhosh Kumar V via groups.io
Resolved Coverity Issues in Http Dxe
1.HttpResponseWorker(DEADCODE)
The result of pointer arithmetic "HttpHeaders + AsciiStrLen("HTTP/1.1") + 1" is 
never null.
2.HttpDns4 (DEAD LOOP)
Coverity reports dead loop error since IsDone is always false ,In Some scenario 
it might not update the to true
3.HttpsSupport.c (NULL_RETURNS)
NetbufAlloc ,NetbufAllocSpace might return null pointer ,so Assigning: "NULL" 
to "PacketOut" and "DataOut" pointer.
---
 NetworkPkg/HttpDxe/HttpDns.c  |  2 +-
 NetworkPkg/HttpDxe/HttpImpl.c |  5 +
 NetworkPkg/HttpDxe/HttpsSupport.c | 21 -
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpDns.c b/NetworkPkg/HttpDxe/HttpDns.c
index 13cbde0f34..b8ac6fba4b 100644
--- a/NetworkPkg/HttpDxe/HttpDns.c
+++ b/NetworkPkg/HttpDxe/HttpDns.c
@@ -150,7 +150,7 @@ HttpDns4 (
 goto Exit;

   }



-  while (!IsDone) {

+  while (!IsDone && (Dns4->Poll != NULL)) {

 Dns4->Poll (Dns4);

   }



diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 6606c29342..6d05c203b0 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -1104,10 +1104,7 @@ HttpResponseWorker (
 // Search for Status Code.

 //

 StatusCodeStr = HttpHeaders + AsciiStrLen (HTTP_VERSION_STR) + 1;

-if (StatusCodeStr == NULL) {

-  Status = EFI_NOT_READY;

-  goto Error;

-}

+



 StatusCode = AsciiStrDecimalToUintn (StatusCodeStr);



diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c 
b/NetworkPkg/HttpDxe/HttpsSupport.c
index 8d7bffe1e9..e40386a99c 100644
--- a/NetworkPkg/HttpDxe/HttpsSupport.c
+++ b/NetworkPkg/HttpDxe/HttpsSupport.c
@@ -732,7 +732,6 @@ TlsConfigureSession (
   // the caller. The failure is pushed back to TLS DXE driver if the

   // HTTP communication actually requires certificate.

   //

-  Status = EFI_SUCCESS;

 } else {

   DEBUG ((DEBUG_ERROR, "TLS Certificate Config Error!\n"));

   return Status;

@@ -1250,6 +1249,10 @@ TlsConnectSession (
   // Transmit ClientHello

   //

   PacketOut = NetbufAlloc ((UINT32)BufferOutSize);

+  if (PacketOut == NULL) {

+  FreePool (BufferOut);

+  return EFI_OUT_OF_RESOURCES;

+  }

   DataOut   = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, 
NET_BUF_TAIL);

   if (DataOut == NULL) {

 FreePool (BufferOut);

@@ -1336,6 +1339,10 @@ TlsConnectSession (
   // Transmit the response packet.

   //

   PacketOut = NetbufAlloc ((UINT32)BufferOutSize);

+  if (PacketOut == NULL) {

+FreePool (BufferOut);

+return EFI_OUT_OF_RESOURCES;

+}

   DataOut   = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, 
NET_BUF_TAIL);

   if (DataOut == NULL) {

 FreePool (BufferOut);

@@ -1493,6 +1500,10 @@ TlsCloseSession (
   }



   PacketOut = NetbufAlloc ((UINT32)BufferOutSize);

+  if (PacketOut == NULL) {

+FreePool (BufferOut);

+return EFI_OUT_OF_RESOURCES;

+  }

   DataOut   = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, 
NET_BUF_TAIL);

   if (DataOut == NULL) {

 FreePool (BufferOut);

@@ -1781,6 +1792,10 @@ HttpsReceive (


 if (BufferOutSize != 0) {

   PacketOut = NetbufAlloc ((UINT32)BufferOutSize);

+  if (PacketOut == NULL) {

+FreePool (BufferOut);

+return EFI_OUT_OF_RESOURCES;

+  }

   DataOut   = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, 
NET_BUF_TAIL);

   if (DataOut == NULL) {

 FreePool (BufferOut);

@@ -1873,6 +1888,10 @@ HttpsReceive (


 if (BufferOutSize != 0) {

   PacketOut = NetbufAlloc ((UINT32)BufferOutSize);

+  if (PacketOut == NULL) {

+FreePool (BufferOut);

+return EFI_OUT_OF_RESOURCES;

+  }

   DataOut   = NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, 
NET_BUF_TAIL);

   if (DataOut == NULL) {

 FreePool (BufferOut);

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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118812): https://edk2.groups.io/g/devel/message/118812
Mute This Topic: https://groups.io/mt/106018538/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 07/13] SecurityPkg: RngDxe: Remove incorrect limitation on GetRng

2024-05-10 Thread Yao, Jiewen
Hi Doug
First, I agree with you that "A caller is free to request less than 256 bit".

Second, I think we still need to meet 256 bit entropy requirement in UEFI spec, 
right?
With above assumption, I checked how the callee is implemented when input 
length is small.

https://github.com/tianocore/edk2/blob/master/SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c#L54-L59

EntropyBits = MIN ((RequiredEntropyBits - CollectedEntropyBits), MaxBits);
Status  = GetArmTrngEntropy (
EntropyBits,
(Length - Index),
[Index]
);

It seems to me that the EntropyBits is also less than 256, when the input 
requirement is less than 256 bit.

Would you please double check that, to see if the requirement is still 
satisfied?
Please correct me if my understanding is wrong.


Thank you
Yao, Jiewen



> -Original Message-
> From: Doug Flick 
> Sent: Thursday, May 9, 2024 1:56 PM
> To: devel@edk2.groups.io
> Cc: Yao, Jiewen 
> Subject: [PATCH v2 07/13] SecurityPkg: RngDxe: Remove incorrect limitation on
> GetRng
> 
> Removed from gEfiRngAlgorithmRaw an incorrect assumption that
> Raw cannot return less than 256 bits. The DRNG Algorithms
> should always use a 256 bit seed as per nist standards
> however a caller is free to request less than 256 bits.
> >
> > //
> >// When a DRBG is used on the output of a entropy source,
> >// its security level must be at least 256 bits according to UEFI Spec.
> >//
> >if (RNGValueLength < 32) {
> >  return EFI_INVALID_PARAMETER;
> >}
> >
> 
> AARCH64 platforms do not have this limitation and this brings both
> implementations into alignment with each other and the spec.
> 
> Cc: Jiewen Yao 
> 
> Signed-off-by: Doug Flick [MSFT] 
> ---
>  SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 8 
>  1 file changed, 8 deletions(-)
> 
> diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
> b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
> index 7e06e16e4be5..5723ed695747 100644
> --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
> +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
> @@ -116,14 +116,6 @@ RngGetRNG (
>// The "raw" algorithm is intended to provide entropy directly
> 
>//
> 
>if (CompareGuid (RNGAlgorithm, )) {
> 
> -//
> 
> -// When a DRBG is used on the output of a entropy source,
> 
> -// its security level must be at least 256 bits according to UEFI Spec.
> 
> -//
> 
> -if (RNGValueLength < 32) {
> 
> -  return EFI_INVALID_PARAMETER;
> 
> -}
> 
> -
> 
>  Status = GenerateEntropy (RNGValueLength, RNGValue);
> 
>  return Status;
> 
>}
> 
> --
> 2.34.1



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




[edk2-devel] [PATCH 18/18] MdeModulePkg:Remove MpService2Ppi field in SMM_S3_RESUME_STATE

2024-05-10 Thread duntan
This MpService2Ppi field in SMM_S3_RESUME_STATE is used to
wakeup AP to do the CPU initialization during smm s3 boot when
the execution mode of PEI and DXE are the same.
Currently, in CpuS3.c of smm cpu driver, BSP doesn't need to
wakeup AP anymore. The initialization for AP will be done in
S3Resume.c before transfer to CpuS3.c of smm cpu driver.
So we can remove the MpService2Ppi field in SMM_S3_RESUME_STATE.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Liming Gao 
---
 MdeModulePkg/Include/Guid/AcpiS3Context.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/MdeModulePkg/Include/Guid/AcpiS3Context.h 
b/MdeModulePkg/Include/Guid/AcpiS3Context.h
index 72d173c4fd..0cfc81b49b 100644
--- a/MdeModulePkg/Include/Guid/AcpiS3Context.h
+++ b/MdeModulePkg/Include/Guid/AcpiS3Context.h
@@ -30,7 +30,6 @@ typedef struct {
   EFI_PHYSICAL_ADDRESSReturnContext1;
   EFI_PHYSICAL_ADDRESSReturnContext2;
   EFI_PHYSICAL_ADDRESSReturnStackPointer;
-  EFI_PHYSICAL_ADDRESSMpService2Ppi;
   EFI_PHYSICAL_ADDRESSSmst;
 } SMM_S3_RESUME_STATE;
 
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 17/18] UefiCpuPkg: Remove GetAcpiCpuData() in CpuS3.c

2024-05-10 Thread duntan
Remove GetAcpiCpuData() in CpuS3.c. The mAcpiCpuData
is not needed in S3 boot anymore.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c  | 243 
+--
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c |   6 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h |  24 
 3 files changed, 3 insertions(+), 270 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index e84bc14de0..78ecf4efc6 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -9,22 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include "PiSmmCpuDxeSmm.h"
 #include 
 
-//
-// Flags used when program the register.
-//
-typedef struct {
-  volatile UINTN MemoryMappedLock;  // Spinlock used to 
program mmio
-  volatile UINT32*CoreSemaphoreCount;   // Semaphore container 
used to program
-// core level semaphore.
-  volatile UINT32*PackageSemaphoreCount;// Semaphore container 
used to program
-// package level semaphore.
-} PROGRAM_CPU_REGISTER_FLAGS;
-
-#define LEGACY_REGION_SIZE  (2 * 0x1000)
-#define LEGACY_REGION_BASE  (0xA - LEGACY_REGION_SIZE)
-
-ACPI_CPU_DATA  mAcpiCpuData;
-BOOLEANmRestoreSmmConfigurationInS3 = FALSE;
+BOOLEAN  mRestoreSmmConfigurationInS3 = FALSE;
 
 //
 // S3 boot flag
@@ -266,232 +251,6 @@ InitSmmS3ResumeState (
   }
 }
 
-/**
-  Copy register table from non-SMRAM into SMRAM.
-
-  @param[in] DestinationRegisterTableList  Points to destination register 
table.
-  @param[in] SourceRegisterTableList   Points to source register table.
-  @param[in] NumberOfCpus  Number of CPUs.
-
-**/
-VOID
-CopyRegisterTable (
-  IN CPU_REGISTER_TABLE  *DestinationRegisterTableList,
-  IN CPU_REGISTER_TABLE  *SourceRegisterTableList,
-  IN UINT32  NumberOfCpus
-  )
-{
-  UINTN Index;
-  CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntry;
-
-  CopyMem (DestinationRegisterTableList, SourceRegisterTableList, NumberOfCpus 
* sizeof (CPU_REGISTER_TABLE));
-  for (Index = 0; Index < NumberOfCpus; Index++) {
-if (DestinationRegisterTableList[Index].TableLength != 0) {
-  DestinationRegisterTableList[Index].AllocatedSize = 
DestinationRegisterTableList[Index].TableLength * sizeof 
(CPU_REGISTER_TABLE_ENTRY);
-  RegisterTableEntry= AllocateCopyPool (
-
DestinationRegisterTableList[Index].AllocatedSize,
-(VOID 
*)(UINTN)SourceRegisterTableList[Index].RegisterTableEntry
-);
-  ASSERT (RegisterTableEntry != NULL);
-  DestinationRegisterTableList[Index].RegisterTableEntry = 
(EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTableEntry;
-}
-  }
-}
-
-/**
-  Check whether the register table is empty or not.
-
-  @param[in] RegisterTable  Point to the register table.
-  @param[in] NumberOfCpus   Number of CPUs.
-
-  @retval TRUE  The register table is empty.
-  @retval FALSE The register table is not empty.
-**/
-BOOLEAN
-IsRegisterTableEmpty (
-  IN CPU_REGISTER_TABLE  *RegisterTable,
-  IN UINT32  NumberOfCpus
-  )
-{
-  UINTN  Index;
-
-  if (RegisterTable != NULL) {
-for (Index = 0; Index < NumberOfCpus; Index++) {
-  if (RegisterTable[Index].TableLength != 0) {
-return FALSE;
-  }
-}
-  }
-
-  return TRUE;
-}
-
-/**
-  Copy the data used to initialize processor register into SMRAM.
-
-  @param[in,out]  CpuFeatureInitDataDst   Pointer to the destination 
CPU_FEATURE_INIT_DATA structure.
-  @param[in]  CpuFeatureInitDataSrc   Pointer to the source 
CPU_FEATURE_INIT_DATA structure.
-
-**/
-VOID
-CopyCpuFeatureInitDatatoSmram (
-  IN OUT CPU_FEATURE_INIT_DATA  *CpuFeatureInitDataDst,
-  IN CPU_FEATURE_INIT_DATA  *CpuFeatureInitDataSrc
-  )
-{
-  CPU_STATUS_INFORMATION  *CpuStatus;
-
-  if (!IsRegisterTableEmpty ((CPU_REGISTER_TABLE 
*)(UINTN)CpuFeatureInitDataSrc->PreSmmInitRegisterTable, 
mAcpiCpuData.NumberOfCpus)) {
-CpuFeatureInitDataDst->PreSmmInitRegisterTable = 
(EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (mAcpiCpuData.NumberOfCpus * sizeof 
(CPU_REGISTER_TABLE));
-ASSERT (CpuFeatureInitDataDst->PreSmmInitRegisterTable != 0);
-
-CopyRegisterTable (
-  (CPU_REGISTER_TABLE 
*)(UINTN)CpuFeatureInitDataDst->PreSmmInitRegisterTable,
-  (CPU_REGISTER_TABLE 
*)(UINTN)CpuFeatureInitDataSrc->PreSmmInitRegisterTable,
- 

[edk2-devel] [PATCH 14/18] UefiCpuPkg: Remove code to set register table

2024-05-10 Thread duntan
Remove code to set register table in CpuS3.c.
In previous commit, PcdCpuFeaturesInitOnS3Resume
has been set to TRUE. So that CpuFeaturesPei PEIM
will initialize the CPU registers and perform CPU
features initialization.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 423 
---
 1 file changed, 423 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 7ac6b62676..9520451d92 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -91,425 +91,6 @@ UINT8  mApHltLoopCodeTemplate[] = {
   0xEB, 0xFC  // jmp $-2
 };
 
-/**
-  Increment semaphore by 1.
-
-  @param  SemIN:  32-bit unsigned integer
-
-**/
-VOID
-S3ReleaseSemaphore (
-  IN OUT  volatile UINT32  *Sem
-  )
-{
-  InterlockedIncrement (Sem);
-}
-
-/**
-  Decrement the semaphore by 1 if it is not zero.
-
-  Performs an atomic decrement operation for semaphore.
-  The compare exchange operation must be performed using
-  MP safe mechanisms.
-
-  @param  SemIN:  32-bit unsigned integer
-
-**/
-VOID
-S3WaitForSemaphore (
-  IN OUT  volatile UINT32  *Sem
-  )
-{
-  UINT32  Value;
-
-  do {
-Value = *Sem;
-  } while (Value == 0 ||
-   InterlockedCompareExchange32 (
- Sem,
- Value,
- Value - 1
- ) != Value);
-}
-
-/**
-  Read / write CR value.
-
-  @param[in]  CrIndex The CR index which need to read/write.
-  @param[in]  ReadRead or write. TRUE is read.
-  @param[in,out]  CrValue CR value.
-
-  @retvalEFI_SUCCESS means read/write success, else return EFI_UNSUPPORTED.
-**/
-UINTN
-ReadWriteCr (
-  IN UINT32   CrIndex,
-  IN BOOLEAN  Read,
-  IN OUT UINTN*CrValue
-  )
-{
-  switch (CrIndex) {
-case 0:
-  if (Read) {
-*CrValue = AsmReadCr0 ();
-  } else {
-AsmWriteCr0 (*CrValue);
-  }
-
-  break;
-case 2:
-  if (Read) {
-*CrValue = AsmReadCr2 ();
-  } else {
-AsmWriteCr2 (*CrValue);
-  }
-
-  break;
-case 3:
-  if (Read) {
-*CrValue = AsmReadCr3 ();
-  } else {
-AsmWriteCr3 (*CrValue);
-  }
-
-  break;
-case 4:
-  if (Read) {
-*CrValue = AsmReadCr4 ();
-  } else {
-AsmWriteCr4 (*CrValue);
-  }
-
-  break;
-default:
-  return EFI_UNSUPPORTED;
-  }
-
-  return EFI_SUCCESS;
-}
-
-/**
-  Initialize the CPU registers from a register table.
-
-  @param[in]  RegisterTable The register table for this AP.
-  @param[in]  ApLocationAP location info for this ap.
-  @param[in]  CpuStatus CPU status info for this CPU.
-  @param[in]  CpuFlags  Flags data structure used when program the 
register.
-
-  @note This service could be called by BSP/APs.
-**/
-VOID
-ProgramProcessorRegister (
-  IN CPU_REGISTER_TABLE  *RegisterTable,
-  IN EFI_CPU_PHYSICAL_LOCATION   *ApLocation,
-  IN CPU_STATUS_INFORMATION  *CpuStatus,
-  IN PROGRAM_CPU_REGISTER_FLAGS  *CpuFlags
-  )
-{
-  CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntry;
-  UINTN Index;
-  UINTN Value;
-  CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntryHead;
-  volatile UINT32   *SemaphorePtr;
-  UINT32FirstThread;
-  UINT32CurrentThread;
-  UINT32CurrentCore;
-  UINTN ProcessorIndex;
-  UINT32*ThreadCountPerPackage;
-  UINT8 *ThreadCountPerCore;
-  EFI_STATUSStatus;
-  UINT64CurrentValue;
-
-  //
-  // Traverse Register Table of this logical processor
-  //
-  RegisterTableEntryHead = (CPU_REGISTER_TABLE_ENTRY 
*)(UINTN)RegisterTable->RegisterTableEntry;
-
-  for (Index = 0; Index < RegisterTable->TableLength; Index++) {
-RegisterTableEntry = [Index];
-
-//
-// Check the type of specified register
-//
-switch (RegisterTableEntry->RegisterType) {
-  //
-  // The specified register is Control Register
-  //
-  case ControlRegister:
-Status = ReadWriteCr (RegisterTableEntry->Index, TRUE, );
-if (EFI_ERROR (Status)) {
-  break;
-}
-
-if (RegisterTableEntry->TestThenWrite) {
-  CurrentValue = BitFieldRead64 (
-   Value,
-   RegisterTableEntry->ValidBitStart,
-  

[edk2-devel] [PATCH 16/18] UefiCpuPkg:Remove code to wakeup AP and relocate ap

2024-05-10 Thread duntan
After the code to load mtrr setting, set register table,
handle APIC setting and Interrupt after INIT-SIPI-SIPI
is moved, the InitializeCpuProcedure() only contains
following code logic:
1.Bsp runs ExecuteFirstSmiInit().
2.Bsp transfers AP to safe hlt-loop

During S3 boot, since APs will be relocated to new safe
buffer by the callback of gEdkiiEndOfS3ResumeGuid in
PeiMpLib, Bsp doesn't need to transfer AP to safe hlt-loop
any more. SmmRestoreCpu() in CpuS3 only needs to runs the
ExecuteFirstSmiInit() on BSP. So remove code to wakeup
AP by INIT-SIPI-SIPI and remove code to relocate ap to
safe hlt-loop.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 292 
+---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm   | 153 
-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c |  27 ---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf  |   3 ---
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm| 189 
-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c  |  28 

 6 files changed, 9 insertions(+), 683 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 65fe903fd3..e84bc14de0 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -8,30 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include "PiSmmCpuDxeSmm.h"
 #include 
-#include 
-
-#pragma pack(1)
-typedef struct {
-  UINTN  Lock;
-  VOID   *StackStart;
-  UINTN  StackSize;
-  VOID   *ApFunction;
-  IA32_DESCRIPTORGdtrProfile;
-  IA32_DESCRIPTORIdtrProfile;
-  UINT32 BufferStart;
-  UINT32 Cr3;
-  UINTN  InitializeFloatingPointUnitsAddress;
-} MP_CPU_EXCHANGE_INFO;
-#pragma pack()
-
-typedef struct {
-  UINT8*RendezvousFunnelAddress;
-  UINTNPModeEntryOffset;
-  UINTNFlatJumpOffset;
-  UINTNSize;
-  UINTNLModeEntryOffset;
-  UINTNLongJumpOffset;
-} MP_ASSEMBLY_ADDRESS_MAP;
 
 //
 // Flags used when program the register.
@@ -44,31 +20,11 @@ typedef struct {
 // package level semaphore.
 } PROGRAM_CPU_REGISTER_FLAGS;
 
-//
-// Signal that SMM BASE relocation is complete.
-//
-volatile BOOLEAN  mInitApsAfterSmmBaseReloc;
-
-/**
-  Get starting address and size of the rendezvous entry for APs.
-  Information for fixing a jump instruction in the code is also returned.
-
-  @param AddressMap  Output buffer for address map information.
-**/
-VOID *
-EFIAPI
-AsmGetAddressMap (
-  MP_ASSEMBLY_ADDRESS_MAP  *AddressMap
-  );
-
 #define LEGACY_REGION_SIZE  (2 * 0x1000)
 #define LEGACY_REGION_BASE  (0xA - LEGACY_REGION_SIZE)
 
-PROGRAM_CPU_REGISTER_FLAGS  mCpuFlags;
-ACPI_CPU_DATA   mAcpiCpuData;
-volatile UINT32 mNumberToFinish;
-MP_CPU_EXCHANGE_INFO*mExchangeInfo;
-BOOLEAN mRestoreSmmConfigurationInS3 = FALSE;
+ACPI_CPU_DATA  mAcpiCpuData;
+BOOLEANmRestoreSmmConfigurationInS3 = FALSE;
 
 //
 // S3 boot flag
@@ -82,191 +38,6 @@ SMM_S3_RESUME_STATE  *mSmmS3ResumeState = NULL;
 
 BOOLEAN  mAcpiS3Enable = TRUE;
 
-UINT8  *mApHltLoopCode  = NULL;
-UINT8  mApHltLoopCodeTemplate[] = {
-  0x8B, 0x44, 0x24, 0x04, // mov  eax, dword ptr [esp+4]
-  0xF0, 0xFF, 0x08,   // lock dec  dword ptr [eax]
-  0xFA,   // cli
-  0xF4,   // hlt
-  0xEB, 0xFC  // jmp $-2
-};
-
-/**
-  The function is invoked before SMBASE relocation in S3 path to restores CPU 
status.
-
-  The function is invoked before SMBASE relocation in S3 path. It does first 
time microcode load
-  and restores MTRRs for both BSP and APs.
-
-  @param   IsBsp   The CPU this function executes on is BSP or not.
-
-**/
-VOID
-InitializeCpuBeforeRebase (
-  IN BOOLEAN  IsBsp
-  )
-{
-  //
-  // Count down the number with lock mechanism.
-  //
-  InterlockedDecrement ();
-
-  if (IsBsp) {
-//
-// Bsp wait here till all AP finish the initialization before rebase
-//
-while (mNumberToFinish > 0) {
-  CpuPause ();
-}
-  }
-}
-
-/**
-  The function is invoked after SMBASE relocation in S3 path to restores CPU 
status.
-
-  The function is invoked after SMBASE relocation in S3 path. 

[edk2-devel] [PATCH 13/18] UefiCpuPkg:Set PcdCpuFeaturesInitOnS3Resume to TRUE

2024-05-10 Thread duntan
Set PcdCpuFeaturesInitOnS3Resume to TRUE. So that
CpuFeaturesPei PEIM will initialize the CPU registers
and perform CPU features initialization.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/UefiCpuPkg.dec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index f86a6d2bcb..45384d725c 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -310,7 +310,7 @@
 
   ## Specifies if CPU features will be initialized during S3 resume.
   # @Prompt If CPU features will be initialized during S3 resume.
-  
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume|FALSE|BOOLEAN|0x001D
+  
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume|TRUE|BOOLEAN|0x001D
 
   ## Specifies CPUID Leaf 0x15 Time Stamp Counter and Nominal Core Crystal 
Clock Frequency.
   # TSC Frequency = ECX (core crystal clock frequency) * EBX/EAX.
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 15/18] UefiCpuPkg:Remove code to handle APIC setting and Interrupt

2024-05-10 Thread duntan
Remove ProgramVirtualWireMode()/DisableLvtInterrupts()
since APs won't be waken by INIT-SIPI-SIPI in CpuS3.c
any more. The two functions has been executed in
MpInitLibInitialize() in PeiMplib.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 9520451d92..65fe903fd3 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -105,11 +105,6 @@ InitializeCpuBeforeRebase (
   IN BOOLEAN  IsBsp
   )
 {
-  ProgramVirtualWireMode ();
-  if (!IsBsp) {
-DisableLvtInterrupts ();
-  }
-
   //
   // Count down the number with lock mechanism.
   //
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 12/18] UefiCpuPkg: Remove code to load mtrr setting

2024-05-10 Thread duntan
Remove code to load mtrr setting in CpuS3.c.
In previous commits, before transferring to
CpuS3.c, MTRR setting has been loaded in
S3RestoreConfig2() for all CPU.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 32 
 1 file changed, 32 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index d67fb49890..7ac6b62676 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -91,36 +91,6 @@ UINT8  mApHltLoopCodeTemplate[] = {
   0xEB, 0xFC  // jmp $-2
 };
 
-/**
-  Sync up the MTRR values for all processors.
-
-  @param MtrrTable  Table holding fixed/variable MTRR values to be loaded.
-**/
-VOID
-EFIAPI
-LoadMtrrData (
-  EFI_PHYSICAL_ADDRESS  MtrrTable
-  )
-
-/*++
-
-Routine Description:
-
-  Sync up the MTRR values for all processors.
-
-Arguments:
-
-Returns:
-None
-
---*/
-{
-  MTRR_SETTINGS  *MtrrSettings;
-
-  MtrrSettings = (MTRR_SETTINGS *)(UINTN)MtrrTable;
-  MtrrSetAllMtrrs (MtrrSettings);
-}
-
 /**
   Increment semaphore by 1.
 
@@ -554,8 +524,6 @@ InitializeCpuBeforeRebase (
   IN BOOLEAN  IsBsp
   )
 {
-  LoadMtrrData (mAcpiCpuData.MtrrTable);
-
   SetRegister (TRUE);
 
   ProgramVirtualWireMode ();
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 11/18] UefiCpuPkg: Disable PG in IA32 ApLoopCode

2024-05-10 Thread duntan
Disable paging in IA32 RelocateApLoop assembly
code to fix the issue that the AP page table is
unavailiable after boot OS under IA32 execution mode.

This issue exist in IA32 PEI + IA32 DXE normal boot
(also S3 boot with IA32 PEI after previous three commits
are accepted). In current MpLib code, the IA32 execution
mode code did not create page table in reserved memory
like what X64 code did. If PcdCpuStackGuard is TRUE, the
PG is enabled for AP in current RelocateApLoop assembly
code. And the page table for AP is unavailiable after
boot OS. This might cause potential issue. So disable PG
in IA32 RelocateApLoop.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm | 4 
 1 file changed, 4 insertions(+)

diff --git a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm 
b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
index d117f09ef5..75b18ce56f 100644
--- a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
+++ b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
@@ -225,6 +225,10 @@ RendezvousFunnelProcEnd:
 ;  specific to SEV-ES support and are not applicable on IA32.
 
;-
 AsmRelocateApLoopGenericStart:
+moveax, cr0
+btreax, 31 ; Clear CR0.PG
+movcr0, eax; Disable paging since the page table might 
be unavailiable
+
 moveax, esp
 movesp, [eax + 12] ; TopOfApStack
 push   dword [eax] ; push return address for stack trace
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 10/18] UefiCpuPkg:Relocate AP to new safe buffer in PeiMpLib

2024-05-10 Thread duntan
In this commit, change PeiMpLib to install callback
of gEdkiiEndOfS3ResumeGuid to relocate AP to new safe
buffer. The gEdkiiEndOfS3ResumeGuid is installed in
S3Resume.c before jmping to OS waking vector.

Previously, code in CpuS3.c of PiSmmCpuDxe driver will
prepare the new safe buffer for AP and place AP in hlt
loop state. With this code change, we can remove the
Machine Instructions of mApHltLoopCode in PiSmmCpuDxe.
Also we can reuse the related code in DxeMpLib for
PeiMpLib.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/Library/MpInitLib/MpLib.h  |   3 +++
 UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf |   4 
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c   | 152 

 3 files changed, 159 insertions(+)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h 
b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index 11e0d2661f..3efd913395 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -68,6 +69,8 @@
 //
 #define DEFAULT_MAX_MICROCODE_PATCH_NUM  8
 
+#define PAGING_4K_ADDRESS_MASK_64  0x000FF000ull
+
 //
 // Data structure for microcode patch information
 //
diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf 
b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
index e31e34b6f9..8736690348 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
@@ -25,10 +25,12 @@
 [Sources.IA32]
   Ia32/AmdSev.c
   Ia32/MpFuncs.nasm
+  Ia32/CreatePageTable.c
 
 [Sources.X64]
   X64/AmdSev.c
   X64/MpFuncs.nasm
+  X64/CreatePageTable.c
 
 [Sources.IA32, Sources.X64]
   AmdSev.c
@@ -64,6 +66,7 @@
   LocalApicLib
   MicrocodeLib
   MtrrLib
+  CpuPageTableLib
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase   ## CONSUMES
@@ -87,6 +90,7 @@
   gEdkiiS3SmmInitDoneGuid
   gEdkiiMicrocodePatchHobGuid
   gGhcbApicIdsGuid   ## SOMETIMES_CONSUMES
+  gEdkiiEndOfS3ResumeGuid
 
 [Guids.LoongArch64]
   gProcessorResourceHobGuid  ## SOMETIMES_CONSUMES  ## HOB
diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
index 4d3acb491f..deb5fc3aac 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
@@ -9,6 +9,7 @@
 #include "MpLib.h"
 #include 
 #include 
+#include 
 #include 
 
 STATIC UINT64  mSevEsPeiWakeupBuffer = BASE_1MB;
@@ -449,6 +450,47 @@ BuildMicrocodeCacheHob (
   return;
 }
 
+/**
+  S3 SMM Init Done notification function.
+
+  @param  PeiServices  Indirect reference to the PEI Services Table.
+  @param  NotifyDesc   Address of the notification descriptor data 
structure.
+  @param  InvokePpiAddress of the PPI that was invoked.
+
+  @retval EFI_SUCCESS  The function completes successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+NotifyOnEndOfS3Resume (
+  IN  EFI_PEI_SERVICES   **PeiServices,
+  IN  EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDesc,
+  IN  VOID   *InvokePpi
+  )
+{
+  CPU_MP_DATA  *CpuMpData;
+
+  CpuMpData   = GetCpuMpData ();
+  mNumberToFinish = CpuMpData->CpuCount - 1;
+  WakeUpAP (CpuMpData, TRUE, 0, RelocateApLoop, NULL, TRUE);
+  while (mNumberToFinish > 0) {
+CpuPause ();
+  }
+
+  DEBUG ((DEBUG_INFO, "%a() done!\n", __func__));
+
+  return EFI_SUCCESS;
+}
+
+//
+// Global function
+//
+EFI_PEI_NOTIFY_DESCRIPTOR  mEndOfS3ResumeNotifyDesc = {
+  EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | 
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+  ,
+  NotifyOnEndOfS3Resume
+};
+
 /**
   Initialize global data for MP support.
 
@@ -463,12 +505,16 @@ InitMpGlobalData (
 
   BuildMicrocodeCacheHob (CpuMpData);
   SaveCpuMpData (CpuMpData);
+  PrepareApLoopCode (CpuMpData);
 
   ///
   /// Install Notify
   ///
   Status = PeiServicesNotifyPpi ();
   ASSERT_EFI_ERROR (Status);
+
+  Status = PeiServicesNotifyPpi ();
+  ASSERT_EFI_ERROR (Status);
 }
 
 /**
@@ -815,3 +861,109 @@ PlatformShadowMicrocode (
 
   return EFI_SUCCESS;
 }
+
+/**
+  Allocate buffer for ApLoopCode.
+
+  @param[in]  PagesNumber of pages to allocate.
+  @param[in, out] Address  Pointer to the allocated buffer.
+**/
+VOID
+AllocateApLoopCodeBuffer (
+  IN UINTN Pages,
+  IN OUT EFI_PHYSICAL_ADDRESS  *Address
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = PeiServicesAllocatePages (EfiACPIMemoryNVS, Pages, Address);
+  if (EFI_ERROR (Status)) {
+*Address = 0;
+  }
+}
+
+/**
+  Remove Nx protection for the range specific by BaseAddress and Length.
+
+  The PEI implementation uses CpuPageTableLib to change the attribute.
+  The DXE implementation uses gDS to change the attribute.
+
+  @param[in] BaseAddress  BaseAddress of the range.
+  @param[in] 

[edk2-devel] [PATCH 09/18] UefiCpuPkg:Move some code in DxeMpLib to common place

2024-05-10 Thread duntan
Move some code in DxeMpLib.C to common MpLib.c.
The related code is to relocate Ap to new safe buffer
before booting into OS. In next commits, these code
also will be used by PeiMpLib. This commit doesn't
change any code functionality.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 151 
+--
 UefiCpuPkg/Library/MpInitLib/MpLib.c| 142 
++
 UefiCpuPkg/Library/MpInitLib/MpLib.h|  51 
++-
 3 files changed, 197 insertions(+), 147 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index d13cebbee6..229e38e593 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -20,15 +20,11 @@
 
 #define  AP_SAFE_STACK_SIZE  128
 
-CPU_MP_DATA *mCpuMpData  = NULL;
-EFI_EVENT   mCheckAllApsEvent= NULL;
-EFI_EVENT   mMpInitExitBootServicesEvent = NULL;
-EFI_EVENT   mLegacyBootEvent = NULL;
-volatile BOOLEANmStopCheckAllApsStatus   = TRUE;
-RELOCATE_AP_LOOP_ENTRY  mReservedApLoop;
-UINTN   mReservedTopOfApStack;
-volatile UINT32 mNumberToFinish = 0;
-UINTN   mApPageTable;
+CPU_MP_DATA   *mCpuMpData  = NULL;
+EFI_EVENT mCheckAllApsEvent= NULL;
+EFI_EVENT mMpInitExitBootServicesEvent = NULL;
+EFI_EVENT mLegacyBootEvent = NULL;
+volatile BOOLEAN  mStopCheckAllApsStatus   = TRUE;
 
 //
 // Begin wakeup buffer allocation below 0x88000
@@ -368,60 +364,6 @@ GetProtectedModeCS (
   return Index * 8;
 }
 
-/**
-  Do sync on APs.
-
-  @param[in, out] Buffer  Pointer to private data buffer.
-**/
-VOID
-EFIAPI
-RelocateApLoop (
-  IN OUT VOID  *Buffer
-  )
-{
-  CPU_MP_DATA  *CpuMpData;
-  BOOLEAN  MwaitSupport;
-  UINTNProcessorNumber;
-  UINTNStackStart;
-
-  MpInitLibWhoAmI ();
-  CpuMpData= GetCpuMpData ();
-  MwaitSupport = IsMwaitSupport ();
-  if (CpuMpData->UseSevEsAPMethod) {
-//
-// 64-bit AMD processors with SEV-ES
-//
-StackStart = CpuMpData->SevEsAPResetStackStart;
-mReservedApLoop.AmdSevEntry (
-  MwaitSupport,
-  CpuMpData->ApTargetCState,
-  CpuMpData->PmCodeSegment,
-  StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE,
-  (UINTN),
-  CpuMpData->Pm16CodeSegment,
-  CpuMpData->SevEsAPBuffer,
-  CpuMpData->WakeupBuffer
-  );
-  } else {
-//
-// Intel processors (32-bit or 64-bit), 32-bit AMD processors, or 64-bit 
AMD processors without SEV-ES
-//
-StackStart = mReservedTopOfApStack;
-mReservedApLoop.GenericEntry (
-  MwaitSupport,
-  CpuMpData->ApTargetCState,
-  StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE,
-  (UINTN),
-  mApPageTable
-  );
-  }
-
-  //
-  // It should never reach here
-  //
-  ASSERT (FALSE);
-}
-
 /**
   Allocate buffer for ApLoopCode.
 
@@ -477,89 +419,6 @@ RemoveNxprotection (
   }
 }
 
-/**
-  Prepare ApLoopCode.
-
-  @param[in] CpuMpData  Pointer to CpuMpData.
-**/
-VOID
-PrepareApLoopCode (
-  IN CPU_MP_DATA  *CpuMpData
-  )
-{
-  EFI_PHYSICAL_ADDRESS Address;
-  MP_ASSEMBLY_ADDRESS_MAP  *AddressMap;
-  UINT8*ApLoopFunc;
-  UINTNApLoopFuncSize;
-  UINTNStackPages;
-  UINTNFuncPages;
-  IA32_CR0 Cr0;
-
-  AddressMap = >AddressMap;
-  if (CpuMpData->UseSevEsAPMethod) {
-//
-// 64-bit AMD processors with SEV-ES
-//
-Address= BASE_4GB - 1;
-ApLoopFunc = AddressMap->RelocateApLoopFuncAddressAmdSev;
-ApLoopFuncSize = AddressMap->RelocateApLoopFuncSizeAmdSev;
-  } else {
-//
-// Intel processors (32-bit or 64-bit), 32-bit AMD processors, or 64-bit 
AMD processors without SEV-ES
-//
-Address= MAX_ADDRESS;
-ApLoopFunc = AddressMap->RelocateApLoopFuncAddressGeneric;
-ApLoopFuncSize = AddressMap->RelocateApLoopFuncSizeGeneric;
-  }
-
-  //
-  // Avoid APs access invalid buffer data which allocated by BootServices,
-  // so we will allocate reserved data for AP loop code. We also need to
-  // allocate this buffer below 4GB due to APs may be transferred to 32bit
-  // protected mode on long mode DXE.
-  // Allocating it in 

[edk2-devel] [PATCH 08/18] UefiCpuPkg:Abstract some DxeMpLib code to function

2024-05-10 Thread duntan
Abstract some DxeMpLib code to function in this commit.
Some of these internal functions will be moved to common
MpLib.c in following commits. Then PeiMpLib can reuse
the code.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 220 
+++-
 1 file changed, 139 insertions(+), 81 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 57ddb86600..d13cebbee6 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -422,6 +422,144 @@ RelocateApLoop (
   ASSERT (FALSE);
 }
 
+/**
+  Allocate buffer for ApLoopCode.
+
+  @param[in]  PagesNumber of pages to allocate.
+  @param[in, out] Address  Pointer to the allocated buffer.
+**/
+VOID
+AllocateApLoopCodeBuffer (
+  IN UINTN Pages,
+  IN OUT EFI_PHYSICAL_ADDRESS  *Address
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = gBS->AllocatePages (
+  AllocateMaxAddress,
+  EfiReservedMemoryType,
+  Pages,
+  Address
+  );
+  ASSERT_EFI_ERROR (Status);
+}
+
+/**
+  Remove Nx protection for the range specific by BaseAddress and Length.
+
+  The PEI implementation uses CpuPageTableLib to change the attribute.
+  The DXE implementation uses gDS to change the attribute.
+
+  @param[in] BaseAddress  BaseAddress of the range.
+  @param[in] Length   Length of the range.
+**/
+VOID
+RemoveNxprotection (
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN UINTN Length
+  )
+{
+  EFI_STATUS   Status;
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR  MemDesc;
+
+  //
+  // TODO: Check EFI_MEMORY_XP bit set or not once it's available in DXE GCD
+  //   service.
+  //
+  Status = gDS->GetMemorySpaceDescriptor (BaseAddress, );
+  if (!EFI_ERROR (Status)) {
+gDS->SetMemorySpaceAttributes (
+   BaseAddress,
+   Length,
+   MemDesc.Attributes & (~EFI_MEMORY_XP)
+   );
+  }
+}
+
+/**
+  Prepare ApLoopCode.
+
+  @param[in] CpuMpData  Pointer to CpuMpData.
+**/
+VOID
+PrepareApLoopCode (
+  IN CPU_MP_DATA  *CpuMpData
+  )
+{
+  EFI_PHYSICAL_ADDRESS Address;
+  MP_ASSEMBLY_ADDRESS_MAP  *AddressMap;
+  UINT8*ApLoopFunc;
+  UINTNApLoopFuncSize;
+  UINTNStackPages;
+  UINTNFuncPages;
+  IA32_CR0 Cr0;
+
+  AddressMap = >AddressMap;
+  if (CpuMpData->UseSevEsAPMethod) {
+//
+// 64-bit AMD processors with SEV-ES
+//
+Address= BASE_4GB - 1;
+ApLoopFunc = AddressMap->RelocateApLoopFuncAddressAmdSev;
+ApLoopFuncSize = AddressMap->RelocateApLoopFuncSizeAmdSev;
+  } else {
+//
+// Intel processors (32-bit or 64-bit), 32-bit AMD processors, or 64-bit 
AMD processors without SEV-ES
+//
+Address= MAX_ADDRESS;
+ApLoopFunc = AddressMap->RelocateApLoopFuncAddressGeneric;
+ApLoopFuncSize = AddressMap->RelocateApLoopFuncSizeGeneric;
+  }
+
+  //
+  // Avoid APs access invalid buffer data which allocated by BootServices,
+  // so we will allocate reserved data for AP loop code. We also need to
+  // allocate this buffer below 4GB due to APs may be transferred to 32bit
+  // protected mode on long mode DXE.
+  // Allocating it in advance since memory services are not available in
+  // Exit Boot Services callback function.
+  //
+  // ++ (TopOfApStack)
+  // |  Stack * N |
+  // ++ (stack base, 4k aligned)
+  // |  Padding   |
+  // ++
+  // |  Ap Loop   |
+  // ++ ((low address, 4k-aligned)
+  //
+
+  StackPages = EFI_SIZE_TO_PAGES (CpuMpData->CpuCount * AP_SAFE_STACK_SIZE);
+  FuncPages  = EFI_SIZE_TO_PAGES (ApLoopFuncSize);
+
+  AllocateApLoopCodeBuffer (StackPages + FuncPages, );
+  ASSERT (Address != 0);
+
+  Cr0.UintN = AsmReadCr0 ();
+  if (Cr0.Bits.PG != 0) {
+//
+// Make sure that the buffer memory is executable if NX protection is 
enabled
+// for EfiReservedMemoryType.
+//
+RemoveNxprotection (Address, EFI_PAGES_TO_SIZE (FuncPages));
+  }
+
+  mReservedTopOfApStack = (UINTN)Address + EFI_PAGES_TO_SIZE 
(StackPages+FuncPages);
+  ASSERT ((mReservedTopOfApStack & (UINTN)(CPU_STACK_ALIGNMENT - 1)) == 0);
+  mReservedApLoop.Data = (VOID *)(UINTN)Address;
+  ASSERT (mReservedApLoop.Data != NULL);
+  CopyMem (mReservedApLoop.Data, ApLoopFunc, ApLoopFuncSize);
+  if (!CpuMpData->UseSevEsAPMethod) {
+//
+// processors without SEV-ES and paging is enabled
+//
+mApPageTable = CreatePageTable (
+ (UINTN)Address,
+ EFI_PAGES_TO_SIZE 

[edk2-devel] [PATCH 07/18] UefiCpuPkg: Install gEdkiiEndOfS3ResumeGuid in S3Resume

2024-05-10 Thread duntan
Install gEdkiiEndOfS3ResumeGuid in S3Resume to trigger
callback registered by PeiMpLib. The callback is to
relocate Ap to new safe memory before jump to OS waking
vector in S3 boot flow.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c 
b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index a8e9c92a93..98badc74ae 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -260,6 +260,12 @@ EFI_PEI_PPI_DESCRIPTOR  mPpiListS3SmmInitDoneTable = {
   0
 };
 
+EFI_PEI_PPI_DESCRIPTOR  mPpiListEndOfS3ResumeTable = {
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+  ,
+  0
+};
+
 //
 // Global Descriptor Table (GDT)
 //
@@ -490,6 +496,13 @@ S3ResumeBootOs (
   PERF_INMODULE_BEGIN ("EndOfS3Resume");
 
   DEBUG ((DEBUG_INFO, "Signal EndOfS3Resume\n"));
+
+  //
+  // Install EndOfS3Resume.
+  //
+  Status = PeiServicesInstallPpi ();
+  ASSERT_EFI_ERROR (Status);
+
   //
   // Signal EndOfS3Resume to SMM.
   //
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 06/18] UefiCpuPkg: Remove the duplicated mpservice locate

2024-05-10 Thread duntan
Remove the duplicated mpservice locate in the code
logic. Previously, when the execution combination
of PEI and DXE are the same, the pointer of mpservice
ppi will be passed to CpuS3.c in smm cpu driver to
wakeup all APs, instead of init-sipi-sipi. Currently,
CpuS3.c doesn't need to wakeup Aps anymore. So remove
the duplicated mpservice locate and the assignment to
MpService2Ppi field in SmmS3ResumeState.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c 
b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 3e85eab28f..a8e9c92a93 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -1139,7 +1139,6 @@ S3RestoreConfig2 (
 SmmS3ResumeState->ReturnContext1 = 
(EFI_PHYSICAL_ADDRESS)(UINTN)AcpiS3Context;
 SmmS3ResumeState->ReturnContext2 = 
(EFI_PHYSICAL_ADDRESS)(UINTN)EfiBootScriptExecutorVariable;
 SmmS3ResumeState->ReturnStackPointer = 
(EFI_PHYSICAL_ADDRESS)STACK_ALIGN_DOWN ();
-SmmS3ResumeState->MpService2Ppi  = 0;
 
 DEBUG ((DEBUG_INFO, "SMM S3 Signature= %x\n", 
SmmS3ResumeState->Signature));
 DEBUG ((DEBUG_INFO, "SMM S3 Stack Base   = %x\n", 
SmmS3ResumeState->SmmS3StackBase));
@@ -1168,19 +1167,6 @@ S3RestoreConfig2 (
 if (((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) && (sizeof 
(UINTN) == sizeof (UINT32))) ||
 ((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) && (sizeof 
(UINTN) == sizeof (UINT64
 {
-  //
-  // Get MP Services2 Ppi to pass it to Smm S3.
-  //
-  Status = PeiServicesLocatePpi (
- ,
- 0,
- NULL,
- (VOID **)
- );
-  ASSERT_EFI_ERROR (Status);
-  SmmS3ResumeState->MpService2Ppi = 
(EFI_PHYSICAL_ADDRESS)(UINTN)MpService2Ppi;
-  DEBUG ((DEBUG_INFO, "SMM S3 MpService2Ppi Point = %lx\n", 
SmmS3ResumeState->MpService2Ppi));
-
   SwitchStack (
 
(SWITCH_STACK_ENTRY_POINT)(UINTN)SmmS3ResumeState->SmmS3ResumeEntryPoint,
 (VOID *)AcpiS3Context,
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 05/18] UefiCpuPkg: LoadMtrrData for all cpu in S3Resume

2024-05-10 Thread duntan
In this commit, S3Resume.c wakeup all Aps to run
LoadMtrrData for all cpu before transfer to CpuS3.c
in smm cpu driver. The MtrrSetting table can be restored
by gEdkiiS3MtrrSettingGuid which is saved by lockbox in
PEI phase. This can avoid waking up APs in CpuS3.c.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c   | 49 
+
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf |  2 ++
 2 files changed, 51 insertions(+)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c 
b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 4cf676fb3e..3e85eab28f 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -938,6 +939,20 @@ S3ResumeExecuteBootScript (
   CpuDeadLoop ();
 }
 
+/**
+  Sync up the MTRR values for all processors.
+
+  @param[in] MtrrTable  Address of MTRR setting.
+**/
+VOID
+EFIAPI
+LoadMtrrData (
+  IN VOID  *MtrrTable
+  )
+{
+  MtrrSetAllMtrrs (MtrrTable);
+}
+
 /**
   Restores the platform to its preboot configuration for an S3 resume and
   jumps to the OS waking vector.
@@ -990,6 +1005,7 @@ S3RestoreConfig2 (
   BOOLEANInterruptStatus;
   IA32_CR0   Cr0;
   EDKII_PEI_MP_SERVICES2_PPI *MpService2Ppi;
+  MTRR_SETTINGS  MtrrTable;
 
   TempAcpiS3Context = 0;
   TempEfiBootScriptExecutorVariable = 0;
@@ -1082,6 +1098,39 @@ S3RestoreConfig2 (
   Status = SmmAccess->Open ((EFI_PEI_SERVICES 
**)GetPeiServicesTablePointer (), SmmAccess, Index);
 }
 
+//
+// Get MP Services2 Ppi to pass it to Smm S3.
+//
+Status = PeiServicesLocatePpi (
+   ,
+   0,
+   NULL,
+   (VOID **)
+   );
+ASSERT_EFI_ERROR (Status);
+
+//
+// Restore MTRR setting
+//
+VarSize = sizeof (MTRR_SETTINGS);
+Status  = RestoreLockBox (
+,
+,
+
+);
+ASSERT_EFI_ERROR (Status);
+
+//
+// Sync up the MTRR values for all processors.
+//
+Status = MpService2Ppi->StartupAllCPUs (
+  MpService2Ppi,
+  (EFI_AP_PROCEDURE)LoadMtrrData,
+  0,
+  (VOID *)
+  );
+ASSERT_EFI_ERROR (Status);
+
 SmramDescriptor  = (EFI_SMRAM_DESCRIPTOR *)GET_GUID_HOB_DATA (GuidHob);
 SmmS3ResumeState = (SMM_S3_RESUME_STATE *)(UINTN)SmramDescriptor->CpuStart;
 
diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf 
b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
index 9c9b6f3db3..890c588aa8 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
@@ -67,6 +67,7 @@
   LocalApicLib
   ReportStatusCodeLib
   LockBoxLib
+  MtrrLib
 
 [Guids]
   gEfiBootScriptExecutorVariableGuid## SOMETIMES_CONSUMES ## 
UNDEFINED # LockBox
@@ -79,6 +80,7 @@
   ## SOMETIMES_PRODUCES ## UNDEFINED # Install PPI
   ## SOMETIMES_CONSUMES ## UNDEFINED # Used to do smm communication
   gEdkiiS3SmmInitDoneGuid
+  gEdkiiS3MtrrSettingGuid
 
 [Ppis]
   gEfiPeiS3Resume2PpiGuid   ## PRODUCES
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 04/18] UefiCpuPkg: Save MTRR by lockbox in CpuS3DataDxe

2024-05-10 Thread duntan
Save MTRR by lockbox in CpuS3DataDxe. In S3 boot,
The MTRR setting will be restored in S3Resume.c
in following patches. Then S3Resume.c will wakeup
all APs to load the MTRR setting. This can avoid
waking up APs in CpuS3.c.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c  | 11 +++
 UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c 
b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c
index 86ce5303ca..825bb00b74 100644
--- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c
+++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c
@@ -26,6 +26,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -130,6 +131,16 @@ CpuS3DataOnEndOfDxe (
   DEBUG ((DEBUG_VERBOSE, "%a\n", __func__));
   MtrrGetAllMtrrs (>MtrrTable);
 
+  //
+  // Save MTRR in lockbox
+  //
+  Status = SaveLockBox (
+ ,
+ >MtrrTable,
+ sizeof (MTRR_SETTINGS)
+ );
+  ASSERT_EFI_ERROR (Status);
+
   //
   // Close event, so it will not be invoked again.
   //
diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf 
b/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
index 510133a614..a09254746b 100644
--- a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
+++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
@@ -46,9 +46,11 @@
   BaseLib
   MtrrLib
   MemoryAllocationLib
+  LockBoxLib
 
 [Guids]
   gEfiEndOfDxeEventGroupGuid ## CONSUMES   ## Event
+  gEdkiiS3MtrrSettingGuid
 
 [Protocols]
   gEfiMpServiceProtocolGuid  ## CONSUMES
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 03/18] UefiCpuPkg: Add locbox lib instance in DSC

2024-05-10 Thread duntan
Add locbox lib instance in DSC. The SmmLockBoxDxeLib
will be consumed by CpuS3DataDxe driver

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Jiaxin Wu 
---
 UefiCpuPkg/UefiCpuPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index 3d49f72588..b113ae022f 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -68,6 +68,7 @@
   UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.inf
   
UnitTestPersistenceLib|UnitTestFrameworkPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.inf
   
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.inf
+  LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf
 
 [LibraryClasses.common.SEC]
   PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 02/18] OvmfPkg: Save MTRR by lockbox in CpuS3DataDxe

2024-05-10 Thread duntan
Save MTRR by lockbox in CpuS3DataDxe. In S3 boot,
The MTRR setting will be restored in S3Resume.c
in following patches. Then S3Resume.c will wakeup
all APs to load the MTRR setting. This can avoid
waking up APs in CpuS3.c.

Signed-off-by: Dun Tan 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Gerd Hoffmann 
Cc: Ray Ni 
Cc: Jiaxin Wu 
---
 OvmfPkg/CpuS3DataDxe/CpuS3Data.c  | 11 +++
 OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/OvmfPkg/CpuS3DataDxe/CpuS3Data.c b/OvmfPkg/CpuS3DataDxe/CpuS3Data.c
index 289048b75d..d1aba32842 100644
--- a/OvmfPkg/CpuS3DataDxe/CpuS3Data.c
+++ b/OvmfPkg/CpuS3DataDxe/CpuS3Data.c
@@ -26,6 +26,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -130,6 +131,16 @@ CpuS3DataOnEndOfDxe (
   DEBUG ((DEBUG_VERBOSE, "%a\n", __func__));
   MtrrGetAllMtrrs (>MtrrTable);
 
+  //
+  // Save MTRR in lockbox
+  //
+  Status = SaveLockBox (
+ ,
+ >MtrrTable,
+ sizeof (MTRR_SETTINGS)
+ );
+  ASSERT_EFI_ERROR (Status);
+
   //
   // Close event, so it will not be invoked again.
   //
diff --git a/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf 
b/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf
index 228d5ae1b2..f5032a9222 100644
--- a/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf
+++ b/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf
@@ -46,9 +46,11 @@
   MtrrLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
+  LockBoxLib
 
 [Guids]
   gEfiEndOfDxeEventGroupGuid ## CONSUMES   ## Event
+  gEdkiiS3MtrrSettingGuid
 
 [Protocols]
   gEfiMpServiceProtocolGuid  ## CONSUMES
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 01/18] MdeModulePkg: Add gEdkiiS3MtrrSettingGuid

2024-05-10 Thread duntan
Add gEdkiiS3MtrrSettingGuid a new GUID for s3
MTRR setting. This GUID will be used to save
MTRR_SETTINGS at EndOfDxe by LockBox and restore
at S3 boot PEI phase for s3 usage.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Liming Gao 
Cc: Jiaxin Wu 
---
 MdeModulePkg/MdeModulePkg.dec | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index f7339f0aec..2c50d90e94 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -465,6 +465,9 @@
   gEdk2JedecSfdpSpiDxeDriverGuid  = { 0xBE71701E, 0xB63C, 0x4574, { 0x9C, 
0x5C, 0x36, 0x29, 0xE8, 0xEA, 0xC4, 0x14 }}
   gEdk2JedecSfdpSpiSmmDriverGuid  = { 0x95A1E915, 0x195C, 0x477C, { 0x92, 
0x6F, 0x7E, 0x24, 0x67, 0xC1, 0xB3, 0x1F }}
 
+  ## This GUID will be used to save MTRR_SETTINGS at EndOfDxe by LockBox and 
restore at S3 boot PEI phase for s3 usage.
+  gEdkiiS3MtrrSettingGuid = { 0xd77baa84, 0xb332, 0x4463, { 0x9f, 0x1d, 0xce, 
0x81, 0x00, 0xfe, 0x7f, 0x35 }}
+
 [Ppis]
   ## Include/Ppi/FirmwareVolumeShadowPpi.h
   gEdkiiPeiFirmwareVolumeShadowPpiGuid = { 0x7dfe756c, 0xed8d, 0x4d77, {0x9e, 
0xc4, 0x39, 0x9a, 0x8a, 0x81, 0x51, 0x16 } }
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 00/19] Remove some S3 related code in CpuS3.c of smm cpu driver

2024-05-10 Thread duntan
This patch set is to remove some S3 related code in CpuS3.c of smm cpu driver. 
It contain commits to:
1.Save MTRR setting by lockbox in PEI phase 
2.Load MTRR in S3Resume.c before transferring to CpuS3.c in smm cpu driver.
3.Add callback of gEdkiiEndOfS3ResumeGuid in PeiMpLib to relocate Ap to new 
safe buffer.
4.Install gEdkiiEndOfS3ResumeGuid in S3Resume.c before booting OS to relocate 
APs
4.Change PcdCpuFeaturesInitOnS3Resume to TRUE to set register table in 
CpuFeaturesPei
5.Remove code to set register table/load mtrr/wakeup AP and relocate ap in 
CpuS3.c.

With this patch set, CpuS3.c in smm CPU driver can be simplified.

Dun Tan (18):
  MdeModulePkg: Add gEdkiiS3MtrrSettingGuid
  OvmfPkg: Save MTRR by lockbox in CpuS3DataDxe
  UefiCpuPkg: Add locbox lib instance in DSC
  UefiCpuPkg: Save MTRR by lockbox in CpuS3DataDxe
  UefiCpuPkg: LoadMtrrData for all cpu in S3Resume
  UefiCpuPkg: Remove the duplicated mpservice locate
  UefiCpuPkg: Install gEdkiiEndOfS3ResumeGuid in S3Resume
  UefiCpuPkg:Abstract some DxeMpLib code to function
  UefiCpuPkg:Move some code in DxeMpLib to common place
  UefiCpuPkg:Relocate AP to new safe buffer in PeiMpLib
  UefiCpuPkg: Disable PG in IA32 ApLoopCode
  UefiCpuPkg: Remove code to load mtrr setting
  UefiCpuPkg:Set PcdCpuFeaturesInitOnS3Resume to TRUE
  UefiCpuPkg: Remove code to set register table
  UefiCpuPkg:Remove code to handle APIC setting and Interrupt
  UefiCpuPkg:Rremove code to wakeup AP and relocate ap
  UefiCpuPkg: Remove GetAcpiCpuData() in CpuS3.c
  MdeModulePkg: remove MpService2Ppi field in SMM_S3_RESUME_STATE

Ray Ni (1):
  MdePkg: Add MmUnblockMemoryLib to MdeLibs.dsc

 MdeModulePkg/Include/Guid/AcpiS3Context.h   |   1 -
 MdeModulePkg/MdeModulePkg.dec   |   3 +++
 MdePkg/MdeLibs.dsc.inc  |   3 ++-
 OvmfPkg/CpuS3DataDxe/CpuS3Data.c|  11 +++
 OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf   |   2 ++
 UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c |  11 +++
 UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf|   2 ++
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 181 
+++
 UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm  |   4 
 UefiCpuPkg/Library/MpInitLib/MpLib.c| 142 
++
 UefiCpuPkg/Library/MpInitLib/MpLib.h|  54 
++-
 UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf   |   4 
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 152 

 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c   | 991 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm | 153 
-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c   |  27 
--
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c  |   6 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h  |  24 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf|   3 ---
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm  | 189 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c|  28 
---
 UefiCpuPkg/UefiCpuPkg.dec   |   2 +-
 UefiCpuPkg/UefiCpuPkg.dsc   |   1 +
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c   |  76 
++--
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf |   2 ++
 25 files changed, 511 insertions(+), 1561 deletions(-)
 delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm
 delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm

-- 
2.31.1.windows.1



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

[edk2-devel] [PATCH] NetworkPkg:MnpDxe:CoverityIssues

2024-05-10 Thread Santhosh Kumar V via groups.io
Resolved INTEGER_OVERFLOW Coverity Issues in MNP Dxe
1.MnpStop,MnpInstanceDeliverPacket
Expression "MnpDeviceData->ConfiguredChildrenNumber--" and 
Instance->RcvdPacketQueueSize--  where Both variables are known to be equal to 
0, underflows the type that receives it.


Cc: Saloni Kasbekar 
Cc: Zachary Clark-williams 

Signed-off-by: SanthoshKumarV 
---
 NetworkPkg/MnpDxe/MnpConfig.c | 3 ++-
 NetworkPkg/MnpDxe/MnpIo.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/MnpDxe/MnpConfig.c b/NetworkPkg/MnpDxe/MnpConfig.c
index 93587d53aa..80253e88de 100644
--- a/NetworkPkg/MnpDxe/MnpConfig.c
+++ b/NetworkPkg/MnpDxe/MnpConfig.c
@@ -1313,7 +1313,8 @@ MnpStop (
   //

   // Decrease the children number.

   //

-  MnpDeviceData->ConfiguredChildrenNumber--;

+  if (MnpDeviceData->ConfiguredChildrenNumber > 0)

+  MnpDeviceData->ConfiguredChildrenNumber--;



   if (MnpDeviceData->ConfiguredChildrenNumber > 0) {

 //

diff --git a/NetworkPkg/MnpDxe/MnpIo.c b/NetworkPkg/MnpDxe/MnpIo.c
index 087c879c46..492edd9b66 100644
--- a/NetworkPkg/MnpDxe/MnpIo.c
+++ b/NetworkPkg/MnpDxe/MnpIo.c
@@ -351,7 +351,8 @@ MnpInstanceDeliverPacket (
   // All resources are OK, remove the packet from the queue.

   //

   NetListRemoveHead (>RcvdPacketQueue);

-  Instance->RcvdPacketQueueSize--;

+  if (Instance->RcvdPacketQueueSize != 0)

+  Instance->RcvdPacketQueueSize--;



   RxData  = >RxData;

   SnpMode = MnpDeviceData->Snp->Mode;

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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118791): https://edk2.groups.io/g/devel/message/118791
Mute This Topic: https://groups.io/mt/106018089/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: Warn if out of space when writing variables

2024-05-10 Thread Oliver Steffen
Emit a DEBUG_ERROR message if there is not enough space left to
write/update a variable. This condition is currently not logged
appropriately in all cases, given that full variable store can easily
render the system unbootable.
This new message helps identifying this condition quickly.

Background:
We had the case where an OVMF based VM ran out of flash space after a
large number of reboots and hardware configuration changes. The MAC
address of the NIC was changing a lot over the life time of the VM. The
variable store was consumed entirely by networking related non-volatile
variables, written for each network card/MAC address present during
boot. Almost all of those were obsolete, of course, but the error that
presented itself at first was a VM that failed to boot the firmware and
ended up in an rather cryptic ASSERT message.

The hope is that this new message makes it easier for non-experts to
diagnose the situation.

The root cause is of course not addressed by this, but it might also be
hard to solve. One would have to identify obsolete network/hardware
settings somehow, but there is no way to tell if a certain NIC/MAC
might come back at a later point or not.


Launching OVMF with a full variable store then looks like this (Debug
Output):
[...]
CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize = 0x3FF60
UpdateVariable failed: Out of variable space
Select Item: 0xE
Select Item: 0x19
RecordVarErrorFlag (0xEF) Timeout:8BE4DF61-93CA-11D2-AA0D-00E098032B8C - 
0x0007 - 0x4E
CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize = 0x3FF60
UpdateVariable failed: Out of variable space
PlatformBootManagerBeforeConsole: SetVariable(Timeout, 3): Out of Resources
RecordVarErrorFlag (0xEF) BootOrder:8BE4DF61-93CA-11D2-AA0D-00E098032B8C - 
0x0007 - 0x52
CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize = 0x3FF60
UpdateVariable failed: Out of variable space

ASSERT_EFI_ERROR (Status = Out of Resources)
ASSERT OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c(361): 
!(((INTN)(RETURN_STATUS)(Status)) < 0)


PR: https://github.com/tianocore/edk2/pull/5435

Changes since v1:
- Mention "variable space" instead of "flash space"
- Emit DEBUG_ERROR instead of DEBUG_WARN

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Zhiguang Liu 

Oliver Steffen (1):
  MdeModulePkg: Warn if out of space when writing variables

 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 2 ++
 1 file changed, 2 insertions(+)

--
2.44.0



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




[edk2-devel] [PATCH] NetworkPkg:SnpDxe:Fix Coverity Issues

2024-05-10 Thread Santhosh Kumar V via groups.io
Resolved Coverity Issues reported in SNP Dxe.
1.ComponentName.c (Overflow)
Expression "OffSet--", which is equal to 18446744073709551615, where "OffSet" 
is known to be equal to 0, underflows the type that receives it.
2.SnpUndi32GetStatus,SnpUndi32Initialize,SnpUndi32Transmit (Deadcode)
Execution is not reaching as always snp is not equal to NULL
As This pointer is compared with NULL in function start
Macro EFI_SIMPLE_NETWORK_DEV_FROM_THIS always return address in This pointer
3.PxeInit(Overflow)
Expression "Snp->TxRxBufferSize - 1U", where "Snp->TxRxBufferSize" is known to 
be equal to 0, underflows the type that receives it
4.SnpUndi32Reset (Not used Variable)
ExtendedVerification variable is assigned but not used in that function.hence 
assign

Cc: Saloni Kasbekar 
Cc: Zachary Clark-williams 

Signed-off-by: SanthoshKumarV 
---
 NetworkPkg/SnpDxe/ComponentName.c |  3 ++-
 NetworkPkg/SnpDxe/Get_status.c|  3 ---
 NetworkPkg/SnpDxe/Initialize.c| 17 +++--
 NetworkPkg/SnpDxe/Reset.c |  3 +--
 NetworkPkg/SnpDxe/Transmit.c  |  3 ---
 5 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/NetworkPkg/SnpDxe/ComponentName.c 
b/NetworkPkg/SnpDxe/ComponentName.c
index cc4cc5bddb..7d1360ff46 100644
--- a/NetworkPkg/SnpDxe/ComponentName.c
+++ b/NetworkPkg/SnpDxe/ComponentName.c
@@ -267,7 +267,8 @@ UpdateName (
   //

   // Remove the last '-'

   //

-  OffSet--;

+  if (OffSet > 0)

+OffSet--;

   OffSet += UnicodeSPrint (

   HandleName + OffSet,

   sizeof (HandleName) - OffSet * sizeof (CHAR16),

diff --git a/NetworkPkg/SnpDxe/Get_status.c b/NetworkPkg/SnpDxe/Get_status.c
index 14b678fd36..6f277eb1a4 100644
--- a/NetworkPkg/SnpDxe/Get_status.c
+++ b/NetworkPkg/SnpDxe/Get_status.c
@@ -218,9 +218,6 @@ SnpUndi32GetStatus (


   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);



-  if (Snp == NULL) {

-return EFI_DEVICE_ERROR;

-  }



   switch (Snp->Mode.State) {

 case EfiSimpleNetworkInitialized:

diff --git a/NetworkPkg/SnpDxe/Initialize.c b/NetworkPkg/SnpDxe/Initialize.c
index c219a1cb20..4a15ad1cbd 100644
--- a/NetworkPkg/SnpDxe/Initialize.c
+++ b/NetworkPkg/SnpDxe/Initialize.c
@@ -128,11 +128,13 @@ PxeInit (
   );



 if (Snp->TxRxBuffer != NULL) {

-  Snp->PciIo->FreeBuffer (

-Snp->PciIo,

-SNP_MEM_PAGES (Snp->TxRxBufferSize),

-(VOID *)Snp->TxRxBuffer

-);

+  if (Snp->TxRxBufferSize != 0) {

+Snp->PciIo->FreeBuffer (

+  Snp->PciIo,

+  SNP_MEM_PAGES (Snp->TxRxBufferSize),

+  (VOID *)Snp->TxRxBuffer

+  );

+ }

 }



 Snp->TxRxBuffer = NULL;

@@ -196,11 +198,6 @@ SnpUndi32Initialize (


   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);



-  if (Snp == NULL) {

-EfiStatus = EFI_INVALID_PARAMETER;

-goto ON_EXIT;

-  }

-

   switch (Snp->Mode.State) {

 case EfiSimpleNetworkStarted:

   break;

diff --git a/NetworkPkg/SnpDxe/Reset.c b/NetworkPkg/SnpDxe/Reset.c
index 2ff685376d..1257cb6d71 100644
--- a/NetworkPkg/SnpDxe/Reset.c
+++ b/NetworkPkg/SnpDxe/Reset.c
@@ -94,9 +94,8 @@ SnpUndi32Reset (


   //

   // Resolve Warning 4 unreferenced parameter problem

+  // ExtendedVerification is not implemented

   //

-  ExtendedVerification = 0;

-  DEBUG ((DEBUG_WARN, "ExtendedVerification = %d is not implemented!\n", 
ExtendedVerification));



   if (This == NULL) {

 return EFI_INVALID_PARAMETER;

diff --git a/NetworkPkg/SnpDxe/Transmit.c b/NetworkPkg/SnpDxe/Transmit.c
index e2c7467b86..1e4ef2a8c3 100644
--- a/NetworkPkg/SnpDxe/Transmit.c
+++ b/NetworkPkg/SnpDxe/Transmit.c
@@ -289,9 +289,6 @@ SnpUndi32Transmit (


   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);



-  if (Snp == NULL) {

-return EFI_DEVICE_ERROR;

-  }



   switch (Snp->Mode.State) {

 case EfiSimpleNetworkInitialized:

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


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