Re: [edk2-devel] [PATCH v3 3/6] UefiCpuPkg: Implements SmmCpuSyncLib library instance

2023-12-14 Thread Wu, Jiaxin
SmmCpuSyncGetArrivedCpuCount () won't have below requirement to caller:

"The caller shall not call this function for the number of arrived CPU after 
look door in SMI since the value has been returned in the parameter of 
LockDoor()."

The API will ways support to get the ArrivedCpuCount no mater locked or not.

So, ignore below case.

Thanks,
Jiaxin 

> -Original Message-
> From: Wu, Jiaxin
> Sent: Thursday, December 14, 2023 11:55 PM
> To: devel@edk2.groups.io; ler...@redhat.com
> Cc: Dong, Eric ; Ni, Ray ; Zeng, Star
> ; Gerd Hoffmann ; Kumar, Rahul R
> 
> Subject: RE: [edk2-devel] [PATCH v3 3/6] UefiCpuPkg: Implements
> SmmCpuSyncLib library instance
> 
> BTW, for SmmCpuSyncGetArrivedCpuCount ():
> 
> we can't check the CpuCount (Original is named as Counter Sem) is locked or
> not, then decide return from the *Context->CpuCount or locked value for the
> arrived CPU in SMI. Just like:
> 
> if (*Context->CpuCount == MAX_UINT32) {--> does not meet this
> condition, means unlocked!
>   Return real CpuCount from the SmmCpuSyncLockDoor().
> }
> > lock operation is here *Context->CpuCount change to
> MAX_UINT32
> Return *Context->CpuCount;   --> return wrong value since MAX_UINT32 is
> return.
> 
> Because if we found it's not locked during the check, but it suddenly locked
> before return, then -1 will be returned. this is not atomic operation. The
> behavior is not expected. If we add the atomic operation here, I believe it 
> will
> surely impact the existing performance.
> 
> And the real usage case is that we only need this api before the lock. I don't
> want make it complex.
> 
> So, based on this, we add the comment in the function:
>   The caller shall not call this function for the number of arrived CPU after 
> look
> door
>   in SMI since the value has been returned in the parameter of LockDoor().
> 
> See below:
> 
> /**
>   Get current number of arrived CPU in SMI.
> 
>   BSP might need to know the current number of arrived CPU in SMI to make
> sure all APs
>   in SMI. This API can be for that purpose.
> 
>   The caller shall not call this function for the number of arrived CPU after 
> look
> door
>   in SMI since the value has been returned in the parameter of LockDoor().
> 
>   If Context is NULL, then ASSERT().
> 
>   @param[in]  Context Pointer to the SMM CPU Sync context object.
> 
>   @retvalCurrent number of arrived CPU in SMI.
> 
> **/
> UINTN
> EFIAPI
> SmmCpuSyncGetArrivedCpuCount (
>   IN  SMM_CPU_SYNC_CONTEXT  *Context
>   )
> {
>   ASSERT (Context != NULL);
> 
>   return *Context->CpuCount;
> }
> 
> Thanks,
> Jiaxin
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH v3 3/6] UefiCpuPkg: Implements SmmCpuSyncLib library instance

2023-12-14 Thread Wu, Jiaxin
I will the align the ReleaseSemaphore & WaitForSemaphore behavior as blow:

ReleaseSemaphore() prevents increase the semaphore if locked, and it should 
return the locked value (MAX_UINT32);  --> then we can check the return value 
is  MAX_UINT32 or not in SmmCpuSyncCheckInCpu(), and sem itself won't be 
changed.
WaitForSemaphore() prevents decrease the semaphore if locked, and it should 
return the locked value (MAX_UINT32); --> then we can check the return value is 
 MAX_UINT32 or not in SmmCpuSyncCheckOutCpu (), and sem itself won'tbe changed.

Thanks,
Jiaxin 


> -Original Message-
> From: Wu, Jiaxin
> Sent: Thursday, December 14, 2023 11:35 PM
> To: devel@edk2.groups.io; ler...@redhat.com
> Cc: Dong, Eric ; Ni, Ray ; Zeng, Star
> ; Gerd Hoffmann ; Kumar, Rahul R
> 
> Subject: RE: [edk2-devel] [PATCH v3 3/6] UefiCpuPkg: Implements
> SmmCpuSyncLib library instance
> 
> > > The code will be changed to:
> > >
> > >   if ((INT32)InternalWaitForSemaphore (Context->CpuCount) < 0) {
> > > return RETURN_ABORTED;
> > >   }
> >
> > I find this quite ugly. In the "semaphore post" operation, we already
> > have code that prevents incrementing if the semaphore is "locked". Can
> > we perhaps create a "semaphore pend" operation that does the same?
> >
> > How about this:
> >
> > diff --git a/UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
> > b/UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
> > index 3c2835f8def6..5d7fc58ef23f 100644
> > --- a/UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
> > +++ b/UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
> > @@ -91,35 +91,38 @@ UINT32
> >  InternalWaitForSemaphore (
> >IN OUT  volatile UINT32  *Sem
> >)
> >  {
> >UINT32  Value;
> >
> >for ( ; ;) {
> >  Value = *Sem;
> > +if (Value == MAX_UINT32) {
> > +  return Value;
> > +}
> >  if ((Value != 0) &&
> >  (InterlockedCompareExchange32 (
> > (UINT32 *)Sem,
> > Value,
> > Value - 1
> > ) == Value))
> >  {
> >break;
> >  }
> >
> >  CpuPause ();
> >}
> >
> >return Value - 1;
> >  }
> >
> > Note, I'm just brainstorming here, I've not thought it through. Just to
> > illustrate the direction I'm thinking of.
> >
> > This change should be mostly OK. InternalWaitForSemaphore() returns the
> > decremented value. So, for InternalWaitForSemaphore() to return
> > MAX_UINT32 *without* this update, the function would have to decrement
> > the semaphore when the semaphore is zero. But in that case, the function
> > *blocks*. Thus, a return value of MAX_UINT32 is not possible without
> > this extension; ergo, if MAX_UINT32 is returned (with this extension),
> 
> Yes, that's for the semaphore sync usage, we have to block the sem if it's 
> zero,
> decrease it when return. That's why I said - it's naturally make sure the Run 
> is
> reset after all ready to exit.  Then it can achieve the below flow:
> BSP: ReleaseOneAp  -->  AP: WaitForBsp
> BSP: WaitForAPs<--  AP: ReleaseBsp
> 
> 
> For locked case, I just copy the existing logic from SMM cpu driver (as I
> document in the commit message: The instance refers the existing SMM CPU
> driver (PiSmmCpuDxeSmm) sync implementation and behavior):
> existing ReleaseSemaphore() prevents increase the semaphore, but it still
> return the original semaphore value +1; --> that's why we have to check the
> return value is  0 or not in SmmCpuSyncCheckInCpu()
> existing WaitForSemaphore() allow decrease the semaphore if locked, and it
> also return the original semaphore value -1;  --> that's why we have to check
> the return value is  < 0 or not in SmmCpuSyncCheckOutCpu()
> 
> so, do you want to align the behavior as below?
> 
> ReleaseSemaphore() prevents increase the semaphore if locked, and it should
> return the locked value (MAX_UINT32);  --> then we can check the return
> value is  MAX_UINT32 or not in SmmCpuSyncCheckInCpu(), and sem itself
> won't be changed.
> WaitForSemaphore() prevents decrease the semaphore if locked, and it should
> return the locked value (MAX_UINT32); --> then we can check the return value
> is  MAX_UINT32 or not in SmmCpuSyncCheckOutCpu (), and sem itself won't
> be changed.
> 
> I think:
> for ReleaseSemaphore, it must meet below 2 cases usage:
> 1. for semaphore sync usage (Run), it doesn't care the lock case, and returned
> value is not cared. Just check the semaphore itself.
> 2. for Rendezvous case (Counter), it not only needs to check locked or not
> from return value, but also require "only increase the semaphore if not
> locked".
> 
> for WaitForSemaphore, it must meet below 2 cases usage:
> 1. for semaphore sync usage (Run), it doesn't care the lock case, and returned
> value is not cared. But for the semaphore itself, it need block at 0, and
> decrease when return.
> 2. for Rendezvous case (Counter), it only needs to check locked or not from
> return value. semaphore itself is not cared.
> 
> So, based on above, I 

Re: [edk2-devel] [edk2-stable202311][PATCH] BaseTools: Python VfrCompiler implementation

2023-12-14 Thread Yuting Yang

Hi Liming,

The way to apply new VfrCompiler in Edk2  is detailed in the 
BaseTools/Source/Python/VfrCompiler/Readme.md file
You can use this branch to have a try ~
https://github.com/yytshirley/edk2/tree/PyVfrCompiler_Tool

Thanks,
Yuting
From: devel@edk2.groups.io  On Behalf Of gaoliming via 
groups.io
Sent: Monday, December 11, 2023 5:34 PM
To: Chen, Christine ; devel@edk2.groups.io; 'Rebecca 
Cran' ; Zimmer, Vincent ; Kinney, 
Michael D ; 'Leif Lindholm' 
; 'Andrew Fish' 
Cc: Feng, Bob C ; Yang, Yuting2 ; 
Hartung, Stephen 
Subject: 回复: [edk2-devel] [edk2-stable202311][PATCH] BaseTools: Python 
VfrCompiler implementation

Christine:
 Is there the change in Edk2 to apply new VfrCompiler? Can you share your code 
branch with new VfrCompiler to pass build on Emulator or Ovmf? I would like to 
try this tool first.

Thanks
Liming
发件人: Chen, Christine mailto:yuwei.c...@intel.com>>
发送时间: 2023年12月7日 17:08
收件人: devel@edk2.groups.io; Chen, Christine 
mailto:yuwei.c...@intel.com>>; Gao, Liming 
mailto:gaolim...@byosoft.com.cn>>; 'Rebecca Cran' 
mailto:rebe...@bsdio.com>>; Zimmer, Vincent 
mailto:vincent.zim...@intel.com>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 'Leif 
Lindholm' mailto:quic_llind...@quicinc.com>>; 
'Andrew Fish' mailto:af...@apple.com>>
抄送: Feng, Bob C mailto:bob.c.f...@intel.com>>; Yang, 
Yuting2 mailto:yuting2.y...@intel.com>>; Hartung, 
Stephen mailto:stephen.hart...@intel.com>>
主题: RE: [edk2-devel] [edk2-stable202311][PATCH] BaseTools: Python VfrCompiler 
implementation

Hi Liming,

Is this feature been tested and reviewed these two weeks? 

Thanks,
Christine
From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Yuwei Chen
Sent: Monday, November 13, 2023 8:32 AM
To: Gao, Liming mailto:gaolim...@byosoft.com.cn>>; 
'Rebecca Cran' mailto:rebe...@bsdio.com>>; Gao, Liming 
mailto:gaolim...@byosoft.com.cn>>; Zimmer, Vincent 
mailto:vincent.zim...@intel.com>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 'Leif 
Lindholm' mailto:quic_llind...@quicinc.com>>; 
'Andrew Fish' mailto:af...@apple.com>>
Cc: Feng, Bob C mailto:bob.c.f...@intel.com>>; Yang, 
Yuting2 mailto:yuting2.y...@intel.com>>; 
devel@edk2.groups.io; Hartung, Stephen 
mailto:stephen.hart...@intel.com>>
Subject: Re: [edk2-devel] [edk2-stable202311][PATCH] BaseTools: Python 
VfrCompiler implementation

Hi Liming,

I know your point. Would you like to start reviewing it and give us more 
feedbacks? We really hope it can be merged as soon as possible.
We can do the merging after the stable tag, but just like you said, maybe we 
need to review it firstly.

Looking forward to your feedbacks, and I think this one is a very big step for 
BaseTools. Thanks a lot for your help and contribution on this.
I have created a BZ for this feature: 
https://bugzilla.tianocore.org/show_bug.cgi?id=4596
Will update the patch with Bugzilla link. (This step should not influence the 
reviewing)

Thanks,
Christine

From: gaoliming mailto:gaolim...@byosoft.com.cn>>
Sent: Thursday, November 9, 2023 10:19 PM
To: 'Rebecca Cran' mailto:rebe...@bsdio.com>>; Gao, Liming 
mailto:gaolim...@byosoft.com.cn>>; Zimmer, Vincent 
mailto:vincent.zim...@intel.com>>; Chen, Christine 
mailto:yuwei.c...@intel.com>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 'Leif 
Lindholm' mailto:quic_llind...@quicinc.com>>; 
'Andrew Fish' mailto:af...@apple.com>>
Cc: Feng, Bob C mailto:bob.c.f...@intel.com>>; Yang, 
Yuting2 mailto:yuting2.y...@intel.com>>; 
devel@edk2.groups.io; Hartung, Stephen 
mailto:stephen.hart...@intel.com>>
Subject: RE: [edk2-stable202311][PATCH] BaseTools: Python VfrCompiler 
implementation


Christine:

 I can’t directly reply to the original mail because it is too large. This is a 
new feature to add python version VfrCompiler. I don’t think we have enough 
time to review the design and implementation. Although it has no real impact, 
its code may have many change in future. So, I suggest to merge it after this 
stable tag.



Thanks

Liming



Below is your request.



Hi Liming and Cran,



Could you help on quick reviewing this new VfrCompiler python tool, it has the 
same functions with origin C version VfrCompiler, meanwhile it supports more 
new features such as generated Vfr files config info into Yaml format.



This feature is urgent for us to use, and we really hope it can be merged into 
this stable tag. This patch is linked to the edk2-basetools PR: 
https://github.com/tianocore/edk2-basetools/pull/109. We list all the known 
issues which will be enhanced in the ReadMe file. And will enhance them one by 
one after the patch merged.



For the code quality, in this patch, the new tool is not enabled in build 
process, it just saves in the basetools python folder, which will not influence 
the current edk2 behaviors. We will enable it with a new patch when everything 
is ready.



Many 

Re: [edk2-devel] [edk2-redfish-client][PATCH 4/4] RedfishClientPkg: use POST method while provisioning new property.

2023-12-14 Thread Nickle Wang via groups.io
Hi Mike,

Per Redfish specification 7.9 POST(create)

"The POST request is submitted to the resource collection to which the new 
resource will belong."

If this is not a collection resource, we cannot use POST method. And 
/redfish/v1/Systems/SYS_ID/Bios is not a collection resource. The allowed 
method returned from BMC for BIOS resource is usually "GET" and "PUT".

So, I think that the fourth parameter is still FALSE here. But I admit that the 
function header below is confusing and did not express above rule clearly.

/**
  Provisioning redfish resource by given URI.

  @param[in]   Schema  Redfish schema information.
  @param[in]   Uri Target URI to create resource.
  @param[in]   InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANGE.
  @param[in]   HttpPostModeTRUE if resource does not exist, HTTP POST 
method is used.
   FALSE if the resource exist but some of 
properties are missing,
   HTTP PUT method is used.

  @retval EFI_SUCCESS  Value is returned successfully.
  @retval Others   Some error happened.

**/

Below is my suggestion.

  @param[in]   HttpPostModeTRUE if target resource is a member of 
collection resource, HTTP POST method is used.
 FALSE if target 
resource is non-collection resource, HTTP PUT method is used.

Do you think this helps to explain the use-case of fourth parameter more 
clearly?

Thanks,
Nickle

