[edk2-devel] [PATCH] [edk2-staging]BaseTools: Python VfrCompiler Tool Update

2023-12-07 Thread Yuwei Chen



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




Re: [edk2-devel] Question about the boundary and difference between System Firmware and UEFI CXL drivers

2023-12-07 Thread Yoshinoya
There is a description about UEFI Drivers in 1.4 Abbreviations in this doc.


UEFI Drivers : UEFI CXL Bus and memory device drivers.


I think UEFI CXL Drivers is a part of System Firmware(UEFI BIOS). 




These UEFI Drivers may do some basic configuation for some direct attached clx 
type-3 devices.







At 2023-12-06 15:13:00, "Yuquan Wang"  wrote:

Addition: [the link of  CXL Memory Device SW Guide]
https://cdrdv2-public.intel.com/643805/643805_CXL%20Memory%20Device%20SW%20Guide_Rev1p0.pdf


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112215): https://edk2.groups.io/g/devel/message/112215
Mute This Topic: https://groups.io/mt/103008846/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-07 Thread Andrei Warkentin
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.

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 
; 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 
mailto:tp...@ventanamicro.com>> wrote:


On Tue, May 30, 2023 at 10:38 AM Tuan Phan via groups.io 
mailto:ventanamicro@groups.io>> wrote:


On Mon, May 29, 2023 at 7:07 AM Ard Biesheuvel 
mailto:a...@kernel.org>> wrote:
On Sat, 27 May 2023 at 01:18, Tuan Phan 
mailto:tp...@ventanamicro.com>> 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 
> mailto:tp...@ventanamicro.com>>
> Reviewed-by: Andrei Warkentin 
> mailto:andrei.warken...@intel.com>>

> ---
>  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));
> +
>return EFI_SUCCESS;
>  }
> diff --git a/OvmfPkg/RiscVVirt/Sec/SecMain.inf 
> b/OvmfPkg/RiscVVirt/Sec/SecMain.inf
> index 0e2a5785e8a4..75d5b74b3d3f 100644
> --- a/OvmfPkg/RiscVVirt/Sec/SecMain.inf
> +++ b/OvmfPkg/RiscVVirt/Sec/SecMain.inf
> @@ -62,6 +62,7 

[edk2-devel] [PATCH] MdePkg: Define the DevicePath argument from LoadImage as optional

2023-12-07 Thread ManickamX Srinivasan
Define the DevicePath argument from LoadImage as optional as per
the UEFI 2.9A specification.

Reviewed-by: Zhiguang Liu 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: T V Krishnamoorthy 
Signed-off-by: ManickamX Srinivasan 
---
 MdePkg/Include/Uefi/UefiSpec.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h
index 7dfe35b499..e83e14d347 100644
--- a/MdePkg/Include/Uefi/UefiSpec.h
+++ b/MdePkg/Include/Uefi/UefiSpec.h
@@ -898,7 +898,7 @@ EFI_STATUS
 (EFIAPI *EFI_IMAGE_LOAD)(
   IN  BOOLEAN  BootPolicy,
   IN  EFI_HANDLE   ParentImageHandle,
-  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath   OPTIONAL,
   IN  VOID *SourceBuffer OPTIONAL,
   IN  UINTNSourceSize,
   OUT EFI_HANDLE   *ImageHandle
-- 
2.30.2.windows.1



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




Re: [edk2-devel] [PATCH] RedfishPkg/RedfishDicovery: Remedy Redfish service discovery flow

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

Hi Mike, below is my answer,

> -Original Message-
> From: Mike Maslenkin 
> Sent: Thursday, December 7, 2023 9:37 PM
> To: Chang, Abner 
> Cc: devel@edk2.groups.io; Nickle Wang ; Igor
> Kulchytskyy 
> Subject: Re: [PATCH] RedfishPkg/RedfishDicovery: Remedy Redfish service
> discovery flow
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Hi Abner,
>
> please see my comments below
>
> On Wed, Dec 6, 2023 at 6:06 PM  wrote:
> >
> > From: Abner Chang 
> >
> > Remedy Redfish service discovery flow changes made
> > in commit 8736b8fd.
> >
> > The above fix creates the dependency with SMBIOS 42h record,
> > which has a problem as SMBIOS 42h may not be created when
> > RedfishDiscovery.Supported() is invoked even all of the
> > required protocols are ready on the ControllerHandle. We can’t
> > guarantee SMBIOS 42 structure will be always created before
> > ConnectController(). USB NIC maybe detected late and it means
> > PlatformHostInterfaceBmcUsbNicLib can populate SMBIOS 42h
> > information late as well. Calling to
> > RedfishServiceGetNetworkInterface with the previous fix may
> > result in no network interface for BMC-exposed NIC as SMBIOS
> > 42h is not ready yet.This is the first issue.
> >
> > Second, to skip the network interface when
> > NetworkInterfaceGetSubnetInfo() returns a failure also has
> > problem, as the NIC may be configured via RestEx->Configure().
> > This happens after the Host interface is discovered, as at this
> > moment we have the sufficient network information to configure
> > BMC-exposed NIC.
> >
> > Base on Redfish spec in 31.1.5.2, “EFI Redfish Client may provide
> > selection UI of network interfaces for Redfish service discovery.",
> > This means edk2 Redfish client gets all network interfaces
> > through RedfishServiceGetNetworkInterface and choose the desired
> > network interface at its discretion for Redfish service.
> >
> > So the fix here is:
> > 1. In BuildNetworkInterface(), we don’t skip any network
> >interface. In RedfishServiceGetNetworkInterface, we don’t
> >skip any network interface even the subnet information is not
> >retrieved. We will still return all of network interfaces to
> >client.
> > 2. In RedfishServiceAcquireService for
> >EFI_REDFISH_RISCOVER_HOST_INTERFACE case, we don’t skip any
> >network interface even the subnet information is not
> >retrieved.
> >
> > 3. Added some more debug information.
> >
> > Note: The subnet information is used for the scenario the system
> > is managed by a centralized Redfish service (not on BMC), says
> > the multiple Redfish computer system instances. As it mentions
> > in 31.1.5.2, Redfish client they may have to know the subnet
> > information so they can know the network domain the NIC is
> > connected. There may have multiple subnets in the corporation
> > network environment. So the subnet information provides client
> > an idea when they choose the network interface, so does VLAN ID.
> >
> > Signed-off-by: Abner Chang 
> > Cc: Nickle Wang 
> > Cc: Igor Kulchytskyy 
> > Cc: Mike Maslenkin 
> > ---
> >  .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 105 ++
> >  1 file changed, 37 insertions(+), 68 deletions(-)
> >
> > diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > index 833ae2b969f..1cfcbcdc794 100644
> > --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > @@ -487,43 +487,6 @@ CheckIsIpVersion6 (
> >return FALSE;
> >  }
> >
> > -/**
> > -  This function returns the  IP type supported by the Host Interface.
> > -
> > -  @retval 00h is Unknown
> > -  01h is Ipv4
> > -  02h is Ipv6
> > -
> > -**/
> > -STATIC
> > -UINT8
> > -GetHiIpProtocolType (
> > -  VOID
> > -  )
> > -{
> > -  EFI_STATUS Status;
> > -  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
> > -  REDFISH_INTERFACE_DATA *DeviceDescriptor;
> > -
> > -  Data = NULL;
> > -  DeviceDescriptor = NULL;
> > -  if (mSmbios == NULL) {
> > -Status = gBS->LocateProtocol (, NULL, (VOID
> **));
> > -if (EFI_ERROR (Status)) {
> > -  return
> REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
> > -}
> > -  }
> > -
> > -  Status = RedfishGetHostInterfaceProtocolData (mSmbios,
> , ); // Search for SMBIOS type 42h
> > -  if (!EFI_ERROR (Status) && (Data != NULL) &&
> > -  (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic))
> > -  {
> > -return Data->HostIpAddressFormat;
> > -  }
> > -
> > -  return
> REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
> > -}
> > -
> >  /**
> >Check if Network Protocol Type matches with SMBIOS Type 42 IP Address
> Type.
> >
> > @@ -583,7 +546,10 @@ DiscoverRedfishHostInterface (
> >}
> >
> >Status = 

Re: [edk2-devel] [PATCH v3] MdePkg: Add a new memory type definition

2023-12-07 Thread Zhiguang Liu
Reviewed-by: Zhiguang Liu < zhiguang@intel.com >


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112211): https://edk2.groups.io/g/devel/message/112211
Mute This Topic: https://groups.io/mt/103050230/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] MdePkg: Define the DevicePath argument from LoadImage as optional

2023-12-07 Thread Zhiguang Liu
Reviewed-by: Zhiguang Liu 

> -Original Message-
> From: Srinivasan, ManickamX 
> Sent: Friday, December 8, 2023 1:41 PM
> To: devel@edk2.groups.io
> Cc: Srinivasan, ManickamX ; Kinney,
> Michael D ; Gao, Liming
> ; Liu, Zhiguang ; T V,
> Krishnamoorthy 
> Subject: [PATCH v2] MdePkg: Define the DevicePath argument from
> LoadImage as optional
> 
> Update the EFI LoadImage API in accordance with the UEFI v2.10
> specification.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Cc: T V Krishnamoorthy 
> Signed-off-by: ManickamX Srinivasan 
> ---
>  MdePkg/Include/Uefi/UefiSpec.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdePkg/Include/Uefi/UefiSpec.h
> b/MdePkg/Include/Uefi/UefiSpec.h index 7dfe35b499..e83e14d347 100644
> --- a/MdePkg/Include/Uefi/UefiSpec.h
> +++ b/MdePkg/Include/Uefi/UefiSpec.h
> @@ -898,7 +898,7 @@ EFI_STATUS
>  (EFIAPI *EFI_IMAGE_LOAD)(
>IN  BOOLEAN  BootPolicy,
>IN  EFI_HANDLE   ParentImageHandle,
> -  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath,
> +  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath   OPTIONAL,
>IN  VOID *SourceBuffer OPTIONAL,
>IN  UINTNSourceSize,
>OUT EFI_HANDLE   *ImageHandle
> --
> 2.30.2.windows.1



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




[edk2-devel] [PATCH v2] MdePkg: Define the DevicePath argument from LoadImage as optional

2023-12-07 Thread ManickamX Srinivasan
Update the EFI LoadImage API in accordance with the
UEFI v2.10 specification.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: T V Krishnamoorthy 
Signed-off-by: ManickamX Srinivasan 
---
 MdePkg/Include/Uefi/UefiSpec.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h
index 7dfe35b499..e83e14d347 100644
--- a/MdePkg/Include/Uefi/UefiSpec.h
+++ b/MdePkg/Include/Uefi/UefiSpec.h
@@ -898,7 +898,7 @@ EFI_STATUS
 (EFIAPI *EFI_IMAGE_LOAD)(
   IN  BOOLEAN  BootPolicy,
   IN  EFI_HANDLE   ParentImageHandle,
-  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath   OPTIONAL,
   IN  VOID *SourceBuffer OPTIONAL,
   IN  UINTNSourceSize,
   OUT EFI_HANDLE   *ImageHandle
-- 
2.30.2.windows.1



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




[edk2-devel] [PATCH v3] MdePkg: Add a new memory type definition

2023-12-07 Thread ManickamX Srinivasan
New memory type as defined in UEFI standard v2.10

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: T V Krishnamoorthy 
Signed-off-by: ManickamX Srinivasan 
---
 MdePkg/Include/Uefi/UefiSpec.h | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h
index 7dfe35b499..d583ee17d0 100644
--- a/MdePkg/Include/Uefi/UefiSpec.h
+++ b/MdePkg/Include/Uefi/UefiSpec.h
@@ -110,6 +110,21 @@ typedef enum {
 //
 #define EFI_MEMORY_RUNTIME  0x8000ULL
 
+//
+// If this flag is set, the memory region is
+// described with additional ISA-specific memory attributes 
+// as specified in EFI_MEMORY_ISA_MASK.
+//
+#define EFI_MEMORY_ISA_VALID 0x4000ULL
+
+//
+// Defines the bits reserved for describing optional ISA-specific cacheability 
+// attributes that are not covered by the standard UEFI Memory Attributes 
cacheability
+// bits (EFI_MEMORY_UC, EFI_MEMORY_WC, EFI_MEMORY_WT, EFI_MEMORY_WB and 
EFI_MEMORY_UCE).
+// See Calling Conventions for further ISA-specific enumeration of these bits.
+//
+#define EFI_MEMORY_ISA_MASK 0x0000ULL
+
 //
 // Attributes bitmasks, grouped by type
 //
-- 
2.30.2.windows.1



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




Re: [edk2-devel] [PATCH v9 4/5] MdePkg: Utilize Cache Management Operations Implementation For RISC-V

2023-12-07 Thread Sunil V L
On Thu, Dec 07, 2023 at 10:31:48AM +0530, Dhaval Sharma wrote:
> Comments inline:
> 
> 
> On Wed, Dec 6, 2023 at 7:50 PM Sunil V L  wrote:
> 
> > Hi Dhaval,
> >
> > Thank you very much for fixing the issue with instruction cache
> > invalidation and confirming with the spec owner. Few minor comments
> > below.
> >
> > On Mon, Dec 04, 2023 at 01:59:49PM +0530, Dhaval Sharma wrote:
> > > Use newly defined cache management operations for RISC-V where possible
> > > It builds up on the support added for RISC-V cache management
> > > instructions in BaseLib.
> > > Cc: Michael D Kinney 
> > > Cc: Liming Gao 
> > > Cc: Zhiguang Liu 
> > > Cc: Laszlo Ersek 
> > >
> > > Signed-off-by: Dhaval Sharma 
> > > Acked-by: Laszlo Ersek 
> > > ---
> > >
> > > Notes:
> > > V9:
> > > - Fixed an issue with Instruction cache invalidation. Use fence.i
> > >   instruction as CMO does not support i-cache operations.
> > > V8:
> > > - Added note to convert PCD into RISC-V feature bitmap pointer
> > > - Modified function names to be more explicit about cache ops
> > > - Added RB tag
> > > V7:
> > > - Added PcdLib
> > > - Restructure DEBUG message based on feedback on V6
> > > - Make naming consistent to CMO, remove all CBO references
> > > - Add ASSERT for not supported functions instead of plain debug
> > message
> > > - Added RB tag
> > > V6:
> > > - Utilize cache management instructions if HW supports it
> > >   This patch is part of restructuring on top of v5
> > >
> > IMO, it is better to keep the change log in the cover letter. Since not
> > all patches may be CC'd to every one apart from the cover letter, it is
> > difficult to understand from the cover letter what has changed in the new
> > series.
> >
> [Dhaval] AFAIU notes are tied to specific commits. But it makes sense, I
> can add an update to the cover letter.
> 
> >
> > >  MdePkg/MdePkg.dec  |
> >  8 +
> > >  MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf |
> >  5 +
> > >  MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c|
> > 173 
> > >  MdePkg/MdePkg.uni  |
> >  4 +
> > >  4 files changed, 160 insertions(+), 30 deletions(-)
> > >
> > > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
> > > index ac54338089e8..fa92673ff633 100644
> > > --- a/MdePkg/MdePkg.dec
> > > +++ b/MdePkg/MdePkg.dec
> > > @@ -2399,6 +2399,14 @@ [PcdsFixedAtBuild.AARCH64,
> > PcdsPatchableInModule.AARCH64]
> > ># @Prompt CPU Rng algorithm's GUID.
> > >
> > gEfiMdePkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm|{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}|VOID*|0x0037
> > >
> > > +[PcdsFixedAtBuild.RISCV64, PcdsPatchableInModule.RISCV64]
> > > +  #
> > > +  # Configurability to override RISC-V CPU Features
> > > +  # BIT 0 = Cache Management Operations. This bit is relevant only if
> > > +  # previous stage has feature enabled and user wants to disable it.
> > > +  #
> > > +
> > gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride|0x|UINT64|0x69
> > > +
> > >  [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
> > >## This value is used to set the base address of PCI express
> > hierarchy.
> > ># @Prompt PCI Express Base Address.
> > > diff --git
> > a/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> > b/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> > > index 6fd9cbe5f6c9..601a38d6c109 100644
> > > --- a/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> > > +++ b/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> > > @@ -56,3 +56,8 @@ [LibraryClasses]
> > >BaseLib
> > >DebugLib
> > >
> > > +[LibraryClasses.RISCV64]
> > > +  PcdLib
> > > +
> > > +[Pcd.RISCV64]
> > > +  gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride  ## CONSUMES
> > > diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > > index ac2a3c23a249..cacc38eff4f4 100644
> > > --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > > +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > > @@ -2,6 +2,7 @@
> > >RISC-V specific functionality for cache.
> > >
> > >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
> > >  **/
> > > @@ -9,10 +10,117 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > > +
> > > +//
> > > +// TODO: Grab cache block size and make Cache Management Operation
> > > +// enabling decision based on RISC-V CPU HOB in
> > > +// future when it is available and convert PcdRiscVFeatureOverride
> > > +// PCD to a pointer that contains pointer to bitmap structure
> > > +// 

Re: [edk2-devel] [PATCH v3 13/39] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg

2023-12-07 Thread Chao Li

Hi Ray,

Do you think this plan is OK? If possible, I will submit the V4 today.


Thanks,
Chao
On 2023/12/5 20:27, Chao Li wrote:


Hi Ray,

On 2023/12/5 16:27, Ni, Ray wrote:


Thanks,

Ray

*From:* devel@edk2.groups.io  *On Behalf Of 
*Chao Li

*Sent:* Monday, December 4, 2023 3:32 PM
*To:* devel@edk2.groups.io; Ni, Ray 
*Cc:* Dong, Eric ; Kumar, Rahul R 
; Gerd Hoffmann ; Leif 
Lindholm ; Ard Biesheuvel 
; Sami Mujawar ; 
Sunil V L ; Warkentin, Andrei 

*Subject:* Re: [edk2-devel] [PATCH v3 13/39] UefiCpuPkg: Add 
CpuMmuLib.h to UefiCpuPkg


Hi Ray,

For this patch, I checked again and here are my opinions:

 1. (Set|Get)MemoryRegionAttribute is difficult to merge together,
because the parameters between the tow APIs are not similar. So I
suggest they be independent.

[Ray] What I mean is to merge SetMemoryRegion(NonExec|ReadOly) to 
SetMemoryRegionAttribute(). Similarly, GetXXX can be merged as well. 
What’s your opinion?



Ok, I already said it in point 2, other APIs will be removed.


 2. The EfiAttributeConverse, GetMemoryRegionAttribute,
SetMemoryRegionAttributes and ConfigureMemoryManagementUnit will
be retained and other APIs will be removed. Because the functions
expressed by other APIs can be completed though the retained API.

[Ray] I didn’t notice EfiAttributeConverse(). I guess callers may not 
need to know the architectural specific attributes. So 
EfiAttributeConverse() might be not needed as a public API.



I agree, the EfiAttributeCoverse() complete by caller or as a private API.


 3. You pointed out MEMORY_REGION_DESCRIPTOR have no one to construct
it, do I need add a new API to construct it? Could it be named
GetMemoryMapPolicy and accept a parameter with
MEMORY_REGION_DESCRIPTOR** ?

[Ray] So the GetMemoryRegionAttribute() and 
SetMemoryRegionAttributes() are performed on the active translation 
table. ConfigureMemoryManagementUint() is to create a translation 
table with a list of memory attributes. How about the following idea?


[Ray] (Set|Get)MemoryRegionAttribute() are performed on a translation 
table buffer. And caller calls SetMemoryRegionAttribute() to modify 
the translation table buffer supplied as the parameter. With this, 
ConfigureMemoryManagementUnit() is not needed.


Ah, I think you may have some misunderstanding, the 
ConfigureMemoryManagementUint is a function that to initialize the 
MMU. The MEMORY_REGION_DESCRIPTOR will created by the private API, and 
then the caller will call the ConfigureMemoryManagementUnit to 
initialize the MMU first(may be fill the static page tables and so on).


But I thought about it again and it seems you are right, the 
ConfigureMemoryManagementUnit and discrptor creater as the public APIs 
are not appropriate. They are more suitable as some private APIs.


So, (Get|Set)MemoryRegionAttribute() will be the public APIs and the 
parameters will be the same with this change?



Hope to hear from you! :)

