Re: [edk2-devel] [PATCH 2/2] RedfishPkg: RedfishDiscoverDxe: Optimize the Redfish Discover flow

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

Hi Igor,
Only one comment below,

> -Original Message-
> From: Igor Kulchytskyy 
> Sent: Tuesday, November 14, 2023 1:24 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; Nickle Wang
> 
> Subject: [PATCH 2/2] RedfishPkg: RedfishDiscoverDxe: Optimize the Redfish
> Discover flow
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Filter out the network interfaces which are not supported by
> Redfish Host Interface.
>
> Cc: Abner Chang 
> Cc: Nickle Wang 
> Signed-off-by: Igor Kulchytskyy 
> ---
>  .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 169 +-
>  1 file changed, 120 insertions(+), 49 deletions(-)
>
> diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> index 0f622e05a9..3d514d7e4c 100644
> --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> @@ -13,6 +13,12 @@
>
>  #include "RedfishDiscoverInternal.h"
>
> +#define MAC_COMPARE(ThisNetworkInterface, TargetNetworkInterface)
> (CompareMem ((VOID *)>MacAddress,
> >MacAddress, ThisNetworkInterface-
> >HwAddressSize))
> +#define VALID_TCP6(TargetNetworkInterface, ThisNetworkInterface)
> (TargetNetworkInterface->IsIpv6 && (ThisNetworkInterface-
> >NetworkProtocolType == ProtocolTypeTcp6))
> +#define VALID_TCP4(TargetNetworkInterface, ThisNetworkInterface)
> (!TargetNetworkInterface->IsIpv6 && (ThisNetworkInterface-
> >NetworkProtocolType == ProtocolTypeTcp4))
> +#define IS_TCP4_MATCH(IpType)
> ((gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp4) && (IpType !=
> REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4))
> +#define IS_TCP6_MATCH(IpType)
> ((gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp6) && (IpType !=
> REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6))

Let's move these macro to RedfishDicoverInternal.h

Abner