> -Original Message-
> From: Mike Maslenkin 
> Sent: Friday, December 15, 2023 8:04 AM
> To: devel@edk2.groups.io
> Cc: abner.ch...@amd.com; Nickle Wang ;
> ig...@ami.com; Mike Maslenkin 
> Subject: [edk2-redfish-client][PATCH 4/4] RedfishClientPkg: use POST method
> while provisioning new property.
> 
> External email: Use caution opening links or attachments
> 
> 
> If EdkIIRedfishResourceConfigCheck fails according to the logic and
> comment: new resources should be provisioned, so the POST method must be
> used. Fourth parameter of EdkIIRedfishResourceConfigProvisioning is BOOLEAN
> HttpPostMode, so we pass TRUE here.
> 
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> Cc: Nickle Wang 
> Signed-off-by: Mike Maslenkin 
> ---
>  RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
> b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
> index a26a1083cd74..4fd4845f3420 100644
> --- a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
> +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
> @@ -818,9 +818,9 @@ HandleResource (
>  // The target property does not exist, do the provision to create 
> property.
> 
>  //
> 
>  DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __func__, Uri));
> 
> -Status = EdkIIRedfishResourceConfigProvisioning (, Uri, 
> Private-
> >InformationExchange, FALSE);
> 
> +Status = EdkIIRedfishResourceConfigProvisioning (, Uri,
> + Private->InformationExchange, TRUE);
> 
>  if (EFI_ERROR (Status)) {
> 
> -  DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n",
> __func__, Status));
> 
> +  DEBUG ((DEBUG_ERROR, "%a, failed to provision with POST mode:
> + %r\n", __func__, Status));
> 
>  }
> 
> 
> 
>  return Status;
> 
> --
> 2.32.0 (Apple Git-132)



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




Re: [edk2-devel] [edk2-redfish-client][PATCH 3/4] RedfishClientPkg: fix access to unitialized variable.

2023-12-14 Thread Nickle Wang via groups.io
Thanks for catching this issue.


Reviewed-by: Nickle Wang 

Regards,
Nickle

> -Original Message-
> From: Mike Maslenkin 
> Sent: Friday, December 15, 2023 8:04 AM
> To: devel@edk2.groups.io
> Cc: abner.ch...@amd.com; Nickle Wang ;
> ig...@ami.com; Mike Maslenkin 
> Subject: [edk2-redfish-client][PATCH 3/4] RedfishClientPkg: fix access to
> unitialized variable.
> 
> External email: Use caution opening links or attachments
> 
> 
> It is possible that at the time of accessing to AsciiLocation pointer the 
> memory is
> not allocated.
> 
> Also gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) emits a warning for this 
> case:
> 
> RedfishFeatureUtilityLib.c:1889:37: error: 'AsciiLocation' may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
>*Location = StrAsciiToUnicode (AsciiLocation);
> 
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> Cc: Nickle Wang 
> Signed-off-by: Mike Maslenkin 
> ---
>  .../RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c| 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> index 0f0b050d7eba..01c054ae3b70 100644
> ---
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUt
> +++ ilityLib.c
> @@ -1856,7 +1856,8 @@ GetEtagAndLocation (
>}
> 
> 
> 
>if (Location != NULL) {
> 
> -*Location = NULL;
> 
> +*Location = NULL;
> 
> +AsciiLocation = NULL;
> 
> 
> 
>  if (*(Response->StatusCode) == HTTP_STATUS_200_OK) {
> 
>Header = HttpFindHeader (Response->HeaderCount, Response->Headers,
> HTTP_HEADER_LOCATION);
> 
> --
> 2.32.0 (Apple Git-132)



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




Re: [edk2-devel] [edk2-redfish-client][PATCH 2/4] RedfishClientPkg: fix typo in EfiRestJsonStructureProtocolIsReady

2023-12-14 Thread Nickle Wang via groups.io



Reviewed-by: Nickle Wang 

Regards,
Nickle

> -Original Message-
> From: Mike Maslenkin 
> Sent: Friday, December 15, 2023 8:04 AM
> To: devel@edk2.groups.io
> Cc: abner.ch...@amd.com; Nickle Wang ;
> ig...@ami.com; Mike Maslenkin 
> Subject: [edk2-redfish-client][PATCH 2/4] RedfishClientPkg: fix typo in
> EfiRestJsonStructureProtocolIsReady
> 
> External email: Use caution opening links or attachments
> 
> 
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> Cc: Nickle Wang 
> Signed-off-by: Mike Maslenkin 
> ---
>  RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> index 8b9bdc313832..85dc546120e2 100644
> --- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> @@ -562,7 +562,7 @@ EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL
> mRedfishConfigHandler = {  **/
> 
>  VOID
> 
>  EFIAPI
> 
> -EfiRestJasonStructureProtocolIsReady (
> 
> +EfiRestJsonStructureProtocolIsReady (
> 
>IN  EFI_EVENT  Event,
> 
>IN  VOID   *Context
> 
>)
> 
> @@ -829,7 +829,7 @@ RedfishResourceEntryPoint (
>EfiCreateProtocolNotifyEvent (
> 
>  ,
> 
>  TPL_CALLBACK,
> 
> -EfiRestJasonStructureProtocolIsReady,
> 
> +EfiRestJsonStructureProtocolIsReady,
> 
>  NULL,
> 
>  
> 
>  );
> 
> --
> 2.32.0 (Apple Git-132)



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




Re: [edk2-devel] [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add check for NULL pointer to avoid ASSERT

2023-12-14 Thread Nickle Wang via groups.io



Reviewed-by: Nickle Wang 

Regards,
Nickle

> -Original Message-
> From: Mike Maslenkin 
> Sent: Friday, December 15, 2023 8:04 AM
> To: devel@edk2.groups.io
> Cc: abner.ch...@amd.com; Nickle Wang ;
> ig...@ami.com; Mike Maslenkin 
> Subject: [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add check for NULL
> pointer to avoid ASSERT
> 
> External email: Use caution opening links or attachments
> 
> 
> Initially RedfishPlatformConfigGetConfigureLang could return success even if
> ConfigureLangList is empty. After fixing this condition,
> RedfishPlatformConfigGetConfigureLang returns an error, but this doesn't help 
> to
> avoid ASSERT because the error path is the same as for non-empty list.
> 
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> Cc: Nickle Wang 
> Signed-off-by: Mike Maslenkin 
> ---
>  .../RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c   | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> index 4cb7621c25c4..0f0b050d7eba 100644
> ---
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
> +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUt
> +++ ilityLib.c
> @@ -3118,7 +3118,9 @@ LeaveFunction:
>  FreePool (ConfigureLangBuffer);
> 
>}
> 
> 
> 
> -  FreePool (ConfigureLangList);
> 
> +  if (ConfigureLangList != NULL) {
> 
> +FreePool (ConfigureLangList);
> 
> +  }
> 
> 
> 
>*NumberOfValues = (UINT32)ListCount;
> 
>return FirstEmptyPropKeyValueList;
> 
> --
> 2.32.0 (Apple Git-132)



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




Re: [edk2-devel] [PATCH v3 4/6] OvmfPkg: Specifies SmmCpuSyncLib instance

2023-12-14 Thread Ni, Ray
Laszlo,
I like the "local lib override" idea, similar to the C language recommendation 
to use local variables instead of global ones when possible.

Thanks,
Ray
> -Original Message-
> From: Laszlo Ersek 
> Sent: Thursday, December 14, 2023 12:53 AM
> To: devel@edk2.groups.io; Wu, Jiaxin 
> Cc: Ard Biesheuvel ; Yao, Jiewen
> ; Justen, Jordan L ; Dong,
> Eric ; Ni, Ray ; Zeng, Star
> ; Kumar, Rahul R ; Gerd
> Hoffmann 
> Subject: Re: [edk2-devel] [PATCH v3 4/6] OvmfPkg: Specifies SmmCpuSyncLib
> instance
> 
> On 12/6/23 11:01, Wu, Jiaxin wrote:
> > This patch is to specify SmmCpuSyncLib instance for OvmfPkg.
> >
> > Cc: Laszlo Ersek 
> > Cc: Ard Biesheuvel 
> > Cc: Jiewen Yao 
> > Cc: Jordan Justen 
> > Cc: Eric Dong 
> > Cc: Ray Ni 
> > Cc: Zeng Star 
> > Cc: Rahul Kumar 
> > Cc: Gerd Hoffmann 
> > Signed-off-by: Jiaxin Wu 
> > ---
> >  OvmfPkg/CloudHv/CloudHvX64.dsc | 2 ++
> >  OvmfPkg/OvmfPkgIa32.dsc| 2 ++
> >  OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++
> >  OvmfPkg/OvmfPkgX64.dsc | 1 +
> >  4 files changed, 7 insertions(+)
> >
> > diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc
> b/OvmfPkg/CloudHv/CloudHvX64.dsc
> > index 821ad1b9fa..f735b69a37 100644
> > --- a/OvmfPkg/CloudHv/CloudHvX64.dsc
> > +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
> > @@ -183,10 +183,12 @@
> >
> PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.i
> nf
> >
> DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib
> .inf
> >
> ImagePropertiesRecordLib|MdeModulePkg/Library/ImagePropertiesRecordLi
> b/ImagePropertiesRecordLib.inf
> >  !if $(SMM_REQUIRE) == FALSE
> >LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
> > +!else
> > +
> SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
> >  !endif
> >
> CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Custo
> mizedDisplayLib.inf
> >
> FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBlt
> Lib.inf
> >
> MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncr
> yptTdxLib.inf
> >
> > diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> > index bce2aedcd7..b05b13b18c 100644
> > --- a/OvmfPkg/OvmfPkgIa32.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32.dsc
> > @@ -188,10 +188,12 @@
> >
> PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.i
> nf
> >
> DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib
> .inf
> >
> ImagePropertiesRecordLib|MdeModulePkg/Library/ImagePropertiesRecordLi
> b/ImagePropertiesRecordLib.inf
> >  !if $(SMM_REQUIRE) == FALSE
> >LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
> > +!else
> > +
> SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
> >  !endif
> >
> CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Custo
> mizedDisplayLib.inf
> >
> FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBlt
> Lib.inf
> >
> >  !if $(SOURCE_DEBUG_ENABLE) == TRUE
> > diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc
> b/OvmfPkg/OvmfPkgIa32X64.dsc
> > index 631e909a54..5a16eb7abe 100644
> > --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> > @@ -193,10 +193,12 @@
> >
> PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.i
> nf
> >
> DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib
> .inf
> >
> ImagePropertiesRecordLib|MdeModulePkg/Library/ImagePropertiesRecordLi
> b/ImagePropertiesRecordLib.inf
> >  !if $(SMM_REQUIRE) == FALSE
> >LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
> > +!else
> > +
> SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
> >  !endif
> >
> CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Custo
> mizedDisplayLib.inf
> >
> FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBlt
> Lib.inf
> >
> >  !if $(SOURCE_DEBUG_ENABLE) == TRUE
> > diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> > index 4ea3008cc6..6bb4c777b9 100644
> > --- a/OvmfPkg/OvmfPkgX64.dsc
> > +++ b/OvmfPkg/OvmfPkgX64.dsc
> > @@ -209,10 +209,11 @@
> >  !if $(SMM_REQUIRE) == FALSE
> >LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
> >CcProbeLib|OvmfPkg/Library/CcProbeLib/DxeCcProbeLib.inf
> >  !else
> >CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf
> > +
> SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
> >  !endif
> >
> CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Custo
> mizedDisplayLib.inf
> >
> FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBlt
> Lib.inf
> >
> >  !if $(SOURCE_DEBUG_ENABLE) == TRUE
> 
> All four DSC files already include "PiSmmCpuDxeSmm.inf" like this:
> 
>   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
> 
>   ...
>   }
> 
> Given that this new library class is again exclusively used by
> PiSmmCpuDxeSmm, can you please resolve this lib class too in module
> scope only?
> 
> Thanks!
> Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent 

Re: [edk2-devel] [RFC PATCH] RedfishPkg: RedfishDiscoverDxe: add [] brackets to URI for IPv6 addresses

2023-12-14 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

> -Original Message-
> From: Pedro Falcato 
> Sent: Wednesday, December 13, 2023 9:15 PM
> To: devel@edk2.groups.io; mike.maslen...@gmail.com
> Cc: Chang, Abner ; Nickle Wang
> ; Igor Kulchytskyy 
> Subject: Re: [edk2-devel] [RFC PATCH] RedfishPkg: RedfishDiscoverDxe: add []
> brackets to URI for IPv6 addresses
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Thu, Dec 7, 2023 at 1:24 PM Mike Maslenkin
>  wrote:
> >
> > URI is generated based on the RedfishLocation containing an ASCII string
> > representing the IP address. So, in the case of IPv4 the canonical
> > representation of an IPv4 address was inserted into the resulting Unicode
> > string i.e: "http{,s}://X.X.X.X/".
> >
> > In the case of IPv6, to access resources, the IP address must be specified
> > in brackets, i.e. the resulting string should look like:
> >   "http{,s}://[X::X:X:X:X]/".
> >
> > Cc: Abner Chang 
> > Cc: Nickle Wang 
> > Cc: Igor Kulchytskyy 
> > Signed-off-by: Mike Maslenkin 
> > ---
> >  .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 20 ---
> >  1 file changed, 17 insertions(+), 3 deletions(-)
> >
> > diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > index 28ba2d3a9fca..49c96bd28b27 100644
> > --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > @@ -863,9 +863,23 @@ AddAndSignalNewRedfishService (
> >  }
> >
> >  if (RedfishLocation != NULL) {
> > -  DiscoveredInstance->Information.Location = (CHAR16 *)AllocatePool
> (AsciiStrSize ((const CHAR8 *)RedfishLocation) * sizeof (CHAR16));
> > -  AsciiStrToUnicodeStrS ((const CHAR8 *)RedfishLocation,
> DiscoveredInstance->Information.Location, AsciiStrSize ((const CHAR8
> *)RedfishLocation) * sizeof (CHAR16));
> > -  DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n",
> DiscoveredInstance->Information.Location));
> > +  UINTNAllocSize;
> > +  CONST CHAR8  *IpAddress;
> > +
> > +  IpAddress = (CONST CHAR8 *)RedfishLocation;
> > +  AllocSize = AsciiStrSize (IpAddress) * sizeof (CHAR16);
> > +
> > +  if (CheckIsIpVersion6 (NetworkInterface)) {
> > +AllocSize += 2 * sizeof (CHAR16); // take into account '[' and ']'
> > +
> > +DiscoveredInstance->Information.Location = (CHAR16 *)AllocatePool
> (AllocSize);
>
> You don't check for NULL.
>
> > +UnicodeSPrintAsciiFormat (DiscoveredInstance->Information.Location,
> AllocSize, "[%a]", IpAddress);
> > +  } else {
> > +DiscoveredInstance->Information.Location = (CHAR16 *)AllocatePool
> (AllocSize);
>
> You don't check for NULL.
> Heck, why does no one check for NULL in this whole function
> (AddAndSignalNewRedfishService)?
Yes, we should check it. Could you please create a Bugzilla ticket for this?

Thanks
Abner

>
> --
> Pedro


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




[edk2-devel] [edk2-redfish-client][PATCH 2/4] RedfishClientPkg: fix typo in EfiRestJsonStructureProtocolIsReady

2023-12-14 Thread Mike Maslenkin
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nickle Wang 
Signed-off-by: Mike Maslenkin 
---
 RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c 
b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
index 8b9bdc313832..85dc546120e2 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
@@ -562,7 +562,7 @@ EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  
mRedfishConfigHandler = {
 **/
 VOID
 EFIAPI
-EfiRestJasonStructureProtocolIsReady (
+EfiRestJsonStructureProtocolIsReady (
   IN  EFI_EVENT  Event,
   IN  VOID   *Context
   )
@@ -829,7 +829,7 @@ RedfishResourceEntryPoint (
   EfiCreateProtocolNotifyEvent (
 ,
 TPL_CALLBACK,
-EfiRestJasonStructureProtocolIsReady,
+EfiRestJsonStructureProtocolIsReady,
 NULL,
 
 );
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [edk2-redfish-client][PATCH 3/4] RedfishClientPkg: fix access to unitialized variable.

2023-12-14 Thread Mike Maslenkin
It is possible that at the time of accessing to AsciiLocation pointer
the memory is not allocated.

Also gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) emits a warning for
this case:

RedfishFeatureUtilityLib.c:1889:37: error: 'AsciiLocation' may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
   *Location = StrAsciiToUnicode (AsciiLocation);

Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nickle Wang 
Signed-off-by: Mike Maslenkin 
---
 .../RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c| 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c 
b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
index 0f0b050d7eba..01c054ae3b70 100644
--- 
a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
+++ 
b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
@@ -1856,7 +1856,8 @@ GetEtagAndLocation (
   }
 
   if (Location != NULL) {
-*Location = NULL;
+*Location = NULL;
+AsciiLocation = NULL;
 
 if (*(Response->StatusCode) == HTTP_STATUS_200_OK) {
   Header = HttpFindHeader (Response->HeaderCount, Response->Headers, 
HTTP_HEADER_LOCATION);
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [edk2-redfish-client][PATCH 4/4] RedfishClientPkg: use POST method while provisioning new property.

2023-12-14 Thread Mike Maslenkin
If EdkIIRedfishResourceConfigCheck fails according to the logic and
comment: new resources should be provisioned, so the POST method must be
used. Fourth parameter of EdkIIRedfishResourceConfigProvisioning is
BOOLEAN HttpPostMode, so we pass TRUE here.

Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nickle Wang 
Signed-off-by: Mike Maslenkin 
---
 RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c 
b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
index a26a1083cd74..4fd4845f3420 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
@@ -818,9 +818,9 @@ HandleResource (
 // The target property does not exist, do the provision to create property.
 //
 DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __func__, Uri));
-Status = EdkIIRedfishResourceConfigProvisioning (, Uri, 
Private->InformationExchange, FALSE);
+Status = EdkIIRedfishResourceConfigProvisioning (, Uri, 
Private->InformationExchange, TRUE);
 if (EFI_ERROR (Status)) {
-  DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n", 
__func__, Status));
+  DEBUG ((DEBUG_ERROR, "%a, failed to provision with POST mode: %r\n", 
__func__, Status));
 }
 
 return Status;
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add check for NULL pointer to avoid ASSERT

2023-12-14 Thread Mike Maslenkin
Initially RedfishPlatformConfigGetConfigureLang could return success
even if ConfigureLangList is empty. After fixing this condition,
RedfishPlatformConfigGetConfigureLang returns an error, but this doesn't
help to avoid ASSERT because the error path is the same as for non-empty
list.

Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nickle Wang 
Signed-off-by: Mike Maslenkin 
---
 .../RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c 
b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
index 4cb7621c25c4..0f0b050d7eba 100644
--- 
a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
+++ 
b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
@@ -3118,7 +3118,9 @@ LeaveFunction:
 FreePool (ConfigureLangBuffer);
   }
 
-  FreePool (ConfigureLangList);
+  if (ConfigureLangList != NULL) {
+FreePool (ConfigureLangList);
+  }
 
   *NumberOfValues = (UINT32)ListCount;
   return FirstEmptyPropKeyValueList;
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [edk2-redfish-client][PATCH 0/4] change method for provisioning + minor fixes

2023-12-14 Thread Mike Maslenkin
This patch set contains minor fixes and the one major change related
to BIOS resources provisioning.

PR: https://github.com/tianocore/edk2-redfish-client/pull/64

Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nickle Wang 
Signed-off-by: Mike Maslenkin 




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




[edk2-devel] [PATCH] NetworkPkg/Ip4Dxe: Fix Reset To Default

2023-12-14 Thread Ashish Singhal via groups.io
Exercising reset to default does not reset the settings.
Add handler code for the case where configuration is
disabled.

Signed-off-by: Ashish Singhal 
---
 NetworkPkg/Ip4Dxe/Ip4Config2Nv.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/NetworkPkg/Ip4Dxe/Ip4Config2Nv.c b/NetworkPkg/Ip4Dxe/Ip4Config2Nv.c
index e0b6a4d4a9..dac5817b7c 100644
--- a/NetworkPkg/Ip4Dxe/Ip4Config2Nv.c
+++ b/NetworkPkg/Ip4Dxe/Ip4Config2Nv.c
@@ -586,6 +586,31 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
   }
 
   if (IfrFormNvData->Configure != TRUE) {
+if (Ip4NvData->DnsAddress != NULL) {
+  FreePool (Ip4NvData->DnsAddress);
+  Ip4NvData->DnsAddress  = NULL;
+  Ip4NvData->DnsAddressCount = 0;
+}
+
+if (Ip4NvData->GatewayAddress != NULL) {
+  FreePool (Ip4NvData->GatewayAddress);
+  Ip4NvData->GatewayAddress  = NULL;
+  Ip4NvData->GatewayAddressCount = 0;
+}
+
+if (Ip4NvData->ManualAddress != NULL) {
+  FreePool (Ip4NvData->ManualAddress);
+  Ip4NvData->ManualAddress  = NULL;
+  Ip4NvData->ManualAddressCount = 0;
+}
+
+Ip4NvData->Policy = Ip4Config2PolicyDhcp;
+Status= Ip4Cfg2->SetData (
+   Ip4Cfg2,
+   Ip4Config2DataTypePolicy,
+   sizeof (EFI_IP4_CONFIG2_POLICY),
+   >Policy
+   );
 return EFI_SUCCESS;
   }
 
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112572): https://edk2.groups.io/g/devel/message/112572
Mute This Topic: https://groups.io/mt/103181314/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/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test

2023-12-14 Thread Stuart Yoder
From: Joseph Hemann 

-add tests for HashLogExtendEvent()
  -tests with valid, invalid, and out of range parameters
  -do extend of data to PCR 16

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |  29 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  29 ++
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |  12 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 283 
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
|   9 +
 5 files changed, 362 insertions(+)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index d6797f5287f4..dcfd5919acda 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -56,3 +56,32 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID \
+{ 0xa8e1b5e6, 0xfc09, 0x461c, {0xb0, 0xe9, 0x2a, 0x49, 0xcd, 0x25, 0xc1, 0x24 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid007;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID \
+{ 0x26f04a9b, 0x7b7a, 0x4f47, {0xbe, 0xa8, 0xb1, 0xa6, 0x02, 0x65, 0x19, 0x8a 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID \
+{ 0x4d1d9985, 0x91e2, 0x4948, {0x89, 0x16, 0xbb, 0x98, 0x13, 0x62, 0x39, 0x1d 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID \
+{ 0xfb59cab7, 0x4f8c, 0x4ded, {0xa4, 0x1c, 0xc8, 0x41, 0x20, 0x1c, 0x37, 0x22 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid010;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID \
+{ 0x0363d22f, 0xc66a, 0x4872, {0xa5, 0x46, 0x06, 0x7f, 0x6a, 0x0d, 0xdb, 0xcd 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID \
+{ 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index 80c02d9ed2d2..cbbadef4a5c7 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -40,6 +40,15 @@ Abstract:
 #define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102 \
  {0x847f1ae0, 0xb429, 0x49f1, {0x9e, 0x0c, 0x8f, 0x43, 0xfb, 0x55, 0x34, 0x54} 
}
 
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \
+ {0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} 
}
+
+#define EV_POST_CODE 0x01
+
+#define EFI_TCG2_EXTEND_ONLY 0x0001
+
+#define PE_COFF_IMAGE 0x0010
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -82,6 +91,18 @@ BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2
   );
 
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint1 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint2 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
 EFI_STATUS
 BBTestGetCapabilityConformanceTest (
   IN EFI_BB_TEST_PROTOCOL   *This,
@@ -98,3 +119,11 @@ BBTestGetActivePcrBanksConformanceTest (
   IN EFI_HANDLE SupportHandle
   );
 
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTest (
+  IN EFI_BB_TEST_PROTOCOL   *This,
+  IN VOID   *ClientInterface,
+  IN EFI_TEST_LEVEL TestLevel,
+  IN EFI_HANDLE SupportHandle
+  );
+
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 0dc2cfddfcbf..ccc20259d128 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -39,3 +39,15 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid004 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 EFI_GUID gTcg2ConformanceTestAssertionGuid005 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
 
 EFI_GUID gTcg2ConformanceTestAssertionGuid006 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid007 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID;
+
+EFI_GUID 

[edk2-devel] [PATCH v1 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

2023-12-14 Thread Stuart Yoder
From: Joseph Hemann 

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |   5 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  71 
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |   2 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 173 
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
|   9 +
 5 files changed, 260 insertions(+)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index 746ff83f899c..044e549ce8f0 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -105,3 +105,8 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
 { 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 
}}
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid016;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_017_GUID \
+{ 0x3aac8b9a, 0x312a, 0x4dcf, {0x12, 0x76, 0x54, 0x55, 0x32, 0xcd, 0x3a, 0xea 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid017;
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index 5ce275dc6258..f8880599f150 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -54,6 +54,64 @@ Abstract:
 
 #define PE_COFF_IMAGE 0x0010
 
+// ST_NO_SESSION as defined in Table 19 of TPM Library Part 2: Structures
+#define ST_NO_SESSIONS (UINT16) 0x8001
+
+// TPM_RC_SUCCESS as defined in Table 16 of TPM Library Spec Part 2: Structures
+#define TPM_RC_SUCCESS (UINT32) 0x000
+
+// TPM_CC_Hash as defined in Table 12 of TPM Library Spec Part 2: Structures
+#define TPM_CC_Hash(UINT32)(0x017D)
+
+#define TPM_RH_NULL(UINT32) 0x4007
+
+#define TPM_ALG_SHA256 (UINT16) 0x000B
+
+#define SHA256_LENGTH (UINT16) 0x0020
+
+#pragma pack(1)
+// TPM2B_MAX_BUFFER as defined in Table 86 of TPM Library Spec Part 2: 
Structures
+// Size of buffer in spec is variable length, but hash test will always use a 
fixed length string
+// of length 43
+#define TEST_STRING_LEN 43
+typedef struct {
+  UINT16 size;
+  UINT8  buffer[TEST_STRING_LEN];
+} TPM2B_MAX_BUFFER;
+
+#pragma pack(1)
+// TPM2B_DIGEST as defined in Table 73 of TPM Library Spec Part 2: Structures
+typedef struct {
+  UINT16 size;
+  UINT8  digest[32];  // Size of buffer in spec is defined to be variable 
length but for this test will always be 32
+} TPM2B_DIGEST;
+
+typedef struct {
+  UINT16   tag;
+  UINT32   hierarchy;
+  UINT16   digest;  // Size of buffer in spec is defined to be 
variable length but for this test will always be UINT16
+} TPMT_TK_HASHCHECK;
+
+// TPM2_Hash command Structure as defined in Section 15.4 of TPM Spec Part 3: 
Commands
+typedef struct {
+  UINT16 Tag;
+  UINT32 CommandSize;
+  UINT32 CommandCode;
+  TPM2B_MAX_BUFFER data;
+  UINT16 hashAlg;
+  UINT32 hierarchy;
+} TPM2_HASH_COMMAND;
+
+// TPM2_Hash Response Structure as defined in Section 15.4 of TPM Spec Part 3: 
Commands
+typedef struct {
+  UINT16 Tag;
+  UINT32 ResponseSize;
+  UINT32 ResponseCode;
+  TPM2B_DIGEST data;
+  TPMT_TK_HASHCHECK validation;
+} TPM2_HASH_RESPONSE;
+#pragma
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -120,6 +178,12 @@ BBTestGetEventLogConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2
   );
 
+EFI_STATUS
+BBTestSubmitCommandConformanceTestCheckpoint1 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
 EFI_STATUS
 BBTestGetCapabilityConformanceTest (
   IN EFI_BB_TEST_PROTOCOL   *This,
@@ -144,3 +208,10 @@ BBTestHashLogExtendEventConformanceTest (
   IN EFI_HANDLE SupportHandle
   );
 
+EFI_STATUS
+BBTestSubmitCommandConformanceTest (
+  IN EFI_BB_TEST_PROTOCOL   *This,
+  IN VOID   *ClientInterface,
+  IN EFI_TEST_LEVEL TestLevel,
+  IN EFI_HANDLE SupportHandle
+  );
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 8c528aa8ddfc..9aa5315e670e 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -59,3 +59,5 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid014 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 EFI_GUID 

[edk2-devel] [PATCH v1 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test

2023-12-14 Thread Stuart Yoder
From: Joseph Hemann 

-add test for GetEventLog()
  -test for valid and invalid event log format
  -test event log header
  -verify expected event log entry

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |  20 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  17 ++
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h   
  |  46 +
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |   8 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 207 +++-
 5 files changed, 297 insertions(+), 1 deletion(-)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index dcfd5919acda..746ff83f899c 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -85,3 +85,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
 { 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \
+{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0x35 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \
+{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \
+{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0x51 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID \
+{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid016;
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index cbbadef4a5c7..5ce275dc6258 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -43,8 +43,13 @@ Abstract:
 #define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \
  {0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} 
}
 
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104 \
+ {0x9087ad78, 0x9ad2, 0x4172, {0x9a, 0xbc, 0x98, 0x23, 0x08, 0xf5, 0x6d, 0x26} 
}
+
 #define EV_POST_CODE 0x01
 
+#define EV_NO_ACTION 0x03
+
 #define EFI_TCG2_EXTEND_ONLY 0x0001
 
 #define PE_COFF_IMAGE 0x0010
@@ -103,6 +108,18 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2
   );
 
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint1 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint2 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
 EFI_STATUS
 BBTestGetCapabilityConformanceTest (
   IN EFI_BB_TEST_PROTOCOL   *This,
diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h 
b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
index 659c61a741e7..73e800af6205 100644
--- a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -50,6 +50,8 @@ Abstract:
 
 #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
 
+#define HASH_NUMBER 0x04
+
 typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
 
 typedef UINT64 EFI_PHYSICAL_ADDRESS;
@@ -117,6 +119,50 @@ typedef struct tdEFI_TCG2_EVENT {
   UINT8 Event[];
 } EFI_TCG2_EVENT;
 
+typedef struct {
+  UINT16 hashAlg;
+  UINT8  digest[];
+} TPMT_HA;
+
+typedef struct tdTPML_DIGEST_VALUES {
+  UINT32 Count;// number of digests
+  TPMT_HA Digests[HASH_NUMBER];// Count digests
+} TPML_DIGEST_VALUES;
+
+// This Declaration is for parsing the eventlog header which is defined to be 
20 bytes in TCG EFI Protocol Spec
+typedef UINT8 TCG_DIGEST[20];
+
+typedef struct tdTCG_PCR_EVENT2 {
+  TCG_PCRINDEX PCRIndex;   // PCRIndex event extended to
+  TCG_EVENTTYPE EventType; // Type of event (see [2])
+  TPML_DIGEST_VALUES Digests;  // List of digests extended to //PCRIndex
+  UINT32 EventSize;// Size of the event data
+  UINT8 *Event;// The event data
+} TCG_PCR_EVENT2;
+
+typedef struct tdTCG_PCR_EVENT {
+  UINT32 PCRIndex; // PCRIndex event extended to
+  UINT32 EventType; // Type of event (see EFI specs)
+  

[edk2-devel] [PATCH v1 0/6] Tests for TCG2 Protocol

2023-12-14 Thread Stuart Yoder
This patch series adds tests for the TCG2 Protocol which is implemented by EDK2.
The protocol is defined in chapter 6 in the TCG EFI Protocol Specification:
https://trustedcomputinggroup.org/resource/tcg-efi-protocol-specification/

The definition of the test cases is in a specification that has been
reviewed in 2022 by participants in the monthly Tianocore edk2-test bug triage
 meeting.  That spec is here:
https://github.com/stuyod01/edk2-test/blob/master/uefi-sct/Doc/UEFI-SCT-Case-Spec/30_Protocols_TCG2_Test.md

Bugzilla ticket for this is:
https://bugzilla.tianocore.org/show_bug.cgi?id=3736

The patches in this series are an updated version of code that has been
in the Arm SystemReady ACS for several years, and have been used as
part of SystemReady certifications.

There are tests for functions
  EFI_TCG2_PROTOCOL.GetCapability
  EFI_TCG2_PROTOCOL.GetEventLog
  EFI_TCG2_PROTOCOL.HashLogExtendEvent
  EFI_TCG2_PROTOCOL.SubmitCommand
  EFI_TCG2_PROTOCOL.GetActivePcrBanks

Joseph Hemann (6):
  uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol
definitions
  uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test
  uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test
  uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test
  uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
  uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

 uefi-sct/SctPkg/CommonGenFramework.sh |1 +
 uefi-sct/SctPkg/Config/Data/Category.ini  |7 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   63 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  112 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  217 +++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf  |   51 +
 .../TCG2ProtocolBBTestConformance.c   | 1181 +
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |  129 ++
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h  |  225 
 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc |1 +
 10 files changed, 1987 insertions(+)
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
 create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h

-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112565): https://edk2.groups.io/g/devel/message/112565
Mute This Topic: https://groups.io/mt/103181266/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/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions

2023-12-14 Thread Stuart Yoder
From: Joseph Hemann 

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 179 
 1 file changed, 179 insertions(+)

diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h 
b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
new file mode 100644
index ..659c61a741e7
--- /dev/null
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -0,0 +1,179 @@
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.
+  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+  TCG2.h
+
+Abstract:
+
+  EFI TCG Protocol
+
+--*/
+
+
+#ifndef __TCG2_PROTOCOL_H__
+#define __TCG2_PROTOCOL_H__
+
+//
+// Global ID for the TCG2 Protocol
+//
+#define EFI_TCG2_PROTOCOL_GUID\
+   {0x607f766c, 0x7455, 0x42be, {0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 
0x0f}}
+
+// Following defintions come from TCG2 Efi Protocol Spec
+#define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x0001
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x0002
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x0004
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x0008
+
+#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x0010
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x0001
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
+
+typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
+
+typedef UINT64 EFI_PHYSICAL_ADDRESS;
+
+typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP;
+
+typedef UINT32 EFI_TCG2_EVENT_LOG_FORMAT;
+
+typedef UINT32 EFI_TCG2_EVENT_ALGORITHM_BITMAP;
+
+typedef UINT32 TCG_PCRINDEX;
+
+typedef UINT32 TCG_EVENTTYPE;
+
+// Following struct defintions come from TCG2 Efi Protocol Spec
+typedef struct {
+  UINT8 Major;
+  UINT8 Minor;
+} EFI_TCG2_VERSION;
+
+typedef struct {
+  UINT8 Size;
+  EFI_TCG2_VERSION StructureVersion;
+  EFI_TCG2_VERSION ProtocolVersion;
+  EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap;
+  EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs;
+  BOOLEAN TPMPresentFlag;
+  UINT16 MaxCommandSize;
+  UINT16 MaxResponseSize;
+  UINT32 ManufacturerID;
+  UINT32 NumberOfPcrBanks;
+  EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks;
+} EFI_TCG2_BOOT_SERVICE_CAPABILITY;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_CAPABILITY) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_EVENT_LOG) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat,
+  OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,
+  OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry,
+  OUT BOOLEAN *EventLogTruncated
+);
+
+// all structs except EFI_TCG2_BOOT_SERVICE_CAPABILITY are packed
+#pragma pack(1)
+
+typedef struct tdEFI_TCG2_EVENT_HEADER {
+  UINT32 HeaderSize;
+  UINT16 HeaderVersion;
+  TCG_PCRINDEX PCRIndex;
+  TCG_EVENTTYPE EventType;
+} EFI_TCG2_EVENT_HEADER;
+
+typedef struct tdEFI_TCG2_EVENT {
+  UINT32 Size;
+  EFI_TCG2_EVENT_HEADER Header;
+  UINT8 Event[];
+} EFI_TCG2_EVENT;
+
+#pragma pack()
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_HASH_LOG_EXTEND_EVENT) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN UINT64 Flags,
+  IN EFI_PHYSICAL_ADDRESS DataToHash,
+  IN UINT64 DataToHashLen,
+  IN EFI_TCG2_EVENT *EfiTcgEvent
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SUBMIT_COMMAND) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN UINT32 InputParameterBlockSize,
+  IN UINT8 *InputParameterBlock,
+  IN UINT32 OutputParameterBlockSize,
+  IN UINT8 *OutputParameterBlock
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_ACTIVE_PCR_BANKS) (
+  IN EFI_TCG2_PROTOCOL *This,
+  OUT UINT32 *ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SET_ACTIVE_PCR_BANKS) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN UINT32 ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS) (
+  IN EFI_TCG2_PROTOCOL *This,
+  OUT UINT32 *OperationPresent,
+  OUT UINT32 *Response
+);
+
+//
+// Interface structure for the TCG2 Protocol
+//
+struct _EFI_TCG2_PROTOCOL {
+  EFI_TCG2_GET_CAPABILITY GetCapability;
+  EFI_TCG2_GET_EVENT_LOG GetEventLog;
+  EFI_TCG2_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;
+  EFI_TCG2_SUBMIT_COMMAND SubmitCommand;
+  EFI_TCG2_GET_ACTIVE_PCR_BANKS GetActivePcrBanks;
+  EFI_TCG2_SET_ACTIVE_PCR_BANKS SetActivePcrBanks;
+  EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS GetResultOfSetActivePcrBanks;
+};
+
+extern EFI_GUID gEfiTcg2ProtocolGuid;
+
+#endif
-- 
2.34.1



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

[edk2-devel] [PATCH v1 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test

2023-12-14 Thread Stuart Yoder
From: Joseph Hemann 

-add test for GetActivePcrBanks()
  -checkpoint for NULL pointer passed for buffer
  -checkpoint for test of function with proper input

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |  11 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  23 +++
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |   4 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 159 
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
|   9 ++
 5 files changed, 206 insertions(+)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index 50b14272939f..d6797f5287f4 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -45,3 +45,14 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;
 { 0x8ddb031b, 0x7448, 0x40ee, {0xb1, 0xa2, 0xe6, 0xf8, 0xe8, 0xc4, 0xe5, 0x5f 
}}
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID \
+{ 0x7a1e79a3, 0x4064, 0x4372, {0xbb, 0x64, 0x55, 0xb8, 0xf2, 0xa5, 0xa3, 0x26 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID \
+{ 0xb0e717c4, 0xb1e2, 0x49f7, {0xb2, 0xd7, 0x60, 0x58, 0x97, 0x7d, 0x09, 0x2c 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
+
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index a7ce2db322d9..80c02d9ed2d2 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -37,6 +37,9 @@ Abstract:
 #define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101 \
  {0x39ff9c71, 0x4b41, 0x4e5b, {0xae, 0xd7, 0x87, 0xc7, 0x94, 0x18, 0x7d, 0x67} 
}
 
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102 \
+ {0x847f1ae0, 0xb429, 0x49f1, {0x9e, 0x0c, 0x8f, 0x43, 0xfb, 0x55, 0x34, 0x54} 
}
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -67,6 +70,18 @@ BBTestGetCapabilityConformanceTestCheckpoint4 (
   IN EFI_TCG2_PROTOCOL *TCG2
   );
 
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint1 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
 EFI_STATUS
 BBTestGetCapabilityConformanceTest (
   IN EFI_BB_TEST_PROTOCOL   *This,
@@ -75,3 +90,11 @@ BBTestGetCapabilityConformanceTest (
   IN EFI_HANDLE SupportHandle
   );
 
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTest (
+  IN EFI_BB_TEST_PROTOCOL   *This,
+  IN VOID   *ClientInterface,
+  IN EFI_TEST_LEVEL TestLevel,
+  IN EFI_HANDLE SupportHandle
+  );
+
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 3e75ffdc0a60..0dc2cfddfcbf 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -35,3 +35,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid002 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 EFI_GUID gTcg2ConformanceTestAssertionGuid003 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID;
 
 EFI_GUID gTcg2ConformanceTestAssertionGuid004 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid005 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid006 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID;
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 686cf4baebcd..681f57ac224a 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -87,6 +87,58 @@ BBTestGetCapabilityConformanceTest (
   return EFI_SUCCESS;
 }
 
+/**
+ *  @brief Entrypoint for GetActivePcrBanks() Function Test.
+ * 2 checkpoints will be tested.
+ *  @param This a pointer of EFI_BB_TEST_PROTOCOL
+ *  @param ClientInterface A pointer to the interface 

[edk2-devel] [PATCH v1 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test

2023-12-14 Thread Stuart Yoder
From: Joseph Hemann 

-implement initial infrastructure for the TCG2 protocol test
 including updates to .dsc file, inf file, GUID source files,
 update to Category.ini.

-add test case for GetCapability(), as defined in the TCG EFI
 Protocol Spec 6.4.4.

-add checkpoint for NULL pointer passed for buffer

-add checkpoint for validating fields of the struct returned by GetCapability()

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc  
  |   1 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
  |  51 +++
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |  47 +++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  77 +
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |  37 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 361 
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
| 102 ++
 uefi-sct/SctPkg/CommonGenFramework.sh  
  |   1 +
 uefi-sct/SctPkg/Config/Data/Category.ini   
  |   7 +
 9 files changed, 684 insertions(+)

diff --git a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc 
b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
index 155490fa39d3..96c93e73992c 100644
--- a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
+++ b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
@@ -301,6 +301,7 @@ 
SctPkg/TestCase/UEFI/EFI/Protocol/StorageSecurityCommand/BlackBoxTest/StorageSec
 
SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoProtocolBBTest.inf
 
SctPkg/TestCase/UEFI/EFI/Protocol/TimeStamp/BlackBoxTest/TimeStampProtocolBBTest.inf
 
SctPkg/TestCase/UEFI/EFI/Protocol/RandomNumber/BlackBoxTest/RandomNumberBBTest.inf
+SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 
 SctPkg/TestCase/UEFI/EFI/Protocol/Hash2/BlackBoxTest/Hash2BBTest.inf
 SctPkg/TestCase/UEFI/EFI/Protocol/PKCS7Verify/BlackBoxTest/Pkcs7BBTest.inf
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
new file mode 100644
index ..563d81b7e859
--- /dev/null
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
@@ -0,0 +1,51 @@
+## @file
+#
+#  Copyright 2006 - 2015 Unified EFI, Inc.
+#  Copyright (c) 2013, Intel Corporation. All rights reserved.
+#  Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+##
+#/*++
+#
+# Module Name:
+#
+#   TCG2ProtocolBBTest.inf
+#
+# Abstract:
+#
+#   Component description file for TCG2 Protocol Black-Box Test.
+#
+#--*/
+
+[defines]
+  INF_VERSION  = 0x00010005
+  BASE_NAME= TCG2ProtocolBBTest
+  FILE_GUID= BD8CB762-3935-434C-AC3F-462244910A2D
+  MODULE_TYPE  = UEFI_DRIVER
+  VERSION_STRING   = 1.0
+  ENTRY_POINT  = InitializeBBTestTCG2Protocol
+
+[sources.common]
+  Guid.c
+  TCG2ProtocolBBTestMain.c
+  TCG2ProtocolBBTestConformance.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  SctPkg/SctPkg.dec
+  SctPkg/UEFI/UEFI.dec
+
+[LibraryClasses]
+  UefiDriverEntryPoint
+  SctLib
+  EfiTestLib
+
+[Protocols]
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
new file mode 100644
index ..50b14272939f
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -0,0 +1,47 @@
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.
+  Copyright (c) 2013, Intel Corporation. All rights reserved.
+  Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+  guid.h
+
+Abstract:
+
+  GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+
+#define 

Re: [edk2-devel] [PATCH] MdeModulePkg/ResetSystemRuntimeDxe: Print Reset Data

2023-12-14 Thread Ashish Singhal via groups.io
Hello Gao,

Checking if you have any feedback on this.

Thanks
Ashish

From: Ashish Singhal 
Sent: Wednesday, December 6, 2023 5:21 PM
To: devel@edk2.groups.io ; gaolim...@byosoft.com.cn 
; Jeff Brasen 
Cc: Ashish Singhal 
Subject: [PATCH] MdeModulePkg/ResetSystemRuntimeDxe: Print Reset Data

ResetSystem runtime call allows for sending reset data that
starts with a NULL terminated string. Add support to print
that string on console.

Signed-off-by: Ashish Singhal 
---
 .../Universal/ResetSystemRuntimeDxe/ResetSystem.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c 
b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
index 42f1b1d015..72bb1d2be6 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
@@ -252,6 +252,14 @@ RuntimeServiceResetSystem (
 mResetNotifyDepth
 ));

+  if ((ResetData != NULL) && (DataSize != 0)) {
+DEBUG ((
+  DEBUG_INFO,
+  "DXE ResetSystem2: ResetData: %s\n",
+  ResetData
+  ));
+  }
+
   if (mResetNotifyDepth <= MAX_RESET_NOTIFY_DEPTH) {
 if (!EfiAtRuntime ()) {
   //
--
2.17.1



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




[edk2-devel] [PATCH v2 13/14] RedfishDiscoverDxe: handle memory allocation error conditions.

2023-12-14 Thread Mike Maslenkin
Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
---
 .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 85 ---
 1 file changed, 75 insertions(+), 10 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 3499a855570c..9d1678c3429e 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -748,38 +748,103 @@ InitInformationData (
   if (RedfishLocation != NULL) {
 AllocationSize= AsciiStrSize (RedfishLocation) * sizeof (CHAR16);
 Information->Location = AllocatePool (AllocationSize);
-AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, 
AllocationSize);
-DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", 
Information->Location));
+if (Information->Location != NULL) {
+  AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, 
AllocationSize);
+  DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", 
Information->Location));
+} else {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: Can not allocate memory for Redfish service location: %a.\n",
+__func__,
+RedfishLocation
+));
+}
   }
 
   if (Uuid != NULL) {
 AllocationSize= AsciiStrSize (Uuid) * sizeof (CHAR16);
 Information->Uuid = AllocatePool (AllocationSize);
-AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize);
-DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uuid));
+if (Information->Uuid != NULL) {
+  AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize);
+  DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uuid));
+} else {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: Can not allocate memory for Service UUID: %a.\n",
+__func__,
+Uuid
+));
+}
   }
 
   if (Os != NULL) {
 AllocationSize  = AsciiStrSize (Os) * sizeof (CHAR16);
 Information->Os = AllocatePool (AllocationSize);
-AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize);
+if (Information->Os != NULL) {
+  AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize);
+} else {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: Can not allocate memory for Redfish service OS: %a.\n",
+__func__,
+Os
+));
+}
   }
 
   if (OsVer != NULL) {
 AllocationSize = AsciiStrSize (OsVer) * sizeof (CHAR16);
 Information->OsVersion = AllocatePool (AllocationSize);
-AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AllocationSize);
-DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n", 
Information->Os, Information->OsVersion));
+if (Information->OsVersion != NULL) {
+  AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AllocationSize);
+  DEBUG ((
+DEBUG_MANAGEABILITY,
+"Redfish service OS: %s, Version:%s.\n",
+Information->Os,
+Information->OsVersion
+));
+} else {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: Can not allocate memory for Redfish OS Version:%a.\n",
+__func__,
+OsVer
+));
+}
   }
 
   if ((Product != NULL) && (ProductVer != NULL)) {
 AllocationSize   = AsciiStrSize (Product) * sizeof (CHAR16);
 Information->Product = AllocatePool (AllocationSize);
-AsciiStrToUnicodeStrS (Product, Information->Product, AllocationSize);
+if (Information->Product != NULL) {
+  AsciiStrToUnicodeStrS (Product, Information->Product, AllocationSize);
+} else {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: Can not allocate memory for Redfish service product: %a.\n",
+__func__,
+Product
+));
+}
+
 AllocationSize  = AsciiStrSize (ProductVer) * sizeof (CHAR16);
 Information->ProductVer = AllocatePool (AllocationSize);
-AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, 
AllocationSize);
-DEBUG ((DEBUG_MANAGEABILITY, "Redfish service product: %s, Version:%s.\n", 
Information->Product, Information->ProductVer));
+if (Information->ProductVer != NULL) {
+  AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, 
AllocationSize);
+  DEBUG ((
+DEBUG_MANAGEABILITY,
+"Redfish service product: %s, Version:%s.\n",
+Information->Product,
+Information->ProductVer
+));
+} else {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: Can not allocate memory for Redfish service product Version: 
%a.\n",
+__func__,
+ProductVer
+));
+}
   }
 }
 
-- 
2.32.0 (Apple Git-132)



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

[edk2-devel] [PATCH v2 14/14] RedfishPkg: RedfishDiscoverDxe: add [] brackets to URI for IPv6 addresses

2023-12-14 Thread Mike Maslenkin
URI is generated based on the RedfishLocation containing an ASCII string
representing the IP address. So, in the case of IPv4 the canonical
representation of an IPv4 address was inserted into the resulting Unicode
string i.e: "http{,s}://X.X.X.X/".

In the case of IPv6, to access resources, the IP address must be specified
in brackets, i.e. the resulting string should look like:
  "http{,s}://[X::X:X:X:X]/".

Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
---
 .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 21 ---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 9d1678c3429e..38eaf4f6decc 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -715,6 +715,7 @@ DiscoverRedfishHostInterface (
   The function initalizes particular strings into 
EFI_REDFISH_DISCOVERED_INFORMATION structure
 
   @param[in]  Information   EFI_REDFISH_DISCOVERED_INFORMATION
+  @param[in]  IsIpv6Flag indicating IP version 6 protocol is 
used
   @param[in]  RedfishVersionRedfish version.
   @param[in]  RedfishLocation   Redfish location.
   @param[in]  Uuid  Service UUID string.
@@ -729,6 +730,7 @@ STATIC
 VOID
 InitInformationData (
   IN EFI_REDFISH_DISCOVERED_INFORMATION  *Information,
+  IN BOOLEAN IsIpv6,
   IN UINTN   *RedfishVersion OPTIONAL,
   IN CONST CHAR8 *RedfishLocation OPTIONAL,
   IN CONST CHAR8 *Uuid OPTIONAL,
@@ -738,7 +740,8 @@ InitInformationData (
   IN CONST CHAR8 *ProductVer OPTIONAL
   )
 {
-  UINTN  AllocationSize;
+  UINTNAllocationSize;
+  CONST CHAR8  *IpAddress;
 
   if (RedfishVersion != NULL) {
 Information->RedfishVersion = *RedfishVersion;
@@ -746,10 +749,21 @@ InitInformationData (
   }
 
   if (RedfishLocation != NULL) {
-AllocationSize= AsciiStrSize (RedfishLocation) * sizeof (CHAR16);
+AllocationSize = AsciiStrSize (RedfishLocation) * sizeof (CHAR16);
+IpAddress  = RedfishLocation;
+
+if (IsIpv6) {
+  AllocationSize += 2 * sizeof (CHAR16); // take into account '[' and ']'
+}
+
 Information->Location = AllocatePool (AllocationSize);
 if (Information->Location != NULL) {
-  AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, 
AllocationSize);
+  if (IsIpv6) {
+UnicodeSPrintAsciiFormat (Information->Location, AllocationSize, 
"[%a]", IpAddress);
+  } else {
+AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, 
AllocationSize);
+  }
+
   DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", 
Information->Location));
 } else {
   DEBUG ((
@@ -991,6 +1005,7 @@ AddAndSignalNewRedfishService (
 
 InitInformationData (
   >Information,
+  CheckIsIpVersion6 (NetworkInterface),
   RedfishVersion,
   RedfishLocation,
   Uuid,
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [PATCH v2 12/14] RedfishDiscoverDxe: refine InitInformationData() function

2023-12-14 Thread Mike Maslenkin
Cache size of ASCII string in local variable.

Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
---
 .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 34 ---
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index e3fc2d809dbc..3499a855570c 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -738,39 +738,47 @@ InitInformationData (
   IN CONST CHAR8 *ProductVer OPTIONAL
   )
 {
+  UINTN  AllocationSize;
+
   if (RedfishVersion != NULL) {
 Information->RedfishVersion = *RedfishVersion;
 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service version: %d.\n", 
Information->RedfishVersion));
   }
 
   if (RedfishLocation != NULL) {
-Information->Location = AllocatePool (AsciiStrSize (RedfishLocation) * 
sizeof (CHAR16));
-AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, 
AsciiStrSize (RedfishLocation) * sizeof (CHAR16));
+AllocationSize= AsciiStrSize (RedfishLocation) * sizeof (CHAR16);
+Information->Location = AllocatePool (AllocationSize);
+AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, 
AllocationSize);
 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", 
Information->Location));
   }
 
   if (Uuid != NULL) {
-Information->Uuid = AllocatePool (AsciiStrSize (Uuid) * sizeof (CHAR16));
-AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AsciiStrSize (Uuid) * 
sizeof (CHAR16));
+AllocationSize= AsciiStrSize (Uuid) * sizeof (CHAR16);
+Information->Uuid = AllocatePool (AllocationSize);
+AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize);
 DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uuid));
   }
 
   if (Os != NULL) {
-Information->Os = AllocatePool (AsciiStrSize (Os) * sizeof (CHAR16));
-AsciiStrToUnicodeStrS (Os, Information->Os, AsciiStrSize (Os) * sizeof 
(CHAR16));
-DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n", 
Information->Os, Information->OsVersion));
+AllocationSize  = AsciiStrSize (Os) * sizeof (CHAR16);
+Information->Os = AllocatePool (AllocationSize);
+AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize);
   }
 
   if (OsVer != NULL) {
-Information->OsVersion = AllocatePool (AsciiStrSize (OsVer) * sizeof 
(CHAR16));
-AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AsciiStrSize (OsVer) 
* sizeof (CHAR16));
+AllocationSize = AsciiStrSize (OsVer) * sizeof (CHAR16);
+Information->OsVersion = AllocatePool (AllocationSize);
+AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AllocationSize);
+DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n", 
Information->Os, Information->OsVersion));
   }
 
   if ((Product != NULL) && (ProductVer != NULL)) {
-Information->Product = AllocatePool (AsciiStrSize (Product) * sizeof 
(CHAR16));
-AsciiStrToUnicodeStrS (Product, Information->Product, AsciiStrSize 
(Product) * sizeof (CHAR16));
-Information->ProductVer = AllocatePool (AsciiStrSize (ProductVer) * sizeof 
(CHAR16));
-AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, AsciiStrSize 
(ProductVer) * sizeof (CHAR16));
+AllocationSize   = AsciiStrSize (Product) * sizeof (CHAR16);
+Information->Product = AllocatePool (AllocationSize);
+AsciiStrToUnicodeStrS (Product, Information->Product, AllocationSize);
+AllocationSize  = AsciiStrSize (ProductVer) * sizeof (CHAR16);
+Information->ProductVer = AllocatePool (AllocationSize);
+AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, 
AllocationSize);
 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service product: %s, Version:%s.\n", 
Information->Product, Information->ProductVer));
   }
 }
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [PATCH v2 10/14] RedfishDiscoverDxe: introduce InitInformationData helper function

2023-12-14 Thread Mike Maslenkin
Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
---
 .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 108 --
 1 file changed, 74 insertions(+), 34 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index e344e06d8dcc..724aa35431a8 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -711,6 +711,69 @@ DiscoverRedfishHostInterface (
   return Status;
 }
 