Thanks,
Chao

On 2023/11/30 10:25, Chao Li wrote:

Hi Ray,

Thanks for review, here are some of my thoughts:

On 2023/11/30 08:59, Ni, Ray wrote:

Chao,

Since the lib class is so general, I'd like to understand more details 
to make sure it can properly fit into any CPU arch.

In X86, cache setting is through MSRs and Page tables, and memory 
access control (read-only, not-present, non-executable) is through page tables.

Let me understand, 'cache setting' means does it access a certain
address(probably a memory address) via cache? If so, I'd say the
'cache setting' should be a part of attributes.

This CpuMmuLib is to provide both services. How does LoongArch64 manage 
the cache settings and memory access control?

Is it proper to combine both services into one lib?

In LoongArch64, cache settings and memory access control are
performed via page tables. Please check the patch 14 of this series.

If the backend silicon IP is the same one that supports the "one" lib 
design, can we refine the lib API a bit?

Yes, I think Attribute's instance family can be bear the memory
access and cache setting. So what are you suggestions if we
improve the lib API?

We have (Set|Get)MemoryRegionAttribute() and 
(Set|Clear)MemoryRegion(NoExec|ReadOnly). Can we merge them together?

Do you means the (Set|Get) merge together(differentiate Get or
Set operations by parameters)? If so, I think it's OK, but maybe
some existing instances will be modified together.

And the API ConfigureMemoryManagementUint() accepts 
MEMORY_REGION_DESCRIPTOR but none of other APIs helps to construct the 
descriptor.

Yes, currently, no one helps construct MEMORY_REGION_DESCRIPTOR.
I think the construction of descriptors is not part of the API,
it should be the localized or private when I design them. Do I
need to add an API to construct descripters?

It seems to me the MmuLib is simply a combination 

Re: [edk2-devel] [PATCH 00/37] OvmfPkg: remove the CSM (after edk2-stable202311)

2023-12-07 Thread Laszlo Ersek
On 11/11/23 00:57, Laszlo Ersek wrote:
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4588
> CI: https://github.com/tianocore/edk2/pull/5031 (@ 961d5add9f03)
> 
> Remove the Compatibility Support Module (CSM) from OVMF (after
> edk2-stable202311).
> 
> Modify the following platforms:
> 
>   OvmfPkg/AmdSev/AmdSevX64.dsc
>   OvmfPkg/Bhyve/BhyveX64.dsc
>   OvmfPkg/CloudHv/CloudHvX64.dsc
>   OvmfPkg/IntelTdx/IntelTdxX64.dsc
>   OvmfPkg/Microvm/MicrovmX64.dsc
>   OvmfPkg/OvmfPkgIa32.dsc
>   OvmfPkg/OvmfPkgIa32X64.dsc
>   OvmfPkg/OvmfPkgX64.dsc
>   OvmfPkg/OvmfXen.dsc
> 
> Each of those platforms builds at every stage of the series.
> 
> Follow a gradual approach. Peel off CSM components in (reverse)
> dependency order:
> 
> - exclude a high-level CSM component (library or driver) from the OVMF
>   platforms, without breaking dependencies of low-level components;
> 
> - delete the high-level component from OvmfPkg;
> 
> - add, to a removal queue, any source code artifacts (protocols, GUIDs,
>   headers, PCDs) that the high-level component's deletion
>   *unreferences*;
> 
> - delete all entries of the removal queue (protocols, GUIDs, headers,
>   PCDs) from the edk2 source tree that are now completely unreferenced
>   (... and extend the removal queue recursively, if needed);
> 
> - advance to the next component that now qualifies as "high-level"
>   (because nothing consumes the services it provides any longer), and
>   exclude that one.
> 
> Regression-test the traditional platforms as needed; see the notes in
> the following patches:
> 
> - OvmfPkg: remove PcdCsmEnable
> - OvmfPkg/IncompatiblePciDeviceSupportDxe: ignore CSM presence
> - OvmfPkg: exclude 8254TimerDxe
> 
> Cc: Anatol Belski 
> Cc: Andrei Warkentin 
> Cc: Anthony Perard 
> Cc: Ard Biesheuvel 
> Cc: Corvin Köhne 
> Cc: Erdem Aktas 
> Cc: Gerd Hoffmann 
> Cc: Jianyong Wu 
> Cc: Jiewen Yao 
> Cc: Michael Roth 
> Cc: Min Xu 
> Cc: Rebecca Cran 
> Cc: Sunil V L 
> Cc: Tom Lendacky 
> 
> Thanks
> Laszlo
> 
> Laszlo Ersek (37):
>   OvmfPkg: cripple CSM_ENABLE macro
>   OvmfPkg: remove PcdCsmEnable
>   OvmfPkg: unplug LegacyBootManagerLib from BdsDxe and UiApp
>   OvmfPkg: remove LegacyBootManagerLib
>   OvmfPkg: unplug LegacyBootMaintUiLib from UiApp
>   OvmfPkg: remove LegacyBootMaintUiLib
>   OvmfPkg: remove gEfiLegacyDevOrderVariableGuid
>   OvmfPkg: exclude the CSM-based VideoDxe driver
>   OvmfPkg: remove Csm/BiosThunk/VideoDxe
>   OvmfPkg: remove gEfiVgaMiniPortProtocolGuid
>   OvmfPkg: remove Bios Video PCDs
>   OvmfPkg: exclude LegacyBiosDxe
>   OvmfPkg/IncompatiblePciDeviceSupportDxe: ignore CSM presence
>   Revert "OvmfPkg: don't assign PCI BARs above 4GiB when CSM enabled"
>   OvmfPkg: remove LegacyBiosDxe
>   OvmfPkg: exclude NullMemoryTestDxe driver
>   OvmfPkg: remove gEfiIsaIoProtocolGuid
>   OvmfPkg: remove gEfiIsaAcpiProtocolGuid
>   OvmfPkg: remove gEfiLegacyBiosGuid
>   OvmfPkg: remove LegacyBiosDxe PCDs
>   OvmfPkg: unplug CsmSupportLib from BdsDxe
>   OvmfPkg: remove CsmSupportLib
>   OvmfPkg: remove gEfiFirmwareVolumeProtocolGuid
>   OvmfPkg: remove gEfiLegacyBiosPlatformProtocolGuid
>   OvmfPkg: remove gEfiLegacyBiosProtocolGuid
>   OvmfPkg: remove gEfiLegacyInterruptProtocolGuid
>   OvmfPkg: remove 
>   OvmfPkg: exclude Csm16.inf / Csm16.bin
>   OvmfPkg: remove Rule.Common.USER_DEFINED.CSM from all FDF files
>   OvmfPkg: remove Csm16
>   OvmfPkg: exclude 8254TimerDxe
>   OvmfPkg: remove 8254TimerDxe
>   OvmfPkg: exclude 8259InterruptControllerDxe
>   OvmfPkg: remove 8259InterruptControllerDxe
>   OvmfPkg: remove gEfiLegacy8259ProtocolGuid
>   OvmfPkg: remove Pcd8259LegacyModeEdgeLevel and Pcd8259LegacyModeMask
>   OvmfPkg: remove CSM_ENABLE build macro
> 
>  OvmfPkg/8254TimerDxe/8254Timer.inf   |   
> 43 -
>  OvmfPkg/8254TimerDxe/Timer.c |  
> 406 ---
>  OvmfPkg/8254TimerDxe/Timer.h |  
> 186 --
>  OvmfPkg/8254TimerDxe/Timer.uni   |   
> 16 -
>  OvmfPkg/8254TimerDxe/TimerExtra.uni  |   
> 14 -
>  OvmfPkg/8259InterruptControllerDxe/8259.c|  
> 622 
>  OvmfPkg/8259InterruptControllerDxe/8259.h|  
> 218 --
>  OvmfPkg/8259InterruptControllerDxe/8259.inf  |   
> 45 -
>  OvmfPkg/8259InterruptControllerDxe/Legacy8259.uni|   
> 16 -
>  OvmfPkg/8259InterruptControllerDxe/Legacy8259Extra.uni   |   
> 14 -
>  OvmfPkg/AmdSev/AmdSevX64.dsc |   
>  4 -
>  OvmfPkg/AmdSev/AmdSevX64.fdf |   
>  1 -
>  OvmfPkg/Bhyve/BhyveRfbDxe/GopDriver.c|   
>  2 -
>  OvmfPkg/Bhyve/BhyveX64.dsc   |   
> 24 +-
>  OvmfPkg/Bhyve/BhyveX64.fdf   

