Re: [edk2-devel] [PATCH v4 1/1] MdePkg:Implement RISCV CMO

2023-07-26 Thread Dhaval Sharma
Thanks for your feedback.

   1. Reg coding style, I will remove _ and resubmit but somehow PR CI
   seemed to pass for me (https://github.com/tianocore/edk2/pull/4636).
   2. For size and ext discovery should I wait until your ext discovery
   patch is merged?
   3. Thanks for catching the issue with SENVCFG. Will fix it in the next
   revision after #2 is addressed.

On Mon, Jul 24, 2023 at 10:03 AM Sunil V L  wrote:

> Hi Dhaval,
>
> On Thu, Jul 13, 2023 at 03:03:31PM +0530, Dhaval wrote:
> > From: Dhaval Sharma 
> >
> > Implementing code to support Cache Management Operations
> > (CMO) defined by RV spec https://github.com/riscv/riscv-CMOs
> >
> > Notes:
> > 1. CMO only supports block based Operations. Meaning complete
> >cache flush/invd/clean Operations are not available. In that case
> >we fallback on fence.i instructions.
> > 2. Rely on the fact that platform init has initialized CMO and this
> >implementation just checks if it is enabled.
> > 3. In order to avoid compiler dependency injecting byte code.
> >
> > Test:
> > 1. Ensured correct instructions are refelecting in asm
> > 2. Able to boot platform with RiscVVirtQemu config
> > 3. Not able to verify actual instruction in HW as Qemu ignores
> > any actual cache operations.
> >
> > Cc: Ard Biesheuvel 
> > Cc: Jiewen Yao 
> > Cc: Jordan Justen 
> > Cc: Gerd Hoffmann 
> > Cc: Sunil V L 
> > Cc: Andrei Warkentin 
> > Signed-off-by: Dhaval Sharma 
> > ---
> >
> > Notes:
> > v4:
> > - Removed CMO specific directory in Base Lib
> > - Implemented compiler independent code for CMO
> > - Merged CMO implementation with fence.i
> > - Added logic to confirm CMO is enabled
> >
> >  MdePkg/Library/BaseLib/BaseLib.inf  |   2 +-
> >  MdePkg/Include/Register/RiscV64/RiscVEncoding.h |   4 +
> >  MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c | 200
> ++--
> >  MdePkg/Library/BaseLib/RiscV64/FlushCache.S |  21 --
> >  MdePkg/Library/BaseLib/RiscV64/RiscVCacheMgmt.S |  64 +++
> >  5 files changed, 254 insertions(+), 37 deletions(-)
> >
> > diff --git a/MdePkg/Library/BaseLib/BaseLib.inf
> b/MdePkg/Library/BaseLib/BaseLib.inf
> > index 03c7b02e828b..53389389448c 100644
> > --- a/MdePkg/Library/BaseLib/BaseLib.inf
> > +++ b/MdePkg/Library/BaseLib/BaseLib.inf
> > @@ -400,7 +400,7 @@ [Sources.RISCV64]
> >RiscV64/RiscVCpuBreakpoint.S  | GCC
> >RiscV64/RiscVCpuPause.S   | GCC
> >RiscV64/RiscVInterrupt.S  | GCC
> > -  RiscV64/FlushCache.S  | GCC
> > +  RiscV64/RiscVCacheMgmt.S  | GCC
> >RiscV64/CpuScratch.S  | GCC
> >RiscV64/ReadTimer.S   | GCC
> >RiscV64/RiscVMmu.S| GCC
> > diff --git a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h
> b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h
> > index 5c2989b797bf..ea1493578bd5 100644
> > --- a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h
> > +++ b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h
> > @@ -85,6 +85,10 @@
> >  /* Supervisor Configuration */
> >  #define CSR_SENVCFG  0x10a
> >
> > +/* Defined CBO bits*/
> > +#define SENVCFG_CBCFE  0x40UL
> > +#define SENVCFG_CBIE   0x30UL
> > +
> >  /* Supervisor Trap Handling */
> >  #define CSR_SSCRATCH  0x140
> >  #define CSR_SEPC  0x141
> > diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > index d08fb9f193ca..8b853e5b69fa 100644
> > --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > @@ -1,7 +1,8 @@
> >  /** @file
> > -  RISC-V specific functionality for cache.
> > +  Implement Risc-V Cache Management Operations
> >
> >Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All
> rights reserved.
> > +  Copyright (c) 2023, Rivos Inc. All rights reserved.
> >
> >SPDX-License-Identifier: BSD-2-Clause-Patent
> >  **/
> > @@ -10,13 +11,21 @@
> >  #include 
> >  #include 
> >
> > +#define RV64_CACHE_BLOCK_SIZE  64
> > +
> Can we avoid hard coding this? We can get it from DT.
>
> > +typedef enum {
> > +  Clean,
> > +  Flush,
> > +  Invld,
> > +} CACHE_OP;
> > +
> >  /**
> >RISC-V invalidate instruction cache.
> >
> >  **/
> >  VOID
> >  EFIAPI
> > -RiscVInvalidateInstCacheAsm (
> > +RiscVInvalidateInstCacheAsm_Fence (
> This is not EDK2 coding style... and other similar functions below.
>
> >VOID
> >);
> >
> > @@ -26,13 +35,144 @@ RiscVInvalidateInstCacheAsm (
> >  **/
> >  VOID
> >  EFIAPI
> > -RiscVInvalidateDataCacheAsm (
> > +RiscVInvalidateDataCacheAsm_Fence (
> >VOID
> >);
> >
> > +/**
> > +  RISC-V flush cache block. Atomically perform a clean operation
> > +  followed by an invalidate operation
> > +
> > +**/
> > +VOID
> > +EFIAPI
> > +RiscVCpuCacheFlushAsm_Cbo (
> > +  UINTN
> > +  );
> > +
> > +/**
> > +Perform a write transfer to another cache or to memory if the
> > +data in the copy of the cache 

Re: [edk2-devel] empty USB DVD disk hang Xhci

2023-07-26 Thread 苏丽坤
Hi, Hao,Liming,




   this is my reply, function XhcInitializeDeviceSlot64 will init 
EndpointTransferRing,while fuctionUsbMassReadBlocks return (Invalid Parameter), 
which result in run function UsbMassReset, this will call  XhcDisableSlotCmd64, 
will clear EndpointTransferRing, like this 
Xhc->UsbDevContext[SlotId].EndpointTransferRing[Index] = NULL;  If  
fuctionUsbMassReadBlocks return success also run function UsbMassReset, will 
hang for the same reason. why fuctionUsbMassReadBlocks return (Invalid 
Parameter), this function will call UsbBootRequestSense,this retun (Invalid 
Parameter). At the same time, Ehci alsoretun  (Invalid Parameter).




Thanks 
-原始邮件-
发件人:"Wu, Hao A" 
发送时间:2023-07-25 10:18:42 (星期二)
收件人: "Gao, Liming" , "devel@edk2.groups.io" 
, "suli...@loongson.cn" , "Demeter, 
Miki" 
主题: RE: [edk2-devel] empty USB DVD disk hang Xhci



Sorry, I do not have much resource to review this in detail. But the patch 
generally looks good to me:

Acked-by: Hao A Wu hao.a...@intel.com

 

However, I hope the below question can be answered (or add related information 
to the commit log message) before mering:

Likun, could you help to elaborate a bit more on why the below statement will 
return NULL pointer for “USB DVD with empty disk”?

EPRing= (TRANSFER_RING 
*)(UINTN)Xhc->UsbDevContext[SlotId].EndpointTransferRing[Dci-1];

 

 

Best Regards,

Hao Wu

 

From: gaoliming 
Sent: Tuesday, July 25, 2023 9:44 AM
To: devel@edk2.groups.io; suli...@loongson.cn; Demeter, Miki 

Cc: Wu, Hao A 
Subject:回复: [edk2-devel] empty USB DVD disk hang Xhci

 

Likun:

 This change is good to me.  Reviewed-by: Liming Gao 

 

Hao:

 Have you time to review this fix?

 

Thanks

Liming

发件人:devel@edk2.groups.io  代表 苏丽坤
发送时间: 2023年7月18日 9:49
收件人:gaolim...@byosoft.com.cn; miki.deme...@intel.com; devel@edk2.groups.io
主题: [edk2-devel] empty USB DVD disk hang Xhci

 

Hi

We find a bug in xhci, USB DVD boot with emtpy disk will hang Xhci while 
Ehci can pass.

The hang log is shown as : MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c(1847): 
TrsRing != ((void *) 0)

We suggest a way to solve this bug is shown as: 
https://github.com/suling-123/edk2 the latest commit,   MdeModulePkg: Solve 
boot hang xhci driver when use USB DVD with empty disk, 
950bc8781d81b96b0c7944e7ac947382b1bc0c06



本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。
 
This email and its attachments contain confidential information from Loongson 
Technology , which is intended only for the person or entity whose address is 
listed above. Any use of the information contained herein in any way 
(including, but not limited to, total or partial disclosure, reproduction or 
dissemination) by persons other than the intended recipient(s) is prohibited. 
If you receive this email in error, please notify the sender by phone or email 
immediately and delete it. 



本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。
 
This email and its attachments contain confidential information from Loongson 
Technology , which is intended only for the person or entity whose address is 
listed above. Any use of the information contained herein in any way 
(including, but not limited to, total or partial disclosure, reproduction or 
dissemination) by persons other than the intended recipient(s) is prohibited. 
If you receive this email in error, please notify the sender by phone or email 
immediately and delete it. 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107291): https://edk2.groups.io/g/devel/message/107291
Mute This Topic: https://groups.io/mt/100343121/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 2/3] ShellPkg: acpiview: Add routine to print 16 chars

2023-07-26 Thread Gao, Zhichao
Reviewed-by: Zhichao Gao 

Thanks,
Zhichao

> -Original Message-
> From: Pierre Gondois 
> Sent: Thursday, July 20, 2023 11:25 PM
> To: devel@edk2.groups.io; rohit.mat...@arm.com
> Cc: Thomas Abraham ; Sami Mujawar
> ; James Morse ; Ni,
> Ray ; Gao, Zhichao 
> Subject: Re: [edk2-devel] [PATCH V3 2/3] ShellPkg: acpiview: Add routine to
> print 16 chars
> 
> Reviewed-by: Pierre Gondois 
> 
> On 5/22/23 16:44, Rohit Mathew via groups.io wrote:
> > Certain ACPI tables like MPAM has fields which are 16 bytes long.
> > Routines similar to Dump12Chars but for 16 characters are required to
> > print such fields. Add Dump16Chars routine to satisfy this requirement.
> >
> > Signed-off-by: Rohit Mathew 
> > ---
> >   ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 39
> +++-
> >   ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h | 18
> -
> >   2 files changed, 55 insertions(+), 2 deletions(-)
> >
> > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
> > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
> > index eac9286176..87f55098b8 100644
> > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
> > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
> > @@ -1,7 +1,7 @@
> >   /** @file
> > ACPI parser
> >
> > -  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
> > +  Copyright (c) 2016 - 2023, Arm Limited. All rights reserved.
> > Copyright (c) 2022, AMD Incorporated. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >   **/
> > @@ -449,6 +449,43 @@ Dump12Chars (
> >   );
> >   }
> >
> > +/**
> > +  This function traces 16 characters which can be optionally
> > +  formated using the format string if specified.
> > +
> > +  If no format string is specified the Format must be NULL.
> > +
> > +  @param [in] Format  Optional format string for tracing the data.
> > +  @param [in] Ptr Pointer to the start of the buffer.
> > +**/
> > +VOID
> > +EFIAPI
> > +Dump16Chars (
> > +  IN CONST CHAR16  *Format OPTIONAL,
> > +  IN UINT8 *Ptr
> > +  )
> > +{
> > +  Print (
> > +(Format != NULL) ? Format :
> L"%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
> > +Ptr[0],
> > +Ptr[1],
> > +Ptr[2],
> > +Ptr[3],
> > +Ptr[4],
> > +Ptr[5],
> > +Ptr[6],
> > +Ptr[7],
> > +Ptr[8],
> > +Ptr[9],
> > +Ptr[10],
> > +Ptr[11],
> > +Ptr[12],
> > +Ptr[13],
> > +Ptr[14],
> > +Ptr[15]
> > +);
> > +}
> > +
> >   /**
> > This function indents and prints the ACPI table Field Name.
> >
> > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> > index 4b4397961b..c9f41650d9 100644
> > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> > @@ -2,7 +2,7 @@
> > Header file for ACPI parser
> >
> > Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
> > -  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
> > +  Copyright (c) 2016 - 2023, Arm Limited. All rights reserved.
> > Copyright (c) 2022, AMD Incorporated. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >   **/
> > @@ -202,6 +202,22 @@ Dump12Chars (
> > IN   UINT8   *Ptr
> > );
> >
> > +/**
> > +  This function traces 16 characters which can be optionally
> > +  formated using the format string if specified.
> > +
> > +  If no format string is specified the Format must be NULL.
> > +
> > +  @param [in] Format  Optional format string for tracing the data.
> > +  @param [in] Ptr Pointer to the start of the buffer.
> > +**/
> > +VOID
> > +EFIAPI
> > +Dump16Chars (
> > +  IN CONST CHAR16  *Format OPTIONAL,
> > +  IN UINT8 *Ptr
> > +  );
> > +
> >   /**
> > This function indents and prints the ACPI table Field Name.
> >


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




Re: [edk2-devel] [PATCH v2 1/1] ShellPkg: Acpiview/GTDT: Print timer flags information.

2023-07-26 Thread Gao, Zhichao
Reviewed-by: Zhichao Gao 

Thanks,
Zhichao

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of levi.yun
> Sent: Monday, July 17, 2023 3:44 PM
> To: devel@edk2.groups.io
> Cc: yeoreum@arm.com; Gao, Zhichao ;
> pedro.falc...@gmail.com; sami.muja...@arm.com;
> pierre.gond...@arm.com; n...@arm.com
> Subject: [edk2-devel] [PATCH v2 1/1] ShellPkg: Acpiview/GTDT: Print timer
> flags information.
> 
> Currently, GTDT only prints the value of timer flags in hex.
> This change prints the detail information about Timer flags in GTDT.
> 
> before:
> Shell> acpiview -s GTDT
> ...
> Non-Secure EL1 timer FLAGS : 0x2
> Virtual timer GSIV : 0x1B
> Virtual timer FLAGS: 0x2
> ...
> 
> after:
> Shell> acpiview -s GTDT
> ...
> Non-Secure EL1 timer FLAGS : 0x2
> Timer Interrupt Mode : Level Trigger(0)
> Timer Interrupt Polarity : Active Low(1)
> Always-on Capability : 0
> Reserved : 0
> 
> Virtual timer GSIV : 0x1B
> Virtual timer FLAGS: 0x2
> 
> Signed-off-by: levi.yun 
> Tested-by: Pierre Gondois 
> ---
> The changes can be seen at
> https://github.com/LeviYeoReum/edk2/tree/2711_gtdt_flags_v2
> 
> Notes:
> v2:
>- Fix typos.
>- Remove unnecessary type casting.
> 
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
> | 111 +---
>  1 file changed, 98 insertions(+), 13 deletions(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser
> .c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser
> .c
> index
> e62927098a010a0e1dad8361dcfc6559d32dcebf..c95b96a673bf7e6afea7902f57
> 30dcb61a3ce508 100644
> ---
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser
> .c
> +++
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser
> .c
> @@ -84,33 +84,118 @@ ValidateGtFrameNumber (
>}
>  }
> 
> +/**
> +  This function prints trigger mode information in timer flags.
> +
> +  @param [in] Format Print format.
> +  @param [in] PtrPointer to the start of the field data.
> +**/
> +STATIC
> +VOID
> +EFIAPI
> +PrintTimerInterruptMode (
> +  IN CONST CHAR16  *Format OPTIONAL,
> +  IN UINT8 *Ptr
> +  )
> +{
> +  UINT8  TriggerMode;
> +
> +  TriggerMode = *Ptr;
> +
> +  Print (
> +L"%s(%d)",
> +(TriggerMode ? L"Edge Trigger" : L"Level Trigger"),
> +TriggerMode
> +);
> +}
> +
> +/**
> +  This function prints polarity information in timer flags.
> +
> +  @param [in] Format Print format.
> +  @param [in] PtrPointer to the start of the field data.
> +**/
> +STATIC
> +VOID
> +EFIAPI
> +PrintTimerInterruptPolarity (
> +  IN CONST CHAR16  *Format OPTIONAL,
> +  IN UINT8 *Ptr
> +  )
> +{
> +  UINT8  Polarity;
> +
> +  Polarity = *Ptr;
> +
> +  Print (
> +L"%s(%d)",
> +(Polarity ? L"Active Low" : L"Active High"),
> +Polarity
> +);
> +}
> +
> +/**
> +  An ACPI_PARSER array describing the Timer Flags Field in GTDT Table.
> +**/
> +STATIC CONST ACPI_PARSER  TimerFlagsParser[] = {
> +  { L"Timer Interrupt Mode", 1,  0, NULL,  PrintTimerInterruptMode,
> NULL, NULL, NULL },
> +  { L"Timer Interrupt Polarity", 1,  1, NULL,  PrintTimerInterruptPolarity, 
> NULL,
> NULL, NULL },
> +  { L"Always-on Capability", 1,  2, L"%d", NULL,
> NULL, NULL,
> NULL },
> +  { L"Reserved", 29, 3, L"%d", NULL,
> NULL, NULL, NULL },
> +};
> +
> +/**
> +  This function parses the Timer Flags.
> +
> +  @param [in]   Format  Print format.
> +  @param [in]   Ptr Pointer to the start of the Timer flags.
> + **/
> +STATIC
> +VOID
> +EFIAPI
> +DumpTimerFlags (
> +  IN CONST CHAR16  *Format OPTIONAL,
> +  IN UINT8 *Ptr
> +  )
> +{
> +  DumpUint32 (L"0x%x\n", Ptr);
> +  ParseAcpiBitFields (
> +TRUE,
> +2,
> +NULL,
> +Ptr,
> +4,
> +PARSER_PARAMS (TimerFlagsParser)
> +);
> +}
> +
>  /**
>An ACPI_PARSER array describing the ACPI GTDT Table.
>  **/
>  STATIC CONST ACPI_PARSER  GtdtParser[] = {
>PARSE_ACPI_HEADER (),
> -  { L"CntControlBase Physical Address",8,  36,  L"0x%lx", NULL, NULL,
> +  { L"CntControlBase Physical Address",8,  36,  L"0x%lx", NULL,  
>  NULL,
>  NULL, NULL },
> -  { L"Reserved",  4,  44,  L"0x%x",  NULL, 
> NULL,NULL,  NULL },
> -  { L"Secure EL1 timer GSIV", 4,  48,  L"0x%x",  NULL, NULL,NULL,
> NULL },
> -  { L"Secure EL1 timer FLAGS",4,  52,  L"0x%x",  NULL, NULL,NULL,
> NULL },
> +  { L"Reserved",  4,  44,  L"0x%x",  NULL,   
> NULL,NULL,  NULL },
> +  { L"Secure EL1 timer GSIV", 4,  48,  L"0x%x",  NULL,   
> NULL,NULL,
> NULL },
> +  { L"Secure EL1 timer FLAGS",

Re: [edk2-devel] [PATCH v2 2/2] ShellPkg/Dp: Allow dp command to work without ACPI

2023-07-26 Thread Gao, Zhichao
Reviewed-by: Zhichao Gao 

Thanks,
Zhichao

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Jeff
> Brasen via groups.io
> Sent: Saturday, July 1, 2023 1:30 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J ; Gao, Liming
> ; Bi, Dandan ; Gao,
> Zhichao ; Jeff Brasen 
> Subject: [edk2-devel] [PATCH v2 2/2] ShellPkg/Dp: Allow dp command to
> work without ACPI
> 
> If the system does not have ACPI setup use the configuration table to get the
> performance info.
> 
> Signed-off-by: Jeff Brasen 
> ---
>  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf|  1 +
>  .../DpDynamicCommand/DpDynamicCommand.inf |  1 +
>  ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 11 -
> --
>  3 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> index 4a58286b8c1a..d9e1c23a1ee7 100644
> --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> @@ -54,6 +54,7 @@ [LibraryClasses]
> 
>  [Guids]
>gPerformanceProtocolGuid## CONSUMES ## 
> SystemTable
> +  gEdkiiFpdtExtendedFirmwarePerformanceGuid   ## CONSUMES ##
> SystemTable
> 
>  [Protocols]
>gEfiLoadedImageProtocolGuid ## CONSUMES
> diff --git
> a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.i
> nf
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.i
> nf
> index 013bdbd4a07e..2723fee7066e 100644
> ---
> a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.i
> nf
> +++
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.i
> nf
> @@ -55,6 +55,7 @@ [LibraryClasses]
> 
>  [Guids]
>gPerformanceProtocolGuid## CONSUMES ## 
> SystemTable
> +  gEdkiiFpdtExtendedFirmwarePerformanceGuid   ## CONSUMES ##
> SystemTable
> 
>  [Protocols]
>gEfiLoadedImageProtocolGuid ## CONSUMES
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> index 512a146da6dd..98c84d2ef938 100644
> --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> @@ -129,17 +129,22 @@ EFI_STATUS
>  GetBootPerformanceTable (
>)
>  {
> +  EFI_STATUS  Status;
>FIRMWARE_PERFORMANCE_TABLE  *FirmwarePerformanceTable;
> 
>FirmwarePerformanceTable = (FIRMWARE_PERFORMANCE_TABLE
> *)EfiLocateFirstAcpiTable (
> 
> EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
>   );
>if (FirmwarePerformanceTable == NULL) {
> -ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_GET_ACPI_FPDT_FAIL), mDpHiiHandle);
> -return EFI_NOT_FOUND;
> +Status = EfiGetSystemConfigurationTable
> (, (VOID
> **));
> +if (EFI_ERROR (Status)) {
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_GET_ACPI_FPDT_FAIL), mDpHiiHandle);
> +  return EFI_NOT_FOUND;
> +}
> +  } else {
> +mBootPerformanceTable = (UINT8
> + *)(UINTN)FirmwarePerformanceTable-
> >BootPointerRecord.BootPerformanceTa
> + blePointer;
>}
> 
> -  mBootPerformanceTable = (UINT8
> *)(UINTN)FirmwarePerformanceTable-
> >BootPointerRecord.BootPerformanceTablePointer;
>mBootPerformanceTableSize = ((BOOT_PERFORMANCE_TABLE
> *)mBootPerformanceTable)->Header.Length;
> 
>return EFI_SUCCESS;
> --
> 2.25.1
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH] Intel/MinPlatformPkg:Add MmSaveStateLib required by PiSmmCpuDxe

2023-07-26 Thread Ni, Ray
Reviewed-by: Ray Ni 

> -Original Message-
> From: Tan, Dun 
> Sent: Thursday, July 27, 2023 10:22 AM
> To: devel@edk2.groups.io
> Cc: Ni, Ray ; Chiu, Chasel ;
> Desimone, Nathaniel L ; Oram, Isaac W
> ; Gao, Liming ; Dong,
> Eric 
> Subject: [PATCH] Intel/MinPlatformPkg:Add MmSaveStateLib required by
> PiSmmCpuDxe
> 
> Add MmSaveStateLib instance required by PiSmmCpuDxe driver to
> fix QSP platform build failure.
> 
> Signed-off-by: Dun Tan 
> Cc: Ray Ni 
> Cc: Chasel Chiu 
> Cc: Nate DeSimone 
> Cc: Isaac Oram 
> Cc: Liming Gao 
> Cc: Eric Dong 
> ---
>  Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
> b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
> index 5a2cb130b3..260f3b94c5 100644
> --- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
> +++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
> @@ -83,6 +83,7 @@
> 
> 
> SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull
> /SmmCpuPlatformHookLibNull.inf
> 
> SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeat
> uresLib.inf
> +
> MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib
> .inf
> 
> 
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmC
> puExceptionHandlerLib.inf
> 
> Tcg2PhysicalPresenceLib|SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/S
> mmTcg2PhysicalPresenceLib.inf
> --
> 2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107287): https://edk2.groups.io/g/devel/message/107287
Mute This Topic: https://groups.io/mt/100383968/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] SimicsOpenBoardPkg: Set PcdDxeIplSwitchToLongMode to FALSE

2023-07-26 Thread Ni, Ray
Reviewed-by: Ray Ni 

> -Original Message-
> From: Tan, Dun 
> Sent: Thursday, July 27, 2023 10:23 AM
> To: devel@edk2.groups.io
> Cc: Ni, Ray ; Desimone, Nathaniel L
> ; Zhiguang Liu 
> Subject: [PATCH] SimicsOpenBoardPkg: Set PcdDxeIplSwitchToLongMode to
> FALSE
> 
> Set PcdDxeIplSwitchToLongMode to FALSE if the execution
> mode is not IA32 PEI + X64 DXE.
> 
> Signed-off-by: Dun Tan 
> Cc: Ray Ni 
> Cc: Nate DeSimone 
> Cc: Zhiguang Liu 
> ---
>  Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
> | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> index b401bcd414..180f229545 100644
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> @@ -32,7 +32,11 @@
>##
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdBrowerGrayOutReadOnlyMenu|TRUE
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
> +!if $(PEI_ARCH) == "IA32" && $(DXE_ARCH) == "X64"
>gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
> +!else
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
> +!endif
>gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
>gEfiMdeModulePkgTokenSpaceGuid.PcdPciBusHotplugDeviceSupport|FALSE
>gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset|FALSE
> --
> 2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107286): https://edk2.groups.io/g/devel/message/107286
Mute This Topic: https://groups.io/mt/100383975/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] [PATCH] SimicsOpenBoardPkg: Set PcdDxeIplSwitchToLongMode to FALSE

