]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/CpuHotplugSmm: define the QEMU_CPUHP_CMD_GET_ARCH_ID macro
authorLaszlo Ersek <lersek@redhat.com>
Wed, 26 Feb 2020 22:11:48 +0000 (23:11 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 4 Mar 2020 12:22:07 +0000 (12:22 +0000)
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>
OvmfPkg/CpuHotplugSmm/CpuHotplug.c
OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h

index fd09403eabf3693da15a0ac7595360b943d7fb0c..5df8c689c63aac0ed4d4b3810d790c113bde5722 100644 (file)
@@ -7,6 +7,7 @@
 **/\r
 \r
 #include <IndustryStandard/Q35MchIch9.h>     // ICH9_APM_CNT\r
+#include <IndustryStandard/QemuCpuHotplug.h> // QEMU_CPUHP_CMD_GET_PENDING\r
 #include <Library/BaseLib.h>                 // CpuDeadLoop()\r
 #include <Library/DebugLib.h>                // ASSERT()\r
 #include <Library/MmServicesTableLib.h>      // gMmst\r
@@ -14,6 +15,8 @@
 #include <Protocol/MmCpuIo.h>                // EFI_MM_CPU_IO_PROTOCOL\r
 #include <Uefi/UefiBaseType.h>               // EFI_STATUS\r
 \r
+#include "QemuCpuhp.h"                       // QemuCpuhpWriteCpuSelector()\r
+\r
 //\r
 // We use this protocol for accessing IO Ports.\r
 //\r
@@ -168,6 +171,38 @@ CpuHotplugEntry (
     goto Fatal;\r
   }\r
 \r
+  //\r
+  // Sanity-check the CPU hotplug interface.\r
+  //\r
+  // Both of the following features are part of QEMU 5.0, introduced primarily\r
+  // in commit range 3e08b2b9cb64..3a61c8db9d25:\r
+  //\r
+  // (a) the QEMU_CPUHP_CMD_GET_ARCH_ID command of the modern CPU hotplug\r
+  //     interface,\r
+  //\r
+  // (b) the "SMRAM at default SMBASE" feature.\r
+  //\r
+  // From these, (b) is restricted to 5.0+ machine type versions, while (a)\r
+  // does not depend on machine type version. Because we ensured the stricter\r
+  // condition (b) through PcdQ35SmramAtDefaultSmbase above, the (a)\r
+  // QEMU_CPUHP_CMD_GET_ARCH_ID command must now be available too. While we\r
+  // can't verify the presence of precisely that command, we can still verify\r
+  // (sanity-check) that the modern interface is active, at least.\r
+  //\r
+  // Consult the "Typical usecases | Detecting and enabling modern CPU hotplug\r
+  // interface" section in QEMU's "docs/specs/acpi_cpu_hotplug.txt", on the\r
+  // following.\r
+  //\r
+  QemuCpuhpWriteCpuSelector (mMmCpuIo, 0);\r
+  QemuCpuhpWriteCpuSelector (mMmCpuIo, 0);\r
+  QemuCpuhpWriteCommand (mMmCpuIo, QEMU_CPUHP_CMD_GET_PENDING);\r
+  if (QemuCpuhpReadCommandData2 (mMmCpuIo) != 0) {\r
+    Status = EFI_NOT_FOUND;\r
+    DEBUG ((DEBUG_ERROR, "%a: modern CPU hotplug interface: %r\n",\r
+      __FUNCTION__, Status));\r
+    goto Fatal;\r
+  }\r
+\r
   //\r
   // Register the handler for the CPU Hotplug MMI.\r
   //\r
index cf0745610f2c496ddf4c4190c26cbb969cfe2a46..3d013633501b3ee3892c95b0d2b8ded3c17c98ae 100644 (file)
@@ -39,5 +39,6 @@
 \r
 #define QEMU_CPUHP_W_CMD                     0x5\r
 #define QEMU_CPUHP_CMD_GET_PENDING             0x0\r
+#define QEMU_CPUHP_CMD_GET_ARCH_ID             0x3\r
 \r
 #endif // QEMU_CPU_HOTPLUG_H_\r