[edk2-devel] Tools and CI meeting moved to as needed basis + call for topics

2023-12-07 Thread Sean

The weekly Tools & CI meeting meeting is moving to an as needed basis.

There is a Github discussion item for each weeks meeting that will 
indicate the status and agenda.  If you have a topic please use the 
appropriate weeks discussion to raise it and the meeting will be 
confirmed as scheduled.  Otherwise meeting with no agenda will be 
cancelled.



Dec 11th meeting discussion here:

Tools and CI Meeting - Dec 11, 2023 · tianocore/edk2 · Discussion #5118 
(github.com) 



Thanks

Sean



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112204): https://edk2.groups.io/g/devel/message/112204
Mute This Topic: https://groups.io/mt/103039030/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 v2 1/1] OvmfPkg/Bhyve: use a proper PCI IO range

2023-12-07 Thread Ard Biesheuvel
On Mon, 20 Nov 2023 at 08:25, Corvin Köhne  wrote:
>
> Bhyve uses an io port range of [ 0x2000, 0x1 ] [1]. At the moment,
> EDKII is using a subset of this range [ 0xC000, 0x1 ] [2]. Even
> though the EDKII range doesn't exceed the bhyve range, it's causing
> issues on some guests like OpenBSD [3]. We don't know why it's causing
> issues yet. However, using the same IO port range in EDKII fixes the
> issue and is a good idea anyway.
>
> [1] 
> https://github.com/freebsd/freebsd-src/blob/82ea0132c8b17a7a6067c8a36c6434e587ede6de/usr.sbin/bhyve/pci_emul.c#L133-L134
> [2] 
> https://github.com/tianocore/edk2/blob/fb044b7fe893a4545995bfe2701fd38e593355d9/OvmfPkg/Bhyve/PlatformPei/Platform.c#L156-L157
> [3] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274389
>
> Signed-off-by: Corvin Köhne 
> Reviewed-by: Laszlo Ersek 
> Reviewed-by: Rebecca Cran 
> Cc: Ard Biesheuvel 
> Cc: Gerd Hoffmann 
> Cc: Liming Gao 
> Cc: Jiewen Yao 

Queued up as #5121 - thanks.

> ---
>  OvmfPkg/Bhyve/PlatformPei/Platform.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/OvmfPkg/Bhyve/PlatformPei/Platform.c 
> b/OvmfPkg/Bhyve/PlatformPei/Platform.c
> index f6d9a9038e12..bd1b22a9476e 100644
> --- a/OvmfPkg/Bhyve/PlatformPei/Platform.c
> +++ b/OvmfPkg/Bhyve/PlatformPei/Platform.c
> @@ -153,8 +153,8 @@ MemMapInitialization (
>UINT64 PciIoSize;
>RETURN_STATUS  PcdStatus;
>
> -  PciIoBase = 0xC000;
> -  PciIoSize = 0x4000;
> +  PciIoBase = 0x2000;
> +  PciIoSize = 0xE000;
>
>//
>// Create Memory Type Information HOB
> --
> 2.42.0
>


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




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

2023-12-07 Thread Ard Biesheuvel
Hi Gerd,

On Thu, 7 Dec 2023 at 10:44, Gerd Hoffmann  wrote:
>
> 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 

This seems like a good idea to me, and the change looks generally
fine, except for one nit below:

> ---
>  OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c | 82 +--
>  1 file changed, 77 insertions(+), 5 deletions(-)
>
> diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c 
> b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> index 5ee98e9b595a..1bfb14495abd 100644
> --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
> @@ -185,11 +185,16 @@ 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;
> +  AUTHENTICATED_VARIABLE_HEADER  *VarHeader;
> +  UINTN  VarSize;
> +  CHAR16 *VarName;
> +  CHAR8  *VarState;
> +  UINTN  VariableStoreLength;
> +  UINTN  FvLength;
>
>FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Instance->RegionBaseAddress;
>
> @@ -260,6 +265,73 @@ ValidateFvHeader (
>  return EFI_NOT_FOUND;
>}
>
> +  // check variables
> +  DEBUG ((DEBUG_INFO, "%a: checking variables\n", __func__));
> +  VarOffset = sizeof (*VariableStoreHeader);
> +  while (VarOffset + sizeof (*VarHeader) < VariableStoreHeader->Size) {
> +VarHeader = (VOID *)((UINTN)VariableStoreHeader + VarOffset);
> +if (VarHeader->StartId != 0x55aa) {
> +  DEBUG ((DEBUG_INFO, "%a: end of var list\n", __func__));
> +  break;
> +}
> +
> +VarSize = sizeof (*VarHeader) + VarHeader->NameSize + 
> VarHeader->DataSize;
> +if (VarOffset + VarSize > VariableStoreHeader->Size) {
> +  DEBUG ((
> +DEBUG_ERROR,
> +"%a: invalid variable size: 0x%x + 0x%x + 0x%x + 0x%x > 0x%x\n",
> +__func__,
> +VarOffset,
> +sizeof (*VarHeader),
> +VarHeader->NameSize,
> +VarHeader->DataSize,
> +VariableStoreHeader->Size
> +));
> +  return EFI_NOT_FOUND;
> +}
> +
> +VarName = (VOID *)((UINTN)VariableStoreHeader + VarOffset
> +   + sizeof (*VarHeader));
> +switch (VarHeader->State) {
> +  case VAR_HEADER_VALID_ONLY:
> +VarState = "header-ok";
> +VarName  = L"";
> +break;
> +  case VAR_ADDED:
> +VarState = "ok";
> +break;
> +  case VAR_ADDED _IN_DELETED_TRANSITION:

This looks odd, so please add a comment explaining why these constants
are constructed this way.


> +VarState = "del-in-transition";
> +break;
> +  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;
> +}
> +
> +DEBUG ((
> +  DEBUG_VERBOSE,
> +  "%a: +0x%04x: name=0x%x data=0x%x '%s' (%a)\n",
> +  __func__,
> +  VarOffset,
> +  VarHeader->NameSize,
> +  VarHeader->DataSize,
> +  VarName,
> +  VarState
> +  ));
> +
> +VarSize= (VarSize + 3) & ~3; // align
> +VarOffset += VarSize;
> +  }
> +
>return EFI_SUCCESS;
>  }
>
> --
> 2.43.0
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112202): https://edk2.groups.io/g/devel/message/112202
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]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 2/4] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters

