summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/CpuHotplugSmm
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2020-02-26 23:11:48 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-03-04 12:22:07 +0000
commitf668e78871659f438ed4548650ffd07c31a429b5 (patch)
tree92a747aa8b84f15975abad230194491134c3f10c /OvmfPkg/CpuHotplugSmm
parent590f5f09b7e11682e2607633bb08fcdac2c2bb4c (diff)
downloadedk2-f668e78871659f438ed4548650ffd07c31a429b5.tar.gz
edk2-f668e78871659f438ed4548650ffd07c31a429b5.tar.bz2
edk2-f668e78871659f438ed4548650ffd07c31a429b5.zip
OvmfPkg/CpuHotplugSmm: define the QEMU_CPUHP_CMD_GET_ARCH_ID macro
QEMU commit 3a61c8db9d25 ("acpi: cpuhp: add CPHP_GET_CPU_ID_CMD command", 2020-01-22) introduced a new command in the modern CPU hotplug register block that lets the firmware query the arch-specific IDs (on IA32/X64: the APIC IDs) of CPUs. Add a macro for this command value, because we'll need it later. At the same time, add a sanity check for the modern hotplug interface to CpuHotplugSmm. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Igor Mammedov <imammedo@redhat.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1512 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20200226221156.29589-9-lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Diffstat (limited to 'OvmfPkg/CpuHotplugSmm')
-rw-r--r--OvmfPkg/CpuHotplugSmm/CpuHotplug.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c
index fd09403eab..5df8c689c6 100644
--- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c
+++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c
@@ -7,6 +7,7 @@
**/
#include <IndustryStandard/Q35MchIch9.h> // ICH9_APM_CNT
+#include <IndustryStandard/QemuCpuHotplug.h> // QEMU_CPUHP_CMD_GET_PENDING
#include <Library/BaseLib.h> // CpuDeadLoop()
#include <Library/DebugLib.h> // ASSERT()
#include <Library/MmServicesTableLib.h> // gMmst
@@ -14,6 +15,8 @@
#include <Protocol/MmCpuIo.h> // EFI_MM_CPU_IO_PROTOCOL
#include <Uefi/UefiBaseType.h> // EFI_STATUS
+#include "QemuCpuhp.h" // QemuCpuhpWriteCpuSelector()
+
//
// We use this protocol for accessing IO Ports.
//
@@ -169,6 +172,38 @@ CpuHotplugEntry (
}
//
+ // Sanity-check the CPU hotplug interface.
+ //
+ // Both of the following features are part of QEMU 5.0, introduced primarily
+ // in commit range 3e08b2b9cb64..3a61c8db9d25:
+ //
+ // (a) the QEMU_CPUHP_CMD_GET_ARCH_ID command of the modern CPU hotplug
+ // interface,
+ //
+ // (b) the "SMRAM at default SMBASE" feature.
+ //
+ // From these, (b) is restricted to 5.0+ machine type versions, while (a)
+ // does not depend on machine type version. Because we ensured the stricter
+ // condition (b) through PcdQ35SmramAtDefaultSmbase above, the (a)
+ // QEMU_CPUHP_CMD_GET_ARCH_ID command must now be available too. While we
+ // can't verify the presence of precisely that command, we can still verify
+ // (sanity-check) that the modern interface is active, at least.
+ //
+ // Consult the "Typical usecases | Detecting and enabling modern CPU hotplug
+ // interface" section in QEMU's "docs/specs/acpi_cpu_hotplug.txt", on the
+ // following.
+ //
+ QemuCpuhpWriteCpuSelector (mMmCpuIo, 0);
+ QemuCpuhpWriteCpuSelector (mMmCpuIo, 0);
+ QemuCpuhpWriteCommand (mMmCpuIo, QEMU_CPUHP_CMD_GET_PENDING);
+ if (QemuCpuhpReadCommandData2 (mMmCpuIo) != 0) {
+ Status = EFI_NOT_FOUND;
+ DEBUG ((DEBUG_ERROR, "%a: modern CPU hotplug interface: %r\n",
+ __FUNCTION__, Status));
+ goto Fatal;
+ }
+
+ //
// Register the handler for the CPU Hotplug MMI.
//
Status = gMmst->MmiHandlerRegister (