public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Lendacky, Thomas" <thomas.lendacky@amd.com>
To: devel@edk2.groups.io
Cc: Brijesh Singh <brijesh.singh@amd.com>,
	Eric Dong <eric.dong@intel.com>, Ray Ni <ray.ni@intel.com>,
	Laszlo Ersek <lersek@redhat.com>,
	Rahul Kumar <rahul1.kumar@intel.com>
Subject: [PATCH v2 11/11] UefiCpuPkg/MpInitLib: For SEV-ES guest, set stack based on processor number
Date: Fri, 16 Oct 2020 11:09:17 -0500	[thread overview]
Message-ID: <3a53fda34f0c765e1f28ba26ac2cb6fa1db29345.1602864557.git.thomas.lendacky@amd.com> (raw)
In-Reply-To: <cover.1602864557.git.thomas.lendacky@amd.com>

From: Tom Lendacky <thomas.lendacky@amd.com>

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

Set the SEV-ES reset stack address for an AP based on the processor number
instead of the APIC ID in case the APIC IDs are not zero-based and densely
packed/enumerated. This will ensure an AP reset stack address does not get
set outside of the AP reset stack memory allocation.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Acked-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 4f4b26a7c196..c9bb1d25c616 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -680,11 +680,16 @@ MpInitLibSevEsAPReset (
   IN CPU_MP_DATA                  *CpuMpData
   )
 {
+  EFI_STATUS       Status;
+  UINTN            ProcessorNumber;
   UINT16           Code16, Code32;
   AP_RESET         *APResetFn;
   UINTN            BufferStart;
   UINTN            StackStart;
 
+  Status = GetProcessorNumber (CpuMpData, &ProcessorNumber);
+  ASSERT_EFI_ERROR (Status);
+
   Code16 = GetProtectedMode16CS ();
   Code32 = GetProtectedMode32CS ();
 
@@ -696,7 +701,7 @@ MpInitLibSevEsAPReset (
 
   BufferStart = CpuMpData->MpCpuExchangeInfo->BufferStart;
   StackStart = CpuMpData->SevEsAPResetStackStart -
-                 (AP_RESET_STACK_SIZE * GetApicId ());
+                 (AP_RESET_STACK_SIZE * ProcessorNumber);
 
   //
   // This call never returns.
-- 
2.28.0


      parent reply	other threads:[~2020-10-16 16:10 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 16:09 [PATCH v2 00/11] SEV-ES guest support fixes and cleanup Lendacky, Thomas
2020-10-16 16:09 ` [PATCH v2 01/11] MdePkg, OvmfPkg: Clean up GHCB field offsets and save area Lendacky, Thomas
2020-10-19  1:41   ` 回复: " gaoliming
2020-10-19 12:50     ` Lendacky, Thomas
2020-10-19 20:17       ` Laszlo Ersek
2020-10-19 20:48         ` Lendacky, Thomas
2020-10-19 20:42       ` Laszlo Ersek
2020-10-20  1:08         ` 回复: " gaoliming
2020-10-20  8:31           ` Laszlo Ersek
2020-10-20 13:10             ` Lendacky, Thomas
2020-10-21  0:54               ` 回复: " gaoliming
2020-10-21 21:54                 ` Lendacky, Thomas
2020-10-22  1:25                   ` 回复: [edk2-devel] " gaoliming
2020-10-22 13:12                     ` Laszlo Ersek
2020-10-23  2:57                       ` 回复: " gaoliming
2020-10-26 16:34                         ` Lendacky, Thomas
2020-10-27  7:57                           ` Dong, Eric
2020-10-28 17:42                             ` Lendacky, Thomas
2020-10-21 12:29               ` Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 02/11] UefiCpuPkg/VmgExitLib: Add interfaces to set/read GHCB ValidBitmap bits Lendacky, Thomas
2020-10-19 20:46   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 03/11] OvmfPkg/VmgExitLib: Implement new VmgExitLib interfaces Lendacky, Thomas
2020-10-19 20:51   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 04/11] OvmfPkg/VmgExitLib: Set the SW exit fields when performing VMGEXIT Lendacky, Thomas
2020-10-19 20:53   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 05/11] OvmfPkg/VmgExitLib: Set the SwScratch valid bit for IOIO events Lendacky, Thomas
2020-10-19 20:54   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 06/11] OvmfPkg/VmgExitLib: Set the SwScratch valid bit for MMIO events Lendacky, Thomas
2020-10-16 16:09 ` [PATCH v2 07/11] UefiCpuPkg/MpInitLib: Set the SW exit fields when performing VMGEXIT Lendacky, Thomas
2020-10-16 16:09 ` [PATCH v2 08/11] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Set the SwScratch valid bit Lendacky, Thomas
2020-10-19 20:57   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 09/11] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Fix erase blocks for SEV-ES Lendacky, Thomas
2020-10-16 16:09 ` [PATCH v2 10/11] UefiCpuPkg, OvmfPkg: Disable interrupts when using the GHCB Lendacky, Thomas
2020-10-19 21:07   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` Lendacky, Thomas [this message]

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=3a53fda34f0c765e1f28ba26ac2cb6fa1db29345.1602864557.git.thomas.lendacky@amd.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