2023-12-07 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Corrects the parameters of AmlCodeGenRdWordBusNumber() to
UINT16 to generate word bus number.

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Pierre Gondois 
---
 DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h   | 10 +-
 .../Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c | 10 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 5e340b94ce..eb8740692f 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -714,11 +714,11 @@ AmlCodeGenRdWordBusNumber (
   INBOOLEAN IsMinFixed,
   INBOOLEAN IsMaxFixed,
   INBOOLEAN IsPosDecode,
-  INUINT32 AddressGranularity,
-  INUINT32 AddressMinimum,
-  INUINT32 AddressMaximum,
-  INUINT32 AddressTranslation,
-  INUINT32 RangeLength,
+  INUINT16 AddressGranularity,
+  INUINT16 AddressMinimum,
+  INUINT16 AddressMaximum,
+  INUINT16 AddressTranslation,
+  INUINT16 RangeLength,
   INUINT8 ResourceSourceIndex,
   IN  CONST CHAR8 *ResourceSource,
   INAML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
diff --git 
a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 60fe69ba6d..46243f981c 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -848,11 +848,11 @@ AmlCodeGenRdWordBusNumber (
   INBOOLEAN IsMinFixed,
   INBOOLEAN IsMaxFixed,
   INBOOLEAN IsPosDecode,
-  INUINT32 AddressGranularity,
-  INUINT32 AddressMinimum,
-  INUINT32 AddressMaximum,
-  INUINT32 AddressTranslation,
-  INUINT32 RangeLength,
+  INUINT16 AddressGranularity,
+  INUINT16 AddressMinimum,
+  INUINT16 AddressMaximum,
+  INUINT16 AddressTranslation,
+  INUINT16 RangeLength,
   INUINT8 ResourceSourceIndex,
   IN  CONST CHAR8 *ResourceSource,
   INAML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
-- 
2.34.1



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




[edk2-devel] [PATCH v2 4/4] DynamicTablesPkg: Adds API to generate a method with ArgN

2023-12-07 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Adds an API to generate a method which invokes another
method with arguments.
This help to generate dynamic code to invoke another
method(might be in static ASL file) with build-in
argument parameters.

e.g:
Method (MET0, 6, Serialized)
{
\_SB.MET1 (Arg0, Arg1, Arg2, Arg3, Arg4, Arg5)
}

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
---
 .../Include/Library/AmlLib/AmlLib.h   |  46 ++
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 142 ++
 2 files changed, 188 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index eb8740692f..991a33fcf6 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -1693,4 +1693,50 @@ AmlAddNameStringToNamedPackage (
   IN AML_OBJECT_NODE_HANDLE  NamedNode
   );
 
+/** AML code generation for a method invoking another method
+with grguments.
+
+  AmlCodeGenMethodInvokeMethodArgN (
+"MET0", "MET1", 4, TRUE, 3, ParentNode, NewObjectNode
+);
+  is equivalent of the following ASL code:
+Method(MET0, 4, Serialized, 3) {
+  MET1 (Arg0, Arg1, Arg2, Arg3)
+}
+
+  @param [in]  MethodNameString   The new Method's name.
+  Must be a NULL-terminated ASL NameString
+  e.g.: "MET0", "_SB.MET0", etc.
+  The input string is copied.
+  @param [in]  InvokeMethodNameString The called/invoked method's name.
+  Must be a NULL-terminated ASL NameString
+  e.g.: "MET1", "_SB.MET1", etc.
+  The input string is copied.
+  @param [in]  NumArgsNumber of arguments.
+  Must be 0 <= NumArgs <= 6.
+  @param [in]  IsSerialized   TRUE is equivalent to Serialized.
+  FALSE is equivalent to NotSerialized.
+  Default is NotSerialized in ASL spec.
+  @param [in]  SyncLevel  Synchronization level for the method.
+  Must be 0 <= SyncLevel <= 15.
+  Default is 0 in ASL.
+  @param [in]  ParentNode If provided, set ParentNode as the parent
+  of the node created.
+  @param [out] NewObjectNode  If success, contains the created node.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenMethodInvokeMethodArgN (
+  IN  CONST CHAR8   *MethodNameString,
+  IN  CONST CHAR8   *InvokeMethodNameString,
+  INUINT8   NumArgs,
+  INBOOLEAN IsSerialized,
+  INUINT8   SyncLevel,
+  INAML_NODE_HANDLE ParentNode   OPTIONAL,
+  OUT   AML_OBJECT_NODE_HANDLE  *NewObjectNode   OPTIONAL
+  );
+
 #endif // AML_LIB_H_
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index a6db34fb97..89a4b48ec0 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -3849,3 +3849,145 @@ exit_handler:
 
   return Status;
 }
+
+/** AML code generation for a method invoking another method
+with grguments.
+
+  AmlCodeGenMethodInvokeMethodArgN (
+"MET0", "MET1", 4, TRUE, 3, ParentNode, NewObjectNode
+);
+  is equivalent of the following ASL code:
+Method(MET0, 4, Serialized, 3) {
+  MET1 (Arg0, Arg1, Arg2, Arg3)
+}
+
+  @param [in]  MethodNameString   The new Method's name.
+  Must be a NULL-terminated ASL NameString
+  e.g.: "MET0", "_SB.MET0", etc.
+  The input string is copied.
+  @param [in]  InvokeMethodNameString The called/invoked method's name.
+  Must be a NULL-terminated ASL NameString
+  e.g.: "MET1", "_SB.MET1", etc.
+  The input string is copied.
+  @param [in]  NumArgsNumber of arguments.
+  Must be 0 <= NumArgs <= 6.
+  @param [in]  IsSerialized   TRUE is equivalent to Serialized.
+  FALSE is equivalent to NotSerialized.
+  Default is NotSerialized in ASL spec.
+  @param [in]  SyncLevel  Synchronization level for the method.
+  Must be 0 <= SyncLevel <= 15.
+  Default is 0 in 

[edk2-devel] [PATCH v2 3/4] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION

2023-12-07 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Corrects the function pointer typedef AML_PARSE_FUNCTION,
otherwise some compiler like VS2019 gives error.

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Pierre Gondois 
---
 DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c 
b/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
index 8e584d4930..d3a51a94c7 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
@@ -100,8 +100,7 @@ AmlParseStream (
 **/
 typedef
 EFI_STATUS
-EFIAPI
-(*AML_PARSE_FUNCTION) (
+(EFIAPI *AML_PARSE_FUNCTION)(
   IN  CONST AML_NODE_HEADER   *Node,
   INAML_PARSE_FORMAT  ExpectedFormat,
   IN  OUT   AML_STREAM*FStream,
-- 
2.34.1



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




[edk2-devel] [PATCH v2 1/4] DynamicTablesPkg: AML Code generation for word I/O ranges

2023-12-07 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Add helper functions to generate AML resource data
for word I/O.

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Pierre Gondois 
---
 .../Include/Library/AmlLib/AmlLib.h   | 65 ++
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   | 88 +++
 2 files changed, 153 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 71e8539b30..5e340b94ce 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -2,6 +2,7 @@
   AML Lib.
 
   Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -724,6 +725,70 @@ AmlCodeGenRdWordBusNumber (
   OUT   AML_DATA_NODE_HANDLE*NewRdNode  OPTIONAL
   );
 
+/** Code generation for the "WordIO ()" ASL function.
+
+  The Resource Data effectively created is a Word Address Space Resource
+  Data. Cf ACPI 6.5:
+   - s6.4.3.5.3 "Word Address Space Descriptor".
+
+  The created resource data node can be:
+   - appended to the list of resource data elements of the NameOpNode.
+ In such case NameOpNode must be defined by a the "Name ()" ASL statement
+ and initially contain a "ResourceTemplate ()".
+   - returned through the NewRdNode parameter.
+
+  @param [in]  IsResourceConsumer   ResourceUsage parameter.
+  @param [in]  IsMinFixed   Minimum address is fixed.
+  @param [in]  IsMaxFixed   Maximum address is fixed.
+  @param [in]  IsPosDecode  Decode parameter
+  @param [in]  IsaRangesPossible values are:
+ 0-Reserved
+ 1-NonISAOnly
+ 2-ISAOnly
+ 3-EntireRange
+  @param [in]  AddressGranularity   Address granularity.
+  @param [in]  AddressMinimum   Minimum address.
+  @param [in]  AddressMaximum   Maximum address.
+  @param [in]  AddressTranslation   Address translation.
+  @param [in]  RangeLength  Range length.
+  @param [in]  ResourceSourceIndex  Resource Source index.
+Not supported. Must be 0.
+  @param [in]  ResourceSource   Resource Source.
+Not supported. Must be NULL.
+  @param [in]  IsDenseTranslation   TranslationDensity parameter.
+  @param [in]  IsTypeStatic TranslationType parameter.
+  @param [in]  NameOpNode   NameOp object node defining a named object.
+If provided, append the new resource data
+node to the list of resource data elements
+of this node.
+  @param [out] NewRdNodeIf provided and success,
+contain the created node.
+
+  @retval EFI_SUCCESS The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESCould not allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenRdWordIo (
+  INBOOLEAN IsResourceConsumer,
+  INBOOLEAN IsMinFixed,
+  INBOOLEAN IsMaxFixed,
+  INBOOLEAN IsPosDecode,
+  INUINT8 IsaRanges,
+  INUINT16 AddressGranularity,
+  INUINT16 AddressMinimum,
+  INUINT16 AddressMaximum,
+  INUINT16 AddressTranslation,
+  INUINT16 RangeLength,
+  INUINT8 ResourceSourceIndex,
+  IN  CONST CHAR8 *ResourceSource,
+  INBOOLEAN IsDenseTranslation,
+  INBOOLEAN IsTypeStatic,
+  INAML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
+  OUT   AML_DATA_NODE_HANDLE*NewRdNode  OPTIONAL
+  );
+
 /** Code generation for the "QWordIO ()" ASL function.
 
   The Resource Data effectively created is a QWord Address Space Resource
diff --git 
a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 0bc1c1d119..60fe69ba6d 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -2,6 +2,7 @@
   AML Resource Data Code Generation.
 
   Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -878,6 +879,93 @@ AmlCodeGenRdWordBusNumber (
);
 }
 
+/** Code generation for the "WordIO ()" ASL function.
+
+  The Resource Data effectively created is a Word Address Space Resource
+  Data. Cf ACPI 6.5:
+   - s6.4.3.5.3 "Word Address Space Descriptor".
+
+  The created resource data node can be:
+   - appended to the list of resource data 

[edk2-devel] [PATCH v2 0/4] DynamicTablesPkg: Updated word I/O

2023-12-07 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

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

Cc: Pierre Gondois 
Cc: Sami Mujawar 

Abdul Lateef Attar (4):
  DynamicTablesPkg: AML Code generation for word I/O ranges
  DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
  DynamicTablesPkg: Corrects function pointer typedef of
AML_PARSE_FUNCTION
  DynamicTablesPkg: Adds API to generate a method with ArgN

 .../Include/Library/AmlLib/AmlLib.h   | 121 ++-
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 142 ++
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   |  98 +++-
 .../Library/Common/AmlLib/Parser/AmlParser.c  |   3 +-
 4 files changed, 352 insertions(+), 12 deletions(-)

-- 
2.34.1



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




Re: [edk2-devel] [edk2-platforms][PATCH V1 5/5] Platform/ARM/N1Sdp: Enable FaultTolerantWrite Dxe driver for N1Sdp

2023-12-07 Thread Thomas Abraham


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of sahil via
> groups.io
> Sent: Thursday, November 16, 2023 11:46 AM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel ; Leif Lindholm
> ; Sami Mujawar ;
> Sahil Kaushal 
> Subject: [edk2-devel] [edk2-platforms][PATCH V1 5/5] Platform/ARM/N1Sdp:
> Enable FaultTolerantWrite Dxe driver for N1Sdp

Add a commit message.

> 
> Signed-off-by: sahil 
> ---
>  Platform/ARM/N1Sdp/N1SdpPlatform.dsc | 5 +
>  Platform/ARM/N1Sdp/N1SdpPlatform.fdf | 1 +
>  2 files changed, 6 insertions(+)
> 
> diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> index 10fe2db9e1b1..703829bbac99 100644
> --- a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> +++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> @@ -165,6 +165,10 @@
>gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x20
> 
> 
> 
># NOR flash support
> 
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x18F400
> 00
> 
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x0002000
> 0
> 
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x18F2
> 
> 
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x0002
> 
> 
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x18F
> 0
> 
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x0002000
> 0
> 
> 
> 
> @@ -227,6 +231,7 @@
> 
> NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.
> inf
> 
>BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
> 
>}
> 
> +  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
> 
> 
> 
># ACPI Support
> 
>MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
> 
> diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> index 4329f892f7c5..17d370a371cf 100644
> --- a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> +++ b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> @@ -90,6 +90,7 @@ READ_LOCK_STATUS   = TRUE
>INF MdeModulePkg/Universal/Metronome/Metronome.inf
> 
>INF
> MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.in
> f
> 
>INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
> 
> +  INF
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
> 
>INF
> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterR
> untimeDxe.inf
> 
>INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
> 
>INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> 
> --
> 2.25.1

With the commit message included,
Reviewed-by: Thomas Abraham 


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




Re: [edk2-devel] [edk2-platforms][PATCH V1 4/5] Platform/ARM/N1Sdp: Persistent storage for N1Sdp

2023-12-07 Thread Thomas Abraham


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of sahil via
> groups.io
> Sent: Thursday, November 16, 2023 11:46 AM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel ; Leif Lindholm
> ; Sami Mujawar ;
> Sahil Kaushal 
> Subject: [edk2-devel] [edk2-platforms][PATCH V1 4/5] Platform/ARM/N1Sdp:
> Persistent storage for N1Sdp
> 
> Enable persistent storage on QSPI flash device.
> 
> Signed-off-by: sahil 
> ---
>  Platform/ARM/N1Sdp/N1SdpPlatform.dsc | 20 ++--
>  Platform/ARM/N1Sdp/N1SdpPlatform.fdf |  4 +++-
>  2 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> index d04b22d3ef51..10fe2db9e1b1 100644
> --- a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> +++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> @@ -4,7 +4,7 @@
>  # This provides platform specific component descriptions and libraries that
> 
>  # conform to EFI/Framework standards.
> 
>  #
> 
> -# Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.
> 
> +# Copyright (c) 2018 - 2023, ARM Limited. All rights reserved.
> 
>  #
> 
>  # SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  #
> 
> @@ -44,6 +44,9 @@
># file explorer library support
> 
>FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
> 
> 
> 
> +  # NOR flash support
> 
> +  NorFlashInfoLib|EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.inf
> 
> +
> 
>  [LibraryClasses.common.SEC]
> 
>HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
> 
> 
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAll
> ocationLib.inf
> 
> @@ -161,11 +164,9 @@
># ACPI Table Version
> 
>gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x20
> 
> 
> 
> -  # Runtime Variable storage
> 
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
> 
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
> 
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
> 
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
> 
> +  # NOR flash support
> 
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x18F
> 0
> 
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x0002000
> 0
> 
> 
> 
> 
> 
> 
> 
>  #
> 
> @@ -197,6 +198,12 @@
>gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x800F
> 
>}
> 
> 
> 
> +  # NOR flash support
> 
> +  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiDxe.inf {
> 
> +  
> 
> +
> NorFlashPlatformLib|Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlas
> hLib.inf
> 
> +  }
> 
> +
> 
># Architectural Protocols
> 
>ArmPkg/Drivers/CpuDxe/CpuDxe.inf
> 
>ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
> 
> @@ -217,6 +224,7 @@
>MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
> 
>  
> 
>NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
> 
> +
> NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.
> inf
> 
>BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
> 
>}
> 
> 
> 
> diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> index e5e24ea50294..4329f892f7c5 100644
> --- a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> +++ b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> @@ -1,7 +1,7 @@
>  ## @file
> 
>  #  FDF file of N1Sdp
> 
>  #
> 
> -#  Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.
> 
> +#  Copyright (c) 2018 - 2023, ARM Limited. All rights reserved.
> 
>  #
> 
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  ##
> 
> @@ -140,6 +140,8 @@ READ_LOCK_STATUS   = TRUE
>INF ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf
> 
>INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
> 
> 
> 
> +  INF Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiDxe.inf
> 
> +
> 
>INF Platform/ARM/Drivers/BootMonFs/BootMonFs.inf
> 
>INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
> 
> 
> 
> --
> 2.25.1

Reviewed-by: Thomas Abraham 


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




Re: [edk2-devel] [edk2-platforms][PATCH V1 3/5] Platform/ARM/N1Sdp: NOR flash Dxe Driver for N1Sdp

2023-12-07 Thread Thomas Abraham


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of sahil via
> groups.io
> Sent: Thursday, November 16, 2023 11:46 AM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel ; Leif Lindholm
> ; Sami Mujawar ;
> Sahil Kaushal 
> Subject: [edk2-devel] [edk2-platforms][PATCH V1 3/5] Platform/ARM/N1Sdp:
> NOR flash Dxe Driver for N1Sdp
> 
> Add NOR flash DXE driver, this brings up NV storage on
> QSPI's flash device using FVB protocol.
> 
> Signed-off-by: sahil 
> ---
>  Platform/ARM/N1Sdp/N1SdpPlatform.dec |5 +-
>  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiDxe.inf |   72 ++
>  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiReg.h   |   33 +
>  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/NorFlash.h |  491
> +
>  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiDxe.c   |  409
> 
>  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/NorFlash.c | 1100
> 
>  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/NorFlashFvb.c  |  647
> 
>  7 files changed, 2756 insertions(+), 1 deletion(-)


Can this driver be moved to either the edk2-platform drivers/ or the 
Platform/Arm/Drivers directory?

Otherwise, looks okay.
Reviewed-by: Thomas Abraham 

[snip]


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




[edk2-devel] Now: TianoCore edk2-test Bug Triage Meeting - Thursday, December 7, 2023 #cal-notice

2023-12-07 Thread Group Notification
*TianoCore edk2-test Bug Triage Meeting*

*When:*
Thursday, December 7, 2023
10:00pm to 11:00pm
(UTC+08:00) Asia/Shanghai

*Where:*
https://armltd.zoom.us/j/94348061758?pwd=Q3RDeFA5K2JFaU5jdWUxc1FnaGdyUT09=addon

*Organizer:* Edhaya Chandran edhaya.chand...@arm.com ( 
edhaya.chand...@arm.com?subject=Re:%20Event:%20TianoCore%20edk2-test%20Bug%20Triage%20Meeting
 )

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

*Description:*


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




[edk2-devel] Event: TianoCore edk2-test Bug Triage Meeting - Thursday, December 7, 2023 #cal-reminder

2023-12-07 Thread Group Notification
*Reminder: TianoCore edk2-test Bug Triage Meeting*

*When:*
Thursday, December 7, 2023
10:00pm to 11:00pm
(UTC+08:00) Asia/Shanghai

*Where:*
https://armltd.zoom.us/j/94348061758?pwd=Q3RDeFA5K2JFaU5jdWUxc1FnaGdyUT09=addon

*Organizer:* Edhaya Chandran edhaya.chand...@arm.com ( 
edhaya.chand...@arm.com?subject=Re:%20Event:%20TianoCore%20edk2-test%20Bug%20Triage%20Meeting
 )

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

*Description:*


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




Re: [edk2-devel] [PATCH] RedfishPkg/RedfishDicovery: Remedy Redfish service discovery flow

2023-12-07 Thread Mike Maslenkin
Hi Abner,

please see my comments below

On Wed, Dec 6, 2023 at 6:06 PM  wrote:
>
> From: Abner Chang 
>
> Remedy Redfish service discovery flow changes made
> in commit 8736b8fd.
>
> The above fix creates the dependency with SMBIOS 42h record,
> which has a problem as SMBIOS 42h may not be created when
> RedfishDiscovery.Supported() is invoked even all of the
> required protocols are ready on the ControllerHandle. We can’t
> guarantee SMBIOS 42 structure will be always created before
> ConnectController(). USB NIC maybe detected late and it means
> PlatformHostInterfaceBmcUsbNicLib can populate SMBIOS 42h
> information late as well. Calling to
> RedfishServiceGetNetworkInterface with the previous fix may
> result in no network interface for BMC-exposed NIC as SMBIOS
> 42h is not ready yet.This is the first issue.
>
> Second, to skip the network interface when
> NetworkInterfaceGetSubnetInfo() returns a failure also has
> problem, as the NIC may be configured via RestEx->Configure().
> This happens after the Host interface is discovered, as at this
> moment we have the sufficient network information to configure
> BMC-exposed NIC.
>
> Base on Redfish spec in 31.1.5.2, “EFI Redfish Client may provide
> selection UI of network interfaces for Redfish service discovery.",
> This means edk2 Redfish client gets all network interfaces
> through RedfishServiceGetNetworkInterface and choose the desired
> network interface at its discretion for Redfish service.
>
> So the fix here is:
> 1. In BuildNetworkInterface(), we don’t skip any network
>interface. In RedfishServiceGetNetworkInterface, we don’t
>skip any network interface even the subnet information is not
>retrieved. We will still return all of network interfaces to
>client.
> 2. In RedfishServiceAcquireService for
>EFI_REDFISH_RISCOVER_HOST_INTERFACE case, we don’t skip any
>network interface even the subnet information is not
>retrieved.
>
> 3. Added some more debug information.
>
> Note: The subnet information is used for the scenario the system
> is managed by a centralized Redfish service (not on BMC), says
> the multiple Redfish computer system instances. As it mentions
> in 31.1.5.2, Redfish client they may have to know the subnet
> information so they can know the network domain the NIC is
> connected. There may have multiple subnets in the corporation
> network environment. So the subnet information provides client
> an idea when they choose the network interface, so does VLAN ID.
>
> Signed-off-by: Abner Chang 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> Cc: Mike Maslenkin 
> ---
>  .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 105 ++
>  1 file changed, 37 insertions(+), 68 deletions(-)
>
> diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
> b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> index 833ae2b969f..1cfcbcdc794 100644
> --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> @@ -487,43 +487,6 @@ CheckIsIpVersion6 (
>return FALSE;
>  }
>
> -/**
> -  This function returns the  IP type supported by the Host Interface.
> -
> -  @retval 00h is Unknown
> -  01h is Ipv4
> -  02h is Ipv6
> -
> -**/
> -STATIC
> -UINT8
> -GetHiIpProtocolType (
> -  VOID
> -  )
> -{
> -  EFI_STATUS Status;
> -  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
> -  REDFISH_INTERFACE_DATA *DeviceDescriptor;
> -
> -  Data = NULL;
> -  DeviceDescriptor = NULL;
> -  if (mSmbios == NULL) {
> -Status = gBS->LocateProtocol (, NULL, (VOID 
> **));
> -if (EFI_ERROR (Status)) {
> -  return REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
> -}
> -  }
> -
> -  Status = RedfishGetHostInterfaceProtocolData (mSmbios, , 
> ); // Search for SMBIOS type 42h
> -  if (!EFI_ERROR (Status) && (Data != NULL) &&
> -  (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic))
> -  {
> -return Data->HostIpAddressFormat;
> -  }
> -
> -  return REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
> -}
> -
>  /**
>Check if Network Protocol Type matches with SMBIOS Type 42 IP Address Type.
>
> @@ -583,7 +546,10 @@ DiscoverRedfishHostInterface (
>}
>
>Status = RedfishGetHostInterfaceProtocolData (mSmbios, , 
> ); // Search for SMBIOS type 42h
> -  if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
> +  if (EFI_ERROR (Status) || (Data == NULL) || (DeviceDescriptor == NULL)) {
> +DEBUG ((DEBUG_ERROR, "%a: RedfishGetHostInterfaceProtocolData is 
> failed.\n", __func__));
> +return Status;
> +  } else {
>  // Check IP Type and skip an unnecessary network protocol if does not 
> match
>  if (FilterProtocol (Instance->NetworkInterface->NetworkProtocolType, 
> Data->HostIpAddressFormat)) {
>return EFI_UNSUPPORTED;
> @@ -737,10 +703,7 @@ DiscoverRedfishHostInterface (
>   IsHttps
>   );
>  }
> -  } 

Re: [edk2-devel] [PATCH] RedfishPkg/RedfishDicovery: Remedy Redfish service discovery flow

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

Hi Igor, thanks for testing this at your end.

Abner

> -Original Message-
> From: Igor Kulchytskyy 
> Sent: Thursday, December 7, 2023 9:23 PM
> To: Chang, Abner ; devel@edk2.groups.io
> Cc: Nickle Wang ; Mike Maslenkin
> 
> Subject: RE: [EXTERNAL] [PATCH] RedfishPkg/RedfishDicovery: Remedy
> Redfish service discovery flow
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Reviewed-by: Igor Kulchytskyy 
> Regards,
> Igor
>
> -Original Message-
> From: abner.ch...@amd.com 
> Sent: Wednesday, December 6, 2023 10:05 AM
> To: devel@edk2.groups.io
> Cc: Nickle Wang ; Igor Kulchytskyy ;
> Mike Maslenkin 
> Subject: [EXTERNAL] [PATCH] RedfishPkg/RedfishDicovery: Remedy Redfish
> service discovery flow
>
>
> **CAUTION: The e-mail below is from an external source. Please exercise
> caution before opening attachments, clicking links, or following guidance.**
>
> From: Abner Chang 
>
> Remedy Redfish service discovery flow changes made
> in commit 8736b8fd.
>
> The above fix creates the dependency with SMBIOS 42h record,
> which has a problem as SMBIOS 42h may not be created when
> RedfishDiscovery.Supported() is invoked even all of the
> required protocols are ready on the ControllerHandle. We can’t
> guarantee SMBIOS 42 structure will be always created before
> ConnectController(). USB NIC maybe detected late and it means
> PlatformHostInterfaceBmcUsbNicLib can populate SMBIOS 42h
> information late as well. Calling to
> RedfishServiceGetNetworkInterface with the previous fix may
> result in no network interface for BMC-exposed NIC as SMBIOS
> 42h is not ready yet.This is the first issue.
>
> Second, to skip the network interface when
> NetworkInterfaceGetSubnetInfo() returns a failure also has
> problem, as the NIC may be configured via RestEx->Configure().
> This happens after the Host interface is discovered, as at this
> moment we have the sufficient network information to configure
> BMC-exposed NIC.
>
> Base on Redfish spec in 31.1.5.2, “EFI Redfish Client may provide
> selection UI of network interfaces for Redfish service discovery.",
> This means edk2 Redfish client gets all network interfaces
> through RedfishServiceGetNetworkInterface and choose the desired
> network interface at its discretion for Redfish service.
>
> So the fix here is:
> 1. In BuildNetworkInterface(), we don’t skip any network
>interface. In RedfishServiceGetNetworkInterface, we don’t
>skip any network interface even the subnet information is not
>retrieved. We will still return all of network interfaces to
>client.
> 2. In RedfishServiceAcquireService for
>EFI_REDFISH_RISCOVER_HOST_INTERFACE case, we don’t skip any
>network interface even the subnet information is not
>retrieved.
>
> 3. Added some more debug information.
>
> Note: The subnet information is used for the scenario the system
> is managed by a centralized Redfish service (not on BMC), says
> the multiple Redfish computer system instances. As it mentions
> in 31.1.5.2, Redfish client they may have to know the subnet
> information so they can know the network domain the NIC is
> connected. There may have multiple subnets in the corporation
> network environment. So the subnet information provides client
> an idea when they choose the network interface, so does VLAN ID.
>
> Signed-off-by: Abner Chang 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> Cc: Mike Maslenkin 
> ---
>  .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 105 ++
>  1 file changed, 37 insertions(+), 68 deletions(-)
>
> diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> index 833ae2b969f..1cfcbcdc794 100644
> --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> @@ -487,43 +487,6 @@ CheckIsIpVersion6 (
>return FALSE;
>  }
>
> -/**
> -  This function returns the  IP type supported by the Host Interface.
> -
> -  @retval 00h is Unknown
> -  01h is Ipv4
> -  02h is Ipv6
> -
> -**/
> -STATIC
> -UINT8
> -GetHiIpProtocolType (
> -  VOID
> -  )
> -{
> -  EFI_STATUS Status;
> -  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
> -  REDFISH_INTERFACE_DATA *DeviceDescriptor;
> -
> -  Data = NULL;
> -  DeviceDescriptor = NULL;
> -  if (mSmbios == NULL) {
> -Status = gBS->LocateProtocol (, NULL, (VOID
> **));
> -if (EFI_ERROR (Status)) {
> -  return
> REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
> -}
> -  }
> -
> -  Status = RedfishGetHostInterfaceProtocolData (mSmbios,
> , ); // Search for SMBIOS type 42h
> -  if (!EFI_ERROR (Status) && (Data != NULL) &&
> -  (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic))
> -  {
> -return Data->HostIpAddressFormat;
> -  }
> -
> -  return
> 

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

2023-12-07 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   | 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);
+UnicodeSPrintAsciiFormat (DiscoveredInstance->Information.Location, 
AllocSize, "[%a]", IpAddress);
+  } else {
+DiscoveredInstance->Information.Location = (CHAR16 *)AllocatePool 
(AllocSize);
+AsciiStrToUnicodeStrS (IpAddress, 
DiscoveredInstance->Information.Location, AllocSize);
+  }
+
+  DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s\n", 
DiscoveredInstance->Information.Location));
 }
 
 if (Uuid != NULL) {
-- 
2.32.0 (Apple Git-132)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112189): https://edk2.groups.io/g/devel/message/112189
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]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] RedfishPkg/RedfishDicovery: Remedy Redfish service discovery flow