+/**
+  The function initalizes particular strings into 
EFI_REDFISH_DISCOVERED_INFORMATION structure
+
+  @param[in]  Information   EFI_REDFISH_DISCOVERED_INFORMATION
+  @param[in]  RedfishVersionRedfish version.
+  @param[in]  RedfishLocation   Redfish location.
+  @param[in]  Uuid  Service UUID string.
+  @param[in]  OsOS string.
+  @param[in]  OsVer OS version string.
+  @param[in]  Product   Product string.
+  @param[in]  ProductVerProduct version string.
+
+**/
+STATIC
+VOID
+InitInformationData (
+  IN EFI_REDFISH_DISCOVERED_INFORMATION  *Information,
+  IN UINTN   *RedfishVersion OPTIONAL,
+  IN CHAR8   *RedfishLocation OPTIONAL,
+  IN CHAR8   *Uuid  OPTIONAL,
+  IN CHAR8   *Os  OPTIONAL,
+  IN CHAR8   *OsVer  OPTIONAL,
+  IN CHAR8   *Product  OPTIONAL,
+  IN CHAR8   *ProductVer  OPTIONAL
+  )
+{
+  if (RedfishVersion != NULL) {
+Information->RedfishVersion = *RedfishVersion;
+DEBUG ((DEBUG_MANAGEABILITY, "Redfish service version: %d.\n", 
Information->RedfishVersion));
+  }
+
+  if (RedfishLocation != NULL) {
+Information->Location = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 
*)RedfishLocation) * sizeof (CHAR16));
+AsciiStrToUnicodeStrS ((const CHAR8 *)RedfishLocation, 
Information->Location, AsciiStrSize ((const CHAR8 *)RedfishLocation) * sizeof 
(CHAR16));
+DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", 
Information->Location));
+  }
+
+  if (Uuid != NULL) {
+Information->Uuid = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 
*)Uuid) * sizeof (CHAR16));
+AsciiStrToUnicodeStrS ((const CHAR8 *)Uuid, Information->Uuid, 
AsciiStrSize ((const CHAR8 *)Uuid) * sizeof (CHAR16));
+DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uuid));
+  }
+
+  if (Os != NULL) {
+Information->Os = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)Os) 
* sizeof (CHAR16));
+AsciiStrToUnicodeStrS ((const CHAR8 *)Os, Information->Os, AsciiStrSize 
((const CHAR8 *)Os) * sizeof (CHAR16));
+DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n", 
Information->Os, Information->OsVersion));
+  }
+
+  if (OsVer != NULL) {
+Information->OsVersion = (CHAR16 *)AllocatePool (AsciiStrSize ((const 
CHAR8 *)OsVer) * sizeof (CHAR16));
+AsciiStrToUnicodeStrS ((const CHAR8 *)OsVer, Information->OsVersion, 
AsciiStrSize ((const CHAR8 *)OsVer) * sizeof (CHAR16));
+  }
+
+  if ((Product != NULL) && (ProductVer != NULL)) {
+Information->Product = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 
*)Product) * sizeof (CHAR16));
+AsciiStrToUnicodeStrS ((const CHAR8 *)Product, Information->Product, 
AsciiStrSize ((const CHAR8 *)Product) * sizeof (CHAR16));
+Information->ProductVer = (CHAR16 *)AllocatePool (AsciiStrSize ((const 
CHAR8 *)ProductVer) * sizeof (CHAR16));
+AsciiStrToUnicodeStrS ((const CHAR8 *)ProductVer, Information->ProductVer, 
AsciiStrSize ((const CHAR8 *)ProductVer) * sizeof (CHAR16));
+DEBUG ((DEBUG_MANAGEABILITY, "Redfish service product: %s, Version:%s.\n", 
Information->Product, Information->ProductVer));
+  }
+}
+
 /**
   The function adds a new found Redfish service to internal list and
   notify client.
@@ -851,41 +915,17 @@ AddAndSignalNewRedfishService (
 DEBUG ((DEBUG_MANAGEABILITY, "*** Redfish Service Information ***\n"));
 
 DiscoveredInstance->Information.UseHttps = UseHttps;
-if (RedfishVersion != NULL) {
-  DiscoveredInstance->Information.RedfishVersion = *RedfishVersion;
-  DEBUG ((DEBUG_MANAGEABILITY, "Redfish service version: %d.\n", 
DiscoveredInstance->Information.RedfishVersion));
-}
 
-if (RedfishLocation != NULL) {
-  DiscoveredInstance->Information.Location = (CHAR16 *)AllocatePool 
(AsciiStrSize ((const CHAR8 *)RedfishLocation) * sizeof (CHAR16));
-  AsciiStrToUnicodeStrS ((const CHAR8 *)RedfishLocation, 
DiscoveredInstance->Information.Location, AsciiStrSize ((const CHAR8 
*)RedfishLocation) * sizeof (CHAR16));
-  DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", 
DiscoveredInstance->Information.Location));
-}
-
-if (Uuid != NULL) {
-  

[edk2-devel] [PATCH v2 11/14] RedfishDiscoverDxe: refine InitInformationData(), remove unnecessary casts

2023-12-14 Thread Mike Maslenkin
Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Cc: Pedro Falcato 
Signed-off-by: Mike Maslenkin 
---
 .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 36 +--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 724aa35431a8..e3fc2d809dbc 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -730,12 +730,12 @@ VOID
 InitInformationData (
   IN EFI_REDFISH_DISCOVERED_INFORMATION  *Information,
   IN UINTN   *RedfishVersion OPTIONAL,
-  IN CHAR8   *RedfishLocation OPTIONAL,
-  IN CHAR8   *Uuid  OPTIONAL,
-  IN CHAR8   *Os  OPTIONAL,
-  IN CHAR8   *OsVer  OPTIONAL,
-  IN CHAR8   *Product  OPTIONAL,
-  IN CHAR8   *ProductVer  OPTIONAL
+  IN CONST CHAR8 *RedfishLocation OPTIONAL,
+  IN CONST CHAR8 *Uuid OPTIONAL,
+  IN CONST CHAR8 *Os OPTIONAL,
+  IN CONST CHAR8 *OsVer OPTIONAL,
+  IN CONST CHAR8 *Product OPTIONAL,
+  IN CONST CHAR8 *ProductVer OPTIONAL
   )
 {
   if (RedfishVersion != NULL) {
@@ -744,33 +744,33 @@ InitInformationData (
   }
 
   if (RedfishLocation != NULL) {
-Information->Location = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 
*)RedfishLocation) * sizeof (CHAR16));
-AsciiStrToUnicodeStrS ((const CHAR8 *)RedfishLocation, 
Information->Location, AsciiStrSize ((const CHAR8 *)RedfishLocation) * sizeof 
(CHAR16));
+Information->Location = AllocatePool (AsciiStrSize (RedfishLocation) * 
sizeof (CHAR16));
+AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, 
AsciiStrSize (RedfishLocation) * sizeof (CHAR16));
 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", 
Information->Location));
   }
 
   if (Uuid != NULL) {
-Information->Uuid = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 
*)Uuid) * sizeof (CHAR16));
-AsciiStrToUnicodeStrS ((const CHAR8 *)Uuid, Information->Uuid, 
AsciiStrSize ((const CHAR8 *)Uuid) * sizeof (CHAR16));
+Information->Uuid = AllocatePool (AsciiStrSize (Uuid) * sizeof (CHAR16));
+AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AsciiStrSize (Uuid) * 
sizeof (CHAR16));
 DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uuid));
   }
 
   if (Os != NULL) {
-Information->Os = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)Os) 
* sizeof (CHAR16));
-AsciiStrToUnicodeStrS ((const CHAR8 *)Os, Information->Os, AsciiStrSize 
((const CHAR8 *)Os) * sizeof (CHAR16));
+Information->Os = AllocatePool (AsciiStrSize (Os) * sizeof (CHAR16));
+AsciiStrToUnicodeStrS (Os, Information->Os, AsciiStrSize (Os) * sizeof 
(CHAR16));
 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n", 
Information->Os, Information->OsVersion));
   }
 
   if (OsVer != NULL) {
-Information->OsVersion = (CHAR16 *)AllocatePool (AsciiStrSize ((const 
CHAR8 *)OsVer) * sizeof (CHAR16));
-AsciiStrToUnicodeStrS ((const CHAR8 *)OsVer, Information->OsVersion, 
AsciiStrSize ((const CHAR8 *)OsVer) * sizeof (CHAR16));
+Information->OsVersion = AllocatePool (AsciiStrSize (OsVer) * sizeof 
(CHAR16));
+AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AsciiStrSize (OsVer) 
* sizeof (CHAR16));
   }
 
   if ((Product != NULL) && (ProductVer != NULL)) {
-Information->Product = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 
*)Product) * sizeof (CHAR16));
-AsciiStrToUnicodeStrS ((const CHAR8 *)Product, Information->Product, 
AsciiStrSize ((const CHAR8 *)Product) * sizeof (CHAR16));
-Information->ProductVer = (CHAR16 *)AllocatePool (AsciiStrSize ((const 
CHAR8 *)ProductVer) * sizeof (CHAR16));
-AsciiStrToUnicodeStrS ((const CHAR8 *)ProductVer, Information->ProductVer, 
AsciiStrSize ((const CHAR8 *)ProductVer) * sizeof (CHAR16));
+Information->Product = AllocatePool (AsciiStrSize (Product) * sizeof 
(CHAR16));
+AsciiStrToUnicodeStrS (Product, Information->Product, AsciiStrSize 
(Product) * sizeof (CHAR16));
+Information->ProductVer = AllocatePool (AsciiStrSize (ProductVer) * sizeof 
(CHAR16));
+AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, AsciiStrSize 
(ProductVer) * sizeof (CHAR16));
 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service product: %s, Version:%s.\n", 
Information->Product, Information->ProductVer));
   }
 }
-- 
2.32.0 (Apple Git-132)



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

[edk2-devel] [PATCH v2 09/14] EmulatorPkg: RedfishPlatformHostInterfaceLib: get rid of unused variable

2023-12-14 Thread Mike Maslenkin
Cc: Abner Chang 
Cc: Nickle Wang 
Signed-off-by: Mike Maslenkin 
---
 .../RedfishPlatformHostInterfaceLib.c   | 2 --
 1 file changed, 2 deletions(-)

diff --git 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
index 4332caa71016..71b3dfc64358 100644
--- 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
+++ 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
@@ -42,12 +42,10 @@ GetMacAddressInformation (
   OUT EFI_MAC_ADDRESS  *MacAddress
   )
 {
-  MAC_ADDR_DEVICE_PATH  *Mac;
   REST_EX_SERVICE_DEVICE_PATH_DATA  *RestExServiceDevicePathData;
   EFI_DEVICE_PATH_PROTOCOL  *RestExServiceDevicePath;
   MAC_ADDR_DEVICE_PATH  *MacAddressDevicePath;
 
-  Mac = NULL;
   RestExServiceDevicePathData = NULL;
   RestExServiceDevicePath = NULL;
 
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [PATCH v2 08/14] EmulatorPkg: fix typo. PcdRedfishServie -> PcdRedfishService

2023-12-14 Thread Mike Maslenkin
Cc: Abner Chang 
Cc: Nickle Wang 
Signed-off-by: Mike Maslenkin 
---
 EmulatorPkg/EmulatorPkg.dec  |  8 
 .../RedfishPlatformCredentialLib.c   | 12 ++--
 .../RedfishPlatformCredentialLib.inf |  8 
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/EmulatorPkg/EmulatorPkg.dec b/EmulatorPkg/EmulatorPkg.dec
index fe81652b0478..c2a92923e9b7 100644
--- a/EmulatorPkg/EmulatorPkg.dec
+++ b/EmulatorPkg/EmulatorPkg.dec
@@ -77,15 +77,15 @@
   ## Platform level Redfish Service control PCD
   # These PCDs are used to stop the Redfish sevice when secure boot is disabled
   # or exit boot service.
-  
gEmulatorPkgTokenSpaceGuid.PcdRedfishServieStopIfSecureBootDisabled|TRUE|BOOLEAN|0x1020
-  
gEmulatorPkgTokenSpaceGuid.PcdRedfishServieStopIfExitbootService|TRUE|BOOLEAN|0x1021
+  
gEmulatorPkgTokenSpaceGuid.PcdRedfishServiceStopIfSecureBootDisabled|TRUE|BOOLEAN|0x1020
+  
gEmulatorPkgTokenSpaceGuid.PcdRedfishServiceStopIfExitbootService|TRUE|BOOLEAN|0x1021
   ##
   # edk2 Redfish implementation on Emulator package is designed to access
   # to Redfish simulator.
   # https://github.com/DMTF/Redfish-Profile-Simulator
   # The user ID and password are fixed as below.
-  gEmulatorPkgTokenSpaceGuid.PcdRedfishServieUserId|"admin"|VOID*|0x1022
-  
gEmulatorPkgTokenSpaceGuid.PcdRedfishServiePassword|"pwd123456"|VOID*|0x1023
+  gEmulatorPkgTokenSpaceGuid.PcdRedfishServiceUserId|"admin"|VOID*|0x1022
+  
gEmulatorPkgTokenSpaceGuid.PcdRedfishServicePassword|"pwd123456"|VOID*|0x1023
   
gEmulatorPkgTokenSpaceGuid.PcdPersistentMemorySize|0x400|UINT32|0x1024
 
 [PcdsFixedAtBuild, PcdsPatchableInModule]
diff --git 
a/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c
 
b/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c
index 614eaebb0d0e..5c167fcdea56 100644
--- 
a/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c
+++ 
b/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c
@@ -57,8 +57,8 @@ GetRedfishCredential (
   //
   // User ID and Password.
   //
-  UserIdSize   = AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdRedfishServieUserId));
-  PasswordSize = AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdRedfishServiePassword));
+  UserIdSize   = AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdRedfishServiceUserId));
+  PasswordSize = AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdRedfishServicePassword));
   if ((UserIdSize == 0) || (PasswordSize == 0)) {
 DEBUG ((DEBUG_ERROR, "Incorrect string of UserID or Password for REdfish 
service.\n"));
 return EFI_INVALID_PARAMETER;
@@ -69,7 +69,7 @@ GetRedfishCredential (
 return EFI_OUT_OF_RESOURCES;
   }
 
-  CopyMem (*UserId, (CHAR8 *)PcdGetPtr (PcdRedfishServieUserId), UserIdSize);
+  CopyMem (*UserId, (CHAR8 *)PcdGetPtr (PcdRedfishServiceUserId), UserIdSize);
 
   *Password = AllocateZeroPool (PasswordSize);
   if (*Password == NULL) {
@@ -77,7 +77,7 @@ GetRedfishCredential (
 return EFI_OUT_OF_RESOURCES;
   }
 
-  CopyMem (*Password, (CHAR8 *)PcdGetPtr (PcdRedfishServiePassword), 
PasswordSize);
+  CopyMem (*Password, (CHAR8 *)PcdGetPtr (PcdRedfishServicePassword), 
PasswordSize);
   return EFI_SUCCESS;
 }
 
@@ -177,7 +177,7 @@ LibStopRedfishService (
 // Check platform PCD to determine the action for stopping
 // Redfish service due to secure boot is disabled.
 //
-if (!PcdGetBool (PcdRedfishServieStopIfSecureBootDisabled)) {
+if (!PcdGetBool (PcdRedfishServiceStopIfSecureBootDisabled)) {
   return EFI_UNSUPPORTED;
 } else {
   //
@@ -198,7 +198,7 @@ LibStopRedfishService (
 // Check platform PCD to determine the action for stopping
 // Redfish service due to exit boot service.
 //
-if (PcdGetBool (PcdRedfishServieStopIfExitbootService)) {
+if (PcdGetBool (PcdRedfishServiceStopIfExitbootService)) {
   return EFI_UNSUPPORTED;
 } else {
   mStopRedfishService = TRUE;
diff --git 
a/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.inf
 
b/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.inf
index 41c389c4a292..9d151f14ee17 100644
--- 
a/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.inf
+++ 
b/EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.inf
@@ -36,10 +36,10 @@
   UefiLib
 
 [Pcd]
-  gEmulatorPkgTokenSpaceGuid.PcdRedfishServieStopIfSecureBootDisabled ## 
CONSUMES
-  gEmulatorPkgTokenSpaceGuid.PcdRedfishServieStopIfExitbootService## 
CONSUMES
-  gEmulatorPkgTokenSpaceGuid.PcdRedfishServieUserId   ## 
CONSUMES
-  gEmulatorPkgTokenSpaceGuid.PcdRedfishServiePassword ## 
CONSUMES
+  gEmulatorPkgTokenSpaceGuid.PcdRedfishServiceStopIfSecureBootDisabled ## 
CONSUMES
+  gEmulatorPkgTokenSpaceGuid.PcdRedfishServiceStopIfExitbootService## 
CONSUMES
+  

[edk2-devel] [PATCH v2 07/14] RedfishPkg: add proper initialization of IPMI request

2023-12-14 Thread Mike Maslenkin
All fields of IPMI_CHANNEL_INFO_CHANNEL_NUMBER union must be
initialized to avoid error condition on BMC side.

Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
---
 .../PlatformHostInterfaceBmcUsbNicLib.c   | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
index 7f295fe7f1c0..c73e76df5791 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
+++ 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
@@ -616,9 +616,10 @@ HostInterfaceIpmiCheckMacAddress (
   }
 
   // Initial the get MAC address request.
-  GetLanConfigReq.SetSelector   = 0;
-  GetLanConfigReq.BlockSelector = 0;
-  GetLanConfigReq.ParameterSelector = IpmiLanMacAddress;
+  GetLanConfigReq.ChannelNumber.Uint8 = 0;
+  GetLanConfigReq.SetSelector = 0;
+  GetLanConfigReq.BlockSelector   = 0;
+  GetLanConfigReq.ParameterSelector   = IpmiLanMacAddress;
 
   ExitStatus = EFI_NOT_FOUND;
   for (ChannelNum = IPMI_CHANNEL_NUMBER_IMPLEMENTATION_SPECIFIC_1;
@@ -640,6 +641,7 @@ HostInterfaceIpmiCheckMacAddress (
 } else {
   DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "  No cached IPMI LAN info\n"));
   DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "  Send NetFn = App, Command = 
0x42 to channel %d\n", ChannelNum));
+  GetChanelInfoRequest.ChannelNumber.Uint8  = 0;
   GetChanelInfoRequest.ChannelNumber.Bits.ChannelNo = (UINT8)ChannelNum;
   Status= IpmiGetChannelInfo (
 
,
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [PATCH v2 06/14] RedfishPkg: add Component Name protocols to RedfishConfigHandler driver

2023-12-14 Thread Mike Maslenkin
Currently there is no description for RedfishConfigHandler driver.
This leads to  in the "DRIVER NAME" column of a `drivers`
command for example.

Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
---
 .../RedfishConfigHandler/ComponentName.c  | 216 ++
 .../RedfishConfigHandlerDriver.c  |  10 +-
 .../RedfishConfigHandlerDriver.h  |   4 +-
 .../RedfishConfigHandlerDriver.inf|   1 +
 4 files changed, 228 insertions(+), 3 deletions(-)
 create mode 100644 RedfishPkg/RedfishConfigHandler/ComponentName.c

diff --git a/RedfishPkg/RedfishConfigHandler/ComponentName.c 
b/RedfishPkg/RedfishConfigHandler/ComponentName.c
new file mode 100644
index ..c6b8b189f3e1
--- /dev/null
+++ b/RedfishPkg/RedfishConfigHandler/ComponentName.c
@@ -0,0 +1,218 @@
+/** @file
+  Implementation of EFI_COMPONENT_NAME_PROTOCOL and 
EFI_COMPONENT_NAME2_PROTOCOL protocol
+  for EFI Refish Config Handler Protocol
+
+  Copyright (c) 2023, Mike Maslenkin 
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "RedfishConfigHandlerCommon.h"
+
+//
+// EFI Component Name Functions
+//
+
+/**
+  Retrieves a Unicode string that is the user-readable name of the EFI Driver.
+
+  @param[in]  This   A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+  @param[in]  Language   A pointer to a three-character ISO 639-2 language 
identifier.
+ This is the language of the driver name that the 
caller
+ is requesting, and it must match one of the languages 
specified
+ in SupportedLanguages.  The number of languages 
supported by a
+ driver is up to the driver writer.
+  @param[out] DriverName A pointer to the Unicode string to return.  This 
Unicode string
+ is the name of the driver specified by This in the 
language
+ specified by Language.
+
+  @retval EFI_SUCCESS   The Unicode string for the Driver specified by 
This
+and the language specified by Language was 
returned
+in DriverName.
+  @retval EFI_INVALID_PARAMETER Language is NULL.
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.
+  @retval EFI_UNSUPPORTED   The driver specified by This does not support 
the
+language specified by Language.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishConfigHandlerComponentNameGetDriverName (
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
+  IN  CHAR8*Language,
+  OUT CHAR16   **DriverName
+  );
+
+/**
+  Retrieves a Unicode string that is the user readable name of the controller
+  that is being managed by an EFI Driver.
+
+  @param[in]  This A pointer to the EFI_COMPONENT_NAME_PROTOCOL 
instance.
+  @param[in]  ControllerHandle The handle of a controller that the driver 
specified by
+   This is managing.  This handle specifies the 
controller
+   whose name is to be returned.
+  @param[in]  ChildHandle  The handle of the child controller to retrieve 
the name
+   of.  This is an optional parameter that may be 
NULL.  It
+   will be NULL for device drivers.  It will also 
be NULL
+   for a bus drivers that wish to retrieve the 
name of the
+   bus controller.  It will not be NULL for a bus 
driver
+   that wishes to retrieve the name of a child 
controller.
+  @param[in]  Language A pointer to a three character ISO 639-2 
language
+   identifier.  This is the language of the 
controller name
+   that the caller is requesting, and it must 
match one
+   of the languages specified in 
SupportedLanguages.  The
+   number of languages supported by a driver is up 
to the
+   driver writer.
+  @param[out]  ControllerName  A pointer to the Unicode string to return.  
This Unicode
+   string is the name of the controller specified 
by
+   ControllerHandle and ChildHandle in the 
language specified
+   by Language, from the point of view of the 
driver specified
+   by This.
+
+  @retval EFI_SUCCESS   The Unicode string for the user-readable name 
in the
+language specified by Language for the driver
+specified by This was returned in DriverName.
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid 
EFI_HANDLE.
+  @retval EFI_INVALID_PARAMETER Language 

[edk2-devel] [PATCH v2 05/14] RedfishPkg: RedfishDiscoverDxe: fix memory leak on error path.

2023-12-14 Thread Mike Maslenkin
Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
---
 RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 06d8d00da7fb..e344e06d8dcc 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -829,6 +829,10 @@ AddAndSignalNewRedfishService (
 } while (TRUE);
   }
 
+  if (Char16Uuid != NULL) {
+FreePool (Char16Uuid);
+  }
+
   if (NewFound || InfoRefresh) {
 if (!InfoRefresh) {
   DiscoveredList = (EFI_REDFISH_DISCOVERED_INTERNAL_LIST 
*)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVERED_INTERNAL_LIST));
@@ -907,10 +911,6 @@ AddAndSignalNewRedfishService (
 }
   }
 
-  if (Char16Uuid != NULL) {
-FreePool ((VOID *)Char16Uuid);
-  }
-
   Status = EFI_SUCCESS;
   if (NewFound || InfoRefresh) {
 //
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [PATCH v2 04/14] RedfishPkg: RedfishPlatformConfigDxe: reduce memory allocations

2023-12-14 Thread Mike Maslenkin
It's unclear why the new string is allocated as copy of the original
string if its pointer is stored in an array and the original string
is released immediately after the copy is created. All data allocated
in the same pool.

Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
---
 .../RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c   | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c 
b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
index cbc65ba59408..f970e317b3f6 100644
--- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
+++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
@@ -2057,9 +2057,7 @@ RedfishPlatformConfigProtocolGetConfigureLang (
 TmpString = HiiGetRedfishString 
(StatementRef->Statement->ParentForm->ParentFormset->HiiHandle, FullSchema, 
StatementRef->Statement->Description);
 ASSERT (TmpString != NULL);
 if (TmpString != NULL) {
-  TmpConfigureLangList[Index] = AllocateCopyPool (StrSize (TmpString), 
TmpString);
-  ASSERT (TmpConfigureLangList[Index] != NULL);
-  FreePool (TmpString);
+  TmpConfigureLangList[Index] = TmpString;
   ++Index;
 }
   }
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [PATCH v2 01/14] RedfishPkg: fix RedfishPlatformHostInterfaceLib library class name typo.

2023-12-14 Thread Mike Maslenkin
PlatformHostInterfaceBmcUsbNicLib is the library instance name not
the class name.

Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
---
 .../PlatformHostInterfaceBmcUsbNicLib.inf   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.inf
 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.inf
index 838a1721a7ae..3660249a3588 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.inf
+++ 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.inf
@@ -14,7 +14,7 @@
   FILE_GUID  = C4837B58-225E-4352-8FDC-4C52A5D65891
   MODULE_TYPE= DXE_DRIVER
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = PlatformHostInterfaceBmcUsbNicLib
+  LIBRARY_CLASS  = RedfishPlatformHostInterfaceLib
 
 [Sources]
   PlatformHostInterfaceBmcUsbNicLib.c
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [PATCH v2 02/14] RedfishPkg: fix RedfishPlatformCredentialLib library class name typo.

2023-12-14 Thread Mike Maslenkin
RedfishPlatformCredentialIpmiLib is the library instance name not the
class name.

Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
---
 .../RedfishPlatformCredentialIpmiLib.inf| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/RedfishPkg/Library/RedfishPlatformCredentialIpmiLib/RedfishPlatformCredentialIpmiLib.inf
 
b/RedfishPkg/Library/RedfishPlatformCredentialIpmiLib/RedfishPlatformCredentialIpmiLib.inf
index 5c20ea22f894..935461e1dcd0 100644
--- 
a/RedfishPkg/Library/RedfishPlatformCredentialIpmiLib/RedfishPlatformCredentialIpmiLib.inf
+++ 
b/RedfishPkg/Library/RedfishPlatformCredentialIpmiLib/RedfishPlatformCredentialIpmiLib.inf
@@ -13,7 +13,7 @@
   FILE_GUID  = 9C45D622-4C66-417F-814C-F76246D97233
   MODULE_TYPE= DXE_DRIVER
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = RedfishPlatformCredentialIpmiLib
+  LIBRARY_CLASS  = RedfishPlatformCredentialLib
 
 [Sources]
   RedfishPlatformCredentialIpmiLib.c
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [PATCH v2 03/14] RedfishPkg: get rid of unused definitions from RedfishCrtLib.h

2023-12-14 Thread Mike Maslenkin
It seems that initial implementation of this header file is based on
CrtLibSupport.h from CryptoPkg. But uid, euid, gid, egid and sa_family_t
sre not used in RedfishPkg. So remove them.

Also take "true" and "false" definition from MdePkg's LibFdtSupport.h
header file, that also seems based on a header mentioned above.

Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
---
 RedfishPkg/Include/Library/RedfishCrtLib.h | 45 ++
 1 file changed, 11 insertions(+), 34 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishCrtLib.h 
b/RedfishPkg/Include/Library/RedfishCrtLib.h
index ac6c5162ad6a..0c51a03d0e1a 100644
--- a/RedfishPkg/Include/Library/RedfishCrtLib.h
+++ b/RedfishPkg/Include/Library/RedfishCrtLib.h
@@ -69,20 +69,17 @@
 //
 // Basic types mapping
 //
-typedef UINTN   size_t;
-typedef INTNssize_t;
-typedef INT32   time_t;
-typedef UINT8   __uint8_t;
-typedef UINT8   sa_family_t;
-typedef UINT32  uid_t;
-typedef UINT32  gid_t;
-typedef INT32   int32_t;
-typedef UINT32  uint32_t;
-typedef UINT16  uint16_t;
-typedef UINT8   uint8_t;
-typedef enum {
-  false, true
-} bool;
+typedef UINTNsize_t;
+typedef INTN ssize_t;
+typedef INT32time_t;
+typedef INT32int32_t;
+typedef UINT32   uint32_t;
+typedef UINT16   uint16_t;
+typedef UINT8uint8_t;
+typedef BOOLEAN  bool;
+
+#define true   (1 == 1)
+#define false  (1 == 0)
 
 //
 // File operations are not required for EFI building,
@@ -343,26 +340,6 @@ fgetc   (
   FILE  *_File
   );
 
-uid_t
-getuid  (
-  void
-  );
-
-uid_t
-geteuid (
-  void
-  );
-
-gid_t
-getgid  (
-  void
-  );
-
-gid_t
-getegid (
-  void
-  );
-
 void
 qsort   (
   void *,
-- 
2.32.0 (Apple Git-132)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112552): https://edk2.groups.io/g/devel/message/112552
Mute This Topic: https://groups.io/mt/103181038/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/14] Redfish related fixes and improvements

2023-12-14 Thread Mike Maslenkin
This is an exapanded version of the original set of 9 patches with
additional patch introducing brackets for IPv6 Redfish resource location
with required changes according to comments for the initial RFC patch.

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

diff from v1:
  fixed typo double "that that"
  removed variable declaration in block scope
  added patches 10-13
  removed unnecessary casts
  added checks for memory allocation result

Cc: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112549): https://edk2.groups.io/g/devel/message/112549
Mute This Topic: https://groups.io/mt/103181035/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] NetworkPkg: Triger regularly scan only if not connect to AP

2023-12-14 Thread Saloni Kasbekar
Mike,

Would you be able to help us merge the patch?

Thanks,
Saloni

-Original Message-
From: Luo, Heng  
Sent: Thursday, December 14, 2023 3:20 AM
To: Clark-williams, Zachary ; Kasbekar, 
Saloni ; devel@edk2.groups.io
Subject: RE: [PATCH v2] NetworkPkg: Triger regularly scan only if not connect 
to AP

Hi Saloni,
Could you help to merge the patch?

Thanks,
Heng

> -Original Message-
> From: Luo, Heng
> Sent: Monday, December 11, 2023 4:13 PM
> To: Clark-williams, Zachary ; 
> Kasbekar, Saloni ; devel@edk2.groups.io
> Subject: RE: [PATCH v2] NetworkPkg: Triger regularly scan only if not 
> connect to AP
> 
> Hi Zack,
> Could you please review the change?
> Thanks,
> Heng
> 
> > -Original Message-
> > From: Kasbekar, Saloni 
> > Sent: Saturday, December 2, 2023 5:25 AM
> > To: Luo, Heng ; devel@edk2.groups.io
> > Cc: Clark-williams, Zachary 
> > Subject: RE: [PATCH v2] NetworkPkg: Triger regularly scan only if 
> > not connect to AP
> >
> > Reviewed-by: Kasbekar, Saloni 
> >
> > Thanks,
> > Saloni
> >
> > -Original Message-
> > From: Luo, Heng 
> > Sent: Monday, November 27, 2023 7:07 PM
> > To: devel@edk2.groups.io
> > Cc: Kasbekar, Saloni ; Clark-williams, 
> > Zachary 
> > Subject: [PATCH v2] NetworkPkg: Triger regularly scan only if not 
> > connect to AP
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4605
> >
> > When UEFI Wi-Fi is in BSS connected state, the platform is 
> > considered as a static and Wi-Fi roaming support is not needed.
> > Wifi connection manager should not initiate Scan requests in this 
> > state affect BSS client connectivity and must be avoided.
> > Triger regularly scan only if not connect to AP.
> >
> > Signed-off-by: Heng Luo 
> > Cc: Saloni Kasbekar 
> > Cc: Zachary Clark-williams 
> > ---
> >  NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c | 4 ++-
> -
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git
> > a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c
> > b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c
> > index d1182e52bd..4c5460b65c 100644
> > --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c
> > +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c
> > @@ -1506,8 +1506,8 @@ WifiMgrOnTimerTick (
> >}Nic->ScanTickTime++;-  if (((Nic->ScanTickTime >
> > WIFI_SCAN_FREQUENCY) || Nic->OneTimeScanRequest) &&-  (Nic-
> > >ScanState == WifiMgrScanFinished))+  if Nic->ScanTickTime >
> > WIFI_SCAN_FREQUENCY) && (Nic->ConnectState !=
> WifiMgrConnectedToAp))
> > ||+   Nic->OneTimeScanRequest) && (Nic->ScanState ==
> > WifiMgrScanFinished))   { Nic->OneTimeScanRequest = FALSE; Nic-
> > >ScanTickTime   = 0;--
> > 2.31.1.windows.1



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




Re: [edk2-devel] [PATCH v3 7/7] OvmfPkg/RiscVVirt: SEC: Add IO memory resource hob for platform devices

2023-12-14 Thread Tuan Phan
On Thu, Dec 7, 2023 at 11:36 PM Andrei Warkentin 
wrote:

> Hi Tuan,
>
>
>
> I noticed that the OvmfPkg RV Sec uses PopulateIoResources by adding
> entries to GCD of type EFI_RESOURCE_MEMORY_MAPPED_IO. Contrast this with
> edk2-platforms/Platforms/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c,
> which adds these as memory and then allocates them away as
> EfiReservedMemoryType. I remember this came up during the upstreaming of
> the Raspberry Pi port…
>
>
>
> Anything we add as MMIO will end up growing the Runtime Services mappings,
> as MMIO are specifically non-memory mappings that need to be present during
> OS use of RT services. It’s probably a good idea to avoid using MMIO
> regions for all I/O used by Boot Services.
>
>
>
Agree. Will post a patch to fix it.


> A
>
>
>
>
>
> *From:* Tuan Phan 
> *Sent:* Thursday, June 22, 2023 3:28 PM
> *To:* devel@edk2.groups.io; tp...@ventanamicro.com
> *Cc:* Ard Biesheuvel ; Kinney, Michael D <
> michael.d.kin...@intel.com>; Gao, Liming ; Liu,
> Zhiguang ; suni...@ventanamicro.com;
> g...@danielschaefer.me; Warkentin, Andrei 
> *Subject:* Re: [edk2-devel] [PATCH v3 7/7] OvmfPkg/RiscVVirt: SEC: Add IO
> memory resource hob for platform devices
>
>
>
>
>
>
>
> On Thu, Jun 22, 2023 at 11:41 AM Tuan Phan  wrote:
>
>
>
>
>
> On Tue, May 30, 2023 at 10:38 AM Tuan Phan via groups.io  ventanamicro@groups.io> wrote:
>
>
>
>
>
> On Mon, May 29, 2023 at 7:07 AM Ard Biesheuvel  wrote:
>
> On Sat, 27 May 2023 at 01:18, Tuan Phan  wrote:
> >
> > Normally, DXE driver would add device resource to GCD before start using.
> > But some key resources such as uart, flash base address are being
> accessing
> > directly in some core modules.
> >
> > Those resources should be populated to HOB in SEC phase so they are
> > added to GCD before anyone can access them.
> >
>
> Why should these be in the GCD to begin with?
>
>
>
> These resources should be in memory space so their addresses and size are
> registered with MMU. If not when MMU enabled, illegal access exception when
> someone access them.
>
>
>
> Hi Ard,
>
> Do you still have concerns about this patch?
>
> BTW, I will drop this patch and put VirtNorFlashDxe in APRIORI DXE list to
> make sure it runs before VariableRuntimeDxe.
>
>
> > Signed-off-by: Tuan Phan 
> > Reviewed-by: Andrei Warkentin 
>
> > ---
> >  OvmfPkg/RiscVVirt/Sec/Platform.c  | 62 +++
> >  OvmfPkg/RiscVVirt/Sec/SecMain.inf |  1 +
> >  2 files changed, 63 insertions(+)
> >
> > diff --git a/OvmfPkg/RiscVVirt/Sec/Platform.c
> b/OvmfPkg/RiscVVirt/Sec/Platform.c
> > index 3645c27b0b12..944b82c84a6e 100644
> > --- a/OvmfPkg/RiscVVirt/Sec/Platform.c
> > +++ b/OvmfPkg/RiscVVirt/Sec/Platform.c
> > @@ -21,6 +21,63 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> >  #include 
> >  #include 
> >
> > +/**
> > +  Build memory map I/O range resource HOB using the
> > +  base address and size.
> > +
> > +  @param  MemoryBase Memory map I/O base.
> > +  @param  MemorySize Memory map I/O size.
> > +
> > +**/
> > +STATIC
> > +VOID
> > +AddIoMemoryBaseSizeHob (
> > +  EFI_PHYSICAL_ADDRESS  MemoryBase,
> > +  UINT64MemorySize
> > +  )
> > +{
> > +  /* Align to EFI_PAGE_SIZE */
> > +  MemorySize = ALIGN_VALUE (MemorySize, EFI_PAGE_SIZE);
> > +  BuildResourceDescriptorHob (
> > +EFI_RESOURCE_MEMORY_MAPPED_IO,
> > +EFI_RESOURCE_ATTRIBUTE_PRESENT |
> > +EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
> > +EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
> > +EFI_RESOURCE_ATTRIBUTE_TESTED,
> > +MemoryBase,
> > +MemorySize
> > +);
> > +}
> > +
> > +/**
> > +  Populate IO resources from FDT that not added to GCD by its
> > +  driver in the DXE phase.
> > +
> > +  @param  FdtBase   Fdt base address
> > +  @param  CompatibleCompatible string
> > +
> > +**/
> > +STATIC
> > +VOID
> > +PopulateIoResources (
> > +  VOID  *FdtBase,
> > +  CONST CHAR8*  Compatible
> > +  )
> > +{
> > +  UINT64  *Reg;
> > +  INT32   Node, LenP;
> > +
> > +  Node = fdt_node_offset_by_compatible (FdtBase, -1, Compatible);
> > +  while (Node != -FDT_ERR_NOTFOUND) {
> > +Reg = (UINT64 *)fdt_getprop (FdtBase, Node, "reg", );
> > +if (Reg) {
> > +  ASSERT (LenP == (2 * sizeof (UINT64)));
> > +  AddIoMemoryBaseSizeHob (SwapBytes64 (Reg[0]), SwapBytes64
> (Reg[1]));
> > +}
> > +Node = fdt_node_offset_by_compatible (FdtBase, Node, Compatible);
> > +  }
> > +}
> > +
> >  /**
> >@retval EFI_SUCCESSThe address of FDT is passed in HOB.
> >EFI_UNSUPPORTEDCan't locate FDT.
> > @@ -80,5 +137,10 @@ PlatformPeimInitialization (
> >
> >BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32
> (PcdOvmfDxeMemFvSize));
> >
> > +  PopulateIoResources (Base, "ns16550a");
> > +  PopulateIoResources (Base, "qemu,fw-cfg-mmio");
> > +  PopulateIoResources (Base, "virtio,mmio");
> > +  AddIoMemoryBaseSizeHob (PcdGet32 (PcdOvmfFdBaseAddress), PcdGet32
> (PcdOvmfFirmwareFdSize));
> > +
> >   

Re: [edk2-devel] [PATCH] ArmPkg/DebugPeCoffExtraActionLib: Drop RVCT and Cygwin support

2023-12-14 Thread Ard Biesheuvel
On Thu, 14 Dec 2023 at 15:59, Sami Mujawar  wrote:
>
> Hi Leif, Ard,
>
> On 14/12/2023, 14:46, "Leif Lindholm"  > wrote:
>
>
> +Sami (who I know once, a very long time ago, used cygwin)
> [SAMI] Now that we have WSL, I have stopped using Cygwin.
> Also, this patch looks good to me.
>
> Reviewed-by: Sami Mujawar 
>

Merged as #5148

Thanks all

>
> On Thu, Dec 14, 2023 at 10:20:46 +0100, Ard Biesheuvel wrote:
> > From: Ard Biesheuvel mailto:a...@kernel.org>>
> >
> > The DebugPeCoffExtraActionLib implemention in ArmPkg contains some cruft
> > that dates back to the original RVCT based ARM port, and support for
> > RVCT was dropped a while ago.
> >
> > Also drop the handling of Cygwin specific paths, which is highly
> > unlikely to be still depended upon by anyone.
> >
> > Tweak the logic so that only two versions of the DEBUG() invocations
> > remain: one for __GNUC__ when PdbPointer is set, and the fallback that
> > just prints the image address and the address of the entrypoint.
> >
> > Cc: Mike Beaton mailto:mjsbea...@gmail.com>>
> > Signed-off-by: Ard Biesheuvel mailto:a...@kernel.org>>
>
>
> But as far as I'm concerned, cygwin support feels extremely dated
> these days and not worth the maintainance overhead to keep around.
> So
> Reviewed-by: Leif Lindholm  >
>
>
> /
> Leif
>
>
> > ---
> > ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c | 100 
> > ++--
> > 1 file changed, 31 insertions(+), 69 deletions(-)
> >
> > diff --git 
> > a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c 
> > b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> > index 432112354fda..992c14d7ef9b 100644
> > --- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> > +++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> > @@ -17,45 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > #include 
> > #include 
> >
> > -/**
> > - If the build is done on cygwin the paths are cygpaths.
> > - /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
> > - them to work with RVD commands
> > -
> > - @param Name Path to convert if needed
> > -
> > -**/
> > -CHAR8 *
> > -DeCygwinPathIfNeeded (
> > - IN CHAR8 *Name,
> > - IN CHAR8 *Temp,
> > - IN UINTN Size
> > - )
> > -{
> > - CHAR8 *Ptr;
> > - UINTN Index;
> > - UINTN Index2;
> > -
> > - Ptr = AsciiStrStr (Name, "/cygdrive/");
> > - if (Ptr == NULL) {
> > - return Name;
> > - }
> > -
> > - for (Index = 9, Index2 = 0; (Index < (Size + 9)) && (Ptr[Index] != '\0'); 
> > Index++, Index2++) {
> > - Temp[Index2] = Ptr[Index];
> > - if (Temp[Index2] == '/') {
> > - Temp[Index2] = '\\';
> > - }
> > -
> > - if (Index2 == 1) {
> > - Temp[Index2 - 1] = Ptr[Index];
> > - Temp[Index2] = ':';
> > - }
> > - }
> > -
> > - return Temp;
> > -}
> > -
> > /**
> > Performs additional actions after a PE/COFF image has been loaded and 
> > relocated.
> >
> > @@ -71,23 +32,24 @@ PeCoffLoaderRelocateImageExtraAction (
> > IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
> > )
> > {
> > - #if !defined (MDEPKG_NDEBUG)
> > - CHAR8 Temp[512];
> > - #endif
> > -
> > +#ifdef __GNUC__
> > if (ImageContext->PdbPointer) {
> > - #ifdef __CC_ARM
> > - // Print out the command for the DS-5 to load symbols for this image
> > - DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", 
> > DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
> > (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
> > - #elif __GNUC__
> > - // This may not work correctly if you generate PE/COFF directly as then 
> > the Offset would not be required
> > - DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", 
> > DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
> > (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
> > - #else
> > - DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p 
> > EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, 
> > FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
> > - #endif
> > - } else {
> > - DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p 
> > EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, 
> > FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
> > + DEBUG ((
> > + DEBUG_LOAD | DEBUG_INFO,
> > + "add-symbol-file %a 0x%p\n",
> > + ImageContext->PdbPointer,
> > + (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)
> > + ));
> > + return;
> > }
> > +#endif
> > +
> > + DEBUG ((
> > + DEBUG_LOAD | DEBUG_INFO,
> > + "Loading driver at 0x%11p EntryPoint=0x%11p\n",
> > + (VOID *)(UINTN)ImageContext->ImageAddress,
> > + FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)
> > + ));
> > }
> >
> > /**
> > @@ -106,21 +68,21 @@ PeCoffLoaderUnloadImageExtraAction (
> > IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
> > )
> > {
> > - #if !defined (MDEPKG_NDEBUG)
> > - CHAR8 Temp[512];
> > - 

Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg/VirtNorFlashDxe: sanity-check variables

2023-12-14 Thread Laszlo Ersek
On 12/14/23 16:31, Gerd Hoffmann wrote:
>   Hi,
>  
>> The general idea is, once we don't trust the varstore, there cannot be
>> a *single* unchecked addition in the code. (Unless we can *prove* that
>> overflow is impossible.)
> 
> There are some cases where we add a small, constant number to a value we
> know is smaller than VariableStoreHeader->Size.  I don't see how those
> can overflow, given that varstore flash typically is an order of
> magnitude smaller than MAX_UINT32

OK. Please add comments about these though, possibly expressed as ASSERT()s.

> (unless VariableStoreHeader->Size is
> corrupted, but then we have bigger problems anyway ...).

Right... I had given some thought to that as well. If there's an easy --
albeit perhaps arbitrary -- range check for that up-front, maybe we
should do it. Maybe.

But I'm certainly not asking for armoring existent code in the affected
function. That's too much work -- ridding all existent code of overflows
is just a special case of eliminating technical debt, and there is
enough technical debt in edk2 to spend a lifetime fixing. The only
reasonable approach I can imagine is to stop introducing technical debt,
or *at least* to fix technical debt at a higher rate than adding it.
(This is no small challenge.)

Thanks,
Laszlo



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




Re: [edk2-devel] [PATCH v3 3/6] UefiCpuPkg: Implements SmmCpuSyncLib library instance

2023-12-14 Thread Wu, Jiaxin
BTW, for SmmCpuSyncGetArrivedCpuCount ():

we can't check the CpuCount (Original is named as Counter Sem) is locked or 
not, then decide return from the *Context->CpuCount or locked value for the 
arrived CPU in SMI. Just like:

if (*Context->CpuCount == MAX_UINT32) {--> does not meet this 
condition, means unlocked!
Return real CpuCount from the SmmCpuSyncLockDoor(). 
} 
> lock operation is here *Context->CpuCount change to 
MAX_UINT32
Return *Context->CpuCount;   --> return wrong value since MAX_UINT32 is return.

Because if we found it's not locked during the check, but it suddenly locked 
before return, then -1 will be returned. this is not atomic operation. The 
behavior is not expected. If we add the atomic operation here, I believe it 
will surely impact the existing performance.

And the real usage case is that we only need this api before the lock. I don't 
want make it complex.

So, based on this, we add the comment in the function:
  The caller shall not call this function for the number of arrived CPU after 
look door
  in SMI since the value has been returned in the parameter of LockDoor().
 
See below: 

/**
  Get current number of arrived CPU in SMI.

  BSP might need to know the current number of arrived CPU in SMI to make sure 
all APs
  in SMI. This API can be for that purpose.

  The caller shall not call this function for the number of arrived CPU after 
look door
  in SMI since the value has been returned in the parameter of LockDoor().

  If Context is NULL, then ASSERT().

  @param[in]  Context Pointer to the SMM CPU Sync context object.

  @retvalCurrent number of arrived CPU in SMI.

**/
UINTN
EFIAPI
SmmCpuSyncGetArrivedCpuCount (
  IN  SMM_CPU_SYNC_CONTEXT  *Context
  )
{
  ASSERT (Context != NULL);

  return *Context->CpuCount;
}