2023-07-26 Thread duntan
Set PcdDxeIplSwitchToLongMode to FALSE if the execution
mode is not IA32 PEI + X64 DXE.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Nate DeSimone 
Cc: Zhiguang Liu 
---
 Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc | 4 
 1 file changed, 4 insertions(+)

diff --git 
a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc 
b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
index b401bcd414..180f229545 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
@@ -32,7 +32,11 @@
   ##
   gEfiMdeModulePkgTokenSpaceGuid.PcdBrowerGrayOutReadOnlyMenu|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
+!if $(PEI_ARCH) == "IA32" && $(DXE_ARCH) == "X64"
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
+!else
+  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
+!endif
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciBusHotplugDeviceSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset|FALSE
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH] Intel/MinPlatformPkg:Add MmSaveStateLib required by PiSmmCpuDxe

2023-07-26 Thread duntan
Add MmSaveStateLib instance required by PiSmmCpuDxe driver to
fix QSP platform build failure.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Isaac Oram 
Cc: Liming Gao 
Cc: Eric Dong 
---
 Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc 
b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
index 5a2cb130b3..260f3b94c5 100644
--- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
+++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
@@ -83,6 +83,7 @@
 
   
SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
   SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
 
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
   
Tcg2PhysicalPresenceLib|SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.inf
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 5/5] UefiCpuPkg/PiSmmCpuDxe: use MpService2Ppi to wakeup AP in s3