2023-12-07 Thread Igor Kulchytskyy via groups.io
Reviewed-by: Igor Kulchytskyy 
Regards,
Igor

-Original Message-
From: abner.ch...@amd.com 
Sent: Wednesday, December 6, 2023 10:05 AM
To: devel@edk2.groups.io
Cc: Nickle Wang ; Igor Kulchytskyy ; Mike 
Maslenkin 
Subject: [EXTERNAL] [PATCH] RedfishPkg/RedfishDicovery: Remedy Redfish service 
discovery flow


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

From: Abner Chang 

Remedy Redfish service discovery flow changes made
in commit 8736b8fd.

The above fix creates the dependency with SMBIOS 42h record,
which has a problem as SMBIOS 42h may not be created when
RedfishDiscovery.Supported() is invoked even all of the
required protocols are ready on the ControllerHandle. We can’t
guarantee SMBIOS 42 structure will be always created before
ConnectController(). USB NIC maybe detected late and it means
PlatformHostInterfaceBmcUsbNicLib can populate SMBIOS 42h
information late as well. Calling to
RedfishServiceGetNetworkInterface with the previous fix may
result in no network interface for BMC-exposed NIC as SMBIOS
42h is not ready yet.This is the first issue.

Second, to skip the network interface when
NetworkInterfaceGetSubnetInfo() returns a failure also has
problem, as the NIC may be configured via RestEx->Configure().
This happens after the Host interface is discovered, as at this
moment we have the sufficient network information to configure
BMC-exposed NIC.

Base on Redfish spec in 31.1.5.2, “EFI Redfish Client may provide
selection UI of network interfaces for Redfish service discovery.",
This means edk2 Redfish client gets all network interfaces
through RedfishServiceGetNetworkInterface and choose the desired
network interface at its discretion for Redfish service.

So the fix here is:
1. In BuildNetworkInterface(), we don’t skip any network
   interface. In RedfishServiceGetNetworkInterface, we don’t
   skip any network interface even the subnet information is not
   retrieved. We will still return all of network interfaces to
   client.
2. In RedfishServiceAcquireService for
   EFI_REDFISH_RISCOVER_HOST_INTERFACE case, we don’t skip any
   network interface even the subnet information is not
   retrieved.

3. Added some more debug information.

Note: The subnet information is used for the scenario the system
is managed by a centralized Redfish service (not on BMC), says
the multiple Redfish computer system instances. As it mentions
in 31.1.5.2, Redfish client they may have to know the subnet
information so they can know the network domain the NIC is
connected. There may have multiple subnets in the corporation
network environment. So the subnet information provides client
an idea when they choose the network interface, so does VLAN ID.

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

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 833ae2b969f..1cfcbcdc794 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -487,43 +487,6 @@ CheckIsIpVersion6 (
   return FALSE;
 }