> +
>  LIST_ENTRY   mRedfishDiscoverList;
>  LIST_ENTRY   mRedfishInstanceList;
>  EFI_SMBIOS_PROTOCOL  *mSmbios = NULL;
> @@ -322,9 +328,16 @@ GetTargetNetworkInterfaceInternal (
>  {
>EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
> *ThisNetworkInterface;
>
> +  if (IsListEmpty ()) {
> +return NULL;
> +  }
> +
>ThisNetworkInterface =
> (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode
> ();
>while (TRUE) {
> -if (CompareMem ((VOID *)>MacAddress,
> >MacAddress, ThisNetworkInterface-
> >HwAddressSize) == 0) {
> +if ((MAC_COMPARE (ThisNetworkInterface, TargetNetworkInterface) == 0)
> &&
> +(VALID_TCP6 (TargetNetworkInterface, ThisNetworkInterface) ||
> + VALID_TCP4 (TargetNetworkInterface, ThisNetworkInterface)))
> +{
>return ThisNetworkInterface;
>  }
>
> @@ -354,6 +367,10 @@ GetTargetNetworkInterfaceInternalByController (
>  {
>EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
> *ThisNetworkInterface;
>
> +  if (IsListEmpty ()) {
> +return NULL;
> +  }
> +
>ThisNetworkInterface =
> (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode
> ();
>while (TRUE) {
>  if (ThisNetworkInterface->OpenDriverControllerHandle ==
> ControllerHandle) {
> @@ -476,6 +493,42 @@ CheckIsIpVersion6 (
>return FALSE;
>  }
>
> +/**
> +  This function returns the  IP type supported by the Host Interface.
> +
> +  @retval 00h is Unknown
> +  01h is Ipv4
> +  02h is Ipv6
> +
> +**/
> +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;
> +}
> +
>  /**
>This function discover Redfish service through SMBIOS host interface.
>
> @@ -512,6 +565,18 @@ DiscoverRedfishHostInterface (
>
>Status = RedfishGetHostInterfaceProtocolData (mSmbios,
> , ); // Search for SMBIOS type 42h
>if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
> +if ((Instance->NetworkInterface->NetworkProtocolType ==
> ProtocolTypeTcp4) &&
> +(Data->HostIpAddressFormat !=
> REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4)) // IPv4 case
> +{
> +  DEBUG ((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host
> Interface requires Ipv6\n", __func__));
> +  return 

Re: [edk2-devel] [PATCH 1/2] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx

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

Reviewed-by: Abner Chang 

> -Original Message-
> From: Igor Kulchytskyy 
> Sent: Tuesday, November 14, 2023 1:24 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; Nickle Wang
> 
> Subject: [PATCH 1/2] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4
> installed after RestEx
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Supported function of the driver changed to wait for all network
> interface to be installed.
>
> Cc: Abner Chang 
> Cc: Nickle Wang 
> Signed-off-by: Igor Kulchytskyy 
> ---
>  .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 31 ++-
>  1 file changed, 16 insertions(+), 15 deletions(-)
>
> diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> index 23da3b968f..0f622e05a9 100644
> --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> @@ -1547,25 +1547,26 @@ TestForRequiredProtocols (
>  ControllerHandle,
>  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
>  );
> +if (EFI_ERROR (Status)) {
> +  return EFI_UNSUPPORTED;
> +}
> +
> +Status = gBS->OpenProtocol (
> +ControllerHandle,
> +gRequiredProtocol[Index].DiscoveredProtocolGuid,
> +(VOID **),
> +This->DriverBindingHandle,
> +ControllerHandle,
> +EFI_OPEN_PROTOCOL_GET_PROTOCOL
> +);
>  if (!EFI_ERROR (Status)) {
> -  Status = gBS->OpenProtocol (
> -  ControllerHandle,
> -  gRequiredProtocol[Index].DiscoveredProtocolGuid,
> -  (VOID **),
> -  This->DriverBindingHandle,
> -  ControllerHandle,
> -  EFI_OPEN_PROTOCOL_GET_PROTOCOL
> -  );
> -  if (EFI_ERROR (Status)) {
> -if (Index == ListCount - 1) {
> -  DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this
> controller handle: %p.\n", __func__, ControllerHandle));
> -  return EFI_SUCCESS;
> -}
> -  }
> +  // Already installed
> +  return EFI_UNSUPPORTED;
>  }
>}
>
> -  return EFI_UNSUPPORTED;
> +  DEBUG ((DEBUG_MANAGEABILITY, "%a: all required protocols are found on
> this controller handle: %p.\n", __func__, ControllerHandle));
> +  return EFI_SUCCESS;
>  }
>
>  /**
> --
> 2.37.1.windows.1
> -The information contained in this message may be confidential and
> proprietary to American Megatrends (AMI). This communication is intended
> to be read only by the individual or entity to whom it is addressed or by 
> their
> designee. If the reader of this message is not the intended recipient, you are
> on notice that any distribution of this message, in any form, is strictly
> prohibited. Please promptly notify the sender by reply e-mail or by telephone
> at 770-246-8600, and then delete or destroy all copies of the transmission.


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




[edk2-devel] Event: TianoCore Bug Triage - APAC / NAMO - Tuesday, November 14, 2023 #cal-reminder

2023-11-13 Thread Group Notification
*Reminder: TianoCore Bug Triage - APAC / NAMO*

*When:*
Tuesday, November 14, 2023
6:30pm to 7:30pm
(UTC-08:00) America/Los Angeles

*Where:*
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTk1YzJhN2UtOGQwNi00NjY4LWEwMTktY2JiODRlYTY1NmY0%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4-1242-431b-9a51-92cd01a5df3c%22%7d

*Organizer:* Liming Gao gaolim...@byosoft.com.cn ( 
gaolim...@byosoft.com.cn?subject=Re:%20Event:%20TianoCore%20Bug%20Triage%20-%20APAC%20%2F%20NAMO
 )

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

*Description:*

TianoCore Bug Triage - APAC / NAMO

Hosted by Liming Gao



Microsoft Teams meeting

*Join on your computer or mobile app*

Click here to join the meeting ( 
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTk1YzJhN2UtOGQwNi00NjY4LWEwMTktY2JiODRlYTY1NmY0%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4-1242-431b-9a51-92cd01a5df3c%22%7d
 )

*Join with a video conferencing device*

te...@conf.intel.com

Video Conference ID: 116 062 094 0

Alternate VTC dialing instructions ( 
https://conf.intel.com/teams/?conf=1160620940=teams=conf.intel.com=test_call
 )

*Or call in (audio only)*

+1 916-245-6934,,77463821# ( tel:+19162456934,,77463821# ) United States, 
Sacramento

Phone Conference ID: 774 638 21#

Find a local number ( 
https://dialin.teams.microsoft.com/d195d438-2daa-420e-b9ea-da26f9d1d6d5?id=77463821
 ) | Reset PIN ( https://mysettings.lync.com/pstnconferencing )

Learn More ( https://aka.ms/JoinTeamsMeeting ) | Meeting options ( 
https://teams.microsoft.com/meetingOptions/?organizerId=b286b53a-1218-4db3-bfc9-3d4c5aa7669e=46c98d88-e344-4ed4-8496-4ed7712e255d=19_meeting_OTUyZTg2NjgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh@thread.v2=0=en-US
 )


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90): https://edk2.groups.io/g/devel/message/90
Mute This Topic: https://groups.io/mt/102576791/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 v2 23/30] OvmfPkg/LoongArchVirt: Add PeiServiceTablePointerLib

2023-11-13 Thread Chao Li

Hi Laszlo,

I see, I will look into this PI SPEC and try to implement it in MdePkg 
first and then to update the SPEC.



Thanks,
Chao
On 2023/11/13 19:02, Laszlo Ersek wrote:

On 11/10/23 07:44, Chao Li wrote:

Hi Laszlo,

This is a good question, same as the previous email, some ARCH don't
require running code on memory during PEI phase or other reason can not
used the MdePkg version, so this pointer will be saved by some register,
I saw the ArmPkg version also uses a register to save this pointer.

If I move ArmPkg version PeiServiceTablePointer to MdePkg and the method
of getting and saving the pointer use a new library which related
architecture, other word, the API of PeiServiceTablePointer has not
changed, adding a new library that PeiServiceTablePointer depends on,
the real saving and reading method completed in the new library. Do you
think this way is better?

Right. I think you need a loongarch-specific library instance of
PeiServicesTablePointerLib under MdePkg. Presumably, if / when you
enable edk2 on *physical* loongarch platforms, you're going to need the
same library instance. And therefore it should not be under OvmfPkg, but
MdePkg.

In fact, now that I'm reading the comments in
"MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c",
it seems that the architecture bindings in the Platform Init
specification actually document how the PEI services table pointer is
supposed to be stored before system memory becomes available (IIUC).

The latest version of the PI spec that I have is 1.8.

In Volume I, there is a section titled "I-9.4 PEI Services Table
Retrieval". It considers the following architectures: X86, x64, Itanium,
ARM, AArch64, RISC-V.

I think that in the longer term, you should file a PIWG Mantis ticket
for extending this section, with an Engineering Change Request where you
describe how this mechanism should work on loongarch.

And then the implementation certainly belongs to MdePkg.

(Note that I'm *not* saying you should first update the specification
and then implement it in edk2 -- that's not my point. My point is that
*eventually*, this mechanism will become a part of the public loongarch
bindings, and therefore you can already start introducing it under
MdePkg, in my opinion anyway.)

Note that "prior art" is inconsistent here, regarding edk2 locations,
because, as you say, the arm/aarch64 implementation lives under ArmPkg
-- but it's quite unlikely IMO that a LoongArchPkg top-level directory
would be introduced. In the longer term, we might want to consolidate
all PeiServicesTablePointerLib instances under MdePkg.


Then your question is, IIUC, whether to reuse any portion of the ArmPkg
implementation. I don't think that's necessary; the library is so small,
there is effectively *nothing generic* in it. Put differently, all of it
is architecture specific. Thus I think you can just add a totally
self-contained loongarch instance.

Laszlo








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




[edk2-devel] [PATCH] UefiCpuPkg: Use NonSmm BSP as BSP if BSP election is not enabled.

2023-11-13 Thread Zhiguang Liu
Currently, if BSP election is not enabled, will use Core0 as SMM BSP,
however, Core0 does not always have the highest performance core.
So, we can used NonSmm BSP as default BSP.

Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Signed-off-by: Zhiguang Liu 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  | 10 +
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 48 +++---
 2 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 25d058c5b9..a4f83bb122 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -29,6 +29,8 @@ MM_COMPLETIONmSmmStartupThisApToken;
 //
 UINT32  *mPackageFirstThreadIndex = NULL;
 
+extern EFI_MP_SERVICES_PROTOCOL  *mMpServices;
+
 /**
   Performs an atomic compare exchange operation to get semaphore.
   The compare exchange operation must be performed using
@@ -1953,6 +1955,14 @@ InitializeMpSyncData (
   // Enable BSP election by setting BspIndex to -1
   //
   mSmmMpSyncData->BspIndex = (UINT32)-1;
+} else {
+  //
+  // Use NonSMM BSP as SMM BSP
+  //
+  ASSERT (mMpServices != NULL);
+  if (mMpServices != NULL) {
+mMpServices->WhoAmI (mMpServices, (UINTN *)>BspIndex);
+  }
 }
 
 mSmmMpSyncData->EffectiveSyncMode = mCpuSmmSyncMode;
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
index 1d022a7051..18c77c59e6 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -128,7 +128,8 @@ SPIN_LOCK  *mConfigSmmCodeAccessCheckLock = NULL;
 EFI_SMRAM_DESCRIPTOR  *mSmmCpuSmramRanges;
 UINTN mSmmCpuSmramRangeCount;
 
-UINT8  mPhysicalAddressBits;
+UINT8 mPhysicalAddressBits;
+EFI_MP_SERVICES_PROTOCOL  *mMpServices;
 
 //
 // Control register contents saved for SMM S3 resume state initialization.
@@ -603,26 +604,25 @@ PiCpuSmmEntry (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  EFI_STATUSStatus;
-  EFI_MP_SERVICES_PROTOCOL  *MpServices;
-  UINTN NumberOfEnabledProcessors;
-  UINTN Index;
-  VOID  *Buffer;
-  UINTN BufferPages;
-  UINTN TileCodeSize;
-  UINTN TileDataSize;
-  UINTN TileSize;
-  UINT8 *Stacks;
-  VOID  *Registration;
-  UINT32RegEax;
-  UINT32RegEbx;
-  UINT32RegEcx;
-  UINT32RegEdx;
-  UINTN FamilyId;
-  UINTN ModelId;
-  UINT32Cr3;
-  EFI_HOB_GUID_TYPE *GuidHob;
-  SMM_BASE_HOB_DATA *SmmBaseHobData;
+  EFI_STATUS Status;
+  UINTN  NumberOfEnabledProcessors;
+  UINTN  Index;
+  VOID   *Buffer;
+  UINTN  BufferPages;
+  UINTN  TileCodeSize;
+  UINTN  TileDataSize;
+  UINTN  TileSize;
+  UINT8  *Stacks;
+  VOID   *Registration;
+  UINT32 RegEax;
+  UINT32 RegEbx;
+  UINT32 RegEcx;
+  UINT32 RegEdx;
+  UINTN  FamilyId;
+  UINTN  ModelId;
+  UINT32 Cr3;
+  EFI_HOB_GUID_TYPE  *GuidHob;
+  SMM_BASE_HOB_DATA  *SmmBaseHobData;
 
   GuidHob= NULL;
   SmmBaseHobData = NULL;
@@ -656,13 +656,13 @@ PiCpuSmmEntry (
   //
   // Get MP Services Protocol
   //
-  Status = SystemTable->BootServices->LocateProtocol 
(, NULL, (VOID **));
+  Status = SystemTable->BootServices->LocateProtocol 
(, NULL, (VOID **));
   ASSERT_EFI_ERROR (Status);
 
   //
   // Use MP Services Protocol to retrieve the number of processors and number 
of enabled processors
   //
-  Status = MpServices->GetNumberOfProcessors (MpServices, , 
);
+  Status = mMpServices->GetNumberOfProcessors (mMpServices, , 
);
   ASSERT_EFI_ERROR (Status);
   ASSERT (mNumberOfCpus <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
 
@@ -945,7 +945,7 @@ PiCpuSmmEntry (
 gSmmCpuPrivate->Operation[Index]= SmmCpuNone;
 
 if (Index < mNumberOfCpus) {
-  Status = MpServices->GetProcessorInfo (MpServices, Index | 
CPU_V2_EXTENDED_TOPOLOGY, >ProcessorInfo[Index]);
+  Status = mMpServices->GetProcessorInfo (mMpServices, Index | 
CPU_V2_EXTENDED_TOPOLOGY, >ProcessorInfo[Index]);
   ASSERT_EFI_ERROR (Status);
   mCpuHotPlugData.ApicId[Index] = 
gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId;
 
-- 
2.31.1.windows.1



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

Re: [edk2-devel] [PATCH v2 11/30] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg

2023-11-13 Thread Chao Li

Hi Andrei,

I agree with you, I will move LoongArch-specific stuff from UefiCpuPkg 
to MdePkg/Include/ in V3.


And you are also saied record the idea of moving ArmMmuLib to CpuMmuLib, 
I would to say, this header is referenced from ArmPkg, and I plan to 
move the ArmMmuLib from ArmPkg to UefiCpuPkg after merging this patch 
set, and other BZ number will be used. The premise is that the 
maintainers of ArmPkg agrees move operation.



Thanks,
Chao
On 2023/11/9 09:17, Andrei Warkentin wrote:

Hi Chao,

I see that you're adding a header, CpuMmuLib.h, but this header is not generic - it 
includes a bunch of Loongson arch-specific "stuff".

I agree in principle that there's room for a generic CpuMmuLib, and I don't 
think you ought to be on the hook to refactor ArmMmuLib, but I suggest moving
the architecture-specific PTE #defines into MdePkg/Include similar to 
./MdePkg/Include/Register/RiscV64. (it would, though, be nice to at least 
record the idea of moving ArmMmuLib to CpuMmuLib raise a BZ for that or 
something!)

This will avoid the #ifdef MDE_CPU_LOONGARCH64 inside a generic Library header.

A


-Original Message-
From: Chao Li
Sent: Sunday, November 5, 2023 9:28 PM
To:devel@edk2.groups.io
Cc: Dong, Eric; Ni, Ray; Kumar,
Rahul R; Gerd Hoffmann;
Leif Lindholm; Ard Biesheuvel
; Sami Mujawar;
Sunil V L; Warkentin, Andrei

Subject: [PATCH v2 11/30] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg

Add a new header file CpuMmuLib.h, whitch is referenced from
ArmPkg/Include/Library/ArmMmuLib.h. Currently, only support for
LoongArch64 is added, and more architectures can be accommodated in the
future.

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Eric Dong
Cc: Ray Ni
Cc: Rahul Kumar
Cc: Gerd Hoffmann
Cc: Leif Lindholm
Cc: Ard Biesheuvel
Cc: Sami Mujawar
Cc: Sunil V L
Cc: Andrei Warkentin
Signed-off-by: Chao Li
---
  UefiCpuPkg/Include/Library/CpuMmuLib.h | 194
+
  UefiCpuPkg/UefiCpuPkg.dec  |   4 +
  2 files changed, 198 insertions(+)
  create mode 100644 UefiCpuPkg/Include/Library/CpuMmuLib.h

diff --git a/UefiCpuPkg/Include/Library/CpuMmuLib.h
b/UefiCpuPkg/Include/Library/CpuMmuLib.h
new file mode 100644
index 00..8f524d31d4
--- /dev/null
+++ b/UefiCpuPkg/Include/Library/CpuMmuLib.h
@@ -0,0 +1,194 @@
+/** @file
+
+  Copyright (c) 2023 Loongson Technology Corporation Limited. All
+ rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CPU_MMU_LIB_H_
+#define CPU_MMU_LIB_H_
+
+#include 
+
+#ifdef MDE_CPU_LOONGARCH64
+
+/* Page table property definitions  */
+#define PAGE_VALID_SHIFT   0
+#define PAGE_DIRTY_SHIFT   1
+#define PAGE_PLV_SHIFT 2  // 2~3, two bits
+#define CACHE_SHIFT4  // 4~5, two bits
+#define PAGE_GLOBAL_SHIFT  6
+#define PAGE_HUGE_SHIFT6  // HUGE is a PMD bit
+
+#define PAGE_HGLOBAL_SHIFT  12 // HGlobal is a PMD bit
+#define PAGE_PFN_SHIFT  12
+#define PAGE_PFN_END_SHIFT  48
+#define PAGE_NO_READ_SHIFT  61
+#define PAGE_NO_EXEC_SHIFT  62
+#define PAGE_RPLV_SHIFT 63
+
+/* Used by TLB hardware (placed in EntryLo*) */
+#define PAGE_VALID((UINTN)(1) << PAGE_VALID_SHIFT)
+#define PAGE_DIRTY((UINTN)(1) << PAGE_DIRTY_SHIFT)
+#define PAGE_PLV  ((UINTN)(3) << PAGE_PLV_SHIFT)
+#define PAGE_GLOBAL   ((UINTN)(1) << PAGE_GLOBAL_SHIFT)
+#define PAGE_HUGE ((UINTN)(1) << PAGE_HUGE_SHIFT)
+#define PAGE_HGLOBAL  ((UINTN)(1) << PAGE_HGLOBAL_SHIFT) #define
+PAGE_NO_READ  ((UINTN)(1) << PAGE_NO_READ_SHIFT) #define
PAGE_NO_EXEC
+((UINTN)(1) << PAGE_NO_EXEC_SHIFT)
+#define PAGE_RPLV ((UINTN)(1) << PAGE_RPLV_SHIFT)
+#define CACHE_MASK((UINTN)(3) << CACHE_SHIFT)
+#define PFN_SHIFT (EFI_PAGE_SHIFT - 12 + PAGE_PFN_SHIFT)
+
+#define PLV_KERNEL  0
+#define PLV_USER3
+
+#define PAGE_USER(PLV_USER << PAGE_PLV_SHIFT)
+#define PAGE_KERNEL  (PLV_KERN << PAGE_PLV_SHIFT)
+
+#define CACHE_SUC  (0 << CACHE_SHIFT) // Strong-ordered UnCached
+#define CACHE_CC   (1 << CACHE_SHIFT) // Coherent Cached
+#define CACHE_WUC  (2 << CACHE_SHIFT) // Weak-ordered UnCached
+
+#define EFI_MEMORY_CACHETYPE_MASK  (EFI_MEMORY_UC  | \
+EFI_MEMORY_WC  | \
+EFI_MEMORY_WT  | \
+EFI_MEMORY_WB  | \
+EFI_MEMORY_UCE   \
+)
+#endif
+
+typedef struct {
+  EFI_PHYSICAL_ADDRESSPhysicalBase;
+  EFI_VIRTUAL_ADDRESS VirtualBase;
+  UINTN   Length;
+  UINTN   Attributes;
+} MEMORY_REGION_DESCRIPTOR;
+
+/**
+  Converts EFI Attributes to corresponding architecture Attributes.
+
+  @param[in]  EfiAttributes Efi Attributes.
+
+  @retval  Corresponding architecture attributes.
+**/
+UINTN
+EfiAttributeConverse (
+  IN UINTN  EfiAttributes
+  );
+
+/**
+  Finds the length and memory properties of the memory region
corresponding to the specified base address.
+
+  @param[in]  BaseAddressTo 

Re: [edk2-devel] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Michael Kubacki

On 11/13/2023 3:37 PM, Rebecca Cran wrote:

On 11/13/2023 1:08 PM, Michael Kubacki wrote:
Yes. I just did it. It is relatively minor and impacts expected code 
areas.


https://github.com/tianocore/edk2/pull/5043/files



Could you update .git-blame-ignore-revs please?

https://black.readthedocs.io/en/stable/guides/introducing_black_to_your_project.html#avoiding-ruining-git-blame


Yes. This was discussed this in the Tianocore Tools & CI meeting. I will 
submit the series to the mailing list as this only impacts 5 files in 2 
packages.


I will follow up with a commmit to propose adding that file with all 
formatting changes including the original Uncrustify changes.



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86): https://edk2.groups.io/g/devel/message/86
Mute This Topic: https://groups.io/mt/102559740/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 16/30] ArmVirtPkg: Move PCD of FDT base address and FDT padding to OvmfPkg

2023-11-13 Thread Chao Li

Hi Sami,

Ok, I will fix them in V3 and follow your suggestions, thanks for the 
review.



Thanks,
Chao
On 2023/11/13 19:46, Sami Mujawar wrote:

Hi Chao,

Thank you for this patch.

I have a few suggestions marked inline as [SAMI].

Otherwise this patch looks good to me.

With those fixed,

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar

On 06/11/2023 03:29 am, Chao Li wrote:

Moved PcdDeviceTreeInitialBaseAddress and PcdDeviceTreeAllocationPadding
to OvmfPkg for easier use by other architectures.

Build-tested only (with "ArmVirtQemu.dsc").

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Sami Mujawar 
Cc: Gerd Hoffmann 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Signed-off-by: Chao Li 
---
  ArmVirtPkg/ArmVirtCloudHv.dsc |  2 +-
  ArmVirtPkg/ArmVirtKvmTool.dsc |  2 +-
  ArmVirtPkg/ArmVirtPkg.dec | 14 --
  ArmVirtPkg/ArmVirtQemu.dsc    |  2 +-
  ArmVirtPkg/ArmVirtQemuKernel.dsc  |  2 +-
  ArmVirtPkg/ArmVirtXen.dsc |  2 +-
  .../ArmVirtPsciResetSystemPeiLib.inf  |  3 ++-
  .../CloudHvVirtMemInfoPeiLib.inf  |  3 ++-
  .../DebugLibFdtPL011UartFlash.inf |  3 ++-
  .../EarlyFdt16550SerialPortHookLib.inf    |  3 ++-
  .../EarlyFdtPL011SerialPortLib.inf    |  3 ++-
  .../KvmtoolPlatformPeiLib.inf |  5 +++--
  .../Library/PlatformPeiLib/PlatformPeiLib.inf | 10 +-
  .../QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf  |  3 ++-
  .../PrePi/ArmVirtPrePiUniCoreRelocatable.inf  |  3 ++-
  OvmfPkg/OvmfPkg.dec   | 15 +++
  16 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtCloudHv.dsc 
b/ArmVirtPkg/ArmVirtCloudHv.dsc

index 2cb89ce10c..76c0d28544 100644
--- a/ArmVirtPkg/ArmVirtCloudHv.dsc
+++ b/ArmVirtPkg/ArmVirtCloudHv.dsc
@@ -129,7 +129,7 @@
    gArmTokenSpaceGuid.PcdSystemMemoryBase|0x4000
      # initial location of the device tree blob passed by Cloud 
Hypervisor -- base of DRAM

- gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x4000
+ gUefiOvmfPkgTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x4000
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
    gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 
0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 
0xf4, 0x66, 0x23, 0x31 }
diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc 
b/ArmVirtPkg/ArmVirtKvmTool.dsc

index f50d53bf15..cac4fe06d3 100644
--- a/ArmVirtPkg/ArmVirtKvmTool.dsc
+++ b/ArmVirtPkg/ArmVirtKvmTool.dsc
@@ -179,7 +179,7 @@
    # We are booting from RAM using the Linux kernel boot protocol,
    # x0 will point to the DTB image in memory.
    #
-  gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0
+ gUefiOvmfPkgTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0
      gArmTokenSpaceGuid.PcdFdBaseAddress|0x0
    gArmTokenSpaceGuid.PcdFvBaseAddress|0x0
diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
index 0f2d787327..2451644844 100644
--- a/ArmVirtPkg/ArmVirtPkg.dec
+++ b/ArmVirtPkg/ArmVirtPkg.dec
@@ -42,20 +42,6 @@
gArmVirtTokenSpaceGuid.PcdTpm2SupportEnabled|FALSE|BOOLEAN|0x0004
    [PcdsFixedAtBuild, PcdsPatchableInModule]
-  #
-  # This is the physical address where the device tree is expected 
to be stored
-  # upon first entry into UEFI. This needs to be a FixedAtBuild PCD, 
so that we
-  # can do a first pass over the device tree in the SEC phase to 
discover the

-  # UART base address.
-  #
- 
gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0|UINT64|0x0001

-
-  #
-  # Padding in bytes to add to the device tree allocation, so that 
the DTB can

-  # be modified in place (default: 256 bytes)
-  #
- 
gArmVirtTokenSpaceGuid.PcdDeviceTreeAllocationPadding|256|UINT32|0x0002

-
    #
    # Binary representation of the GUID that determines the terminal 
type. The

    # size must be exactly 16 bytes. The default value corresponds to
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 30e3cfc8b9..cf306cac08 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -201,7 +201,7 @@
    gArmTokenSpaceGuid.PcdSystemMemoryBase|0x4000
      # initial location of the device tree blob passed by QEMU -- 
base of DRAM

- gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x4000
+ gUefiOvmfPkgTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x4000
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
    gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 
0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 
0xf4, 0x66, 0x23, 0x31 }
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc 
b/ArmVirtPkg/ArmVirtQemuKernel.dsc

index b50f8e84a3..c0d079e28d 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ 

[edk2-devel] Now: Tools, CI, Code base construction meeting series - Monday, November 13, 2023 #cal-notice

2023-11-13 Thread Group Notification
*Tools, CI, Code base construction meeting series*

*When:*
Monday, November 13, 2023
4:30pm to 5:30pm
(UTC-08:00) America/Los Angeles

*Where:*
https://teams.microsoft.com/l/meetup-join/19%3ameeting_ZDI2ZDg4NmMtMjI1My00MzI5LWFmYjAtMGQyNjUzNTBjZGYw%40thread.v2/0?context=%7b%22Tid%22%3a%2272f988bf-86f1-41af-91ab-2d7cd011db47%22%2c%22Oid%22%3a%2223af6561-6e1c-450d-b917-d9d674eb3cb6%22%7d

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

*Description:*

TianoCore community,

Microsoft and Intel will be hosting a series of open meetings to discuss build, 
CI, tools, and other related topics. If you are interested, have ideas/opinions 
please join us. These meetings will be Monday 4:30pm Pacific Time on Microsoft 
Teams.

MS Teams Link in following discussion: * 
https://github.com/tianocore/edk2/discussions/2614

Anyone is welcome to join.

* tianocore/edk2: EDK II (github.com)
* tianocore/edk2-basetools: EDK II BaseTools Python tools as a PIP module 
(github.com) https://github.com/tianocore/edk2-basetools
* tianocore/edk2-pytool-extensions: Extensions to the edk2 build system 
allowing for a more robust and plugin based build system and tool execution 
environment (github.com) https://github.com/tianocore/edk2-pytool-extensions
* tianocore/edk2-pytool-library: Python library package that supports UEFI 
development (github.com) https://github.com/tianocore/edk2-pytool-library

MS Teams Browser Clients * 
https://docs.microsoft.com/en-us/microsoftteams/get-clients?tabs=Windows#browser-client


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84): https://edk2.groups.io/g/devel/message/84
Mute This Topic: https://groups.io/mt/102574841/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: Tools, CI, Code base construction meeting series - Monday, November 13, 2023 #cal-reminder

2023-11-13 Thread Group Notification
*Reminder: Tools, CI, Code base construction meeting series*

*When:*
Monday, November 13, 2023
4:30pm to 5:30pm
(UTC-08:00) America/Los Angeles

*Where:*
https://teams.microsoft.com/l/meetup-join/19%3ameeting_ZDI2ZDg4NmMtMjI1My00MzI5LWFmYjAtMGQyNjUzNTBjZGYw%40thread.v2/0?context=%7b%22Tid%22%3a%2272f988bf-86f1-41af-91ab-2d7cd011db47%22%2c%22Oid%22%3a%2223af6561-6e1c-450d-b917-d9d674eb3cb6%22%7d

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

*Description:*

TianoCore community,

Microsoft and Intel will be hosting a series of open meetings to discuss build, 
CI, tools, and other related topics. If you are interested, have ideas/opinions 
please join us. These meetings will be Monday 4:30pm Pacific Time on Microsoft 
Teams.

MS Teams Link in following discussion: * 
https://github.com/tianocore/edk2/discussions/2614

Anyone is welcome to join.

* tianocore/edk2: EDK II (github.com)
* tianocore/edk2-basetools: EDK II BaseTools Python tools as a PIP module 
(github.com) https://github.com/tianocore/edk2-basetools
* tianocore/edk2-pytool-extensions: Extensions to the edk2 build system 
allowing for a more robust and plugin based build system and tool execution 
environment (github.com) https://github.com/tianocore/edk2-pytool-extensions
* tianocore/edk2-pytool-library: Python library package that supports UEFI 
development (github.com) https://github.com/tianocore/edk2-pytool-library

MS Teams Browser Clients * 
https://docs.microsoft.com/en-us/microsoftteams/get-clients?tabs=Windows#browser-client


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#83): https://edk2.groups.io/g/devel/message/83
Mute This Topic: https://groups.io/mt/102552921/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] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Pedro Falcato
On Mon, Nov 13, 2023 at 8:37 PM Rebecca Cran  wrote:
>
> On 11/13/2023 1:08 PM, Michael Kubacki wrote:
> > Yes. I just did it. It is relatively minor and impacts expected code
> > areas.
> >
> > https://github.com/tianocore/edk2/pull/5043/files
>
>
> Could you update .git-blame-ignore-revs please?

You can't do that until the merge is done, since we use
rebase-and-merge for tianocore (and rebases do not keep stable commit
hashes).
But I would plead that this should not get merged in general :/

-- 
Pedro


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




Re: [edk2-devel] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Michael D Kinney
Hi Michael,

Have you tried to upstream the edk2 specific elements to the
uncrustify project?  That would be a path to remove the fork
and eventually all the distros would catch up.

Mike

> -Original Message-
> From: Michael Kubacki 
> Sent: Monday, November 13, 2023 12:22 PM
> To: Pedro Falcato ; devel@edk2.groups.io;
> ler...@redhat.com
> Cc: Kinney, Michael D ; Andrew Fish
> ; Marcin Juszkiewicz ;
> Leif Lindholm (Quic) 
> Subject: Re: [edk2-devel] edk2 uncrustify update (73.0.8)?
> 
> On 11/13/2023 2:07 PM, Pedro Falcato wrote:
> > On Mon, Nov 13, 2023 at 11:58 AM Laszlo Ersek 
> wrote:
> >>
> >> Hi Michael,
> >>
> >> recently I encountered an uncrustify failure on github.
> >>
> >> The reason was that my local uncrustify was *more recent* (73.0.8)
> than
> >> the one we use in edk2 CI (which is 73.0.3, per the edk2 file
> >> ".pytool/Plugin/UncrustifyCheck/uncrustify_ext_dep.yaml").
> >
> > Wait, you can use upstream uncrustify? I'm just using whatever
> > uncrustify version I took from the project-mu fork...
> >
> The fork version is needed for edk2 specific conventions. More details
> are here -
> https://dev.azure.com/projectmu/uncrustify?anchor=edk-ii-poc-details
> 
> >>
> >> Updating the version number in the YAML file (i.e., advancing edk2
> to
> >> version 73.0.8) seems easy enough, but:
> >>
> >> - Do you think 73.0.8 is mature enough for adoption in edk2?
> >>
> >>This upstream uncrustify release was tagged in April (and I
> can't see
> >>any more recent commits), so I assume it should be stable.
> >>
> >> - Would the version update require a whole-tree re-
> uncrustification?
> >
> > Please, no. I didn't mind doing an initial reformatting at first,
> but
> > doing this continuously is both 1) problem-prone 2) just amazing
> > amounts of churn.
> > Let's say I have version N, you have version N+1 - we may never get
> > any final, formatted output as your version formats it differently
> > from mine.
> >
> > I don't know how the CI is doing its thing atm (I haven't merged
> > anything myself to edk2), but the uncrustify check should be relaxed
> > to just a warning. There's nothing wrong with what my uncrustify
> > version is formatting to, there's nothing wrong with yours either,
> and
> > CI isn't necessarily wrong either.
> >
> > And, to be fair, I already find uncrustify a large pain in the butt
> to
> > use (requiring a custom fork really does not help), but I find the
> > benefits worth it *locally*, as my coding style is also quite
> > different from the NT-esque style.
> >
> It should be simple to update and ensure everyone is using the same
> version. This requires stuart commands to be used
> (https://github.com/tianocore/edk2-pytool-extensions). I know there's
> aversion to stuart but that's how these extensions plug into the edk2
> build process right now.
> 
> If you use it, as an end user, you just run "stuart_update -c
> .pytool/CISettings.py" and it will get the Uncrustify binary for your
> host OS with the version used by the project.
> 
> ---
> 
> The version pulled and the source feed used by stuart are defined in
> edk2 here:
> https://github.com/tianocore/edk2/blob/master/.pytool/Plugin/Uncrustif
> yCheck/uncrustify_ext_dep.yaml
> 
> That file and command are used locally, in CI, and the file is checked
> into edk2. At any given point in time, a user at a given point in edk2
> history should be using the same version and configuration.
> 
> More details, for those interested, are here
> https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Code-
> Formatting.
> That tries to cover some niche use cases so it may seem more
> overwhelming than it actually is to just get and use the executable.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81): https://edk2.groups.io/g/devel/message/81
Mute This Topic: https://groups.io/mt/102559740/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] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Michael Kubacki

On 11/13/2023 2:14 PM, Rebecca Cran via groups.io wrote:

On 11/13/2023 5:29 AM, Marcin Juszkiewicz via groups.io wrote:

Still a fan of adding edk2-uncrustify to BaseTools. If we are expected 
to use it then let it get installed at same moment as "build" command is.


The issue with doing this is there's a push to remove all C/C++ code 
from BaseTools (including porting existing code to Python), and adding 
edk2-uncrustify would work against that.


That was a reason I did not add the code to BaseTools. I personally 
think it would bloat the edk2 repo and complicate its build process for 
something that rarely changes. Given binary dependencies are already 
used and managed for other incoming binaries such as iasl and nasm 
(https://github.com/tianocore/edk2/tree/master/BaseTools/Bin) and the 
effort to eliminate C/C++ code from BaseTools, I think it makes sense to 
keep it in a dedicated repository.


If there is another reason for the move, such as a preference to move 
the repo under the Tianocore organization (for whatever reason) or 
something like that, please let me know.



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




Re: [edk2-devel] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Rebecca Cran

On 11/13/2023 1:08 PM, Michael Kubacki wrote:
Yes. I just did it. It is relatively minor and impacts expected code 
areas.


https://github.com/tianocore/edk2/pull/5043/files



Could you update .git-blame-ignore-revs please?

https://black.readthedocs.io/en/stable/guides/introducing_black_to_your_project.html#avoiding-ruining-git-blame


--

Rebecca Cran



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




Re: [edk2-devel] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Michael Kubacki

On 11/13/2023 2:07 PM, Pedro Falcato wrote:

On Mon, Nov 13, 2023 at 11:58 AM Laszlo Ersek  wrote:


Hi Michael,

recently I encountered an uncrustify failure on github.

The reason was that my local uncrustify was *more recent* (73.0.8) than
the one we use in edk2 CI (which is 73.0.3, per the edk2 file
".pytool/Plugin/UncrustifyCheck/uncrustify_ext_dep.yaml").


Wait, you can use upstream uncrustify? I'm just using whatever
uncrustify version I took from the project-mu fork...

The fork version is needed for edk2 specific conventions. More details 
are here - 
https://dev.azure.com/projectmu/uncrustify?anchor=edk-ii-poc-details




Updating the version number in the YAML file (i.e., advancing edk2 to
version 73.0.8) seems easy enough, but:

- Do you think 73.0.8 is mature enough for adoption in edk2?

   This upstream uncrustify release was tagged in April (and I can't see
   any more recent commits), so I assume it should be stable.

- Would the version update require a whole-tree re-uncrustification?


Please, no. I didn't mind doing an initial reformatting at first, but
doing this continuously is both 1) problem-prone 2) just amazing
amounts of churn.
Let's say I have version N, you have version N+1 - we may never get
any final, formatted output as your version formats it differently
from mine.

I don't know how the CI is doing its thing atm (I haven't merged
anything myself to edk2), but the uncrustify check should be relaxed
to just a warning. There's nothing wrong with what my uncrustify
version is formatting to, there's nothing wrong with yours either, and
CI isn't necessarily wrong either.

And, to be fair, I already find uncrustify a large pain in the butt to
use (requiring a custom fork really does not help), but I find the
benefits worth it *locally*, as my coding style is also quite
different from the NT-esque style.

It should be simple to update and ensure everyone is using the same 
version. This requires stuart commands to be used 
(https://github.com/tianocore/edk2-pytool-extensions). I know there's 
aversion to stuart but that's how these extensions plug into the edk2 
build process right now.


If you use it, as an end user, you just run "stuart_update -c 
.pytool/CISettings.py" and it will get the Uncrustify binary for your 
host OS with the version used by the project.


---

The version pulled and the source feed used by stuart are defined in 
edk2 here: 
https://github.com/tianocore/edk2/blob/master/.pytool/Plugin/UncrustifyCheck/uncrustify_ext_dep.yaml


That file and command are used locally, in CI, and the file is checked 
into edk2. At any given point in time, a user at a given point in edk2 
history should be using the same version and configuration.


More details, for those interested, are here 
https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Code-Formatting. 
That tries to cover some niche use cases so it may seem more 
overwhelming than it actually is to just get and use the executable.



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




Re: [edk2-devel] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Michael Kubacki

On 11/13/2023 6:58 AM, Laszlo Ersek wrote:

Hi Michael,

recently I encountered an uncrustify failure on github.

The reason was that my local uncrustify was *more recent* (73.0.8) than
the one we use in edk2 CI (which is 73.0.3, per the edk2 file
".pytool/Plugin/UncrustifyCheck/uncrustify_ext_dep.yaml").

Updating the version number in the YAML file (i.e., advancing edk2 to
version 73.0.8) seems easy enough, but:

- Do you think 73.0.8 is mature enough for adoption in edk2?

   This upstream uncrustify release was tagged in April (and I can't see
   any more recent commits), so I assume it should be stable.

Yes, it is stable. We've been using each new Uncrustify release against 
edk2 code in Project Mu during that time. I updated our code to include 
that change in September 2022 - 
https://github.com/microsoft/mu_basecore/commit/6932526bee9a2f5f3af7588923beae5e5d8fd128.


The changes since then have been additional build support for Linux and 
Windows Arm and macOS.


I originally did not bring this to edk2 right away to verify stability 
over time and reduce thrash if any other changes came in to consolidate 
overall disruption to edk2.



- Would the version update require a whole-tree re-uncrustification?


Yes. I just did it. It is relatively minor and impacts expected code areas.

https://github.com/tianocore/edk2/pull/5043/files

I'm happy to send that to the list if desired.


The reason I'm not just ignoring this topic is that 73.0.8 actually
produces *better output* than 73.0.3, at least in the one instance I
encountered. Compare:


diff --git 
a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c 
b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c
index 434cdca84b23..3a6f75988220 100644
--- a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c
+++ b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c
@@ -43,12 +43,12 @@ STATIC EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL
  STATIC CONST EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  mMmio64Configuration = {
ACPI_ADDRESS_SPACE_DESCRIPTOR,   // Desc
(UINT16)(// Len
-   sizeof 
(EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) -
-   OFFSET_OF (
- 
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR,
- ResType
- )
-   ),
+sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) -
+OFFSET_OF (
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR,
+  ResType
+  )
+),
ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType
0,   // GenFlag
0,   // SpecificFlag
@@ -77,12 +77,12 @@ STATIC CONST EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  
mMmio64Configuration = {
  STATIC CONST EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  mOptionRomConfiguration =   {
ACPI_ADDRESS_SPACE_DESCRIPTOR,   // Desc
(UINT16)(// Len
-   sizeof 
(EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) -
-   OFFSET_OF (
- 
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR,
- ResType
- )
-   ),
+sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) -
+OFFSET_OF (
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR,
+  ResType
+  )
+),
ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType
0,   // GenFlag
0,   // Disable option roms 
SpecificFlag


Note that 73.0.3 indents the subexpression to the "//"  comment on the
previous line, while 73.0.8 ignores the comment -- which I think is
justified here.

I believe this improvement may come from uncrustify commit 239c4fad745b
("Prevent endless indentation scenario in struct assignment",
2022-07-29). I think it's worth having in edk2.

CC: stewards, Pedro (commit 6ded9f50c3aa), Marcin (traditionally a big
fan of uncrustify :))

Thanks
Laszlo



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




Re: [edk2-devel] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Rebecca Cran via groups.io

On 11/13/2023 5:29 AM, Marcin Juszkiewicz via groups.io wrote:

Still a fan of adding edk2-uncrustify to BaseTools. If we are expected 
to use it then let it get installed at same moment as "build" command is.


The issue with doing this is there's a push to remove all C/C++ code 
from BaseTools (including porting existing code to Python), and adding 
edk2-uncrustify would work against that.


--
Rebecca Cran




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




Re: [edk2-devel] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Pedro Falcato
On Mon, Nov 13, 2023 at 7:07 PM Pedro Falcato via groups.io
 wrote:
>
> On Mon, Nov 13, 2023 at 11:58 AM Laszlo Ersek  wrote:
> >
> > Hi Michael,
> >
> > recently I encountered an uncrustify failure on github.
> >
> > The reason was that my local uncrustify was *more recent* (73.0.8) than
> > the one we use in edk2 CI (which is 73.0.3, per the edk2 file
> > ".pytool/Plugin/UncrustifyCheck/uncrustify_ext_dep.yaml").
>
> Wait, you can use upstream uncrustify? I'm just using whatever
> uncrustify version I took from the project-mu fork...

Scratch that, I see there's a 73.0.8 in mu's fork.

-- 
Pedro


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




Re: [edk2-devel] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Pedro Falcato
On Mon, Nov 13, 2023 at 11:58 AM Laszlo Ersek  wrote:
>
> Hi Michael,
>
> recently I encountered an uncrustify failure on github.
>
> The reason was that my local uncrustify was *more recent* (73.0.8) than
> the one we use in edk2 CI (which is 73.0.3, per the edk2 file
> ".pytool/Plugin/UncrustifyCheck/uncrustify_ext_dep.yaml").

Wait, you can use upstream uncrustify? I'm just using whatever
uncrustify version I took from the project-mu fork...

>
> Updating the version number in the YAML file (i.e., advancing edk2 to
> version 73.0.8) seems easy enough, but:
>
> - Do you think 73.0.8 is mature enough for adoption in edk2?
>
>   This upstream uncrustify release was tagged in April (and I can't see
>   any more recent commits), so I assume it should be stable.
>
> - Would the version update require a whole-tree re-uncrustification?

Please, no. I didn't mind doing an initial reformatting at first, but
doing this continuously is both 1) problem-prone 2) just amazing
amounts of churn.
Let's say I have version N, you have version N+1 - we may never get
any final, formatted output as your version formats it differently
from mine.

I don't know how the CI is doing its thing atm (I haven't merged
anything myself to edk2), but the uncrustify check should be relaxed
to just a warning. There's nothing wrong with what my uncrustify
version is formatting to, there's nothing wrong with yours either, and
CI isn't necessarily wrong either.

And, to be fair, I already find uncrustify a large pain in the butt to
use (requiring a custom fork really does not help), but I find the
benefits worth it *locally*, as my coding style is also quite
different from the NT-esque style.

-- 
Pedro


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




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

2023-11-13 Thread Laszlo Ersek
On 11/13/23 07:22, Sheng Wei wrote:
> Patch V4:
>   Separate the changes to 5 patches.
> 1) Add macro definitions for CET feature for NASM files.
> 2) Use macro CR4_CET_BIT to replace hard code value in Cet.nasm.
> 3) Use CET macro definitions in Cet.inc for SmiEntry.nasm files.
> 4) Only change CR4.CET bit for enable/disable CET.
> 5) Backup and Restore MSR IA32_U_CET in SMI handler.
>   Remove some unused code.
> It is no need to clear MSR IA32_S_CET,
>  because clear CR4.CET bit will disable all CET functions.
> Since CET is disabled between clear CR4.CET and run 'rsm',
>  it is no need to delay MSR IA32_S_CET restoration.
> 
> Patch V3:
>   Remove the 3rd patch. mSmmInterruptSspTables is a global variable.
>   It is unnecessary to initializ it to zero manually.
> 
> Patch V2:
>   No function change with Patch V1.
>   Split the patch to into 3 separate patches.
> 
> Sheng Wei (5):
>   UefiCpuPkg: Add macro definitions for CET feature for NASM files.
>   UefiCpuPkg: Use macro CR4_CET_BIT to replace hard code value in
> Cet.nasm.
>   UefiCpuPkg: Use CET macro definitions in Cet.inc for SmiEntry.nasm
> files.
>   UefiCpuPkg: Only change CR4.CET bit for enable and disable CET.
>   UefiCpuPkg: Backup and Restore MSR IA32_U_CET in SMI handler.
> 
>  UefiCpuPkg/Include/Cet.inc   | 26 +
>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Cet.nasm  |  5 ++-
>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm | 39 +++
>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/Cet.nasm   |  5 ++-
>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm  | 40 +++-
>  5 files changed, 78 insertions(+), 37 deletions(-)
>  create mode 100644 UefiCpuPkg/Include/Cet.inc
> 

series
Reviewed-by: Laszlo Ersek 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#73): https://edk2.groups.io/g/devel/message/73
Mute This Topic: https://groups.io/mt/102556832/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 V4] UefiCpuPkg/MpInitLib: Enable execute disable bit.

2023-11-13 Thread Laszlo Ersek
On 11/13/23 06:59, Yuanhao Xie wrote:
> From: Yuanhao Xie 
>
> This patch synchronizes the No-Execute bit in the IA32_EFER
> register for the APs before the RestoreVolatileRegisters operation.
>
> The commit 964a4f0, titled "Eliminate the second INIT-SIPI-SIPI
> sequence," replaces the second INIT-SIPI-SIPI sequence with the BSP
> calling the SwitchApContext function to initiate a specialized start-up
> signal, waking up APs in the DXE instead of using INIT-SIPI-SIPI.
>
> Due to this change, the logic for "Enable execute disable bit" in
> MpFuncs.nasm is no longer executed. However, to ensure the proper setup
> of the page table, it is necessary to synchronize the IA32_EFER.NXE for
> APs before executing RestoreVolatileRegisters .
>
> Based on SDM:
> If IA32_EFER.NXE is set to 1, it signifies execute-disable, meaning
> instruction fetches are not allowed from the 4-KByte page controlled by
> this entry. Conversely, if it is set to 0, it is reserved.
>
> Signed-off-by: Yuanhao Xie 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 14 +++---
>  UefiCpuPkg/Library/MpInitLib/MpLib.h |  1 +
>  2 files changed, 12 insertions(+), 3 deletions(-)

Good problem description!

>
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 9a6ec5db5c..f29e66a14f 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -910,9 +910,16 @@ DxeApEntryPoint (
>CPU_MP_DATA  *CpuMpData
>)
>  {
> -  UINTN  ProcessorNumber;
> +  UINTN   ProcessorNumber;
> +  MSR_IA32_EFER_REGISTER  EferMsr;
>
>GetProcessorNumber (CpuMpData, );
> +  if (CpuMpData->EnableExecuteDisableForSwitchContext) {
> +EferMsr.Uint64   = AsmReadMsr64 (MSR_IA32_EFER);
> +EferMsr.Bits.NXE = 1;
> +AsmWriteMsr64 (MSR_IA32_EFER, EferMsr.Uint64);
> +  }
> +
>RestoreVolatileRegisters (>CpuData[0].VolatileRegisters, FALSE);
>InterlockedIncrement ((UINT32 *)>FinishedCount);
>PlaceAPInMwaitLoopOrRunLoop (
> @@ -2188,8 +2195,9 @@ MpInitLibInitialize (
>  if (MpHandOff->WaitLoopExecutionMode == sizeof (VOID *)) {
>ASSERT (CpuMpData->ApLoopMode != ApInHltLoop);
>
> -  CpuMpData->FinishedCount = 0;
> -  CpuMpData->InitFlag  = ApInitDone;
> +  CpuMpData->FinishedCount= 0;
> +  CpuMpData->InitFlag = ApInitDone;
> +  CpuMpData->EnableExecuteDisableForSwitchContext = 
> IsBspExecuteDisableEnabled ();
>SaveCpuMpData (CpuMpData);
>//
>// In scenarios where both the PEI and DXE phases run in the same
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h 
> b/UefiCpuPkg/Library/MpInitLib/MpLib.h
> index 763db4963d..af296f6ac0 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
> @@ -270,6 +270,7 @@ struct _CPU_MP_DATA {
>UINT64   TotalTime;
>EFI_EVENTWaitEvent;
>UINTN**FailedCpuList;
> +  BOOLEAN  EnableExecuteDisableForSwitchContext;
>
>AP_INIT_STATEInitFlag;
>BOOLEAN  SwitchBspFlag;

Functionally this patch seems fine.

(I cannot test it very usefully, because this code path is not active in
OVMF.)

However, there's one thing I think is less than ideal: after this patch,
we'll have

  MP_CPU_EXCHANGE_INFO . EnableExecuteDisable

but also

  MP_CPU_EXCHANGE_INFO . CpuMpData -> EnableExecuteDisableForSwitchContext

Furthermore, we'll have two invocations of IsBspExecuteDisableEnabled():

- once for the original (HLT loop + INIT-SIPI-SIPI) method, in
  WakeUpAP() -> FillExchangeInfoData(),

- and another time for the new method, in MpInitLibInitialize().

I feel that we should centralize this to one spot.

Note that in commit 629c1dacc9bd ("UefiCpuPkg: ApWakeupFunction directly
use CpuMpData.", 2023-07-11), you changed the prototype of
ApWakeupFunction(), such that it would take CpuMpData directly, rather
than MP_CPU_EXCHANGE_INFO. This was done so that in the next commit
(964a4f032dcd, "UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI
sequence.", 2023-07-11), you could invoke ApWakeupFunction() on *both*
paths, old and new:

- old (INIT-SIPI-SIPI): from the assembly language startup code,

- new: from DxeApEntryPoint().

Therefore, it seems that the *old* field
"MP_CPU_EXCHANGE_INFO.EnableExecuteDisable" is now superfluous. You have
effectively pushed it down to "CpuMpData", so that it's available in
DxeApEntryPoint().

But CpuMpData is similarly available in the assembly language startup
code (that's why you could implement commit 629c1dacc9bd).

So I think this patch is good, but it should be followed with a further
patch: can you please rebase the *old* startup code to the new CpuMpData
field "EnableExecuteDisableForSwitchContext", and then eliminate

[edk2-devel] [PATCH 2/2] RedfishPkg: RedfishDiscoverDxe: Optimize the Redfish Discover flow

2023-11-13 Thread Igor Kulchytskyy via groups.io
Filter out the network interfaces which are not supported by
Redfish Host Interface.

Cc: Abner Chang 
Cc: Nickle Wang 
Signed-off-by: Igor Kulchytskyy 
---
 .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 169 +-
 1 file changed, 120 insertions(+), 49 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 0f622e05a9..3d514d7e4c 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -13,6 +13,12 @@

 #include "RedfishDiscoverInternal.h"

+#define MAC_COMPARE(ThisNetworkInterface, TargetNetworkInterface)  (CompareMem 
((VOID *)>MacAddress, 
>MacAddress, ThisNetworkInterface->HwAddressSize))
+#define VALID_TCP6(TargetNetworkInterface, ThisNetworkInterface)   
(TargetNetworkInterface->IsIpv6 && (ThisNetworkInterface->NetworkProtocolType 
== ProtocolTypeTcp6))
+#define VALID_TCP4(TargetNetworkInterface, ThisNetworkInterface)   
(!TargetNetworkInterface->IsIpv6 && (ThisNetworkInterface->NetworkProtocolType 
== ProtocolTypeTcp4))
+#define IS_TCP4_MATCH(IpType)  
((gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp4) && (IpType != 
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4))
+#define IS_TCP6_MATCH(IpType)  
((gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp6) && (IpType != 
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6))
+
 LIST_ENTRY   mRedfishDiscoverList;
 LIST_ENTRY   mRedfishInstanceList;
 EFI_SMBIOS_PROTOCOL  *mSmbios = NULL;
@@ -322,9 +328,16 @@ GetTargetNetworkInterfaceInternal (
 {
   EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty ()) {
+return NULL;
+  }
+
   ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL 
*)GetFirstNode ();
   while (TRUE) {
-if (CompareMem ((VOID *)>MacAddress, 
>MacAddress, ThisNetworkInterface->HwAddressSize) == 0) 
{
+if ((MAC_COMPARE (ThisNetworkInterface, TargetNetworkInterface) == 0) &&
+(VALID_TCP6 (TargetNetworkInterface, ThisNetworkInterface) ||
+ VALID_TCP4 (TargetNetworkInterface, ThisNetworkInterface)))
+{
   return ThisNetworkInterface;
 }

@@ -354,6 +367,10 @@ GetTargetNetworkInterfaceInternalByController (
 {
   EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty ()) {
+return NULL;
+  }
+
   ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL 
*)GetFirstNode ();
   while (TRUE) {
 if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
@@ -476,6 +493,42 @@ CheckIsIpVersion6 (
   return FALSE;
 }

+/**
+  This function returns the  IP type supported by the Host Interface.
+
+  @retval 00h is Unknown
+  01h is Ipv4
+  02h is Ipv6
+
+**/
+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;
+}
+
 /**
   This function discover Redfish service through SMBIOS host interface.

@@ -512,6 +565,18 @@ DiscoverRedfishHostInterface (

   Status = RedfishGetHostInterfaceProtocolData (mSmbios, , 
); // Search for SMBIOS type 42h
   if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
+if ((Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4) 
&&
+(Data->HostIpAddressFormat != 
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4)) // IPv4 case
+{
+  DEBUG ((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface 
requires Ipv6\n", __func__));
+  return EFI_UNSUPPORTED;
+} else if ((Instance->NetworkInterface->NetworkProtocolType == 
ProtocolTypeTcp6) &&
+   (Data->HostIpAddressFormat != 
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6)) // IPv6 case
+{
+  DEBUG ((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface 
requires IPv4\n", __func__));
+  return EFI_UNSUPPORTED;
+}
+
 //
 // Check if we can reach out Redfish service using this network interface.
 // Check with MAC address using Device Descriptor Data Device Type 04 and 
Type 05.
@@ -1102,6 +1167,7 @@ RedfishServiceGetNetworkInterface (
   OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  **NetworkIntfInstances
   )
 {
+  

[edk2-devel] [PATCH 1/2] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx

2023-11-13 Thread Igor Kulchytskyy via groups.io
Supported function of the driver changed to wait for all network
interface to be installed.

Cc: Abner Chang 
Cc: Nickle Wang 
Signed-off-by: Igor Kulchytskyy 
---
 .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 31 ++-
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 23da3b968f..0f622e05a9 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -1547,25 +1547,26 @@ TestForRequiredProtocols (
 ControllerHandle,
 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
 );
+if (EFI_ERROR (Status)) {
+  return EFI_UNSUPPORTED;
+}
+
+Status = gBS->OpenProtocol (
+ControllerHandle,
+gRequiredProtocol[Index].DiscoveredProtocolGuid,
+(VOID **),
+This->DriverBindingHandle,
+ControllerHandle,
+EFI_OPEN_PROTOCOL_GET_PROTOCOL
+);
 if (!EFI_ERROR (Status)) {
-  Status = gBS->OpenProtocol (
-  ControllerHandle,
-  gRequiredProtocol[Index].DiscoveredProtocolGuid,
-  (VOID **),
-  This->DriverBindingHandle,
-  ControllerHandle,
-  EFI_OPEN_PROTOCOL_GET_PROTOCOL
-  );
-  if (EFI_ERROR (Status)) {
-if (Index == ListCount - 1) {
-  DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this 
controller handle: %p.\n", __func__, ControllerHandle));
-  return EFI_SUCCESS;
-}
-  }
+  // Already installed
+  return EFI_UNSUPPORTED;
 }
   }

-  return EFI_UNSUPPORTED;
+  DEBUG ((DEBUG_MANAGEABILITY, "%a: all required protocols are found on this 
controller handle: %p.\n", __func__, ControllerHandle));
+  return EFI_SUCCESS;
 }

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


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




[edk2-devel] [PATCH 0/2] Fix and optimize the issue if IPv4 installed after RestEx

2023-11-13 Thread Igor Kulchytskyy via groups.io
Igor Kulchytskyy (2):
  RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after
RestEx
  RedfishPkg: RedfishDiscoverDxe: Optimize the Redfish Discover flow

 .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 138 +-
 1 file changed, 105 insertions(+), 33 deletions(-)

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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69): https://edk2.groups.io/g/devel/message/69
Mute This Topic: https://groups.io/mt/102566299/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] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure all Aps in Present.

2023-11-13 Thread Laszlo Ersek
On 11/13/23 06:47, Yuanhao Xie wrote:
> SMM read save state requires AP must be present.
> This patch aim to avoid the AP not ready for save state check.
> 
> Signed-off-by: Zhihao Li 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 25 +
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 13 +
>  2 files changed, 38 insertions(+)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> index 391b64e9f2..cdc7021ee9 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> @@ -406,8 +406,15 @@ SmmCpuRendezvous (
>IN BOOLEANBlockingMode
>)
>  {
> +  UINTN   Index;
> +  UINTN   PresentCount;
> +  UINT32  BlockedCount;
> +  UINT32  DisabledCount;
>EFI_STATUS  Status;
>  
> +  BlockedCount  = 0;
> +  DisabledCount = 0;
> +
>//
>// Return success immediately if all CPUs are already synchronized.
>//
> @@ -426,6 +433,24 @@ SmmCpuRendezvous (
>  // There are some APs outside SMM, Wait for all avaiable APs to arrive.
>  //
>  SmmWaitForApArrival ();
> +
> +//
> +// Make sure all APs have their Present flag set
> +//
> +while (TRUE) {
> +  PresentCount = 0;
> +  for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
> +if (*(mSmmMpSyncData->CpuData[Index].Present)) {
> +  PresentCount++;
> +}
> +  }
> +
> +  GetSmmDelayedBlockedDisabledCount (NULL, , 
> );
> +  if (PresentCount == mMaxNumberOfCpus - BlockedCount - DisabledCount ) {
> +break;
> +  }
> +}
> +
>  Status = mSmmMpSyncData->AllApArrivedWithException ? EFI_SUCCESS : 
> EFI_TIMEOUT;
>} else {
>  //

(1) Here's why I don't like this:

we already have a function that is supposed to do this, and it is
SmmWaitForApArrival().

SmmWaitForApArrival() is called in two contexts. One, in BSPHandler().
Two, here.

Consider the following condition:

  (SyncMode == SmmCpuSyncModeTradition) ||
  SmmCpuFeaturesNeedConfigureMtrrs ()

If this condition evaluates to true, then BSPHandler() calls
SmmWaitForApArrival(), and SmmCpuRendezvous() doesn't.

(This is what the "else" branch in SmmCpuRendezvous() states, in a
comment, too.)

And if the condition evaluates to false, then SmmCpuRendezvous() calls
SmmWaitForApArrival(), and BSPHandler() doesn't.

This patch adds extra waiting logic to *one* of both call sites. And I
don't understand why the *other* call site (in BSPHandler()) does not
need the exact same logic.

In my opinion, this is a sign that SmmWaitForApArrival() isn't "strong
enough". It is not doing all of the work.

In my opinion, *both* call sites should receive this logic (i.e., ensure
that all AP's are "present"), but then in turn, the additional waiting /
checking should be pushed down into SmmWaitForApArrival().

What's your opinion on that?

(2) I notice that a similar "busy loop", waiting for Present flags, is
in BSPHandler().

Do you think we could call CpuPause() in all such "busy loops" (just
before the end of the "while" body)? I think that's supposed to improve
the system's throughput, considered as a whole. The function's comment says,

  Requests CPU to pause for a short period of time. Typically used in MP
  systems to prevent memory starvation while waiting for a spin lock.


Thanks
Laszlo





> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> index 20ada465c2..b5aa5f99d7 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> @@ -1552,6 +1552,19 @@ SmmWaitForApArrival (
>VOID
>);
>  
> +/**
> +  Returns the Number of SMM Delayed & Blocked & Disabled Thread Count.
> +  @param[in,out] DelayedCount  The Number of SMM Delayed Thread Count.
> +  @param[in,out] BlockedCount  The Number of SMM Blocked Thread Count.
> +  @param[in,out] DisabledCount The Number of SMM Disabled Thread Count.
> +**/
> +VOID
> +GetSmmDelayedBlockedDisabledCount (
> +  IN OUT UINT32  *DelayedCount,
> +  IN OUT UINT32  *BlockedCount,
> +  IN OUT UINT32  *DisabledCount
> +  );
> +
>  /**
>Write unprotect read-only pages if Cr0.Bits.WP is 1.
>  



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




Re: [edk2-devel] [PATCH v3 2/2] MdeModulePkg/Bus/Pci/XhciDxe: Fix MISSING_BREAK Coverity issues

2023-11-13 Thread Laszlo Ersek
On 11/10/23 06:22, Ranbir Singh wrote:
> From: Ranbir Singh 
> 
> The functions
> XhcInitializeEndpointContext and XhcInitializeEndpointContext64 has
> a switch-case code in which the case USB_ENDPOINT_CONTROL: falls
> through to default:
> 
> While this may be intentional, it may not be evident to any general code
> reader/developer or static analyis tool why there is no break in between.
> 
> Merge the USB_ENDPOINT_CONTROL and default using conditional debug print.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4221
> 
> Cc: Ray Ni 
> Signed-off-by: Ranbir Singh 
> ---
>  MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 33 +++-
>  1 file changed, 19 insertions(+), 14 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c 
> b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> index 05528a478baf..00b3a13a95bb 100644
> --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> @@ -2825,6 +2825,7 @@ XhcInitializeEndpointContext (
>UINTNNumEp;
>UINTNEpIndex;
>UINT8EpAddr;
> +  UINT8EpType;
>UINT8Direction;
>UINT8Dci;
>UINT8MaxDci;
> @@ -2871,7 +2872,8 @@ XhcInitializeEndpointContext (
>InputContext->EP[Dci-1].MaxBurstSize = 0x0;
>  }
>  
> -switch (EpDesc->Attributes & USB_ENDPOINT_TYPE_MASK) {
> +EpType = EpDesc->Attributes & USB_ENDPOINT_TYPE_MASK;
> +switch (EpType) {
>case USB_ENDPOINT_BULK:
>  if (Direction == EfiUsbDataIn) {
>InputContext->EP[Dci-1].CErr   = 3;
> @@ -2974,13 +2976,13 @@ XhcInitializeEndpointContext (
>  
>  break;
>  
> -  case USB_ENDPOINT_CONTROL:
> -//
> -// Do not support control transfer now.
> -//
> -DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext: Unsupport Control 
> EP found, Transfer ring is not allocated.\n"));
>default:
> -DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext: Unknown EP found, 
> Transfer ring is not allocated.\n"));
> +DEBUG ((
> +  DEBUG_INFO,
> +  "%a: %a found, Transfer ring is not allocated.\n",
> +  __func__,
> +  (EpType == USB_ENDPOINT_CONTROL ? "Unsupported Control EP" : 
> "Unknown EP")
> +  ));
>  EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length);
>  continue;
>  }
> @@ -3028,6 +3030,7 @@ XhcInitializeEndpointContext64 (
>UINTNNumEp;
>UINTNEpIndex;
>UINT8EpAddr;
> +  UINT8EpType;
>UINT8Direction;
>UINT8Dci;
>UINT8MaxDci;
> @@ -3074,7 +3077,8 @@ XhcInitializeEndpointContext64 (
>InputContext->EP[Dci-1].MaxBurstSize = 0x0;
>  }
>  
> -switch (EpDesc->Attributes & USB_ENDPOINT_TYPE_MASK) {
> +EpType = EpDesc->Attributes & USB_ENDPOINT_TYPE_MASK;
> +switch (EpType) {
>case USB_ENDPOINT_BULK:
>  if (Direction == EfiUsbDataIn) {
>InputContext->EP[Dci-1].CErr   = 3;
> @@ -3177,13 +3181,14 @@ XhcInitializeEndpointContext64 (
>  
>  break;
>  
> -  case USB_ENDPOINT_CONTROL:
> -//
> -// Do not support control transfer now.
> -//
> -DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext64: Unsupport 
> Control EP found, Transfer ring is not allocated.\n"));
>default:
> -DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext64: Unknown EP 
> found, Transfer ring is not allocated.\n"));
> +DEBUG ((
> +  DEBUG_INFO,
> +  "%a: %a found, Transfer ring is not allocated.\n",
> +  __func__,
> +  ((EpType == USB_ENDPOINT_CONTROL) ? "Unsupported Control EP" : 
> "Unknown EP")
> +  ));
> +
>  EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length);
>  continue;
>  }

Reviewed-by: Laszlo Ersek 



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




Re: [edk2-devel] [PATCH v3 1/2] MdeModulePkg/Bus/Pci/XhciDxe: Fix FORWARD_NULL Coverity issues

2023-11-13 Thread Laszlo Ersek
On 11/10/23 06:22, Ranbir Singh wrote:
> From: Ranbir Singh 
> 
> The functions UsbHcGetHostAddrForPciAddr, UsbHcGetPciAddrForHostAddr
> and UsbHcFreeMem do have
> 
> ASSERT ((Block != NULL));
> 
> statements after for loop, but these are applicable only in DEBUG mode.
> In RELEASE mode, if for whatever reasons there is no match inside for
> loop and the loop exits because of Block != NULL; condition, then there
> is no "Block" NULL pointer check afterwards and the code proceeds to do
> dereferencing "Block" which will lead to CRASH.
> 
> Hence, for safety add NULL pointer checks always.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4221
> 
> Cc: Ray Ni 
> Co-authored-by: Veeresh Sangolli 
> Signed-off-by: Ranbir Singh 
> Signed-off-by: Ranbir Singh 
> ---
>  MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c | 29 
>  1 file changed, 29 insertions(+)
> 
> diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c 
> b/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c
> index b54187ec228e..597cbe4646e8 100644
> --- a/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c
> +++ b/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c
> @@ -267,6 +267,16 @@ UsbHcGetPciAddrForHostAddr (
>}
>  
>ASSERT ((Block != NULL));
> +
> +  if (Block == NULL) {
> +//
> +// Should never be here
> +//
> +DEBUG ((DEBUG_ERROR, "UsbHcGetPciAddrForHostAddr: Invalid host memory 
> pointer passed\n"));
> +CpuDeadLoop ();
> +return 0;
> +  }
> +
>//
>// calculate the pci memory address for host memory address.
>//
> @@ -322,6 +332,16 @@ UsbHcGetHostAddrForPciAddr (
>}
>  
>ASSERT ((Block != NULL));
> +
> +  if (Block == NULL) {
> +//
> +// Should never be here
> +//
> +DEBUG ((DEBUG_ERROR, "UsbHcGetHostAddrForPciAddr: Invalid pci memory 
> pointer passed\n"));
> +CpuDeadLoop ();
> +return 0;
> +  }
> +
>//
>// calculate the pci memory address for host memory address.
>//
> @@ -603,6 +623,15 @@ UsbHcFreeMem (
>//
>ASSERT (Block != NULL);
>  
> +  if (Block == NULL) {
> +//
> +// Should never be here
> +//
> +DEBUG ((DEBUG_ERROR, "UsbHcFreeMem: Invalid memory pointer passed\n"));
> +CpuDeadLoop ();
> +return;
> +  }
> +
>//
>// Release the current memory block if it is empty and not the head
>//

Reviewed-by: Laszlo Ersek 



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




Re: [edk2-devel] [PATCH v3 2/2] MdeModulePkg/Bus/Pci/PciHostBridgeDxe: Fix MISSING_BREAK Coverity issue

2023-11-13 Thread Laszlo Ersek
On 11/9/23 18:39, Ranbir Singh wrote:
> From: Ranbir Singh 
>
> The function SubmitResources has a switch-case code in which the
> case ACPI_ADDRESS_SPACE_TYPE_MEM: which falls through to
> case ACPI_ADDRESS_SPACE_TYPE_IO: to include additional common check.
>
> While this may be intentional, it may not be evident to any general code
> reader/developer or static analyis tool why there is no break in between.
>
> SubmitResources function is supposed to handle only Mem or IO resources.
> So, update the ResType parameter check reflecting that and re-model the
> switch-case code in contention using just one if condition to further
> handle other parameter checks specific to ACPI_ADDRESS_SPACE_TYPE_MEM.
> This leads to mostly indentation level code changes. Few ASSERT's later
> present are henceforth not required.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4212
>
> Cc: Ray Ni 
> Signed-off-by: Ranbir Singh 
> ---
>  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 60 
> +---
>  1 file changed, 26 insertions(+), 34 deletions(-)

I have applied this patch locally, and displayed it with

  git show -W -b

Let me make comments on that:

>  /**
>
>Submits the I/O and memory resource requirements for the specified PCI 
> Root Bridge.
>
>@param This  The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ 
> PROTOCOL instance.
> -  @param RootBridgeHandle  The PCI Root Bridge whose I/O and memory resource 
> requirements.
> +  @param RootBridgeHandle  The PCI Root Bridge whose I/O and memory resource 
> requirements
> are being submitted.
>@param Configuration The pointer to the PCI I/O and PCI memory 
> resource descriptor.
>
>@retval EFI_SUCCESSSucceed.
>@retval EFI_INVALID_PARAMETER  Wrong parameters passed in.
>  **/
> @@ -1460,137 +1460,129 @@ EFIAPI
>  SubmitResources (
>IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  *This,
>IN EFI_HANDLERootBridgeHandle,
>IN VOID  *Configuration
>)
>  {
>LIST_ENTRY *Link;
>PCI_HOST_BRIDGE_INSTANCE   *HostBridge;
>PCI_ROOT_BRIDGE_INSTANCE   *RootBridge;
>EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  *Descriptor;
>PCI_RESOURCE_TYPE  Type;
>
>//
>// Check the input parameter: Configuration
>//
>if (Configuration == NULL) {
>  return EFI_INVALID_PARAMETER;
>}
>
>HostBridge = PCI_HOST_BRIDGE_FROM_THIS (This);
>for (Link = GetFirstNode (>RootBridges)
> ; !IsNull (>RootBridges, Link)
> ; Link = GetNextNode (>RootBridges, Link)
> )
>{
>  RootBridge = ROOT_BRIDGE_FROM_LINK (Link);
>  if (RootBridgeHandle == RootBridge->Handle) {
>DEBUG ((DEBUG_INFO, "PciHostBridge: SubmitResources for %s\n", 
> RootBridge->DevicePathStr));
>//
>// Check the resource descriptors.
>// If the Configuration includes one or more invalid resource 
> descriptors, all the resource
>// descriptors are ignored and the function returns 
> EFI_INVALID_PARAMETER.
>//
>for (Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Configuration; 
> Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
> -if (Descriptor->ResType > ACPI_ADDRESS_SPACE_TYPE_BUS) {
> +if ((Descriptor->ResType != ACPI_ADDRESS_SPACE_TYPE_MEM) && 
> (Descriptor->ResType != ACPI_ADDRESS_SPACE_TYPE_IO)) {
>return EFI_INVALID_PARAMETER;
>  }

This is a slight logic change.

Previously, the code did the following:

- Any resource types that were different from MEM, IO, and BUS, would be
  rejected with EFI_INVALID_PARAMETER.

- MEM and IO would be handled.

- BUS resource types would trigger an ASSERT().

In effect, the code claimed that BUS resource types were *impossible*
here, due to prior filtering or whatever.

The logic change is that now we reject BUS resource types explicitly.

I think that's not ideal. Here's why:

- If the preexistent ASSERT() about BUS resource types being impossible
  was right, then now we are occluding that fact, and pretending /
  suggesting that BUS types are something we *should* handle. This
  creates a confusion about data flow.

- If the preexistent ASSERT() about BUS resource types being impossible
  was wrong (i.e., dependent on input data, we could actuall trigger the
  ASSERT()), then this change is very welcome, but *then* it is a bugfix
  in its own right! And therefore should be documented separately.

Anyway. I'm getting exhausted.

>
>  DEBUG ((
>DEBUG_INFO,
>" %s: Granularity/SpecificFlag = %ld / %02x%s\n",
>mAcpiAddressSpaceTypeStr[Descriptor->ResType],
>Descriptor->AddrSpaceGranularity,
>Descriptor->SpecificFlag,
>(Descriptor->SpecificFlag & 
> 

Re: [edk2-devel] [PATCH v3 1/2] MdeModulePkg/Bus/Pci/PciHostBridgeDxe: Fix OVERRUN Coverity issues

2023-11-13 Thread Laszlo Ersek
On 11/10/23 05:07, Ranbir Singh wrote:
> Options before us till now -
> 
> 1. Add array overrun check and Debug statement before CpuDeadLoop within

This would be useless.

Your current patch implements the following pattern:

  ASSERT (X);
  if (!X) {
CpuDeadLoop ();
  }

Option#1 would mean

  ASSERT (X);
  if (!X) {
DEBUG ((DEBUG_ERROR, "%a: condition X failed\n", __func__));
CpuDeadLoop ();
  }

Now compare the behavior of both code snippets.

- In DEBUG and NOOPT builds, if X evaluated to FALSE, then the ASSERT()
would fire. A DEBUG_ERROR message would be logged, including "X", the
file name, and the line number. ASSERT() would then enter CpuDeadLoop()
internally, or invoke CpuBreakpoint() -- dependent on platform PCD
configuration. This applies to both snippets. In particular, the
explicit DEBUG and CpuDeadLoop() would not be reached, in the second
snippet. In other words, in DEBUG and NOOPT builds, the difference is
unobservable.

- In RELEASE builds, the ASSERT() is compiled out of both snippets.
Furthermore, the explicit DEBUG is compiled out of the second snippet.
That is, both code snippets would silently enter CpuDeadLoop(). In other
words, the behavior of both snippets is undistinguishable in RELEASE
builds too.

In my opinion, the current patch is right.

Reviewed-by: Laszlo Ersek 


To elaborate on that more generally:

Core edk2 code has so consistently and so broadly *abused* and *misused*
ASSERT() for error checking, that now we fail to recognize an *actual
valid use* of ASSERT() for what it is. For illustration, compare the
following two code snippets:

(a)

  UINTN Val;

  Val = 1 + 2;
  ASSERT (Val == 3);

(b)

  VOID *Ptr;

  Ptr = AllocatePool (1024);
  ASSERT (Ptr != NULL);

Snippet (a) is a *valid* use of an assert. It encapsulates a logical
predicate about the program's state, based on algorithmic and
mathematical reasoning. If the predicate turns out not to hold in
practice, at runtime,that means the programmer has retroactively caught
an issue in their own thinking, the algorithm is incorrectly designed or
implemented, and the program's state is effectively unknown at this
point (the internal invariant in question is broken), and so we must
stop immediately, because we don't know what the program is going to do
next. Given that what we thought about the program *thus far* has now
turned out to be false.

Snippet (b) is an abuse of assert. AllocatePool()'s result depends on
the environment. Available memory, input data seen from the user or the
disk or the network thus far, and a bunch of other things not under our
control. Therefore, we must explicitly deal with AllocatePool() failing.
Claiming that AllocatePool() will succeed is wrong because we generally
cannot even *attempt* to prove it.

In case (a) however, we can actually make a plausible attempt at
*proving* the predicate. The assert is there just in case our proof is
wrong.

There's an immense difference between situations (a) and (b). I cannot
emphasize that enough. Case (a) is a provable statement about the
behavior of an algorithm. Case (b) is a *guess* at input data and
environment.

The problem with edk2 core is that it has so consistently abused
ASSERT() for case (b) that now, when we occasionally see a *valid
instance* of (a), we mistake it for (b).

That's the case here. The ASSERT() seen in this patch is case (a). It's
just that Coverity cannot prove it itself, because the predicate we
assert is much more complicated than (1 + 2 == 3). But that doesn't
change the fact that we have a proof for the invariant in question.

Therefore, the solution is not to try to handle an impossible error
gracefully. The solution is two-fold:

- Tell coverity that we have a proof, in terms that it understands, to
shut it up. The terminology for this is CpuDeadLoop(). We're willing to
hang at runtime even in RELEASE builds, if the condition fails.

- If, at runtime, our proof turns out to be wrong indeed, then we must
stop immediately (because if 1+2 stops equalling 3, then we can't trust
*anything else* that our program would do).

(The more generic corollary of my last point, by the way, is that
ASSERT()s should NEVER be compiled out of programs. And if we actually
did that, like many other projects do, then this Coverity warning
wouldn't even exist, in the first place, because Coverity would *always*
see -- with the ASSERT() being there in all builds -- a range check on
Index.

Put differently, having to add a CpuDeadLoop() explicitly is just
"damage control" for the self-inflicted damage of compiling out ASSERTs.)

Laszlo



> 2. Status Quo (not everything can be ideal :-))
> 
> Question before us
>      - Is 1 better than 2 ?
> 
> 
> On Fri, Nov 10, 2023 at 8:41 AM Ranbir Singh  > wrote:
> 
> As far as I know, from a secure coding perspective, it would be
> recommended that array overrun condition check is captured in the
> code even if it is felt that it will never hit.

Re: [edk2-devel] [PATCH v3 1/2] MdeModulePkg/Bus/Pci/PciHostBridgeDxe: Fix OVERRUN Coverity issues

2023-11-13 Thread Laszlo Ersek
On 11/9/23 21:40, Michael D Kinney wrote:
> Hi Ranbir,
> 
> A deadloop without even a debug print is not good behavior.

In DEBUG and NOOPT builds, the ASSERT() would fire, hence providing a
debug message.

In RELEASE builds, even if there were a separate DEBUG message, the
DEBUG would be compiled out.

> 
> If this condition really represents a condition where it is not possible
> to complete the PCI resource allocation/assignment, then an error status
> code should be returned to the caller of NotifyPhase().

That's not the case here. This ASSERT() really cannot fire:

  https://edk2.groups.io/g/devel/message/110856

In other words, it is a *true* genuine assertion.

It's only that Coverity cannot see that.

Thus the idea here is to tell Coverity that we're willing to hang even
in RELEASE builds. That hang will never ever occur (it can't), but by
adding the explicit CpuDeadLoop(), we can placate Coverity (hopefully).

Put differently: if we had an ASSERT() variant that could not be
compiled out of RELEASE builds, then we'd use that variant here.

Laszlo

> Perhaps
> EFI_OUT_OF_RESOURCES.  The other ASSERT() conditions in this API should
> likely be updated to do the same.
> 
> This may also require the caller of this service, the PCI Bus Driver,
> to be reviewed to make sure it handles error conditions from NotifyPhase().
> 
> I recommend you get help on the proposed code changes from the PCI
> subsystem maintainers.
> 
> Thanks,
> 
> Mike
> 
> 
> 
>> -Original Message-
>> From: devel@edk2.groups.io  On Behalf Of Ranbir
>> Singh
>> Sent: Thursday, November 9, 2023 9:39 AM
>> To: devel@edk2.groups.io; rsi...@ventanamicro.com
>> Cc: Ni, Ray ; Veeresh Sangolli
>> 
>> Subject: [edk2-devel] [PATCH v3 1/2]
>> MdeModulePkg/Bus/Pci/PciHostBridgeDxe: Fix OVERRUN Coverity issues
>>
>> From: Ranbir Singh 
>>
>> The function NotifyPhase has a check
>>
>> ASSERT (Index < TypeMax);
>>
>> but this comes into play only in DEBUG mode. In Release mode, there is
>> no handling if the Index value is within array limits or not. If for
>> whatever reasons, the Index does not get re-assigned to Index2 at line
>> 937, then it remains at TypeMax as assigned earlier at line 929. This
>> poses array overrun risk at lines 942 and 943. It is better to deploy
>> a safety check on Index limit before accessing array elements.
>>
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4212
>>
>> Cc: Ray Ni 
>> Co-authored-by: Veeresh Sangolli 
>> Signed-off-by: Ranbir Singh 
>> Signed-off-by: Ranbir Singh 
>> ---
>>  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 5 +
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
>> b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
>> index d573e532bac8..c2c143068cd2 100644
>> --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
>> +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
>> @@ -939,6 +939,11 @@ NotifyPhase (
>>  }
>>
>>
>>
>>  ASSERT (Index < TypeMax);
>>
>> +
>>
>> +if (Index == TypeMax) {
>>
>> +  CpuDeadLoop ();
>>
>> +}
>>
>> +
>>
>>  ResNodeHandled[Index] = TRUE;
>>
>>  Alignment = RootBridge-
>>> ResAllocNode[Index].Alignment;
>>
>>  BitsOfAlignment   = LowBitSet64 (Alignment + 1);
>>
>> --
>> 2.34.1
>>
>>
>>
>> -=-=-=-=-=-=
>> Groups.io Links: You receive all messages sent to this group.
>> View/Reply Online (#110993):
>> https://edk2.groups.io/g/devel/message/110993
>> Mute This Topic: https://groups.io/mt/102490513/1643496
>> Group Owner: devel+ow...@edk2.groups.io
>> Unsubscribe: https://edk2.groups.io/g/devel/unsub
>> [michael.d.kin...@intel.com]
>> -=-=-=-=-=-=
>>
> 
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH v1] UefiCpuPkg/PiSmmCpuDxeSmm: Use processor extended information

2023-11-13 Thread Laszlo Ersek
On 11/13/23 16:38, Laszlo Ersek wrote:
> On 11/7/23 03:43, Wu, Jiaxin wrote:
>> Processor extended information is filled when
>> CPU_V2_EXTENDED_TOPOLOGY is set in parameter ProcessorNumber
>> from GetProcessorInfo() (See commit: 1fadd18d).
>>
>> This filed value is retrieved from CPUID leaf 1FH, which is
>> a preferred superset to leaf 0BH.
>>
>> Since Intel recommends first use the CPUID leaf 1FH instead of
>> leaf 0BH, this patch change to use the processor extended
>> information, which can reflect the value from CPUID leaf 1FH.
>>
>> Cc: Eric Dong 
>> Cc: Ray Ni 
>> Cc: Rahul Kumar 
>> Cc: Gerd Hoffmann 
>> Cc: Star Zeng 
>> Signed-off-by: Jiaxin Wu 
>> ---
>>  UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 10 ++
>>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  |  6 +++---
>>  2 files changed, 13 insertions(+), 3 deletions(-)
>>
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c 
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
>> index 391b64e9f2..c0485b0519 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
>> @@ -169,10 +169,20 @@ SmmAddProcessor (
>>  >ProcessorInfo[Index].Location.Package,
>>  >ProcessorInfo[Index].Location.Core,
>>  >ProcessorInfo[Index].Location.Thread
>>  );
>>  
>> +  GetProcessorLocation2ByApicId (
>> +(UINT32)ProcessorId,
>> +
>> >ProcessorInfo[Index].ExtendedInformation.Location2.Package,
>> +
>> >ProcessorInfo[Index].ExtendedInformation.Location2.Die,
>> +
>> >ProcessorInfo[Index].ExtendedInformation.Location2.Tile,
>> +
>> >ProcessorInfo[Index].ExtendedInformation.Location2.Module,
>> +
>> >ProcessorInfo[Index].ExtendedInformation.Location2.Core,
>> +
>> >ProcessorInfo[Index].ExtendedInformation.Location2.Thread
>> +);
>> +
>>*ProcessorNumber = Index;
>>gSmmCpuPrivate->Operation[Index] = SmmCpuAdd;
>>return EFI_SUCCESS;
>>  }
>>}
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> index 25d058c5b9..c61562c867 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> @@ -177,11 +177,11 @@ IsPackageFirstThread (
>>IN UINTN  CpuIndex
>>)
>>  {
>>UINT32  PackageIndex;
>>  
>> -  PackageIndex =  gSmmCpuPrivate->ProcessorInfo[CpuIndex].Location.Package;
>> +  PackageIndex =  
>> gSmmCpuPrivate->ProcessorInfo[CpuIndex].ExtendedInformation.Location2.Package;
>>  
>>ASSERT (mPackageFirstThreadIndex != NULL);
>>  
>>//
>>// Set the value of mPackageFirstThreadIndex[PackageIndex].
>> @@ -1834,12 +1834,12 @@ InitPackageFirstThreadIndexInfo (
>>  
>>//
>>// Count the number of package, set to max PackageId + 1
>>//
>>for (Index = 0; Index < mNumberOfCpus; Index++) {
>> -if (PackageId < gSmmCpuPrivate->ProcessorInfo[Index].Location.Package) {
>> -  PackageId = gSmmCpuPrivate->ProcessorInfo[Index].Location.Package;
>> +if (PackageId < 
>> gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Location2.Package) {
>> +  PackageId = 
>> gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Location2.Package;
>>  }
>>}
>>  
>>PackageCount = PackageId + 1;
>>  
> 
> Regression-tested-by: Laszlo Ersek 
> 

also

Reviewed-by: Laszlo Ersek 



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




Re: [edk2-devel] [PATCH v1] UefiCpuPkg/PiSmmCpuDxeSmm: Use processor extended information

2023-11-13 Thread Laszlo Ersek
On 11/7/23 03:43, Wu, Jiaxin wrote:
> Processor extended information is filled when
> CPU_V2_EXTENDED_TOPOLOGY is set in parameter ProcessorNumber
> from GetProcessorInfo() (See commit: 1fadd18d).
> 
> This filed value is retrieved from CPUID leaf 1FH, which is
> a preferred superset to leaf 0BH.
> 
> Since Intel recommends first use the CPUID leaf 1FH instead of
> leaf 0BH, this patch change to use the processor extended
> information, which can reflect the value from CPUID leaf 1FH.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Cc: Star Zeng 
> Signed-off-by: Jiaxin Wu 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 10 ++
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  |  6 +++---
>  2 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> index 391b64e9f2..c0485b0519 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> @@ -169,10 +169,20 @@ SmmAddProcessor (
>  >ProcessorInfo[Index].Location.Package,
>  >ProcessorInfo[Index].Location.Core,
>  >ProcessorInfo[Index].Location.Thread
>  );
>  
> +  GetProcessorLocation2ByApicId (
> +(UINT32)ProcessorId,
> +
> >ProcessorInfo[Index].ExtendedInformation.Location2.Package,
> +
> >ProcessorInfo[Index].ExtendedInformation.Location2.Die,
> +
> >ProcessorInfo[Index].ExtendedInformation.Location2.Tile,
> +
> >ProcessorInfo[Index].ExtendedInformation.Location2.Module,
> +
> >ProcessorInfo[Index].ExtendedInformation.Location2.Core,
> +
> >ProcessorInfo[Index].ExtendedInformation.Location2.Thread
> +);
> +
>*ProcessorNumber = Index;
>gSmmCpuPrivate->Operation[Index] = SmmCpuAdd;
>return EFI_SUCCESS;
>  }
>}
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index 25d058c5b9..c61562c867 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -177,11 +177,11 @@ IsPackageFirstThread (
>IN UINTN  CpuIndex
>)
>  {
>UINT32  PackageIndex;
>  
> -  PackageIndex =  gSmmCpuPrivate->ProcessorInfo[CpuIndex].Location.Package;
> +  PackageIndex =  
> gSmmCpuPrivate->ProcessorInfo[CpuIndex].ExtendedInformation.Location2.Package;
>  
>ASSERT (mPackageFirstThreadIndex != NULL);
>  
>//
>// Set the value of mPackageFirstThreadIndex[PackageIndex].
> @@ -1834,12 +1834,12 @@ InitPackageFirstThreadIndexInfo (
>  
>//
>// Count the number of package, set to max PackageId + 1
>//
>for (Index = 0; Index < mNumberOfCpus; Index++) {
> -if (PackageId < gSmmCpuPrivate->ProcessorInfo[Index].Location.Package) {
> -  PackageId = gSmmCpuPrivate->ProcessorInfo[Index].Location.Package;
> +if (PackageId < 
> gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Location2.Package) {
> +  PackageId = 
> gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Location2.Package;
>  }
>}
>  
>PackageCount = PackageId + 1;
>  

Regression-tested-by: Laszlo Ersek 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#61): https://edk2.groups.io/g/devel/message/61
Mute This Topic: https://groups.io/mt/102436095/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] IntelFsp2Pkg/FspMultiPhaseLib: Remove EFIAPI for local function

2023-11-13 Thread Kuo, Ted
Reviewed-by: Kuo, Ted 

Thanks,
Ted

-Original Message-
From: S, Ashraf Ali  
Sent: Monday, November 13, 2023 4:12 PM
To: Ni, Ray ; devel@edk2.groups.io
Cc: Chiu, Chasel ; Desimone, Nathaniel L 
; Duggapu, Chinni B 
; Ng, Ray Han Lim ; Zeng, 
Star ; Kuo, Ted ; Mohapatra, Susovan 

Subject: RE: [PATCH] IntelFsp2Pkg/FspMultiPhaseLib: Remove EFIAPI for local 
function

Reviewed-by: S, Ashraf Ali 

Thanks.,
S, Ashraf Ali

-Original Message-
From: Ni, Ray  
Sent: Monday, November 13, 2023 1:09 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel ; Desimone, Nathaniel L 
; Duggapu, Chinni B 
; Ng, Ray Han Lim ; Zeng, 
Star ; Kuo, Ted ; S, Ashraf Ali 
; Mohapatra, Susovan 
Subject: [PATCH] IntelFsp2Pkg/FspMultiPhaseLib: Remove EFIAPI for local function

FspMultiPhaseWorker() is a local function that's called from
FspMultiPhaseMemInitApiHandler()
and FspMultiPhaseSiInitApiHandlerV2().

Remove "EFIAPI" from its function header.

Signed-off-by: Ray Ni 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Duggapu Chinni B 
Cc: Ray Han Lim Ng 
Cc: Star Zeng 
Cc: Ted Kuo 
Cc: Ashraf Ali S 
Cc: Susovan Mohapatra 
---
 IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c 
b/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c
index 3786da91b1..4fc4104226 100644
--- a/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c
+++ b/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c
@@ -1,7 +1,7 @@
 /** @file

   FSP MultiPhase library.

 

-  Copyright (c) 2022, Intel Corporation. All rights reserved.

+  Copyright (c) 2022 - 2023, Intel Corporation. All rights reserved.

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

 

 **/

@@ -58,7 +58,6 @@ FspVariableRequestSwitchStack (
   @retval EFI_DEVICE_ERRORFSP initialization failed.

 **/

 EFI_STATUS

-EFIAPI

 FspMultiPhaseWorker (

   IN UINT32  ApiIdx,

   IN VOID*ApiParam

-- 
2.39.1.windows.1



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




[edk2-devel][edk2-staging] DeviceSimPkg branch creation

2023-11-13 Thread Maciej Czajkowski
Hello,

I would like to announce DeviceSimPkg branch creation in edk2-staging 
repository.
Branch will be used to develop DeviceSimPkg, a package for developing OS 
executable tests
for device focused code.

Branch owner: Maciej Czajkowski , GitHub ID: 
81293748 (https://github.com/mczaj)

Signed-off-by: Maciej Czajkowski 
Cc: Michael D Kinney 
---
 Readme.md | 37 +
 1 file changed, 37 insertions(+)
 create mode 100644 Readme.md

diff --git a/Readme.md b/Readme.md
new file mode 100644
index ..96077d0a478c
--- /dev/null
+++ b/Readme.md
@@ -0,0 +1,37 @@
+# DeviceSimPkg
+
+## Introduction
+
+DeviceSimPkg is a package aimed at providing an environment to write 
OS-executable unit tests for code that interacts directly with devices.
+This code is referred to as driver code below although code under test doesn't 
have to follow UEFI driver model. \
+Branch owner: Maciej Czajkowski <>
+
+## How to use it
+### Using the code
+
+You can refer to UnitTest modules to see the usage details. In general you 
will need to link to package libraries (instead of the ones normally provided 
by MdePkg/MdeModulePkg) and initialize your device access. Details of 
initialization will vary based on which REGISTER_ACCESS_INTERFACE implementer 
library you will
+choose. Please refer to corresponding libraries Readmes for details.
+
+## General architecture
+
+On high-level package consists of:
+
+* REGISTER_ACCESS_INTERFACE - interface between device model and driver code
+* REGISTER_ACCESS_INTERFACE wrappers - libraries that wrap 
REGISTER_ACCESS_INTERFACE and present it as a standard UEFI library
+* REGISTER_ACCESS_INTERFACE implementers - libraries that implement 
REGISTER_ACCESS_INTERFACE interface
+
+## Wrapper libraries
+
+Currently package implements following wrappers:
+
+* IoLib in 
[RegisterAccessIoLib](DeviceSimPkg/Library/RegisterAccessIoLib/Readme.md)
+* PciSegmentLib in RegisterAccessPciSegmentLib
+* PCI_IO_PROTOCOL in RegisterAccessPciIoLib
+
+## REGISTER_ACCESS_INTERFACE implementations
+
+Currently only a single implementation is fully supported - 
FakeRegisterSpaceLib. Please see its Readme for more details on how to use it.
+
+## GMOCK support
+
+DeviceSim implements Gmock based mock object for the IoLib functions. Please 
see GmockIoLib [Readme](DeviceSimPkg/Library/MockIoLib//Readme.md) for details.
-- 
2.39.1.windows.1

-
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial 
Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | 
Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z 
dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach 
handlowych.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i 
moze zawierac informacje poufne. W razie przypadkowego otrzymania tej 
wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; 
jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole 
use of the intended recipient(s). If you are not the intended recipient, please 
contact the sender and delete all copies; any review or distribution by others 
is strictly prohibited.


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




Re: [edk2-devel] [PATCH v1 1/1] Bug 2861 - HiiDatabaseDxe, ConfigRouting.c, GetElementsFromRequest incorrect error handling.

2023-11-13 Thread Laszlo Ersek
Hi Charles,

On 10/26/23 03:05, Charles Hyde wrote:
> From: Charles Hyde 
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2861
> 
> I believe the attached ConfigRouting.txt patch will resolve bug 2861, plus
> resolve an uninitialized pointer issue in HiiConfigRoutingExportConfig().
> The uninitialized pointer was identified when running the EDK2 Self
> Certification Test with all tests selected, having caused the CPU to issue
> an exception error (most times) or completely trashed the system
> (sometimes).
> 
> I found a second instance of GetElementsFromRequest(), located in HiiLib.c,
> that also needed an update.  The attached patch should address this bug and
> more.
> 
> Signed-off-by: Charles Hyde 
> ---

Thanks for analyzing and fixing these bugs.

Can you please split the separate fixes to separate patches?

Also, the patch looks garbled; it shouldn't be attached / pasted but
sent with git-send-email. Are you familiar with git-send-email?

Here's the official docs:

https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Development-Process

and some unofficial tips:

https://github.com/tianocore/tianocore.github.io/wiki/Laszlo's-unkempt-git-guide-for-edk2-contributors-and-maintainers

Third, I suggest not to comment out, with /* */, dead code (such as a
subcondition that always evaluates to false or true); instead, remove
it, and explain in the commit message (or, if necessary, in a code
comment) why that condition is a tautology. If the condition or argument
is nontrivial, consider using an ASSERT().

Laszlo


> 
> diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
> b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
> index 63a37ab59a..c3dc7bf558 100644
> --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
> +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
> @@ -2272,8 +2272,14 @@ GetElementsFromRequest (
> {
>   EFI_STRING  TmpRequest;
> 
> +  ASSERT (ConfigRequest != NULL);
> +  if (ConfigRequest == NULL)
> +    return FALSE;
> +
>   TmpRequest = StrStr (ConfigRequest, L"PATH=");
>   ASSERT (TmpRequest != NULL);
> +  if (TmpRequest == NULL)
> +    return FALSE;
> 
>   if ((StrStr (TmpRequest, L"=") != NULL) || (StrStr (TmpRequest,
> L"&") != NULL)) {
>     return TRUE;
> diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> index 5ae6189a28..0b39f156f3 100644
> --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> @@ -420,14 +420,19 @@ AppendToMultiString (
>   }
> 
>   AppendStringSize = StrSize (AppendString);
> +  if (AppendStringSize <= sizeof(*AppendString))    // If the string is
> empty, there is no need to proceed further.
> +    return EFI_SUCCESS;
> +
>   MultiStringSize  = StrSize (*MultiString);
>   MaxLen   = MAX_STRING_LENGTH / sizeof (CHAR16);
> 
>   //
>   // Enlarge the buffer each time when length exceeds MAX_STRING_LENGTH.
>   //
> -  if ((MultiStringSize + AppendStringSize > MAX_STRING_LENGTH) ||
> -  (MultiStringSize > MAX_STRING_LENGTH))
> +  if ((MultiStringSize + AppendStringSize > MAX_STRING_LENGTH) /*||
> +  (MultiStringSize > MAX_STRING_LENGTH)*/)  // There is no need to
> check the second part.
> +    // If the first part is
> false, the second part will always be false.
> +    // If the second part is
> true, the first part must also be true.
>   {
>     *MultiString = (EFI_STRING)ReallocatePool (
>  MultiStringSize,
> @@ -1800,8 +1805,14 @@ GetElementsFromRequest (
> {
>   EFI_STRING  TmpRequest;
> 
> +  ASSERT (ConfigRequest != NULL);
> +  if (ConfigRequest == NULL)
> +    return FALSE;
> +
>   TmpRequest = StrStr (ConfigRequest, L"PATH=");
>   ASSERT (TmpRequest != NULL);
> +  if (TmpRequest == NULL)
> +    return FALSE;
> 
>   if ((StrStr (TmpRequest, L"=") != NULL) || (StrStr (TmpRequest,
> L"&") != NULL)) {
>     return TRUE;
> @@ -5292,6 +5303,7 @@ HiiConfigRoutingExportConfig (
>     //
>     IfrDataParsedFlag = FALSE;
>     Progress  = NULL;
> +    AccessResults = NULL;
>     HiiHandle = NULL;
>     DefaultResults    = NULL;
>     Database  = NULL;
> @@ -5326,6 +5338,14 @@ HiiConfigRoutingExportConfig (
>  
>  );
>     if (EFI_ERROR (Status)) {
> +
> +  // If an error was returned, then do not believe any results in
> these
> two pointers.
> +  Progress = NULL;
> +  if (AccessResults) {
> +    FreePool (AccessResults);
> +    AccessResults = NULL;
> +  }
> +
>   //
>   // Update AccessResults by getting default setting from IFR when
> HiiPackage is registered to HiiHandle
>   //
> @@ -5350,6 +5370,17 @@ HiiConfigRoutingExportConfig (
>     }
> 
>     if (!EFI_ERROR (Status)) {
> +
> +  // If AccessResults == NULL, there is nothing to be done.
> +  if 

Re: [edk2-devel] [PATCH edk2-test v2 4/4] Fix the URL for the edk2-test repo

2023-11-13 Thread Laszlo Ersek
On 11/10/23 20:08, Rebecca Cran wrote:
> Fix the URL for the edk2-test repo: the uefi-sct is a directory inside
> the repo.
> 
> Signed-off-by: Rebecca Cran 
> Contributed-under: TianoCore Contribution Agreement 1.1
> ---
>  Maintainers.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Maintainers.txt b/Maintainers.txt
> index a94255f015ad..ae6dd7008bcd 100644
> --- a/Maintainers.txt
> +++ b/Maintainers.txt
> @@ -28,7 +28,7 @@ Descriptions of section entries:
>  
>  UEFI-SCT
>  --
> -T: git - https://github.com/tianocore/edk2-test/uefi-sct
> +T: git - https://github.com/tianocore/edk2-test
>  
>  
>  Responsible Disclosure, Reporting Security Issues

Reviewed-by: Laszlo Ersek 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#56): https://edk2.groups.io/g/devel/message/56
Mute This Topic: https://groups.io/mt/102513318/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 0/3] Move gMpInformationHobGuid from StandaloneMmPkg to UefiCpuPkg.

2023-11-13 Thread Laszlo Ersek
On 11/9/23 03:51, duntan wrote:
> Move gMpInformationHobGuid from StandaloneMmPkg to UefiCpuPkg.
> 
> Previously, the HOB is defined, created and consumed only in StandaloneMmPkg. 
> The HOB contains the number
> of processors and EFI_PROCESSOR_INFORMATION structure. This is the same as 
> the information that PiSmmCpuDxeSmm
> uses EfiMpServiceProtocolGuid to get.
> 
> The incoming plan is to create gMpInformationHobGuid for both StandaloneMm 
> and legacy DXE_SMM in early
> phase(for example in CpuMpPei). Then PiSmmCpuDxeSmm can consume the hob, 
> which can simplify code logic
> in PiSmmCpuDxeSmm driver.
> 
> So move this HOB definition to UefiCpuPkg in this patch series.
> 
> Dun Tan (3):
>   UefiCpuPkg: Create MpInformation.h in UefiCpuPkg
>   StandaloneMmPkg:Add UefiCpuPkg.dec in DependencyCheck
>   StandaloneMmPkg:Remove MpInformation.h
> 
>  StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf  
>  | 1 +
>  
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
>  | 1 +
>  StandaloneMmPkg/StandaloneMmPkg.ci.yaml  
>  | 3 ++-
>  StandaloneMmPkg/StandaloneMmPkg.dec  
>  | 1 -
>  {StandaloneMmPkg => UefiCpuPkg}/Include/Guid/MpInformation.h 
>  | 2 +-
>  UefiCpuPkg/UefiCpuPkg.dec
>  | 3 +++
>  6 files changed, 8 insertions(+), 3 deletions(-)
>  rename {StandaloneMmPkg => UefiCpuPkg}/Include/Guid/MpInformation.h (88%)
> 

>From a quick skim, the series looks OK to me, and I also agree that the
above two MP services calls (GetNumberOfProcessors, GetProcessorInfo)
seem to be the only ones in PiSmmCpuDxeSmm.

However, what about the following scenario:

- in the PI phase (or HOB producer phase), the HOB is produced

- in the DXE phase, a platform DXE driver uses EFI_MP_SERVICES_PROTOCOL
to change some aspect of the processors in the system. For example, it
calls SwitchBSP, or calls EnableDisableAP.

- Then the information in the HOB will be stale, once PiSmmCpuDxeSmm
consumes it. The EFI_PROCESSOR_INFORMATION.StatusFlag field carries
information both about the CPU in question being BSP vs. AP, and about
the CPU being enabled or disabled. So either of SwitchBSP() and
EnableDisableAP() can invalidate the StatusFlag field for a given
ProcessorId.

I don't know how StandaloneMmPkg currently deals with this scenario, and
I also don't know whether StatusFlag actually matters to PiSmmCpuSmmDxe.
Apparently, it doesn't. So technically, the replacement of the protocol
with the HOB should be fine, but for the general case, we should
document somehow that specific fields of the HOB may be invalidated
between HOB production and HOB consumption. If platform code is required
to prevent that (i.e., the platform is responsible for not calling
SwitchBSP() or EnableDisableAP()), then that requirement should also be
documented.

Acked-by: Laszlo Ersek 


Thanks
Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#55): https://edk2.groups.io/g/devel/message/55
Mute This Topic: https://groups.io/mt/102479007/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] CodeQL Analysis in edk2

2023-11-13 Thread Laszlo Ersek
sorry, unfinished thought:

On 11/13/23 14:39, Laszlo Ersek wrote:

> - the "sarif emacs" output seems a bit broken, actually, so it's not usable. 
> Consider the following entry from the original JSON file:
> 
> }, {
>   "ruleId" : "cpp/missing-null-test",
>   "ruleIndex" : 0,
>   "rule" : {
> "id" : "cpp/missing-null-test",
> "index" : 0
>   },
>   "message" : {
> "text" : "Value may be null; it should be checked before 
> dereferencing."
>   },
>   "locations" : [ {
> "physicalLocation" : {
>   "artifactLocation" : {
> "uri" : 
> "MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c",
> "uriBaseId" : "%SRCROOT%",
> "index" : 0
>   },
>   "region" : {
> "startLine" : 355,
> "startColumn" : 48,
> "endColumn" : 52
>   }
> }
>   } ],
>   "partialFingerprints" : {
> "primaryLocationLineHash" : "f374f6e6dfc92010:1",
> "primaryLocationStartColumnFingerprint" : "43"
>   }
> }, {
> 
> In the "emacs" output, it appears as:
> 
> 
> ModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c:355: 
> cpp/missing-null-test Value may be null; it should be checked before 
> dereferencing.
> 
> 
> Note that the first three characters, "Mde" of "Mde" are lost.

I meant '"Mde" of "ModulePkg"'.

> 
> This issue (first three chars cut) affects all other pathnames in the emacs 
> output too.




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#54): https://edk2.groups.io/g/devel/message/54
Mute This Topic: https://groups.io/mt/102444916/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] CodeQL Analysis in edk2

2023-11-13 Thread Laszlo Ersek
On 11/7/23 16:43, Michael Kubacki wrote:
> The series that makes it easy to run CodeQL locally and have access to
> results from any PR or push to master.
> 
> Those that have access can see the results directly in "Code Scanning"
> in the "Security" tab of the edk2 repo. That may be affected in times
> like freezes when permissions are adjusted (write permission is needed).
> 
> I am hoping we can work together to improve the overall quality of the
> code and minimize the number of CodeQL alerts.
> 
> This is an example of that interface:
> 
> *Overview of Issues (many)*
> 
> 
> *Example of Details for a Specific Issue*
> 
> *---*
> 
> *However, you can always download the results for an individual package*
> from its GitHub Action run. I encourage people to do so.
> 
> 1. Go to Actions -> CodeQL
> 
> (https://github.com/tianocore/edk2/actions/workflows/codeql.yml).
> Anything to "master" are results at that point in time on the master
> branch. Individual PR branches are shown to get results for a specific PR.
> 
> 
> 
> 2. Download and open the SARIF file for a package. In the commit to
> master shown above in
> https://github.com/tianocore/edk2/actions/runs/6779575049, for
> MdeModulePkg, I would download "MdeModulePkg-CodeQL-SARIF" and unzip.
> 
> 
> 
> 3. Open the SARIF file to view results. For example, drag/drop the file
> "codeql-db-mdemodulepkg-debug-0.sarif" into VS Code with the "SARIF
> Viewer"
> 
>  installed. It shows all of the issues by file or rule with click to the 
> problem and more details about it. There are other SARIF viewers available as 
> well.

I've investigated "sarif", from "sarif-tools version 2.0.0", at 
.

The "emacs" output module of "sarif" would be ideal for my needs, but I have 
two questions / requests regarding that:

- would it be possible to run "sarif emacs" immediately in the github action, 
so that the text file can be downloaded at once? (I currently have sarif-tools 
installed in a python venv, but I'd prefer avoiding even that.)

- the "sarif emacs" output seems a bit broken, actually, so it's not usable. 
Consider the following entry from the original JSON file:

}, {
  "ruleId" : "cpp/missing-null-test",
  "ruleIndex" : 0,
  "rule" : {
"id" : "cpp/missing-null-test",
"index" : 0
  },
  "message" : {
"text" : "Value may be null; it should be checked before dereferencing."
  },
  "locations" : [ {
"physicalLocation" : {
  "artifactLocation" : {
"uri" : 
"MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c",
"uriBaseId" : "%SRCROOT%",
"index" : 0
  },
  "region" : {
"startLine" : 355,
"startColumn" : 48,
"endColumn" : 52
  }
}
  } ],
  "partialFingerprints" : {
"primaryLocationLineHash" : "f374f6e6dfc92010:1",
"primaryLocationStartColumnFingerprint" : "43"
  }
}, {

In the "emacs" output, it appears as:


ModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c:355: 
cpp/missing-null-test Value may be null; it should be checked before 
dereferencing.


Note that the first three characters, "Mde" of "Mde" are lost.

This issue (first three chars cut) affects all other pathnames in the emacs 
output too.

Is this a known issue perhaps?

Thanks!
Laszlo

> 
> 
> 
> Keep in mind that CodeQL will often not highlight everything that needs
> to be done to fix an issue. It alerts the developer to an issue and then
> you need to inspect the code to determine if other code paths or
> refactoring should be applied.
> 
> I will create a wiki page with more user focused information, but I
> wanted to share some quick info for getting started.
> 
> More technical details about how the plugin itself works and applying
> exceptions are available in its readme
> - edk2/BaseTools/Plugin/CodeQL/Readme.md at master · tianocore/edk2
> (github.com).
> 
> 
> Thanks,
> Michael
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#53): https://edk2.groups.io/g/devel/message/53
Mute This Topic: https://groups.io/mt/102444916/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 0/2] Remove string IO instruction in BaseIoLibIntrinsic.inf

2023-11-13 Thread Laszlo Ersek
On 11/9/23 06:56, Ni, Ray wrote:
> Reviewed-by: Ray Ni 
> 
> Thanks for providing the alternative solution that avoids impacting OVMF
> boot performance.

This approach looks good to me.

The IA32 and X64 OVMF platforms use "BaseIoLibIntrinsicSev.inf", and
that library instance is left alone.

The RISC-V OVMF platform uses "BaseIoLibIntrinsic.inf", but RISC-V
already doesn't (can't) use the IA32/X64 NASM files.

So, surprisingly, the "IoFifo.nasm" files are actually unused,
pre-patch; IA32 and X64 OVMF only uses the "IoFifoSev.nasm" files.

Acked-by: Laszlo Ersek 

Thanks!
Laszlo




> 
> Thanks,
> Ray
> 
> *From:* devel@edk2.groups.io  on behalf of duntan
> 
> *Sent:* Thursday, November 9, 2023 10:49 AM
> *To:* devel@edk2.groups.io 
> *Subject:* [edk2-devel] [PATCH 0/2] Remove string IO instruction in
> BaseIoLibIntrinsic.inf
>  
> Simplify IoRead/WriteFifo implement in BaseIoLibIntrinsic by repeatedly
> calling
> IoRead/Write in C code. This can avoid calling assembly code to use
> string I/O instructions.
> With this change, Ia32/IoFifo.nasm and X64/IoFifo.nasm can be removed. Also
> source files for IA32 and X64 are the same.
> 
> Dun Tan (2):
>   MdePkg: Change IoLibFifo.c to IoLibFifoCc.c
>   MdePkg:simplify Fifo API in BaseIoLibIntrinsic
> 
>  MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf    |  10
> ++
>  MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf |   2 +-
>  MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifo.nasm  | 131
> ---
>  MdePkg/Library/BaseIoLibIntrinsic/IoLibFifo.c   |  59
> +++
>  MdePkg/Library/BaseIoLibIntrinsic/IoLibFifoCc.c | 217
> +
>  MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifo.nasm   | 120
> 
>  6 files changed, 251 insertions(+), 288 deletions(-)
>  delete mode 100644 MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifo.nasm
>  create mode 100644 MdePkg/Library/BaseIoLibIntrinsic/IoLibFifoCc.c
>  delete mode 100644 MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifo.nasm
> 
> -- 
> 2.31.1.windows.1
> 
> 
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#52): https://edk2.groups.io/g/devel/message/52
Mute This Topic: https://groups.io/mt/102478994/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] TPM2 NVM WRITE IN EDK2

2023-11-13 Thread Laszlo Ersek
On 11/9/23 11:39, Hamit Can Karaca wrote:
> Hello,
> I am a young UEFI developer and I am trying to use the functions in
> Tpm2CommandLib to write data to TPM2. I have defined the index that, I
> am going to write data to, using the DefineSpace function. But whenever
> I am trying to use the Tpm2NvWrite function, I keep getting
> EFI_DEVICE_ERROR with a response code 0x1D5. Is there anything to do
> before Tpm2NvWrite that I don't know or do I use the wrong parameters?
> If anyone has used these functions please let me know, thanks!

I think this should be possible to explain from the TPM2 spec, part 2,
"structures".

Response code 0x1D5 is binary 111010101. Bit 7 is set, therefore we have
to look at the format-1 RC structure:

  0001 1 1 010101
   - - --
 N F P  E

N=1 (1-based parameter that the error refers to)
F=1 (format-1 response)
P=1 (error is associated with a parameter)
E=0x15 (error number)

In Table 16, RC_FMT1 (value 0x80 -- F bit, or bit 7) says "This bit is
SET in all format 1 response codes. The codes in this group may have a
value added to them to indicate the handle, session, or parameter
to which they apply". Indeed, we have P=1 (error is associated with
parameter) and N=1 (1-based parameter number related to the error is 1).

Thus, we have TPM_RC_SIZE (= RC_FMT1 + 0x015, 0x95, to which we add P=1
(0x40) and N=1 (0x100) for getting 0x1D5):

TPM_RC_SIZE: structure is the wrong size

In other words, whatever command you are sending, the TPM seems to reply
with "parameter 1 of your command is incorrectly sized".

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#51): https://edk2.groups.io/g/devel/message/51
Mute This Topic: https://groups.io/mt/102510897/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 0/4] Sync BSP's APIC mode to APs in MP init flow

2023-11-13 Thread Laszlo Ersek
On 11/9/23 19:08, Michael D Kinney wrote:
> +Ray
> 
>  
> 
> Unless I missed it, I do not see review of the patch series Ray sent
> back in July.

Right, please repost.

Laszlo

> 
>  
> 
> Mike
> 
>  
> 
> *From:* devel@edk2.groups.io  *On Behalf Of *Aaron
> Young via groups.io
> *Sent:* Thursday, November 9, 2023 8:29 AM
> *To:* Gerd Hoffmann ; devel@edk2.groups.io
> *Subject:* Re: [edk2-devel] [PATCH 0/4] Sync BSP's APIC mode to APs in
> MP init flow
> 
>  
> 
>  
> 
>  Hello, is this issue/patch still being worked/considered? If so, is
> there an ETA?
> 
>  Without this fix, one cannot hotplug beyond 255 vcpus with OVMF and we
> need this capability.
> 
>  NOTE: Gerd's original fix
> (https://edk2.groups.io/g/devel/message/100801
> ), does allow hotplug
> beyond 255 vcpus. So, that fix seems viable. Should it be re-evaluated?
> 
>  We would gladly test a fix if that would be helpful.
> 
>  Thanks in advance!
> 
>  -Aaron Young (aaron.yo...@oracle.com )
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#50): https://edk2.groups.io/g/devel/message/50
Mute This Topic: https://groups.io/mt/10874/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] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Marcin Juszkiewicz

W dniu 13.11.2023 o 12:58, Laszlo Ersek pisze:

Note that 73.0.3 indents the subexpression to the "//"  comment on the
previous line, while 73.0.8 ignores the comment -- which I think is
justified here.

I believe this improvement may come from uncrustify commit 239c4fad745b
("Prevent endless indentation scenario in struct assignment",
2022-07-29). I think it's worth having in edk2.


I like this.


CC: stewards, Pedro (commit 6ded9f50c3aa), Marcin (traditionally a big
fan of uncrustify :))


I prefer to have source formatter than not having it. Especially in 
projects which have code style far from mine.


Still a fan of adding edk2-uncrustify to BaseTools. If we are expected 
to use it then let it get installed at same moment as "build" command is.



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




Re: [edk2-devel] [Patch V4] UefiCpuPkg/MpInitLib: Enable execute disable bit.

2023-11-13 Thread Gerd Hoffmann
On Mon, Nov 13, 2023 at 01:59:48PM +0800, xieyuanh wrote:
> From: Yuanhao Xie 
> 
> This patch synchronizes the No-Execute bit in the IA32_EFER
> register for the APs before the RestoreVolatileRegisters operation.
> 
> The commit 964a4f0, titled "Eliminate the second INIT-SIPI-SIPI
> sequence," replaces the second INIT-SIPI-SIPI sequence with the BSP
> calling the SwitchApContext function to initiate a specialized start-up
> signal, waking up APs in the DXE instead of using INIT-SIPI-SIPI.
> 
> Due to this change, the logic for "Enable execute disable bit" in
> MpFuncs.nasm is no longer executed. However, to ensure the proper setup
> of the page table, it is necessary to synchronize the IA32_EFER.NXE for
> APs before executing RestoreVolatileRegisters .
> 
> Based on SDM:
> If IA32_EFER.NXE is set to 1, it signifies execute-disable, meaning
> instruction fetches are not allowed from the 4-KByte page controlled by
> this entry. Conversely, if it is set to 0, it is reserved.
> 
> Signed-off-by: Yuanhao Xie 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 

Acked-by: Gerd Hoffmann 



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




[edk2-devel] edk2 uncrustify update (73.0.8)?

2023-11-13 Thread Laszlo Ersek
Hi Michael,

recently I encountered an uncrustify failure on github.

The reason was that my local uncrustify was *more recent* (73.0.8) than
the one we use in edk2 CI (which is 73.0.3, per the edk2 file
".pytool/Plugin/UncrustifyCheck/uncrustify_ext_dep.yaml").

Updating the version number in the YAML file (i.e., advancing edk2 to
version 73.0.8) seems easy enough, but:

- Do you think 73.0.8 is mature enough for adoption in edk2?

  This upstream uncrustify release was tagged in April (and I can't see
  any more recent commits), so I assume it should be stable.

- Would the version update require a whole-tree re-uncrustification?

The reason I'm not just ignoring this topic is that 73.0.8 actually
produces *better output* than 73.0.3, at least in the one instance I
encountered. Compare:

> diff --git 
> a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c 
> b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c
> index 434cdca84b23..3a6f75988220 100644
> --- a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c
> +++ b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c
> @@ -43,12 +43,12 @@ STATIC EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL
>  STATIC CONST EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  mMmio64Configuration = {
>ACPI_ADDRESS_SPACE_DESCRIPTOR,   // Desc
>(UINT16)(// Len
> -   sizeof 
> (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) -
> -   OFFSET_OF (
> - 
> EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR,
> - ResType
> - )
> -   ),
> +sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) -
> +OFFSET_OF (
> +  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR,
> +  ResType
> +  )
> +),
>ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType
>0,   // GenFlag
>0,   // SpecificFlag
> @@ -77,12 +77,12 @@ STATIC CONST EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  
> mMmio64Configuration = {
>  STATIC CONST EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  mOptionRomConfiguration =   {
>ACPI_ADDRESS_SPACE_DESCRIPTOR,   // Desc
>(UINT16)(// Len
> -   sizeof 
> (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) -
> -   OFFSET_OF (
> - 
> EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR,
> - ResType
> - )
> -   ),
> +sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) -
> +OFFSET_OF (
> +  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR,
> +  ResType
> +  )
> +),
>ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType
>0,   // GenFlag
>0,   // Disable option roms 
> SpecificFlag

Note that 73.0.3 indents the subexpression to the "//"  comment on the
previous line, while 73.0.8 ignores the comment -- which I think is
justified here.

I believe this improvement may come from uncrustify commit 239c4fad745b
("Prevent endless indentation scenario in struct assignment",
2022-07-29). I think it's worth having in edk2.

CC: stewards, Pedro (commit 6ded9f50c3aa), Marcin (traditionally a big
fan of uncrustify :))

Thanks
Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#47): https://edk2.groups.io/g/devel/message/47
Mute This Topic: https://groups.io/mt/102559740/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 16/30] ArmVirtPkg: Move PCD of FDT base address and FDT padding to OvmfPkg

2023-11-13 Thread Sami Mujawar

Hi Chao,

Thank you for this patch.

I have a few suggestions marked inline as [SAMI].

Otherwise this patch looks good to me.

With those fixed,

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar

On 06/11/2023 03:29 am, Chao Li wrote:

Moved PcdDeviceTreeInitialBaseAddress and PcdDeviceTreeAllocationPadding
to OvmfPkg for easier use by other architectures.

Build-tested only (with "ArmVirtQemu.dsc").

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Sami Mujawar 
Cc: Gerd Hoffmann 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Signed-off-by: Chao Li 
---
  ArmVirtPkg/ArmVirtCloudHv.dsc |  2 +-
  ArmVirtPkg/ArmVirtKvmTool.dsc |  2 +-
  ArmVirtPkg/ArmVirtPkg.dec | 14 --
  ArmVirtPkg/ArmVirtQemu.dsc|  2 +-
  ArmVirtPkg/ArmVirtQemuKernel.dsc  |  2 +-
  ArmVirtPkg/ArmVirtXen.dsc |  2 +-
  .../ArmVirtPsciResetSystemPeiLib.inf  |  3 ++-
  .../CloudHvVirtMemInfoPeiLib.inf  |  3 ++-
  .../DebugLibFdtPL011UartFlash.inf |  3 ++-
  .../EarlyFdt16550SerialPortHookLib.inf|  3 ++-
  .../EarlyFdtPL011SerialPortLib.inf|  3 ++-
  .../KvmtoolPlatformPeiLib.inf |  5 +++--
  .../Library/PlatformPeiLib/PlatformPeiLib.inf | 10 +-
  .../QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf  |  3 ++-
  .../PrePi/ArmVirtPrePiUniCoreRelocatable.inf  |  3 ++-
  OvmfPkg/OvmfPkg.dec   | 15 +++
  16 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtCloudHv.dsc b/ArmVirtPkg/ArmVirtCloudHv.dsc
index 2cb89ce10c..76c0d28544 100644
--- a/ArmVirtPkg/ArmVirtCloudHv.dsc
+++ b/ArmVirtPkg/ArmVirtCloudHv.dsc
@@ -129,7 +129,7 @@
gArmTokenSpaceGuid.PcdSystemMemoryBase|0x4000
  
# initial location of the device tree blob passed by Cloud Hypervisor -- base of DRAM

-  gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x4000
+  gUefiOvmfPkgTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x4000
  
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE

gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 
0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc
index f50d53bf15..cac4fe06d3 100644
--- a/ArmVirtPkg/ArmVirtKvmTool.dsc
+++ b/ArmVirtPkg/ArmVirtKvmTool.dsc
@@ -179,7 +179,7 @@
# We are booting from RAM using the Linux kernel boot protocol,
# x0 will point to the DTB image in memory.
#
-  gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0
+  gUefiOvmfPkgTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0
  
gArmTokenSpaceGuid.PcdFdBaseAddress|0x0

gArmTokenSpaceGuid.PcdFvBaseAddress|0x0
diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec
index 0f2d787327..2451644844 100644
--- a/ArmVirtPkg/ArmVirtPkg.dec
+++ b/ArmVirtPkg/ArmVirtPkg.dec
@@ -42,20 +42,6 @@
gArmVirtTokenSpaceGuid.PcdTpm2SupportEnabled|FALSE|BOOLEAN|0x0004
  
  [PcdsFixedAtBuild, PcdsPatchableInModule]

-  #
-  # This is the physical address where the device tree is expected to be stored
-  # upon first entry into UEFI. This needs to be a FixedAtBuild PCD, so that we
-  # can do a first pass over the device tree in the SEC phase to discover the
-  # UART base address.
-  #
-  gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0|UINT64|0x0001
-
-  #
-  # Padding in bytes to add to the device tree allocation, so that the DTB can
-  # be modified in place (default: 256 bytes)
-  #
-  gArmVirtTokenSpaceGuid.PcdDeviceTreeAllocationPadding|256|UINT32|0x0002
-
#
# Binary representation of the GUID that determines the terminal type. The
# size must be exactly 16 bytes. The default value corresponds to
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 30e3cfc8b9..cf306cac08 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -201,7 +201,7 @@
gArmTokenSpaceGuid.PcdSystemMemoryBase|0x4000
  
# initial location of the device tree blob passed by QEMU -- base of DRAM

-  gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x4000
+  gUefiOvmfPkgTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x4000
  
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE

gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 
0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index b50f8e84a3..c0d079e28d 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -198,7 +198,7 @@
# Define a default initial address for the device tree.
# Ignored if x0 != 0 at 

Re: [edk2-devel] [PATCH v2] MdeModulePkg/PciHostBridgeDxe: Add readback after final Cfg-Write

2023-11-13 Thread Laszlo Ersek
On 11/8/23 02:06, Michael D Kinney wrote:
> Hi Jose,
> 
>  
> 
>  1. This logic needs to move into an AARCH64 specific directory/file. 
> Other architectures handle this in other ways.
>  2. There are many places throughout edk2 sources that perform PCI
> config write operations.  You are only fixing it in a single
> location.  You may want to look at the MdePkg PciLibs to see if it
> can be addressed there with an AARCH64 specific dir/file, but that
> still may not address all possible PCI config write accesses.  Fill
> analysis of the target platform sources may be required to make sure
> it is fixes for all locations.

Hm.

Perhaps if this change is pushed down as much as possible, into a
special AARCH64 PciLib instance, so that the readback or the DSB (IIRC)
is performed after every PCI config space write, then that might
actually suffice. Because, ultimately, PciHostBridgeDxe too depends on
PciSegmentLib for the access sycles.

(Previously I suggested extending PciHostBridgeLib with a new API, but
that wasn't right, per your second point -- I didn't realize the same
issue must exist (for example) in the PEI phase, before the PCI-related
protocols even exist.)

Laszlo


> 
>  
> 
> Mike
> 
>  
> 
> *From:* Jose Lopez 
> *Sent:* Tuesday, November 7, 2023 10:59 AM
> *To:* devel@edk2.groups.io
> *Cc:* Leif Lindholm ; Ard Biesheuvel
> ; Gao, Liming ;
> Michael Brown ; Pedro Falcato ;
> Ni, Ray ; Wu, Hao A ; Wang, Jian J
> ; Sami Mujawar ;
> ler...@redhat.com; Kinney, Michael D 
> *Subject:* Re: [PATCH v2] MdeModulePkg/PciHostBridgeDxe: Add readback
> after final Cfg-Write
> 
>  
> 
> ++ Laszlo and Michael
> 
>  
> 
> On Tue, Nov 7, 2023 at 10:54 AM Jose Lopez  > wrote:
> 
> ++ CC'd
> 
>  
> 
>  
> 
> On Mon, Nov 6, 2023 at 6:02 PM Joe Lopez  > wrote:
> 
> From: joelopez333 mailto:jlo...@gmail.com>>
> 
>     REF:https://edk2.groups.io/g/devel/topic/102310377#110456
> 
> 
>     Problem Report:
> 
>     On AARCH64, there is no ordering guarantee between configuration
>     space (ECAM) writes and memory space reads (MMIO). ARM AMBA CHI
>     only guarantees ordering for reads and writes within a
> single address region,
>     however, on some systems MMIO and ECAM may be split into
> separate
>     address regions.
> 
>     A problem may arise when an ECAM write is issued a
> completion before a subsequent
>     MMIO read is issued and receives a completion.
> 
>     For example, a typical PCI software flow is the following:
> 
>     1. ECAM write to device command register to enable memory space
>     2. MMIO read from device memory space for which access was
> enabled
>     in step 1.
> 
>     There is no guarantee that step 2. will not begin before the
> completion of step 1.
>     on systems where ECAM/MMIO are specified as separate address
> regions, even
>     if both spaces have the memory attributes device-nGnRnE.
> 
>     Fix:
> 
>     - Add a read after the final PCI Configuration space write
>       in RootBridgeIoPciAccess.
> 
>     - When configuration space is strongly ordered, this ensures
>       that program execution cannot continue until the completion
>       is received for the previous Cfg-Write, which may have
> side-effects.
> 
>     - Risk of reading a "write-only" register and causing a CA
> which leaves the device
>       unresponsive. The expectation based on the PCI Base Spec
> v6.1 section 7.4 is that
>       all PCI Spec-defined registers will be readable, however,
> there may exist
>       design-specific registers that fall into this category.
> 
>     Cc: Leif Lindholm  >
>     Cc: Ard Biesheuvel  >
>     Cc: Sami Mujawar  >
>     Cc: Jian J Wang  >
>     Cc: Liming Gao  >
>     Cc: Hao A Wu mailto:hao.a...@intel.com>>
>     Cc: Ray Ni mailto:ray...@intel.com>>
>     Cc: Pedro Falcato  >
>     Cc: Michael Brown mailto:mc...@ipxe.org>>
>     Signed-off-by: Joe Lopez  >
> ---
>  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 8
> 
>  1 file changed, 8 insertions(+)
> 
> diff --git
> a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c
> b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c
>

Re: [edk2-devel] [PATCH v1] UefiCpuPkg/PiSmmCpuDxeSmm: Use processor extended information

2023-11-13 Thread Laszlo Ersek
On 11/8/23 05:11, Wu, Jiaxin wrote:
> Hi Laszlo,
> 
>>>
>>> The patch looks OK to me, but:
>>>
>>> - I would like to test it with CPU hotplug (later, likely under v2), and
>>>
> 
> Sure, I can wait the update from you.
> 
>>> - I think this should be two patches.
>>>
>>> First, the SmmAddProcessor() function should be extended just to
>>> complete commit 1fadd18d. (BTW I highly appreciate the reference to
>>> commit 1fadd18d; otherwise I couldn't find where the *coldplugged* CPUs'
>>> locations were retrieved!)
>>>
>>> Then the Package calculations should be updated separately -- mostly
>>> because I would appreciate a concrete description in that separate
>>> commit message why the difference matters. Clearly you have a use case
>>> where the v1 and v2 package numbers differ, and recording that in the
>>> commit history would be great.
> 
> Sure, let me explain more, there are 2 reason I did this change:
> 
> 1. the processor package ID retrieved from CPUID 0x0Bh may be not 
> correct/accurate if CPU has the module & die info, it depends on the CPUID 
> implementation. See SDM statement:
> 
> EAX Bits 04 - 00: Number of bits to shift right on x2APIC ID to get a unique 
> topology ID of the *next level type*
> ECX Bits 15 - 08: *Level type*
> Level type field has the following encoding:
> 0: Invalid.
> 1: SMT.
> 2: Core.
> 3-255: Reserved
> 
> So,  if level type returned from ECX Bits 15 - 08 is 2 (Core), then what's 
> the next level mean? Module or Die or Package? SDM doesn't has explanation 
> for the next level of Core. If so, the value will be decided by 
> implementation. 
> The value can be package info for compatibility consideration, but it's not 
> standardized. That's the reason we suggest use the leaf 1Fh.
>
> 2. And according SDM declaration, "CPUID leaf 1FH is a preferred superset to 
> leaf 0BH. Intel recommends first checking for the existence of CPUID leaf 1FH 
> before using leaf 0BH."
> This is perfect match the existing GetProcessorLocation2ByApicId() 
> implementation. 
> 
> That's the main reasons we switch to EFI_CPU_PHYSICAL_LOCATION2.
> 
>>
>> Side note, just for completeness: the x2apic lib instance performs the
>> v2 feature detection correctly since Gerd's commit 170d4ce8e90a
>> ("UefiCpuPkg/BaseXApicX2ApicLib: fix CPUID_V2_EXTENDED_TOPOLOGY
>> detection", 2023-10-25). Furthermore, OVMF uses the x2apic lib instance
>> since commit decb365b0016 ("OvmfPkg: select LocalApicLib instance with
>> x2apic support", 2015-11-30). Therefore, this patch looks fine for OVMF.
>>
>> However, for platforms that use the old xapic lib instance, there could
>> be problems, as the v2 feature detection in *that* instance is not fixed
>> -- it does not check EBX.
>>
> 
> Great catch this! I can create the patch 3 for this porting to old xapic lib 
> instance if you no objection.

Sure, sounds good, although I have no way of testing that.

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#44): https://edk2.groups.io/g/devel/message/44
Mute This Topic: https://groups.io/mt/102436095/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 4/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix NULL_RETURNS Coverity issue

2023-11-13 Thread Laszlo Ersek
On 11/10/23 07:11, Ranbir Singh wrote:
> EFI_NOT_READY was listed as one of the error return values in the
> function header of StartPciDevices(). So, I considered it here.
> 
> Maybe we can go by a dual approach, including CpuDeadLoop() in
> StartPciDevices() as well as add return value check at the call site in
> PciBusDriverBindingStart().

I don't think this makes much sense, given that execution is not
supposed to continue past CpuDeadLoop(), so the new error check would
not be reached.

I think two options are realistic:

- replace the assert() with a CpuDeadLoop() -- this is my preference

- keep the assert, add the "if", and in the caller, handle the
EFI_NOT_READY error. This is workable too. (Keeping the assert is goog
because it shows that we don't expect the "if" to fire.)

Anyway, now that we have no way to verify the change against Coverity, I
don't know if this patch is worth the churn. :( As I said, this ASSERT()
is one of those few justified ones in edk2 core that can indeed never
fail, IMO.

Laszlo


> 
> On Tue, Nov 7, 2023 at 10:18 PM Laszlo Ersek  > wrote:
> 
> On 11/7/23 07:19, Ranbir Singh wrote:
> > From: Ranbir Singh 
> >
> > The function StartPciDevices has a check
> >
> >     ASSERT (RootBridge != NULL);
> >
> > but this comes into play only in DEBUG mode. In Release mode, there
> > is no handling if the RootBridge value is NULL and the code proceeds
> > to unconditionally dereference "RootBridge" which will lead to CRASH.
> >
> > Hence, for safety add NULL pointer checks always and return
> > EFI_NOT_READY if RootBridge value is NULL which is one of the return
> > values as mentioned in the function description header.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4239
> 
> >
> > Cc: Ray Ni mailto:ray...@intel.com>>
> > Co-authored-by: Veeresh Sangolli  >
> > Signed-off-by: Ranbir Singh 
> > Signed-off-by: Ranbir Singh  >
> > ---
> >  MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 5 -
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> > index 581e9075ad41..3de80d98370e 100644
> > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> > @@ -772,7 +772,10 @@ StartPciDevices (
> >    LIST_ENTRY     *CurrentLink;
> > 
> >    RootBridge = GetRootBridgeByHandle (Controller);
> > -  ASSERT (RootBridge != NULL);
> > +  if (RootBridge == NULL) {
> > +    return EFI_NOT_READY;
> > +  }
> > +
> >    ThisHostBridge = RootBridge->PciRootBridgeIo->ParentHandle;
> > 
> >    CurrentLink = mPciDevicePool.ForwardLink;
> 
> I don't think this is a good fix.
> 
> There is one call site, namely in PciBusDriverBindingStart(). That call
> site does not check the return value. (Of course /s)
> 
> I think that this ASSERT() can indeed never fail. Therefore I suggest
> CpuDeadLoop() instead.
> 
> If you insist that CpuDeadLoop() is "too risky" here, then the patch is
> acceptable, but then the StartPciDevices() call site in
> PciBusDriverBindingStart() must check the error properly: we must not
> install "gEfiPciEnumerationCompleteProtocolGuid", and the function must
> propagate the error outwards.
> 
> Laszlo
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#43): https://edk2.groups.io/g/devel/message/43
Mute This Topic: https://groups.io/mt/102438320/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 2/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix MISSING_BREAK Coverity issues

2023-11-13 Thread Laszlo Ersek
On 11/8/23 05:29, Ranbir Singh wrote:
> Hi Mike,
> 
> I agree that any manual inspection is sort of a burden, more so when it
> becomes repetitive in the long run.
> 
> When I was doing these Coverity checks (Nov-Dec' 2022), I was working in
> Dell and had access to the real systems to check the execution flow as
> well as the Coverity status. I could never post these patches while
> being there, but happened to raise Bugzilla's and post them there
> instead hoping that they would be taken up by somebody further.
> 
> I am no longer with Dell and later on when I found that those BZ /
> issues pointed out by Coverity still exist as there are no code changes
> in related contexts, I thought of taking them forward in whatever
> limited capacity I can. I am a bit hesitant to do any further code
> changes as now I do not have any systems to check the execution flow as
> well as the Coverity status. So, I do not guarantee, but will try to
> make the code changes wherever it is easy to ascertain that the
> functional flow would not be impacted and the same issue won't exist
> anymore.

This makes me a bit sad.

I was happy to see that a company seriously invested in cleaning up
Coverity issue reports all over edk2.

If you don't have the environment and/or the assignment to continue
doing that, then I agree that further tweaking these patches is
unjustifed. (Sorry, I didn't realize the background when I reviewed your
patches.) New versions would effectively mean "untested" code (untested
as in not tested with Coverity specifically). In particular because the
purported warning fixes will require real edk2 review (and occasionally
regression testing even), which doesn't look good if we can't even be
sure that the change actually placates coverity.

I guess we should upstream those of your patches that are fine right as
they are, and drop the rest for now. (A pity!) Accordingly, if you think
some of my review comments are not especially important in this light
(i.e., whenever it is better to take the patch as is, than to drop an
updated version due to untestability), then please do comment so explicitly!

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#42): https://edk2.groups.io/g/devel/message/42
Mute This Topic: https://groups.io/mt/102438299/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 V4] UefiCpuPkg/MpInitLib: Enable execute disable bit.

2023-11-13 Thread Yuanhao Xie
Hi Gerd,

In v4 , InterlockedIncrement called is after RestoreVolatileRegisters to ensure 
that "finished" reporting from the APs is as
later as possible.

Here is V3:
   GetProcessorNumber (CpuMpData, );
-  RestoreVolatileRegisters (>CpuData[0].VolatileRegisters, FALSE);
   InterlockedIncrement ((UINT32 *)>FinishedCount);
+
+  if (CpuMpData->EnableExecuteDisableForSwitchContext) {
+EferMsr.Uint64   = AsmReadMsr64 (MSR_IA32_EFER);
+EferMsr.Bits.NXE = 1;
+AsmWriteMsr64 (MSR_IA32_EFER, EferMsr.Uint64);
+  }
+
+  RestoreVolatileRegisters (>CpuData[0].VolatileRegisters, FALSE);

Regards,
Yuanhao

-Original Message-
From: Gerd Hoffmann  
Sent: Monday, November 13, 2023 6:54 PM
To: Xie, Yuanhao 
Cc: devel@edk2.groups.io; Dong, Eric ; Ni, Ray 
; Kumar, Rahul R 
Subject: Re: [Patch V4] UefiCpuPkg/MpInitLib: Enable execute disable bit.

> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 9a6ec5db5c..f29e66a14f 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -910,9 +910,16 @@ DxeApEntryPoint (
>CPU_MP_DATA  *CpuMpData
>)
>  {
> -  UINTN  ProcessorNumber;
> +  UINTN   ProcessorNumber;
> +  MSR_IA32_EFER_REGISTER  EferMsr;
>  
>GetProcessorNumber (CpuMpData, );
> +  if (CpuMpData->EnableExecuteDisableForSwitchContext) {
> +EferMsr.Uint64   = AsmReadMsr64 (MSR_IA32_EFER);
> +EferMsr.Bits.NXE = 1;
> +AsmWriteMsr64 (MSR_IA32_EFER, EferMsr.Uint64);  }

It helps reviewers if you document changes from one version to the next.
This code block was moved (compared to v3).  Why?

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#41): https://edk2.groups.io/g/devel/message/41
Mute This Topic: https://groups.io/mt/102556608/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 24/30] OvmfPkg/LoongArchVirt: Add platform boot manager library

2023-11-13 Thread Laszlo Ersek
On 11/10/23 10:46, Gerd Hoffmann wrote:
> On Fri, Nov 10, 2023 at 03:09:47PM +0800, Chao Li wrote:
>> Hi Laszlo,
>>
>> Sorry, I'm not check carefully, it is really **copied**, and we not think
>> the ARM version is not good enough.
>>
>> So, can I move this library to OvmfPkg so other ARCH use it easily?
> 
> Moving code from ArmVirtPkg to OvmfPkg is fine.
> 
> OvmfPkg is the home for both x86 virtual machine bits and shared code.
> The later used to be mostly virtio drivers, but with the arrival of
> riscv some fdt support code has already moved from ArmVirtPkg to OvmfPkg
> so arm and riscv can share it.  Doing the same for loongarch is
> perfectly fine.

Agreed!

The naming of course remains tricky. :) It's not easy to come up with
good names for distinguishing various instances of the same library class.

I suggest renaming "OvmfPkg/PlatformBootManagerLib" to
"PlatformBootManagerLibX86", and calling ArmVirtPkg's instance (once
moved) PlatformBootManagerLibGeneric or just PlatformBootManagerLib.

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#40): https://edk2.groups.io/g/devel/message/40
Mute This Topic: https://groups.io/mt/102413902/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 23/30] OvmfPkg/LoongArchVirt: Add PeiServiceTablePointerLib

2023-11-13 Thread Laszlo Ersek
On 11/10/23 07:44, Chao Li wrote:
> Hi Laszlo,
> 
> This is a good question, same as the previous email, some ARCH don't
> require running code on memory during PEI phase or other reason can not
> used the MdePkg version, so this pointer will be saved by some register,
> I saw the ArmPkg version also uses a register to save this pointer.
> 
> If I move ArmPkg version PeiServiceTablePointer to MdePkg and the method
> of getting and saving the pointer use a new library which related
> architecture, other word, the API of PeiServiceTablePointer has not
> changed, adding a new library that PeiServiceTablePointer depends on,
> the real saving and reading method completed in the new library. Do you
> think this way is better?

Right. I think you need a loongarch-specific library instance of
PeiServicesTablePointerLib under MdePkg. Presumably, if / when you
enable edk2 on *physical* loongarch platforms, you're going to need the
same library instance. And therefore it should not be under OvmfPkg, but
MdePkg.

In fact, now that I'm reading the comments in
"MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c",
it seems that the architecture bindings in the Platform Init
specification actually document how the PEI services table pointer is
supposed to be stored before system memory becomes available (IIUC).

The latest version of the PI spec that I have is 1.8.

In Volume I, there is a section titled "I-9.4 PEI Services Table
Retrieval". It considers the following architectures: X86, x64, Itanium,
ARM, AArch64, RISC-V.

I think that in the longer term, you should file a PIWG Mantis ticket
for extending this section, with an Engineering Change Request where you
describe how this mechanism should work on loongarch.

And then the implementation certainly belongs to MdePkg.

(Note that I'm *not* saying you should first update the specification
and then implement it in edk2 -- that's not my point. My point is that
*eventually*, this mechanism will become a part of the public loongarch
bindings, and therefore you can already start introducing it under
MdePkg, in my opinion anyway.)

Note that "prior art" is inconsistent here, regarding edk2 locations,
because, as you say, the arm/aarch64 implementation lives under ArmPkg
-- but it's quite unlikely IMO that a LoongArchPkg top-level directory
would be introduced. In the longer term, we might want to consolidate
all PeiServicesTablePointerLib instances under MdePkg.


Then your question is, IIUC, whether to reuse any portion of the ArmPkg
implementation. I don't think that's necessary; the library is so small,
there is effectively *nothing generic* in it. Put differently, all of it
is architecture specific. Thus I think you can just add a totally
self-contained loongarch instance.

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#39): https://edk2.groups.io/g/devel/message/39
Mute This Topic: https://groups.io/mt/102413901/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 V4] UefiCpuPkg/MpInitLib: Enable execute disable bit.

2023-11-13 Thread Gerd Hoffmann
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 9a6ec5db5c..f29e66a14f 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -910,9 +910,16 @@ DxeApEntryPoint (
>CPU_MP_DATA  *CpuMpData
>)
>  {
> -  UINTN  ProcessorNumber;
> +  UINTN   ProcessorNumber;
> +  MSR_IA32_EFER_REGISTER  EferMsr;
>  
>GetProcessorNumber (CpuMpData, );
> +  if (CpuMpData->EnableExecuteDisableForSwitchContext) {
> +EferMsr.Uint64   = AsmReadMsr64 (MSR_IA32_EFER);
> +EferMsr.Bits.NXE = 1;
> +AsmWriteMsr64 (MSR_IA32_EFER, EferMsr.Uint64);
> +  }

It helps reviewers if you document changes from one version to the next.
This code block was moved (compared to v3).  Why?

take care,
  Gerd



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




Re: [edk2-devel] [PATCH] OvmfPkg/MemEncryptSevLib: Fix address overflow during PVALIDATE

2023-11-13 Thread Gerd Hoffmann
On Fri, Nov 10, 2023 at 08:14:39PM -0600, Michael Roth wrote:
> The struct used for GHCB-based page-state change requests uses a 40-bit
> bit-field for the GFN, which is shifted by PAGE_SHIFT to generate a
> 64-bit address. However, anything beyond 40-bits simply gets shifted off
> when doing this, which will cause issues when dealing with 1TB+
> addresses. Fix this by casting the 40-bit GFN values to 64-bit ones
> prior to shifting it by PAGE_SHIFT.
> 
> Fixes: ade62c18f474 ("OvmfPkg/MemEncryptSevLib: add support to validate 
> system RAM")
> Signed-off-by: Michael Roth 
> ---
>  .../BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c| 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git 
> a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c 
> b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c
> index 85eb41585b..d52d2940e9 100644
> --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c
> +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c
> @@ -78,13 +78,14 @@ PvalidateRange (
>IN  BOOLEAN Validate
>)
>  {
> -  UINTN  Address, RmpPageSize, Ret, i;
> +  UINTN RmpPageSize, Ret, i;
> +  EFI_PHYSICAL_ADDRESS  Address;
>  
>for ( ; StartIndex <= EndIndex; StartIndex++) {
>  //
>  // Get the address and the page size from the Info.
>  //
> -Address = Info->Entry[StartIndex].GuestFrameNumber << EFI_PAGE_SHIFT;
> +Address = ((UINT64)Info->Entry[StartIndex].GuestFrameNumber) << 
> EFI_PAGE_SHIFT;

Minor nit: why cast to UINT64 not EFI_PHYSICAL_ADDRESS?

Otherwise looks good to me.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#37): https://edk2.groups.io/g/devel/message/37
Mute This Topic: https://groups.io/mt/102520474/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 20/30] OvmfPkg/LoongArchVirt: Add serial port library

2023-11-13 Thread Laszlo Ersek
On 11/10/23 05:51, Chao Li wrote:
> Hi Laszlo,
> 
> Sorry, it is my fault, I should separate this this patch for two
> standalone patches, and with some detailed commit message. I will fix
> this in V3.
> 
> Currently, there are two libraries are not independent, so I guess you
> are talking about Fdt16550SerialPortHookLib. I would say that the
> different is not in GetSerialConsolePortAddress, the logic about this
> function is same to ARM, the different is in
> PlatformHookSerialPortInitialize. Since some platform do not require
> running code on memory during the PEI phase, so the ARM version of
> PlatformHookSerialPortInitialize will use PcdSet to set a PCD value, if
> the memory is not ready, this funciton can not be used. So this library
> is override from ArmVirtPkg to LongArchVirt. 
> 
> BTW, the new library FdtSerialProtAddressLib which you committed a few
> days ago, I will look into it and try it. Roughly speaking, it is look
> like the code for obtaining the serial port address is sparated from the
> HookLIb. I have a question, can I move this library to OvmfPkg so that
> other ARCH can use it easily?

Yes, I think that's consistent with earlier code movements. Moving code
from ArmVirtPkg to OvmfPkg for improving (or enabling) code reuse is
valid, because ArmVirtPkg can continue consuming the same code from OvmfPkg.

> 
> Regarding FdtSerialPortAddressLib, I would like to say that it was not
> committed when I porting LoongArchVirt,  my code base is based on
> stable202308, so I don't know you committed a new library, sorry.

Sure, that sometimes happens when a new feature takes long (either to
implement, or to review).

Laszlo

> 
> 
> 
> Thanks,
> Chao
> 在 2023/11/9 06:21, Laszlo Ersek 写道:
>> On 11/7/23 11:12, Chao Li wrote:
>>> Hi Gerd,
>>>
>>> These two libraries is not only copy code, the way of obtain the serial
>>> base address is different from ARM, and the early serial port output
>>> also different from ARM, so these two libraries are LoongArch specific.
>> I think we're going to have to go through the design with "baby steps".
>>
>> The commit message of the patch is empty.
>>
>> Please don't expect reviewers to "reverse engineer" the design from the
>> code. That's hugely taxing. It's hard enough to review code when we
>> precisey know in advance, from the commit message, what the code will
>> try to achieve.
>>
>> You are saying that the way to obtain serial base address is different
>> from ARM, yet the GetSerialConsolePortAddress() function looks very
>> similar to the function that I *replaced* in recent commits eb83b5330961
>> ("ArmVirtPkg: introduce FdtSerialPortAddressLib", 2023-10-26) and
>> f078a6fdd4d7 ("ArmVirtPkg/Fdt16550SerialPortHookLib: rebase to
>> FdtSerialPortAddressLib", 2023-10-26).
>>
>> So there are two issues with your GetSerialConsolePortAddress() function
>> immediately, I would say:
>>
>> - you say that it's different from ARM, but it seems to parse the DTB
>> identically (or mostly identically -- I'm speaking from memory),
>>
>> - I factored out the subject DTB parsing logic in the above-noted
>> commits recently, so even if your GetSerialConsolePortAddress() function
>> is *supposed* to parse the DTB identically to ARM, then the way to
>> employ that logic is different; it should be reused, not duplicated.
>>
>> Now that you have a running prototype (basically evidence that the port
>> to this new architecture can be done), can we go through the design of
>> each component (library, driver etc) one by one? Dumping the whole thing
>> on reviewers all at once, with little documentation, is not helpful. We
>> basically need to start with the specification of each of your modules.
>> See where the existing components in edk2 are not good enough or not
>> flexible enough, etc.
>>
>> Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#36): https://edk2.groups.io/g/devel/message/36
Mute This Topic: https://groups.io/mt/102413885/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 00/37] OvmfPkg: remove the CSM (after edk2-stable202311)

2023-11-13 Thread Gerd Hoffmann
  Hi,

On Sat, Nov 11, 2023 at 12:57:43AM +0100, 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).

Nice cleanup.

Acked-by: Gerd Hoffmann 

take care,
  Gerd



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




Re: [edk2-devel] [PATCH v1 3/7] UefiCpuPkg: Adds SmmCpuSyncLib library class

2023-11-13 Thread Laszlo Ersek
On 11/13/23 04:15, Ni, Ray wrote:
> I provided 4 comments in below, starting with "[Ray".
> 
> Sorry for the poor new Outlook that I am not able to put ">" in the
> original email.
> 
> Thanks,
> Ray
> 
> 
> 
> (1) I agree that the internals of the context should be hidden, but
> (VOID*) is not the right way. Instead, please use an incomplete
> structure type.
> 
> That is, in the library header class file, do the following:
> 
>   typedef struct SMM_CPU_SYNC_CTX SMM_CPU_SYNC_CTX;
> 
> and then make all these functions return and take
> 
>   SMM_CPU_SYNC_CTX *
> 
> The library users will still not know what is inside SMM_CPU_SYNC_CTX,
> just like with (VOID*), but the compiler will be able to perform much
> stronger type checking than with (VOID*).
> 
> And then in the library *instance(s)*, you can complete the incomplete type:
> 
>   struct SMM_CPU_SYNC_CTX {
>     ...
>   };
> 
> [Ray.1] Good suggestion. I still remember you taught me this technique
> when I
> wrote the FrameBufferBltLib.
> 
> (3) By definition, in a function that resets the internals of an object,
> you cannot specify "IN" for that function. It must be OUT.
> 
> [Ray.2] I have a different opinion about IN/OUT.  I think we should use
> "IN OUT".

OK! I can see that "reset" may rely on previous information in the
structure. Furthermore, "IN OUT" may indeed better reflect the
requirement that the object being reset must have been initialized
previously (i.e. that it must be a valid object at the time of the
"reset" call).

> 
> 
> Please add a large comment to the top of the library class header that
> explains the operation / concepts of the context. What operations and
> behaviors are defined for this data type?
> 
> [Ray.3] Good suggestions.
> The lib provides 3 sets of APIs:
> 1. Init/Deinit
> Init() is called in driver's entrypoint for allocating the storage and
> initialize the content of sync object.
> Deinit() is called in driver's unload function for undoing what has been
> done in Init().
> 
> 2. CheckInCpu/CheckOutCpu/LockDoor/GetArrivedCpuCount
> When SMI happens, all processors including BSP enter to SMM mode by
> calling CheckInCpu().
> The elected BSP calls LockDoor() so that CheckInCpu() after that returns
> failure code.
> CheckOutCpu() is called in error handling flow for the CPU who calls
> CheckInCpu() earlier.
> GetArrivedCpuCount() returns the number of checked-in CPUs.
> 
> 3. WaitForAllAPs/ReleaseOneAp/WaitForBsp/ReleaseBsp
> First 2 APIs are called from BSP.
> Latter 2 APIs are called from APs.
> The 4 APIs are used to synchronize the running flow among BSP and APs.

This sounds really nice in fact; I'd be glad to see it captured in the
comments!

> 
>> +
>> +  @return CPU arrival count number.
> 
> (14) why is it necessary for outputting the arrived number when locking?
> [Ray.4] As I explained above, when BSP locks the door, it might need to
> know how many CPUs are in the SMM "room".
> Maybe today the number is not cared by BSP.
> 

This helps, thanks. Please do capture it in the comments.

Laszlo



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




Re: [edk2-devel] [PATCH v3 0/6] CryptoPkg: Enable Openssl native instruction support for AARCH64

2023-11-13 Thread Gerd Hoffmann
On Fri, Nov 10, 2023 at 11:48:04AM +0100, Pierre Gondois wrote:
> v3:
> - Use ArmPkg's function to access register:
>   - Dropped:
> - [PATCH v2 1/7] MdePkg/BaseLib: AARCH64: Add ArmReadCntPctReg()
> - [PATCH v2 2/7] MdePkg/BaseLib: AARCH64: Add ArmReadIdAA64Isar0Reg()
> - [PATCH v2 3/7] MdePkg/BaseRngLib: Prefer ArmReadIdAA64Isar0Reg() over 
> ArmReadIdIsar0()
>   - Added:
> - [PATCH v3 1/6] ArmPkg/ArmLib: Move ArmReadIdAA64Isar0() to ArmLib
> - Allow dependency of CryptoPkg over ArmPkg in CI:
>   - Added:
> - [PATCH v3 2/6] CryptoPkg/CryptoPkg.ci.yaml: Allow dependency upon
> 
> v2:
> - [PATCH v2 2/7] MdePkg/BaseLib: AARCH64: Add ArmReadIdAA64Isar0Reg()
>   - Correct bad mask values in MdePkg/Include/Library/BaseLib.h
> - [PATCH v2 4/7] CryptoPkg/OpensslLib: Add native instruction support:
>   - Add armcap.c to configure.py:sources_filter_fn() instead of
> manually commenting the file in .inf files
> 
> Various OpensslLib implementations are available in edk2. The
> OpensslLibAccel.inf and OpensslLibFullAccel.inf ones use
> architecture specific instructions, e.g. AESE, PMULL, SHA256H, ...,
> allowing to improve speed.

Can't comment on the arm asm bits but the integration
into OpensslLib looks good to me.

Acked-by: Gerd Hoffmann 

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#33): https://edk2.groups.io/g/devel/message/33
Mute This Topic: https://groups.io/mt/102504417/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 1/2] WhitleyOpenBoardPkg: remove references

2023-11-13 Thread Laszlo Ersek
Hi Chasel,

On 11/10/23 02:13, Chiu, Chasel wrote:
> 
> Hi Laszlo,
> 
> I verified and encountered build failure as some files still consuming 
> definitions from LegacyBiosMpTable.h, for example:
> https://github.com/tianocore/edk2-platforms/blob/899a9dc97cd54690513380ad01ee8b2609dbefd5/Platform/Intel/WhitleyOpenBoardPkg/Uba/UbaMain/Common/Dxe/SystemBoardInfoDxe/SystemBoardInfoDxe.c#L22
> 
> Any suggestion that we can reduce impact to existing platforms?

thanks for testing the build!

Here's my problem: this information seems to be exposed
firmware-globally, ultimately. We have a UbaConfigProtocol->AddData()
call, which exposes SystemBoardInfoData. SystemBoardInfoData exposes
SystemBoardInfoCallback(). That one in turn exposes SystemBoardInfoTable
(of type DXE_SYSTEM_BOARD_INFO).

And so on and so on, and ultimately we publicly expose
DEVICE_DATA_HW_LOCAL_INT.

That structure type is defined in
"Platform/Intel/WhitleyOpenBoardPkg/Include/PlatDevData.h", and it only
has the following comment:

"Platform hardwired data describing connection of interrupt sources to
local APICs"

So I can't tell if this structure type officially and explicitly defers
to the MP Table specification, or just ad-hoc reuses the same values.

In the former case, we cannot remove LegacyBiosMpTable.h from edk2 (or
perhaps we need to move it over to edk2-platforms).

In the latter case, we should just replace the enum constants with their
integer values (or perhaps replace them with some different macros, like
ACPI spec macros or similar), and then we can delete LegacyBiosMpTable.h.

That is, we need to figure out where the DEVICE_DATA_HW_LOCAL_INT type
definition originates from.

The particular "DeviceDataHwLocalInt1" array comes from edk2-platforms
commit 3584efd25110 ("WhitleyOpenBoardPkg: Add UBA Modules",
2021-07-14). The commit message is empty -- so it's a dead-end.

The type definition comes from edk2-platforms commit 41bfa85f527a
("WhitleyOpenBoardPkg: Add Includes and Libraries", 2021-07-14). The
commit message is similarly empty.

Laszlo

> 
> Thanks,
> Chasel
> 
> 
> 
>> -Original Message-
>> From: devel@edk2.groups.io  On Behalf Of Laszlo Ersek
>> Sent: Thursday, November 9, 2023 4:06 AM
>> To: devel@edk2.groups.io
>> Cc: Chaganty, Rangasai V ; Desimone, Nathaniel
>> L ; Chiu, Chasel 
>> Subject: [edk2-devel] [edk2-platforms PATCH 1/2] WhitleyOpenBoardPkg:
>> remove  references
>>
>> For removing "MdePkg/Include/IndustryStandard/LegacyBiosMpTable.h" from
>> edk2, first remove the edk2-platforms references to that header file.
>>
>> I can't build-test this change. As far as I can tell, building the 
>> CooperCityRvp and
>> WilsonCityRvp platforms with "build_bios.py" should build these changes;
>> however, both platforms fail to build without FSP blobs.
>>
>> I think there's a fair chance that this patch should work nonetheless;
>>  introduces names prefixed with
>> EFI_LEGACY_MP_TABLE_, and edk2-platforms doesn't contain that string. (The
>> one exception is FEATUREBYTE2_5, which is also absent from edk2-platforms.)
>>
>> Cc: Sai Chaganty 
>> Cc: Nate DeSimone 
>> Cc: Chasel Chiu 
>> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1754
>> Signed-off-by: Laszlo Ersek 
>> ---
>>
>> Platform/Intel/WhitleyOpenBoardPkg/Uba/UbaMain/Common/Dxe/SystemBoar
>> dInfoDxe/SystemBoardInfoDxe.h | 1 -
>>
>> Platform/Intel/WhitleyOpenBoardPkg/Uba/UbaMain/StaticSkuDataDxe/Platform
>> DeviceDataSRP10nm.c   | 1 -
>>  2 files changed, 2 deletions(-)
>>
>> diff --git
>> a/Platform/Intel/WhitleyOpenBoardPkg/Uba/UbaMain/Common/Dxe/SystemBo
>> ardInfoDxe/SystemBoardInfoDxe.h
>> b/Platform/Intel/WhitleyOpenBoardPkg/Uba/UbaMain/Common/Dxe/SystemBo
>> ardInfoDxe/SystemBoardInfoDxe.h
>> index 32c16ff9110a..d8c209a57f75 100644
>> ---
>> a/Platform/Intel/WhitleyOpenBoardPkg/Uba/UbaMain/Common/Dxe/SystemBo
>> ardInfoDxe/SystemBoardInfoDxe.h
>> +++
>> b/Platform/Intel/WhitleyOpenBoardPkg/Uba/UbaMain/Common/Dxe/SystemBo
>> +++ ardInfoDxe/SystemBoardInfoDxe.h
>> @@ -27,7 +27,6 @@
>>  #include 
>>  #include 
>>
>> -#include 
>>  #include 
>>
>>  #endif  //_SYSTEM_BOARD_INFO_DXE_H_
>> diff --git
>> a/Platform/Intel/WhitleyOpenBoardPkg/Uba/UbaMain/StaticSkuDataDxe/Platfor
>> mDeviceDataSRP10nm.c
>> b/Platform/Intel/WhitleyOpenBoardPkg/Uba/UbaMain/StaticSkuDataDxe/Platfor
>> mDeviceDataSRP10nm.c
>> index ed9f80734cd7..b69ae1736bb8 100644
>> ---
>> a/Platform/Intel/WhitleyOpenBoardPkg/Uba/UbaMain/StaticSkuDataDxe/Platfor
>> mDeviceDataSRP10nm.c
>> +++ b/Platform/Intel/WhitleyOpenBoardPkg/Uba/UbaMain/StaticSkuDataDxe/Pl
>> +++ atformDeviceDataSRP10nm.c
>> @@ -8,7 +8,6 @@
>>
>>  #include 
>>  #include 
>> -#include 
>>
>>  #ifndef V_INTEL_VID
>>  #define V_INTEL_VID   0x8086
>>
>>
>>
>>
>>
> 
> 
> 
> 
> 
> 



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

Re: [edk2-devel] [PATCH] UefiCpuPkg/MpInitLib: Enable execute disable bit.

2023-11-13 Thread Gerd Hoffmann
  Hi,

> -  GetProcessorNumber (CpuMpData, );
> -  RestoreVolatileRegisters (>CpuData[0].VolatileRegisters, FALSE);
> -  InterlockedIncrement ((UINT32 *)>FinishedCount);
> -  PlaceAPInMwaitLoopOrRunLoop (
> -CpuMpData->ApLoopMode,
> -CpuMpData->CpuData[ProcessorNumber].StartupApSignal,
> -CpuMpData->ApTargetCState
> -);
> -  ApWakeupFunction (CpuMpData, ProcessorNumber);
> +  GetProcessorNumber(CpuMpData, );
> +  InterlockedIncrement((UINT32 *)>FinishedCount);

You have some whitespace changes here makes the patch hard to read and
I also doubt this will pass the uncrustify check in CI.

take care,
  Gerd



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




Re: [edk2-devel] [PATCH] IntelFsp2Pkg/FspMultiPhaseLib: Remove EFIAPI for local function

2023-11-13 Thread Ashraf Ali S
Reviewed-by: S, Ashraf Ali 

Thanks.,
S, Ashraf Ali

-Original Message-
From: Ni, Ray  
Sent: Monday, November 13, 2023 1:09 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel ; Desimone, Nathaniel L 
; Duggapu, Chinni B 
; Ng, Ray Han Lim ; Zeng, 
Star ; Kuo, Ted ; S, Ashraf Ali 
; Mohapatra, Susovan 
Subject: [PATCH] IntelFsp2Pkg/FspMultiPhaseLib: Remove EFIAPI for local function

FspMultiPhaseWorker() is a local function that's called from
FspMultiPhaseMemInitApiHandler()
and FspMultiPhaseSiInitApiHandlerV2().

Remove "EFIAPI" from its function header.

Signed-off-by: Ray Ni 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Duggapu Chinni B 
Cc: Ray Han Lim Ng 
Cc: Star Zeng 
Cc: Ted Kuo 
Cc: Ashraf Ali S 
Cc: Susovan Mohapatra 
---
 IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c 
b/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c
index 3786da91b1..4fc4104226 100644
--- a/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c
+++ b/IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/FspMultiPhaseLib.c
@@ -1,7 +1,7 @@
 /** @file

   FSP MultiPhase library.

 

-  Copyright (c) 2022, Intel Corporation. All rights reserved.

+  Copyright (c) 2022 - 2023, Intel Corporation. All rights reserved.

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

 

 **/

@@ -58,7 +58,6 @@ FspVariableRequestSwitchStack (
   @retval EFI_DEVICE_ERRORFSP initialization failed.

 **/

 EFI_STATUS

-EFIAPI

 FspMultiPhaseWorker (

   IN UINT32  ApiIdx,

   IN VOID*ApiParam

-- 
2.39.1.windows.1



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