2023-07-26 Thread duntan
Use MpService2Ppi to wakeup AP in s3 boot flow during initializing
CPU. If mSmmS3ResumeState->MpService2Ppi is not 0, then BSP will
use MpService2Ppi->StartupAllCPUs to do CPU initialization for both
BSP and AP instead of only sending InitSipiSipi for AP.

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 75 
+++
 1 file changed, 55 insertions(+), 20 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index d2e2135d08..8b0e4afc59 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -7,6 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
 #include "PiSmmCpuDxeSmm.h"
+#include 
+#include 
 
 #pragma pack(1)
 typedef struct {
@@ -571,12 +573,17 @@ InitializeAp (
   SetRegister (FALSE);
 
   //
-  // Place AP into the safe code, count down the number with lock mechanism in 
the safe code.
+  // When using MpService2Ppi to wakeup AP, BSP will fail to return from 
MpService2Ppi if AP hang there.
   //
-  TopOfStack  = (UINTN)Stack + sizeof (Stack);
-  TopOfStack &= ~(UINTN)(CPU_STACK_ALIGNMENT - 1);
-  CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, sizeof 
(mApHltLoopCodeTemplate));
-  TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, 
(UINTN));
+  if (mSmmS3ResumeState->MpService2Ppi == 0) {
+//
+// Place AP into the safe code, count down the number with lock mechanism 
in the safe code.
+//
+TopOfStack  = (UINTN)Stack + sizeof (Stack);
+TopOfStack &= ~(UINTN)(CPU_STACK_ALIGNMENT - 1);
+CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, sizeof 
(mApHltLoopCodeTemplate));
+TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, 
(UINTN));
+  }
 }
 
 /**
@@ -634,7 +641,7 @@ PrepareApStartupVector (
   The function is invoked before SMBASE relocation in S3 path to restores CPU 
status.
 
   The function is invoked before SMBASE relocation in S3 path. It does first 
time microcode load
-  and restores MTRRs for both BSP and APs.
+  and restores MTRRs for BSP.
 
 **/
 VOID