-/**
-  This function returns the  IP type supported by the Host Interface.
-
-  @retval 00h is Unknown
-  01h is Ipv4
-  02h is Ipv6
-
-**/
-STATIC
-UINT8
-GetHiIpProtocolType (
-  VOID
-  )
-{
-  EFI_STATUS Status;
-  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
-  REDFISH_INTERFACE_DATA *DeviceDescriptor;
-
-  Data = NULL;
-  DeviceDescriptor = NULL;
-  if (mSmbios == NULL) {
-Status = gBS->LocateProtocol (, NULL, (VOID 
**));
-if (EFI_ERROR (Status)) {
-  return REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
-}
-  }
-
-  Status = RedfishGetHostInterfaceProtocolData (mSmbios, , 
); // Search for SMBIOS type 42h
-  if (!EFI_ERROR (Status) && (Data != NULL) &&
-  (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic))
-  {
-return Data->HostIpAddressFormat;
-  }
-
-  return REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
-}
-
 /**
   Check if Network Protocol Type matches with SMBIOS Type 42 IP Address Type.

@@ -583,7 +546,10 @@ DiscoverRedfishHostInterface (
   }

   Status = RedfishGetHostInterfaceProtocolData (mSmbios, , 
); // Search for SMBIOS type 42h
-  if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
+  if (EFI_ERROR (Status) || (Data == NULL) || (DeviceDescriptor == NULL)) {
+DEBUG ((DEBUG_ERROR, "%a: RedfishGetHostInterfaceProtocolData is 
failed.\n", __func__));
+return Status;
+  } else {
 // Check IP Type and skip an unnecessary network protocol if does not match
 if (FilterProtocol (Instance->NetworkInterface->NetworkProtocolType, 
Data->HostIpAddressFormat)) {
   

Re: [edk2-devel] CLANGDWARF OVMF hangs on start

2023-12-07 Thread Mike Beaton
>  - I have just replicated exactly the same issue from a clean, new
> checkout and build on Fedora 38 and clang 16 (Fedora 16.0.6-3.fc38).
>  - I then upgraded that same VM to Fedora 39 and clang 17 and ... I
> still get the same issue, including that it works again when switching
> to 140e4422b16482f0bcafdc20d42141434d450450~1 (then cleaning Conf/ and
> Build/, then `make clean`, `make` in BaseTools/, then retry, as for
> each re-test).

I assume we must all be talking about clean builds at each point, more
or less by definition. But for the avoidance of doubt the script I'm
using to fully rebuild at each commit (which is reproducing these
problems, on all versions listed above, and which matches what happens
on a clean checkout - for me) is:

```
#!/bin/bash
git submodule update --init
rm -rf Build
rm Conf/*
rm -rf Conf/.cache
rm Conf/.AutoGenIdFile.txt
cd BaseTools
make clean
make
cd ../OvmfPkg
./build.sh -a X64 -b NOOPT -t CLANGDWARF -D DEBUG_ON_SERIAL_PORT=1 || exit 1
./build.sh -a X64 -b NOOPT -t CLANGDWARF qemu -serial stdio
```


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




Re: [edk2-devel] CLANGDWARF OVMF hangs on start

2023-12-07 Thread Mike Beaton
> > Which clang version is this?
> >
> > It works for me, fedora 39 / clang 17, and I'm pretty sure I tested it
> > when creating the patch on a slightly older clang version (15 or 16).
>
> It is 14 ('Ubuntu clang version 14.0.0-1ubuntu1.1' on Ubuntu 22.04.3 LTS)
>
> Cheers,
> Mike

Strangely, given what you say:

 - I have just replicated exactly the same issue from a clean, new
checkout and build on Fedora 38 and clang 16 (Fedora 16.0.6-3.fc38).
 - I then upgraded that same VM to Fedora 39 and clang 17 and ... I
still get the same issue, including that it works again when switching
to 140e4422b16482f0bcafdc20d42141434d450450~1 (then cleaning Conf/ and
Build/, then `make clean`, `make` in BaseTools/, then retry, as for
each re-test).

Mike


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112186): https://edk2.groups.io/g/devel/message/112186
Mute This Topic: https://groups.io/mt/103030855/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-test v2 2/4] Rename files in HowToBuild to avoid spaces in filenames

2023-12-07 Thread G Edhaya Chandran
In keeping the consistency with existing file names, I think the names that you 
suggested is okay.
Thank you again.

Reviewed-by: G Edhaya Chandran 


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




Re: [edk2-devel] [edk2-platforms][PATCH V1 2/5] Silicon/ARM/NeoverseN1Soc: NOR flash library for N1Sdp

2023-12-07 Thread Thomas Abraham
Hi Sahil,

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of sahil via
> groups.io
> Sent: Thursday, November 16, 2023 11:46 AM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel ; Leif Lindholm
> ; Sami Mujawar ;
> Sahil Kaushal 
> Subject: [edk2-devel] [edk2-platforms][PATCH V1 2/5]
> Silicon/ARM/NeoverseN1Soc: NOR flash library for N1Sdp
> 
> Add NOR flash library, this library provides APIs for getting the list
> of NOR flash devices on the platform.
> 
> Signed-off-by: sahil 
> ---
>  Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.inf | 36
> ++
>  Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.c   | 52
> 
>  2 files changed, 88 insertions(+)
> 
> diff --git a/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.inf
> b/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.inf
> new file mode 100644
> index ..14f81125c4e1
> --- /dev/null
> +++ b/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.inf
> @@ -0,0 +1,36 @@
> +## @file
> 
> +#  NOR flash lib for ARM Neoverse N1 platform.
> 
> +#
> 
> +#  Copyright (c) 2023, ARM Limited. All rights reserved.
> 
> +#
> 
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +#
> 
> +##
> 
> +
> 
> +[Defines]
> 
> +  INF_VERSION= 0x0001001B
> 
> +  BASE_NAME  = NorFlashNeoverseN1SocLib
> 
> +  FILE_GUID  = 7006fcf1-a585-4272-92e3-b286b1dff5bb
> 
> +  MODULE_TYPE= DXE_DRIVER
> 
> +  VERSION_STRING = 1.0
> 
> +  LIBRARY_CLASS  = NorFlashPlatformLib
> 
> +
> 
> +[Sources.common]
> 
> +  NorFlashLib.c
> 
> +
> 
> +[Packages]
> 
> +  MdeModulePkg/MdeModulePkg.dec
> 
> +  MdePkg/MdePkg.dec
> 
> +  Platform/ARM/ARM.dec
> 
> +  Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
> 
> +
> 
> +[LibraryClasses]
> 
> +  BaseLib
> 
> +  DebugLib
> 
> +  IoLib
> 
> +
> 
> +[FixedPcd]
> 
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
> 
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
> 
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
> 
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
> 
> diff --git a/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.c
> b/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.c
> new file mode 100644
> index ..a508d7d77373
> --- /dev/null
> +++ b/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.c
> @@ -0,0 +1,52 @@
> +/** @file
> 
> +*  NOR flash lib for ARM Neoverse N1 platform
> 
> +*
> 
> +*  Copyright (c) 2023, ARM Limited. All rights reserved.
> 
> +*
> 
> +*  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +*
> 
> +**/
> 
> +
> 
> +#include 
> 
> +#include 
> 
> +#include 
> 
> +#include 
> 
> +#include 
> 
> +
> 
> +#define FW_ENV_REGION_BASE  FixedPcdGet32
> (PcdFlashNvStorageVariableBase)
> 
> +#define FW_ENV_REGION_SIZE  (FixedPcdGet32
> (PcdFlashNvStorageVariableSize) +   \
> 
> +  FixedPcdGet32 
> (PcdFlashNvStorageFtwWorkingSize) + \
> 
> +  FixedPcdGet32 
> (PcdFlashNvStorageFtwSpareSize))

Why is FtwWorkingSize and FtwSpareSize included in the calculation of the size? 
Are these not offsets inside a flash region?

> 
> +
> 
> +STATIC NOR_FLASH_DESCRIPTION  mNorFlashDevices[] = {
> 
> +  {
> 
> +/// Environment variable region
> 
> +NEOVERSEN1SOC_SCP_QSPI_AHB_BASE,///< device base
> 
> +FW_ENV_REGION_BASE, ///< region base
> 
> +FW_ENV_REGION_SIZE, ///< region size
> 
> +SIZE_4KB,   ///< block size
> 
> +  },
> 
> +};
> 
> +
> 
> +/**
> 
> +  Get NOR flash region info
> 
> +
> 
> +  @param[out]NorFlashDevicesNOR flash regions info.
> 
> +  @param[out]Count  number of flash instance.
> 
> +
> 
> +  @retvalEFI_SUCCESSSuccess.
> 
> +**/
> 
> +EFI_STATUS
> 
> +NorFlashPlatformGetDevices (
> 
> +  OUT NOR_FLASH_DESCRIPTION  **NorFlashDevices,
> 
> +  OUT UINT32 *Count
> 
> +  )
> 
> +{
> 
> +  if ((NorFlashDevices == NULL) || (Count == NULL)) {
> 
> +return EFI_INVALID_PARAMETER;
> 
> +  }
> 
> +
> 
> +  *NorFlashDevices = mNorFlashDevices;
> 
> +  *Count   = ARRAY_SIZE (mNorFlashDevices);
> 
> +  return EFI_SUCCESS;
> 
> +}
> 
> --
> 2.25.1



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




Re: [edk2-devel] CLANGDWARF OVMF hangs on start

2023-12-07 Thread Mike Beaton
> Which clang version is this?
>
> It works for me, fedora 39 / clang 17, and I'm pretty sure I tested it
> when creating the patch on a slightly older clang version (15 or 16).

It is 14 ('Ubuntu clang version 14.0.0-1ubuntu1.1' on Ubuntu 22.04.3 LTS)

Cheers,
Mike


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




[edk2-devel] [PATCH v2] MdePkg: Add a new memory type definition

2023-12-07 Thread ManickamX Srinivasan
New memory type as defined in UEFI standard v2.9.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: T V Krishnamoorthy 
Signed-off-by: ManickamX Srinivasan 
---
 MdePkg/Include/Uefi/UefiSpec.h | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h
index 08db17e674..d583ee17d0 100644
--- a/MdePkg/Include/Uefi/UefiSpec.h
+++ b/MdePkg/Include/Uefi/UefiSpec.h
@@ -110,6 +110,21 @@ typedef enum {
 //
 #define EFI_MEMORY_RUNTIME  0x8000ULL
 
+//
+// If this flag is set, the memory region is
+// described with additional ISA-specific memory attributes 
+// as specified in EFI_MEMORY_ISA_MASK.
+//
+#define EFI_MEMORY_ISA_VALID 0x4000ULL
+
+//
+// Defines the bits reserved for describing optional ISA-specific cacheability 
+// attributes that are not covered by the standard UEFI Memory Attributes 
cacheability
+// bits (EFI_MEMORY_UC, EFI_MEMORY_WC, EFI_MEMORY_WT, EFI_MEMORY_WB and 
EFI_MEMORY_UCE).
+// See Calling Conventions for further ISA-specific enumeration of these bits.
+//
+#define EFI_MEMORY_ISA_MASK 0x0000ULL
+
-- 
2.30.2.windows.1



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




Re: [edk2-devel] [edk2-platforms][PATCH V1 1/5] Silicon/ARM/NeoverseN1Soc: Enable SCP QSPI flash region

