Skip to contentSkip to conversation

microvm: add acpi support

PATCH Superseded Gerd Hoffmann 3 participants 28 messages Jul 2, 2020 – Jul 6, 2020

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v4 cover microvm: add acpi support

I know that not supporting ACPI in microvm is intentional. If you still don't want ACPI this is perfectly fine, you can use the usual -no-acpi switch to toggle ACPI support.

These are the advantages you are going to loose then:

(1) virtio-mmio device discovery without command line hacks (tweaking the command line is a problem when not using direct kernel boot).
(2) Better IO-APIC support, we can use IRQ lines 16-23.
(3) ACPI power button (aka powerdown request) works.
(4) machine poweroff (aka S5 state) works.

Together with seabios patches for virtio-mmio support this allows to boot standard fedora images (cloud, coreos, workstation live) with the microvm machine type.

git branch for testing (including updated seabios):
https://git.kraxel.org/cgit/qemu/log/?h=sirius/microvm

changes in v2:
* some acpi cleanups are an separate patch series now.
* switched to hw reduced acpi & generic event device.
* misc fixes here and there.

changes in v3:
* depeds on "[PATCH v6 00/16] acpi: i386 tweaks" series.
* renamed qboot to qboot.bin
* updated seabios to master branch snapshot.
- this version boots fine with rtc=off
* generic event device tweaks (Igor's comments).
* make SMP work.
* add RfC patches to turn off acpi by default for microvm.
* misc fixes here and there.

changes in v4
* rebase to latest master
- this also depends on the pending seabios update
* drop some patches which got cherry-picked.
* wire up cpu hotplug (also does coldplug cpu init).
* add microvm acpi test case.
* dropped RfC patches to turn off acpi by default for microvm.
* misc fixes here and there.

take care,
Gerd

Gerd Hoffmann (21):
microvm: name qboot binary qboot.rom
seabios: add microvm config, update build rules
seabios: add bios-microvm.bin binary
acpi: ged: add control regs
acpi: ged: add x86 device variant.
acpi: move acpi_dsdt_add_power_button() to ged
microvm: make virtio irq base runtime configurable microvm/acpi: add minimal acpi support microvm/acpi: add acpi_dsdt_add_virtio() for x86 microvm/acpi: use GSI 16-23 for virtio microvm/acpi: use seabios with acpi=on microvm/acpi: disable virtio-mmio cmdline hack
x86: constify x86_machine_is_*_enabled
x86: move acpi_dev from pc/microvm
x86: move cpu plug from pc to x86
microvm: wire up hotplug
tests/acpi: clear bios-tables-test-allowed-diff.h tests/acpi: allow microvm test data updates. tests/acpi: allow override blkdev tests/acpi: add microvm test
tests/acpi: update expected data files for microvm

 hw/i386/acpi-microvm.h                      |   8 +
 include/hw/acpi/generic_event_device.h      |  12 +
 include/hw/i386/microvm.h                   |  10 +-
 include/hw/i386/pc.h                        |   1 -
 include/hw/i386/x86.h                       |  11 +-
 tests/qtest/bios-tables-test-allowed-diff.h |  18 --
 hw/acpi/generic_event_device.c              |  52 ++++
 hw/arm/virt-acpi-build.c                    |   8 -
 hw/i386/acpi-build.c                        |   2 +-
 hw/i386/acpi-microvm.c                      | 234 ++++++++++++++++++
 hw/i386/generic_event_device_x86.c          |  36 +++
 hw/i386/microvm.c                           | 105 +++++++-
 hw/i386/pc.c                                | 260 ++------------------
 hw/i386/pc_piix.c                           |   2 +-
 hw/i386/pc_q35.c                            |   2 +-
 hw/i386/x86.c                               | 226 ++++++++++++++++-
 tests/qtest/bios-tables-test.c              |  21 +-
 hw/i386/Kconfig                             |   1 +
 hw/i386/Makefile.objs                       |   2 +
 pc-bios/bios-microvm.bin                    | Bin 65536 -> 131072 bytes
 pc-bios/qboot.rom                           | Bin 0 -> 65536 bytes
 roms/Makefile                               |  11 +-
 roms/config.seabios-microvm                 |  26 ++
 tests/data/acpi/microvm/APIC                | Bin 0 -> 70 bytes
 tests/data/acpi/microvm/DSDT                | Bin 0 -> 365 bytes
 tests/data/acpi/microvm/FACP                | Bin 0 -> 268 bytes
 26 files changed, 761 insertions(+), 287 deletions(-)
 create mode 100644 hw/i386/acpi-microvm.h
 create mode 100644 hw/i386/acpi-microvm.c
 create mode 100644 hw/i386/generic_event_device_x86.c
 create mode 100644 pc-bios/qboot.rom
 create mode 100644 roms/config.seabios-microvm
 create mode 100644 tests/data/acpi/microvm/APIC
 create mode 100644 tests/data/acpi/microvm/DSDT
 create mode 100644 tests/data/acpi/microvm/FACP
Signature · 1 line
2.18.4
#1 lore raw

PATCH v4 1/21 microvm: name qboot binary qboot.rom

qboot isn't a bios and shouldnt be named that way.

---
 hw/i386/microvm.c                       |   4 ++--
 pc-bios/{bios-microvm.bin => qboot.rom} | Bin
 roms/Makefile                           |   6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
 rename pc-bios/{bios-microvm.bin => qboot.rom} (100%)
hw/i386/microvm.c +2 -2
index 5e931975a06d..1300c396947b 100644
@@ -47,7 +47,7 @@
 #include "kvm_i386.h"
 #include "hw/xen/start_info.h"
 
-#define MICROVM_BIOS_FILENAME "bios-microvm.bin"
+#define MICROVM_QBOOT_FILENAME "qboot.rom"
 
 static void microvm_set_rtc(MicrovmMachineState *mms, ISADevice *s)
 {
@@ -158,7 +158,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)
     }
 
     if (bios_name == NULL) {
-        bios_name = MICROVM_BIOS_FILENAME;
+        bios_name = MICROVM_QBOOT_FILENAME;
     }
     x86_bios_rom_init(get_system_memory(), true);
 }
pc-bios/qboot.rom renamed from pc-bios/bios-microvm.bin +0 -0
similarity index 100%
rename from pc-bios/bios-microvm.bin
rename to pc-bios/qboot.rom
roms/Makefile +3 -3
index f9acf39954dc..b185c880541c 100644
@@ -68,7 +68,7 @@ default help:
 	@echo "  opensbi64-virt     -- update OpenSBI for 64-bit virt machine"
 	@echo "  opensbi32-sifive_u -- update OpenSBI for 32-bit sifive_u machine"
 	@echo "  opensbi64-sifive_u -- update OpenSBI for 64-bit sifive_u machine"
-	@echo "  bios-microvm       -- update bios-microvm.bin (qboot)"
+	@echo "  qboot              -- update qboot"
 	@echo "  clean              -- delete the files generated by the previous" \
 	                              "build targets"
 
@@ -194,9 +194,9 @@ opensbi64-sifive_u:
 		PLATFORM="sifive/fu540"
 	cp opensbi/build/platform/sifive/fu540/firmware/fw_jump.bin ../pc-bios/opensbi-riscv64-sifive_u-fw_jump.bin
 
-bios-microvm:
+qboot:
 	$(MAKE) -C qboot
-	cp qboot/bios.bin ../pc-bios/bios-microvm.bin
+	cp qboot/bios.bin ../pc-bios/qboot.rom
 
 clean:
 	rm -rf seabios/.config seabios/out seabios/builds
Signature · 1 line
2.18.4
#2 lore raw

PATCH v4 2/21 seabios: add microvm config, update build rules

In reply to Gerd Hoffmann
---
 roms/Makefile               |  5 ++++-
 roms/config.seabios-microvm | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 roms/config.seabios-microvm
roms/Makefile +4 -1
index b185c880541c..1a9d14674464 100644
@@ -72,9 +72,12 @@ default help:
 	@echo "  clean              -- delete the files generated by the previous" \
 	                              "build targets"
 
-bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k
+bios: build-seabios-config-seabios-128k \
+		build-seabios-config-seabios-256k \
+		build-seabios-config-seabios-microvm
 	cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin
 	cp seabios/builds/seabios-256k/bios.bin ../pc-bios/bios-256k.bin
+	cp seabios/builds/seabios-microvm/bios.bin ../pc-bios/bios-microvm.bin
 
 vgabios seavgabios: $(patsubst %,seavgabios-%,$(vgabios_variants))
 
roms/config.seabios-microvm new file +26 -0
new file mode 100644
index 000000000000..a253e2edc6ec
@@ -0,0 +1,26 @@
+CONFIG_QEMU=y
+CONFIG_QEMU_HARDWARE=y
+CONFIG_PERMIT_UNALIGNED_PCIROM=y
+CONFIG_ROM_SIZE=128
+CONFIG_XEN=n
+CONFIG_BOOTSPLASH=n
+CONFIG_ATA=n
+CONFIG_AHCI=n
+CONFIG_SDCARD=n
+CONFIG_PVSCSI=n
+CONFIG_ESP_SCSI=n
+CONFIG_LSI_SCSI=n
+CONFIG_MEGASAS=n
+CONFIG_MPT_SCSI=n
+CONFIG_FLOPPY=n
+CONFIG_FLASH_FLOPPY=n
+CONFIG_NVME=n
+CONFIG_PS2PORT=n
+CONFIG_USB=n
+CONFIG_LPT=n
+CONFIG_RTC_TIMER=n
+CONFIG_USE_SMM=n
+CONFIG_PMTIMER=n
+CONFIG_TCGBIOS=n
+CONFIG_HARDWARE_IRQ=n
+CONFIG_ACPI_PARSE=y
Signature · 1 line
2.18.4
#3 lore raw

