microvm: add acpi support
v7 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.
changes in v5:
* rebase to latest master (seabios dependency is merged meanwhile)
* fix DSDT version (mst).
* add comments referencing the ACPI spec for easier review (mst).
changes in v6:
* rebase to latest master, adapt to meson build system.
* pick up some review tags.
* misc fixes here and there.
changes in v7:
* rebase to latest master, adapt to x86 cpu hotplug changes.
* meson tweaks for firmware binaries.
* pick up some review tags.
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 hotplug from pc to x86
microvm: wire up hotplug
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
microvm: enable ramfb
hw/i386/acpi-microvm.h | 8 + include/hw/acpi/generic_event_device.h | 17 ++ include/hw/i386/microvm.h | 10 +- include/hw/i386/pc.h | 1 - include/hw/i386/x86.h | 15 +- 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 | 240 ++++++++++++++++++++ hw/i386/generic_event_device_x86.c | 36 +++ hw/i386/microvm.c | 108 ++++++++- hw/i386/pc.c | 297 ++----------------------- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/i386/x86.c | 275 ++++++++++++++++++++++- tests/qtest/bios-tables-test.c | 21 +- hw/i386/Kconfig | 1 + hw/i386/meson.build | 3 +- pc-bios/bios-microvm.bin | Bin 65536 -> 131072 bytes pc-bios/meson.build | 1 + 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, 823 insertions(+), 313 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.27.0
PATCH v7 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/meson.build | 2 +-
pc-bios/{bios-microvm.bin => qboot.rom} | Bin
roms/Makefile | 6 +++---
4 files changed, 6 insertions(+), 6 deletions(-)
rename pc-bios/{bios-microvm.bin => qboot.rom} (100%)hw/i386/microvm.c +2 -2
@@ -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/meson.build +1 -1
@@ -27,7 +27,7 @@ endif blobs = files( 'bios.bin', 'bios-256k.bin', - 'bios-microvm.bin', + 'qboot.rom', 'sgabios.bin', 'vgabios.bin', 'vgabios-cirrus.bin',
pc-bios/qboot.rom renamed from pc-bios/bios-microvm.bin +0 -0
roms/Makefile +3 -3
@@ -66,7 +66,7 @@ default help: @echo " efi -- update UEFI (edk2) platform firmware" @echo " opensbi32-generic -- update OpenSBI for 32-bit generic machine" @echo " opensbi64-generic -- update OpenSBI for 64-bit generic machine" - @echo " bios-microvm -- update bios-microvm.bin (qboot)" + @echo " qboot -- update qboot" @echo " clean -- delete the files generated by the previous" \ "build targets"
@@ -182,9 +182,9 @@ opensbi64-generic: cp opensbi/build/platform/generic/firmware/fw_dynamic.bin ../pc-bios/opensbi-riscv64-generic-fw_dynamic.bin cp opensbi/build/platform/generic/firmware/fw_dynamic.elf ../pc-bios/opensbi-riscv64-generic-fw_dynamic.elf -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.27.0
Re: [PATCH v7 01/21] microvm: name qboot binary qboot.rom
Quoted 11 lines · Gerd Hoffmann
qboot isn't a bios and shouldnt be named that way.
Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Sergio Lopez <[email protected]>--- hw/i386/microvm.c | 4 ++-- pc-bios/meson.build | 2 +- pc-bios/{bios-microvm.bin => qboot.rom} | Bin roms/Makefile | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) rename pc-bios/{bios-microvm.bin => qboot.rom} (100%)
PATCH v7 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
@@ -70,9 +70,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
@@ -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.27.0
PATCH v7 3/21 seabios: add bios-microvm.bin binary
In reply to Gerd Hoffmann--- pc-bios/bios-microvm.bin | Bin 0 -> 131072 bytes pc-bios/meson.build | 1 + 2 files changed, 1 insertion(+) create mode 100644 pc-bios/bios-microvm.bin
pc-bios/bios-microvm.bin new file binary +0 -0
pc-bios/meson.build +1 -0
@@ -27,6 +27,7 @@ endif blobs = files( 'bios.bin', 'bios-256k.bin', + 'bios-microvm.bin', 'qboot.rom', 'sgabios.bin', 'vgabios.bin',
Signature · 1 line
2.27.0
PATCH v7 4/21 acpi: ged: add control regs
In reply to Gerd HoffmannAdd control regs (sleep, reset) for hw-reduced acpi.
--- include/hw/acpi/generic_event_device.h | 12 +++++++ hw/acpi/generic_event_device.c | 44 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+)
include/hw/acpi/generic_event_device.h +12 -0
@@ -72,6 +72,17 @@#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_REG_COUNT 0x03 + +/* ACPI_GED_REG_RESET value for reset*/ +#define ACPI_GED_RESET_VALUE 0x42 + +/* ACPI_GED_REG_SLEEP_CTL.SLP_TYP value for S5 (aka poweroff) */ +#define ACPI_GED_SLP_TYP_S5 0x05 +#define GED_DEVICE "GED"#define AML_GED_EVT_REG "EREG"#define AML_GED_EVT_SEL "ESEL"
@@ -87,6 +98,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.27.0
PATCH v7 5/21 acpi: ged: add x86 device variant.
In reply to Gerd HoffmannSet 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/meson.build | 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
@@ -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
@@ -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/meson.build +1 -0
@@ -18,6 +18,7 @@ i386_ss.add(when: 'CONFIG_VMPORT', if_true: files('vmport.c')) i386_ss.add(when: 'CONFIG_VTD', if_true: files('intel_iommu.c')) i386_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-common.c')) +i386_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('generic_event_device_x86.c')) i386_ss.add(when: 'CONFIG_PC', if_true: files( 'pc.c', 'pc_sysfw.c',
Signature · 1 line
2.27.0
PATCH v7 6/21 acpi: move acpi_dsdt_add_power_button() to ged
In reply to Gerd HoffmannAllow 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
@@ -118,5 +118,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
@@ -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
@@ -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.27.0
PATCH v7 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
@@ -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
@@ -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.27.0
PATCH v7 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 | 187 ++++++++++++++++++++++++++++++++++++++ hw/i386/microvm.c | 40 ++++++++ hw/i386/Kconfig | 1 + hw/i386/meson.build | 2 +- 6 files changed, 246 insertions(+), 1 deletion(-) 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
@@ -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
@@ -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 +187 -0
187 lines not on this page · raw message
hw/i386/microvm.c +40 -0
@@ -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
@@ -103,6 +103,7 @@ config MICROVM select I8259 select MC146818RTC select VIRTIO_MMIO + select ACPI_HW_REDUCED config X86_IOMMU bool
hw/i386/meson.build +1 -1
@@ -11,7 +11,7 @@ i386_ss.add(when: 'CONFIG_X86_IOMMU', if_true: files('x86-iommu.c'), if_false: files('x86-iommu-stub.c')) i386_ss.add(when: 'CONFIG_AMD_IOMMU', if_true: files('amd_iommu.c')) i386_ss.add(when: 'CONFIG_I440FX', if_true: files('pc_piix.c')) -i386_ss.add(when: 'CONFIG_MICROVM', if_true: files('microvm.c')) +i386_ss.add(when: 'CONFIG_MICROVM', if_true: files('microvm.c', 'acpi-microvm.c')) i386_ss.add(when: 'CONFIG_Q35', if_true: files('pc_q35.c')) i386_ss.add(when: 'CONFIG_VMMOUSE', if_true: files('vmmouse.c')) i386_ss.add(when: 'CONFIG_VMPORT', if_true: files('vmport.c'))
Signature · 1 line
2.27.0
PATCH v7 9/21 microvm/acpi: add acpi_dsdt_add_virtio() for x86
In reply to Gerd HoffmannMakes 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
@@ -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);/* ACPI 5.0: Table 7-209 System State Package */
Signature · 1 line
2.27.0
PATCH v7 10/21 microvm/acpi: use GSI 16-23 for virtio
In reply to Gerd HoffmannWith 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
@@ -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.27.0
PATCH v7 11/21 microvm/acpi: use seabios with acpi=on
In reply to Gerd HoffmannWith acpi=off continue to use qboot.
--- hw/i386/microvm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/i386/microvm.c +4 -1
@@ -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.27.0
PATCH v7 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
@@ -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.27.0
PATCH v7 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
@@ -101,8 +101,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
@@ -821,7 +821,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;
@@ -863,7 +863,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.27.0
Re: [PATCH v7 13/21] x86: constify x86_machine_is_*_enabled
Quoted 7 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Sergio Lopez <[email protected]>Reviewed-by Igor Mammedov <[email protected]>--- include/hw/i386/x86.h | 4 ++-- hw/i386/x86.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
PATCH v7 14/21 x86: move acpi_dev from pc/microvm
In reply to Gerd HoffmannBoth 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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);
@@ -136,6 +136,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;
@@ -183,7 +184,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
@@ -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
@@ -1274,6 +1274,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 );
@@ -1285,7 +1286,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 ;
@@ -1296,7 +1297,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 ;
@@ -1311,6 +1312,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 );
@@ -1323,7 +1325,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); }
@@ -1331,14 +1333,14 @@ out:static void pc_memory_unplug_request (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) { -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 (errp,"memory hotplug is not enabled: missing acpi device or acpi disabled" );return ;
@@ -1349,7 +1351,7 @@ static void pc_memory_unplug_request(HotplugHandler *hotplug_dev,return ; } -hotplug_handler_unplug_request (HOTPLUG_HANDLER (pcms->acpi_dev), dev, +hotplug_handler_unplug_request (x86ms->acpi_dev, dev, errp); }
@@ -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; }
@@ -1432,8 +1435,9 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,int idx =-1 ;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 (errp,"CPU hot unplug not supported without ACPI" );return ; }
@@ -1445,7 +1449,7 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,return ; } -hotplug_handler_unplug_request (HOTPLUG_HANDLER (pcms->acpi_dev), dev, +hotplug_handler_unplug_request (x86ms->acpi_dev, dev, errp); }
@@ -1456,9 +1460,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; }
@@ -1487,7 +1491,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
@@ -293,7 +293,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), PC_MACHINE_ACPI_DEVICE_PROP,
hw/i386/pc_q35.c +1 -1
@@ -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), PC_MACHINE_ACPI_DEVICE_PROP,
Signature · 1 line
2.27.0
PATCH v7 15/21 x86: move cpu hotplug from pc to x86
In reply to Gerd HoffmannThe 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.
Move both plug and unplug to keep everything in one place, even though microvm needs plug only.
--- include/hw/i386/x86.h | 10 ++ hw/i386/pc.c | 281 +----------------------------------------- hw/i386/x86.c | 271 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 286 insertions(+), 276 deletions(-)
include/hw/i386/x86.h +10 -0
@@ -93,6 +93,16 @@ 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_cpu_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp); +void x86_cpu_unplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp);void x86_bios_rom_init (MemoryRegion *rom_memory,bool isapc_ram_fw);
hw/i386/pc.c +5 -276
323 lines not on this page · raw message
hw/i386/x86.c +271 -0
283 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v7 16/21 microvm: wire up hotplug
In reply to Gerd HoffmannThe 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
@@ -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;
@@ -524,6 +558,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,
@@ -573,6 +614,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.27.0
PATCH v7 17/21 tests/acpi: allow microvm test data updates.
In reply to Gerd HoffmannAlso 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
@@ -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
tests/data/acpi/microvm/DSDT new file +0 -0
tests/data/acpi/microvm/FACP new file +0 -0
Signature · 1 line
2.27.0
PATCH v7 18/21 tests/acpi: allow override blkdev
In reply to Gerd Hoffmannmicrovm 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
@@ -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;
@@ -666,9 +667,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.27.0
PATCH v7 19/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
@@ -1044,6 +1044,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 =NULL ;/* no smbios */ + data.required_struct_types_len =0 ; + 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 = {
@@ -1161,6 +1175,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.27.0
PATCH v7 20/21 tests/acpi: update expected data files for microvm
In reply to Gerd HoffmannAlso 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
@@ -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
tests/data/acpi/microvm/DSDT binary +0 -0
tests/data/acpi/microvm/FACP binary +0 -0
Signature · 1 line
2.27.0
PATCH v7 21/21 microvm: enable ramfb
In reply to Gerd Hoffmann--- hw/i386/microvm.c | 3 +++ 1 file changed, 3 insertions(+)
hw/i386/microvm.c +3 -0
@@ -39,6 +39,7 @@#include "hw/timer/i8254.h" #include "hw/rtc/mc146818rtc.h" #include "hw/char/serial.h" +#include "hw/display/ramfb.h" #include "hw/i386/topology.h" #include "hw/i386/e820_memory_layout.h" #include "hw/i386/fw_cfg.h"
@@ -604,6 +605,8 @@ static void microvm_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,MICROVM_MACHINE_AUTO_KERNEL_CMDLINE ,"Set off to disable adding virtio-mmio devices to the kernel cmdline" ); + +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_RAMFB_DEVICE ); }static const TypeInfo microvm_machine_info = {
Signature · 1 line
2.27.0