2023-12-07 Thread Thomas Abraham


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of sahil via
> groups.io
> Sent: Thursday, November 16, 2023 11:46 AM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel ; Leif Lindholm
> ; Sami Mujawar ;
> Sahil Kaushal 
> Subject: [edk2-devel] [edk2-platforms][PATCH V1 1/5]
> Silicon/ARM/NeoverseN1Soc: Enable SCP QSPI flash region
>
> Enable SCP QSPI flash region access by adding it in the PlatformLibMem
>
> Signed-off-by: sahil 
> ---
>  Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h  |  6 +-
>  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c | 10
> --
>  2 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
> b/Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
> index 097160c7e2d1..92b8c9c45775 100644
> --- a/Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
> +++ b/Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
> @@ -1,6 +1,6 @@
>  /** @file
>
>  *
>
> -* Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.
>
> +* Copyright (c) 2018 - 2023, ARM Limited. All rights reserved.
>
>  *
>
>  * SPDX-License-Identifier: BSD-2-Clause-Patent
>
>  *
>
> @@ -41,6 +41,10 @@
>  #define NEOVERSEN1SOC_EXP_PERIPH_BASE0   0x1C00
>
>  #define NEOVERSEN1SOC_EXP_PERIPH_BASE0_SZ0x130
>
>
>
> +// SCP QSPI flash device
>
> +#define NEOVERSEN1SOC_SCP_QSPI_AHB_BASE  0x1800
>
> +#define NEOVERSEN1SOC_SCP_QSPI_AHB_SZ0x200
>
> +
>
>  // Base address to a structure of type NEOVERSEN1SOC_PLAT_INFO which is
>
>  // pre-populated by a earlier boot stage
>
>  #define NEOVERSEN1SOC_PLAT_INFO_STRUCT_BASE
> (NEOVERSEN1SOC_NON_SECURE_SRAM_BASE + \
>
> diff --git a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c
> b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c
> index 9e8a1efc557d..eb099953fe29 100644
> --- a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c
> +++ b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c
> @@ -1,6 +1,6 @@
>  /** @file
>
>
>
> -  Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.
>
> +  Copyright (c) 2018 - 2023, ARM Limited. All rights reserved.
>
>
>
>SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
>
> @@ -13,7 +13,7 @@
>  #include 
>
>
>
>  // The total number of descriptors, including the final "end-of-table" 
> descriptor.
>
> -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 19
>
> +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 20
>
>
>
>  /**
>
>Returns the Virtual Memory Map of the platform.
>
> @@ -184,6 +184,12 @@ ArmPlatformGetVirtualMemoryMap (
>VirtualMemoryTable[Index].Length  =
> NEOVERSEN1SOC_EXP_PERIPH_BASE0_SZ;
>
>VirtualMemoryTable[Index].Attributes  =
> ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
>
>
>
> +  // SCP QSPI flash device
>
> +  VirtualMemoryTable[++Index].PhysicalBase  =
> NEOVERSEN1SOC_SCP_QSPI_AHB_BASE;
>
> +  VirtualMemoryTable[Index].VirtualBase =
> NEOVERSEN1SOC_SCP_QSPI_AHB_BASE;
>
> +  VirtualMemoryTable[Index].Length  =
> NEOVERSEN1SOC_SCP_QSPI_AHB_SZ;
>
> +  VirtualMemoryTable[Index].Attributes  =
> ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
>
> +
>
>if (PlatInfo->MultichipMode == 1) {
>
>  //Remote DDR (2GB)
>
>  VirtualMemoryTable[++Index].PhysicalBase  = PcdGet64
> (PcdExtMemorySpace) +
>

Reviewed-by: Thomas Abraham 
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112181): https://edk2.groups.io/g/devel/message/112181
Mute This Topic: https://groups.io/mt/102625033/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 V3 1/1] Platform/ARM/N1sdp: Add support to parse NT_FW_CONFIG

2023-12-07 Thread Thomas Abraham
Hi Sahil,

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of sahil via
> groups.io
> Sent: Wednesday, August 23, 2023 12:03 PM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel ; Leif Lindholm
> ; Sami Mujawar ; Sahil
> 
> Subject: [edk2-devel] [edk2-platforms][PATCH V3 1/1] Platform/ARM/N1sdp:
> Add support to parse NT_FW_CONFIG
>
> NT_FW_CONFIG DTB contains platform information passed by
> Tf-A boot stage.
> This information is used for Virtual memory map generation
> during PEI phase and passed on to DXE phase as a HOB, where
> it is used in ConfigurationManagerDxe.
>
> This patch adds a PEI to parse NT_FW_CONFIG and pass it to
> other PEI modules(as PPI) and DXE modules(as HOB).
>
> Signed-off-by: sahil 
> ---
>
> Notes:
> v3:
>  - Fixed code review comments
>  - Added a PEI to parse nt_fw_config
>
>  Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
> |   8 +-
>  Platform/ARM/N1Sdp/N1SdpPlatform.dsc 
>|
> 5 +-
>  Platform/ARM/N1Sdp/N1SdpPlatform.fdf 
>|
> 3 +-
>
> Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDxe/Config
> urationManagerDxe.inf |   6 +-
>  Platform/ARM/N1Sdp/Drivers/N1SdpNtFwConfigPei/NtFwConfigPei.inf
> |  41 ++
>  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
> |   8 +-
>  Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
> |  14 +--
>
> Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDxe/Config
> urationManager.c  |  24 ++--
>  Platform/ARM/N1Sdp/Drivers/N1SdpNtFwConfigPei/NtFwConfigPei.c
> | 133 
>  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.c
> |  12 +-
>  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c
> |  33 +++--
>  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/AArch64/Helper.S
> |   4 +-
>  12 files changed, 255 insertions(+), 36 deletions(-)
>
> diff --git a/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
> b/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
> index d59f25a5b915..7118da25dce0 100644
> --- a/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
> +++ b/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
> @@ -1,7 +1,7 @@
>  ## @file
>
>  #  Describes the entire platform configuration.
>
>  #
>
> -#  Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.
>
> +#  Copyright (c) 2018 - 2023, ARM Limited. All rights reserved.
>
>  #
>
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>
>  #
>
> @@ -22,6 +22,8 @@
>Include# Root include for the package
>
>
>
>  [Guids.common]
>
> +  # ARM NeoverseN1Soc Platform Info descriptor
>
> +  gArmNeoverseN1SocPlatformInfoDescriptorGuid = { 0x9fa16eb5, 0xce13,
> 0x4d37, { 0x96, 0xf0, 0x0a, 0xb5, 0xf1, 0xab, 0xff, 0x01 } }
>
>gArmNeoverseN1SocTokenSpaceGuid = { 0xab93eb78, 0x60d7, 0x4099, { 0xac,
> 0xeb, 0x6d, 0xb5, 0x02, 0x58, 0x7c, 0x24 } }
>
>
>
>  [PcdsFixedAtBuild]
>
> @@ -83,3 +85,7 @@
>
> gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieMmio32Translation|0x400
> |UINT64|0x004F
>
>
> gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieMmio64Translation|0x400
> |UINT64|0x0050
>
>
> gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieSegmentNumber|2|UINT3
> 2|0x0051
>
> +
>
> +[Ppis]
>
> +  gArmNeoverseN1SocPlatformInfoDescriptorPpiGuid = { 0x21D04AD4,
> 0x4D23, 0x426D, { 0x8D, 0x3E, 0x92, 0x23, 0x3E, 0xF4, 0xB9, 0x5E } }
>
> +  gArmNeoverseN1SocParameterPpiGuid = { 0x4DDD5A72, 0x31AD, 0x4B20, {
> 0x8F, 0x5F, 0xB3, 0xE8, 0x24, 0x6F, 0x80, 0x2B } }
>
> diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> index d04b22d3ef51..691d1af3c25c 100644
> --- a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> +++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
> @@ -4,7 +4,7 @@
>  # This provides platform specific component descriptions and libraries that
>
>  # conform to EFI/Framework standards.
>
>  #
>
> -# Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.
>
> +# Copyright (c) 2018 - 2023, ARM Limited. All rights reserved.
>
>  #
>
>  # SPDX-License-Identifier: BSD-2-Clause-Patent
>
>  #
>
> @@ -228,6 +228,9 @@
># Platform driver
>
>Platform/ARM/N1Sdp/Drivers/PlatformDxe/PlatformDxe.inf
>
>
>
> +  # PEI Phase modules
>
> +  Platform/ARM/N1Sdp/Drivers/N1SdpNtFwConfigPei/NtFwConfigPei.inf
>
> +
>
># Human Interface Support
>
>MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
>
>
>
> diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> index e5e24ea50294..baac8a3ef727 100644
> --- a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> +++ b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
> @@ -1,7 +1,7 @@
>  ## @file
>
>  #  FDF file of N1Sdp
>
>  #
>
> -#  Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.
>
> +#  Copyright (c) 2018 - 2023, ARM Limited. All rights reserved.
>
>  #
>
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>
>  ##
>
> @@ -195,6 +195,7 @@ READ_LOCK_STATUS   = TRUE
>INF 

[edk2-devel] [PATCH v2] ArmVirt: Allow memory attributes protocol to be disabled on first boot

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

Shim's PE loader uses the EFI memory attributes protocol in a way that
results in an immediate crash when invoking the loaded image, unless the
base and size of its executable segment are both aligned to 4k.

If this is not the case, it will strip the memory allocation of its
executable permissions, but fail to add them back for the executable
region, resulting in non-executable code. Unfortunately, the PE loader
does not even bother invoking the protocol in this case (as it notices
the misalignment), making it very hard for system firmware to work
around this by attempting to infer the intent of the caller.

So let's introduce a QEMU command line option to indicate that the
protocol should not be exposed at all on the first boot, which is when
the issue is triggered. (fbaa64.efi is broken but grubaa64.efi boots
fine)

  -fw_cfg opt/org.tianocore/UninstallMemAttrProtocolOnFirstBoot,string=y

Also introduce a fixed boolean PCD that sets the default.

Cc: Laszlo Ersek 
Cc: Gerd Hoffmann 
Cc: Oliver Steffen 
Cc: Alexander Graf 
Cc: Oliver Smith-Denny 
Cc: Taylor Beebe 
Cc: Peter Jones 
Cc: Leif Lindholm 
Link: https://gitlab.com/qemu-project/qemu/-/issues/1990
Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirtPkg.dec|  6 ++
 ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  7 ++
 ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c   | 85 

 3 files changed, 98 insertions(+)

diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
index 0f2d7873279f..c55978f75c19 100644
--- a/ArmVirtPkg/ArmVirtPkg.dec
+++ b/ArmVirtPkg/ArmVirtPkg.dec
@@ -68,3 +68,9 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
   # Cloud Hypervisor has no other way to pass Rsdp address to the guest except 
use a PCD.

   #

   gArmVirtTokenSpaceGuid.PcdCloudHvAcpiRsdpBaseAddress|0x0|UINT64|0x0005

+

+  ##

+  # Whether the EFI memory attribus protocol should be uninstalled before

+  # invoking the OS loader on the first boot. This may be needed to work around

+  # problematic builds of shim that use the protocol incorrectly.

+  
gArmVirtTokenSpaceGuid.PcdUninstallMemAttrProtocolOnFirstBoot|FALSE|BOOLEAN|0x0006

diff --git 
a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 997eb1a4429f..5d119af6a3b3 100644
--- a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -16,6 +16,7 @@ [Defines]
   MODULE_TYPE= DXE_DRIVER

   VERSION_STRING = 1.0

   LIBRARY_CLASS  = PlatformBootManagerLib|DXE_DRIVER

+  CONSTRUCTOR= PlatformBootManagerLibConstructor

 

 #

 # The following information is for reference only and not required by the 
build tools.

@@ -46,6 +47,7 @@ [LibraryClasses]
   PcdLib

   PlatformBmPrintScLib

   QemuBootOrderLib

+  QemuFwCfgSimpleParserLib

   QemuLoadImageLib

   ReportStatusCodeLib

   TpmPlatformHierarchyLib

@@ -55,6 +57,7 @@ [LibraryClasses]
   UefiRuntimeServicesTableLib

 

 [FixedPcd]

+  gArmVirtTokenSpaceGuid.PcdUninstallMemAttrProtocolOnFirstBoot

   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate

   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits

   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity

@@ -73,5 +76,9 @@ [Guids]
 [Protocols]

   gEfiFirmwareVolume2ProtocolGuid

   gEfiGraphicsOutputProtocolGuid

+  gEfiMemoryAttributeProtocolGuid

   gEfiPciRootBridgeIoProtocolGuid

   gVirtioDeviceProtocolGuid

+

+[Depex]

+  gEfiVariableArchProtocolGuid

diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c 
b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
index 85c01351b09d..5306d9ea0a05 100644
--- a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
@@ -16,6 +16,7 @@
 #include 

 #include 

 #include 

+#include 

 #include 

 #include 

 #include 

@@ -1274,3 +1275,87 @@ PlatformBootManagerUnableToBoot (
 EfiBootManagerBoot ();

   }

 }

+

+/**

+  Uninstall the EFI memory attribute protocol if it exists.

+**/

+STATIC

+VOID

+UninstallEfiMemoryAttributesProtocol (

+  VOID

+  )

+{

+  EFI_STATUS  Status;

+  EFI_HANDLE  Handle;

+  UINTN   Size;

+  VOID*MemoryAttributeProtocol;

+

+  Size   = sizeof (Handle);

+  Status = gBS->LocateHandle (

+  ByProtocol,

+  ,

+  NULL,

+  ,

+  

+  );

+

+  if (EFI_ERROR (Status)) {

+ASSERT (Status == EFI_NOT_FOUND);

+return;

+  }

+

+  Status = gBS->HandleProtocol (

+  Handle,

+  ,

+  

+  );

+  ASSERT_EFI_ERROR (Status);

+

+  Status = gBS->UninstallProtocolInterface (

+

[edk2-devel] [PATCH] MdePkg: Add a new memory type definition

2023-12-07 Thread ManickamX Srinivasan
New memory type as defined in UEFI standard v2.9.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: T V Krishnamoorthy 
Signed-off-by: ManickamX Srinivasan 
---
 MdePkg/Include/Uefi/UefiSpec.h | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h
index 08db17e674..d583ee17d0 100644
--- a/MdePkg/Include/Uefi/UefiSpec.h
+++ b/MdePkg/Include/Uefi/UefiSpec.h
@@ -110,6 +110,21 @@ typedef enum {
 //
 #define EFI_MEMORY_RUNTIME  0x8000ULL
 
+//
+// If this flag is set, the memory region is
+// described with additional ISA-specific memory attributes 
+// as specified in EFI_MEMORY_ISA_MASK.
+//
+#define EFI_MEMORY_ISA_VALID 0x4000ULL
+
+//
+// Defines the bits reserved for describing optional ISA-specific cacheability 
+// attributes that are not covered by the standard UEFI Memory Attributes 
cacheability
+// bits (EFI_MEMORY_UC, EFI_MEMORY_WC, EFI_MEMORY_WT, EFI_MEMORY_WB and 
EFI_MEMORY_UCE).
+// See Calling Conventions for further ISA-specific enumeration of these bits.
+//
+#define EFI_MEMORY_ISA_MASK 0x0000ULL
+
 //
 // Attributes bitmasks, grouped by type
 //
@@ -898,7 +913,7 @@ EFI_STATUS
 (EFIAPI *EFI_IMAGE_LOAD)(
   IN  BOOLEAN  BootPolicy,
   IN  EFI_HANDLE   ParentImageHandle,
-  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL,
+  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath,
   IN  VOID *SourceBuffer OPTIONAL,
   IN  UINTNSourceSize,
   OUT EFI_HANDLE   *ImageHandle
-- 
2.30.2.windows.1



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




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

2023-12-07 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/VirtNorFlashFvb.c | 82 +--
 1 file changed, 77 insertions(+), 5 deletions(-)

diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c 
b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
index 5ee98e9b595a..1bfb14495abd 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c
@@ -185,11 +185,16 @@ 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;
+  AUTHENTICATED_VARIABLE_HEADER  *VarHeader;
+  UINTN  VarSize;
+  CHAR16 *VarName;
+  CHAR8  *VarState;
+  UINTN  VariableStoreLength;
+  UINTN  FvLength;
 
   FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Instance->RegionBaseAddress;
 
@@ -260,6 +265,73 @@ ValidateFvHeader (
 return EFI_NOT_FOUND;
   }
 
+  // check variables
+  DEBUG ((DEBUG_INFO, "%a: checking variables\n", __func__));
+  VarOffset = sizeof (*VariableStoreHeader);
+  while (VarOffset + sizeof (*VarHeader) < VariableStoreHeader->Size) {
+VarHeader = (VOID *)((UINTN)VariableStoreHeader + VarOffset);
+if (VarHeader->StartId != 0x55aa) {
+  DEBUG ((DEBUG_INFO, "%a: end of var list\n", __func__));
+  break;
+}
+
+VarSize = sizeof (*VarHeader) + VarHeader->NameSize + VarHeader->DataSize;
+if (VarOffset + VarSize > VariableStoreHeader->Size) {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: invalid variable size: 0x%x + 0x%x + 0x%x + 0x%x > 0x%x\n",
+__func__,
+VarOffset,
+sizeof (*VarHeader),
+VarHeader->NameSize,
+VarHeader->DataSize,
+VariableStoreHeader->Size
+));
+  return EFI_NOT_FOUND;
+}
+
+VarName = (VOID *)((UINTN)VariableStoreHeader + VarOffset
+   + sizeof (*VarHeader));
+switch (VarHeader->State) {
+  case VAR_HEADER_VALID_ONLY:
+VarState = "header-ok";
+VarName  = L"";
+break;
+  case VAR_ADDED:
+VarState = "ok";
+break;
+  case VAR_ADDED _IN_DELETED_TRANSITION:
+VarState = "del-in-transition";
+break;
+  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;
+}
+
+DEBUG ((
+  DEBUG_VERBOSE,
+  "%a: +0x%04x: name=0x%x data=0x%x '%s' (%a)\n",
+  __func__,
+  VarOffset,
+  VarHeader->NameSize,
+  VarHeader->DataSize,
+  VarName,
+  VarState
+  ));
+
+VarSize= (VarSize + 3) & ~3; // align
+VarOffset += VarSize;
+  }
+
   return EFI_SUCCESS;
 }
 
-- 
2.43.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112177): https://edk2.groups.io/g/devel/message/112177
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 1/1] OvmfPkg/VirtNorFlashDxe: sanity-check variables

2023-12-07 Thread Gerd Hoffmann
  Hi,

> > +  default:
> > +DEBUG ((
> > +  DEBUG_ERROR,
> > +  "%a: invalid variable state: 0x%x\n",
> > +  __func__,
> > +  VarState
> > +  ));
> 
> Did you want to print VarHeader->State?

Yes, indeed.  Good catch, thank you, will fix send send v2.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112176): https://edk2.groups.io/g/devel/message/112176
Mute This Topic: https://groups.io/mt/102991507/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-test v2 1/4] Unbreak buildzip.sh

2023-12-07 Thread G Edhaya Chandran
Reviewed-by: G Edhaya Chandran 
Thank you for the update.


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




Re: [edk2-devel] CLANGDWARF OVMF hangs on start