PATCH v4 3/21 seabios: add bios-microvm.bin binary

In reply to Gerd Hoffmann
---
 pc-bios/bios-microvm.bin | Bin 0 -> 131072 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/bios-microvm.bin
pc-bios/bios-microvm.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..352c82692e11155c3e2c70d226c789a7c2b055f4
GIT binary patch
Signature · 1 line
2.18.4
#4 lore raw

PATCH v4 4/21 acpi: ged: add control regs

In reply to Gerd Hoffmann

Add control regs (sleep, reset) for hw-reduced acpi.

---
 include/hw/acpi/generic_event_device.h |  7 ++++
 hw/acpi/generic_event_device.c         | 44 ++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
include/hw/acpi/generic_event_device.h +7 -0
index 90a9180db572..474c92198080 100644
@@ -72,6 +72,12 @@
 #define ACPI_GED_EVT_SEL_OFFSET    0x0
 #define ACPI_GED_EVT_SEL_LEN       0x4
 
+#define ACPI_GED_REG_SLEEP_CTL     0x00
+#define ACPI_GED_REG_SLEEP_STS     0x01
+#define ACPI_GED_REG_RESET         0x02
+#define   ACPI_GED_RESET_VALUE     0x42
+#define ACPI_GED_REG_COUNT         0x03
+
 #define GED_DEVICE      "GED"
 #define AML_GED_EVT_REG "EREG"
 #define AML_GED_EVT_SEL "ESEL"
@@ -87,6 +93,7 @@
 
 typedef struct GEDState {
     MemoryRegion evt;
+    MemoryRegion regs;
     uint32_t     sel;
 } GEDState;
 
hw/acpi/generic_event_device.c +44 -0

62 lines not on this page · raw message

Signature · 1 line
2.18.4
#5 lore raw

PATCH v4 5/21 acpi: ged: add x86 device variant.

In reply to Gerd Hoffmann

Set AcpiDeviceIfClass->madt_cpu,
otherwise identical to TYPE_ACPI_GED.

---
 include/hw/acpi/generic_event_device.h |  4 +++
 hw/i386/generic_event_device_x86.c     | 36 ++++++++++++++++++++++++++
 hw/i386/Makefile.objs                  |  1 +
 3 files changed, 41 insertions(+)
 create mode 100644 hw/i386/generic_event_device_x86.c
include/hw/acpi/generic_event_device.h +4 -0
index 474c92198080..9687cb524258 100644
@@ -69,6 +69,10 @@
 #define ACPI_GED(obj) \
     OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED)
 
+#define TYPE_ACPI_GED_X86 "acpi-ged-x86"
+#define ACPI_GED_X86(obj) \
+    OBJECT_CHECK(AcpiGedX86State, (obj), TYPE_ACPI_GED_X86)
+
 #define ACPI_GED_EVT_SEL_OFFSET    0x0
 #define ACPI_GED_EVT_SEL_LEN       0x4
 
hw/i386/generic_event_device_x86.c new file +36 -0
new file mode 100644
index 000000000000..e26fb02a2ef6
@@ -0,0 +1,36 @@
+/*
+ * x86 variant of the generic event device for hw reduced acpi
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2 or later, as published by the Free Software Foundation.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/acpi/generic_event_device.h"
+#include "hw/i386/pc.h"
+
+static void acpi_ged_x86_class_init(ObjectClass *class, void *data)
+{
+    AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(class);
+
+    adevc->madt_cpu = pc_madt_cpu_entry;
+}
+
+static const TypeInfo acpi_ged_x86_info = {
+    .name          = TYPE_ACPI_GED_X86,
+    .parent        = TYPE_ACPI_GED,
+    .class_init    = acpi_ged_x86_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_HOTPLUG_HANDLER },
+        { TYPE_ACPI_DEVICE_IF },
+        { }
+    }
+};
+
+static void acpi_ged_x86_register_types(void)
+{
+    type_register_static(&acpi_ged_x86_info);
+}
+
+type_init(acpi_ged_x86_register_types)
hw/i386/Makefile.objs +1 -0
index 6abc74551a72..622739305882 100644
@@ -17,4 +17,5 @@ obj-$(CONFIG_PC) += port92.o
 
 obj-y += kvmvapic.o
 obj-$(CONFIG_ACPI) += acpi-common.o
+obj-$(CONFIG_ACPI_HW_REDUCED) += generic_event_device_x86.o
 obj-$(CONFIG_PC) += acpi-build.o
Signature · 1 line
2.18.4
#6 lore raw

PATCH v4 6/21 acpi: move acpi_dsdt_add_power_button() to ged

In reply to Gerd Hoffmann

Allow reuse for microvm.

---
 include/hw/acpi/generic_event_device.h | 1 +
 hw/acpi/generic_event_device.c         | 8 ++++++++
 hw/arm/virt-acpi-build.c               | 8 --------
 3 files changed, 9 insertions(+), 8 deletions(-)
include/hw/acpi/generic_event_device.h +1 -0
index 9687cb524258..ebed1ffe4231 100644
@@ -113,5 +113,6 @@ typedef struct AcpiGedState {
 
 void build_ged_aml(Aml *table, const char* name, HotplugHandler *hotplug_dev,
                    uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base);
+void acpi_dsdt_add_power_button(Aml *scope);
 
 #endif
hw/acpi/generic_event_device.c +8 -0
index 491df80a5cc7..6df400e1ee16 100644
@@ -142,6 +142,14 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,
     aml_append(table, dev);
 }
 
+void acpi_dsdt_add_power_button(Aml *scope)
+{
+    Aml *dev = aml_device(ACPI_POWER_BUTTON_DEVICE);
+    aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C")));
+    aml_append(dev, aml_name_decl("_UID", aml_int(0)));
+    aml_append(scope, dev);
+}
+
 /* Memory read by the GED _EVT AML dynamic method */
 static uint64_t ged_evt_read(void *opaque, hwaddr addr, unsigned size)
 {
hw/arm/virt-acpi-build.c +0 -8
index 1384a2cf2ab4..852eb6484b0e 100644
@@ -357,14 +357,6 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap,
     aml_append(scope, dev);
 }
 
-static void acpi_dsdt_add_power_button(Aml *scope)
-{
-    Aml *dev = aml_device(ACPI_POWER_BUTTON_DEVICE);
-    aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C")));
-    aml_append(dev, aml_name_decl("_UID", aml_int(0)));
-    aml_append(scope, dev);
-}
-
 static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms)
 {
     PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
Signature · 1 line
2.18.4
#7 lore raw

PATCH v4 7/21 microvm: make virtio irq base runtime configurable

In reply to Gerd Hoffmann
---
 include/hw/i386/microvm.h |  2 +-
 hw/i386/microvm.c         | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)
include/hw/i386/microvm.h +1 -1
index fd34b78e0d2a..03e735723726 100644
@@ -27,7 +27,6 @@
 
 /* Platform virtio definitions */
 #define VIRTIO_MMIO_BASE      0xfeb00000
-#define VIRTIO_IRQ_BASE       5
 #define VIRTIO_NUM_TRANSPORTS 8
 #define VIRTIO_CMDLINE_MAXLEN 64
 
@@ -57,6 +56,7 @@ typedef struct {
     bool auto_kernel_cmdline;
 
     /* Machine state */
+    uint32_t virtio_irq_base;
     bool kernel_cmdline_fixed;
 } MicrovmMachineState;
 
hw/i386/microvm.c +7 -4
index 1300c396947b..ab6ee6c67b1a 100644
@@ -121,10 +121,11 @@ static void microvm_devices_init(MicrovmMachineState *mms)
 
     kvmclock_create();
 
+    mms->virtio_irq_base = 5;
     for (i = 0; i < VIRTIO_NUM_TRANSPORTS; i++) {
         sysbus_create_simple("virtio-mmio",
                              VIRTIO_MMIO_BASE + i * 512,
-                             x86ms->gsi[VIRTIO_IRQ_BASE + i]);
+                             x86ms->gsi[mms->virtio_irq_base + i]);
     }
 
     /* Optional and legacy devices */
@@ -227,7 +228,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)
     x86ms->ioapic_as = &address_space_memory;
 }
 