@@ -689,8 +696,10 @@ InitializeCpuAfterRebase (
   //
   SetRegister (FALSE);
 
-  while (mNumberToFinish > 0) {
-CpuPause ();
+  if (mSmmS3ResumeState->MpService2Ppi == 0) {
+while (mNumberToFinish > 0) {
+  CpuPause ();
+}
   }
 }
 
@@ -742,6 +751,24 @@ InitializeBsp (
   }
 }
 
+/**
+  Cpu initialization procedure.
+
+  @param[in,out] Buffer  The pointer to private data buffer.
+**/
+VOID
+EFIAPI
+InitializeCpuProcedure (
+  IN OUT VOID  *Buffer
+  )
+{
+  if (mBspApicId == GetApicId ()) {
+InitializeBsp ();
+  } else {
+InitializeAp ();
+  }
+}
+
 /**
   Restore SMM Configuration in S3 boot path.
 
@@ -790,11 +817,12 @@ SmmRestoreCpu (
   VOID
   )
 {
-  SMM_S3_RESUME_STATE   *SmmS3ResumeState;
-  IA32_DESCRIPTOR   Ia32Idtr;
-  IA32_DESCRIPTOR   X64Idtr;
-  IA32_IDT_GATE_DESCRIPTOR  IdtEntryTable[EXCEPTION_VECTOR_NUMBER];
-  EFI_STATUSStatus;
+  SMM_S3_RESUME_STATE *SmmS3ResumeState;
+  IA32_DESCRIPTOR Ia32Idtr;
+  IA32_DESCRIPTOR X64Idtr;
+  IA32_IDT_GATE_DESCRIPTORIdtEntryTable[EXCEPTION_VECTOR_NUMBER];
+  EFI_STATUS  Status;
+  EDKII_PEI_MP_SERVICES2_PPI  *Mp2ServicePpi;
 
   DEBUG ((DEBUG_INFO, "SmmRestoreCpu()\n"));
 
@@ -858,15 +886,22 @@ SmmRestoreCpu (
 //
 mInitApsAfterSmmBaseReloc = FALSE;
 
-PrepareApStartupVector (mAcpiCpuData.StartupVector);
-//
-// Send INIT IPI - SIPI to all APs
-//
-SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
+if (mSmmS3ResumeState->MpService2Ppi != 0) {
+  mBspApicId= GetApicId ();
+  Mp2ServicePpi = (EDKII_PEI_MP_SERVICES2_PPI 
*)(UINTN)mSmmS3ResumeState->MpService2Ppi;
+  Mp2ServicePpi->StartupAllCPUs (Mp2ServicePpi, 
(EFI_AP_PROCEDURE)InitializeCpuProcedure, 0, NULL);
+} else {
+  PrepareApStartupVector (mAcpiCpuData.StartupVector);
+  //
+  // Send INIT IPI - SIPI to all APs
+  //
+  SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
+  InitializeBsp ();
+}
+  } else {
+InitializeBsp ();
   }
 
-  InitializeBsp ();
-
   //
   // Set a flag to restore SMM configuration in S3 path.
   //
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 4/5] UefiCpuPkg/PiSmmCpuDxe: code refinement for CpuS3.c

2023-07-26 Thread duntan
This commit is code logic refinement for CpuS3.c. It doesn't
change any code functionality.
In this commit, abstract the function originally executed by BSP
into a new InitializeBsp(). Also prepare the AP StartupVector and
send InitSipiSipi in SmmRestoreCpu() when mAcpiCpuData is valid.
Or only InitializeBsp will be executed by BSP. This can make the
code logic easier to understand.

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 110 
+++---
 1 file changed, 63 insertions(+), 47 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 0f7ee0372d..d2e2135d08 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -627,6 +627,7 @@ PrepareApStartupVector (
   mExchangeInfo->BufferStart = (UINT32)StartupVector;
   mExchangeInfo->Cr3 = (UINT32)(AsmReadCr3 ());
   mExchangeInfo->InitializeFloatingPointUnitsAddress = 
(UINTN)InitializeFloatingPointUnits;
+  mExchangeInfo->ApFunction  = (VOID 
*)(UINTN)InitializeAp;
 }
 
 /**
@@ -647,27 +648,6 @@ InitializeCpuBeforeRebase (
 
   ProgramVirtualWireMode ();
 
-  PrepareApStartupVector (mAcpiCpuData.StartupVector);
-
-  if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
-ASSERT (mNumberOfCpus <= mAcpiCpuData.NumberOfCpus);
-  } else {
-ASSERT (mNumberOfCpus == mAcpiCpuData.NumberOfCpus);
-  }
-
-  mNumberToFinish   = (UINT32)(mNumberOfCpus - 1);
-  mExchangeInfo->ApFunction = (VOID *)(UINTN)InitializeAp;
-
-  //
-  // Execute code for before SmmBaseReloc. Note: This flag is maintained 
across S3 boots.
-  //
-  mInitApsAfterSmmBaseReloc = FALSE;
-
-  //
-  // Send INIT IPI - SIPI to all APs
-  //
-  SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
-
   while (mNumberToFinish > 0) {
 CpuPause ();
   }
@@ -714,6 +694,54 @@ InitializeCpuAfterRebase (
   }
 }
 
+/**
+  Procedure for BSP to do the cpu initialization.
+
+**/
+VOID
+InitializeBsp (
+  VOID
+  )
+{
+  //
+  // Skip initialization if mAcpiCpuData is not valid
+  //
+  if (mAcpiCpuData.NumberOfCpus > 0) {
+//
+// First time microcode load and restore MTRRs
+//
+InitializeCpuBeforeRebase ();
+  }
+
+  DEBUG ((DEBUG_INFO, "SmmRestoreCpu: mSmmRelocated is %d\n", mSmmRelocated));
+
+  //
+  // Check whether Smm Relocation is done or not.
+  // If not, will do the SmmBases Relocation here!!!
+  //
+  if (!mSmmRelocated) {
+//
+// Restore SMBASE for BSP and all APs
+//
+SmmRelocateBases ();
+  } else {
+//
+// Issue SMI IPI (All Excluding  Self SMM IPI + BSP SMM IPI) to execute 
first SMI init.
+//
+ExecuteFirstSmiInit ();
+  }
+
+  //
+  // Skip initialization if mAcpiCpuData is not valid
+  //
+  if (mAcpiCpuData.NumberOfCpus > 0) {
+//
+// Restore MSRs for BSP and all APs
+//
+InitializeCpuAfterRebase ();
+  }
+}
+
 /**
   Restore SMM Configuration in S3 boot path.
 
@@ -814,43 +842,31 @@ SmmRestoreCpu (
   }
 
   //
-  // Skip initialization if mAcpiCpuData is not valid
+  // Skip AP initialization if mAcpiCpuData is not valid
   //
   if (mAcpiCpuData.NumberOfCpus > 0) {
-//
-// First time microcode load and restore MTRRs
-//
-InitializeCpuBeforeRebase ();
-  }
+if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
+  ASSERT (mNumberOfCpus <= mAcpiCpuData.NumberOfCpus);
+} else {
+  ASSERT (mNumberOfCpus == mAcpiCpuData.NumberOfCpus);
+}
 
-  DEBUG ((DEBUG_INFO, "SmmRestoreCpu: mSmmRelocated is %d\n", mSmmRelocated));
+mNumberToFinish = (UINT32)(mNumberOfCpus - 1);
 
-  //
-  // Check whether Smm Relocation is done or not.
-  // If not, will do the SmmBases Relocation here!!!
-  //
-  if (!mSmmRelocated) {
-//
-// Restore SMBASE for BSP and all APs
-//
-SmmRelocateBases ();
-  } else {
 //
-// Issue SMI IPI (All Excluding  Self SMM IPI + BSP SMM IPI) to execute 
first SMI init.
+// Execute code for before SmmBaseReloc. Note: This flag is maintained 
across S3 boots.
 //
-ExecuteFirstSmiInit ();
-  }
+mInitApsAfterSmmBaseReloc = FALSE;
 
-  //
-  // Skip initialization if mAcpiCpuData is not valid
-  //
-  if (mAcpiCpuData.NumberOfCpus > 0) {
+PrepareApStartupVector (mAcpiCpuData.StartupVector);
 //
-// Restore MSRs for BSP and all APs
+// Send INIT IPI - SIPI to all APs
 //
-InitializeCpuAfterRebase ();
+SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
   }
 
+  InitializeBsp ();
+
   //
   // Set a flag to restore SMM configuration in S3 path.
   //
-- 
2.31.1.windows.1



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

[edk2-devel] [PATCH 3/5] UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo

2023-07-26 Thread duntan
Add assert for invalid excution mode combination of 64bit PEI +
32bit DXE.

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c 
b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 6574849939..34aa901f93 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -1106,6 +1106,13 @@ S3RestoreConfig2 (
 DEBUG ((DEBUG_INFO, "SMM S3 Return Stack Pointer = %x\n", 
SmmS3ResumeState->ReturnStackPointer));
 DEBUG ((DEBUG_INFO, "SMM S3 Smst = %x\n", 
SmmS3ResumeState->Smst));
 
+//
+// 64bit PEI and 32bit DXE is not a supported combination.
+//
+if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) {
+  ASSERT (sizeof (UINTN) == sizeof (UINT32));
+}
+
 //
 // Directly do the switch stack when PEI and SMM env run in the same 
execution mode.
 //
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 2/5] UefiCpuPkg/S3Resume2Pei: prepare MpService2Ppi in S3Resume

2023-07-26 Thread duntan
Prepare MpService2Ppi in S3Resume when PEI and SMM env run
in the same execution mode. Then smm s3 code can use Mp
Service to wakeup AP instead of only sending InitSipiSipi.

Signed-off-by: Dun Tan 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c   | 18 +-
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf |  3 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c 
b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 9ea5f6f4e5..6574849939 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -4,7 +4,7 @@
   This module will execute the boot script saved during last boot and after 
that,
   control is passed to OS waking up handler.
 
-  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
   Copyright (c) 2017, AMD Incorporated. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -988,6 +989,7 @@ S3RestoreConfig2 (
   BOOLEANBuild4GPageTableOnly;
   BOOLEANInterruptStatus;
   IA32_CR0   Cr0;
+  EDKII_PEI_MP_SERVICES2_PPI *MpService2Ppi;
 
   TempAcpiS3Context = 0;
   TempEfiBootScriptExecutorVariable = 0;
@@ -1088,6 +1090,7 @@ S3RestoreConfig2 (
 SmmS3ResumeState->ReturnContext1 = 
(EFI_PHYSICAL_ADDRESS)(UINTN)AcpiS3Context;
 SmmS3ResumeState->ReturnContext2 = 
(EFI_PHYSICAL_ADDRESS)(UINTN)EfiBootScriptExecutorVariable;
 SmmS3ResumeState->ReturnStackPointer = 
(EFI_PHYSICAL_ADDRESS)STACK_ALIGN_DOWN ();
+SmmS3ResumeState->MpService2Ppi  = 0;
 
 DEBUG ((DEBUG_INFO, "SMM S3 Signature= %x\n", 
SmmS3ResumeState->Signature));
 DEBUG ((DEBUG_INFO, "SMM S3 Stack Base   = %x\n", 
SmmS3ResumeState->SmmS3StackBase));
@@ -1109,6 +1112,19 @@ S3RestoreConfig2 (
 if (((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) && (sizeof 
(UINTN) == sizeof (UINT32))) ||
 ((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) && (sizeof 
(UINTN) == sizeof (UINT64
 {
+  //
+  // Get MP Services2 Ppi to pass it to Smm S3.
+  //
+  Status = PeiServicesLocatePpi (
+ ,
+ 0,
+ NULL,
+ (VOID **)
+ );
+  ASSERT_EFI_ERROR (Status);
+  SmmS3ResumeState->MpService2Ppi = 
(EFI_PHYSICAL_ADDRESS)(UINTN)MpService2Ppi;
+  DEBUG ((DEBUG_INFO, "SMM S3 MpService2Ppi Point = %x\n", 
SmmS3ResumeState->MpService2Ppi));
+
   SwitchStack (
 
(SWITCH_STACK_ENTRY_POINT)(UINTN)SmmS3ResumeState->SmmS3ResumeEntryPoint,
 (VOID *)AcpiS3Context,
diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf 
b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
index aae984d138..9c9b6f3db3 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
@@ -5,7 +5,7 @@
 # This module will excute the boot script saved during last boot and after 
that,
 # control is passed to OS waking up handler.
 #
-# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2023, Intel Corporation. All rights reserved.
 # Copyright (c) 2017, AMD Incorporated. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -86,6 +86,7 @@
   gPeiPostScriptTablePpiGuid## SOMETIMES_PRODUCES
   gEfiEndOfPeiSignalPpiGuid ## SOMETIMES_PRODUCES
   gEfiPeiSmmCommunicationPpiGuid## SOMETIMES_CONSUMES
+  gEdkiiPeiMpServices2PpiGuid   ## SOMETIMES_CONSUMES
 
 [FeaturePcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE

2023-07-26 Thread duntan
Add MpService2Ppi field in SMM_S3_RESUME_STATE of
AcpiS3Context.h. It will be used to wakeup AP to do the CPU
initialization during smm s3 boot flow in following patches.
With this field, we can avoid sending InitSipiSipi to wakeup
AP.

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

diff --git a/MdeModulePkg/Include/Guid/AcpiS3Context.h 
b/MdeModulePkg/Include/Guid/AcpiS3Context.h
index 645496d191..b1c177e072 100644
--- a/MdeModulePkg/Include/Guid/AcpiS3Context.h
+++ b/MdeModulePkg/Include/Guid/AcpiS3Context.h
@@ -1,7 +1,7 @@
 /** @file
   Definitions for data structures used in S3 resume.
 
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -20,6 +20,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 typedef struct {
   UINT64  Signature;
   EFI_PHYSICAL_ADDRESSSmmS3ResumeEntryPoint;
+  EFI_PHYSICAL_ADDRESSMpService2Ppi;
   EFI_PHYSICAL_ADDRESSSmmS3StackBase;
   UINT64  SmmS3StackSize;
   UINT64  SmmS3Cr0;
-- 
2.31.1.windows.1



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




[edk2-devel] [PATCH 0/5] Use MpService2Ppi to wakeup CPU in Smm CpuS3

2023-07-26 Thread duntan
This patch set is to prepare MpService2Ppi in S3Resume when PEI and
SMM env run in the same execution mode, and use MpService2Ppi to
wakeup Cpu to do CPU initialization in Smm CpuS3 boot flow if
MpService2Ppi is not 0 in mSmmS3ResumeState.

Dun Tan (5):
  MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE
  UefiCpuPkg/S3Resume2Pei: prepare MpService2Ppi in S3Resume
  UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo
  UefiCpuPkg/PiSmmCpuDxe: code refinement for CpuS3.c
  UefiCpuPkg/PiSmmCpuDxe: use MpService2Ppi to wakeup AP in s3

 MdeModulePkg/Include/Guid/AcpiS3Context.h   |   3 ++-
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c   | 175 
+--
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c   |  25 
-
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf |   3 ++-
 4 files changed, 141 insertions(+), 65 deletions(-)

-- 
2.31.1.windows.1



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




Re: [edk2-devel] [PATCH] Silicon/Synopsys/DesignWare: DwEmacSnpDxe: Fix bug in EmacGetDmaStatus

2023-07-26 Thread Pedro Falcato
On Wed, Jul 26, 2023 at 4:07 AM wangy  wrote:
>
> Hi Pedro Falcato,
>
> At 2023-07-25 16:45:01, "Pedro Falcato"  wrote:
>
> >On Tue, Jul 25, 2023 at 2:10 AM  wrote:
> >>
> >> From: Yang Wang 
> >>
> >> Check EmacGetDmaStatus input parameters
> >> IrqStat may be a null pointer.
> >>
> >> Signed-off-by: Yang Wang 
> >> ---
> >>  .../Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c  |  7 +--
> >>  .../Drivers/DwEmacSnpDxe/EmacDxeUtil.c   | 16 
> >>  .../Drivers/DwEmacSnpDxe/EmacDxeUtil.h   |  2 +-
> >>  3 files changed, 18 insertions(+), 7 deletions(-)
> >>
> >> diff --git 
> >> a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c 
> >> b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c
> >> index 4cb3371d79..6805511a1d 100755
> >> --- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c
> >> +++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c
> >> @@ -847,9 +847,12 @@ SnpGetStatus (
> >>}
> >>
> >>// Check DMA Irq status
> >> -  EmacGetDmaStatus (IrqStat, Snp->MacBase);
> >> +  Status = EmacGetDmaStatus (IrqStat, Snp->MacBase);
> >> +  if (EFI_ERROR(Status)) {
> >> +DEBUG ((DEBUG_ERROR, "%a: error  Status: %r\n", __func__, Status));
> >> +  }
> >>
> >> -  return EFI_SUCCESS;
> >> +  return Status;
> >>  }
> >>
> >>
> >> diff --git 
> >> a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c 
> >> b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
> >> index 3b982ce984..45b5a05f51 100755
> >> --- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
> >> +++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
> >> @@ -489,16 +489,22 @@ EmacDmaStart (
> >>  }
> >>
> >>
> >> -VOID
> >> +EFI_STATUS
> >>  EFIAPI
> >>  EmacGetDmaStatus (
> >>OUT  UINT32   *IrqStat  OPTIONAL,
> >>IN   UINTNMacBaseAddress
> >>)
> >>  {
> >> -  UINT32  DmaStatus;
> >> -  UINT32  ErrorBit;
> >> -  UINT32  Mask = 0;
> >> +  UINT32DmaStatus;
> >> +  UINT32ErrorBit;
> >> +  UINT32Mask = 0;
> >> +  EFI_STATUSStatus = EFI_SUCCESS;
> >> +
> >> +  if (IrqStat == NULL) {
> >> +Status = EFI_INVALID_PARAMETER;
> >> +goto EXIT;
> >> +  }
> >
> >This patch looks bogus to me. IrqStat is marked OPTIONAL, how can you
> >error out if it isn't provided?
>
> I foud in the MnpRecycleTxBuf(), it will pass NULL in 2nd parameter at code 
> of 'Status=Snp ->GetStatus (Snp, NULL, (VOID * *));'.
> then in EmacGetDmaStatus(), it will not check this pointer and use directly, 
> causig this problem (system hang). That's why I add above check.
>

The EFI_SIMPLE_NETWORK protocol, that SnpGetStatus implements, says:

> A pointer to the bit mask of the currently active interrupts (see “Related 
> Definitions”). If this is NULL, the interrupt status will not be read from 
> the device.
> If this is not NULL, the interrupt status will be read from the device. When 
> the interrupt status is read, it will also be cleared.
> Clearing the transmit interrupt does not empty the recycled transmit buffer 
> array.

So it seems to me that there's some missing logic in EmacGetDmaStatus.

I don't know this hardware, but I'll assume that writes to
DW_EMAC_DMAGRP_STATUS_OFST clear/ACK the corresponding interrupt
status bit.

I would suggest this (apologies for gmail line wrapping, hopefully you
get the idea):

diff --git a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
index 3b982ce98411..df4ce53e9e0b 100755
--- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
+++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
@@ -500,24 +500,29 @@ EmacGetDmaStatus (
  UINT32  ErrorBit;
  UINT32  Mask = 0;

+  if (IrqStat != NULL) {
+*IrqStat = 0;
+  }
+
  DmaStatus = MmioRead32 (MacBaseAddress +
   DW_EMAC_DMAGRP_STATUS_OFST);
  if (DmaStatus & DW_EMAC_DMAGRP_STATUS_NIS_SET_MSK) {
Mask |= DW_EMAC_DMAGRP_STATUS_NIS_SET_MSK;
// Rx interrupt
if (DmaStatus & DW_EMAC_DMAGRP_STATUS_RI_SET_MSK) {
-  *IrqStat |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;
-  Mask |= DW_EMAC_DMAGRP_STATUS_RI_SET_MSK;
-} else {
-  *IrqStat &= ~EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;
+  if (IrqStat != NULL) {
+*IrqStat |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;
+Mask |= DW_EMAC_DMAGRP_STATUS_RI_SET_MSK;
+  }
}
// Tx interrupt
if (DmaStatus & DW_EMAC_DMAGRP_STATUS_TI_SET_MSK) {
-  *IrqStat |= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;
-  Mask |= DW_EMAC_DMAGRP_STATUS_TI_SET_MSK;
-} else {
-  *IrqStat &= ~EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;
+  if (IrqStat != NULL) {
+*IrqStat |= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;
+Mask |= DW_EMAC_DMAGRP_STATUS_TI_SET_MSK;
+  }
}
+
// Tx Buffer
if (DmaStatus & DW_EMAC_DMAGRP_STATUS_TU_SET_MSK){
  Mask |= DW_EMAC_DMAGRP_STATUS_TU_SET_MSK;


It 

Re: [edk2-devel] [PATCH v1 0/3] Add support for handling SGI and pending interrupts

2023-07-26 Thread Kun Qin

Hi Ard,

Our current use case is around AP core suspension and wake-ups.

The program can suspend the secondary cores through PSCI interfaces 
(after powering

them on). BSP can then wake up the suspended cores through SGI on demand.

The pending interrupt manipulation is to support BSP suspension and 
wakeup. We

currently use watchdog timer to wake up suspended BSPs after a timeout.

Platforms can perform needed tasks during suspension, such as core power 
consumption

analysis, in UEFI environment.

Please let me if you have any suggestions.

Thanks,
Kun

On 7/26/2023 1:45 AM, Ard Biesheuvel wrote:

On Mon, 24 Jul 2023 at 22:15, Kun Qin  wrote:

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

This patch series introduce a few improvements related to interrupt
handling for ArmGic driver and library.

1. The current implementation of the `ArmGicSendSgiTo` is based on GIC v2
and does not work on GIC v3 and on.
2. The pending interrupt related primitives does not exist for end users.

The change added the SGI support compatible with GIC v3 and v4. A few
pending interrupt related utility functions were also added.

This change was tested on QEMU, FVP and proprietary hardware platforms.

Pathc v1 branch: https://github.com/kuqin12/edk2/tree/improve_gic_v1

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Cc: Sami Mujawar 

Kun Qin (3):
   ArmPkg: ArmGic: Added support to send SGI to NS G1 EL1
   ArmPkg: ArmGicLib: Added GIC v3 and v4 support to ArmGicSendSgiTo
   ArmPkg: ArmGic: Added functionalities to manipulate pending interrupts


Hello Kun,

Could you please explain how this will be used by platforms?

SGIs are only used by the MPcore SEC code, which is deprecated and
shouldn't be used. And manipulating pending interrupts is another
thing we should only support if there is a compelling use case.



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




Re: [edk2-devel] [PATCH] MinPlatformPkg: Remove IA32 in PeiFspWrapperPlatformLib

2023-07-26 Thread Isaac Oram
Pushed as 9131d63e08..41e8d638fa

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Isaac Oram
Sent: Wednesday, July 26, 2023 10:11 AM
To: Hsueh, DoraX ; devel@edk2.groups.io
Cc: Chiu, Chasel ; Desimone, Nathaniel L 
; Gao, Liming ; Dong, 
Eric ; Chuang, Rosen ; Kuo, Ted 

Subject: Re: [edk2-devel] [PATCH] MinPlatformPkg: Remove IA32 in 
PeiFspWrapperPlatformLib

Reviewed-by: Isaac Oram 

-Original Message-
From: Hsueh, DoraX  
Sent: Monday, July 24, 2023 3:43 AM
To: devel@edk2.groups.io
Cc: Hsueh, DoraX ; Chiu, Chasel ; 
Desimone, Nathaniel L ; Oram, Isaac W 
; Gao, Liming ; Dong, Eric 
; Chuang, Rosen ; Kuo, Ted 

Subject: [PATCH] MinPlatformPkg: Remove IA32 in PeiFspWrapperPlatformLib

From: DoraX Hsueh 

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

Remove IA32 only dependency, Because we need to support both IA32 and X64.
Apply to a modern platform supporting x64.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Isaac Oram 
Cc: Liming Gao 
Cc: Eric Dong 
Cc: Rosen Chuang 
Cc: Ted Kuo 
Signed-off-by: DoraX Hsueh 
---
 .../PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf
 
b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf
index dafd17dc..489b34cf 100644
--- 
a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf
+++ 
b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf
@@ -51,7 +51,7 @@
   IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec

   MinPlatformPkg/MinPlatformPkg.dec

 

-[LibraryClasses.IA32]

+[LibraryClasses]

   SiliconPolicyInitLib

   SiliconPolicyUpdateLib

   PeiServicesTablePointerLib

-- 
2.26.2.windows.1








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




Re: [edk2-devel] [PATCH] MinPlatformPkg: Remove IA32 in PeiFspWrapperPlatformLib

2023-07-26 Thread Isaac Oram
Reviewed-by: Isaac Oram 

-Original Message-
From: Hsueh, DoraX  
Sent: Monday, July 24, 2023 3:43 AM
To: devel@edk2.groups.io
Cc: Hsueh, DoraX ; Chiu, Chasel ; 
Desimone, Nathaniel L ; Oram, Isaac W 
; Gao, Liming ; Dong, Eric 
; Chuang, Rosen ; Kuo, Ted 

Subject: [PATCH] MinPlatformPkg: Remove IA32 in PeiFspWrapperPlatformLib

From: DoraX Hsueh 

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

Remove IA32 only dependency, Because we need to support both IA32 and X64.
Apply to a modern platform supporting x64.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Isaac Oram 
Cc: Liming Gao 
Cc: Eric Dong 
Cc: Rosen Chuang 
Cc: Ted Kuo 
Signed-off-by: DoraX Hsueh 
---
 .../PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf
 
b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf
index dafd17dc..489b34cf 100644
--- 
a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf
+++ 
b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf
@@ -51,7 +51,7 @@
   IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec

   MinPlatformPkg/MinPlatformPkg.dec

 

-[LibraryClasses.IA32]

+[LibraryClasses]

   SiliconPolicyInitLib

   SiliconPolicyUpdateLib

   PeiServicesTablePointerLib

-- 
2.26.2.windows.1



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




[edk2-devel] [edk2-libc Patch v2 1/1] edk2-libc/StdLib: Fix uninitialized global variable

2023-07-26 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4506

res_init() is called from different places in sockets library. It depends
on global _res variable containing a state.
The problem is that if __BIND_RES_TEXT macro is not defined, _res is not
initialized.
Depending on compiler and build optimization this can fill the
variable with garbage that is later used by res_init().
Fix is trivial - explicitly initialize _res.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Kloper Dimitry 
---
 StdLib/BsdSocketLib/res_init.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/StdLib/BsdSocketLib/res_init.c b/StdLib/BsdSocketLib/res_init.c
index 613a76a..9df7d4f 100644
--- a/StdLib/BsdSocketLib/res_init.c
+++ b/StdLib/BsdSocketLib/res_init.c
@@ -121,9 +121,11 @@ static u_int32_t net_mask __P((struct in_addr));
  */
 
 struct __res_state _res
