public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yuanhao Xie" <yuanhao.xie@intel.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Dong, Eric" <eric.dong@intel.com>, "Ni, Ray" <ray.ni@intel.com>,
	"Kumar, Rahul R" <rahul.r.kumar@intel.com>
Subject: Re: [edk2-devel] [Patch V4] UefiCpuPkg/MpInitLib: Enable execute disable bit.
Date: Mon, 13 Nov 2023 11:08:03 +0000	[thread overview]
Message-ID: <SJ0PR11MB5037D1D3AA2D61F892DDA846F0B3A@SJ0PR11MB5037.namprd11.prod.outlook.com> (raw)
In-Reply-To: <bo6iugtrgspk4yzvttlvvlmxrhtamu4tuhfosfzs22soracvcr@bthqsovmob4j>

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 <kraxel@redhat.com> 
Sent: Monday, November 13, 2023 6:54 PM
To: Xie, Yuanhao <yuanhao.xie@intel.com>
Cc: devel@edk2.groups.io; Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Kumar, Rahul R <rahul.r.kumar@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/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2023-11-13 11:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13  5:59 [edk2-devel] [Patch V4] UefiCpuPkg/MpInitLib: Enable execute disable bit Yuanhao Xie
2023-11-13 10:54 ` Gerd Hoffmann
2023-11-13 11:08   ` Yuanhao Xie [this message]
2023-11-13 12:28 ` Gerd Hoffmann
2023-11-13 18:02 ` Laszlo Ersek
2023-11-17  7:01   ` Ni, Ray
2023-11-17  8:38     ` Laszlo Ersek
2023-11-20  4:57       ` Yuanhao Xie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SJ0PR11MB5037D1D3AA2D61F892DDA846F0B3A@SJ0PR11MB5037.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox