microvm: add acpi support
v5 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).
take care,
Gerd
Gerd Hoffmann (20):
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: 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 +- 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 | 248 +++++++++++++++++++++++ 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 25 files changed, 775 insertions(+), 269 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
PATCH v5 1/20 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
@@ -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
roms/Makefile +3 -3
@@ -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
PATCH v5 2/20 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
@@ -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
@@ -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
PATCH v5 3/20 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
Signature · 1 line
2.18.4
PATCH v5 4/20 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 | 7 ++++ hw/acpi/generic_event_device.c | 44 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+)
include/hw/acpi/generic_event_device.h +7 -0
@@ -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
Re: [PATCH v5 04/20] acpi: ged: add control regs
Quoted 3 lines · On Tue, 7 Jul 2020 14:53:40 +0200 Gerd Hoffmann <[email protected]> wrote:
Add control regs (sleep, reset) for hw-reduced acpi.
Signed-off-by Gerd Hoffmann <[email protected]>
with below comments addressed:
Quoted 10 lines
--- 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 +0
-0
include/hw/acpi/generic_event_device.h line 78
Quoted 7 lines
include/hw/acpi/generic_event_device.h +4
-0@@ -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
^^ too many ' '
also it would be nice to point out where vaule comes from (if it's from spec then ref to spec pls)
Quoted 35 lines
include/hw/acpi/generic_event_device.h +3
-0+#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 +7
-0@@ -20,6 +20,7 @@#include "hw/qdev-properties.h" #include "migration/vmstate.h" #include "qemu/error-report.h" +#include "sysemu/runstate.h" static const uint32_t ged_supported_events[] = {ACPI_GED_MEM_HOTPLUG_EVT ,@@ -176,6 +177,45 @@ static const MemoryRegionOps ged_evt_ops = { }, }; +static uint64_t ged_regs_read (void *opaque,hwaddr addr,unsigned size) +{ +return 0 ; +} + +static void ged_regs_write(void *opaque, hwaddr addr, uint64_t data,
hw/acpi/generic_event_device.c static const MemoryRegionOps ged_evt_ops = { · line 195
Quoted 10 lines
hw/acpi/generic_event_device.c +10
-0+ unsigned int size) +{ +bool slp_en; +int slp_typ; + +switch (addr) { +case ACPI_GED_REG_SLEEP_CTL : + slp_typ = (data >>2 ) &0x07 ; + slp_en = (data >>5 ) &0x01 ; +if (slp_en && slp_typ ==5 ) {
replace magic 5 with something more descriptive and use it also in 8/20 during initializing _S5 package
Quoted 37 lines
hw/acpi/generic_event_device.c +27
-0+qemu_system_shutdown_request (SHUTDOWN_CAUSE_GUEST_SHUTDOWN ); + } +return ; +case ACPI_GED_REG_SLEEP_STS : +return ; +case ACPI_GED_REG_RESET : +if (data ==ACPI_GED_RESET_VALUE ) { +qemu_system_reset_request (SHUTDOWN_CAUSE_GUEST_SHUTDOWN ); + } +return ; + } +} + +static const MemoryRegionOps ged_regs_ops = { + .read = ged_regs_read, + .write = ged_regs_write, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =1 , + .max_access_size =1 , + }, +}; +static void acpi_ged_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {@@ -332,6 +372,10 @@ static void acpi_ged_initfn(Object *obj)sysbus_init_mmio (sbd, &s->container_memhp);acpi_memory_hotplug_init (&s->container_memhp,OBJECT (dev), &s->memhp_state,0 ); + +memory_region_init_io (&ged_st->regs, obj, &ged_regs_ops, ged_st, +TYPE_ACPI_GED "-regs" ,ACPI_GED_REG_COUNT ); +sysbus_init_mmio (sbd, &ged_st->regs); }static void acpi_ged_class_init (ObjectClass *class,void *data)
PATCH v5 5/20 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/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
@@ -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/Makefile.objs +1 -0
@@ -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
PATCH v5 6/20 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
@@ -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
@@ -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.18.4
PATCH v5 7/20 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.18.4
Re: [PATCH v5 07/20] microvm: make virtio irq base runtime configurable
Quoted 2 lines · On Tue, 7 Jul 2020 14:53:43 +0200 Gerd Hoffmann <[email protected]> wrote:
Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Sergio Lopez <[email protected]>
Quoted 78 lines
--- 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);
PATCH v5 8/20 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 | 195 ++++++++++++++++++++++++++++++++++++++ hw/i386/microvm.c | 40 ++++++++ hw/i386/Kconfig | 1 + hw/i386/Makefile.objs | 1 + 6 files changed, 254 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
@@ -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 +195 -0
195 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
@@ -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
@@ -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
Re: [PATCH v5 08/20] microvm/acpi: add minimal acpi support
Quoted 3 lines · Gerd Hoffmann
$subject says all. Can be controlled using -M microvm,acpi=on/off.
Signed-off-by Gerd Hoffmann <[email protected]>
Overall I don't see bugs here. Some comments are bit confusing and I point that out below. With that addressed:
Quoted 121 lines
--- hw/i386/acpi-microvm.h | 8 ++ include/hw/i386/microvm.h | 9 ++ hw/i386/acpi-microvm.c | 195 ++++++++++++++++++++++++++++++++++++++ hw/i386/microvm.c | 40 ++++++++ hw/i386/Kconfig | 1 + hw/i386/Makefile.objs | 1 + 6 files changed, 254 insertions(+) create mode 100644 hw/i386/acpi-microvm.h create mode 100644 hw/i386/acpi-microvm.chw/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 +57
-0@@ -0,0 +1,195 @@ +/* Support for generating ACPI tables and passing them to Guests +* +* Copyright (C) 2008-2010 Kevin O'Connor <[email protected]> +* Copyright (C) 2006 Fabrice Bellard +* Copyright (C) 2013 Red Hat Inc +* +* Author: Michael S. Tsirkin <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" + +#include "exec/memory.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/bios-linker-loader.h" +#include "hw/acpi/generic_event_device.h" +#include "hw/acpi/utils.h" +#include "hw/boards.h" +#include "hw/i386/fw_cfg.h" +#include "hw/i386/microvm.h" + +#include "acpi-common.h" +#include "acpi-microvm.h" + +static void +build_dsdt_microvm (GArray *table_data,BIOSLinker *linker, +MicrovmMachineState *mms) +{ +X86MachineState *x86ms =X86_MACHINE (mms); +Aml *dsdt, *sb_scope, *scope, *pkg; +bool ambiguous; +Object *isabus; + + isabus =object_resolve_path_type ("" ,TYPE_ISA_BUS , &ambiguous); +assert (isabus); +assert (!ambiguous); + + dsdt =init_aml_allocator (); + +/* Reserve space for header */ +acpi_data_push (dsdt->buf,sizeof (AcpiTableHeader)); + + sb_scope =aml_scope ("_SB" );
hw/i386/acpi-microvm.c line 67
Quoted 10 lines
hw/i386/acpi-microvm.c new file +10
-0+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), +GED_MMIO_IRQ ,AML_SYSTEM_MEMORY ,GED_MMIO_BASE ); +acpi_dsdt_add_power_button (sb_scope); +aml_append (dsdt, sb_scope); + + scope =aml_scope ("\\" ); + pkg =aml_package (4 ); +aml_append (pkg,aml_int (5 ));/* SLEEP_CONTROL_REG.SLP_TYP */
I'm not sure what does the comment refer to here.
Does this 5 match
the value IO handler tests against? A macro might make sense then ...
Below is from "7.3.4 System \_Sx states" right?
hw/i386/acpi-microvm.c line 78
Quoted 11 lines
hw/i386/acpi-microvm.c new file +11
-0+aml_append (pkg,aml_int (0 ));/* ignored */ +aml_append (pkg,aml_int (0 ));/* reserved */ +aml_append (pkg,aml_int (0 ));/* reserved */ +aml_append (scope,aml_name_decl ("_S5" , pkg)); +aml_append (dsdt, scope); + +/* 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,2 ,NULL ,NULL );
/* DSDT always uses revision 2 */.
Quoted 4 lines
hw/i386/acpi-microvm.c new file +4
-0+free_aml_allocator (); +} + +static void acpi_build_microvm(AcpiBuildTables *tables,
hw/i386/acpi-microvm.c line 92
Quoted 10 lines
hw/i386/acpi-microvm.c new file +10
-0+ MicrovmMachineState *mms) +{ +MachineState *machine =MACHINE (mms); +GArray *table_offsets; +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"
Spec version - I'm guessing ACPI spec 5.0.
And I think here is where you refer to
Table 5-34 Fixed ACPI Description Table (FADT) Format
hw/i386/acpi-microvm.c line 95
Quoted 3 lines
hw/i386/acpi-microvm.c new file +3
-0+*/ + .rev = 5, + .minor_ver = 1,
So 5.1 I am guessing just copied from virt/arm? Or do you know why?
If not all we can say is /* ACPI v5.1 */
like ARM does, rest is guesswork ...
hw/i386/acpi-microvm.c line 100
Quoted 5 lines
hw/i386/acpi-microvm.c new file +5
-0+ + .flags = ((1 << ACPI_FADT_F_HW_REDUCED_ACPI) | + (1 << ACPI_FADT_F_RESET_REG_SUP)), + +/* Table 5-33 FADT Format -- SLEEP_CONTROL_REG */
You need to use the earliest spec version that includes a specific feature - and document which one it is. In version 5 table 5-33 is XSDT.
Generally it took me a while to understand this comment. It makes it look like
one needs to find SLEEP_CONTROL_REG in Table 5-33 You mean the address refers to SLEEP_CONTROL_REG. So put the comment near the address pls.
But the main poit is AcpiFadtData actually has nothing to do with FADT format. It's an abstracted API
Quoted 40 lines
hw/i386/acpi-microvm.c new file +40
-0+ .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 , + }; + + table_offsets =g_array_new (false, true/* clear */ , +sizeof (uint32_t )); +bios_linker_loader_alloc (tables->linker, +ACPI_BUILD_TABLE_FILE , tables_blob, +64 /* Ensure FACS is aligned */ , + false/* high memory */ ); + + dsdt = tables_blob->len; +build_dsdt_microvm (tables_blob, tables->linker, mms); + + pmfadt.dsdt_tbl_offset = &dsdt; + pmfadt.xdsdt_tbl_offset = &dsdt; +acpi_add_table (table_offsets, tables_blob); +build_fadt (tables_blob, tables->linker, &pmfadt,NULL ,NULL ); + +acpi_add_table (table_offsets, tables_blob);
hw/i386/acpi-microvm.c line 150
Quoted 10 lines
hw/i386/acpi-microvm.c new file +10
-0+acpi_build_madt (tables_blob, tables->linker,X86_MACHINE (machine), + mms->acpi_dev, false); + + xsdt = tables_blob->len; +build_xsdt (tables_blob, tables->linker, table_offsets,NULL ,NULL ); + +/* RSDP is in FSEG memory, so allocate it separately */ + { +AcpiRsdpData rsdp_data = { +/* Table 5-27 RSDP Structure */
RSDP is since ACPI 2.0, table number there is different.
Quoted 147 lines
hw/i386/acpi-microvm.c new file +45
-0+ .revision = 2, /* rev2 needed for xsdt support */ + .oem_id = ACPI_BUILD_APPNAME6, + .xsdt_tbl_offset = &xsdt, + .rsdt_tbl_offset = NULL, + }; +build_rsdp (tables->rsdp, tables->linker, &rsdp_data); + } + +/* Cleanup memory that's no longer used. */ +g_array_free (table_offsets, true); +} + +static void acpi_build_no_update (void *build_opaque) +{ +/* nothing, microvm tables don't change at runtime */ +} + +void acpi_setup_microvm (MicrovmMachineState *mms) +{ +X86MachineState *x86ms =X86_MACHINE (mms); +AcpiBuildTables tables; + +assert (x86ms->fw_cfg); + +if (!x86_machine_is_acpi_enabled (x86ms)) { +return ; + } + +acpi_build_tables_init (&tables); +acpi_build_microvm (&tables, mms); + +/* Now expose it all to Guest */ +acpi_add_rom_blob (acpi_build_no_update,NULL , + tables.table_data, +ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_MAX_SIZE ); +acpi_add_rom_blob (acpi_build_no_update,NULL , + tables.linker->cmd_blob, +"etc/table-loader" ,0 ); +acpi_add_rom_blob (acpi_build_no_update,NULL , + tables.rsdp, +ACPI_BUILD_RSDP_FILE ,0 ); + +acpi_build_tables_cleanup (&tables, false); +}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@@ -102,6 +102,7 @@ config MICROVM select I8259 select MC146818RTC select VIRTIO_MMIO + select ACPI_HW_REDUCED config X86_IOMMU boolhw/i386/Makefile.objs +1
-0@@ -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.oSignature · 1 line
2.18.4
Re: [PATCH v5 08/20] microvm/acpi: add minimal acpi support
Hi,
Quoted 5 lines
hw/i386/acpi-microvm.c line 67
Quoted 3 lines
hw/i386/acpi-microvm.c new file +3
-0+ scope =aml_scope ("\\" ); + pkg =aml_package (4 ); +aml_append (pkg,aml_int (5 ));/* SLEEP_CONTROL_REG.SLP_TYP */ I'm not sure what does the comment refer to here.
It's the register field the value gets written to.
With full acpi this is PM1a_CNT.SLP_TYP, hw-reduced uses SLEEP_CONTROL_REG.SLP_TYP instead. This is cut&paste from pc/q35 version + adapted for hw-reduced.
Quoted 2 lines
Does this 5 match
the value IO handler tests against?
Yes. "5" for S5 state (aka poweroff). Can add a #define.
Quoted 1 line
Below is from "7.3.4 System \_Sx states" right?
"7.4.2 \_Sx (System States)" here (ACPI 6.3), guess that is the same.
Quoted 6 lines
hw/i386/acpi-microvm.c line 92
Quoted 4 lines
hw/i386/acpi-microvm.c new file +4
-0+AcpiFadtData pmfadt = { +/* +* minimum version for ACPI_FADT_F_HW_REDUCED_ACPI, +* see acpi spec "4.1 Hardware-Reduced ACPI" Spec version - I'm guessing ACPI spec 5.0.
6.3
Quoted 2 lines
And I think here is where you refer to
Table 5-34 Fixed ACPI Description Table (FADT) Format
Table 5-33 FADT Format
Quoted 5 lines
hw/i386/acpi-microvm.c line 95
Quoted 3 lines
hw/i386/acpi-microvm.c new file +3
-0+*/ + .rev = 5, + .minor_ver = 1,So 5.1 I am guessing just copied from
virt/arm?
Yes.
Quoted 7 lines
hw/i386/acpi-microvm.c line 100
Quoted 4 lines
hw/i386/acpi-microvm.c new file +4
-0+ .flags = ((1 << ACPI_FADT_F_HW_REDUCED_ACPI) | + (1 << ACPI_FADT_F_RESET_REG_SUP)), + +/* Table 5-33 FADT Format -- SLEEP_CONTROL_REG */ You need to use the earliest spec version that includes a specific feature - and document which one it is.
Phew. Isn't it easier to just use table and field name then, so it is easy to find in whatever version of the spec you have at hand? Also how can I figure the earliest spec version easily?
Sometimes the 6.3 spec documents which table version added specific fields, sometimes not ...
Is the table version synced with the acpi spec version? Does DSDT v2 mean the DSDT format was updated for ACPI 2.0 and hasn't changed since?
Quoted 2 lines
But the main poit is AcpiFadtData actually has nothing to do with FADT format. It's an abstracted API
The FADT is generated from AcpiFadtData. There is a 1:1 relationship between most AcpiFadtData fields and FADT table entries. This isn't what I would call "has nothing to do with" ...
Quoted 9 lines
hw/i386/acpi-microvm.c line 150
Quoted 7 lines
hw/i386/acpi-microvm.c new file +7
-0+ xsdt = tables_blob->len; +build_xsdt (tables_blob, tables->linker, table_offsets,NULL ,NULL ); + +/* RSDP is in FSEG memory, so allocate it separately */ + { +AcpiRsdpData rsdp_data = { +/* Table 5-27 RSDP Structure */ RSDP is since ACPI 2.0, table number there is different.
References to ACPI 2.0 are almost useless. ACPI 5.0 is the oldest version uefi.org offers for download.
Guess that underlines the point I made above that referencing specific versions of the spec doesn't work very well ...
take care,
Gerd
Re: [PATCH v5 08/20] microvm/acpi: add minimal acpi support
Quoted 56 lines · On Thu, 9 Jul 2020 14:33:32 +0200 Gerd Hoffmann <[email protected]> wrote:
Hi,
Quoted 5 lines
hw/i386/acpi-microvm.c line 67
Quoted 3 lines
hw/i386/acpi-microvm.c new file +3
-0+ scope =aml_scope ("\\" ); + pkg =aml_package (4 ); +aml_append (pkg,aml_int (5 ));/* SLEEP_CONTROL_REG.SLP_TYP */ I'm not sure what does the comment refer to here.
It's the register field the value gets written to.
With full acpi this is PM1a_CNT.SLP_TYP, hw-reduced uses SLEEP_CONTROL_REG.SLP_TYP instead. This is cut&paste from pc/q35 version + adapted for hw-reduced.Quoted 2 lines
Does this 5 match
the value IO handler tests against?Yes. "5" for S5 state (aka poweroff). Can add a #define.
Quoted 1 line
Below is from "7.3.4 System \_Sx states" right?
"7.4.2 \_Sx (System States)" here (ACPI 6.3), guess that is the same.
Quoted 6 lines
hw/i386/acpi-microvm.c line 92
Quoted 4 lines
hw/i386/acpi-microvm.c new file +4
-0+AcpiFadtData pmfadt = { +/* +* minimum version for ACPI_FADT_F_HW_REDUCED_ACPI, +* see acpi spec "4.1 Hardware-Reduced ACPI" Spec version - I'm guessing ACPI spec 5.0.
6.3
Quoted 2 lines
And I think here is where you refer to
Table 5-34 Fixed ACPI Description Table (FADT) FormatTable 5-33 FADT Format
Quoted 5 lines
hw/i386/acpi-microvm.c line 95
Quoted 3 lines
hw/i386/acpi-microvm.c new file +3
-0+*/ + .rev = 5, + .minor_ver = 1,So 5.1 I am guessing just copied from
virt/arm?Yes.
Quoted 7 lines
hw/i386/acpi-microvm.c line 100
Quoted 4 lines
hw/i386/acpi-microvm.c new file +4
-0+ .flags = ((1 << ACPI_FADT_F_HW_REDUCED_ACPI) | + (1 << ACPI_FADT_F_RESET_REG_SUP)), + +/* Table 5-33 FADT Format -- SLEEP_CONTROL_REG */ You need to use the earliest spec version that includes a specific feature - and document which one it is.
Phew. Isn't it easier to just use table and field name then, so it is easy to find in whatever version of the spec you have at hand? Also how can I figure the earliest spec version easily?
Quoted 5 lines
Sometimes the 6.3 spec documents which table version added specific fields, sometimes not ...
Is the table version synced with the acpi spec version? Does DSDT v2 mean the DSDT format was updated for ACPI 2.0 and hasn't changed since?
not necessarily, even if it's pain to check for earliest spec where feature appeared, it's the best and the least ambiguos comment format to refference spec, i.e. (do not count on chapter/table numbering/naming being stable accross versions)
/* Spec name + ver: chapter/table where the feature is described */
something like:
/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefObjectType */ Aml *aml_object_type(Aml *object)
Quoted 16 lines
Quoted 3 lines
But the main poit is AcpiFadtData actually has nothing to do with FADT format. It's an abstracted API
The FADT is generated from AcpiFadtData. There is a 1:1 relationship between most AcpiFadtData fields and FADT table entries. This isn't what I would call "has nothing to do with" ...
Quoted 8 lines
Quoted 7 lines
hw/i386/acpi-microvm.c new file +7
-0+ xsdt = tables_blob->len; +build_xsdt (tables_blob, tables->linker, table_offsets,NULL ,NULL ); + +/* RSDP is in FSEG memory, so allocate it separately */ + { +AcpiRsdpData rsdp_data = { +/* Table 5-27 RSDP Structure */
Quoted 4 lines
Quoted 1 line
RSDP is since ACPI 2.0, table number there is different.
References to ACPI 2.0 are almost useless. ACPI 5.0 is the oldest version uefi.org offers for download.
all versions are at (starting from 1.0)
https://uefi.org/acpi/specs
Quoted 2 lines
Guess that underlines the point I made above that referencing specific versions of the spec doesn't work very well ...
so far that worked well, effect of requiring spec+version was less questions during review as reviewer doesn't have to guess where it's documented.
Quoted 4 lines
take care,
Gerd
Re: [PATCH v5 08/20] microvm/acpi: add minimal acpi support
Hi,
Quoted 4 lines
Quoted 2 lines
References to ACPI 2.0 are almost useless. ACPI 5.0 is the oldest version uefi.org offers for download.
all versions are at (starting from 1.0)
https://uefi.org/acpi/specs
Ah, there are the old ones hidden.
Thanks for the pointer.
Fetched latest errata of each version (assuming errata will not put chapter numbers upside down ;)
take care,
Gerd
PATCH v5 9/20 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); scope =aml_scope ("\\" );
Signature · 1 line
2.18.4
PATCH v5 10/20 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.18.4
PATCH v5 11/20 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.18.4
PATCH v5 12/20 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.18.4
PATCH v5 13/20 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
@@ -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
@@ -848,7 +848,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;
@@ -890,7 +890,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
PATCH v5 14/20 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);
@@ -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;
@@ -191,7 +192,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
@@ -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
@@ -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
@@ -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
PATCH v5 15/20 x86: move cpu plug 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.
--- 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
@@ -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
Re: [PATCH v5 15/20] x86: move cpu plug from pc to x86
Quoted 4 lines · On Tue, 7 Jul 2020 14:53:51 +0200 Gerd Hoffmann <[email protected]> wrote:
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.
it's very convinient to have all hotplug handles in one place, so maybe move along unplug[_request] variants as well?
Quoted 562 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- 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@@ -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@@ -798,19 +798,6 @@ void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp) } } -static void rtc_set_cpus_count (ISADevice *rtc,uint16_t cpus_count) -{ -if (cpus_count >0xff ) { -/* If the number of CPUs can't be represented in 8 bits, the -* BIOS must use "FW_CFG_NB_CPUS". Set RTC field to 0 just -* to make old BIOSes fail more predictably. -*/ -rtc_set_memory (rtc,0x5f ,0 ); - }else { -rtc_set_memory (rtc,0x5f , cpus_count -1 ); - } -} -static void pc_machine_done (Notifier *notifier,void *data) {@@ -820,7 +807,7 @@ void pc_machine_done(Notifier *notifier, void *data)PCIBus *bus = pcms->bus;/* set the number of CPUs */ -rtc_set_cpus_count (x86ms->rtc, x86ms->boot_cpus); +x86_rtc_set_cpus_count (x86ms->rtc, x86ms->boot_cpus);if (bus) {int extra_hosts =0 ;@@ -1373,62 +1360,6 @@ static void pc_memory_unplug(HotplugHandler *hotplug_dev,error_propagate (errp, local_err); } -static int pc_apic_cmp (const void *a,const void *b) -{ -CPUArchId *apic_a = (CPUArchId *)a; -CPUArchId *apic_b = (CPUArchId *)b; - -return apic_a->arch_id - apic_b->arch_id; -} - -/* returns pointer to CPUArchId descriptor that matches CPU's apic_id -* in ms->possible_cpus->cpus, if ms->possible_cpus->cpus has no -* entry corresponding to CPU's apic_id returns NULL. -*/ -static CPUArchId *pc_find_cpu_slot (MachineState *ms,uint32_t id,int *idx) -{ -CPUArchId apic_id, *found_cpu; - - apic_id.arch_id = id; - found_cpu =bsearch (&apic_id, ms->possible_cpus->cpus, - ms->possible_cpus->len,sizeof (*ms->possible_cpus->cpus), - pc_apic_cmp); -if (found_cpu && idx) { - *idx = found_cpu - ms->possible_cpus->cpus; - } -return found_cpu; -} - -static void pc_cpu_plug (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) -{ -CPUArchId *found_cpu; -Error *local_err =NULL ; -X86CPU *cpu =X86_CPU (dev); -PCMachineState *pcms =PC_MACHINE (hotplug_dev); -X86MachineState *x86ms =X86_MACHINE (hotplug_dev); - -if (x86ms->acpi_dev) { -hotplug_handler_plug (x86ms->acpi_dev, dev, &local_err); -if (local_err) { - goto out; - } - } - -/* increment the number of CPUs */ - x86ms->boot_cpus++; -if (x86ms->rtc) { -rtc_set_cpus_count (x86ms->rtc, x86ms->boot_cpus); - } -if (x86ms->fw_cfg) { -fw_cfg_modify_i16 (x86ms->fw_cfg,FW_CFG_NB_CPUS , x86ms->boot_cpus); - } - - found_cpu =pc_find_cpu_slot (MACHINE (pcms), cpu->apic_id,NULL ); - found_cpu->cpu =OBJECT (dev); -out: -error_propagate (errp, local_err); -}static void pc_cpu_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {@@ -1443,7 +1374,7 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, goto out; } -pc_find_cpu_slot (MACHINE (pcms), cpu->apic_id, &idx); +x86_find_cpu_slot (MACHINE (pcms), cpu->apic_id, &idx);assert (idx !=-1 );if (idx ==0 ) {error_setg (&local_err,"Boot CPU is unpluggable" );@@ -1475,172 +1406,19 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_dev, goto out; } - found_cpu =pc_find_cpu_slot (MACHINE (pcms), cpu->apic_id,NULL ); + found_cpu =x86_find_cpu_slot (MACHINE (pcms), cpu->apic_id,NULL ); found_cpu->cpu =NULL ;qdev_unrealize (dev);/* decrement the number of CPUs */ x86ms->boot_cpus--;/* Update the number of CPUs in CMOS */ -rtc_set_cpus_count (x86ms->rtc, x86ms->boot_cpus); +x86_rtc_set_cpus_count (x86ms->rtc, x86ms->boot_cpus);fw_cfg_modify_i16 (x86ms->fw_cfg,FW_CFG_NB_CPUS , x86ms->boot_cpus); out:error_propagate (errp, local_err); } -static void pc_cpu_pre_plug (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) -{ -int idx; -CPUState *cs; -CPUArchId *cpu_slot; -X86CPUTopoIDs topo_ids; -X86CPU *cpu =X86_CPU (dev); -CPUX86State *env = &cpu->env; -MachineState *ms =MACHINE (hotplug_dev); -PCMachineState *pcms =PC_MACHINE (hotplug_dev); -X86MachineState *x86ms =X86_MACHINE (hotplug_dev); -unsigned int smp_cores = ms->smp.cores; -unsigned int smp_threads = ms->smp.threads; -X86CPUTopoInfo topo_info; - -if (!object_dynamic_cast (OBJECT (cpu), ms->cpu_type)) { -error_setg (errp,"Invalid CPU type, expected cpu type: '%s'" , - ms->cpu_type); -return ; - } - -init_topo_info (&topo_info, x86ms); - - env->nr_dies = x86ms->smp_dies; - env->nr_nodes = topo_info.nodes_per_pkg; - env->pkg_offset = x86ms->apicid_pkg_offset (&topo_info); - -/* -* If APIC ID is not set, -* set it based on socket/die/core/thread properties. -*/ -if (cpu->apic_id ==UNASSIGNED_APIC_ID ) { -int max_socket = (ms->smp.max_cpus -1 ) / - smp_threads / smp_cores / x86ms->smp_dies; - -/* -* die-id was optional in QEMU 4.0 and older, so keep it optional -* if there's only one die per socket. -*/ -if (cpu->die_id <0 && x86ms->smp_dies ==1 ) { - cpu->die_id =0 ; - } - -if (cpu->socket_id <0 ) { -error_setg (errp,"CPU socket-id is not set" ); -return ; - }else if (cpu->socket_id > max_socket) { -error_setg (errp,"Invalid CPU socket-id: %u must be in range 0:%u" , - cpu->socket_id, max_socket); -return ; - } -if (cpu->die_id <0 ) { -error_setg (errp,"CPU die-id is not set" ); -return ; - }else if (cpu->die_id > x86ms->smp_dies -1 ) { -error_setg (errp,"Invalid CPU die-id: %u must be in range 0:%u" , - cpu->die_id, x86ms->smp_dies -1 ); -return ; - } -if (cpu->core_id <0 ) { -error_setg (errp,"CPU core-id is not set" ); -return ; - }else if (cpu->core_id > (smp_cores -1 )) { -error_setg (errp,"Invalid CPU core-id: %u must be in range 0:%u" , - cpu->core_id, smp_cores -1 ); -return ; - } -if (cpu->thread_id <0 ) { -error_setg (errp,"CPU thread-id is not set" ); -return ; - }else if (cpu->thread_id > (smp_threads -1 )) { -error_setg (errp,"Invalid CPU thread-id: %u must be in range 0:%u" , - cpu->thread_id, smp_threads -1 ); -return ; - } - - topo_ids.pkg_id = cpu->socket_id; - topo_ids.die_id = cpu->die_id; - topo_ids.core_id = cpu->core_id; - topo_ids.smt_id = cpu->thread_id; - cpu->apic_id = x86ms->apicid_from_topo_ids (&topo_info, &topo_ids); - } - - cpu_slot =pc_find_cpu_slot (MACHINE (pcms), cpu->apic_id, &idx); -if (!cpu_slot) { -MachineState *ms =MACHINE (pcms); - - x86ms->topo_ids_from_apicid (cpu->apic_id, &topo_info, &topo_ids); -error_setg (errp, -"Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" -" APIC ID %" PRIu32", valid index range 0:%d" , - topo_ids.pkg_id, topo_ids.die_id, topo_ids.core_id, topo_ids.smt_id, - cpu->apic_id, ms->possible_cpus->len -1 ); -return ; - } - -if (cpu_slot->cpu) { -error_setg (errp,"CPU[%d] with APIC ID %" PRIu32" exists" , - idx, cpu->apic_id); -return ; - } - -/* if 'address' properties socket-id/core-id/thread-id are not set, set them -* so that machine_query_hotpluggable_cpus would show correct values -*/ -/* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizefn() -* once -smp refactoring is complete and there will be CPU private -* CPUState::nr_cores and CPUState::nr_threads fields instead of globals */ - x86ms->topo_ids_from_apicid (cpu->apic_id, &topo_info, &topo_ids); -if (cpu->socket_id !=-1 && cpu->socket_id != topo_ids.pkg_id) { -error_setg (errp,"property socket-id: %u doesn't match set apic-id:" -" 0x%x (socket-id: %u)" , cpu->socket_id, cpu->apic_id, - topo_ids.pkg_id); -return ; - } - cpu->socket_id = topo_ids.pkg_id; - -if (cpu->die_id !=-1 && cpu->die_id != topo_ids.die_id) { -error_setg (errp,"property die-id: %u doesn't match set apic-id:" -" 0x%x (die-id: %u)" , cpu->die_id, cpu->apic_id, topo_ids.die_id); -return ; - } - cpu->die_id = topo_ids.die_id; - -if (cpu->core_id !=-1 && cpu->core_id != topo_ids.core_id) { -error_setg (errp,"property core-id: %u doesn't match set apic-id:" -" 0x%x (core-id: %u)" , cpu->core_id, cpu->apic_id, - topo_ids.core_id); -return ; - } - cpu->core_id = topo_ids.core_id; - -if (cpu->thread_id !=-1 && cpu->thread_id != topo_ids.smt_id) { -error_setg (errp,"property thread-id: %u doesn't match set apic-id:" -" 0x%x (thread-id: %u)" , cpu->thread_id, cpu->apic_id, - topo_ids.smt_id); -return ; - } - cpu->thread_id = topo_ids.smt_id; - -if (hyperv_feat_enabled (cpu,HYPERV_FEAT_VPINDEX ) && - !kvm_hv_vpindex_settable ()) { -error_setg (errp,"kernel doesn't allow setting HyperV VP_INDEX" ); -return ; - } - - cs =CPU (cpu); - cs->cpu_index = idx; - -numa_cpu_pre_plug (cpu_slot, dev, errp); -} -static void pc_virtio_pmem_pci_pre_plug (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {@@ -1706,7 +1484,7 @@ static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,if (object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) {pc_memory_pre_plug (hotplug_dev, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { -pc_cpu_pre_plug (hotplug_dev, dev, errp); +x86_cpu_pre_plug (hotplug_dev, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_VIRTIO_PMEM_PCI )) {pc_virtio_pmem_pci_pre_plug (hotplug_dev, dev, errp); }@@ -1718,7 +1496,7 @@ static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev,if (object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) {pc_memory_plug (hotplug_dev, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { -pc_cpu_plug (hotplug_dev, dev, errp); +x86_cpu_plug (hotplug_dev, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_VIRTIO_PMEM_PCI )) {pc_virtio_pmem_pci_plug (hotplug_dev, dev, errp); }hw/i386/x86.c +222
-0@@ -41,6 +41,7 @@#include "hw/i386/topology.h" #include "hw/i386/fw_cfg.h" #include "hw/intc/i8259.h" +#include "hw/rtc/mc146818rtc.h" #include "hw/acpi/cpu_hotplug.h" #include "hw/irq.h" @@ -168,6 +169,227 @@ void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version) } } +void x86_cpu_pre_plug (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +int idx; +CPUState *cs; +CPUArchId *cpu_slot; +X86CPUTopoIDs topo_ids; +X86CPU *cpu =X86_CPU (dev); +CPUX86State *env = &cpu->env; +MachineState *ms =MACHINE (hotplug_dev); +X86MachineState *x86ms =X86_MACHINE (hotplug_dev); +unsigned int smp_cores = ms->smp.cores; +unsigned int smp_threads = ms->smp.threads; +X86CPUTopoInfo topo_info; + +if (!object_dynamic_cast (OBJECT (cpu), ms->cpu_type)) { +error_setg (errp,"Invalid CPU type, expected cpu type: '%s'" , + ms->cpu_type); +return ; + } + +init_topo_info (&topo_info, x86ms); + + env->nr_dies = x86ms->smp_dies; + env->nr_nodes = topo_info.nodes_per_pkg; + env->pkg_offset = x86ms->apicid_pkg_offset (&topo_info); + +/* +* If APIC ID is not set, +* set it based on socket/die/core/thread properties. +*/ +if (cpu->apic_id ==UNASSIGNED_APIC_ID ) { +int max_socket = (ms->smp.max_cpus -1 ) / + smp_threads / smp_cores / x86ms->smp_dies; + +/* +* die-id was optional in QEMU 4.0 and older, so keep it optional +* if there's only one die per socket. +*/ +if (cpu->die_id <0 && x86ms->smp_dies ==1 ) { + cpu->die_id =0 ; + } + +if (cpu->socket_id <0 ) { +error_setg (errp,"CPU socket-id is not set" ); +return ; + }else if (cpu->socket_id > max_socket) { +error_setg (errp,"Invalid CPU socket-id: %u must be in range 0:%u" , + cpu->socket_id, max_socket); +return ; + } +if (cpu->die_id <0 ) { +error_setg (errp,"CPU die-id is not set" ); +return ; + }else if (cpu->die_id > x86ms->smp_dies -1 ) { +error_setg (errp,"Invalid CPU die-id: %u must be in range 0:%u" , + cpu->die_id, x86ms->smp_dies -1 ); +return ; + } +if (cpu->core_id <0 ) { +error_setg (errp,"CPU core-id is not set" ); +return ; + }else if (cpu->core_id > (smp_cores -1 )) { +error_setg (errp,"Invalid CPU core-id: %u must be in range 0:%u" , + cpu->core_id, smp_cores -1 ); +return ; + } +if (cpu->thread_id <0 ) { +error_setg (errp,"CPU thread-id is not set" ); +return ; + }else if (cpu->thread_id > (smp_threads -1 )) { +error_setg (errp,"Invalid CPU thread-id: %u must be in range 0:%u" , + cpu->thread_id, smp_threads -1 ); +return ; + } + + topo_ids.pkg_id = cpu->socket_id; + topo_ids.die_id = cpu->die_id; + topo_ids.core_id = cpu->core_id; + topo_ids.smt_id = cpu->thread_id; + cpu->apic_id = x86ms->apicid_from_topo_ids (&topo_info, &topo_ids); + } + + cpu_slot =x86_find_cpu_slot (MACHINE (x86ms), cpu->apic_id, &idx); +if (!cpu_slot) { +MachineState *ms =MACHINE (x86ms); + + x86ms->topo_ids_from_apicid (cpu->apic_id, &topo_info, &topo_ids); +error_setg (errp, +"Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" +" APIC ID %" PRIu32", valid index range 0:%d" , + topo_ids.pkg_id, topo_ids.die_id, topo_ids.core_id, topo_ids.smt_id, + cpu->apic_id, ms->possible_cpus->len -1 ); +return ; + } + +if (cpu_slot->cpu) { +error_setg (errp,"CPU[%d] with APIC ID %" PRIu32" exists" , + idx, cpu->apic_id); +return ; + } + +/* if 'address' properties socket-id/core-id/thread-id are not set, set them +* so that machine_query_hotpluggable_cpus would show correct values +*/ +/* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizefn() +* once -smp refactoring is complete and there will be CPU private +* CPUState::nr_cores and CPUState::nr_threads fields instead of globals */ + x86ms->topo_ids_from_apicid (cpu->apic_id, &topo_info, &topo_ids); +if (cpu->socket_id !=-1 && cpu->socket_id != topo_ids.pkg_id) { +error_setg (errp,"property socket-id: %u doesn't match set apic-id:" +" 0x%x (socket-id: %u)" , cpu->socket_id, cpu->apic_id, + topo_ids.pkg_id); +return ; + } + cpu->socket_id = topo_ids.pkg_id; + +if (cpu->die_id !=-1 && cpu->die_id != topo_ids.die_id) { +error_setg (errp,"property die-id: %u doesn't match set apic-id:" +" 0x%x (die-id: %u)" , cpu->die_id, cpu->apic_id, topo_ids.die_id); +return ; + } + cpu->die_id = topo_ids.die_id; + +if (cpu->core_id !=-1 && cpu->core_id != topo_ids.core_id) { +error_setg (errp,"property core-id: %u doesn't match set apic-id:" +" 0x%x (core-id: %u)" , cpu->core_id, cpu->apic_id, + topo_ids.core_id); +return ; + } + cpu->core_id = topo_ids.core_id; + +if (cpu->thread_id !=-1 && cpu->thread_id != topo_ids.smt_id) { +error_setg (errp,"property thread-id: %u doesn't match set apic-id:" +" 0x%x (thread-id: %u)" , cpu->thread_id, cpu->apic_id, + topo_ids.smt_id); +return ; + } + cpu->thread_id = topo_ids.smt_id; + +if (hyperv_feat_enabled (cpu,HYPERV_FEAT_VPINDEX ) && + !kvm_hv_vpindex_settable ()) { +error_setg (errp,"kernel doesn't allow setting HyperV VP_INDEX" ); +return ; + } + + cs =CPU (cpu); + cs->cpu_index = idx; + +numa_cpu_pre_plug (cpu_slot, dev, errp); +} + +void x86_rtc_set_cpus_count (ISADevice *rtc,uint16_t cpus_count) +{ +if (cpus_count >0xff ) { +/* If the number of CPUs can't be represented in 8 bits, the +* BIOS must use "FW_CFG_NB_CPUS". Set RTC field to 0 just +* to make old BIOSes fail more predictably. +*/ +rtc_set_memory (rtc,0x5f ,0 ); + }else { +rtc_set_memory (rtc,0x5f , cpus_count -1 ); + } +} + +static int x86_apic_cmp (const void *a,const void *b) +{ +CPUArchId *apic_a = (CPUArchId *)a; +CPUArchId *apic_b = (CPUArchId *)b; + +return apic_a->arch_id - apic_b->arch_id; +} + +/* returns pointer to CPUArchId descriptor that matches CPU's apic_id +* in ms->possible_cpus->cpus, if ms->possible_cpus->cpus has no +* entry corresponding to CPU's apic_id returns NULL. +*/ +CPUArchId *x86_find_cpu_slot (MachineState *ms,uint32_t id,int *idx) +{ +CPUArchId apic_id, *found_cpu; + + apic_id.arch_id = id; + found_cpu =bsearch (&apic_id, ms->possible_cpus->cpus, + ms->possible_cpus->len,sizeof (*ms->possible_cpus->cpus), + x86_apic_cmp); +if (found_cpu && idx) { + *idx = found_cpu - ms->possible_cpus->cpus; + } +return found_cpu; +} + +void x86_cpu_plug (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +CPUArchId *found_cpu; +Error *local_err =NULL ; +X86CPU *cpu =X86_CPU (dev); +X86MachineState *x86ms =X86_MACHINE (hotplug_dev); + +if (x86ms->acpi_dev) { +hotplug_handler_plug (x86ms->acpi_dev, dev, &local_err); +if (local_err) { + goto out; + } + } + +/* increment the number of CPUs */ + x86ms->boot_cpus++; +if (x86ms->rtc) { +x86_rtc_set_cpus_count (x86ms->rtc, x86ms->boot_cpus); + } +if (x86ms->fw_cfg) { +fw_cfg_modify_i16 (x86ms->fw_cfg,FW_CFG_NB_CPUS , x86ms->boot_cpus); + } + + found_cpu =x86_find_cpu_slot (MACHINE (x86ms), cpu->apic_id,NULL ); + found_cpu->cpu =OBJECT (dev); +out: +error_propagate (errp, local_err); +} +CpuInstanceProperties x86_cpu_index_to_props (MachineState *ms,unsigned cpu_index) {
PATCH v5 16/20 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;
@@ -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
Re: [PATCH v5 16/20] microvm: wire up hotplug
Quoted 7 lines · On Tue, 7 Jul 2020 14:53:52 +0200 Gerd Hoffmann <[email protected]> wrote:
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.Signed-off-by Gerd Hoffmann <[email protected]>
Blame is on me for calling it hotplug, HotplugHandlerClass is basically a set of hooks to wire things up regardless if it's hotplug or coldplug. In hindsight it was obvious at the time it was introduced.
Quoted 78 lines
--- 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;@@ -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 }, { } }, };
PATCH v5 17/20 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.18.4
PATCH v5 18/20 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;
@@ -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
Re: [PATCH v5 18/20] tests/acpi: allow override blkdev
Quoted 3 lines · On Tue, 7 Jul 2020 14:53:54 +0200 Gerd Hoffmann <[email protected]> wrote:
microvm needs virtio-blk instead of ide.
Signed-off-by Gerd Hoffmann <[email protected]>
Quoted 29 lines
--- 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;@@ -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);
PATCH v5 19/20 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
@@ -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
Re: [PATCH v5 19/20] tests/acpi: add microvm test
Quoted 12 lines · On Tue, 7 Jul 2020 14:53:55 +0200 Gerd Hoffmann <[email protected]> wrote:
Signed-off-by Gerd Hoffmann <[email protected]>--- tests/qtest/bios-tables-test.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)tests/qtest/bios-tables-test.c +0
-0@@ -1007,6 +1007,20 @@ static void test_acpi_virt_tcg_memhp(void) }
tests/qtest/bios-tables-test.c static void test_acpi_virt_tcg_memhp(void) · line 1018
Quoted 10 lines
tests/qtest/bios-tables-test.c +8
-0+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);
I vaguely recall this belongs to smbios tables, does actually microvm provide them?
Quoted 17 lines
tests/qtest/bios-tables-test.c +6
-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 = {tests/qtest/bios-tables-test.c +1
-0@@ -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);
Re: [PATCH v5 19/20] tests/acpi: add microvm test
Hi,
Quoted 3 lines
tests/qtest/bios-tables-test.c static void test_acpi_virt_tcg_memhp(void) · line 1017
Quoted 2 lines
tests/qtest/bios-tables-test.c +2
-0+ data.required_struct_types = base_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);I vaguely recall this belongs to smbios tables, does actually microvm provide them?
Checked. Yes, it tests smbios tables.
seabios generates something in case qemu doesn't provide smbios tables, so the test works. We don't actually test qemu though, so it probably makes sense to drop that for microvm until we actually generate smbios tables. Should we?
take care,
Gerd
Re: [PATCH v5 19/20] tests/acpi: add microvm test
Quoted 4 lines · On Thu, 16 Jul 2020 11:10:35 +0200 Gerd Hoffmann <[email protected]> wrote:
Hi,
Quoted 2 lines
Quoted 2 lines
tests/qtest/bios-tables-test.c +2
-0+ data.required_struct_types = base_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);
Quoted 8 lines
Quoted 1 line
I vaguely recall this belongs to smbios tables, does actually microvm provide them?
Checked. Yes, it tests smbios tables.
seabios generates something in case qemu doesn't provide smbios tables, so the test works. We don't actually test qemu though, so it probably makes sense to drop that for microvm until we actually generate smbios tables. Should we?
if dropping it just works, then yes, otherwise I wouldn't bother.
Quoted 4 lines
take care,
Gerd
PATCH v5 20/20 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.18.4
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:
Type: series
Message-id: [email protected]
Subject: [PATCH v5 00/20] microvm: add acpi support
=== 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
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
d5b6102 tests/acpi: update expected data files for microvm 4016e67 tests/acpi: add microvm test
7a0b05e tests/acpi: allow override blkdev
9855e16 tests/acpi: allow microvm test data updates. e96b4cf microvm: wire up hotplug
c0f5744 x86: move cpu plug from pc to x86
d7dc51c x86: move acpi_dev from pc/microvm c98bafc x86: constify x86_machine_is_*_enabled 9bf3547 microvm/acpi: disable virtio-mmio cmdline hack c725465 microvm/acpi: use seabios with acpi=on 856eae6 microvm/acpi: use GSI 16-23 for virtio 4b04f91 microvm/acpi: add acpi_dsdt_add_virtio() for x86 1d5e0bf microvm/acpi: add minimal acpi support 6ec826e microvm: make virtio irq base runtime configurable c3ca775 acpi: move acpi_dsdt_add_power_button() to ged 7d7d83c acpi: ged: add x86 device variant. 18cd04d acpi: ged: add control regs
c64763a seabios: add bios-microvm.bin binary 91801f8 seabios: add microvm config, update build rules 31f51e5 microvm: name qboot binary qboot.rom
=== OUTPUT BEGIN ===
1/20 Checking commit 31f51e53edea (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/20 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/20 Checking commit 91801f804550 (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/20 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
3/20 Checking commit c64763a56c6a (seabios: add bios-microvm.bin binary) 4/20 Checking commit 18cd04d78b56 (acpi: ged: add control regs) 5/20 Checking commit 7d7d83cd1c2c (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/20 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
6/20 Checking commit c3ca775f6e35 (acpi: move acpi_dsdt_add_power_button() to ged) 7/20 Checking commit 6ec826ec31e9 (microvm: make virtio irq base runtime configurable) 8/20 Checking commit 1d5e0bff7fc1 (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 #163: FILE: hw/i386/acpi-microvm.c:125:
+ table_offsets = g_array_new(false, true /* clear */,
WARNING: Block comments use a leading /* on a separate line #167: FILE: hw/i386/acpi-microvm.c:129:
+ 64 /* Ensure FACS is aligned */,
WARNING: Block comments use a leading /* on a separate line #168: FILE: hw/i386/acpi-microvm.c:130:
+ false /* high memory */);
total: 0 errors, 5 warnings, 311 lines checked
Patch 8/20 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
9/20 Checking commit 4b04f911df7a (microvm/acpi: add acpi_dsdt_add_virtio() for x86) 10/20 Checking commit 856eae6a8af7 (microvm/acpi: use GSI 16-23 for virtio) 11/20 Checking commit c7254650d200 (microvm/acpi: use seabios with acpi=on) 12/20 Checking commit 9bf3547b321c (microvm/acpi: disable virtio-mmio cmdline hack) 13/20 Checking commit c98bafce4745 (x86: constify x86_machine_is_*_enabled) 14/20 Checking commit d7dc51c13d40 (x86: move acpi_dev from pc/microvm) 15/20 Checking commit c0f57441ad6c (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/20 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
16/20 Checking commit e96b4cfdddca (microvm: wire up hotplug)
17/20 Checking commit 9855e16bac52 (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 17/20 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
18/20 Checking commit 7a0b05e95471 (tests/acpi: allow override blkdev) 19/20 Checking commit 4016e6747755 (tests/acpi: add microvm test)
20/20 Checking commit d5b610245ac6 (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]
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
acpi-test: Warning! DSDT binary file mismatch. Actual [aml:/tmp/aml-YB3SN0], Expected [aml:tests/data/acpi/microvm/DSDT].
See source file tests/qtest/bios-tables-test.c for instructions on how to update expected files.
to see ASL diff between mismatched files install IASL, rebuild QEMU from scratch and re-run tests with V=1 environment variable set**
ERROR:/tmp/qemu-test/src/tests/qtest/bios-tables-test.c:495:test_acpi_asl: assertion failed: (all_tables_match)
ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/qtest/bios-tables-test.c:495:test_acpi_asl: assertion failed: (all_tables_match)
make: *** [check-qtest-x86_64] Error 1
make: *** Waiting for unfinished jobs....
TEST iotest-qcow2: 030
TEST iotest-qcow2: 031
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=8f5f41e386b845a9a0f5edc2ade231c7', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-dd7_unsg/src/docker-src.2020-07-07-09.19.21.10455:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=8f5f41e386b845a9a0f5edc2ade231c7
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-dd7_unsg/src'
make: *** [docker-run-test-quick@centos7] Error 2
real 15m42.335s
user 0m8.981s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]