2023-12-07 Thread Gerd Hoffmann
On Thu, Dec 07, 2023 at 08:40:55AM +, Mike Beaton wrote:
> From commit 
> https://github.com/tianocore/edk2/commit/140e4422b16482f0bcafdc20d42141434d450450
> (and see also the preceding commit, which I believe is related) up to
> the current tip of master, CLANGDWARF OVMF is broken. It builds and
> starts but hangs early (more info below). I do not currently have a
> patch to offer though of course it would be useful if this could be
> resolved.

Which clang version is this?

It works for me, fedora 39 / clang 17, and I'm pretty sure I tested it
when creating the patch on a slightly older clang version (15 or 16).

take care,
  Gerd



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




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

2023-12-07 Thread Yuwei Chen
Hi Liming,

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

Thanks,
Christine
From: devel@edk2.groups.io  On Behalf Of Yuwei Chen
Sent: Monday, November 13, 2023 8:32 AM
To: Gao, Liming ; 'Rebecca Cran' ; 
Gao, Liming ; Zimmer, Vincent 
; Kinney, Michael D ; 
'Leif Lindholm' ; 'Andrew Fish' 
Cc: Feng, Bob C ; Yang, Yuting2 ; 
devel@edk2.groups.io; Hartung, Stephen 
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 thanks~



Hi Vincent, please help add more information if necessary~ Thanks a lot~



Thanks,

Christine




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112173): https://edk2.groups.io/g/devel/message/112173
Mute This Topic: https://groups.io/mt/102486097/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/6] UefiCpuPkg: Adds SmmCpuSyncLib library class

2023-12-07 Thread Ni, Ray



Thanks,
Ray
> -Original Message-
> From: Wu, Jiaxin 
> Sent: Wednesday, December 6, 2023 6:01 PM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek ; Dong, Eric ; Ni,
> Ray ; Zeng, Star ; Gerd Hoffmann
> ; Kumar, Rahul R 
> Subject: [PATCH v3 2/6] UefiCpuPkg: Adds SmmCpuSyncLib library class
> 
> Intel is planning to provide different SMM CPU Sync implementation
> along with some specific registers to improve the SMI performance,
> hence need SmmCpuSyncLib Library for Intel.
> 
> This patch is to:
> 1.Adds SmmCpuSyncLib Library class in UefiCpuPkg.dec.
> 2.Adds SmmCpuSyncLib.h function declaration header file.
> 
> For the new SmmCpuSyncLib, it provides 3 sets of APIs:
> 
> 1. ContextInit/ContextDeinit/ContextReset:

1. add extra empty line.

> ContextInit() is called in driver's entrypoint to allocate and

2. add extra spaces to show the paragraph is body of each bullet item.

In general, please make necessary changes to make the comments easy to read.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112172): https://edk2.groups.io/g/devel/message/112172
Mute This Topic: https://groups.io/mt/103010164/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 v7 1/5] UefiCpuPkg: Add macro definitions for CET feature for NASM files.

2023-12-07 Thread Sheng Wei
Hi Ray,
I update the copyright year and add your review-by for the 5 patches.
And here is the PR https://github.com/tianocore/edk2/pull/5109

Thank you.
BR
Sheng Wei

> -Original Message-
> From: Ni, Ray 
> Sent: Thursday, December 7, 2023 4:41 PM
> To: Sheng, W ; devel@edk2.groups.io
> Cc: Dong, Eric ; Laszlo Ersek ; Wu,
> Jiaxin ; Tan, Dun 
> Subject: RE: [PATCH v7 1/5] UefiCpuPkg: Add macro definitions for CET
> feature for NASM files.
> 
> For all the series (5 patches), Reviewed-by: Ray Ni 
> 
> Can you kindly create PR and update the copyright year in file header in the
> final PR?
> 
> Thanks,
> Ray
> > -Original Message-
> > From: Sheng, W 
> > Sent: Wednesday, December 6, 2023 4:16 PM
> > To: devel@edk2.groups.io
> > Cc: Dong, Eric ; Ni, Ray ;
> > Laszlo Ersek ; Wu, Jiaxin ;
> > Tan, Dun 
> > Subject: [PATCH v7 1/5] UefiCpuPkg: Add macro definitions for CET
> > feature for NASM files.
> >
> > Signed-off-by: Sheng Wei 
> > Cc: Eric Dong 
> > Cc: Ray Ni 
> > Cc: Laszlo Ersek 
> > Cc: Wu Jiaxin 
> > Cc: Tan Dun 
> > ---
> >  UefiCpuPkg/PiSmmCpuDxeSmm/Cet.inc | 26
> > ++
> >  1 file changed, 26 insertions(+)
> >  create mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Cet.inc
> >
> > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Cet.inc
> > b/UefiCpuPkg/PiSmmCpuDxeSmm/Cet.inc
> > new file mode 100644
> > index 00..41c99988c9
> > --- /dev/null
> > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Cet.inc
> > @@ -0,0 +1,26 @@
> > +;
> > +--
> >
> > +;
> >
> > +; Copyright (c) 2023, Intel Corporation. All rights reserved.
> >
> > +; SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > +;
> >
> > +; Abstract:
> >
> > +;
> >
> > +;   This file provides macro definitions for CET feature for NASM files.
> >
> > +;
> >
> > +;
> > +--
> >
> > +
> >
> > +%define MSR_IA32_U_CET 0x6A0
> >
> > +%define MSR_IA32_S_CET 0x6A2
> >
> > +%define MSR_IA32_CET_SH_STK_EN (1<<0)
> >
> > +%define MSR_IA32_CET_WR_SHSTK_EN   (1<<1)
> >
> > +%define MSR_IA32_CET_ENDBR_EN  (1<<2)
> >
> > +%define MSR_IA32_CET_LEG_IW_EN (1<<3)
> >
> > +%define MSR_IA32_CET_NO_TRACK_EN   (1<<4)
> >
> > +%define MSR_IA32_CET_SUPPRESS_DIS  (1<<5)
> >
> > +%define MSR_IA32_CET_SUPPRESS  (1<<10)
> >
> > +%define MSR_IA32_CET_TRACKER   (1<<11)
> >
> > +%define MSR_IA32_PL0_SSP   0x6A4
> >
> > +%define MSR_IA32_INTERRUPT_SSP_TABLE_ADDR  0x6A8
> >
> > +
> >
> > +%define CR4_CET_BIT23
> >
> > +%define CR4_CET(1< >
> > --
> > 2.26.2.windows.1



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




[edk2-devel] [PATCH] MdePkg: Define the DevicePath argument from LoadImage as optional

2023-12-07 Thread ManickamX Srinivasan
Update the EFI LoadImage API in accordance with the UEFI 2.9
specification.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: T V Krishnamoorthy 
Signed-off-by: ManickamX Srinivasan 
---
 MdePkg/Include/Uefi/UefiSpec.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h
index 7dfe35b499..08db17e674 100644
--- a/MdePkg/Include/Uefi/UefiSpec.h
+++ b/MdePkg/Include/Uefi/UefiSpec.h
@@ -898,7 +898,7 @@ EFI_STATUS
 (EFIAPI *EFI_IMAGE_LOAD)(
   IN  BOOLEAN  BootPolicy,
   IN  EFI_HANDLE   ParentImageHandle,
-  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL,
   IN  VOID *SourceBuffer OPTIONAL,
   IN  UINTNSourceSize,
   OUT EFI_HANDLE   *ImageHandle
-- 
2.30.2.windows.1



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




Re: [edk2-devel] [PATCH v7 1/5] UefiCpuPkg: Add macro definitions for CET feature for NASM files.

2023-12-07 Thread Ni, Ray
For all the series (5 patches), Reviewed-by: Ray Ni 

Can you kindly create PR and update the copyright year in file header in the 
final PR?

Thanks,
Ray
> -Original Message-
> From: Sheng, W 
> Sent: Wednesday, December 6, 2023 4:16 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Ni, Ray ; Laszlo
> Ersek ; Wu, Jiaxin ; Tan, Dun
> 
> Subject: [PATCH v7 1/5] UefiCpuPkg: Add macro definitions for CET feature for
> NASM files.
> 
> Signed-off-by: Sheng Wei 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Wu Jiaxin 
> Cc: Tan Dun 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/Cet.inc | 26
> ++
>  1 file changed, 26 insertions(+)
>  create mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Cet.inc
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Cet.inc
> b/UefiCpuPkg/PiSmmCpuDxeSmm/Cet.inc
> new file mode 100644
> index 00..41c99988c9
> --- /dev/null
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Cet.inc
> @@ -0,0 +1,26 @@
> +;--
> 
> +;
> 
> +; Copyright (c) 2023, Intel Corporation. All rights reserved.
> 
> +; SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +;
> 
> +; Abstract:
> 
> +;
> 
> +;   This file provides macro definitions for CET feature for NASM files.
> 
> +;
> 
> +;--
> 
> +
> 
> +%define MSR_IA32_U_CET 0x6A0
> 
> +%define MSR_IA32_S_CET 0x6A2
> 
> +%define MSR_IA32_CET_SH_STK_EN (1<<0)
> 
> +%define MSR_IA32_CET_WR_SHSTK_EN   (1<<1)
> 
> +%define MSR_IA32_CET_ENDBR_EN  (1<<2)
> 
> +%define MSR_IA32_CET_LEG_IW_EN (1<<3)
> 
> +%define MSR_IA32_CET_NO_TRACK_EN   (1<<4)
> 
> +%define MSR_IA32_CET_SUPPRESS_DIS  (1<<5)
> 
> +%define MSR_IA32_CET_SUPPRESS  (1<<10)
> 
> +%define MSR_IA32_CET_TRACKER   (1<<11)
> 
> +%define MSR_IA32_PL0_SSP   0x6A4
> 
> +%define MSR_IA32_INTERRUPT_SSP_TABLE_ADDR  0x6A8
> 
> +
> 
> +%define CR4_CET_BIT23
> 
> +%define CR4_CET(1< 
> --
> 2.26.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112169): https://edk2.groups.io/g/devel/message/112169
Mute This Topic: https://groups.io/mt/103009377/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] CLANGDWARF OVMF hangs on start

2023-12-07 Thread Mike Beaton
>From commit 
>https://github.com/tianocore/edk2/commit/140e4422b16482f0bcafdc20d42141434d450450
(and see also the preceding commit, which I believe is related) up to
the current tip of master, CLANGDWARF OVMF is broken. It builds and
starts but hangs early (more info below). I do not currently have a
patch to offer though of course it would be useful if this could be
resolved.

Note: I've cc'd those folks who have more or less recently (this year)
authored or reviewed commits which have modified CLANGDWARF OVMF build
behaviour in various interesting ways, including the above, as
described below.

### More detail:

Using the following commands

```
cd OvmfPkg
./build.sh -a X64 -b NOOPT -t CLANGDWARF -D DEBUG_ON_SERIAL_PORT=1
./build.sh -a X64 -b NOOPT -t CLANGDWARF qemu -serial stdio
```

from the mentioned commit up to the current tip of master CLANGDWARF
OVMF builds, but when started it hangs, repeatedly outputting the line
`SecCoreStartupWithStack(0xFFFCC000, 0x82)`.

Prior to that commit, CLANGDWARF OVMF builds and starts normally
(though see the following).

As additional possibly helpful information, it may be worth noting
that if we go back further we reach
https://github.com/tianocore/edk2/commit/c6f47e678f994ac86d36955d24baae465330d356
which is the earliest commit with correct behaviour. In the commit
before that CLANGDWARF OVMF builds but when run stops with an ASSERT,
and in the commit before that again, CLANGDWARF OVMF does not build,
giving:

```
In file included from
/home/mjsbeaton/OpenSource/edk2/CryptoPkg/Library/OpensslLib/openssl/crypto/asn1/a_sign.c:22:
...
In file included from /usr/include/stdint.h:34:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: error: typedef
redefinition with different types ('__int64_t' (aka 'long') vs 'INT64'
(aka 'long long'))
typedef __int64_t int64_t;
  ^
/home/mjsbeaton/OpenSource/edk2/CryptoPkg/Library/OpensslLib/openssl/include/openssl/e_os2.h:238:15:
note: previous definition is here
typedef INT64 int64_t;
  ^
...
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h:27:20: error:
typedef redefinition with different types ('__uint64_t' (aka 'unsigned
long') vs 'UINT64' (aka 'unsigned long long'))
typedef __uint64_t uint64_t;
   ^
/home/mjsbeaton/OpenSource/edk2/CryptoPkg/Library/OpensslLib/openssl/include/openssl/e_os2.h:239:16:
note: previous definition is here
typedef UINT64 uint64_t;
   ^
...
2 errors generated.
```

That failure to build persists back in the commit history for some
time. I didn't find a commit further back than that where CLANGDWARF
OVMF builds and runs correctly with current tools, though the exact
build failure changes at different points in the commit history, and I
haven't bisected everything which happens. (Note: when doing the above
bisects, it seems helpful/necessary to rebuild base tools, plus of
course `git submodule update --init`, at each step to get reliable
results.)

Mike


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




Re: [edk2-devel] [PATCH] ArmVirtPkg: Allow EFI memory attributes protocol to be disabled

2023-12-07 Thread Ard Biesheuvel
On Tue, 5 Dec 2023 at 10:56, Marcin Juszkiewicz
 wrote:
>
...
>
> I use 'sbsa-ref' with QEMU and upstream EDK2. And cannot use either RHEL
> 9.3 nor CentOS Stream 9 installers because they hang.
>
> And this is not the only platform where upstream EDK2 is used.
>
> Sure, I can hack something, use Grub from Debian or Fedora and get
> things working but that's not solution.
>
> Adding flags in 'Broken OS support' section of EDK2 settings feels like
> bad idea. Especially when EFI app generating issues is developed by
> company known for FOSS work.
>

Thanks Marcin - I agree that other EDK2 users are equally affected.

However, I strongly feel that it is up to the distros to clean up this
mess - please go and complain internally at RedHat about this.

In the mean time, there are end users of QEMU + edk2 on macOS (among
other places) whose stuff gets broken if they update their packages.
For these use cases in particular, I am willing to make an exception,
and implement this escape hatch.


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