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, &ProcessorNumber);
-  RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters, FALSE);
   InterlockedIncrement ((UINT32 *)&CpuMpData->FinishedCount);
+
+  if (CpuMpData->EnableExecuteDisableForSwitchContext) {
+    EferMsr.Uint64   = AsmReadMsr64 (MSR_IA32_EFER);
+    EferMsr.Bits.NXE = 1;
+    AsmWriteMsr64 (MSR_IA32_EFER, EferMsr.Uint64);
+  }
+
+  RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters, FALSE);

Regards,
Yuanhao

-----Original Message-----
From: Gerd Hoffmann <kra...@redhat.com> 
Sent: Monday, November 13, 2023 6:54 PM
To: Xie, Yuanhao <yuanhao....@intel.com>
Cc: devel@edk2.groups.io; Dong, Eric <eric.d...@intel.com>; Ni, Ray 
<ray...@intel.com>; Kumar, Rahul R <rahul.r.ku...@intel.com>
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, &ProcessorNumber);
> +  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 (#111141): https://edk2.groups.io/g/devel/message/111141
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]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to