-# if defined(__BIND_RES_TEXT)
+#if defined(__BIND_RES_TEXT)
 = { RES_TIMEOUT, }  /* Motorola, et al. */
-# endif
+#else
+= {0}
+#endif
 ;
 
 
-- 
2.40.0.windows.1



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




[edk2-devel] [edk2-libc Patch v2 0/1] edk2-libc:Fix uninitialized global variable

2023-07-26 Thread Jayaprakash, N
This patch contains a fix for the uninitialized global variable 
in edk2-libc/StdLib/BsdSocketLib/res_init.c

Jayaprakash N (1):
  edk2-libc/StdLib: Fix uninitialized global variable

 StdLib/BsdSocketLib/res_init.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.40.0.windows.1



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




Re: [edk2-devel] [PATCH] MinPlatformPkg: Remove IA32 in PeiFspWrapperPlatformLib

2023-07-26 Thread Chiu, Chasel


Reviewed-by: Chasel Chiu 

Thanks,
Chasel



> -Original Message-
> From: Hsueh, DoraX 
> Sent: Monday, July 24, 2023 2:43 AM
> To: devel@edk2.groups.io
> Cc: Hsueh, DoraX ; Chiu, Chasel
> ; Desimone, Nathaniel L
> ; Oram, Isaac W ;
> Gao, Liming ; Dong, Eric ;
> Chuang, Rosen ; Kuo, Ted 
> Subject: [PATCH] MinPlatformPkg: Remove IA32 in PeiFspWrapperPlatformLib
> 
> From: DoraX Hsueh 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4508
> 
> Remove IA32 only dependency, Because we need to support both IA32 and X64.
> Apply to a modern platform supporting x64.
> 
> Cc: Chasel Chiu 
> Cc: Nate DeSimone 
> Cc: Isaac Oram 
> Cc: Liming Gao 
> Cc: Eric Dong 
> Cc: Rosen Chuang 
> Cc: Ted Kuo 
> Signed-off-by: DoraX Hsueh 
> ---
>  .../PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf   | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git
> a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib
> /PeiFspWrapperPlatformLib.inf
> b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib
> /PeiFspWrapperPlatformLib.inf
> index dafd17dc..489b34cf 100644
> ---
> a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib
> /PeiFspWrapperPlatformLib.inf
> +++
> b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib
> /PeiFspWrapperPlatformLib.inf
> @@ -51,7 +51,7 @@
>IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
> 
>MinPlatformPkg/MinPlatformPkg.dec
> 
> 
> 
> -[LibraryClasses.IA32]
> 
> +[LibraryClasses]
> 
>SiliconPolicyInitLib
> 
>SiliconPolicyUpdateLib
> 
>PeiServicesTablePointerLib
> 
> --
> 2.26.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107271): https://edk2.groups.io/g/devel/message/107271
Mute This Topic: https://groups.io/mt/100333272/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] UefiCpuPkg: Decouple the SEV-ES functionality.