-static gchar *microvm_get_mmio_cmdline(gchar *name)
+static gchar *microvm_get_mmio_cmdline(gchar *name, uint32_t virtio_irq_base)
 {
     gchar *cmdline;
     gchar *separator;
@@ -247,7 +248,7 @@ static gchar *microvm_get_mmio_cmdline(gchar *name)
     ret = g_snprintf(cmdline, VIRTIO_CMDLINE_MAXLEN,
                      " virtio_mmio.device=512@0x%lx:%ld",
                      VIRTIO_MMIO_BASE + index * 512,
-                     VIRTIO_IRQ_BASE + index);
+                     virtio_irq_base + index);
     if (ret < 0 || ret >= VIRTIO_CMDLINE_MAXLEN) {
         g_free(cmdline);
         return NULL;
@@ -259,6 +260,7 @@ static gchar *microvm_get_mmio_cmdline(gchar *name)
 static void microvm_fix_kernel_cmdline(MachineState *machine)
 {
     X86MachineState *x86ms = X86_MACHINE(machine);
+    MicrovmMachineState *mms = MICROVM_MACHINE(machine);
     BusState *bus;
     BusChild *kid;
     char *cmdline;
@@ -282,7 +284,8 @@ static void microvm_fix_kernel_cmdline(MachineState *machine)
             BusState *mmio_bus = &mmio_virtio_bus->parent_obj;
 
             if (!QTAILQ_EMPTY(&mmio_bus->children)) {
-                gchar *mmio_cmdline = microvm_get_mmio_cmdline(mmio_bus->name);
+                gchar *mmio_cmdline = microvm_get_mmio_cmdline
+                    (mmio_bus->name, mms->virtio_irq_base);
                 if (mmio_cmdline) {
                     char *newcmd = g_strjoin(NULL, cmdline, mmio_cmdline, NULL);
                     g_free(mmio_cmdline);
Signature · 1 line
2.18.4
#8 lore raw

PATCH v4 8/21 microvm/acpi: add minimal acpi support

In reply to Gerd Hoffmann

$subject says all. Can be controlled using -M microvm,acpi=on/off.

---
 hw/i386/acpi-microvm.h    |   8 ++
 include/hw/i386/microvm.h |   9 ++
 hw/i386/acpi-microvm.c    | 181 ++++++++++++++++++++++++++++++++++++++
 hw/i386/microvm.c         |  40 +++++++++
 hw/i386/Kconfig           |   1 +
 hw/i386/Makefile.objs     |   1 +
 6 files changed, 240 insertions(+)
 create mode 100644 hw/i386/acpi-microvm.h
 create mode 100644 hw/i386/acpi-microvm.c
hw/i386/acpi-microvm.h new file +8 -0
new file mode 100644
index 000000000000..dfe853690e15
@@ -0,0 +1,8 @@
+#ifndef HW_I386_ACPI_MICROVM_H
+#define HW_I386_ACPI_MICROVM_H
+
+#include "hw/i386/microvm.h"
+
+void acpi_setup_microvm(MicrovmMachineState *mms);
+
+#endif
include/hw/i386/microvm.h +9 -0
index 03e735723726..b6e0d4395af7 100644
@@ -24,12 +24,18 @@
 
 #include "hw/boards.h"
 #include "hw/i386/x86.h"
+#include "hw/acpi/acpi_dev_interface.h"
 
 /* Platform virtio definitions */
 #define VIRTIO_MMIO_BASE      0xfeb00000
 #define VIRTIO_NUM_TRANSPORTS 8
 #define VIRTIO_CMDLINE_MAXLEN 64
 
+#define GED_MMIO_BASE         0xfea00000
+#define GED_MMIO_BASE_MEMHP   (GED_MMIO_BASE + 0x100)
+#define GED_MMIO_BASE_REGS    (GED_MMIO_BASE + 0x200)
+#define GED_MMIO_IRQ          9
+
 /* Machine type options */
 #define MICROVM_MACHINE_PIT                 "pit"
 #define MICROVM_MACHINE_PIC                 "pic"
@@ -58,6 +64,9 @@ typedef struct {
     /* Machine state */
     uint32_t virtio_irq_base;
     bool kernel_cmdline_fixed;
+    Notifier machine_done;
+    Notifier powerdown_req;
+    AcpiDeviceIf *acpi_dev;
 } MicrovmMachineState;
 
 #define TYPE_MICROVM_MACHINE   MACHINE_TYPE_NAME("microvm")
hw/i386/acpi-microvm.c new file +181 -0

181 lines not on this page · raw message

hw/i386/microvm.c +40 -0
index ab6ee6c67b1a..75eca7306b11 100644
@@ -26,6 +26,8 @@
 #include "sysemu/cpus.h"
 #include "sysemu/numa.h"
 #include "sysemu/reset.h"
+#include "sysemu/runstate.h"
+#include "acpi-microvm.h"
 
 #include "hw/loader.h"
 #include "hw/irq.h"
@@ -41,6 +43,8 @@
 #include "hw/i386/e820_memory_layout.h"
 #include "hw/i386/fw_cfg.h"
 #include "hw/virtio/virtio-mmio.h"
+#include "hw/acpi/acpi.h"
+#include "hw/acpi/generic_event_device.h"
 
 #include "cpu.h"
 #include "elf.h"
@@ -129,6 +133,17 @@ static void microvm_devices_init(MicrovmMachineState *mms)
     }
 
     /* Optional and legacy devices */
+    if (x86_machine_is_acpi_enabled(x86ms)) {
+        DeviceState *dev = qdev_new(TYPE_ACPI_GED_X86);
+        qdev_prop_set_uint32(dev, "ged-event", ACPI_GED_PWR_DOWN_EVT);
+        sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, GED_MMIO_BASE);
+        /* sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, GED_MMIO_BASE_MEMHP); */
+        sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, GED_MMIO_BASE_REGS);
+        sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
+                           x86ms->gsi[GED_MMIO_IRQ]);
+        sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
+        mms->acpi_dev = ACPI_DEVICE_IF(dev);
+    }
 
     if (mms->pic == ON_OFF_AUTO_ON || mms->pic == ON_OFF_AUTO_AUTO) {
         qemu_irq *i8259;
@@ -438,6 +453,26 @@ static void microvm_machine_set_auto_kernel_cmdline(Object *obj, bool value,
     mms->auto_kernel_cmdline = value;
 }
 
+static void microvm_machine_done(Notifier *notifier, void *data)
+{
+    MicrovmMachineState *mms = container_of(notifier, MicrovmMachineState,
+                                            machine_done);
+
+    acpi_setup_microvm(mms);
+}
+
+static void microvm_powerdown_req(Notifier *notifier, void *data)
+{
+    MicrovmMachineState *mms = container_of(notifier, MicrovmMachineState,
+                                            powerdown_req);
+
+    if (mms->acpi_dev) {
+        Object *obj = OBJECT(mms->acpi_dev);
+        AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj);
+        adevc->send_event(mms->acpi_dev, ACPI_POWER_DOWN_STATUS);
+    }
+}
+
 static void microvm_machine_initfn(Object *obj)
 {
     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
@@ -452,6 +487,11 @@ static void microvm_machine_initfn(Object *obj)
 
     /* State */
     mms->kernel_cmdline_fixed = false;
+
+    mms->machine_done.notify = microvm_machine_done;
+    qemu_add_machine_init_done_notifier(&mms->machine_done);
+    mms->powerdown_req.notify = microvm_powerdown_req;
+    qemu_register_powerdown_notifier(&mms->powerdown_req);
 }
 
 static void microvm_class_init(ObjectClass *oc, void *data)
hw/i386/Kconfig +1 -0
index c93f32f6579d..be746bcb49eb 100644
@@ -102,6 +102,7 @@ config MICROVM
     select I8259
     select MC146818RTC
     select VIRTIO_MMIO
+    select ACPI_HW_REDUCED
 
 config X86_IOMMU
     bool
hw/i386/Makefile.objs +1 -0
index 622739305882..bbb2fe78f3cd 100644
@@ -19,3 +19,4 @@ obj-y += kvmvapic.o
 obj-$(CONFIG_ACPI) += acpi-common.o
 obj-$(CONFIG_ACPI_HW_REDUCED) += generic_event_device_x86.o
 obj-$(CONFIG_PC) += acpi-build.o
+obj-$(CONFIG_MICROVM) += acpi-microvm.o
Signature · 1 line
2.18.4
#9 lore raw

Re: [PATCH v4 08/21] microvm/acpi: add minimal acpi support

hw/i386/acpi-microvm.c line 78

Quoted 5 lines · Gerd Hoffmann
hw/i386/acpi-microvm.c new file +5 -0
+    /* copy AML table into ACPI tables blob and patch header there */
+    g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
+    build_header(linker, table_data,
+        (void *)(table_data->data + table_data->len - dsdt->buf->len),
+        "DSDT", dsdt->buf->len, 5, NULL, NULL);

Why 5? Just curious ...

Signature · 1 line
MST
#10 lore raw

Re: [PATCH v4 08/21] microvm/acpi: add minimal acpi support

Quoted 8 lines · Michael S. Tsirkin

hw/i386/acpi-microvm.c line 78

Quoted 5 lines · Gerd Hoffmann
hw/i386/acpi-microvm.c new file +5 -0
+    /* copy AML table into ACPI tables blob and patch header there */
+    g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
+    build_header(linker, table_data,
+        (void *)(table_data->data + table_data->len - dsdt->buf->len),
+        "DSDT", dsdt->buf->len, 5, NULL, NULL);

Why 5? Just curious ...

IIRC because the hw reduced hardware profile needs acpi 5+ ...

take care,
Gerd

#11 lore raw

Re: [PATCH v4 08/21] microvm/acpi: add minimal acpi support

Quoted 8 lines · Gerd Hoffmann
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Gerd Hoffmann
hw/i386/acpi-microvm.c new file +5 -0
+    /* copy AML table into ACPI tables blob and patch header there */
+    g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
+    build_header(linker, table_data,
+        (void *)(table_data->data + table_data->len - dsdt->buf->len),
+        "DSDT", dsdt->buf->len, 5, NULL, NULL);
Quoted 6 lines
Quoted 1 line