Thanks,
Jiaxin 
















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




Re: [edk2-devel] [PATCH v3 3/6] UefiCpuPkg: Implements SmmCpuSyncLib library instance

2023-12-14 Thread Wu, Jiaxin
> > The code will be changed to:
> >
> >   if ((INT32)InternalWaitForSemaphore (Context->CpuCount) < 0) {
> > return RETURN_ABORTED;
> >   }
> 
> I find this quite ugly. In the "semaphore post" operation, we already
> have code that prevents incrementing if the semaphore is "locked". Can
> we perhaps create a "semaphore pend" operation that does the same?
> 
> How about this:
> 
> diff --git a/UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
> b/UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
> index 3c2835f8def6..5d7fc58ef23f 100644
> --- a/UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
> +++ b/UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
> @@ -91,35 +91,38 @@ UINT32
>  InternalWaitForSemaphore (
>IN OUT  volatile UINT32  *Sem
>)
>  {
>UINT32  Value;
> 
>for ( ; ;) {
>  Value = *Sem;
> +if (Value == MAX_UINT32) {
> +  return Value;
> +}
>  if ((Value != 0) &&
>  (InterlockedCompareExchange32 (
> (UINT32 *)Sem,
> Value,
> Value - 1
> ) == Value))
>  {
>break;
>  }
> 
>  CpuPause ();
>}
> 
>return Value - 1;
>  }
> 
> Note, I'm just brainstorming here, I've not thought it through. Just to
> illustrate the direction I'm thinking of.
> 
> This change should be mostly OK. InternalWaitForSemaphore() returns the
> decremented value. So, for InternalWaitForSemaphore() to return
> MAX_UINT32 *without* this update, the function would have to decrement
> the semaphore when the semaphore is zero. But in that case, the function
> *blocks*. Thus, a return value of MAX_UINT32 is not possible without
> this extension; ergo, if MAX_UINT32 is returned (with this extension),

Yes, that's for the semaphore sync usage, we have to block the sem if it's 
zero, decrease it when return. That's why I said - it's naturally make sure the 
Run is reset after all ready to exit.  Then it can achieve the below flow:
BSP: ReleaseOneAp  -->  AP: WaitForBsp
BSP: WaitForAPs<--  AP: ReleaseBsp


For locked case, I just copy the existing logic from SMM cpu driver (as I 
document in the commit message: The instance refers the existing SMM CPU driver 
(PiSmmCpuDxeSmm) sync implementation and behavior):
existing ReleaseSemaphore() prevents increase the semaphore, but it still 
return the original semaphore value +1; --> that's why we have to check the 
return value is  0 or not in SmmCpuSyncCheckInCpu()
existing WaitForSemaphore() allow decrease the semaphore if locked, and it also 
return the original semaphore value -1;  --> that's why we have to check the 
return value is  < 0 or not in SmmCpuSyncCheckOutCpu()
 
so, do you want to align the behavior as below?

ReleaseSemaphore() prevents increase the semaphore if locked, and it should 
return the locked value (MAX_UINT32);  --> then we can check the return value 
is  MAX_UINT32 or not in SmmCpuSyncCheckInCpu(), and sem itself won't be 
changed.
WaitForSemaphore() prevents decrease the semaphore if locked, and it should 
return the locked value (MAX_UINT32); --> then we can check the return value is 
 MAX_UINT32 or not in SmmCpuSyncCheckOutCpu (), and sem itself won't be changed.

I think:
for ReleaseSemaphore, it must meet below 2 cases usage:
1. for semaphore sync usage (Run), it doesn't care the lock case, and returned 
value is not cared. Just check the semaphore itself.
2. for Rendezvous case (Counter), it not only needs to check locked or not from 
return value, but also require "only increase the semaphore if not locked".

for WaitForSemaphore, it must meet below 2 cases usage:
1. for semaphore sync usage (Run), it doesn't care the lock case, and returned 
value is not cared. But for the semaphore itself, it need block at 0, and 
decrease when return.
2. for Rendezvous case (Counter), it only needs to check locked or not from 
return value. semaphore itself is not cared.

So, based on above, I think, yes, we can do the change to align the lock 
behavior:  

/**
  Performs an atomic compare exchange operation to get semaphore.
  The compare exchange operation must be performed using MP safe
  mechanisms.

  @param[in,out]  SemIN:  32-bit unsigned integer
 OUT: original integer - 1 if Sem is not locked.
 OUT: original integer (MAX_UINT32) if Sem is locked.

  @retval Original integer - 1 if Sem is not locked.
  Original integer (MAX_UINT32) if Sem is locked.

**/
STATIC
UINT32
InternalWaitForSemaphore (
  IN OUT  volatile UINT32  *Sem
  )
{
  UINT32  Value;

  for ( ; ;) {
Value = *Sem;
if (Value == MAX_UINT32) {
  return Value;
}

if ((Value != 0) &&
(InterlockedCompareExchange32 (
   (UINT32 *)Sem,
   Value,
   Value - 1
   ) == Value))
{
  break;
}

CpuPause ();
  }

  return Value - 1;
}