2023-07-26 Thread Lendacky, Thomas via groups.io

On 7/26/23 02:51, YuanhaoXie wrote:

The purpose is to fix an issue where an exception occurs at the start
of the DXE phase by applying the following patch series on INTEL-based
systems.

UefiCpuPkg: Refactor the logic for placing APs in HltLoop.
UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop.
UefiCpuPkg: Create MpHandOff.
UefiCpuPkg: ApWakeupFunction directly use CpuMpData.
UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI sequence.

This series of patches makes changes to the way the APs are
initialized and woken up. It removes the 2nd time INIT-SIPI-SIPI and
introduces a special startup signal to wake up APs. These patches also
create a new HOB identified by the mMpHandOffGuid, which stores only the
  minimum information required from the PEI phase to the DXE phase.
As a result, the original HOB (mCpuInitMpLibHobGuid) is now used only
as a global variable in the PEI phase and is no longer necessary in the
DXE phase for INTEL-based systems. The AMD SEV-ES related code
still relies on the OldCpuMpData in the DXE phase.

This patch decouple the SEV-ES functionality of assigning CpuMpData to
OldCpuMpData->NewCpuMpData from the Intel logic.

Cc: Eric Dong 
Cc: Rahul Kumar 
Cc: Tom Lendacky 
Cc: Ray Ni 
Signed-off-by: Yuanhao Xie 
---
  UefiCpuPkg/Library/MpInitLib/MpLib.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 737e03ffc5..e7054adbcc 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -2160,7 +2160,10 @@ MpInitLibInitialize (
  // APs have been wakeup before, just get the CPU Information
  // from HOB
  //
-AmdSevUpdateCpuMpData (CpuMpData);
+if (CpuMpData->UseSevEsAPMethod) {
+  AmdSevUpdateCpuMpData (CpuMpData);
+}


This looks fine. Applying this patch did not regress SEV-ES or SEV-SNP 
guest boots.


Reviewed-by: Tom Lendacky 

Thanks,
Tom


+
  CpuMpData->CpuCount  = MpHandOff->CpuCount;
  CpuMpData->BspNumber = GetBspNumber (MpHandOff);
  CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;



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




Re: [edk2-devel] [PATCH edk2-non-osi 1/1] Qemu/Sbsa: Update TF-A binaries for Neoverse-V1 support

2023-07-26 Thread Marcin Juszkiewicz

W dniu 14.07.2023 o 15:03, Marcin Juszkiewicz via groups.io pisze:

Update the TF-A binaries to have Neoverse-V1 cpu support.

This support was merged into TF-A:

https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/21813

This allows SBSA Reference Platform to boot Linux on "neoverse-v1" cpu.

Signed-off-by: Marcin Juszkiewicz


Can someone review it?

Once merged I can add neoverse-v1 to QEMU tests.


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




Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix uninitialized global variable

2023-07-26 Thread Michael Brown

On 25/07/2023 17:07, Jayaprakash, N wrote:

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

res_init() is called from different places in sockets library. It depends
on global _res variable containing a state.

The problem is that if __BIND_RES_TEXT macro is not defined, _res is not
initialized. Depending on compiler and build optimization this can fill the
variable with garbage that is later used by res_init().

Fix is trivial - explicitly initialize _res.
  
  struct __res_state _res

-# if defined(__BIND_RES_TEXT)
+#if defined(__BIND_RES_TEXT)
  = { RES_TIMEOUT, }  /* Motorola, et al. */
-# endif
+#endif
+= {0}
+#endif
  ;


NAK.  This is very wrong.

Firstly, your patch introduces unnecessary whitespace changes and so is 
unnecessarily cumbersome to review.


Secondly, the patch creates an invalid "#if ... #endif ... #endif" 
combination.  I suspect that you meant to use "#else" in the middle.


Thirdly, and most importantly, the whole patch is entirely unnecessary. 
As a variable with static storage duration, if no explicit initializer 
is provided then the C language guarantees that the value will be 
initialized to zero anyway.


Thanks,

Michael



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




Re: [edk2-devel] [PATCH V1 1/1] UefiCpuPkg/ResetVector: Cache Disable should not be set by default in CR0

2023-07-26 Thread Ni, Ray
This patch is not right.

Intel SDM explicitly says the initial CR0 value is 6000_0010. CD bit is set.

So the ResetVector code that still sets CD bit should be good.

If you are facing NEM enable failure, can you change your NEM enable logic to 
explicitly clear CD bit instead of changing here?

Thanks,
Ray


> -Original Message-
> From: xueshengfeng 
> Sent: Wednesday, July 26, 2023 5:48 PM
> To: devel@edk2.groups.io; Dong, Eric ; Ni, Ray
> ; Kumar, Rahul R ;
> kra...@redhat.com; De, Debkumar ; West, Catharine
> 
> Cc: Wu, MingliangX ; Wu
> Subject: [PATCH V1 1/1] UefiCpuPkg/ResetVector: Cache Disable should not be
> set by default in CR0
> 
> From: "Wu, MingliangX" 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4511
> 
> With 64 bit build we are seeing the CD in control register CR 0 set.
> This causes the NEM to disabled for some specific bios profiles.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Cc: Debkumar De 
> Cc: Catharine West 
> Signed-off-by: Wu, Mingliang 
> ---
>  UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> index f59fc6ead4ba..4af2e875c31c 100644
> --- a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> +++ b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm
> @@ -7,7 +7,7 @@
>  ;
>  
> ;--
> 
> -%define SEC_DEFAULT_CR0  0x4023
> +%define SEC_DEFAULT_CR0  0x0023
>  %define SEC_DEFAULT_CR4  0x640
> 
>  BITS16
> --
> 2.26.2.windows.1
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107267): https://edk2.groups.io/g/devel/message/107267
Mute This Topic: https://groups.io/mt/100367559/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 v1 0/3] Add support for handling SGI and pending interrupts