Why 5? Just curious ...

IIRC because the hw reduced hardware profile needs acpi 5+ ...

take care,
Gerd

Well ACPI spec 5 says revision value is 2.

Let's use standard practice in ACPI code, and add comments near each value documenting earliest spec revision where this appeared, chapter where they came from and some verbatim text that both explains and can be searched for in later spec revisions.

In fact, same applies to a bunch of other code in this patchset which just uses macros which does not help all that much as they don't appear in spec as is. Can you pls go over it and add such comments where appropriate?

Signature · 1 line
MST
#12 lore raw

Re: [PATCH v4 08/21] microvm/acpi: add minimal acpi support

Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · Gerd Hoffmann
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Gerd Hoffmann
(quoted diff) +5 -0
+    /* copy AML table into ACPI tables blob and patch header there */
+    g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
+    build_header(linker, table_data,
+        (void *)(table_data->data + table_data->len - dsdt->buf->len),
+        "DSDT", dsdt->buf->len, 5, NULL, NULL);
Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Why 5? Just curious ...

IIRC because the hw reduced hardware profile needs acpi 5+ ...

take care,
Gerd

Well ACPI spec 5 says revision value is 2.

Yep. Confused that with FACS.rev

Quoted 4 lines

Let's use standard practice in ACPI code, and add comments near each value documenting earliest spec revision where this appeared, chapter where they came from and some verbatim text that both explains and can be searched for in later spec revisions.

Incremental patch with the changes I have so far.
Anything important missing?

Is there a formal spec (other than the code for arm virt) for the virtio-mmio acpi entries btw?

take care,
Gerd

From bc82d52a013169b3738a06f33ac7d2289922a683 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Mon, 6 Jul 2020 16:04:36 +0200
Subject: [PATCH] [fixup] microvm acpi spec refs

---
 hw/i386/acpi-microvm.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
hw/i386/acpi-microvm.c +16 -2
index 2f7e50718f70..51916cab42f7 100644
@@ -131,7 +131,7 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker,
     g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
     build_header(linker, table_data,
         (void *)(table_data->data + table_data->len - dsdt->buf->len),
-        "DSDT", dsdt->buf->len, 5, NULL, NULL);
+        "DSDT", dsdt->buf->len, 2, NULL, NULL);
     free_aml_allocator();
 }
 
@@ -144,25 +144,38 @@ static void acpi_build_microvm(AcpiBuildTables *tables,
     GArray *tables_blob = tables->table_data;
     unsigned dsdt, xsdt;
     AcpiFadtData pmfadt = {
+        /*
+         * minimum version for ACPI_FADT_F_HW_REDUCED_ACPI,
+         * see acpi spec "4.1 Hardware-Reduced ACPI"
+         */
         .rev = 5,
         .minor_ver = 1,
+
         .flags = ((1 << ACPI_FADT_F_HW_REDUCED_ACPI) |
                   (1 << ACPI_FADT_F_RESET_REG_SUP)),
+
+        /* Table 5-33 FADT Format -- SLEEP_CONTROL_REG */
         .sleep_ctl = {
             .space_id = AML_AS_SYSTEM_MEMORY,
             .bit_width = 8,
             .address = GED_MMIO_BASE_REGS + ACPI_GED_REG_SLEEP_CTL,
         },
+
+        /* Table 5-33 FADT Format -- SLEEP_STATUS_REG */
         .sleep_sts = {
             .space_id = AML_AS_SYSTEM_MEMORY,
             .bit_width = 8,
             .address = GED_MMIO_BASE_REGS + ACPI_GED_REG_SLEEP_STS,
         },
+
+        /* Table 5-33 FADT Format -- RESET_REG */
         .reset_reg = {
             .space_id = AML_AS_SYSTEM_MEMORY,
             .bit_width = 8,
             .address = GED_MMIO_BASE_REGS + ACPI_GED_REG_RESET,
         },
+
+        /* Table 5-33 FADT Format -- RESET_VALUE */
         .reset_val = ACPI_GED_RESET_VALUE,
     };
 
@@ -191,7 +204,8 @@ static void acpi_build_microvm(AcpiBuildTables *tables,
     /* RSDP is in FSEG memory, so allocate it separately */
     {
         AcpiRsdpData rsdp_data = {
-            .revision = 2,
+            /* Table 5-27 RSDP Structure */
+            .revision = 2, /* rev2 needed for xsdt support */
             .oem_id = ACPI_BUILD_APPNAME6,
             .xsdt_tbl_offset = &xsdt,
             .rsdt_tbl_offset = NULL,
Signature · 1 line
2.18.4
#13 lore raw

PATCH v4 9/21 microvm/acpi: add acpi_dsdt_add_virtio() for x86

In reply to Gerd Hoffmann

Makes x86 linux kernel find virtio-mmio devices automatically.

---
 hw/i386/acpi-microvm.c | 52 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
hw/i386/acpi-microvm.c +52 -0
index 7cd830e628af..20f297517457 100644
@@ -21,6 +21,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "qapi/error.h"
 
 #include "exec/memory.h"
@@ -32,10 +33,60 @@
 #include "hw/boards.h"
 #include "hw/i386/fw_cfg.h"
 #include "hw/i386/microvm.h"
+#include "hw/virtio/virtio-mmio.h"
 
 #include "acpi-common.h"
 #include "acpi-microvm.h"
 
+static void acpi_dsdt_add_virtio(Aml *scope,
+                                 MicrovmMachineState *mms)
+{
+    gchar *separator;
+    long int index;
+    BusState *bus;
+    BusChild *kid;
+
+    bus = sysbus_get_default();
+    QTAILQ_FOREACH(kid, &bus->children, sibling) {
+        DeviceState *dev = kid->child;
+        Object *obj = object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MMIO);
+
+        if (obj) {
+            VirtIOMMIOProxy *mmio = VIRTIO_MMIO(obj);
+            VirtioBusState *mmio_virtio_bus = &mmio->bus;
+            BusState *mmio_bus = &mmio_virtio_bus->parent_obj;
+
+            if (QTAILQ_EMPTY(&mmio_bus->children)) {
+                continue;
+            }
+            separator = g_strrstr(mmio_bus->name, ".");
+            if (!separator) {
+                continue;
+            }
+            if (qemu_strtol(separator + 1, NULL, 10, &index) != 0) {
+                continue;
+            }
+
+            uint32_t irq = mms->virtio_irq_base + index;
+            hwaddr base = VIRTIO_MMIO_BASE + index * 512;
+            hwaddr size = 512;
+
+            Aml *dev = aml_device("VR%02u", (unsigned)index);
+            aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005")));
+            aml_append(dev, aml_name_decl("_UID", aml_int(index)));
+            aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
+
+            Aml *crs = aml_resource_template();
+            aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE));
+            aml_append(crs,
+                       aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
+                                     AML_EXCLUSIVE, &irq, 1));
+            aml_append(dev, aml_name_decl("_CRS", crs));
+            aml_append(scope, dev);
+        }
+    }
+}
+
 static void
 build_dsdt_microvm(GArray *table_data, BIOSLinker *linker,
                    MicrovmMachineState *mms)
@@ -60,6 +111,7 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker,
     build_ged_aml(sb_scope, GED_DEVICE, HOTPLUG_HANDLER(mms->acpi_dev),
                   GED_MMIO_IRQ, AML_SYSTEM_MEMORY, GED_MMIO_BASE);
     acpi_dsdt_add_power_button(sb_scope);
+    acpi_dsdt_add_virtio(sb_scope, mms);
     aml_append(dsdt, sb_scope);
 
     scope = aml_scope("\\");
Signature · 1 line
2.18.4
#14 lore raw

PATCH v4 10/21 microvm/acpi: use GSI 16-23 for virtio

In reply to Gerd Hoffmann

With ACPI enabled and IO-APIC being properly declared in the ACPI tables we can use interrupt lines 16-23 for virtio and avoid shared interrupts.

With acpi disabled we continue to use lines 5-12.

---
 hw/i386/microvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/microvm.c +1 -1
index 75eca7306b11..1bcd57a6fd80 100644
@@ -125,7 +125,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)
 
     kvmclock_create();
 