/**
  Performs an atomic compare exchange operation to release semaphore.
  The compare exchange operation must be 

[edk2-devel] [PATCH v3 1/1] OvmfPkg/VirtNorFlashDxe: sanity-check variables

2023-12-14 Thread Gerd Hoffmann
Extend the ValidateFvHeader function, additionally to the header checks
walk over the list of variables and sanity check them.

In case we find inconsistencies indicating variable store corruption
return EFI_NOT_FOUND so the variable store will be re-initialized.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf |   1 +
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c   | 125 +++-
 2 files changed, 121 insertions(+), 5 deletions(-)

diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
index 2a3d4a218e61..f549400280a1 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
@@ -34,6 +34,7 @@ [LibraryClasses]
   DxeServicesTableLib
   HobLib
   IoLib
+  SafeIntLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
   UefiLib
diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
index 5ee98e9b595a..d69bf8783d77 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -185,11 +186,19 @@ ValidateFvHeader (
   IN  NOR_FLASH_INSTANCE  *Instance
   )
 {
-  UINT16  Checksum;
-  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;
-  VARIABLE_STORE_HEADER   *VariableStoreHeader;
-  UINTN   VariableStoreLength;
-  UINTN   FvLength;
+  UINT16 Checksum;
+  EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+  VARIABLE_STORE_HEADER  *VariableStoreHeader;
+  UINTN  VarOffset;
+  UINTN  VarHeaderEnd;
+  UINTN  VarNameEnd;
+  UINTN  VarEnd;
+  AUTHENTICATED_VARIABLE_HEADER  *VarHeader;
+  CHAR16 *VarName;
+  CONST CHAR8*VarState;
+  UINTN  VariableStoreLength;
+  UINTN  FvLength;
+  RETURN_STATUS  Status;
 
   FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Instance->RegionBaseAddress;
 
@@ -260,6 +269,112 @@ ValidateFvHeader (
 return EFI_NOT_FOUND;
   }
 
+  //
+  // check variables
+  //
+  DEBUG ((DEBUG_INFO, "%a: checking variables\n", __func__));
+  VarOffset = sizeof (*VariableStoreHeader);
+  for ( ; ;) {
+Status = SafeUintnAdd (VarOffset, sizeof (*VarHeader), );
+if (RETURN_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__));
+  return EFI_NOT_FOUND;
+}
+
+if (VarHeaderEnd >= VariableStoreHeader->Size) {
+  DEBUG ((DEBUG_INFO, "%a: end of var list (no space left)\n", __func__));
+  break;
+}
+
+VarHeader = (VOID *)((UINTN)VariableStoreHeader + VarOffset);
+if (VarHeader->StartId != 0x55aa) {
+  DEBUG ((DEBUG_INFO, "%a: end of var list (no startid)\n", __func__));
+  break;
+}
+
+VarName = NULL;
+switch (VarHeader->State) {
+  // usage: State = VAR_HEADER_VALID_ONLY
+  case VAR_HEADER_VALID_ONLY:
+VarState = "header-ok";
+VarName  = L"";
+break;
+
+  // usage: State = VAR_ADDED
+  case VAR_ADDED:
+VarState = "ok";
+break;
+
+  // usage: State &= VAR_IN_DELETED_TRANSITION
+  case VAR_ADDED _IN_DELETED_TRANSITION:
+VarState = "del-in-transition";
+break;
+
+  // usage: State &= VAR_DELETED
+  case VAR_ADDED _DELETED:
+  case VAR_ADDED _DELETED _IN_DELETED_TRANSITION:
+VarState = "deleted";
+break;
+
+  default:
+DEBUG ((
+  DEBUG_ERROR,
+  "%a: invalid variable state: 0x%x\n",
+  __func__,
+  VarHeader->State
+  ));
+return EFI_NOT_FOUND;
+}
+
+Status = SafeUintnAdd (VarHeaderEnd, VarHeader->NameSize, );
+if (RETURN_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__));
+  return EFI_NOT_FOUND;
+}
+
+Status = SafeUintnAdd (VarNameEnd, VarHeader->DataSize, );
+if (RETURN_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__));
+  return EFI_NOT_FOUND;
+}
+
+if (VarEnd > VariableStoreHeader->Size) {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: invalid variable size: 0x%Lx + 0x%Lx + 0x%x + 0x%x > 0x%x\n",
+__func__,
+(UINT64)VarOffset,
+(UINT64)(sizeof (*VarHeader)),
+VarHeader->NameSize,
+VarHeader->DataSize,
+VariableStoreHeader->Size
+));
+  return EFI_NOT_FOUND;
+}
+
+if (VarHeader->NameSize & 1) {
+  DEBUG ((DEBUG_ERROR, "%a: invalid name size\n", __func__));
+  return EFI_NOT_FOUND;
+}
+
+if (VarName == NULL) {
+  VarName = (VOID *)((UINTN)VariableStoreHeader + VarHeaderEnd);
+}
+
+DEBUG ((
+  DEBUG_VERBOSE,
+  "%a: +0x%04Lx: name=0x%x data=0x%x '%s' (%a)\n",
+  

Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg/VirtNorFlashDxe: sanity-check variables

2023-12-14 Thread Gerd Hoffmann
  Hi,
 
> The general idea is, once we don't trust the varstore, there cannot be
> a *single* unchecked addition in the code. (Unless we can *prove* that
> overflow is impossible.)

There are some cases where we add a small, constant number to a value we
know is smaller than VariableStoreHeader->Size.  I don't see how those
can overflow, given that varstore flash typically is an order of
magnitude smaller than MAX_UINT32 (unless VariableStoreHeader->Size is
corrupted, but then we have bigger problems anyway ...).

take care,
  Gerd



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




Re: [edk2-devel] [PATCH v3 1/1] CloudHv: Add CI for CloudHv on AArch64

2023-12-14 Thread Sami Mujawar
Merged as b8a3eec88cc7..59a952d9ab00

Thanks.

Regards,

Sami Mujawar

On 14/12/2023, 13:54, "Sami Mujawar" mailto:sami.muja...@arm.com>> wrote:


Hi Laszlo,




On 14/12/2023, 12:28, "Laszlo Ersek" mailto:ler...@redhat.com> >> wrote:




On 12/13/23 16:13, Sami Mujawar wrote:
> From: Jianyong Wu mailto:jianyong...@arm.com> 
> >>
> 
> Add the long lost CI for CloudHv on AArch64.
> As CloudHv CI works nearly the same way with other VMMs like KvmTool,
> thus we can easily create its CI configuration based on KvmTool.
> 
> Reviewed-by: Laszlo Ersek mailto:ler...@redhat.com> 
> >>
> Signed-off-by: Jianyong Wu mailto:jianyong...@arm.com> 
> >>
> Signed-off-by: Sami Mujawar    >>
> ---
> 
> The changes can be seen at: 
> https://github.com/samimujawar/edk2/tree/2897_cloudhv_ci_v3 
>  
>  
> 
> 
> Notes:
> v3:
> - CI fails to build when merging this patch [Laszlo]
> Ref: https://edk2.groups.io/g/devel/message/112321 
>  
>  
> 
> - Added missing comma in supported architecture lists [Sami]
> in CloudHvBuild.py to fix the issue.




Huh, singleton tuple!




https://docs.python.org/3/library/stdtypes.html#tuple 
 
 





"Using a trailing comma for a singleton tuple: a, or (a,)"




I guess that broke with the ArchSupported update from v1 to v2:




- ArchSupported = ("AARCH64", "ARM")
+ ArchSupported = ("AARCH64")




Sami, you have push right; can you merge this?
[SAMI] I will get this merged, no problem.


Regards,


Sami Mujawar




Thanks!
Laszlo




> 
> ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml | 13 
> ArmVirtPkg/PlatformCI/CloudHvBuild.py | 32 
> 2 files changed, 45 insertions(+)
> 
> diff --git a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml 
> b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
> index 
> d1772a65fc3a84f7f981971ff4ed6c37d7ba84f6..ab8a2db53026db686ae4e5943044235c63ab3a80
>  100644
> --- a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
> +++ b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
> @@ -140,6 +140,19 @@ jobs:
> Build.Target: "RELEASE"
> Run: false
> 
> + CLOUDHV_AARCH64_DEBUG:
> + Build.File: "$(package)/PlatformCI/CloudHvBuild.py"
> + Build.Arch: "AARCH64"
> + Build.Flags: ""
> + Build.Target: "DEBUG"
> + Run: false
> + CLOUDHV_AARCH64_RELEASE:
> + Build.File: "$(package)/PlatformCI/CloudHvBuild.py"
> + Build.Arch: "AARCH64"
> + Build.Flags: ""
> + Build.Target: "RELEASE"
> + Run: false
> +
> workspace:
> clean: all
> 
> diff --git a/ArmVirtPkg/PlatformCI/CloudHvBuild.py 
> b/ArmVirtPkg/PlatformCI/CloudHvBuild.py
> new file mode 100644
> index 
> ..5100a56f3be5ad6d2b156352a521900f93d1de27
> --- /dev/null
> +++ b/ArmVirtPkg/PlatformCI/CloudHvBuild.py
> @@ -0,0 +1,32 @@
> +# @file
> +# Script to Build ArmVirtPkg UEFI firmware
> +#
> +# Copyright (c) Microsoft Corporation.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +##
> +import os
> +import sys
> +
> +sys.path.append(os.path.dirname(os.path.abspath(__file__)))
> +from PlatformBuildLib import SettingsManager
> +from PlatformBuildLib import PlatformBuilder
> +
> + # 
> ###
>  #
> + # Common Configuration #
> + # 
> ###
>  #
> +class CommonPlatform():
> + ''' Common settings for this platform. Define static data here and use
> + for the different parts of stuart
> + '''
> + PackagesSupported = ("ArmVirtPkg",)
> + ArchSupported = ("AARCH64",)
> + TargetsSupported = ("DEBUG", "RELEASE")
> + Scopes = ('armvirt', 'edk2-build')
> + WorkspaceRoot = os.path.realpath(os.path.join(
> + os.path.dirname(os.path.abspath(__file__)), "..", ".."))
> +
> + DscName = os.path.join("ArmVirtPkg", "ArmVirtCloudHv.dsc")
> + FvQemuArg = "" # ignored
> +
> +import PlatformBuildLib
> +PlatformBuildLib.CommonPlatform = CommonPlatform















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

Re: [edk2-devel] [PATCH] ArmPkg/DebugPeCoffExtraActionLib: Drop RVCT and Cygwin support

2023-12-14 Thread Sami Mujawar
Hi Leif, Ard,

On 14/12/2023, 14:46, "Leif Lindholm" mailto:quic_llind...@quicinc.com>> wrote:


+Sami (who I know once, a very long time ago, used cygwin)
[SAMI] Now that we have WSL, I have stopped using Cygwin.
Also, this patch looks good to me.

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar

On Thu, Dec 14, 2023 at 10:20:46 +0100, Ard Biesheuvel wrote:
> From: Ard Biesheuvel mailto:a...@kernel.org>>
> 
> The DebugPeCoffExtraActionLib implemention in ArmPkg contains some cruft
> that dates back to the original RVCT based ARM port, and support for
> RVCT was dropped a while ago.
> 
> Also drop the handling of Cygwin specific paths, which is highly
> unlikely to be still depended upon by anyone.
> 
> Tweak the logic so that only two versions of the DEBUG() invocations
> remain: one for __GNUC__ when PdbPointer is set, and the fallback that
> just prints the image address and the address of the entrypoint.
> 
> Cc: Mike Beaton mailto:mjsbea...@gmail.com>>
> Signed-off-by: Ard Biesheuvel mailto:a...@kernel.org>>


But as far as I'm concerned, cygwin support feels extremely dated
these days and not worth the maintainance overhead to keep around.
So
Reviewed-by: Leif Lindholm mailto:quic_llind...@quicinc.com>>


/
Leif


> ---
> ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c | 100 
> ++--
> 1 file changed, 31 insertions(+), 69 deletions(-)
> 
> diff --git 
> a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c 
> b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> index 432112354fda..992c14d7ef9b 100644
> --- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> +++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> @@ -17,45 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #include 
> #include 
> 
> -/**
> - If the build is done on cygwin the paths are cygpaths.
> - /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
> - them to work with RVD commands
> -
> - @param Name Path to convert if needed
> -
> -**/
> -CHAR8 *
> -DeCygwinPathIfNeeded (
> - IN CHAR8 *Name,
> - IN CHAR8 *Temp,
> - IN UINTN Size
> - )
> -{
> - CHAR8 *Ptr;
> - UINTN Index;
> - UINTN Index2;
> -
> - Ptr = AsciiStrStr (Name, "/cygdrive/");
> - if (Ptr == NULL) {
> - return Name;
> - }
> -
> - for (Index = 9, Index2 = 0; (Index < (Size + 9)) && (Ptr[Index] != '\0'); 
> Index++, Index2++) {
> - Temp[Index2] = Ptr[Index];
> - if (Temp[Index2] == '/') {
> - Temp[Index2] = '\\';
> - }
> -
> - if (Index2 == 1) {
> - Temp[Index2 - 1] = Ptr[Index];
> - Temp[Index2] = ':';
> - }
> - }
> -
> - return Temp;
> -}
> -
> /**
> Performs additional actions after a PE/COFF image has been loaded and 
> relocated.
> 
> @@ -71,23 +32,24 @@ PeCoffLoaderRelocateImageExtraAction (
> IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
> )
> {
> - #if !defined (MDEPKG_NDEBUG)
> - CHAR8 Temp[512];
> - #endif
> -
> +#ifdef __GNUC__
> if (ImageContext->PdbPointer) {
> - #ifdef __CC_ARM
> - // Print out the command for the DS-5 to load symbols for this image
> - DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", 
> DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
> (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
> - #elif __GNUC__
> - // This may not work correctly if you generate PE/COFF directly as then the 
> Offset would not be required
> - DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", 
> DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
> (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
> - #else
> - DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p 
> EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, 
> FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
> - #endif
> - } else {
> - DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p 
> EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, 
> FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
> + DEBUG ((
> + DEBUG_LOAD | DEBUG_INFO,
> + "add-symbol-file %a 0x%p\n",
> + ImageContext->PdbPointer,
> + (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)
> + ));
> + return;
> }
> +#endif
> +
> + DEBUG ((
> + DEBUG_LOAD | DEBUG_INFO,
> + "Loading driver at 0x%11p EntryPoint=0x%11p\n",
> + (VOID *)(UINTN)ImageContext->ImageAddress,
> + FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)
> + ));
> }
> 
> /**
> @@ -106,21 +68,21 @@ PeCoffLoaderUnloadImageExtraAction (
> IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
> )
> {
> - #if !defined (MDEPKG_NDEBUG)
> - CHAR8 Temp[512];
> - #endif
> -
> +#ifdef __GNUC__
> if (ImageContext->PdbPointer) {
> - #ifdef __CC_ARM
> - // Print out the command for the RVD debugger to load symbols for this image
> - DEBUG ((DEBUG_LOAD | DEBUG_INFO, "unload symbols_only %a\n", 
> DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp;
> - #elif __GNUC__
> - // This may not work 

Re: [edk2-devel] [PATCH] ArmPkg/DebugPeCoffExtraActionLib: Drop RVCT and Cygwin support

2023-12-14 Thread Leif Lindholm
+Sami (who I know once, a very long time ago, used cygwin)

On Thu, Dec 14, 2023 at 10:20:46 +0100, Ard Biesheuvel wrote:
> From: Ard Biesheuvel 
> 
> The DebugPeCoffExtraActionLib implemention in ArmPkg contains some cruft
> that dates back to the original RVCT based ARM port, and support for
> RVCT was dropped a while ago.
> 
> Also drop the handling of Cygwin specific paths, which is highly
> unlikely to be still depended upon by anyone.
> 
> Tweak the logic so that only two versions of the DEBUG() invocations
> remain: one for __GNUC__ when PdbPointer is set, and the fallback that
> just prints the image address and the address of the entrypoint.
> 
> Cc: Mike Beaton 
> Signed-off-by: Ard Biesheuvel 

But as far as I'm concerned, cygwin support feels extremely dated
these days and not worth the maintainance overhead to keep around.
So
Reviewed-by: Leif Lindholm 

/
Leif

> ---
>  ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c | 100 
> ++--
>  1 file changed, 31 insertions(+), 69 deletions(-)
> 
> diff --git 
> a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c 
> b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> index 432112354fda..992c14d7ef9b 100644
> --- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> +++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> @@ -17,45 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  #include 
>  #include 
>  
> -/**
> -  If the build is done on cygwin the paths are cygpaths.
> -  /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
> -  them to work with RVD commands
> -
> -  @param  Name  Path to convert if needed
> -
> -**/
> -CHAR8 *
> -DeCygwinPathIfNeeded (
> -  IN  CHAR8  *Name,
> -  IN  CHAR8  *Temp,
> -  IN  UINTN  Size
> -  )
> -{
> -  CHAR8  *Ptr;
> -  UINTN  Index;
> -  UINTN  Index2;
> -
> -  Ptr = AsciiStrStr (Name, "/cygdrive/");
> -  if (Ptr == NULL) {
> -return Name;
> -  }
> -
> -  for (Index = 9, Index2 = 0; (Index < (Size + 9)) && (Ptr[Index] != '\0'); 
> Index++, Index2++) {
> -Temp[Index2] = Ptr[Index];
> -if (Temp[Index2] == '/') {
> -  Temp[Index2] = '\\';
> -}
> -
> -if (Index2 == 1) {
> -  Temp[Index2 - 1] = Ptr[Index];
> -  Temp[Index2] = ':';
> -}
> -  }
> -
> -  return Temp;
> -}
> -
>  /**
>Performs additional actions after a PE/COFF image has been loaded and 
> relocated.
>  
> @@ -71,23 +32,24 @@ PeCoffLoaderRelocateImageExtraAction (
>IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
>)
>  {
> - #if !defined (MDEPKG_NDEBUG)
> -  CHAR8  Temp[512];
> - #endif
> -
> +#ifdef __GNUC__
>if (ImageContext->PdbPointer) {
> - #ifdef __CC_ARM
> -// Print out the command for the DS-5 to load symbols for this image
> -DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", 
> DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
> (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
> - #elif __GNUC__
> -// This may not work correctly if you generate PE/COFF directly as then 
> the Offset would not be required
> -DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", 
> DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
> (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
> - #else
> -DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p 
> EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, 
> FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
> - #endif
> -  } else {
> -DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p 
> EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, 
> FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
> +DEBUG ((
> +  DEBUG_LOAD | DEBUG_INFO,
> +  "add-symbol-file %a 0x%p\n",
> +  ImageContext->PdbPointer,
> +  (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)
> +  ));
> +return;
>}
> +#endif
> +
> +  DEBUG ((
> +DEBUG_LOAD | DEBUG_INFO,
> +"Loading driver at 0x%11p EntryPoint=0x%11p\n",
> +(VOID *)(UINTN)ImageContext->ImageAddress,
> +FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)
> +));
>  }
>  
>  /**
> @@ -106,21 +68,21 @@ PeCoffLoaderUnloadImageExtraAction (
>IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
>)
>  {
> - #if !defined (MDEPKG_NDEBUG)
> -  CHAR8  Temp[512];
> - #endif
> -
> +#ifdef __GNUC__
>if (ImageContext->PdbPointer) {
> - #ifdef __CC_ARM
> -// Print out the command for the RVD debugger to load symbols for this 
> image
> -DEBUG ((DEBUG_LOAD | DEBUG_INFO, "unload symbols_only %a\n", 
> DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp;
> - #elif __GNUC__
> -// This may not work correctly if you generate PE/COFF directly as then 
> the Offset would not be required
> -DEBUG ((DEBUG_LOAD | DEBUG_INFO, "remove-symbol-file %a 0x%08x\n", 
> 

Re: [edk2-devel] [PATCH v5 0/2] Support customized FV Migration Information

2023-12-14 Thread Wang Fan
Hi Liming and Kumar

Could you help review this v5 patch:

MdeModulePkg: Support customized FV Migration Information: 
https://github.com/fanwang2intel/edk2/commit/83c55a73107bfb13df1d8b522e0ea1d18ef3d86b

SecurityPkg: Support customized FV Migration Information
https://github.com/fanwang2intel/edk2/commit/6f7e955f1d63a875f69ebc084885e76610acc722

v5: 
- Remove RemoveFvHobsInTemporaryMemory() since no consumer will call this API 
now.
- Separate patches to different packages. 

Best Regards
Fan

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Wang Fan
Sent: Thursday, December 14, 2023 9:53 PM
To: devel@edk2.groups.io
Cc: Wang, Fan 
Subject: [edk2-devel] [PATCH v5 0/2] Support customized FV Migration Information

There are use cases which not all FVs need be migrated from TempRam to 
permanent memory before TempRam tears down. This new guid is introduced to 
avoid unnecessary FV migration to improve boot performance. Platform can 
publish MigrationInfo hob with this guid to customize FV migration info, and 
PeiCore will only migrate FVs indicated by this Hob info.

This is a backwards compatible change, PeiCore will check MigrationInfo hob 
before migration. If MigrationInfo hobs exists, only migrate FVs recorded by 
hobs. If MigrationInfo hobs not exists, migrate all FVs to permanent memory.

In Tcg driver, when MigratedFvInfo hob is detected, existing code logic is 
assuming FV raw data is already copied, and raw data base address is also 
recorded. Due to the new PeiCore change, the platform can publish hob to 
indicate raw data need be copied or not along with FV migration.

Two cases need be considered to skip copy for boot performance: The first case 
is FV is not expected to be measured in post-mem phase, we should use 
MeasurementExcludedPpiGuid to skip measurement. The second case is FV raw data 
has no need to do rebase operation after migration, then measurement should 
calculate hash directly from FV base address.

Fan Wang (2):
  MdeModulePkg: Support customized FV Migration Information
  SecurityPkg: Support customized FV Migration Information

 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 84 ++-  
MdeModulePkg/Core/Pei/Memory/MemoryServices.c | 40 -
 MdeModulePkg/Core/Pei/PeiMain.h   | 11 ---
 MdeModulePkg/Core/Pei/PeiMain.inf |  1 +
 MdeModulePkg/Include/Guid/MigratedFvInfo.h| 42 +-
 MdeModulePkg/MdeModulePkg.dec |  3 +-
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c |  7 +-
 SecurityPkg/Tcg/TcgPei/TcgPei.c   |  7 +-
 8 files changed, 116 insertions(+), 79 deletions(-)

--
2.29.2.windows.2








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




Re: [edk2-devel] [edk2-platforms][PATCH V2 2/2] Platform/Sgi: Extend SMBIOS support for RD-V2 platform

2023-12-14 Thread Thomas Abraham
On Thu, Dec 14, 2023 at 11:41 AM Pranav Madhu  wrote:
> 
> The Neoverse RD-V2 FVP platform includes 16 CPUs and each CPU has 64KB
> of L1 instruction/data cache, 2MB of L2 cache and 32MB of system level
> cache. Extend the SMBIOS support for RD-V2 platform with this
> configuration.
> 
> Signed-off-by: Pranav Madhu 
> ---
>  Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type1SystemInformation.c
> |  5 -
> 
> Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type4ProcessorInformation
> .c |  7 +--
>  Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c
> | 18 ++
>  3 files changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git
> a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type1SystemInformation.
> c
> b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type1SystemInformation
> .c
> index b7e2238fb39c..fe3c88672d7e 100644
> ---
> a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type1SystemInformation.
> c
> +++
> b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type1SystemInformation
> .c
> @@ -33,7 +33,8 @@
>"RdV1Mc\0"\
>"RdN2\0"  \
>"RdN2Cfg1\0"  \
> -  "RdN2Cfg2\0"
> +  "RdN2Cfg2\0"  \
> +  "RdV2\0"
> 
>  typedef enum {
>ManufacturerName = 1,
> @@ -71,6 +72,8 @@ STATIC GUID mSmbiosUid[] = {
>{0xa4941d3d, 0xfac3, 0x4ace, {0x9a, 0x7e, 0xce, 0x26, 0x76, 0x64, 0x5e,
> 0xda}},
>/* Rd-N2-Cfg2*/
>{0xd2946d07, 0x8057, 0x4c26, {0xbf, 0x53, 0x78, 0xa6, 0x5b, 0xe1, 0xc1,
> 0x60}},
> +  /* Rd-V2 */
> +  {0x3b1180a3, 0x0744, 0x4194, {0xae, 0x2e, 0xed, 0xa5, 0xbc, 0x2e, 0x43,
> 0x45}},
>  };
> 
>  /* System information */
> diff --git
> a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type4ProcessorInformati
> on.c
> b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type4ProcessorInformati
> on.c
> index b59172cf1cb9..0f403e41a3c7 100644
> ---
> a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type4ProcessorInformati
> on.c
> +++
> b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type4ProcessorInformati
> on.c
> @@ -27,7 +27,7 @@
>  #define SOCKET_TYPE_BASE3
>  #define SOCKET_TYPE_NUM 1
>  #define PROCESSOR_VERSION_BASE  (SOCKET_TYPE_BASE +
> SOCKET_TYPE_NUM)
> -#define PROCESSOR_VERSION_NUM   10
> +#define PROCESSOR_VERSION_NUM   11
>  #define SERIAL_NUMBER_BASE  (PROCESSOR_VERSION_BASE +
> PROCESSOR_VERSION_NUM)
>  #define TYPE4_STRINGS   \
>"0x000\0" /* Part Number */   \
> @@ -43,6 +43,7 @@
>"Neoverse-N2\0"   \
>"Neoverse-N2\0"   \
>"Neoverse-N2\0"   \
> +  "Neoverse-V2\0"   \
>"000-0\0" /* Serial number */ \
>"783-3\0" \
>"786-1\0" \
> @@ -52,7 +53,8 @@
>"78A-2\0" \
>"7B7-1\0" \
>"7B6-1\0" \
> -  "7B7-1\0"
> +  "7B7-1\0" \
> +  "7F2-1\0"
> 
>  typedef enum {
>PartNumber = 1,
> @@ -178,6 +180,7 @@ InstallType4ProcessorInformation (
>  break;
>case RdN2:
>case RdN2Cfg1:
> +  case RdV2:
>  mArmRdSmbiosType4.Base.CoreCount = CoreCount;
>  mArmRdSmbiosType4.Base.EnabledCoreCount = CoreCount;
>  mArmRdSmbiosType4.Base.ThreadCount = CoreCount;
> diff --git
> a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c
> b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.
> c
> index b71ce721e2e8..d65ae9520679 100644
> ---
> a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c
> +++
> b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.
> c
> @@ -334,6 +334,24 @@ InstallType7CacheInformation (
>  mArmRdSmbiosType7[4].Base.InstalledSize2 = 8192; // 8MB SLC
>  mArmRdSmbiosType7[4].Base.Associativity = CacheAssociativity16Way;
>  break;
> +  case RdV2:
> +/* L1 instruction cache */
> +mArmRdSmbiosType7[0].Base.MaximumCacheSize2 = 64;// 64KB
> +mArmRdSmbiosType7[0].Base.InstalledSize2 = 64;   // 64KB
> +mArmRdSmbiosType7[0].Base.Associativity = CacheAssociativity4Way;
> +/* L1 data cache */
> +mArmRdSmbiosType7[1].Base.MaximumCacheSize2 = 64;// 64KB
> +mArmRdSmbiosType7[1].Base.InstalledSize2 = 64;   // 64KB
> +mArmRdSmbiosType7[1].Base.Associativity = CacheAssociativity4Way;
> +/* L2 cache */
> +mArmRdSmbiosType7[2].Base.MaximumCacheSize2 = 2048;  // 2MB
> +mArmRdSmbiosType7[2].Base.InstalledSize2 = 2048; // 2MB
> +mArmRdSmbiosType7[2].Base.Associativity = 

Re: [edk2-devel] [edk2-platforms][PATCH V2 1/2] Platform/Sgi: Define RD-V2 platform id values

2023-12-14 Thread Thomas Abraham
On Thu, Dec 14, 2023 at 11:41 AM Pranav Madhu  wrote:
> 
> Add the RD-V2 platform identification values including the part
> number and configuration number. This information will be used in
> populating the SMBIOS tables.
> 
> Signed-off-by: Pranav Madhu 
> ---
>  Platform/ARM/SgiPkg/Include/SgiPlatform.h | 5 +
>  Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c | 6 ++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/Platform/ARM/SgiPkg/Include/SgiPlatform.h
> b/Platform/ARM/SgiPkg/Include/SgiPlatform.h
> index e83853664c4c..ea197b9f50bc 100644
> --- a/Platform/ARM/SgiPkg/Include/SgiPlatform.h
> +++ b/Platform/ARM/SgiPkg/Include/SgiPlatform.h
> @@ -47,6 +47,10 @@
>  #define RD_N2_PART_NUM0x7B7
>  #define RD_N2_CONF_ID 0x1
> 
> +// RD-V2 Platform Identification values
> +#define RD_V2_PART_NUM0x7F2
> +#define RD_V2_CONF_ID 0x1
> +
>  #define SGI_CONFIG_MASK   0x0F
>  #define SGI_CONFIG_SHIFT  0x1C
>  #define SGI_PART_NUM_MASK 0xFFF
> @@ -85,6 +89,7 @@ typedef enum {
>RdN2,
>RdN2Cfg1,
>RdN2Cfg2,
> +  RdV2,
>  } ARM_RD_PRODUCT_ID;
> 
>  // Arm ProductId look-up table
> diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c
> b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c
> index fa006320025b..0562f40d4604 100644
> --- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c
> +++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c
> @@ -79,6 +79,12 @@ STATIC CONST SGI_PRODUCT_ID_LOOKUP
> SgiProductIdLookup[] = {
>  RD_N2_CONF_ID,
>  1
>},
> +  {
> +RdV2,
> +RD_V2_PART_NUM,
> +RD_V2_CONF_ID,
> +0
> +  },
>  };
> 
>  EFI_BOOT_MODE
> --
> 2.34.1

Reviewed-by: Thomas Abraham 


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




Re: [edk2-devel] [PATCH v3 1/1] CloudHv: Add CI for CloudHv on AArch64

2023-12-14 Thread Sami Mujawar
Hi Laszlo,


On 14/12/2023, 12:28, "Laszlo Ersek" mailto:ler...@redhat.com>> wrote:


On 12/13/23 16:13, Sami Mujawar wrote:
> From: Jianyong Wu mailto:jianyong...@arm.com>>
> 
> Add the long lost CI for CloudHv on AArch64.
> As CloudHv CI works nearly the same way with other VMMs like KvmTool,
> thus we can easily create its CI configuration based on KvmTool.
> 
> Reviewed-by: Laszlo Ersek mailto:ler...@redhat.com>>
> Signed-off-by: Jianyong Wu mailto:jianyong...@arm.com>>
> Signed-off-by: Sami Mujawar  >
> ---
> 
> The changes can be seen at: 
> https://github.com/samimujawar/edk2/tree/2897_cloudhv_ci_v3 
> 
> 
> Notes:
> v3:
> - CI fails to build when merging this patch [Laszlo]
> Ref: https://edk2.groups.io/g/devel/message/112321 
> 
> - Added missing comma in supported architecture lists [Sami]
> in CloudHvBuild.py to fix the issue.


Huh, singleton tuple!


https://docs.python.org/3/library/stdtypes.html#tuple 



"Using a trailing comma for a singleton tuple: a, or (a,)"


I guess that broke with the ArchSupported update from v1 to v2:


- ArchSupported = ("AARCH64", "ARM")
+ ArchSupported = ("AARCH64")


Sami, you have push right; can you merge this?
[SAMI] I will get this merged, no problem.

Regards,

Sami Mujawar


Thanks!
Laszlo


> 
> ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml | 13 
> ArmVirtPkg/PlatformCI/CloudHvBuild.py | 32 
> 2 files changed, 45 insertions(+)
> 
> diff --git a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml 
> b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
> index 
> d1772a65fc3a84f7f981971ff4ed6c37d7ba84f6..ab8a2db53026db686ae4e5943044235c63ab3a80
>  100644
> --- a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
> +++ b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
> @@ -140,6 +140,19 @@ jobs:
> Build.Target: "RELEASE"
> Run: false
> 
> + CLOUDHV_AARCH64_DEBUG:
> + Build.File: "$(package)/PlatformCI/CloudHvBuild.py"
> + Build.Arch: "AARCH64"
> + Build.Flags: ""
> + Build.Target: "DEBUG"
> + Run: false
> + CLOUDHV_AARCH64_RELEASE:
> + Build.File: "$(package)/PlatformCI/CloudHvBuild.py"
> + Build.Arch: "AARCH64"
> + Build.Flags: ""
> + Build.Target: "RELEASE"
> + Run: false
> +
> workspace:
> clean: all
> 
> diff --git a/ArmVirtPkg/PlatformCI/CloudHvBuild.py 
> b/ArmVirtPkg/PlatformCI/CloudHvBuild.py
> new file mode 100644
> index 
> ..5100a56f3be5ad6d2b156352a521900f93d1de27
> --- /dev/null
> +++ b/ArmVirtPkg/PlatformCI/CloudHvBuild.py
> @@ -0,0 +1,32 @@
> +# @file
> +# Script to Build ArmVirtPkg UEFI firmware
> +#
> +# Copyright (c) Microsoft Corporation.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +##
> +import os
> +import sys
> +
> +sys.path.append(os.path.dirname(os.path.abspath(__file__)))
> +from PlatformBuildLib import SettingsManager
> +from PlatformBuildLib import PlatformBuilder
> +
> + # 
> ###
>  #
> + # Common Configuration #
> + # 
> ###
>  #
> +class CommonPlatform():
> + ''' Common settings for this platform. Define static data here and use
> + for the different parts of stuart
> + '''
> + PackagesSupported = ("ArmVirtPkg",)
> + ArchSupported = ("AARCH64",)
> + TargetsSupported = ("DEBUG", "RELEASE")
> + Scopes = ('armvirt', 'edk2-build')
> + WorkspaceRoot = os.path.realpath(os.path.join(
> + os.path.dirname(os.path.abspath(__file__)), "..", ".."))
> +
> + DscName = os.path.join("ArmVirtPkg", "ArmVirtCloudHv.dsc")
> + FvQemuArg = "" # ignored
> +
> +import PlatformBuildLib
> +PlatformBuildLib.CommonPlatform = CommonPlatform







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




[edk2-devel] [PATCH v5 2/2] SecurityPkg: Support customized FV Migration Information

2023-12-14 Thread Wang Fan
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4533

In Tcg driver, when MigratedFvInfo hob is detected, existing code logic
is assuming FV raw data is already copied, and raw data base address is
also recorded. Due to the new PeiCore change, the platform can publish
hob to indicate raw data need be copied or not along with FV migration.

Two cases need be considered to skip copy for boot performance: The first
case is FV is not expected to be measured in post-mem phase, we should
use MeasurementExcludedPpiGuid to skip measurement. The second case is
FV raw data has no need to do rebase operation after migration, then
measurement should calculate hash directly from FV base address.

Cc: Liming Gao 
Cc: Rahul Kumar 
Cc: Jian J Wang 
Signed-off-by: Fan Wang 
---
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 7 +--
 SecurityPkg/Tcg/TcgPei/TcgPei.c   | 7 +--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c 
b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
index 1caaa4e319bc..daaf49e644b2 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
@@ -726,8 +726,11 @@ MeasureFvImage (
   //
   // Found the migrated FV info
   //
-  FvOrgBase  = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
-  FvDataBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
+  FvOrgBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
+  if (MigratedFvInfo->FvDataBase != 0) {
+FvDataBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
+  }
+
   break;
 }
 
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c
index 5aa80511aa81..d35c2ad0bc55 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -463,8 +463,11 @@ MeasureFvImage (
   //
   // Found the migrated FV info
   //
-  FvOrgBase  = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
-  FvDataBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
+  FvOrgBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
+  if (MigratedFvInfo->FvDataBase != 0) {
+FvDataBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
+  }
+
   break;
 }
 
-- 
2.29.2.windows.2



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




[edk2-devel] [PATCH v5 1/2] MdeModulePkg: Support customized FV Migration Information

2023-12-14 Thread Wang Fan
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4533

There are use cases which not all FVs need be migrated from TempRam to
permanent memory before TempRam tears down. This new guid is introduced
to avoid unnecessary FV migration to improve boot performance. Platform
can publish MigrationInfo hob with this guid to customize FV migration
info, and PeiCore will only migrate FVs indicated by this Hob info.

This is a backwards compatible change, PeiCore will check MigrationInfo
hob before migration. If MigrationInfo hobs exists, only migrate FVs
recorded by hobs. If MigrationInfo hobs not exists, migrate all FVs to
permanent memory.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Ray Ni 
Cc: Guomin Jiang 
Signed-off-by: Fan Wang 
---
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 84 ++-
 MdeModulePkg/Core/Pei/Memory/MemoryServices.c | 40 -
 MdeModulePkg/Core/Pei/PeiMain.h   | 11 ---
 MdeModulePkg/Core/Pei/PeiMain.inf |  1 +
 MdeModulePkg/Include/Guid/MigratedFvInfo.h| 42 +-
 MdeModulePkg/MdeModulePkg.dec |  3 +-
 6 files changed, 106 insertions(+), 75 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c 
b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 5f32ebb560ae..4cd8c843cd92 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -1184,7 +1184,12 @@ EvacuateTempRam (
 
   PEI_CORE_FV_HANDLEPeiCoreFvHandle;
   EFI_PEI_CORE_FV_LOCATION_PPI  *PeiCoreFvLocationPpi;
+  EFI_PEI_HOB_POINTERS  Hob;
+  EDKII_MIGRATION_INFO  *MigrationInfo;
+  TO_MIGRATE_FV_INFO*ToMigrateFvInfo;
+  UINT32FvMigrationFlags;
   EDKII_MIGRATED_FV_INFOMigratedFvInfo;
+  UINTN Index;
 
   ASSERT (Private->PeiMemoryInstalled);
 
@@ -1211,6 +1216,13 @@ EvacuateTempRam (
 
   ConvertPeiCorePpiPointers (Private, );
 
+  Hob.Raw = GetFirstGuidHob ();
+  if (Hob.Raw != NULL) {
+MigrationInfo = GET_GUID_HOB_DATA (Hob);
+  } else {
+MigrationInfo = NULL;
+  }
+
   for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
 FvHeader = Private->Fv[FvIndex].FvHeader;
 ASSERT (FvHeader != NULL);
@@ -1224,8 +1236,33 @@ EvacuateTempRam (
   )
 )
 {
+  if ((MigrationInfo == NULL) || (MigrationInfo->MigrateAll == TRUE)) {
+//
+// Migrate all FVs and copy raw data
+//
+FvMigrationFlags = FLAGS_FV_RAW_DATA_COPY;
+  } else {
+for (Index = 0; Index < MigrationInfo->ToMigrateFvCount; Index++) {
+  ToMigrateFvInfo = ((TO_MIGRATE_FV_INFO *)(MigrationInfo + 1)) + 
Index;
+  if (ToMigrateFvInfo->FvOrgBaseOnTempRam == (UINT32)(UINTN)FvHeader) {
+//
+// This FV is to migrate
+//
+FvMigrationFlags = ToMigrateFvInfo->FvMigrationFlags;
+break;
+  }
+}
+
+if (Index == MigrationInfo->ToMigrateFvCount) {
+  //
+  // This FV is not expected to migrate
+  //
+  continue;
+}
+  }
+
   //
-  // Allocate page to save the rebased PEIMs, the PEIMs will get 
dispatched later.
+  // Allocate pages to save the rebased PEIMs, the PEIMs will get 
dispatched later.
   //
   Status =  PeiServicesAllocatePages (
   EfiBootServicesCode,
@@ -1234,18 +1271,7 @@ EvacuateTempRam (
   );
   ASSERT_EFI_ERROR (Status);
   MigratedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHeaderAddress;
-
-  //
-  // Allocate pool to save the raw PEIMs, which is used to keep consistent 
context across
-  // multiple boot and PCR0 will keep the same no matter if the address of 
allocated page is changed.
-  //
-  Status =  PeiServicesAllocatePages (
-  EfiBootServicesCode,
-  EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength),
-  
-  );
-  ASSERT_EFI_ERROR (Status);
-  RawDataFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHeaderAddress;
+  CopyMem (MigratedFvHeader, FvHeader, (UINTN)FvHeader->FvLength);
 
   DEBUG ((
 DEBUG_VERBOSE,
@@ -1256,17 +1282,33 @@ EvacuateTempRam (
 ));
 
   //
-  // Copy the context to the rebased pages and raw pages, and create hob 
to save the
-  // information. The MigratedFvInfo HOB will never be produced when
-  // PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the PCD 
control the
-  // feature.
+  // Create hob to save MigratedFvInfo, this hob will only be produced when
+  // Migration feature PCD PcdMigrateTemporaryRamFirmwareVolumes is set to 
TRUE.
   //
-  CopyMem (MigratedFvHeader, FvHeader, (UINTN)FvHeader->FvLength);
-  CopyMem (RawDataFvHeader, MigratedFvHeader, (UINTN)FvHeader->FvLength);
   MigratedFvInfo.FvOrgBase  = (UINT32)(UINTN)FvHeader;
   

[edk2-devel] [PATCH v5 0/2] Support customized FV Migration Information

2023-12-14 Thread Wang Fan
There are use cases which not all FVs need be migrated from TempRam to
permanent memory before TempRam tears down. This new guid is introduced
to avoid unnecessary FV migration to improve boot performance. Platform
can publish MigrationInfo hob with this guid to customize FV migration
info, and PeiCore will only migrate FVs indicated by this Hob info.

This is a backwards compatible change, PeiCore will check MigrationInfo
hob before migration. If MigrationInfo hobs exists, only migrate FVs
recorded by hobs. If MigrationInfo hobs not exists, migrate all FVs to
permanent memory.

In Tcg driver, when MigratedFvInfo hob is detected, existing code logic
is assuming FV raw data is already copied, and raw data base address is
also recorded. Due to the new PeiCore change, the platform can publish
hob to indicate raw data need be copied or not along with FV migration.

Two cases need be considered to skip copy for boot performance: The first
case is FV is not expected to be measured in post-mem phase, we should
use MeasurementExcludedPpiGuid to skip measurement. The second case is
FV raw data has no need to do rebase operation after migration, then
measurement should calculate hash directly from FV base address.

Fan Wang (2):
  MdeModulePkg: Support customized FV Migration Information
  SecurityPkg: Support customized FV Migration Information

 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 84 ++-
 MdeModulePkg/Core/Pei/Memory/MemoryServices.c | 40 -
 MdeModulePkg/Core/Pei/PeiMain.h   | 11 ---
 MdeModulePkg/Core/Pei/PeiMain.inf |  1 +
 MdeModulePkg/Include/Guid/MigratedFvInfo.h| 42 +-
 MdeModulePkg/MdeModulePkg.dec |  3 +-
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c |  7 +-
 SecurityPkg/Tcg/TcgPei/TcgPei.c   |  7 +-
 8 files changed, 116 insertions(+), 79 deletions(-)

-- 
2.29.2.windows.2



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




Re: [edk2-devel] [PATCH v3 3/6] UefiCpuPkg: Implements SmmCpuSyncLib library instance

2023-12-14 Thread Laszlo Ersek
On 12/14/23 12:11, Wu, Jiaxin wrote:
> Hi Laszlo,
> 
> Really appreciate your comments! I checked one by one and feedback as below, 
> thank you & Ray again & again for patch refinement
> 
> 
>>
>> (1) If / when you update the documentation in patch#2, please update
>> this one as well.
>>
> 
> Yes, I will do the alignment.
> 
>> (2) Please sort the #include list alphabetically.
>>
>> (The idea is that the [LibraryClasses] section in the INF file should be
>> sorted as well, and then we can easily verify whether those two lists
>> match each other -- modulo , of course.)
>>
> 
> Agree.
> 
>> (3) We can improve this, as follows:
>>
>>   typedef volatile UINT32 SMM_CPU_SYNC_SEMAPHORE;
> 
> Good comment. Agree.
> 
> 
>>
>>   typedef struct {
>> SMM_CPU_SYNC_SEMAPHORE *Counter;
>>   } SMM_CPU_SYNC_SEMAPHORE_GLOBAL;
>>
>>   typedef struct {
>> SMM_CPU_SYNC_SEMAPHORE *Run;
>>   } SMM_CPU_SYNC_SEMAPHORE_CPU;
>>
>> Because, while it *indeed* makes some sense to introduce these separate
>> wrapper structures, we should still ensure that the internals are
>> identical. This will come handy later.
>>
> 
> After check with Ray, I convinced we don't need wrapper the "Counter" into 
> the SMM_CPU_SYNC_SEMAPHORE_GLOBAL. He thinks it's overdesigned since 
> currently we only have one GLOBAL semaphore. "Counter" defines in the 
> SMM_CPU_SYNC_CONTEXT directly can also make "Counter" has its own CPU cache 
> lines, and don't need consider the future extension. So, I agree to move 
> Counter into SMM_CPU_SYNC_CONTEXT. What's your opinion?
> 
> But for the *Run*, he is ok to wrap into the structure since it's for each 
> CPU, and it can benefit & simply the coding logic, which can easily help us 
> direct to the different CPU with index and meet the semaphore size alignment 
> requirement.

My actual opinion is that *both* wrapper structures are unnecessary. You
can just embed the Counter pointer into the outer sync structure, and
you can have a Run *array of pointers* in the outer sync structure as well.

However, many people find double indirection confusing, and therefore
wrap one level into thin structures. That's fine with me. It has zero
runtime cost, and if it makes the code more manageable to the submitter,
I don't mind. So, up to you.


> 
>>
>> (4) This is too complicated, in my opinion.
>>
>> (4.1) First of all, please add a *conspicuous* comment to the
>> SMM_CPU_SYNC_CONTEXT here, explaining that the whole idea is to place
>> the Counter and Run semaphores on different CPU cache lines, for good
>> performance. That's the *core* principle of this whole structure --
>> that's why we have an array of pointers to semaphores, rather than an
>> array of semaphores directly.
>>
>> You didn't document that principle, and I had to spend a lot of time
>> deducing that fact from the SmmCpuSyncContextInit() function.
> 
> Sorry about that, I will document for the SMM_CPU_SYNC_CONTEXT definition.
> 
> 
>>
>> (4.2) The structure should go like this:
>>
>> struct SMM_CPU_SYNC_CONTEXT  {
>>   UINTNNumberOfCpus;
>>   VOID *SemBuffer;
>>   UINTNSemBufferPages;
>>   SMM_CPU_SYNC_SEMAPHORE_GLOBALGlobalSem;
>>   SMM_CPU_SYNC_SEMAPHORE_CPU   CpuSem[];
>> };
>>
>> Details:
>>
>> - move NumberOfCpus to the top
>>
>> - change the type of SemBuffer from (UINTN*) to (VOID*)
>>
>> - replace SemBufferSize with SemBufferPages
> 
> Oh? Lazlo, could you explain why it's better to define it as "SemBufferPages" 
> instead of "SemBufferSize" in bytes?

Semantically, there is no difference, or even SemBufferSize is more
flexible. My recommendation is basically a "forward declaration" here:
using "SemBufferPages" will simplify the code later on. Because, you
never need to *remember* the precise byte count. What you need to
*remember* is the page count only. So that way the declaration matches
the usage better, and you can save some code logic later on.

> 
> 
>>
>> - move GlobalSem and CpuSem to the end
>>
>> - We need exactly one SMM_CPU_SYNC_SEMAPHORE_GLOBAL, therefore
>> embed
>> GlobalSem directly as a field (it should not be a pointer)
>>
>> - We can much simplify the code by turning CpuSem into a *flexible array
>> member* (this is a C99 feature that is already widely used in edk2).
>> This is why we move CpuSem to the end (and then we keep GlobalSem
>> nearby, for clarity).
> 
> Agree! The same comment from Ray! Thank you and Ray, both!!!
> 
>>
> 
> Really great comment here:
> 
> Based on my above explanation, I propose to below definition:
> 
> ///
> /// Shall place each semaphore on exclusive cache line for good performance.
> ///
> typedef volatile UINT32 SMM_CPU_SYNC_SEMAPHORE;
> 
> typedef struct {
>   ///
>   /// Used for control each CPU continue run or wait for signal
>   ///
>   SMM_CPU_SYNC_SEMAPHORE*Run;
> } SMM_CPU_SYNC_SEMAPHORE_FOR_EACH_CPU;
> 
> struct SMM_CPU_SYNC_CONTEXT  {
>   ///
>   /// Indicate all CPUs in the 

Re: [edk2-devel] [PATCH v3 4/6] OvmfPkg: Specifies SmmCpuSyncLib instance

2023-12-14 Thread Wu, Jiaxin
> >
> >  !if $(SOURCE_DEBUG_ENABLE) == TRUE
> 
> All four DSC files already include "PiSmmCpuDxeSmm.inf" like this:
> 
>   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
> 
>   ...
>   }
> 
> Given that this new library class is again exclusively used by
> PiSmmCpuDxeSmm, can you please resolve this lib class too in module
> scope only?
> 

Yes, I will put it under the PiSmmCpuDxeSmm

> Thanks!
> Laszlo



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




Re: [edk2-devel] [PATCH V6] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined

2023-12-14 Thread Mike Beaton
I did ask. Thank you for the considered answer. Ack. :)

On Thu, 14 Dec 2023 at 13:25, Laszlo Ersek  wrote:
>
> On 12/14/23 10:33, Mike Beaton wrote:
> >> Please stop sending patches.
> >
> > I believe this version is a clear improvement, with motivation.
> > (Certainly, it was meant as such!)
> >
> > How am I meant to send improvements or updates in this email-based workflow?
>
> By pacing yourself. Posting two versions of the same patch set on the
> same day is usually the highest tolerable posting frequency. Many would
> say 1 version/day is the limit (unless there is a pressing security
> issue or CI failure etc).
>
> Basically the request is for the submitter to think more, let their
> latest version soak for longer locally, before posting it.
>
> BTW I don't think this is specific to email, the same issue exists on
> any git forge, except perhaps to a lesser extent. Both channels are
> asynchronous, so if you repost or force-push too quickly, you don't give
> reviewers a chance to finish (or even *start*) the last version's
> review. Well, interrupting them may actually be your intent, but that's
> just not how async communication works. Once you posted it, it's out
> there, and it's going to take up some consumer cycles for sure, either
> way, regardless of what you do later. You can't recall it, you're not in
> the same office at the same time.
>
> github *seems* to mitigate this, because the old version more or less
> just disappears. But that's actually a bug of git forges, not a feature.
> Patch posting history should never be forgotten. Mailing lists get this
> right, but that makes misbehavior (= too frequent posting) more
> damaging, as the total traffic the receiver will have to wade through
> will be higher.
>
> In short: don't experiment, don't thrash. Make every version of your
> patch set *count*. Give yourself more time to think about your latest
> version *in the background*, before posting it. If you sleep over it,
> the next day you might get a new idea, regardless of whether you posted
> or didn't yet post that version. So, as long as it hasn't settled, don't
> post it. If you realize an issue after posting the latest version,
> respond -- just like a reviewer would -- to the problematic patch email,
> pointing out the error; but *don't* post a new version just yet (i.e.,
> don't create a new version / thread on the list). Your attempt to
> "recall" the problematic version is bound to fail.
>
> In short, s/TCP_NODELAY/TCP_CORK/.
>
> Sorry about the sermon -- you asked. :)
> Laszlo
>


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




Re: [edk2-devel] [PATCH V6] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined

2023-12-14 Thread Laszlo Ersek
On 12/14/23 10:33, Mike Beaton wrote:
>> Please stop sending patches.
> 
> I believe this version is a clear improvement, with motivation.
> (Certainly, it was meant as such!)
> 
> How am I meant to send improvements or updates in this email-based workflow?

By pacing yourself. Posting two versions of the same patch set on the
same day is usually the highest tolerable posting frequency. Many would
say 1 version/day is the limit (unless there is a pressing security
issue or CI failure etc).

Basically the request is for the submitter to think more, let their
latest version soak for longer locally, before posting it.

BTW I don't think this is specific to email, the same issue exists on
any git forge, except perhaps to a lesser extent. Both channels are
asynchronous, so if you repost or force-push too quickly, you don't give
reviewers a chance to finish (or even *start*) the last version's
review. Well, interrupting them may actually be your intent, but that's
just not how async communication works. Once you posted it, it's out
there, and it's going to take up some consumer cycles for sure, either
way, regardless of what you do later. You can't recall it, you're not in
the same office at the same time.

github *seems* to mitigate this, because the old version more or less
just disappears. But that's actually a bug of git forges, not a feature.
Patch posting history should never be forgotten. Mailing lists get this
right, but that makes misbehavior (= too frequent posting) more
damaging, as the total traffic the receiver will have to wade through
will be higher.

In short: don't experiment, don't thrash. Make every version of your
patch set *count*. Give yourself more time to think about your latest
version *in the background*, before posting it. If you sleep over it,
the next day you might get a new idea, regardless of whether you posted
or didn't yet post that version. So, as long as it hasn't settled, don't
post it. If you realize an issue after posting the latest version,
respond -- just like a reviewer would -- to the problematic patch email,
pointing out the error; but *don't* post a new version just yet (i.e.,
don't create a new version / thread on the list). Your attempt to
"recall" the problematic version is bound to fail.

In short, s/TCP_NODELAY/TCP_CORK/.

Sorry about the sermon -- you asked. :)
Laszlo



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




Re: [edk2-devel] [PATCH v3 1/1] CloudHv: Add CI for CloudHv on AArch64

2023-12-14 Thread Laszlo Ersek
On 12/13/23 16:13, Sami Mujawar wrote:
> From: Jianyong Wu 
> 
> Add the long lost CI for CloudHv on AArch64.
> As CloudHv CI works nearly the same way with other VMMs like KvmTool,
> thus we can easily create its CI configuration based on KvmTool.
> 
> Reviewed-by: Laszlo Ersek 
> Signed-off-by: Jianyong Wu 
> Signed-off-by: Sami Mujawar 
> ---
> 
> The changes can be seen at: 
> https://github.com/samimujawar/edk2/tree/2897_cloudhv_ci_v3
> 
> Notes:
> v3:
>  - CI fails to build when merging this patch[Laszlo]
>Ref: https://edk2.groups.io/g/devel/message/112321
>  - Added missing comma in supported architecture lists  [Sami]
>in CloudHvBuild.py to fix the issue.

Huh, singleton tuple!

https://docs.python.org/3/library/stdtypes.html#tuple

"Using a trailing comma for a singleton tuple: a, or (a,)"

I guess that broke with the ArchSupported update from v1 to v2:

-ArchSupported = ("AARCH64", "ARM")
+ArchSupported = ("AARCH64")

Sami, you have push right; can you merge this?

Thanks!
Laszlo

> 
>  ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml | 13 
>  ArmVirtPkg/PlatformCI/CloudHvBuild.py | 32 
> 
>  2 files changed, 45 insertions(+)
> 
> diff --git a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml 
> b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
> index 
> d1772a65fc3a84f7f981971ff4ed6c37d7ba84f6..ab8a2db53026db686ae4e5943044235c63ab3a80
>  100644
> --- a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
> +++ b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
> @@ -140,6 +140,19 @@ jobs:
>  Build.Target: "RELEASE"
>  Run: false
>  
> +  CLOUDHV_AARCH64_DEBUG:
> +Build.File: "$(package)/PlatformCI/CloudHvBuild.py"
> +Build.Arch: "AARCH64"
> +Build.Flags: ""
> +Build.Target: "DEBUG"
> +Run: false
> +  CLOUDHV_AARCH64_RELEASE:
> +Build.File: "$(package)/PlatformCI/CloudHvBuild.py"
> +Build.Arch: "AARCH64"
> +Build.Flags: ""
> +Build.Target: "RELEASE"
> +Run: false
> +
>  workspace:
>clean: all
>  
> diff --git a/ArmVirtPkg/PlatformCI/CloudHvBuild.py 
> b/ArmVirtPkg/PlatformCI/CloudHvBuild.py
> new file mode 100644
> index 
> ..5100a56f3be5ad6d2b156352a521900f93d1de27
> --- /dev/null
> +++ b/ArmVirtPkg/PlatformCI/CloudHvBuild.py
> @@ -0,0 +1,32 @@
> +# @file
> +# Script to Build ArmVirtPkg UEFI firmware
> +#
> +# Copyright (c) Microsoft Corporation.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +##
> +import os
> +import sys
> +
> +sys.path.append(os.path.dirname(os.path.abspath(__file__)))
> +from PlatformBuildLib import SettingsManager
> +from PlatformBuildLib import PlatformBuilder
> +
> +# 
> ###
>  #
> +#Common Configuration
>  #
> +# 
> ###
>  #
> +class CommonPlatform():
> +''' Common settings for this platform.  Define static data here and use
> +for the different parts of stuart
> +'''
> +PackagesSupported = ("ArmVirtPkg",)
> +ArchSupported = ("AARCH64",)
> +TargetsSupported = ("DEBUG", "RELEASE")
> +Scopes = ('armvirt', 'edk2-build')
> +WorkspaceRoot = os.path.realpath(os.path.join(
> +os.path.dirname(os.path.abspath(__file__)), "..", ".."))
> +
> +DscName = os.path.join("ArmVirtPkg", "ArmVirtCloudHv.dsc")
> +FvQemuArg = "" # ignored
> +
> +import PlatformBuildLib
> +PlatformBuildLib.CommonPlatform = CommonPlatform



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




[edk2-devel] [edk2-platforms][PATCH V2 2/2] Platform/Sgi: Extend SMBIOS support for RD-V2 platform

2023-12-14 Thread Pranav Madhu
The Neoverse RD-V2 FVP platform includes 16 CPUs and each CPU has 64KB
of L1 instruction/data cache, 2MB of L2 cache and 32MB of system level
cache. Extend the SMBIOS support for RD-V2 platform with this
configuration.

Signed-off-by: Pranav Madhu 
---
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type1SystemInformation.c|  5 
-
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type4ProcessorInformation.c |  7 
+--
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c | 18 
++
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git 
a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type1SystemInformation.c 
b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type1SystemInformation.c
index b7e2238fb39c..fe3c88672d7e 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type1SystemInformation.c
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type1SystemInformation.c
@@ -33,7 +33,8 @@
   "RdV1Mc\0"\
   "RdN2\0"  \
   "RdN2Cfg1\0"  \
-  "RdN2Cfg2\0"
+  "RdN2Cfg2\0"  \
+  "RdV2\0"
 
 typedef enum {
   ManufacturerName = 1,
@@ -71,6 +72,8 @@ STATIC GUID mSmbiosUid[] = {
   {0xa4941d3d, 0xfac3, 0x4ace, {0x9a, 0x7e, 0xce, 0x26, 0x76, 0x64, 0x5e, 
0xda}},
   /* Rd-N2-Cfg2*/
   {0xd2946d07, 0x8057, 0x4c26, {0xbf, 0x53, 0x78, 0xa6, 0x5b, 0xe1, 0xc1, 
0x60}},
+  /* Rd-V2 */
+  {0x3b1180a3, 0x0744, 0x4194, {0xae, 0x2e, 0xed, 0xa5, 0xbc, 0x2e, 0x43, 
0x45}},
 };
 
 /* System information */
diff --git 
a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type4ProcessorInformation.c 
b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type4ProcessorInformation.c
index b59172cf1cb9..0f403e41a3c7 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type4ProcessorInformation.c
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type4ProcessorInformation.c
@@ -27,7 +27,7 @@
 #define SOCKET_TYPE_BASE3
 #define SOCKET_TYPE_NUM 1
 #define PROCESSOR_VERSION_BASE  (SOCKET_TYPE_BASE + SOCKET_TYPE_NUM)
-#define PROCESSOR_VERSION_NUM   10
+#define PROCESSOR_VERSION_NUM   11
 #define SERIAL_NUMBER_BASE  (PROCESSOR_VERSION_BASE + 
PROCESSOR_VERSION_NUM)
 #define TYPE4_STRINGS   \
   "0x000\0" /* Part Number */   \
@@ -43,6 +43,7 @@
   "Neoverse-N2\0"   \
   "Neoverse-N2\0"   \
   "Neoverse-N2\0"   \
+  "Neoverse-V2\0"   \
   "000-0\0" /* Serial number */ \
   "783-3\0" \
   "786-1\0" \
@@ -52,7 +53,8 @@
   "78A-2\0" \
   "7B7-1\0" \
   "7B6-1\0" \
-  "7B7-1\0"
+  "7B7-1\0" \
+  "7F2-1\0"
 
 typedef enum {
   PartNumber = 1,
@@ -178,6 +180,7 @@ InstallType4ProcessorInformation (
 break;
   case RdN2:
   case RdN2Cfg1:
+  case RdV2:
 mArmRdSmbiosType4.Base.CoreCount = CoreCount;
 mArmRdSmbiosType4.Base.EnabledCoreCount = CoreCount;
 mArmRdSmbiosType4.Base.ThreadCount = CoreCount;
diff --git 
a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c 
b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c
index b71ce721e2e8..d65ae9520679 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c
@@ -334,6 +334,24 @@ InstallType7CacheInformation (
 mArmRdSmbiosType7[4].Base.InstalledSize2 = 8192; // 8MB SLC
 mArmRdSmbiosType7[4].Base.Associativity = CacheAssociativity16Way;
 break;
+  case RdV2:
+/* L1 instruction cache */
+mArmRdSmbiosType7[0].Base.MaximumCacheSize2 = 64;// 64KB
+mArmRdSmbiosType7[0].Base.InstalledSize2 = 64;   // 64KB
+mArmRdSmbiosType7[0].Base.Associativity = CacheAssociativity4Way;
+/* L1 data cache */
+mArmRdSmbiosType7[1].Base.MaximumCacheSize2 = 64;// 64KB
+mArmRdSmbiosType7[1].Base.InstalledSize2 = 64;   // 64KB
+mArmRdSmbiosType7[1].Base.Associativity = CacheAssociativity4Way;
+/* L2 cache */
+mArmRdSmbiosType7[2].Base.MaximumCacheSize2 = 2048;  // 2MB
+mArmRdSmbiosType7[2].Base.InstalledSize2 = 2048; // 2MB
+mArmRdSmbiosType7[2].Base.Associativity = CacheAssociativity8Way;
+/* System level cache */
+mArmRdSmbiosType7[4].Base.MaximumCacheSize2 = 32768; // 32MB SLC
+mArmRdSmbiosType7[4].Base.InstalledSize2 = 32768;// 32MB SLC
+mArmRdSmbiosType7[4].Base.Associativity = CacheAssociativity16Way;
+break;
   }
 
   /* Install valid cache 

[edk2-devel] [edk2-platforms][PATCH V2 1/2] Platform/Sgi: Define RD-V2 platform id values

2023-12-14 Thread Pranav Madhu
Add the RD-V2 platform identification values including the part
number and configuration number. This information will be used in
populating the SMBIOS tables.

Signed-off-by: Pranav Madhu 
---
 Platform/ARM/SgiPkg/Include/SgiPlatform.h | 5 +
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c | 6 ++
 2 files changed, 11 insertions(+)

diff --git a/Platform/ARM/SgiPkg/Include/SgiPlatform.h 
b/Platform/ARM/SgiPkg/Include/SgiPlatform.h
index e83853664c4c..ea197b9f50bc 100644
--- a/Platform/ARM/SgiPkg/Include/SgiPlatform.h
+++ b/Platform/ARM/SgiPkg/Include/SgiPlatform.h
@@ -47,6 +47,10 @@
 #define RD_N2_PART_NUM0x7B7
 #define RD_N2_CONF_ID 0x1
 
+// RD-V2 Platform Identification values
+#define RD_V2_PART_NUM0x7F2
+#define RD_V2_CONF_ID 0x1
+
 #define SGI_CONFIG_MASK   0x0F
 #define SGI_CONFIG_SHIFT  0x1C
 #define SGI_PART_NUM_MASK 0xFFF
@@ -85,6 +89,7 @@ typedef enum {
   RdN2,
   RdN2Cfg1,
   RdN2Cfg2,
+  RdV2,
 } ARM_RD_PRODUCT_ID;
 
 // Arm ProductId look-up table
diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c 
b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c
index fa006320025b..0562f40d4604 100644
--- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c
+++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c
@@ -79,6 +79,12 @@ STATIC CONST SGI_PRODUCT_ID_LOOKUP SgiProductIdLookup[] = {
 RD_N2_CONF_ID,
 1
   },
+  {
+RdV2,
+RD_V2_PART_NUM,
+RD_V2_CONF_ID,
+0
+  },
 };
 
 EFI_BOOT_MODE
-- 
2.34.1



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




[edk2-devel] [edk2-platforms][PATCH V2 0/2] Add SMBIOS support for RD-V2 platform

2023-12-14 Thread Pranav Madhu
Changes since V1:
- Rebase the patches on top of latest master branch

SMBIOS provides basic hardware and firmware configuration information
through table-driven data structure. This patch series adds SMBIOS
support for Arm's RD-V2 platforms.

The first patch in this series defines platform-id values for the
RD-V2 platform. The second patch add CPU information and cache
attributes for RD-V2 platform.

Link to branch with the patches in this series -
https://git.gitlab.arm.com/infra-solutions/reference-design/platsw/edk2-platforms/-/tree/topics/rdv2-smbios-v2-upstream

Pranav Madhu (2):
  Platform/Sgi: Define RD-V2 platform id values
  Platform/Sgi: Extend SMBIOS support for RD-V2 platform

 Platform/ARM/SgiPkg/Include/SgiPlatform.h |  5 
+
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type1SystemInformation.c|  5 
-
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type4ProcessorInformation.c |  7 
+--
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c | 18 
++
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c |  6 
++
 5 files changed, 38 insertions(+), 3 deletions(-)

-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112522): https://edk2.groups.io/g/devel/message/112522
Mute This Topic: https://groups.io/mt/103168056/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] NetworkPkg: Triger regularly scan only if not connect to AP

2023-12-14 Thread Heng Luo
Hi Saloni,
Could you help to merge the patch?

Thanks,
Heng

> -Original Message-
> From: Luo, Heng
> Sent: Monday, December 11, 2023 4:13 PM
> To: Clark-williams, Zachary ; Kasbekar,
> Saloni ; devel@edk2.groups.io
> Subject: RE: [PATCH v2] NetworkPkg: Triger regularly scan only if not connect
> to AP
> 
> Hi Zack,
> Could you please review the change?
> Thanks,
> Heng
> 
> > -Original Message-
> > From: Kasbekar, Saloni 
> > Sent: Saturday, December 2, 2023 5:25 AM
> > To: Luo, Heng ; devel@edk2.groups.io
> > Cc: Clark-williams, Zachary 
> > Subject: RE: [PATCH v2] NetworkPkg: Triger regularly scan only if not
> > connect to AP
> >
> > Reviewed-by: Kasbekar, Saloni 
> >
> > Thanks,
> > Saloni
> >
> > -Original Message-
> > From: Luo, Heng 
> > Sent: Monday, November 27, 2023 7:07 PM
> > To: devel@edk2.groups.io
> > Cc: Kasbekar, Saloni ; Clark-williams,
> > Zachary 
> > Subject: [PATCH v2] NetworkPkg: Triger regularly scan only if not
> > connect to AP
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4605
> >
> > When UEFI Wi-Fi is in BSS connected state, the platform is considered
> > as a static and Wi-Fi roaming support is not needed.
> > Wifi connection manager should not initiate Scan requests in this
> > state affect BSS client connectivity and must be avoided.
> > Triger regularly scan only if not connect to AP.
> >
> > Signed-off-by: Heng Luo 
> > Cc: Saloni Kasbekar 
> > Cc: Zachary Clark-williams 
> > ---
> >  NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c | 4 ++-
> -
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git
> > a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c
> > b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c
> > index d1182e52bd..4c5460b65c 100644
> > --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c
> > +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c
> > @@ -1506,8 +1506,8 @@ WifiMgrOnTimerTick (
> >}Nic->ScanTickTime++;-  if (((Nic->ScanTickTime >
> > WIFI_SCAN_FREQUENCY) || Nic->OneTimeScanRequest) &&-  (Nic-
> > >ScanState == WifiMgrScanFinished))+  if Nic->ScanTickTime >
> > WIFI_SCAN_FREQUENCY) && (Nic->ConnectState !=
> WifiMgrConnectedToAp))
> > ||+   Nic->OneTimeScanRequest) && (Nic->ScanState ==
> > WifiMgrScanFinished))   { Nic->OneTimeScanRequest = FALSE; Nic-
> > >ScanTickTime   = 0;--
> > 2.31.1.windows.1



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




Re: [edk2-devel] [PATCH v3 3/6] UefiCpuPkg: Implements SmmCpuSyncLib library instance

2023-12-14 Thread Wu, Jiaxin
Hi Laszlo,

Really appreciate your comments! I checked one by one and feedback as below, 
thank you & Ray again & again for patch refinement


> 
> (1) If / when you update the documentation in patch#2, please update
> this one as well.
> 

Yes, I will do the alignment.

> (2) Please sort the #include list alphabetically.
> 
> (The idea is that the [LibraryClasses] section in the INF file should be
> sorted as well, and then we can easily verify whether those two lists
> match each other -- modulo , of course.)
> 

Agree.

> (3) We can improve this, as follows:
> 
>   typedef volatile UINT32 SMM_CPU_SYNC_SEMAPHORE;

Good comment. Agree.


> 
>   typedef struct {
> SMM_CPU_SYNC_SEMAPHORE *Counter;
>   } SMM_CPU_SYNC_SEMAPHORE_GLOBAL;
> 
>   typedef struct {
> SMM_CPU_SYNC_SEMAPHORE *Run;
>   } SMM_CPU_SYNC_SEMAPHORE_CPU;
> 
> Because, while it *indeed* makes some sense to introduce these separate
> wrapper structures, we should still ensure that the internals are
> identical. This will come handy later.
> 

After check with Ray, I convinced we don't need wrapper the "Counter" into the 
SMM_CPU_SYNC_SEMAPHORE_GLOBAL. He thinks it's overdesigned since currently we 
only have one GLOBAL semaphore. "Counter" defines in the SMM_CPU_SYNC_CONTEXT 
directly can also make "Counter" has its own CPU cache lines, and don't need 
consider the future extension. So, I agree to move Counter into 
SMM_CPU_SYNC_CONTEXT. What's your opinion?

But for the *Run*, he is ok to wrap into the structure since it's for each CPU, 
and it can benefit & simply the coding logic, which can easily help us direct 
to the different CPU with index and meet the semaphore size alignment 
requirement.

> 
> (4) This is too complicated, in my opinion.
> 
> (4.1) First of all, please add a *conspicuous* comment to the
> SMM_CPU_SYNC_CONTEXT here, explaining that the whole idea is to place
> the Counter and Run semaphores on different CPU cache lines, for good
> performance. That's the *core* principle of this whole structure --
> that's why we have an array of pointers to semaphores, rather than an
> array of semaphores directly.
> 
> You didn't document that principle, and I had to spend a lot of time
> deducing that fact from the SmmCpuSyncContextInit() function.

Sorry about that, I will document for the SMM_CPU_SYNC_CONTEXT definition.


> 
> (4.2) The structure should go like this:
> 
> struct SMM_CPU_SYNC_CONTEXT  {
>   UINTNNumberOfCpus;
>   VOID *SemBuffer;
>   UINTNSemBufferPages;
>   SMM_CPU_SYNC_SEMAPHORE_GLOBALGlobalSem;
>   SMM_CPU_SYNC_SEMAPHORE_CPU   CpuSem[];
> };
> 
> Details:
> 
> - move NumberOfCpus to the top
> 
> - change the type of SemBuffer from (UINTN*) to (VOID*)
> 
> - replace SemBufferSize with SemBufferPages

Oh? Lazlo, could you explain why it's better to define it as "SemBufferPages" 
instead of "SemBufferSize" in bytes?


> 
> - move GlobalSem and CpuSem to the end
> 
> - We need exactly one SMM_CPU_SYNC_SEMAPHORE_GLOBAL, therefore
> embed
> GlobalSem directly as a field (it should not be a pointer)
> 
> - We can much simplify the code by turning CpuSem into a *flexible array
> member* (this is a C99 feature that is already widely used in edk2).
> This is why we move CpuSem to the end (and then we keep GlobalSem
> nearby, for clarity).

Agree! The same comment from Ray! Thank you and Ray, both!!!

>

Really great comment here:

Based on my above explanation, I propose to below definition:

///
/// Shall place each semaphore on exclusive cache line for good performance.
///
typedef volatile UINT32 SMM_CPU_SYNC_SEMAPHORE;

typedef struct {
  ///
  /// Used for control each CPU continue run or wait for signal
  ///
  SMM_CPU_SYNC_SEMAPHORE*Run;
} SMM_CPU_SYNC_SEMAPHORE_FOR_EACH_CPU;

struct SMM_CPU_SYNC_CONTEXT  {
  ///
  /// Indicate all CPUs in the system.
  ///
  UINTN  NumberOfCpus;
  ///
  /// Address of semaphores
  ///
  VOID   *SemBuffer;
  ///
  /// Size in bytes of semaphores
  ///
  UINTN  SemBufferSize;  > I can change 
to pages based on your feedback:).
  ///
  /// Indicate CPUs entered SMM.
  ///
  SMM_CPU_SYNC_SEMAPHORE *CpuCount;
  ///
  /// Define an array of structure for each CPU semaphore due to the size 
alignment
  /// requirement. With the array of structure for each CPU semaphore, it's 
easy to
  /// reach the specific CPU with CPU Index for its own semaphore access: 
CpuSem[CpuIndex].
  ///
  SMM_CPU_SYNC_SEMAPHORE_FOR_EACH_CPUCpuSem[];
};


> 
> (5) Please make these Internal functions STATIC.
> 
> Better yet, please make *all* functions that are not EFIAPI, STATIC.

Agree.


> > +  ASSERT (SmmCpuSyncCtx != NULL);
> 
> (6) This assert is unnecessary and wrong; we perform correct error
> checking already.

Agree, I will remove the check, but keep assert.

> 
> So, 

Re: [edk2-devel] [PATCH 1/2] MdeModulePkg/DxeIpl: Add 5 level paging support

2023-12-14 Thread Guo, Gua
Reviewed-by: Gua Guo 

From: Liu, Zhiguang 
Sent: Thursday, December 14, 2023 3:59:38 PM
To: devel@edk2.groups.io 
Cc: Gao, Liming ; Wu, Jiaxin ; 
Ni, Ray ; Dong, Guo ; Rhodes, Sean 
; Lu, James ; Guo, Gua 

Subject: RE: [PATCH 1/2] MdeModulePkg/DxeIpl: Add 5 level paging support

Hi MdeModulePkg/UefiPayloadPkg Maintainers,

This patch set fix a potential issue when handling paging table.
Please help review.

Thanks
Zhiguang

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Thursday, December 7, 2023 10:39 AM
> To: devel@edk2.groups.io
> Cc: Liu, Zhiguang ; Gao, Liming
> ; Wu, Jiaxin ; Ni, Ray
> ; Dong, Guo ; Rhodes, Sean
> ; Lu, James ; Guo, Gua
> 
> Subject: [PATCH 1/2] MdeModulePkg/DxeIpl: Add 5 level paging support
>
> Add 5 level paging support when set the page table memory range as RO to
> protect page table.
>
> Cc: Liming Gao 
> Cc: Jiaxin Wu 
> Cc: Ray Ni 
> Cc: Guo Dong 
> Cc: Sean Rhodes 
> Cc: James Lu 
> Cc: Gua Guo 
> Signed-off-by: Zhiguang Liu 
> ---
>  .../Core/DxeIplPeim/Ia32/DxeLoadFunc.c|  2 +-
>  .../Core/DxeIplPeim/X64/VirtualMemory.c   | 23 ---
>  .../Core/DxeIplPeim/X64/VirtualMemory.h   |  5 +++-
>  3 files changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
> b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
> index 65e9bdc99e..ba871dafc7 100644
> --- a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
> +++ b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c
> @@ -166,7 +166,7 @@ Create4GPageTablesIa32Pae (
>// Protect the page table by marking the memory used for page table to be
>// read-only.
>//
> -  EnablePageTableProtection ((UINTN)PageMap, FALSE);
> +  EnablePageTableProtection ((UINTN)PageMap, FALSE, FALSE);
>
>return (UINTN)PageMap;
>  }
> diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> index 980c2002d4..1c2e29b132 100644
> --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> @@ -486,13 +486,15 @@ Split1GPageTo2M (
>@param[in] PageTableBaseBase address of page table (CR3).
>@param[in] Address  Start address of a page to be set as read-only.
>@param[in] Level4Paging Level 4 paging flag.
> +  @param[in] Level5Paging Level 5 paging flag.
>
>  **/
>  VOID
>  SetPageTablePoolReadOnly (
>IN  UINTN PageTableBase,
>IN  EFI_PHYSICAL_ADDRESS  Address,
> -  IN  BOOLEAN   Level4Paging
> +  IN  BOOLEAN   Level4Paging,
> +  IN  BOOLEAN   Level5Paging
>)
>  {
>UINTN Index;
> @@ -502,9 +504,9 @@ SetPageTablePoolReadOnly (
>UINT64*PageTable;
>UINT64*NewPageTable;
>UINT64PageAttr;
> -  UINT64LevelSize[5];
> -  UINT64LevelMask[5];
> -  UINTN LevelShift[5];
> +  UINT64LevelSize[6];
> +  UINT64LevelMask[6];
> +  UINTN LevelShift[6];
>UINTN Level;
>UINT64PoolUnitSize;
>
> @@ -521,23 +523,26 @@ SetPageTablePoolReadOnly (
>LevelShift[2] = PAGING_L2_ADDRESS_SHIFT;
>LevelShift[3] = PAGING_L3_ADDRESS_SHIFT;
>LevelShift[4] = PAGING_L4_ADDRESS_SHIFT;
> +  LevelShift[5] = PAGING_L5_ADDRESS_SHIFT;
>
>LevelMask[1] = PAGING_4K_ADDRESS_MASK_64;
>LevelMask[2] = PAGING_2M_ADDRESS_MASK_64;
>LevelMask[3] = PAGING_1G_ADDRESS_MASK_64;
>LevelMask[4] = PAGING_1G_ADDRESS_MASK_64;
> +  LevelMask[5] = 0;
>
>LevelSize[1] = SIZE_4KB;
>LevelSize[2] = SIZE_2MB;
>LevelSize[3] = SIZE_1GB;
>LevelSize[4] = SIZE_512GB;
> +  LevelSize[5] = SIZE_256TB;
>
>AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) &
> PAGING_1G_ADDRESS_MASK_64;
>PageTable= (UINT64 *)(UINTN)PageTableBase;
>PoolUnitSize = PAGE_TABLE_POOL_UNIT_SIZE;
>
> -  for (Level = (Level4Paging) ? 4 : 3; Level > 0; --Level) {
> +  for (Level = Level5Paging ? 5 : (Level4Paging ? 4 : 3); Level > 0;
> + --Level) {
>  Index  = ((UINTN)RShiftU64 (Address, LevelShift[Level]));
>  Index &= PAGING_PAE_INDEX_MASK;
>
> @@ -608,12 +613,14 @@ SetPageTablePoolReadOnly (
>
>@param[in] PageTableBaseBase address of page table (CR3).
>@param[in] Level4Paging Level 4 paging flag.
> +  @param[in] Level5Paging Level 5 paging flag.
>
>  **/
>  VOID
>  EnablePageTableProtection (
>IN  UINTNPageTableBase,
> -  IN  BOOLEAN  Level4Paging
> +  IN  BOOLEAN  Level4Paging,
> +  IN  BOOLEAN  Level5Paging
>)
>  {
>PAGE_TABLE_POOL   *HeadPool;
> @@ -642,7 +649,7 @@ EnablePageTableProtection (
>  // protection to them one by one.
>  //
>  while (PoolSize > 0) {
> -  SetPageTablePoolReadOnly (PageTableBase, Address, Level4Paging);
> +  SetPageTablePoolReadOnly 

Re: [edk2-devel] [PATCH V5] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined

2023-12-14 Thread Ard Biesheuvel
On Thu, 14 Dec 2023 at 10:37, Mike Beaton  wrote:
>
> > IOW, please don't send a v6 until the discussion comes to a conclusion.
>
> Apologies, I did _not_ see this before sending.
>
> > > - #if !defined (MDEPKG_NDEBUG)
> > > + #if defined (__CC_ARM) || defined (__GNUC__)
> >
> > No, this is not going to be acceptable to me. You noted that only the
> > ARM code seems to suffer from this issue, so surely, we can find a way
> > to change this code that doesn't introduce spurious dependencies on
> > the exact toolchain we are using.
>
> With all due respect, I believe that you are incorrect that this is
> spurious. Please check the surrounding code (specifically, this
> compiler dependency exactly matches - and is there because of - a
> compiler dependency in the surrounding code). (Additionally, though it
> doesn't affect the point either way, I thought this is what you had
> spotted and were asking for, when previously saying "What about
> GCC?"!)
>

Indeed. I hadn't spotted the context, and actually (patch sent), we
need to rip that code out entirely. So please consider this piece
solved.


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




Re: [edk2-devel] [edk2][PATCH V1 1/2] ArmPkg/ArmGicArchLib: Add macros for SPI and extended SPI ranges

2023-12-14 Thread Sami Mujawar

Hi Himanshu,

Thank you for this patch.

I have a minor suggestion marked inline as [SAMI].

Otherwise this patch looks good to me.

With that fixed,

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar

On 06/12/2023 10:11 am, Himanshu Sharma wrote:

Taking reference from Table 2-1 of the Arm Generic Interrupt Controller
Architecture Specification, Issue H, January 2022, add macros for the
SPI and extended SPI ranges with the purpose of reusability on including
the ArmPkg.

Signed-off-by: Himanshu Sharma
---
  ArmPkg/Include/Library/ArmGicArchLib.h | 9 +
  1 file changed, 9 insertions(+)

diff --git a/ArmPkg/Include/Library/ArmGicArchLib.h 
b/ArmPkg/Include/Library/ArmGicArchLib.h
index 72ac17e13b5a..1b90b354f785 100644
--- a/ArmPkg/Include/Library/ArmGicArchLib.h
+++ b/ArmPkg/Include/Library/ArmGicArchLib.h
@@ -1,6 +1,7 @@
  /** @file

  *

  *  Copyright (c) 2015, Linaro Ltd. All rights reserved.

+*  Copyright (c) 2023, Arm Limited. All rights reserved.

  *

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

  *

[SAMI] It may be useful to include a reference to the spec.

e.g.

@parReference(s):

 - Arm Generic Interrupt Controller Architecture Specification,

  Issue H, January 2022.

  (https://developer.arm.com/documentation/ihi0069/)

[/SAMI]


@@ -23,4 +24,12 @@ ArmGicGetSupportedArchRevision (
VOID

);

  


+//

+// GIC SPI and extended SPI ranges

+//

+#define ARM_GIC_ARCH_SPI_MIN  32

+#define ARM_GIC_ARCH_SPI_MAX  1019

+#define ARM_GIC_ARCH_EXT_SPI_MIN  4096

+#define ARM_GIC_ARCH_EXT_SPI_MAX  5119

+

  #endif // ARM_GIC_ARCH_LIB_H_




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




Re: [edk2-devel] [edk2][PATCH V1 2/2] DynamicTablesPkg/SsdtSerialPortFixupLib: Add Interrupt node for SPIs only

2023-12-14 Thread Sami Mujawar

Hi Himanshu,

Thank you for this patch.

Please see my feedback marked inline as [SAMI].

Regards,

Sami Mujawar

On 06/12/2023 10:11 am, Himanshu Sharma wrote:

Add interrupt node to the AML description of the serial-port only if the
IRQ ID from the Configuration Manager is a valid SPI (shared processor
interrupt) or an extended SPI. So, for DBG2 UART ports where interrupt
is not mandatory, adding of an interrupt node in the AML description
using Serial Port Fixup Library can be ignored if the UART is not
defined with a valid SPI, like in N1SDP.

This update generates the interrupt node for the valid SPI range using
the AML Codegen API instead of updating it using the AML Fixup API.

Signed-off-by: Himanshu Sharma
---
  
DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
 |  3 +-
  
DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c 
  | 38 
  
DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTemplate.asl
 | 29 ---
  3 files changed, 42 insertions(+), 28 deletions(-)

diff --git 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
index 965167bdc4e1..2d16a22aeb41 100644
--- 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
+++ 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
@@ -1,7 +1,7 @@
  ## @file

  #  SSDT Serial Port fixup Library

  #

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

+#  Copyright (c) 2020 - 2021, 2023, Arm Limited. All rights reserved.

  #

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

  ##

@@ -23,6 +23,7 @@
MdeModulePkg/MdeModulePkg.dec

EmbeddedPkg/EmbeddedPkg.dec

DynamicTablesPkg/DynamicTablesPkg.dec

+  ArmPkg/ArmPkg.dec
[SAMI] I understand that this section was not ordered alphabetically, 
but can you add the above line at the begining of this section, please?


  


  [LibraryClasses]

AcpiHelperLib

diff --git 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
index a65c1fe7e30d..fb77136aa844 100644
--- 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
+++ 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
@@ -1,7 +1,7 @@
  /** @file

SSDT Serial Port Fixup Library.

  


-  Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.

+  Copyright (c) 2019 - 2021, 2023, Arm Limited. All rights reserved.

  


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

  


@@ -9,10 +9,12 @@
- Arm Server Base Boot Requirements (SBBR), s4.2.1.8 "SPCR".

- Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.

- ACPI for Arm Components 1.0 - 2020

+  - Arm Generic Interrupt Controller Architecture Specification, Issue H, 
January 2022.


[SAMI] Please limit line length to 80 chars. Also it may be useful to 
include the link to the spec.


e.g.

 - Arm Generic Interrupt Controller Architecture Specification,

  Issue H, January 2022.

  (https://developer.arm.com/documentation/ihi0069/)

[/SAMI]



  **/

  


  #include 

  #include 

+#include 

  #include 

  #include 

  #include 

@@ -270,7 +272,6 @@ FixupCrs (
EFI_STATUS  Status;

AML_OBJECT_NODE_HANDLE  NameOpCrsNode;

AML_DATA_NODE_HANDLEQWordRdNode;

-  AML_DATA_NODE_HANDLEInterruptRdNode;

  


// Get the "_CRS" object defined by the "Name ()" statement.

Status = AmlFindNode (

@@ -303,20 +304,27 @@ FixupCrs (
  return Status;

}

  


-  // Get the Interrupt node.

-  // It is the second Resource Data element in the NameOpCrsNode's

-  // variable list of arguments.

-  Status = AmlNameOpGetNextRdNode (QWordRdNode, );

-  if (EFI_ERROR (Status)) {

-return Status;

+  // Generate an interrupt node if the interrupt for the serial-port is a 
valid SPI.


[SAMI] Can you modify the above comment to say 'Generate an interrupt 
node as the second Resource Data element in the NameOpCrsNode, if the 
interrupt ...'.


Also, limit the line length to 80 characters.

[/SAMI]



+  // SPI ranges from Table 2-1 in Arm Generic Interrupt Controller 
Architecture Specification.

+  if (((SerialPortInfo->Interrupt >= ARM_GIC_ARCH_SPI_MIN) &&

+   (SerialPortInfo->Interrupt <= ARM_GIC_ARCH_SPI_MAX)) ||

+  ((SerialPortInfo->Interrupt >= ARM_GIC_ARCH_EXT_SPI_MIN) &&

+   (SerialPortInfo->Interrupt <= ARM_GIC_ARCH_EXT_SPI_MAX))) {

+Status = AmlCodeGenRdInterrupt (

+  1,   // Resource Consumer

+  0,   // Level Triggered

+  0,   // Active High

+  0,   // Exclusive

[SAMI] Use BOOLEAN types TRUE/FALSE 

Re: [edk2-devel] [PATCH V5] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined

2023-12-14 Thread Mike Beaton
> IOW, please don't send a v6 until the discussion comes to a conclusion.

Apologies, I did _not_ see this before sending.

> > - #if !defined (MDEPKG_NDEBUG)
> > + #if defined (__CC_ARM) || defined (__GNUC__)
>
> No, this is not going to be acceptable to me. You noted that only the
> ARM code seems to suffer from this issue, so surely, we can find a way
> to change this code that doesn't introduce spurious dependencies on
> the exact toolchain we are using.

With all due respect, I believe that you are incorrect that this is
spurious. Please check the surrounding code (specifically, this
compiler dependency exactly matches - and is there because of - a
compiler dependency in the surrounding code). (Additionally, though it
doesn't affect the point either way, I thought this is what you had
spotted and were asking for, when previously saying "What about
GCC?"!)

Mike


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




Re: [edk2-devel] [PATCH V6] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined

2023-12-14 Thread Mike Beaton
> Please stop sending patches.

I believe this version is a clear improvement, with motivation.
(Certainly, it was meant as such!)

How am I meant to send improvements or updates in this email-based workflow?

Mike


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




[edk2-devel] [PATCH] ArmPkg/DebugPeCoffExtraActionLib: Drop RVCT and Cygwin support

2023-12-14 Thread Ard Biesheuvel
From: Ard Biesheuvel 

The DebugPeCoffExtraActionLib implemention in ArmPkg contains some cruft
that dates back to the original RVCT based ARM port, and support for
RVCT was dropped a while ago.

Also drop the handling of Cygwin specific paths, which is highly
unlikely to be still depended upon by anyone.

Tweak the logic so that only two versions of the DEBUG() invocations
remain: one for __GNUC__ when PdbPointer is set, and the fallback that
just prints the image address and the address of the entrypoint.

Cc: Mike Beaton 
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c | 100 
++--
 1 file changed, 31 insertions(+), 69 deletions(-)

diff --git 
a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c 
b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
index 432112354fda..992c14d7ef9b 100644
--- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
+++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
@@ -17,45 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 
-/**
-  If the build is done on cygwin the paths are cygpaths.
-  /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
-  them to work with RVD commands
-
-  @param  Name  Path to convert if needed
-
-**/
-CHAR8 *
-DeCygwinPathIfNeeded (
-  IN  CHAR8  *Name,
-  IN  CHAR8  *Temp,
-  IN  UINTN  Size
-  )
-{
-  CHAR8  *Ptr;
-  UINTN  Index;
-  UINTN  Index2;
-
-  Ptr = AsciiStrStr (Name, "/cygdrive/");
-  if (Ptr == NULL) {
-return Name;
-  }
-
-  for (Index = 9, Index2 = 0; (Index < (Size + 9)) && (Ptr[Index] != '\0'); 
Index++, Index2++) {
-Temp[Index2] = Ptr[Index];
-if (Temp[Index2] == '/') {
-  Temp[Index2] = '\\';
-}
-
-if (Index2 == 1) {
-  Temp[Index2 - 1] = Ptr[Index];
-  Temp[Index2] = ':';
-}
-  }
-
-  return Temp;
-}
-
 /**
   Performs additional actions after a PE/COFF image has been loaded and 
relocated.
 
@@ -71,23 +32,24 @@ PeCoffLoaderRelocateImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
   )
 {
- #if !defined (MDEPKG_NDEBUG)
-  CHAR8  Temp[512];
- #endif
-
+#ifdef __GNUC__
   if (ImageContext->PdbPointer) {
- #ifdef __CC_ARM
-// Print out the command for the DS-5 to load symbols for this image
-DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
(UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
- #elif __GNUC__
-// This may not work correctly if you generate PE/COFF directly as then 
the Offset would not be required
-DEBUG ((DEBUG_LOAD | DEBUG_INFO, "add-symbol-file %a 0x%p\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
(UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
- #else
-DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p 
EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, 
FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
- #endif
-  } else {
-DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Loading driver at 0x%11p 
EntryPoint=0x%11p\n", (VOID *)(UINTN)ImageContext->ImageAddress, 
FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));
+DEBUG ((
+  DEBUG_LOAD | DEBUG_INFO,
+  "add-symbol-file %a 0x%p\n",
+  ImageContext->PdbPointer,
+  (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)
+  ));
+return;
   }
+#endif
+
+  DEBUG ((
+DEBUG_LOAD | DEBUG_INFO,
+"Loading driver at 0x%11p EntryPoint=0x%11p\n",
+(VOID *)(UINTN)ImageContext->ImageAddress,
+FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)
+));
 }
 
 /**
@@ -106,21 +68,21 @@ PeCoffLoaderUnloadImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
   )
 {
- #if !defined (MDEPKG_NDEBUG)
-  CHAR8  Temp[512];
- #endif
-
+#ifdef __GNUC__
   if (ImageContext->PdbPointer) {
- #ifdef __CC_ARM
-// Print out the command for the RVD debugger to load symbols for this 
image
-DEBUG ((DEBUG_LOAD | DEBUG_INFO, "unload symbols_only %a\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp;
- #elif __GNUC__
-// This may not work correctly if you generate PE/COFF directly as then 
the Offset would not be required
-DEBUG ((DEBUG_LOAD | DEBUG_INFO, "remove-symbol-file %a 0x%08x\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
(UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));
- #else
-DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Unloading %a\n", 
ImageContext->PdbPointer));
- #endif
-  } else {
-DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Unloading driver at 0x%11p\n", (VOID 
*)(UINTN)ImageContext->ImageAddress));
+DEBUG ((
+  DEBUG_LOAD | DEBUG_INFO,
+  "remove-symbol-file %a 0x%08x\n",
+  ImageContext->PdbPointer,
+  (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)
+  ));
+return;
   }

Re: [edk2-devel] [PATCH V6] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined

2023-12-14 Thread Ard Biesheuvel
Please stop sending patches.

On Thu, 14 Dec 2023 at 10:12, Mike Beaton  wrote:
>
> Repeats V5, but with a hopefully clearer (on motivation and history) commit 
> message.
> 


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




Re: [edk2-devel] [PATCH V6] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined

2023-12-14 Thread Mike Beaton
Repeats V5, but with a hopefully clearer (on motivation and history) commit 
message.


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




[edk2-devel] [PATCH V6] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined

2023-12-14 Thread Mike Beaton
From: Mike Beaton 

The variant provided when MDEPKG_NDEBUG is defined will be optimised
away in RELEASE builds, but by referencing the argument list, avoids
unused variable errors from valid debug code, for example when STATIC
variables are used only in DEBUG statements.

This issue was being caused by variable EventNames in
OvmfPkg/VirtioSerialDxe/VirtioSerial.c in CLANGPDB X64 RELEASE build
prior to this commit, and was also being caused by the same variable
in CLANGDWARF X64 RELEASE build, prior to
d3225577123767fd09c91201d27e9c91663ae132 - which we
revert, restoring the desirable feature of failure to build on
genuinely (unintentionally) unused variables when building in either
clang toolchain.

Also change manual exclusion of debug vars when MDEPKG_NDEBUG is
not defined in a similar cases in ArmPkg, to inclusion when used
regardless of MDEPKG_NDEBUG (the revised DEBUG macro automatically
compiles away unused variable accesses, but there has to be a
variable, access to which to discard).

Signed-off-by: Mike Beaton 
---
 .../DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c  | 4 ++--
 .../AArch64/DefaultExceptionHandler.c  | 3 ---
 BaseTools/Conf/tools_def.template  | 2 +-
 MdePkg/Include/Library/DebugLib.h  | 7 ++-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git 
a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c 
b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
index 432112354f..c5c53ef3e1 100644
--- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
+++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
@@ -71,7 +71,7 @@ PeCoffLoaderRelocateImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
   )
 {
- #if !defined (MDEPKG_NDEBUG)
+ #if defined (__CC_ARM) || defined (__GNUC__)
   CHAR8  Temp[512];
  #endif
 
@@ -106,7 +106,7 @@ PeCoffLoaderUnloadImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
   )
 {
- #if !defined (MDEPKG_NDEBUG)
+ #if defined (__CC_ARM) || defined (__GNUC__)
   CHAR8  Temp[512];
  #endif
 
diff --git 
a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c 
b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
index a39896d576..1d3ea61311 100644
--- 
a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
+++ 
b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
@@ -157,7 +157,6 @@ DescribeExceptionSyndrome (
   DEBUG ((DEBUG_ERROR, "\n %a \n", Message));
 }
 
-#ifndef MDEPKG_NDEBUG
 STATIC
 CONST CHAR8 *
 BaseName (
@@ -177,8 +176,6 @@ BaseName (
   return Str;
 }
 
-#endif
-
 /**
   This is the default action to take on an unexpected exception
 
diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index c34ecfd557..eaccf0b698 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1859,7 +1859,7 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS= 
-Wl,--defsym=PECOFF_HEADER_SIZE=0x22
 DEFINE CLANGDWARF_IA32_TARGET = -target i686-pc-linux-gnu
 DEFINE CLANGDWARF_X64_TARGET  = -target x86_64-pc-linux-gnu
 
-DEFINE CLANGDWARF_WARNING_OVERRIDES= -Wno-parentheses-equality 
-Wno-empty-body -Wno-unused-const-variable -Wno-varargs 
-Wno-unknown-warning-option -Wno-unused-but-set-variable 
-Wno-unused-const-variable -Wno-unaligned-access 
-Wno-unneeded-internal-declaration
+DEFINE CLANGDWARF_WARNING_OVERRIDES= -Wno-parentheses-equality 
-Wno-empty-body -Wno-unused-const-variable -Wno-varargs 
-Wno-unknown-warning-option -Wno-unused-but-set-variable 
-Wno-unused-const-variable -Wno-unaligned-access
 DEFINE CLANGDWARF_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) 
DEF(CLANGDWARF_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields 
-Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas 
-Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables 
-mno-sse -mno-mmx -msoft-float -mno-implicit-float  
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang 
-funsigned-char -fno-ms-extensions -Wno-null-dereference
 
 ###
diff --git a/MdePkg/Include/Library/DebugLib.h 
b/MdePkg/Include/Library/DebugLib.h
index 40772f2e0f..bc7789f01c 100644
--- a/MdePkg/Include/Library/DebugLib.h
+++ b/MdePkg/Include/Library/DebugLib.h
@@ -426,7 +426,12 @@ UnitTestDebugAssert (
   }\
 } while (FALSE)
 #else
-#define DEBUG(Expression)
+#define DEBUG(Expression)\
+do {   \
+  if (FALSE) { \
+_DEBUG (Expression);   \
+  }\
+} while (FALSE)
 #endif
 
 /**
-- 
2.39.2



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

Re: [edk2-devel] [PATCH V4 2/2] ArmPkg: Remove manual exclusion of debug vars when MDEPKG_NDEBUG is not defined

2023-12-14 Thread Ard Biesheuvel
On Thu, 14 Dec 2023 at 08:40, Ard Biesheuvel  wrote:
>
> On Thu, 14 Dec 2023 at 08:28, Mike Beaton  wrote:
> >
> > From: Mike Beaton 
> >
> > This is no longer required since the revised DEBUG macro automatically
> > compiles away unused var accesses when MDEPKG_NDEBUG is defined;
> > keeping these lines is incompatible with the updated DEBUG macro, as
> > there has to be a variable, access to which to discard.
> >
> > Signed-off-by: Mike Beaton 
>
> I take it this will trigger a build warning if it is not merged at the
> same time as the other change? How about GCC?
>

Looking at this more closely, we should probably just drop
DeCygwinPathIfNeeded() - I don't think it is still needed.

For the exception handler case, we can just drop the #Ifdefs around
the definition of BaseName () entirely given that it will now always
be referenced. But that does depend a lot on how other toolchains deal
with this (VS201x primarily)


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




Re: [edk2-devel] [PATCH V5] DebugLib: Update DEBUG macro used when MDEPKG_NDEBUG is defined

2023-12-14 Thread Ard Biesheuvel
(cc Michael)

On Thu, 14 Dec 2023 at 08:58, Mike Beaton  wrote:
>
> From: Mike Beaton 
>
> The variant provided when MDEPKG_NDEBUG is defined will be optimised
> away in RELEASE builds, but by referencing the argument list, avoids
> unused variable errors from valid debug code, for example when STATIC
> variables are used only in DEBUG statements.
>
> Variable EventNames in OvmfPkg/VirtioSerialDxe/VirtioSerial.c
> was causing this issue in CLANGPDB X64 RELEASE build, prior to this
> commit.
>
> We also change manual exclusion of debug vars when MDEPKG_NDEBUG is
> not defined, in a similar case in
> ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> to inclusion when used regardless of MDEPKG_NDEBUG (the revised DEBUG
> macro automatically compiles away unused variable accesses, but there
> has to be a variable, access to which to discard).
>
> Signed-off-by: Mike Beaton 

Hi Mike,

I'd prefer to have some discussion with the various maintainers first
- shooting off a new version of your patch every time anyone asks a
question is only going to confuse people.

IOW, please don't send a v6 until the discussion comes to a conclusion.

> ---
>  .../DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c  | 4 ++--
>  .../AArch64/DefaultExceptionHandler.c  | 3 ---
>  BaseTools/Conf/tools_def.template  | 2 +-
>  MdePkg/Include/Library/DebugLib.h  | 7 ++-

These are going to have to be separate patches in any case, even the
MdePkg one and BaseTools changes will need to be split.

So the question is really whether the MdePkg change is palatable to
the maintainers and to the users of other toolchains.

Then, we can talk about how to phase the remaining changes so we don't
break the ARM build.



>  4 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git 
> a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c 
> b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> index 432112354f..c5c53ef3e1 100644
> --- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> +++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
> @@ -71,7 +71,7 @@ PeCoffLoaderRelocateImageExtraAction (
>IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
>)
>  {
> - #if !defined (MDEPKG_NDEBUG)
> + #if defined (__CC_ARM) || defined (__GNUC__)

No, this is not going to be acceptable to me. You noted that only the
ARM code seems to suffer from this issue, so surely, we can find a way
to change this code that doesn't introduce spurious dependencies on
the exact toolchain we are using.

>CHAR8  Temp[512];
>   #endif
>
> @@ -106,7 +106,7 @@ PeCoffLoaderUnloadImageExtraAction (
>IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
>)
>  {
> - #if !defined (MDEPKG_NDEBUG)
> + #if defined (__CC_ARM) || defined (__GNUC__)
>CHAR8  Temp[512];
>   #endif
>
> diff --git 
> a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c 
> b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> index a39896d576..1d3ea61311 100644
> --- 
> a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> +++ 
> b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> @@ -157,7 +157,6 @@ DescribeExceptionSyndrome (
>DEBUG ((DEBUG_ERROR, "\n %a \n", Message));
>  }
>
> -#ifndef MDEPKG_NDEBUG
>  STATIC
>  CONST CHAR8 *
>  BaseName (
> @@ -177,8 +176,6 @@ BaseName (
>return Str;
>  }
>
> -#endif
> -
>  /**
>This is the default action to take on an unexpected exception
>
> diff --git a/BaseTools/Conf/tools_def.template 
> b/BaseTools/Conf/tools_def.template
> index c34ecfd557..eaccf0b698 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -1859,7 +1859,7 @@ DEFINE CLANGDWARF_X64_DLINK2_FLAGS= 
> -Wl,--defsym=PECOFF_HEADER_SIZE=0x22
>  DEFINE CLANGDWARF_IA32_TARGET = -target i686-pc-linux-gnu
>  DEFINE CLANGDWARF_X64_TARGET  = -target x86_64-pc-linux-gnu
>
> -DEFINE CLANGDWARF_WARNING_OVERRIDES= -Wno-parentheses-equality 
> -Wno-empty-body -Wno-unused-const-variable -Wno-varargs 
> -Wno-unknown-warning-option -Wno-unused-but-set-variable 
> -Wno-unused-const-variable -Wno-unaligned-access 
> -Wno-unneeded-internal-declaration
> +DEFINE CLANGDWARF_WARNING_OVERRIDES= -Wno-parentheses-equality 
> -Wno-empty-body -Wno-unused-const-variable -Wno-varargs 
> -Wno-unknown-warning-option -Wno-unused-but-set-variable 
> -Wno-unused-const-variable -Wno-unaligned-access
>  DEFINE CLANGDWARF_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) 
> DEF(CLANGDWARF_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields 
> -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas 
> -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables 
> -mno-sse -mno-mmx -msoft-float -mno-implicit-float  
>