2023-07-26 Thread Ard Biesheuvel
On Mon, 24 Jul 2023 at 22:15, Kun Qin  wrote:
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4466
>
> This patch series introduce a few improvements related to interrupt
> handling for ArmGic driver and library.
>
> 1. The current implementation of the `ArmGicSendSgiTo` is based on GIC v2
> and does not work on GIC v3 and on.
> 2. The pending interrupt related primitives does not exist for end users.
>
> The change added the SGI support compatible with GIC v3 and v4. A few
> pending interrupt related utility functions were also added.
>
> This change was tested on QEMU, FVP and proprietary hardware platforms.
>
> Pathc v1 branch: https://github.com/kuqin12/edk2/tree/improve_gic_v1
>
> Cc: Leif Lindholm 
> Cc: Ard Biesheuvel 
> Cc: Sami Mujawar 
>
> Kun Qin (3):
>   ArmPkg: ArmGic: Added support to send SGI to NS G1 EL1
>   ArmPkg: ArmGicLib: Added GIC v3 and v4 support to ArmGicSendSgiTo
>   ArmPkg: ArmGic: Added functionalities to manipulate pending interrupts
>

Hello Kun,

Could you please explain how this will be used by platforms?

SGIs are only used by the MPcore SEC code, which is deprecated and
shouldn't be used. And manipulating pending interrupts is another
thing we should only support if there is a compelling use case.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107266): https://edk2.groups.io/g/devel/message/107266
Mute This Topic: https://groups.io/mt/100337221/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] UefiCpuPkg: Decouple the SEV-ES functionality.

2023-07-26 Thread Ni, Ray
Reviewed-by: Ray Ni 

@Tom Lendacky, can you please comment?