-    mms->virtio_irq_base = 5;
+    mms->virtio_irq_base = x86_machine_is_acpi_enabled(x86ms) ? 16 : 5;
     for (i = 0; i < VIRTIO_NUM_TRANSPORTS; i++) {
         sysbus_create_simple("virtio-mmio",
                              VIRTIO_MMIO_BASE + i * 512,
Signature · 1 line
2.18.4
#15 lore raw

PATCH v4 11/21 microvm/acpi: use seabios with acpi=on

In reply to Gerd Hoffmann

With acpi=off continue to use qboot.

---
 hw/i386/microvm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/i386/microvm.c +4 -1
index 1bcd57a6fd80..ac605d92b984 100644
@@ -52,6 +52,7 @@
 #include "hw/xen/start_info.h"
 
 #define MICROVM_QBOOT_FILENAME "qboot.rom"
+#define MICROVM_BIOS_FILENAME  "bios-microvm.bin"
 
 static void microvm_set_rtc(MicrovmMachineState *mms, ISADevice *s)
 {
@@ -174,7 +175,9 @@ static void microvm_devices_init(MicrovmMachineState *mms)
     }
 
     if (bios_name == NULL) {
-        bios_name = MICROVM_QBOOT_FILENAME;
+        bios_name = x86_machine_is_acpi_enabled(x86ms)
+            ? MICROVM_BIOS_FILENAME
+            : MICROVM_QBOOT_FILENAME;
     }
     x86_bios_rom_init(get_system_memory(), true);
 }
Signature · 1 line
2.18.4
#16 lore raw

PATCH v4 12/21 microvm/acpi: disable virtio-mmio cmdline hack

In reply to Gerd Hoffmann

... in case we are using ACPI.

---
 hw/i386/microvm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/i386/microvm.c +2 -1
index ac605d92b984..fbda323f3b2a 100644
@@ -343,7 +343,8 @@ static void microvm_machine_reset(MachineState *machine)
     CPUState *cs;
     X86CPU *cpu;
 
-    if (machine->kernel_filename != NULL &&
+    if (!x86_machine_is_acpi_enabled(X86_MACHINE(machine)) &&
+        machine->kernel_filename != NULL &&
         mms->auto_kernel_cmdline && !mms->kernel_cmdline_fixed) {
         microvm_fix_kernel_cmdline(machine);
         mms->kernel_cmdline_fixed = true;
Signature · 1 line
2.18.4
#17 lore raw

PATCH v4 13/21 x86: constify x86_machine_is_*_enabled

In reply to Gerd Hoffmann
---
 include/hw/i386/x86.h | 4 ++--
 hw/i386/x86.c         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/hw/i386/x86.h +2 -2
index b79f24e28545..a350ea3609f5 100644
@@ -110,8 +110,8 @@ void x86_load_linux(X86MachineState *x86ms,
                     bool pvh_enabled,
                     bool linuxboot_dma_enabled);
 
-bool x86_machine_is_smm_enabled(X86MachineState *x86ms);
-bool x86_machine_is_acpi_enabled(X86MachineState *x86ms);
+bool x86_machine_is_smm_enabled(const X86MachineState *x86ms);
+bool x86_machine_is_acpi_enabled(const X86MachineState *x86ms);
 
 /* Global System Interrupts */
 
hw/i386/x86.c +2 -2
index 34229b45c759..614723afbd9d 100644
@@ -846,7 +846,7 @@ void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
                                 bios);
 }
 
-bool x86_machine_is_smm_enabled(X86MachineState *x86ms)
+bool x86_machine_is_smm_enabled(const X86MachineState *x86ms)
 {
     bool smm_available = false;
 
@@ -888,7 +888,7 @@ static void x86_machine_set_smm(Object *obj, Visitor *v, const char *name,
     visit_type_OnOffAuto(v, name, &x86ms->smm, errp);
 }
 
-bool x86_machine_is_acpi_enabled(X86MachineState *x86ms)
+bool x86_machine_is_acpi_enabled(const X86MachineState *x86ms)
 {
     if (x86ms->acpi == ON_OFF_AUTO_OFF) {
         return false;
Signature · 1 line
2.18.4
#18 lore raw

PATCH v4 14/21 x86: move acpi_dev from pc/microvm

In reply to Gerd Hoffmann

Both pc and microvm machine types have a acpi_dev field. Move it to the common base type.

---
 include/hw/i386/microvm.h |  1 -
 include/hw/i386/pc.h      |  1 -
 include/hw/i386/x86.h     |  1 +
 hw/i386/acpi-build.c      |  2 +-
 hw/i386/acpi-microvm.c    |  5 +++--
 hw/i386/microvm.c         | 10 ++++++----
 hw/i386/pc.c              | 34 +++++++++++++++++++---------------
 hw/i386/pc_piix.c         |  2 +-
 hw/i386/pc_q35.c          |  2 +-
 9 files changed, 32 insertions(+), 26 deletions(-)
include/hw/i386/microvm.h +0 -1
index b6e0d4395af7..b8ec99aeb051 100644
@@ -66,7 +66,6 @@ typedef struct {
     bool kernel_cmdline_fixed;
     Notifier machine_done;
     Notifier powerdown_req;
-    AcpiDeviceIf *acpi_dev;
 } MicrovmMachineState;
 
 #define TYPE_MICROVM_MACHINE   MACHINE_TYPE_NAME("microvm")
include/hw/i386/pc.h +0 -1
index dce1273c7dad..5e4126fe817d 100644
@@ -29,7 +29,6 @@ struct PCMachineState {
     Notifier machine_done;
 
     /* Pointers to devices and objects: */
-    HotplugHandler *acpi_dev;
     PCIBus *bus;
     I2CBus *smbus;
     PFlashCFI01 *flash[2];
include/hw/i386/x86.h +1 -0
index a350ea3609f5..de74c831c3ab 100644
@@ -50,6 +50,7 @@ typedef struct {
     FWCfgState *fw_cfg;
     qemu_irq *gsi;
     GMappedFile *initrd_mapped_file;
+    HotplugHandler *acpi_dev;
 
     /* RAM information (sizes, addresses, configuration): */
     ram_addr_t below_4g_mem_size, above_4g_mem_size;
hw/i386/acpi-build.c +1 -1
index b7bcbbbb2a35..c356cc71fe08 100644
@@ -2431,7 +2431,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
 
     acpi_add_table(table_offsets, tables_blob);
     acpi_build_madt(tables_blob, tables->linker, x86ms,
-                    ACPI_DEVICE_IF(pcms->acpi_dev), true);
+                    ACPI_DEVICE_IF(x86ms->acpi_dev), true);
 
     vmgenid_dev = find_vmgenid_dev();
     if (vmgenid_dev) {
hw/i386/acpi-microvm.c +3 -2
index 20f297517457..5856b37a06db 100644
@@ -108,7 +108,7 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker,
     sb_scope = aml_scope("_SB");
     fw_cfg_add_acpi_dsdt(sb_scope, x86ms->fw_cfg);
     isa_build_aml(ISA_BUS(isabus), sb_scope);
-    build_ged_aml(sb_scope, GED_DEVICE, HOTPLUG_HANDLER(mms->acpi_dev),
+    build_ged_aml(sb_scope, GED_DEVICE, x86ms->acpi_dev,
                   GED_MMIO_IRQ, AML_SYSTEM_MEMORY, GED_MMIO_BASE);
     acpi_dsdt_add_power_button(sb_scope);
     acpi_dsdt_add_virtio(sb_scope, mms);
@@ -135,6 +135,7 @@ static void acpi_build_microvm(AcpiBuildTables *tables,
                                MicrovmMachineState *mms)
 {
     MachineState *machine = MACHINE(mms);
+    X86MachineState *x86ms = X86_MACHINE(mms);
     GArray *table_offsets;
     GArray *tables_blob = tables->table_data;
     unsigned dsdt, xsdt;
@@ -178,7 +179,7 @@ static void acpi_build_microvm(AcpiBuildTables *tables,
 
     acpi_add_table(table_offsets, tables_blob);
     acpi_build_madt(tables_blob, tables->linker, X86_MACHINE(machine),
-                    mms->acpi_dev, false);
+                    ACPI_DEVICE_IF(x86ms->acpi_dev), false);
 
     xsdt = tables_blob->len;
     build_xsdt(tables_blob, tables->linker, table_offsets, NULL, NULL);
hw/i386/microvm.c +6 -4
index fbda323f3b2a..3d8a66cfc3ac 100644
@@ -143,7 +143,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
                            x86ms->gsi[GED_MMIO_IRQ]);
         sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
-        mms->acpi_dev = ACPI_DEVICE_IF(dev);
+        x86ms->acpi_dev = HOTPLUG_HANDLER(dev);
     }
 
     if (mms->pic == ON_OFF_AUTO_ON || mms->pic == ON_OFF_AUTO_AUTO) {
@@ -469,11 +469,13 @@ static void microvm_powerdown_req(Notifier *notifier, void *data)
 {
     MicrovmMachineState *mms = container_of(notifier, MicrovmMachineState,
                                             powerdown_req);
+    X86MachineState *x86ms = X86_MACHINE(mms);
 
-    if (mms->acpi_dev) {
-        Object *obj = OBJECT(mms->acpi_dev);
+    if (x86ms->acpi_dev) {
+        Object *obj = OBJECT(x86ms->acpi_dev);
         AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj);
-        adevc->send_event(mms->acpi_dev, ACPI_POWER_DOWN_STATUS);
+        adevc->send_event(ACPI_DEVICE_IF(x86ms->acpi_dev),
+                          ACPI_POWER_DOWN_STATUS);
     }
 }
 
hw/i386/pc.c +19 -15
index 4af9679d039b..98d29ead09b0 100644
@@ -1270,6 +1270,7 @@ static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
                                Error **errp)
 {
     const PCMachineState *pcms = PC_MACHINE(hotplug_dev);
+    const X86MachineState *x86ms = X86_MACHINE(hotplug_dev);
     const PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
     const MachineState *ms = MACHINE(hotplug_dev);
     const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
@@ -1281,7 +1282,7 @@ static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
      * but pcms->acpi_dev is still created. Check !acpi_enabled in
      * addition to cover this case.
      */
-    if (!pcms->acpi_dev || !x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
+    if (!x86ms->acpi_dev || !x86_machine_is_acpi_enabled(x86ms)) {
         error_setg(errp,
                    "memory hotplug is not enabled: missing acpi device or acpi disabled");
         return;
@@ -1292,7 +1293,7 @@ static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
         return;
     }
 
-    hotplug_handler_pre_plug(pcms->acpi_dev, dev, &local_err);
+    hotplug_handler_pre_plug(x86ms->acpi_dev, dev, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
@@ -1307,6 +1308,7 @@ static void pc_memory_plug(HotplugHandler *hotplug_dev,
 {
     Error *local_err = NULL;
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
+    X86MachineState *x86ms = X86_MACHINE(hotplug_dev);
     MachineState *ms = MACHINE(hotplug_dev);
     bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
 
@@ -1319,7 +1321,7 @@ static void pc_memory_plug(HotplugHandler *hotplug_dev,
         nvdimm_plug(ms->nvdimms_state);
     }
 
-    hotplug_handler_plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &error_abort);
+    hotplug_handler_plug(x86ms->acpi_dev, dev, &error_abort);
 out:
     error_propagate(errp, local_err);
 }
@@ -1328,14 +1330,14 @@ static void pc_memory_unplug_request(HotplugHandler *hotplug_dev,
                                      DeviceState *dev, Error **errp)
 {
     Error *local_err = NULL;
-    PCMachineState *pcms = PC_MACHINE(hotplug_dev);
+    X86MachineState *x86ms = X86_MACHINE(hotplug_dev);
 
     /*
      * When -no-acpi is used with Q35 machine type, no ACPI is built,
      * but pcms->acpi_dev is still created. Check !acpi_enabled in
      * addition to cover this case.
      */
-    if (!pcms->acpi_dev || !x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
+    if (!x86ms->acpi_dev || !x86_machine_is_acpi_enabled(x86ms)) {
         error_setg(&local_err,
                    "memory hotplug is not enabled: missing acpi device or acpi disabled");
         goto out;
@@ -1347,7 +1349,7 @@ static void pc_memory_unplug_request(HotplugHandler *hotplug_dev,
         goto out;
     }
 
-    hotplug_handler_unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev,
+    hotplug_handler_unplug_request(x86ms->acpi_dev, dev,
                                    &local_err);
 out:
     error_propagate(errp, local_err);
@@ -1357,9 +1359,10 @@ static void pc_memory_unplug(HotplugHandler *hotplug_dev,
                              DeviceState *dev, Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
+    X86MachineState *x86ms = X86_MACHINE(hotplug_dev);
     Error *local_err = NULL;
 
-    hotplug_handler_unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
+    hotplug_handler_unplug(x86ms->acpi_dev, dev, &local_err);
     if (local_err) {
         goto out;
     }
@@ -1403,10 +1406,10 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev,
     Error *local_err = NULL;
     X86CPU *cpu = X86_CPU(dev);
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
-    X86MachineState *x86ms = X86_MACHINE(pcms);
+    X86MachineState *x86ms = X86_MACHINE(hotplug_dev);
 
-    if (pcms->acpi_dev) {
-        hotplug_handler_plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
+    if (x86ms->acpi_dev) {
+        hotplug_handler_plug(x86ms->acpi_dev, dev, &local_err);
         if (local_err) {
             goto out;
         }
@@ -1433,8 +1436,9 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
     Error *local_err = NULL;
     X86CPU *cpu = X86_CPU(dev);
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
+    X86MachineState *x86ms = X86_MACHINE(hotplug_dev);
 
-    if (!pcms->acpi_dev) {
+    if (!x86ms->acpi_dev) {
         error_setg(&local_err, "CPU hot unplug not supported without ACPI");
         goto out;
     }
@@ -1446,7 +1450,7 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
         goto out;
     }
 
-    hotplug_handler_unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev,
+    hotplug_handler_unplug_request(x86ms->acpi_dev, dev,
                                    &local_err);
     if (local_err) {
         goto out;
@@ -1464,9 +1468,9 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_dev,
     Error *local_err = NULL;
     X86CPU *cpu = X86_CPU(dev);
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
-    X86MachineState *x86ms = X86_MACHINE(pcms);
+    X86MachineState *x86ms = X86_MACHINE(hotplug_dev);
 
-    hotplug_handler_unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
+    hotplug_handler_unplug(x86ms->acpi_dev, dev, &local_err);
     if (local_err) {
         goto out;
     }
@@ -1495,7 +1499,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
     CPUX86State *env = &cpu->env;
     MachineState *ms = MACHINE(hotplug_dev);
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
-    X86MachineState *x86ms = X86_MACHINE(pcms);
+    X86MachineState *x86ms = X86_MACHINE(hotplug_dev);
     unsigned int smp_cores = ms->smp.cores;
     unsigned int smp_threads = ms->smp.threads;
     X86CPUTopoInfo topo_info;
hw/i386/pc_piix.c +1 -1
index 1d832b2878b1..34944bd383e3 100644
@@ -291,7 +291,7 @@ static void pc_init1(MachineState *machine,
 
         object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
                                  TYPE_HOTPLUG_HANDLER,
-                                 (Object **)&pcms->acpi_dev,
+                                 (Object **)&x86ms->acpi_dev,
                                  object_property_allow_set_link,
                                  OBJ_PROP_LINK_STRONG);
         object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
hw/i386/pc_q35.c +1 -1
index 047ea8db28ea..92a104059076 100644
@@ -240,7 +240,7 @@ static void pc_q35_init(MachineState *machine)
 
     object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
                              TYPE_HOTPLUG_HANDLER,
-                             (Object **)&pcms->acpi_dev,
+                             (Object **)&x86ms->acpi_dev,
                              object_property_allow_set_link,
                              OBJ_PROP_LINK_STRONG);
     object_property_set_link(OBJECT(machine), OBJECT(lpc),
Signature · 1 line
2.18.4
#19 lore raw

PATCH v4 15/21 x86: move cpu plug from pc to x86

In reply to Gerd Hoffmann

The cpu hotplug code handles the initialization of coldplugged cpus too, so it is needed even in case cpu hotplug is not supported.

Move the code from pc to x86, so microvm can use it.

---
 include/hw/i386/x86.h |   6 ++
 hw/i386/pc.c          | 234 ++----------------------------------------
 hw/i386/x86.c         | 222 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 234 insertions(+), 228 deletions(-)
include/hw/i386/x86.h +6 -0
index de74c831c3ab..23c964471802 100644
@@ -102,6 +102,12 @@ CpuInstanceProperties x86_cpu_index_to_props(MachineState *ms,
                                              unsigned cpu_index);
 int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx);
 const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms);
+CPUArchId *x86_find_cpu_slot(MachineState *ms, uint32_t id, int *idx);
+void x86_rtc_set_cpus_count(ISADevice *rtc, uint16_t cpus_count);
+void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
+                      DeviceState *dev, Error **errp);
+void x86_cpu_plug(HotplugHandler *hotplug_dev,
+                  DeviceState *dev, Error **errp);
 
 void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw);
 
hw/i386/pc.c +6 -228

287 lines not on this page · raw message

hw/i386/x86.c +222 -0

234 lines not on this page · raw message

Signature · 1 line
2.18.4
#20 lore raw

PATCH v4 16/21 microvm: wire up hotplug

In reply to Gerd Hoffmann

The cpu hotplug code handles the initialization of coldplugged cpus too, so it is needed even in case cpu hotplug is not supported.

Wire cpu hotplug up for microvm.
Without this we get a broken MADT table.

---
 hw/i386/microvm.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
hw/i386/microvm.c +42 -0
index 3d8a66cfc3ac..a5b16b728f9f 100644
@@ -320,6 +320,39 @@ static void microvm_fix_kernel_cmdline(MachineState *machine)
     g_free(cmdline);
 }
 
+static void microvm_device_pre_plug_cb(HotplugHandler *hotplug_dev,
+                                       DeviceState *dev, Error **errp)
+{
+    x86_cpu_pre_plug(hotplug_dev, dev, errp);
+}
+
+static void microvm_device_plug_cb(HotplugHandler *hotplug_dev,
+                                   DeviceState *dev, Error **errp)
+{
+    x86_cpu_plug(hotplug_dev, dev, errp);
+}
+
+static void microvm_device_unplug_request_cb(HotplugHandler *hotplug_dev,
+                                             DeviceState *dev, Error **errp)
+{
+    error_setg(errp, "unplug not supported by microvm");
+}
+
+static void microvm_device_unplug_cb(HotplugHandler *hotplug_dev,
+                                     DeviceState *dev, Error **errp)
+{
+    error_setg(errp, "unplug not supported by microvm");
+}
+
+static HotplugHandler *microvm_get_hotplug_handler(MachineState *machine,
+                                                   DeviceState *dev)
+{
+    if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+        return HOTPLUG_HANDLER(machine);
+    }
+    return NULL;
+}
+
 static void microvm_machine_state_init(MachineState *machine)
 {
     MicrovmMachineState *mms = MICROVM_MACHINE(machine);
@@ -503,6 +536,7 @@ static void microvm_machine_initfn(Object *obj)
 static void microvm_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
+    HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
 
     mc->init = microvm_machine_state_init;
 
@@ -523,6 +557,13 @@ static void microvm_class_init(ObjectClass *oc, void *data)
     /* Machine class handlers */
     mc->reset = microvm_machine_reset;
 
+    /* hotplug (for cpu coldplug) */
+    mc->get_hotplug_handler = microvm_get_hotplug_handler;
+    hc->pre_plug = microvm_device_pre_plug_cb;
+    hc->plug = microvm_device_plug_cb;
+    hc->unplug_request = microvm_device_unplug_request_cb;
+    hc->unplug = microvm_device_unplug_cb;
+
     object_class_property_add(oc, MICROVM_MACHINE_PIC, "OnOffAuto",
                               microvm_machine_get_pic,
                               microvm_machine_set_pic,
@@ -572,6 +613,7 @@ static const TypeInfo microvm_machine_info = {
     .class_size    = sizeof(MicrovmMachineClass),
     .class_init    = microvm_class_init,
     .interfaces = (InterfaceInfo[]) {
+         { TYPE_HOTPLUG_HANDLER },
          { }
     },
 };
Signature · 1 line
2.18.4
#21 lore raw

PATCH v4 17/21 tests/acpi: clear bios-tables-test-allowed-diff.h

In reply to Gerd Hoffmann

Leftover from acpi cleanup series.

---
 tests/qtest/bios-tables-test-allowed-diff.h | 18 ------------------
 1 file changed, 18 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -18
index 8992f1f12b77..dfb8523c8bf4 100644
@@ -1,19 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/pc/DSDT",
-"tests/data/acpi/pc/DSDT.acpihmat",
-"tests/data/acpi/pc/DSDT.bridge",
-"tests/data/acpi/pc/DSDT.cphp",
-"tests/data/acpi/pc/DSDT.dimmpxm",
-"tests/data/acpi/pc/DSDT.ipmikcs",
-"tests/data/acpi/pc/DSDT.memhp",
-"tests/data/acpi/pc/DSDT.numamem",
-"tests/data/acpi/q35/DSDT",
-"tests/data/acpi/q35/DSDT.acpihmat",
-"tests/data/acpi/q35/DSDT.bridge",
-"tests/data/acpi/q35/DSDT.cphp",
-"tests/data/acpi/q35/DSDT.dimmpxm",
-"tests/data/acpi/q35/DSDT.ipmibt",
-"tests/data/acpi/q35/DSDT.memhp",
-"tests/data/acpi/q35/DSDT.mmio64",
-"tests/data/acpi/q35/DSDT.numamem",
-"tests/data/acpi/q35/DSDT.tis",
Signature · 1 line
2.18.4
#22 lore raw

PATCH v4 18/21 tests/acpi: allow microvm test data updates.

In reply to Gerd Hoffmann

Also add empty test data files.

---
 tests/qtest/bios-tables-test-allowed-diff.h | 3 +++
 tests/data/acpi/microvm/APIC                | 0
 tests/data/acpi/microvm/DSDT                | 0
 tests/data/acpi/microvm/FACP                | 0
 4 files changed, 3 insertions(+)
 create mode 100644 tests/data/acpi/microvm/APIC
 create mode 100644 tests/data/acpi/microvm/DSDT
 create mode 100644 tests/data/acpi/microvm/FACP
tests/qtest/bios-tables-test-allowed-diff.h +3 -0
index dfb8523c8bf4..97c3fa621b7f 100644
@@ -1 +1,4 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/microvm/APIC",
+"tests/data/acpi/microvm/DSDT",
+"tests/data/acpi/microvm/FACP",
tests/data/acpi/microvm/APIC new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
tests/data/acpi/microvm/DSDT new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
tests/data/acpi/microvm/FACP new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
Signature · 1 line
2.18.4
#23 lore raw

PATCH v4 19/21 tests/acpi: allow override blkdev

In reply to Gerd Hoffmann

microvm needs virtio-blk instead of ide.

---
 tests/qtest/bios-tables-test.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/qtest/bios-tables-test.c +4 -2
index c315156858f4..24b715dce780 100644
@@ -72,6 +72,7 @@ typedef struct {
     const char *variant;
     const char *uefi_fl1;
     const char *uefi_fl2;
+    const char *blkdev;
     const char *cd;
     const uint64_t ram_start;
     const uint64_t scan_len;
@@ -635,9 +636,10 @@ static void test_acpi_one(const char *params, test_data *data)
         args = g_strdup_printf("-machine %s,kernel-irqchip=off %s -accel tcg "
             "-net none -display none %s "
             "-drive id=hd0,if=none,file=%s,format=raw "
-            "-device ide-hd,drive=hd0 ",
+            "-device %s,drive=hd0 ",
              data->machine, data->tcg_only ? "" : "-accel kvm",
-             params ? params : "", disk);
+             params ? params : "", disk,
+             data->blkdev ?: "ide-hd");
     }
 
     data->qts = qtest_init(args);
Signature · 1 line
2.18.4
#24 lore raw

PATCH v4 20/21 tests/acpi: add microvm test

In reply to Gerd Hoffmann
---
 tests/qtest/bios-tables-test.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tests/qtest/bios-tables-test.c +15 -0
index 24b715dce780..b5b98d5c0742 100644
@@ -1007,6 +1007,20 @@ static void test_acpi_virt_tcg_memhp(void)
 
 }
 
+static void test_acpi_microvm_tcg(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = "microvm";
+    data.required_struct_types = base_required_struct_types;
+    data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
+    data.blkdev = "virtio-blk-device";
+    test_acpi_one(" -machine microvm,acpi=on,rtc=off",
+                  &data);
+    free_test_data(&data);
+}
+
 static void test_acpi_virt_tcg_numamem(void)
 {
     test_data data = {
@@ -1118,6 +1132,7 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
         qtest_add_func("acpi/piix4/acpihmat", test_acpi_piix4_tcg_acpi_hmat);
         qtest_add_func("acpi/q35/acpihmat", test_acpi_q35_tcg_acpi_hmat);
+        qtest_add_func("acpi/microvm", test_acpi_microvm_tcg);
     } else if (strcmp(arch, "aarch64") == 0) {
         qtest_add_func("acpi/virt", test_acpi_virt_tcg);
         qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem);
Signature · 1 line
2.18.4
#25 lore raw

PATCH v4 21/21 tests/acpi: update expected data files for microvm

In reply to Gerd Hoffmann

Also clear tests/qtest/bios-tables-test-allowed-diff.h

---
 tests/qtest/bios-tables-test-allowed-diff.h |   3 ---
 tests/data/acpi/microvm/APIC                | Bin 0 -> 70 bytes
 tests/data/acpi/microvm/DSDT                | Bin 0 -> 365 bytes
 tests/data/acpi/microvm/FACP                | Bin 0 -> 268 bytes
 4 files changed, 3 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -3
index 97c3fa621b7f..dfb8523c8bf4 100644
@@ -1,4 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/microvm/APIC",
-"tests/data/acpi/microvm/DSDT",
-"tests/data/acpi/microvm/FACP",
tests/data/acpi/microvm/APIC binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7472c7e830b6c7139720e93dd544d4441556661d 100644
GIT binary patch
tests/data/acpi/microvm/DSDT binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..b7297dfe9a34bede2ad0d65281f0bc7497bbd358 100644
GIT binary patch
tests/data/acpi/microvm/FACP binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e52b16d24ac4f7b95a7d11a5f2ad801c0cb87147 100644
GIT binary patch
Signature · 1 line
2.18.4
#26 lore raw
In reply to Gerd Hoffmann
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Subject: [PATCH v4 00/21] microvm: add acpi support
Type: series
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
6d5eb94 tests/acpi: update expected data files for microvm bc45791 tests/acpi: add microvm test
c4b1e12 tests/acpi: allow override blkdev
afb44f2 tests/acpi: allow microvm test data updates. ef356bd tests/acpi: clear bios-tables-test-allowed-diff.h b80aa70 microvm: wire up hotplug
8f80d76 x86: move cpu plug from pc to x86
e3d689d x86: move acpi_dev from pc/microvm 2ca513e x86: constify x86_machine_is_*_enabled dff3286 microvm/acpi: disable virtio-mmio cmdline hack ee2b30f microvm/acpi: use seabios with acpi=on ec0fefa microvm/acpi: use GSI 16-23 for virtio 35a5595 microvm/acpi: add acpi_dsdt_add_virtio() for x86 ef52f38 microvm/acpi: add minimal acpi support 9c5c1a3 microvm: make virtio irq base runtime configurable dfbba95 acpi: move acpi_dsdt_add_power_button() to ged 9350314 acpi: ged: add x86 device variant. 7e7cbaa acpi: ged: add control regs
0d6d2dd seabios: add bios-microvm.bin binary f847401 seabios: add microvm config, update build rules 1aa4e76 microvm: name qboot binary qboot.rom

=== OUTPUT BEGIN ===
1/21 Checking commit 1aa4e767856e (microvm: name qboot binary qboot.rom)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #36:
rename from pc-bios/bios-microvm.bin

total: 0 errors, 1 warnings, 35 lines checked

Patch 1/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/21 Checking commit f84740183b7c (seabios: add microvm config, update build rules)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #29:
new file mode 100644

total: 0 errors, 1 warnings, 39 lines checked

Patch 2/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
3/21 Checking commit 0d6d2ddc3815 (seabios: add bios-microvm.bin binary) 4/21 Checking commit 7e7cbaa1cf2a (acpi: ged: add control regs) 5/21 Checking commit 9350314a8c62 (acpi: ged: add x86 device variant.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #25:
new file mode 100644

total: 0 errors, 1 warnings, 51 lines checked

Patch 5/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
6/21 Checking commit dfbba956d1bc (acpi: move acpi_dsdt_add_power_button() to ged) 7/21 Checking commit 9c5c1a34efc7 (microvm: make virtio irq base runtime configurable) 8/21 Checking commit ef52f38efb11 (microvm/acpi: add minimal acpi support)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #34:
new file mode 100644

WARNING: Block comments use a leading /* on a separate line #39: FILE: hw/i386/acpi-microvm.c:1:
+/* Support for generating ACPI tables and passing them to Guests

WARNING: Block comments use a leading /* on a separate line #150: FILE: hw/i386/acpi-microvm.c:112:
+ table_offsets = g_array_new(false, true /* clear */,

WARNING: Block comments use a leading /* on a separate line #154: FILE: hw/i386/acpi-microvm.c:116:
+ 64 /* Ensure FACS is aligned */,

WARNING: Block comments use a leading /* on a separate line #155: FILE: hw/i386/acpi-microvm.c:117:
+ false /* high memory */);

total: 0 errors, 5 warnings, 297 lines checked

Patch 8/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
9/21 Checking commit 35a55956c365 (microvm/acpi: add acpi_dsdt_add_virtio() for x86) 10/21 Checking commit ec0fefa9351d (microvm/acpi: use GSI 16-23 for virtio) 11/21 Checking commit ee2b30f1d829 (microvm/acpi: use seabios with acpi=on) 12/21 Checking commit dff3286bf4a4 (microvm/acpi: disable virtio-mmio cmdline hack) 13/21 Checking commit 2ca513ea5407 (x86: constify x86_machine_is_*_enabled) 14/21 Checking commit e3d689d93ee0 (x86: move acpi_dev from pc/microvm) 15/21 Checking commit 8f80d768dea4 (x86: move cpu plug from pc to x86)
ERROR: space required before the open parenthesis '('
#344: FILE: hw/i386/x86.c:187:
+ if(!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) {

WARNING: Block comments use a leading /* on a separate line #431: FILE: hw/i386/x86.c:274:
+ /* if 'address' properties socket-id/core-id/thread-id are not set, set them

WARNING: Block comments use a leading /* on a separate line #434: FILE: hw/i386/x86.c:277:
+ /* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizefn()

WARNING: Block comments use a trailing */ on a separate line #436: FILE: hw/i386/x86.c:279:
+ * CPUState::nr_cores and CPUState::nr_threads fields instead of globals */

WARNING: Block comments use a leading /* on a separate line #484: FILE: hw/i386/x86.c:327:
+ /* If the number of CPUs can't be represented in 8 bits, the

WARNING: Block comments use a leading /* on a separate line #502: FILE: hw/i386/x86.c:345:
+/* returns pointer to CPUArchId descriptor that matches CPU's apic_id

total: 1 errors, 5 warnings, 533 lines checked

Patch 15/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

16/21 Checking commit b80aa70e374f (microvm: wire up hotplug)
17/21 Checking commit ef356bd1fb47 (tests/acpi: clear bios-tables-test-allowed-diff.h) 18/21 Checking commit afb44f2d850b (tests/acpi: allow microvm test data updates.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #13:
new file mode 100644

total: 0 errors, 1 warnings, 4 lines checked

Patch 18/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
19/21 Checking commit c4b1e125fc0e (tests/acpi: allow override blkdev) 20/21 Checking commit bc457914cb9c (tests/acpi: add microvm test)
21/21 Checking commit 6d5eb9469a97 (tests/acpi: update expected data files for microvm) === OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#27 lore raw
In reply to Gerd Hoffmann
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Subject: [PATCH v4 00/21] microvm: add acpi support
Type: series
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu
- [tag update] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
1e173ac tests/acpi: update expected data files for microvm 7f4d75c tests/acpi: add microvm test
7933c7d tests/acpi: allow override blkdev
8246d8e tests/acpi: allow microvm test data updates. 09ff54c tests/acpi: clear bios-tables-test-allowed-diff.h a6ac3a9 microvm: wire up hotplug
37fe132 x86: move cpu plug from pc to x86
18502ab x86: move acpi_dev from pc/microvm e25eb4c x86: constify x86_machine_is_*_enabled 3144c4e microvm/acpi: disable virtio-mmio cmdline hack 488512b microvm/acpi: use seabios with acpi=on 4dce0b0 microvm/acpi: use GSI 16-23 for virtio 6c1e43a microvm/acpi: add acpi_dsdt_add_virtio() for x86 7e90f10 microvm/acpi: add minimal acpi support 91fb357 microvm: make virtio irq base runtime configurable 75d0e28 acpi: move acpi_dsdt_add_power_button() to ged b1b3872 acpi: ged: add x86 device variant. 2f82b96 acpi: ged: add control regs
7b24784 seabios: add bios-microvm.bin binary be06767 seabios: add microvm config, update build rules 30aa71d microvm: name qboot binary qboot.rom

=== OUTPUT BEGIN ===
1/21 Checking commit 30aa71d445e7 (microvm: name qboot binary qboot.rom)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #36:
rename from pc-bios/bios-microvm.bin

total: 0 errors, 1 warnings, 35 lines checked

Patch 1/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/21 Checking commit be0676767e5e (seabios: add microvm config, update build rules)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #29:
new file mode 100644

total: 0 errors, 1 warnings, 39 lines checked

Patch 2/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
3/21 Checking commit 7b247849b125 (seabios: add bios-microvm.bin binary) 4/21 Checking commit 2f82b96fc4fb (acpi: ged: add control regs) 5/21 Checking commit b1b387286c9d (acpi: ged: add x86 device variant.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #25:
new file mode 100644

total: 0 errors, 1 warnings, 51 lines checked

Patch 5/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
6/21 Checking commit 75d0e28f4afe (acpi: move acpi_dsdt_add_power_button() to ged) 7/21 Checking commit 91fb3578211e (microvm: make virtio irq base runtime configurable) 8/21 Checking commit 7e90f10773b4 (microvm/acpi: add minimal acpi support)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #34:
new file mode 100644

WARNING: Block comments use a leading /* on a separate line #39: FILE: hw/i386/acpi-microvm.c:1:
+/* Support for generating ACPI tables and passing them to Guests

WARNING: Block comments use a leading /* on a separate line #150: FILE: hw/i386/acpi-microvm.c:112:
+ table_offsets = g_array_new(false, true /* clear */,

WARNING: Block comments use a leading /* on a separate line #154: FILE: hw/i386/acpi-microvm.c:116:
+ 64 /* Ensure FACS is aligned */,

WARNING: Block comments use a leading /* on a separate line #155: FILE: hw/i386/acpi-microvm.c:117:
+ false /* high memory */);

total: 0 errors, 5 warnings, 297 lines checked

Patch 8/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
9/21 Checking commit 6c1e43a0b904 (microvm/acpi: add acpi_dsdt_add_virtio() for x86) 10/21 Checking commit 4dce0b04d88f (microvm/acpi: use GSI 16-23 for virtio) 11/21 Checking commit 488512b60cfb (microvm/acpi: use seabios with acpi=on) 12/21 Checking commit 3144c4ef8a34 (microvm/acpi: disable virtio-mmio cmdline hack) 13/21 Checking commit e25eb4c6c1ca (x86: constify x86_machine_is_*_enabled) 14/21 Checking commit 18502ab064f4 (x86: move acpi_dev from pc/microvm) 15/21 Checking commit 37fe132c446b (x86: move cpu plug from pc to x86)
ERROR: space required before the open parenthesis '('
#344: FILE: hw/i386/x86.c:187:
+ if(!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) {

WARNING: Block comments use a leading /* on a separate line #431: FILE: hw/i386/x86.c:274:
+ /* if 'address' properties socket-id/core-id/thread-id are not set, set them

WARNING: Block comments use a leading /* on a separate line #434: FILE: hw/i386/x86.c:277:
+ /* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizefn()

WARNING: Block comments use a trailing */ on a separate line #436: FILE: hw/i386/x86.c:279:
+ * CPUState::nr_cores and CPUState::nr_threads fields instead of globals */

WARNING: Block comments use a leading /* on a separate line #484: FILE: hw/i386/x86.c:327:
+ /* If the number of CPUs can't be represented in 8 bits, the

WARNING: Block comments use a leading /* on a separate line #502: FILE: hw/i386/x86.c:345:
+/* returns pointer to CPUArchId descriptor that matches CPU's apic_id

total: 1 errors, 5 warnings, 533 lines checked

Patch 15/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

16/21 Checking commit a6ac3a966c0d (microvm: wire up hotplug)
17/21 Checking commit 09ff54c06666 (tests/acpi: clear bios-tables-test-allowed-diff.h) 18/21 Checking commit 8246d8e472f7 (tests/acpi: allow microvm test data updates.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #13:
new file mode 100644

total: 0 errors, 1 warnings, 4 lines checked

Patch 18/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
19/21 Checking commit 7933c7d34c9f (tests/acpi: allow override blkdev) 20/21 Checking commit 7f4d75c92df2 (tests/acpi: add microvm test)
21/21 Checking commit 1e173acb1faa (tests/acpi: update expected data files for microvm) === OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]