> -Original Message-
> From: Xie, Yuanhao 
> Sent: Wednesday, July 26, 2023 3:51 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Kumar, Rahul R
> ; Tom Lendacky ; Ni,
> Ray ; Xie, Yuanhao 
> Subject: [Patch V3] UefiCpuPkg: Decouple the SEV-ES functionality.
> 
> The purpose is to fix an issue where an exception occurs at the start
> of the DXE phase by applying the following patch series on INTEL-based
> systems.
> 
> UefiCpuPkg: Refactor the logic for placing APs in HltLoop.
> UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop.
> UefiCpuPkg: Create MpHandOff.
> UefiCpuPkg: ApWakeupFunction directly use CpuMpData.
> UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI sequence.
> 
> This series of patches makes changes to the way the APs are
> initialized and woken up. It removes the 2nd time INIT-SIPI-SIPI and
> introduces a special startup signal to wake up APs. These patches also
> create a new HOB identified by the mMpHandOffGuid, which stores only the
>  minimum information required from the PEI phase to the DXE phase.
> As a result, the original HOB (mCpuInitMpLibHobGuid) is now used only
> as a global variable in the PEI phase and is no longer necessary in the
> DXE phase for INTEL-based systems. The AMD SEV-ES related code
> still relies on the OldCpuMpData in the DXE phase.
> 
> This patch decouple the SEV-ES functionality of assigning CpuMpData to
> OldCpuMpData->NewCpuMpData from the Intel logic.
> 
> Cc: Eric Dong 
> Cc: Rahul Kumar 
> Cc: Tom Lendacky 
> Cc: Ray Ni 
> Signed-off-by: Yuanhao Xie 
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 737e03ffc5..e7054adbcc 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -2160,7 +2160,10 @@ MpInitLibInitialize (
>  // APs have been wakeup before, just get the CPU Information
>  // from HOB
>  //
> -AmdSevUpdateCpuMpData (CpuMpData);
> +if (CpuMpData->UseSevEsAPMethod) {
> +  AmdSevUpdateCpuMpData (CpuMpData);
> +}
> +
>  CpuMpData->CpuCount  = MpHandOff->CpuCount;
>  CpuMpData->BspNumber = GetBspNumber (MpHandOff);
>  CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData-
> >CpuInfoInHob;
> --
> 2.36.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107265): https://edk2.groups.io/g/devel/message/107265
Mute This Topic: https://groups.io/mt/100366586/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] [Patch V3] UefiCpuPkg: Decouple the SEV-ES functionality.

2023-07-26 Thread Yuanhao Xie
The purpose is to fix an issue where an exception occurs at the start
of the DXE phase by applying the following patch series on INTEL-based
systems.

UefiCpuPkg: Refactor the logic for placing APs in HltLoop.
UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop.
UefiCpuPkg: Create MpHandOff.
UefiCpuPkg: ApWakeupFunction directly use CpuMpData.
UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI sequence.

This series of patches makes changes to the way the APs are
initialized and woken up. It removes the 2nd time INIT-SIPI-SIPI and
introduces a special startup signal to wake up APs. These patches also
create a new HOB identified by the mMpHandOffGuid, which stores only the
 minimum information required from the PEI phase to the DXE phase.
As a result, the original HOB (mCpuInitMpLibHobGuid) is now used only
as a global variable in the PEI phase and is no longer necessary in the
DXE phase for INTEL-based systems. The AMD SEV-ES related code
still relies on the OldCpuMpData in the DXE phase.

This patch decouple the SEV-ES functionality of assigning CpuMpData to
OldCpuMpData->NewCpuMpData from the Intel logic.

Cc: Eric Dong 
Cc: Rahul Kumar 
Cc: Tom Lendacky 
Cc: Ray Ni 
Signed-off-by: Yuanhao Xie 
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 737e03ffc5..e7054adbcc 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -2160,7 +2160,10 @@ MpInitLibInitialize (
 // APs have been wakeup before, just get the CPU Information
 // from HOB
 //
-AmdSevUpdateCpuMpData (CpuMpData);
+if (CpuMpData->UseSevEsAPMethod) {
+  AmdSevUpdateCpuMpData (CpuMpData);
+}
+
 CpuMpData->CpuCount  = MpHandOff->CpuCount;
 CpuMpData->BspNumber = GetBspNumber (MpHandOff);
 CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
-- 
2.36.1.windows.1



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




[edk2-devel] [Patch V2] UefiCpuPkg: Decouple the SEV-ES functionality.

2023-07-26 Thread Yuanhao Xie
The purpose is to fix an issue where an exception occurs at the start
of the DXE phase by applying the following patch series on INTEL-based
systems.

UefiCpuPkg: Refactor the logic for placing APs in HltLoop.
UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop.
UefiCpuPkg: Create MpHandOff.
UefiCpuPkg: ApWakeupFunction directly use CpuMpData.
UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI sequence.

This series of patches makes changes to the way the APs are
initialized and woken up. It removes the 2nd time INIT-SIPI-SIPI and
introduces a special startup signal to wake up APs. These patches also
create a new HOB identified by the mMpHandOffGuid, which stores only the
 minimum information required from the PEI phase to the DXE phase.
As a result, the original HOB (mCpuInitMpLibHobGuid) is now used only
as a global variable in the PEI phase and is no longer necessary in the
DXE phase for INTEL-based systems. The AMD SEV-ES related code
still relies on the OldCpuMpData in the DXE phase.

This patch decouple the SEV-ES functionality of assigning CpuMpData to
OldCpuMpData->NewCpuMpData from the Intel logic.

Cc: Eric Dong 
Cc: Rahul Kumar 
Cc: Tom Lendacky 
Cc: Ray Ni 
Signed-off-by: Yuanhao Xie 
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 737e03ffc5..3f3c7bf907 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -2160,7 +2160,10 @@ MpInitLibInitialize (
 // APs have been wakeup before, just get the CPU Information
 // from HOB
 //
-AmdSevUpdateCpuMpData (CpuMpData);
+if (CpuMpData->SevEsIsEnabled) {
+  AmdSevUpdateCpuMpData (CpuMpData);
+}
+
 CpuMpData->CpuCount  = MpHandOff->CpuCount;
 CpuMpData->BspNumber = GetBspNumber (MpHandOff);
 CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
-- 
2.36.1.windows.1



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




[edk2-devel] [PATCH] BaseTools: Add FMMT BinPipWrappers

2023-07-26 Thread Yuwei Chen
Cc: Rebecca Cran 
Cc: Liming Gao 
Cc: Bob Feng 
Signed-off-by: Yuwei Chen 
---
 BaseTools/BinPipWrappers/PosixLike/FMMT   | 12 
 BaseTools/BinPipWrappers/WindowsLike/FMMT.bat |  3 +++
 2 files changed, 15 insertions(+)
 create mode 100755 BaseTools/BinPipWrappers/PosixLike/FMMT
 create mode 100644 BaseTools/BinPipWrappers/WindowsLike/FMMT.bat

diff --git a/BaseTools/BinPipWrappers/PosixLike/FMMT 
b/BaseTools/BinPipWrappers/PosixLike/FMMT
new file mode 100755
index 00..9d143c7fc6
--- /dev/null
+++ b/BaseTools/BinPipWrappers/PosixLike/FMMT
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+
+# If a ${PYTHON_COMMAND} command is available, use it in preference to python
+if command -v ${PYTHON_COMMAND} >/dev/null 2>&1; then
+python_exe=${PYTHON_COMMAND}
+fi
+
+full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a 
discussion of why $0 is not a good choice here
+cmd=${full_cmd##*/}
+
+exec "${python_exe:-python}" -m edk2basetools.$cmd.$cmd "$@"
diff --git a/BaseTools/BinPipWrappers/WindowsLike/FMMT.bat 
b/BaseTools/BinPipWrappers/WindowsLike/FMMT.bat
new file mode 100644
index 00..d347d64844
--- /dev/null
+++ b/BaseTools/BinPipWrappers/WindowsLike/FMMT.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_COMMAND% -m edk2basetools.%ToolName%.%ToolName% %*
-- 
2.39.1.windows.1



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




[edk2-devel] [PATCH] UefiCpuPkg: Decouple the SEV-ES functionality.

2023-07-26 Thread Yuanhao Xie
The purpose is to fix an issue where an exception occurs at the start
of the DXE phase by applying the following patch series on INTEL-based
systems.

UefiCpuPkg: Refactor the logic for placing APs in HltLoop.
UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop.
UefiCpuPkg: Create MpHandOff.
UefiCpuPkg: ApWakeupFunction directly use CpuMpData.
UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI sequence.

This series of patches makes changes to the way the APs are
initialized and woken up. It removes the 2nd time INIT-SIPI-SIPI and
introduces a special startup signal to wake up APs. These patches also
create a new HOB identified by the mMpHandOffGuid, which stores only the
 minimum information required from the PEI phase to the DXE phase.
As a result, the original HOB (mCpuInitMpLibHobGuid) is now used only
as a global variable in the PEI phase and is no longer necessary in the
DXE phase for INTEL-based systems. The AMD SEV-ES related code
still relies on the OldCpuMpData in the DXE phase.

This patch decouple the SEV-ES functionality of assigning CpuMpData to
OldCpuMpData->NewCpuMpData from the Intel logic.

Cc: Eric Dong 
Cc: Rahul Kumar 
Cc: Tom Lendacky 
Cc: Ray Ni 
Signed-off-by: Yuanhao Xie 
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 737e03ffc5..4bb9f06edc 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -2160,7 +2160,9 @@ MpInitLibInitialize (
 // APs have been wakeup before, just get the CPU Information
 // from HOB
 //
-AmdSevUpdateCpuMpData (CpuMpData);
+if(CpuMpData->SevEsIsEnabled){
+  AmdSevUpdateCpuMpData (CpuMpData);
+}
 CpuMpData->CpuCount  = MpHandOff->CpuCount;
 CpuMpData->BspNumber = GetBspNumber (MpHandOff);
 CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
-- 
2.36.1.windows.1



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