microvm: add acpi support
PATCH v3 1/22 microvm: name qboot binary qboot.bin
In reply to Gerd Hoffmannqboot isn't a bios and shouldnt be named that way.
---
hw/i386/microvm.c | 4 ++--
pc-bios/{bios-microvm.bin => qboot.bin} | Bin
roms/Makefile | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
rename pc-bios/{bios-microvm.bin => qboot.bin} (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.bin"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.bin 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.bin clean: rm -rf seabios/.config seabios/out seabios/builds
Signature · 1 line
2.18.4
PATCH v3 2/22 seabios: update submodule to master snapshot
In reply to Gerd Hoffmann--- roms/seabios | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
roms/seabios +1 -1
@@ -1 +1 @@ -Subproject commit f21b5a4aeb020f2a5e2c6503f906a9349dd2f069 +Subproject commit b8eda131954452bb5a236100a6572fe8f27d8021
Signature · 1 line
2.18.4
PATCH v3 3/22 seabios: update config & build rules
In reply to Gerd Hoffmann--- roms/Makefile | 5 ++++- roms/config.seabios-128k | 3 +++ roms/config.seabios-microvm | 26 ++++++++++++++++++++++++++ 3 files changed, 33 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-128k +3 -0
@@ -11,8 +11,11 @@ CONFIG_USB_UAS=n CONFIG_SDCARD=n CONFIG_TCGBIOS=n CONFIG_MPT_SCSI=n +CONFIG_ESP_SCSI=n +CONFIG_MEGASAS=n CONFIG_PVSCSI=n CONFIG_NVME=n CONFIG_USE_SMM=n CONFIG_VGAHOOKS=n CONFIG_HOST_BIOS_GEOMETRY=n +CONFIG_ACPI_PARSE=n
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 v3 8/22 acpi: fadt: add hw-reduced sleep register support
In reply to Gerd HoffmannAdd fields to struct AcpiFadtData and update build_fadt() to properly generate sleep register entries.
--- include/hw/acpi/acpi-defs.h | 2 ++ hw/acpi/aml-build.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-)
include/hw/acpi/acpi-defs.h +2 -0
@@ -88,6 +88,8 @@ typedef struct AcpiFadtData {struct AcpiGenericAddress pm_tmr;/* PM_TMR_BLK */ struct AcpiGenericAddress gpe0_blk;/* GPE0_BLK */ struct AcpiGenericAddress reset_reg;/* RESET_REG */ +struct AcpiGenericAddress sleep_ctl;/* SLEEP_CONTROL_REG */ +struct AcpiGenericAddress sleep_sts;/* SLEEP_STATUS_REG */ uint8_t reset_val;/* RESET_VALUE */ uint8_t rev;/* Revision */ uint32_t flags;/* Flags */
hw/acpi/aml-build.c +2 -2
@@ -1865,9 +1865,9 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f, }/* SLEEP_CONTROL_REG */ -build_append_gas (tbl,AML_AS_SYSTEM_MEMORY ,0 ,0 ,0 ,0 ); +build_append_gas_from_struct (tbl, &f->sleep_ctl);/* SLEEP_STATUS_REG */ -build_append_gas (tbl,AML_AS_SYSTEM_MEMORY ,0 ,0 ,0 ,0 ); +build_append_gas_from_struct (tbl, &f->sleep_sts);/* TODO: extra fields need to be added to support revisions above rev5 */ assert (f->rev ==5 );
Signature · 1 line
2.18.4
PATCH v3 7/22 acpi: madt: skip pci override on pci-less systems.
In reply to Gerd HoffmannNeeded for microvm.
--- hw/i386/acpi-common.h | 3 ++- hw/i386/acpi-build.c | 2 +- hw/i386/acpi-common.c | 26 +++++++++++++++----------- 3 files changed, 18 insertions(+), 13 deletions(-)
hw/i386/acpi-common.h +2 -1
@@ -9,6 +9,7 @@#define ACPI_BUILD_IOAPIC_ID 0x0void acpi_build_madt (GArray *table_data,BIOSLinker *linker, -X86MachineState *x86ms,AcpiDeviceIf *adev); +X86MachineState *x86ms,AcpiDeviceIf *adev, +bool has_pci);#endif
hw/i386/acpi-build.c +1 -1
@@ -2414,7 +2414,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)); +ACPI_DEVICE_IF (pcms->acpi_dev), true); vmgenid_dev =find_vmgenid_dev ();if (vmgenid_dev) {
hw/i386/acpi-common.c +15 -11
@@ -72,7 +72,8 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, }void acpi_build_madt (GArray *table_data,BIOSLinker *linker, -X86MachineState *x86ms,AcpiDeviceIf *adev) +X86MachineState *x86ms,AcpiDeviceIf *adev, +bool has_pci) {MachineClass *mc =MACHINE_GET_CLASS (x86ms);const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids (MACHINE (x86ms));
@@ -111,18 +112,21 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *linker, intsrcovr->gsi =cpu_to_le32 (2 ); intsrcovr->flags =cpu_to_le16 (0 );/* conforms to bus specifications */ } -for (i =1 ; i <16 ; i++) { + +if (has_pci) { +for (i =1 ; i <16 ; i++) {#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11)) -if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) { -/* No need for a INT source override structure. */ -continue ; +if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) { +/* No need for a INT source override structure. */ +continue ; + } + intsrcovr =acpi_data_push (table_data,sizeof *intsrcovr); + intsrcovr->type =ACPI_APIC_XRUPT_OVERRIDE ; + intsrcovr->length =sizeof (*intsrcovr); + intsrcovr->source = i; + intsrcovr->gsi =cpu_to_le32 (i); + intsrcovr->flags =cpu_to_le16 (0xd );/* active high, level triggered */ } - intsrcovr =acpi_data_push (table_data,sizeof *intsrcovr); - intsrcovr->type =ACPI_APIC_XRUPT_OVERRIDE ; - intsrcovr->length =sizeof (*intsrcovr); - intsrcovr->source = i; - intsrcovr->gsi =cpu_to_le32 (i); - intsrcovr->flags =cpu_to_le16 (0xd );/* active high, level triggered */ }if (x2apic_mode) {
Signature · 1 line
2.18.4
PATCH v3 15/22 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 0xc0000000 -#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 =8 ;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 */
@@ -246,7 +247,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;
@@ -266,7 +267,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 ;
@@ -278,6 +279,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;
@@ -301,7 +303,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
v3 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.
cheers,
Gerd
Gerd Hoffmann (22):
microvm: name qboot binary qboot.bin [testing] seabios: update submodule to master snapshot [testing] seabios: update config & build rules [testing] seabios: update binaries to master snapshot
acpi: make build_madt() more generic.
acpi: create acpi-common.c and move madt code
acpi: madt: skip pci override on pci-less systems.
acpi: fadt: add hw-reduced sleep register support
acpi: ged: rename event memory region
acpi: ged: add control regs
acpi: ged: add x86 device variant.
acpi: move acpi_dsdt_add_power_button() to ged
x86: coldplug cpus
microvm: use 2G split unconditionally
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 [RfC] acpi: add per machine type acpi default [RfC] acpi: flip default to off for microvm
hw/i386/acpi-common.h | 15 ++ hw/i386/acpi-microvm.h | 6 + include/hw/acpi/acpi-defs.h | 2 + include/hw/acpi/generic_event_device.h | 14 +- include/hw/i386/microvm.h | 11 +- include/hw/i386/x86.h | 1 + hw/acpi/aml-build.c | 4 +- hw/acpi/generic_event_device.c | 68 ++++++- hw/arm/virt-acpi-build.c | 8 - hw/i386/acpi-build.c | 126 +------------ hw/i386/acpi-common.c | 156 +++++++++++++++++ hw/i386/acpi-microvm.c | 234 +++++++++++++++++++++++++ hw/i386/generic_event_device_x86.c | 36 ++++ hw/i386/microvm.c | 78 ++++++--- hw/i386/x86.c | 32 +++- hw/i386/Kconfig | 1 + hw/i386/Makefile.objs | 3 + pc-bios/bios-256k.bin | Bin 262144 -> 262144 bytes pc-bios/bios-microvm.bin | Bin 65536 -> 131072 bytes pc-bios/bios.bin | Bin 131072 -> 131072 bytes pc-bios/qboot.bin | Bin 0 -> 65536 bytes roms/Makefile | 11 +- roms/config.seabios-128k | 3 + roms/config.seabios-microvm | 26 +++ roms/seabios | 2 +- 25 files changed, 664 insertions(+), 173 deletions(-) create mode 100644 hw/i386/acpi-common.h create mode 100644 hw/i386/acpi-microvm.h create mode 100644 hw/i386/acpi-common.c create mode 100644 hw/i386/acpi-microvm.c create mode 100644 hw/i386/generic_event_device_x86.c create mode 100644 pc-bios/qboot.bin create mode 100644 roms/config.seabios-microvm
Signature · 1 line
2.18.4
PATCH v3 6/22 acpi: create acpi-common.c and move madt code
We'll need madt support for microvm.
--- hw/i386/acpi-common.h | 14 ++++ hw/i386/acpi-build.c | 126 +--------------------------------- hw/i386/acpi-common.c | 152 ++++++++++++++++++++++++++++++++++++++++++ hw/i386/Makefile.objs | 1 + 4 files changed, 170 insertions(+), 123 deletions(-) create mode 100644 hw/i386/acpi-common.h create mode 100644 hw/i386/acpi-common.c
hw/i386/acpi-common.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef HW_I386_ACPI_COMMON_H +#define HW_I386_ACPI_COMMON_H +#include "include/hw/acpi/acpi_dev_interface.h" + +#include "include/hw/acpi/bios-linker-loader.h" +#include "include/hw/i386/x86.h" + +/* Default IOAPIC ID */ +#define ACPI_BUILD_IOAPIC_ID 0x0 + +void acpi_build_madt (GArray *table_data,BIOSLinker *linker, +X86MachineState *x86ms,AcpiDeviceIf *adev); + +#endif
hw/i386/acpi-build.c +3 -123
150 lines not on this page · raw message
hw/i386/acpi-common.c new file +152 -0
152 lines not on this page · raw message
hw/i386/Makefile.objs +1 -0
@@ -16,4 +16,5 @@ obj-$(CONFIG_VMMOUSE) += vmmouse.o obj-$(CONFIG_PC) += port92.o obj-y += kvmvapic.o +obj-$(CONFIG_ACPI) += acpi-common.o obj-$(CONFIG_PC) += acpi-build.o
Signature · 1 line
2.18.4
PATCH v3 10/22 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
PATCH v3 12/22 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
@@ -354,14 +354,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 build_iort (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) {
Signature · 1 line
2.18.4
PATCH v3 19/22 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.bin" +#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 v3 9/22 acpi: ged: rename event memory region
In reply to Gerd HoffmannRename memory region and callbacks and ops to carry "evt" in the name because a second region will be added shortly.
--- include/hw/acpi/generic_event_device.h | 2 +- hw/acpi/generic_event_device.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-)
include/hw/acpi/generic_event_device.h +1 -1
@@ -86,7 +86,7 @@#define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4typedef struct GEDState { -MemoryRegion io; +MemoryRegion evt;uint32_t sel; }GEDState ;
hw/acpi/generic_event_device.c +8 -8
@@ -142,7 +142,7 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev, }/* Memory read by the GED _EVT AML dynamic method */ -static uint64_t ged_read (void *opaque,hwaddr addr,unsigned size) +static uint64_t ged_evt_read (void *opaque,hwaddr addr,unsigned size) {uint64_t val =0 ;GEDState *ged_st = opaque;
@@ -161,14 +161,14 @@ static uint64_t ged_read(void *opaque, hwaddr addr, unsigned size) }/* Nothing is expected to be written to the GED memory region */ -static void ged_write (void *opaque,hwaddr addr,uint64_t data, -unsigned int size) +static void ged_evt_write (void *opaque,hwaddr addr,uint64_t data, +unsigned int size) { } -static const MemoryRegionOps ged_ops = { - .read = ged_read, - .write = ged_write, +static const MemoryRegionOps ged_evt_ops = { + .read = ged_evt_read, + .write = ged_evt_write, .endianness =DEVICE_LITTLE_ENDIAN , .valid = { .min_access_size =4 ,
@@ -287,9 +287,9 @@ static void acpi_ged_initfn(Object *obj)SysBusDevice *sbd =SYS_BUS_DEVICE (obj);GEDState *ged_st = &s->ged_state; -memory_region_init_io (&ged_st->io, obj, &ged_ops, ged_st, +memory_region_init_io (&ged_st->evt, obj, &ged_evt_ops, ged_st,TYPE_ACPI_GED ,ACPI_GED_EVT_SEL_LEN ); -sysbus_init_mmio (sbd, &ged_st->io); +sysbus_init_mmio (sbd, &ged_st->evt);sysbus_init_irq (sbd, &s->irq);
Signature · 1 line
2.18.4
PATCH v3 5/22 acpi: make build_madt() more generic.
In reply to Gerd HoffmannRemove PCMachineState dependency from build_madt(). Pass AcpiDeviceIf as separate argument instead of depending on PCMachineState->acpi_dev.
--- hw/i386/acpi-build.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
hw/i386/acpi-build.c +7 -7
@@ -366,14 +366,13 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, }static void -build_madt (GArray *table_data,BIOSLinker *linker,PCMachineState *pcms) +build_madt (GArray *table_data,BIOSLinker *linker, +X86MachineState *x86ms,AcpiDeviceIf *adev) { -MachineClass *mc =MACHINE_GET_CLASS (pcms); -X86MachineState *x86ms =X86_MACHINE (pcms); -const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids (MACHINE (pcms)); +MachineClass *mc =MACHINE_GET_CLASS (x86ms); +const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids (MACHINE (x86ms));int madt_start = table_data->len; -AcpiDeviceIfClass *adevc =ACPI_DEVICE_IF_GET_CLASS (pcms->acpi_dev); -AcpiDeviceIf *adev =ACPI_DEVICE_IF (pcms->acpi_dev); +AcpiDeviceIfClass *adevc =ACPI_DEVICE_IF_GET_CLASS (adev);bool x2apic_mode = false;AcpiMultipleApicTable *madt;
@@ -2534,7 +2533,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) aml_len += tables_blob->len - fadt;acpi_add_table (table_offsets, tables_blob); -build_madt (tables_blob, tables->linker, pcms); +build_madt (tables_blob, tables->linker, x86ms, +ACPI_DEVICE_IF (pcms->acpi_dev)); vmgenid_dev =find_vmgenid_dev ();if (vmgenid_dev) {
Signature · 1 line
2.18.4
PATCH v3 11/22 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 v3 20/22 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
@@ -362,7 +362,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
RFC PATCH v3 22/22 acpi: flip default to off for microvm
In reply to Gerd Hoffmann--- hw/i386/microvm.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/microvm.c +4 -0
@@ -517,6 +517,7 @@ static void microvm_machine_initfn(Object *obj)static void microvm_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +X86MachineClass *x86mc =X86_MACHINE_CLASS (oc); mc->init = microvm_machine_state_init;
@@ -537,6 +538,9 @@ static void microvm_class_init(ObjectClass *oc, void *data)/* Machine class handlers */ mc->reset = microvm_machine_reset; +/* acpi is off by default */ + x86mc->acpi_default = false; + object_class_property_add(oc, MICROVM_MACHINE_PIC, "OnOffAuto", microvm_machine_get_pic, microvm_machine_set_pic,
Signature · 1 line
2.18.4
PATCH v3 14/22 microvm: use 2G split unconditionally
In reply to Gerd HoffmannLooks like the logiv was copied over from q35.
q35 does this for backward compatibility, there is no reason to do this on microvm though. So split @ 2G unconditionally.
--- hw/i386/microvm.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
hw/i386/microvm.c +1 -15
@@ -170,23 +170,9 @@ static void microvm_memory_init(MicrovmMachineState *mms)MemoryRegion *ram_below_4g, *ram_above_4g;MemoryRegion *system_memory =get_system_memory ();FWCfgState *fw_cfg; -ram_addr_t lowmem; +ram_addr_t lowmem =0x80000000 ;/* 2G */ int i; -/* -* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory -* and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping -* also known as MMCFG). -* If it doesn't, we need to split it in chunks below and above 4G. -* In any case, try to make sure that guest addresses aligned at -* 1G boundaries get mapped to host addresses aligned at 1G boundaries. -*/ -if (machine->ram_size >=0xb0000000 ) { - lowmem =0x80000000 ; - }else { - lowmem =0xb0000000 ; - } -/* * Handle the machine opt max-ram-below-4g. It is basically doing * min(qemu limit, user limit).
Signature · 1 line
2.18.4
PATCH v3 4/22 seabios: update binaries to master snapshot
In reply to Gerd Hoffmann--- pc-bios/bios-256k.bin | Bin 262144 -> 262144 bytes pc-bios/bios-microvm.bin | Bin 0 -> 131072 bytes pc-bios/bios.bin | Bin 131072 -> 131072 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 pc-bios/bios-microvm.bin
pc-bios/bios-256k.bin binary +0 -0
pc-bios/bios-microvm.bin new file binary +0 -0
pc-bios/bios.bin binary +0 -0
Signature · 1 line
2.18.4
PATCH v3 16/22 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 | 6 ++ include/hw/i386/microvm.h | 9 ++ hw/i386/acpi-microvm.c | 182 ++++++++++++++++++++++++++++++++++++++ hw/i386/microvm.c | 37 ++++++++ hw/i386/Kconfig | 1 + hw/i386/Makefile.objs | 1 + 6 files changed, 236 insertions(+) create mode 100644 hw/i386/acpi-microvm.h create mode 100644 hw/i386/acpi-microvm.c
hw/i386/acpi-microvm.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef HW_I386_ACPI_MICROVM_H +#define HW_I386_ACPI_MICROVM_H + +void acpi_setup_microvm (void ); + +#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 0xc0000000#define VIRTIO_NUM_TRANSPORTS 8#define VIRTIO_CMDLINE_MAXLEN 64 +#define GED_MMIO_BASE 0xc1000000 +#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 +182 -0
182 lines not on this page · raw message
hw/i386/microvm.c +37 -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_create (NULL ,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 ]); +qdev_init_nofail (dev); + mms->acpi_dev =ACPI_DEVICE_IF (dev); + }if (mms->pic ==ON_OFF_AUTO_ON || mms->pic ==ON_OFF_AUTO_AUTO ) {qemu_irq *i8259;
@@ -457,6 +472,23 @@ 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) +{ +acpi_setup_microvm (); +} + +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);
@@ -471,6 +503,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
PATCH v3 17/22 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 v3 13/22 x86: coldplug cpus
In reply to Gerd Hoffmannmicrovm needs this, for correct madt creation
(make sure enable bit is set).
--- hw/i386/x86.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
hw/i386/x86.c +11 -0
@@ -118,6 +118,7 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms,void x86_cpu_new (X86MachineState *x86ms,int64_t apic_id,Error **errp) { +MachineClass *mc =MACHINE_GET_CLASS (x86ms);Object *cpu =NULL ;Error *local_err =NULL ;
@@ -126,6 +127,16 @@ void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp)object_property_set_uint (cpu, apic_id,"apic-id" , &local_err);object_property_set_bool (cpu, true,"realized" , &local_err); +if (!mc->has_hotpluggable_cpus) { +/* coldplug cpu */ +MachineState *ms =MACHINE (x86ms); +int i =0 ; +while (ms->possible_cpus->cpus[i].arch_id != apic_id) { + i++; + } + ms->possible_cpus->cpus[i].cpu = cpu; + } +object_unref (cpu);error_propagate (errp, local_err); }
Signature · 1 line
2.18.4
RFC PATCH v3 21/22 acpi: add per machine type acpi default
In reply to Gerd HoffmannAllow setting acpi default value for each machine type.
--- include/hw/i386/x86.h | 1 + hw/i386/x86.c | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-)
include/hw/i386/x86.h +1 -0
@@ -37,6 +37,7 @@ typedef struct {bool save_tsc_khz;/* Enables contiguous-apic-ID mode */ bool compat_apic_id_mode; +bool acpi_default; } X86MachineClass; typedef struct {
hw/i386/x86.c +18 -3
@@ -940,10 +940,22 @@ static void x86_machine_set_smm(Object *obj, Visitor *v, const char *name,bool x86_machine_is_acpi_enabled (X86MachineState *x86ms) { -if (x86ms->acpi ==ON_OFF_AUTO_OFF ) { -return false; +X86MachineClass *x86mc =X86_MACHINE_GET_CLASS (x86ms); +bool enabled; + +switch (x86ms->acpi) { +case ON_OFF_AUTO_ON : + enabled = true; +break ; +case ON_OFF_AUTO_OFF : + enabled = false; +break ; +case ON_OFF_AUTO_AUTO : +default : + enabled = x86mc->acpi_default; +break ; } -return true; +return enabled; } static void x86_machine_get_acpi(Object *obj, Visitor *v, const char *name,
@@ -991,6 +1003,9 @@ static void x86_machine_class_init(ObjectClass *oc, void *data) x86mc->save_tsc_khz = true; nc->nmi_monitor_handler = x86_nmi; +/* acpi is on by default */ + x86mc->acpi_default = true; +object_class_property_add (oc,X86_MACHINE_MAX_RAM_BELOW_4G ,"size" , x86_machine_get_max_ram_below_4g, x86_machine_set_max_ram_below_4g,NULL ,NULL );
Signature · 1 line
2.18.4
PATCH v3 18/22 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 8-15.
--- 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 =8 ; + mms->virtio_irq_base =x86_machine_is_acpi_enabled (x86ms) ?16 :8 ;for (i =0 ; i <VIRTIO_NUM_TRANSPORTS ; i++) { sysbus_create_simple("virtio-mmio", VIRTIO_MMIO_BASE + i * 512,
Signature · 1 line
2.18.4
Re: [PATCH v3 15/22] microvm: make virtio irq base runtime configurable
In reply to Gerd HoffmannQuoted 32 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Sergio Lopez <[email protected]>--- 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 0xc0000000 -#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 +0
-0
hw/i386/microvm.c static void microvm_devices_init(MicrovmMachineState *mms) · line 124
Quoted 4 lines
hw/i386/microvm.c +1
-0@@ -121,10 +121,11 @@ static void microvm_devices_init(MicrovmMachineState *mms)kvmclock_create (); + mms->virtio_irq_base =8 ;
Hmm you made it runtime configurable indeed, but you also changed it from 5 to 8. Worth a different patch, or at least mentioning in commit description.
Quoted 45 lines
hw/i386/microvm.c +6
-4for (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 */ @@ -246,7 +247,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;@@ -266,7 +267,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 ;@@ -278,6 +279,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;@@ -301,7 +303,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);
Re: [PATCH v3 12/22] acpi: move acpi_dsdt_add_power_button() to ged
In reply to Gerd HoffmannQuoted 49 lines · Gerd Hoffmann
Allow reuse for microvm.
Signed-off-by Gerd Hoffmann <[email protected]>--- 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
-1@@ -354,14 +354,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)
hw/arm/virt-acpi-build.c static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, · line 359
Quoted 10 lines
hw/arm/virt-acpi-build.c +0
-7-{ -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 build_iort (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) {
Re: [PATCH v3 01/22] microvm: name qboot binary qboot.bin
In reply to Gerd HoffmannHi Gerd,
Quoted 1 line · Gerd Hoffmann
qboot isn't a bios and shouldnt be named that way.
Still it resides in a directory named pc-bios =)
It is used later in x86_bios_rom_init() as:
bios = g_malloc(sizeof(*bios));
memory_region_init_ram(bios, NULL, "pc.bios", bios_size, &error_fatal);
if (!isapc_ram_fw) {
memory_region_set_readonly(bios, true);
}
ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
if (ret != 0) {
bios_error:
fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
exit(1);
}
g_free(filename);Many 'bios' occurrences.
Should it be called 'qboot.rom' instead?
Quoted 61 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/i386/microvm.c | 4 ++-- pc-bios/{bios-microvm.bin => qboot.bin} | Bin roms/Makefile | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)rename pc-bios/{bios-microvm.bin => qboot.bin} (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.bin"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.bin renamed from pc-bios/bios-microvm.bin +0
-0roms/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.bin clean: rm -rf seabios/.config seabios/out seabios/builds
Re: [PATCH v3 09/22] acpi: ged: rename event memory region
In reply to Gerd HoffmannQuoted 58 lines · Gerd Hoffmann
Rename memory region and callbacks and ops to carry "evt" in the name because a second region will be added shortly.
Signed-off-by Gerd Hoffmann <[email protected]>--- include/hw/acpi/generic_event_device.h | 2 +- hw/acpi/generic_event_device.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-)include/hw/acpi/generic_event_device.h +1
-1@@ -86,7 +86,7 @@#define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4typedef struct GEDState { -MemoryRegion io; +MemoryRegion evt;uint32_t sel; }GEDState ;hw/acpi/generic_event_device.c +6
-6@@ -142,7 +142,7 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev, }/* Memory read by the GED _EVT AML dynamic method */ -static uint64_t ged_read (void *opaque,hwaddr addr,unsigned size) +static uint64_t ged_evt_read (void *opaque,hwaddr addr,unsigned size) {uint64_t val =0 ;GEDState *ged_st = opaque;@@ -161,14 +161,14 @@ static uint64_t ged_read(void *opaque, hwaddr addr, unsigned size) }/* Nothing is expected to be written to the GED memory region */ -static void ged_write (void *opaque,hwaddr addr,uint64_t data, -unsigned int size) +static void ged_evt_write (void *opaque,hwaddr addr,uint64_t data, +unsigned int size) { } -static const MemoryRegionOps ged_ops = { - .read = ged_read, - .write = ged_write, +static const MemoryRegionOps ged_evt_ops = { + .read = ged_evt_read, + .write = ged_evt_write, .endianness =DEVICE_LITTLE_ENDIAN , .valid = { .min_access_size =4 ,@@ -287,9 +287,9 @@ static void acpi_ged_initfn(Object *obj)SysBusDevice *sbd =SYS_BUS_DEVICE (obj);
hw/acpi/generic_event_device.c static void acpi_ged_initfn(Object *obj) · line 295
Quoted 10 lines
hw/acpi/generic_event_device.c +2
-2GEDState *ged_st = &s->ged_state; -memory_region_init_io (&ged_st->io, obj, &ged_ops, ged_st, +memory_region_init_io (&ged_st->evt, obj, &ged_evt_ops, ged_st,TYPE_ACPI_GED ,ACPI_GED_EVT_SEL_LEN ); -sysbus_init_mmio (sbd, &ged_st->io); +sysbus_init_mmio (sbd, &ged_st->evt);sysbus_init_irq (sbd, &s->irq);
Re: [PATCH v3 06/22] acpi: create acpi-common.c and move madt code
In reply to Gerd HoffmannQuoted 355 lines · Gerd Hoffmann
We'll need madt support for microvm.
Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Igor Mammedov <[email protected]>--- hw/i386/acpi-common.h | 14 ++++ hw/i386/acpi-build.c | 126 +--------------------------------- hw/i386/acpi-common.c | 152 ++++++++++++++++++++++++++++++++++++++++++ hw/i386/Makefile.objs | 1 + 4 files changed, 170 insertions(+), 123 deletions(-)create mode 100644
hw/i386/acpi-common.h
create mode 100644hw/i386/acpi-common.chw/i386/acpi-common.h new file +14
-0@@ -0,0 +1,14 @@ +#ifndef HW_I386_ACPI_COMMON_H +#define HW_I386_ACPI_COMMON_H +#include "include/hw/acpi/acpi_dev_interface.h" + +#include "include/hw/acpi/bios-linker-loader.h" +#include "include/hw/i386/x86.h" + +/* Default IOAPIC ID */ +#define ACPI_BUILD_IOAPIC_ID 0x0 + +void acpi_build_madt (GArray *table_data,BIOSLinker *linker, +X86MachineState *x86ms,AcpiDeviceIf *adev); + +#endif hw/i386/acpi-build.c +3
-123@@ -24,6 +24,7 @@#include "qapi/error.h" #include "qapi/qmp/qnum.h" #include "acpi-build.h" +#include "acpi-common.h" #include "qemu/bitmap.h" #include "qemu/error-report.h" #include "hw/pci/pci.h" @@ -89,9 +90,6 @@#define ACPI_BUILD_DPRINTF (fmt, ...)#endif -/* Default IOAPIC ID */ -#define ACPI_BUILD_IOAPIC_ID 0x0 - typedef struct AcpiPmInfo { bool s3_disabled; bool s4_disabled;@@ -327,124 +325,6 @@ build_facs(GArray *table_data) facs->length =cpu_to_le32 (sizeof (*facs)); } -void pc_madt_cpu_entry (AcpiDeviceIf *adev,int uid, -const CPUArchIdList *apic_ids,GArray *entry) -{ -uint32_t apic_id = apic_ids->cpus[uid].arch_id; - -/* ACPI spec says that LAPIC entry for non present -* CPU may be omitted from MADT or it must be marked -* as disabled. However omitting non present CPU from -* MADT breaks hotplug on linux. So possible CPUs -* should be put in MADT but kept disabled. -*/ -if (apic_id <255 ) { -AcpiMadtProcessorApic *apic =acpi_data_push (entry,sizeof *apic); - - apic->type =ACPI_APIC_PROCESSOR ; - apic->length =sizeof (*apic); - apic->processor_id = uid; - apic->local_apic_id = apic_id; -if (apic_ids->cpus[uid].cpu !=NULL ) { - apic->flags =cpu_to_le32 (1 ); - }else { - apic->flags =cpu_to_le32 (0 ); - } - }else { -AcpiMadtProcessorX2Apic *apic =acpi_data_push (entry,sizeof *apic); - - apic->type =ACPI_APIC_LOCAL_X2APIC ; - apic->length =sizeof (*apic); - apic->uid =cpu_to_le32 (uid); - apic->x2apic_id =cpu_to_le32 (apic_id); -if (apic_ids->cpus[uid].cpu !=NULL ) { - apic->flags =cpu_to_le32 (1 ); - }else { - apic->flags =cpu_to_le32 (0 ); - } - } -} - -static void -build_madt (GArray *table_data,BIOSLinker *linker, -X86MachineState *x86ms,AcpiDeviceIf *adev) -{ -MachineClass *mc =MACHINE_GET_CLASS (x86ms); -const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids (MACHINE (x86ms)); -int madt_start = table_data->len; -AcpiDeviceIfClass *adevc =ACPI_DEVICE_IF_GET_CLASS (adev); -bool x2apic_mode = false; - -AcpiMultipleApicTable *madt; -AcpiMadtIoApic *io_apic; -AcpiMadtIntsrcovr *intsrcovr; -int i; - - madt =acpi_data_push (table_data,sizeof *madt); - madt->local_apic_address =cpu_to_le32 (APIC_DEFAULT_ADDRESS ); - madt->flags =cpu_to_le32 (1 ); - -for (i =0 ; i < apic_ids->len; i++) { - adevc->madt_cpu (adev, i, apic_ids, table_data); -if (apic_ids->cpus[i].arch_id >254 ) { - x2apic_mode = true; - } - } - - io_apic =acpi_data_push (table_data,sizeof *io_apic); - io_apic->type =ACPI_APIC_IO ; - io_apic->length =sizeof (*io_apic); - io_apic->io_apic_id =ACPI_BUILD_IOAPIC_ID ; - io_apic->address =cpu_to_le32 (IO_APIC_DEFAULT_ADDRESS ); - io_apic->interrupt =cpu_to_le32 (0 ); - -if (x86ms->apic_xrupt_override) { - intsrcovr =acpi_data_push (table_data,sizeof *intsrcovr); - intsrcovr->type =ACPI_APIC_XRUPT_OVERRIDE ; - intsrcovr->length =sizeof (*intsrcovr); - intsrcovr->source =0 ; - intsrcovr->gsi =cpu_to_le32 (2 ); - intsrcovr->flags =cpu_to_le16 (0 );/* conforms to bus specifications */ - } -for (i =1 ; i <16 ; i++) { -#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11)) -if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) { -/* No need for a INT source override structure. */ -continue ; - } - intsrcovr =acpi_data_push (table_data,sizeof *intsrcovr); - intsrcovr->type =ACPI_APIC_XRUPT_OVERRIDE ; - intsrcovr->length =sizeof (*intsrcovr); - intsrcovr->source = i; - intsrcovr->gsi =cpu_to_le32 (i); - intsrcovr->flags =cpu_to_le16 (0xd );/* active high, level triggered */ - } - -if (x2apic_mode) { -AcpiMadtLocalX2ApicNmi *local_nmi; - - local_nmi =acpi_data_push (table_data,sizeof *local_nmi); - local_nmi->type =ACPI_APIC_LOCAL_X2APIC_NMI ; - local_nmi->length =sizeof (*local_nmi); - local_nmi->uid =0xFFFFFFFF ;/* all processors */ - local_nmi->flags =cpu_to_le16 (0 ); - local_nmi->lint =1 ;/* ACPI_LINT1 */ - }else { -AcpiMadtLocalNmi *local_nmi; - - local_nmi =acpi_data_push (table_data,sizeof *local_nmi); - local_nmi->type =ACPI_APIC_LOCAL_NMI ; - local_nmi->length =sizeof (*local_nmi); - local_nmi->processor_id =0xff ;/* all processors */ - local_nmi->flags =cpu_to_le16 (0 ); - local_nmi->lint =1 ;/* ACPI_LINT1 */ - } - -build_header (linker, table_data, - (void *)(table_data->data + madt_start),"APIC" , - table_data->len - madt_start,1 ,NULL ,NULL ); -} -static void build_append_pcihp_notify_entry (Aml *method,int slot) {Aml *if_ctx;@@ -2533,8 +2413,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) aml_len += tables_blob->len - fadt;acpi_add_table (table_offsets, tables_blob); -build_madt (tables_blob, tables->linker, x86ms, -ACPI_DEVICE_IF (pcms->acpi_dev)); +acpi_build_madt (tables_blob, tables->linker, x86ms, +ACPI_DEVICE_IF (pcms->acpi_dev)); vmgenid_dev =find_vmgenid_dev ();if (vmgenid_dev) {hw/i386/acpi-common.c new file +152
-0@@ -0,0 +1,152 @@ +/* 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/utils.h" +#include "hw/i386/pc.h" +#include "target/i386/cpu.h" + +#include "acpi-build.h" +#include "acpi-common.h" + +void pc_madt_cpu_entry (AcpiDeviceIf *adev,int uid, +const CPUArchIdList *apic_ids,GArray *entry) +{ +uint32_t apic_id = apic_ids->cpus[uid].arch_id; + +/* ACPI spec says that LAPIC entry for non present +* CPU may be omitted from MADT or it must be marked +* as disabled. However omitting non present CPU from +* MADT breaks hotplug on linux. So possible CPUs +* should be put in MADT but kept disabled. +*/ +if (apic_id <255 ) { +AcpiMadtProcessorApic *apic =acpi_data_push (entry,sizeof *apic); + + apic->type =ACPI_APIC_PROCESSOR ; + apic->length =sizeof (*apic); + apic->processor_id = uid; + apic->local_apic_id = apic_id; +if (apic_ids->cpus[uid].cpu !=NULL ) { + apic->flags =cpu_to_le32 (1 ); + }else { + apic->flags =cpu_to_le32 (0 ); + } + }else { +AcpiMadtProcessorX2Apic *apic =acpi_data_push (entry,sizeof *apic); + + apic->type =ACPI_APIC_LOCAL_X2APIC ; + apic->length =sizeof (*apic); + apic->uid =cpu_to_le32 (uid); + apic->x2apic_id =cpu_to_le32 (apic_id); +if (apic_ids->cpus[uid].cpu !=NULL ) { + apic->flags =cpu_to_le32 (1 ); + }else { + apic->flags =cpu_to_le32 (0 ); + } + } +} + +void acpi_build_madt (GArray *table_data,BIOSLinker *linker, +X86MachineState *x86ms,AcpiDeviceIf *adev) +{ +MachineClass *mc =MACHINE_GET_CLASS (x86ms); +const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids (MACHINE (x86ms)); +int madt_start = table_data->len; +AcpiDeviceIfClass *adevc =ACPI_DEVICE_IF_GET_CLASS (adev); +bool x2apic_mode = false; + +AcpiMultipleApicTable *madt; +AcpiMadtIoApic *io_apic; +AcpiMadtIntsrcovr *intsrcovr; +int i; + + madt =acpi_data_push (table_data,sizeof *madt); + madt->local_apic_address =cpu_to_le32 (APIC_DEFAULT_ADDRESS ); + madt->flags =cpu_to_le32 (1 ); + +for (i =0 ; i < apic_ids->len; i++) { + adevc->madt_cpu (adev, i, apic_ids, table_data); +if (apic_ids->cpus[i].arch_id >254 ) { + x2apic_mode = true; + } + } + + io_apic =acpi_data_push (table_data,sizeof *io_apic); + io_apic->type =ACPI_APIC_IO ; + io_apic->length =sizeof (*io_apic); + io_apic->io_apic_id =ACPI_BUILD_IOAPIC_ID ; + io_apic->address =cpu_to_le32 (IO_APIC_DEFAULT_ADDRESS ); + io_apic->interrupt =cpu_to_le32 (0 ); + +if (x86ms->apic_xrupt_override) { + intsrcovr =acpi_data_push (table_data,sizeof *intsrcovr); + intsrcovr->type =ACPI_APIC_XRUPT_OVERRIDE ; + intsrcovr->length =sizeof (*intsrcovr); + intsrcovr->source =0 ; + intsrcovr->gsi =cpu_to_le32 (2 ); + intsrcovr->flags =cpu_to_le16 (0 );/* conforms to bus specifications */ + } +for (i =1 ; i <16 ; i++) { +#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11)) +if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) { +/* No need for a INT source override structure. */ +continue ; + } + intsrcovr =acpi_data_push (table_data,sizeof *intsrcovr); + intsrcovr->type =ACPI_APIC_XRUPT_OVERRIDE ; + intsrcovr->length =sizeof (*intsrcovr); + intsrcovr->source = i; + intsrcovr->gsi =cpu_to_le32 (i); + intsrcovr->flags =cpu_to_le16 (0xd );/* active high, level triggered */ + } + +if (x2apic_mode) { +AcpiMadtLocalX2ApicNmi *local_nmi; + + local_nmi =acpi_data_push (table_data,sizeof *local_nmi); + local_nmi->type =ACPI_APIC_LOCAL_X2APIC_NMI ; + local_nmi->length =sizeof (*local_nmi); + local_nmi->uid =0xFFFFFFFF ;/* all processors */ + local_nmi->flags =cpu_to_le16 (0 ); + local_nmi->lint =1 ;/* ACPI_LINT1 */ + }else { +AcpiMadtLocalNmi *local_nmi; + + local_nmi =acpi_data_push (table_data,sizeof *local_nmi); + local_nmi->type =ACPI_APIC_LOCAL_NMI ; + local_nmi->length =sizeof (*local_nmi); + local_nmi->processor_id =0xff ;/* all processors */ + local_nmi->flags =cpu_to_le16 (0 ); + local_nmi->lint =1 ;/* ACPI_LINT1 */ + } + +build_header (linker, table_data, + (void *)(table_data->data + madt_start),"APIC" , + table_data->len - madt_start,1 ,NULL ,NULL ); +} +hw/i386/Makefile.objs +0
-0
hw/i386/Makefile.objs obj-$(CONFIG_VMMOUSE) += vmmouse.o · line 20
Quoted 5 lines
hw/i386/Makefile.objs +1
-0@@ -16,4 +16,5 @@ obj-$(CONFIG_VMMOUSE) += vmmouse.o obj-$(CONFIG_PC) += port92.o obj-y += kvmvapic.o +obj-$(CONFIG_ACPI) += acpi-common.o obj-$(CONFIG_PC) += acpi-build.o
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
In reply to Gerd HoffmannQuoted 1 line · Gerd Hoffmann
Looks like the logiv was copied over from q35.
Typo 'logiv' -> 'logic'.
Quoted 3 lines
q35 does this for backward compatibility, there is no reason to do this on microvm though. So split @ 2G unconditionally.
Yes please!
Quoted 36 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/i386/microvm.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)hw/i386/microvm.c +1
-15@@ -170,23 +170,9 @@ static void microvm_memory_init(MicrovmMachineState *mms)MemoryRegion *ram_below_4g, *ram_above_4g;MemoryRegion *system_memory =get_system_memory ();FWCfgState *fw_cfg; -ram_addr_t lowmem; +ram_addr_t lowmem =0x80000000 ;/* 2G */ int i; -/* -* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory -* and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping -* also known as MMCFG). -* If it doesn't, we need to split it in chunks below and above 4G. -* In any case, try to make sure that guest addresses aligned at -* 1G boundaries get mapped to host addresses aligned at 1G boundaries. -*/ -if (machine->ram_size >=0xb0000000 ) { - lowmem =0x80000000 ; - }else { - lowmem =0xb0000000 ; - } -/* * Handle the machine opt max-ram-below-4g. It is basically doing * min(qemu limit, user limit).
Re: [PATCH v3 13/22] x86: coldplug cpus
In reply to Gerd HoffmannQuoted 23 lines · On Wed, 20 May 2020 15:19:54 +0200 Gerd Hoffmann <[email protected]> wrote:
microvm needs this, for correct madt creation
(make sure enable bit is set).Signed-off-by Gerd Hoffmann <[email protected]>--- hw/i386/x86.c | 11 +++++++++++ 1 file changed, 11 insertions(+)hw/i386/x86.c +1
-0@@ -118,6 +118,7 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms,void x86_cpu_new (X86MachineState *x86ms,int64_t apic_id,Error **errp) { +MachineClass *mc =MACHINE_GET_CLASS (x86ms);Object *cpu =NULL ;Error *local_err =NULL ;@@ -126,6 +127,16 @@ void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp)object_property_set_uint (cpu, apic_id,"apic-id" , &local_err);object_property_set_bool (cpu, true,"realized" , &local_err);
hw/i386/x86.c void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp) · line 138
Quoted 10 lines
hw/i386/x86.c +9
-0+if (!mc->has_hotpluggable_cpus) { +/* coldplug cpu */ +MachineState *ms =MACHINE (x86ms); +int i =0 ; +while (ms->possible_cpus->cpus[i].arch_id != apic_id) { + i++; + } + ms->possible_cpus->cpus[i].cpu = cpu; + }
I'm thinking about removing x86_cpu_new alogether (in favor of device_add), so I'd preffer avoid adding direct access to possible_cpus here.
that's the job of pc_cpu_plug (and possibly pc_cpu_pre_plug) in combination with static const TypeInfo pc_machine_info = {
.name = TYPE_PC_MACHINE,
...
.interfaces = (InterfaceInfo[]) {
{ TYPE_HOTPLUG_HANDLER },
{ }
},
};I'd reuse common code if possible in microvm or make microvm specific simplified version of it if it makes job easier.
Quoted 3 lines
hw/i386/x86.c +0
-0object_unref (cpu);error_propagate (errp, local_err); }
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 ===
CC aarch64-softmmu/hw/arm/integratorcp.o
CC x86_64-softmmu/hw/i386/kvm/i8254.o/tmp/qemu-test/src/hw/i386/acpi-microvm.c: In function 'build_dsdt_microvm':/tmp/qemu-test/src/hw/i386/acpi-microvm.c:109:5: error: implicit declaration of function 'fw_cfg_add_acpi_dsdt' [-Werror=implicit-function-declaration]
fw_cfg_add_acpi_dsdt(sb_scope, x86ms->fw_cfg);
^/tmp/qemu-test/src/hw/i386/acpi-microvm.c:109:5: error: nested extern declaration of 'fw_cfg_add_acpi_dsdt' [-Werror=nested-externs]
cc1: all warnings being treated as errors
make[1]: *** [hw/i386/acpi-microvm.o] Error 1
make[1]: *** Waiting for unfinished jobs....
CC aarch64-softmmu/hw/arm/mainstone.o
CC aarch64-softmmu/hw/arm/microbit.o
---
CC aarch64-softmmu/target/arm/gdbstub64.o CC aarch64-softmmu/target/arm/machine.o CC aarch64-softmmu/target/arm/arch_dump.o
make: *** [x86_64-softmmu/all] Error 2
make: *** Waiting for unfinished jobs....
CC aarch64-softmmu/target/arm/monitor.o
CC aarch64-softmmu/target/arm/arm-powerctl.o
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=5cfa0900fad74d3e96f029386896f751', '-u', '1001', '--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/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-612gx0r0/src/docker-src.2020-05-20-11.43.56.32095:/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=5cfa0900fad74d3e96f029386896f751
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-612gx0r0/src'
make: *** [docker-run-test-quick@centos7] Error 2
real 2m31.578s
user 0m8.620s
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]
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:
Message-id: [email protected]
Subject: [PATCH v3 00/22] microvm: add acpi support
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
7280d50 acpi: flip default to off for microvm 0c46cb7 acpi: add per machine type acpi default 3932159 microvm/acpi: disable virtio-mmio cmdline hack 88c8990 microvm/acpi: use seabios with acpi=on 00de58b microvm/acpi: use GSI 16-23 for virtio f442b20 microvm/acpi: add acpi_dsdt_add_virtio() for x86 50bd765 microvm/acpi: add minimal acpi support b44d3ee2 microvm: make virtio irq base runtime configurable 8473717 microvm: use 2G split unconditionally 9a8690b x86: coldplug cpus
873496e acpi: move acpi_dsdt_add_power_button() to ged 570b71e acpi: ged: add x86 device variant.
42157e1 acpi: ged: add control regs
963229e acpi: ged: rename event memory region ffcb835 acpi: fadt: add hw-reduced sleep register support 628859e acpi: madt: skip pci override on pci-less systems. d7248a7 acpi: create acpi-common.c and move madt code 33254f5 acpi: make build_madt() more generic. 447375a seabios: update binaries to master snapshot f474461 seabios: update config & build rules 583a45c seabios: update submodule to master snapshot ce0b4a0 microvm: name qboot binary qboot.bin
=== OUTPUT BEGIN ===
1/22 Checking commit ce0b4a0ec4ce (microvm: name qboot binary qboot.bin)
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/22 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/22 Checking commit 583a45cbd0ff (seabios: update submodule to master snapshot) 3/22 Checking commit f474461987ec (seabios: update config & build rules)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #45:
new file mode 100644
total: 0 errors, 1 warnings, 50 lines checked
Patch 3/22 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
4/22 Checking commit 447375a74a06 (seabios: update binaries to master snapshot) 5/22 Checking commit 33254f57d62c (acpi: make build_madt() more generic.) 6/22 Checking commit d7248a7438fe (acpi: create acpi-common.c and move madt code)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #182:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #187: FILE: hw/i386/acpi-common.c:1:
+/* Support for generating ACPI tables and passing them to Guests
WARNING: Block comments use a leading /* on a separate line #227: FILE: hw/i386/acpi-common.c:41:
+ /* ACPI spec says that LAPIC entry for non present
ERROR: spaces required around that '<<' (ctx:VxV)
#301: FILE: hw/i386/acpi-common.c:115:
+#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11))
^
ERROR: spaces required around that '<<' (ctx:VxV)
#301: FILE: hw/i386/acpi-common.c:115:
+#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11))
^
ERROR: spaces required around that '<<' (ctx:VxV)
#301: FILE: hw/i386/acpi-common.c:115:
+#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11))
^
ERROR: spaces required around that '<<' (ctx:VxV)
#301: FILE: hw/i386/acpi-common.c:115:
+#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11))
^
total: 4 errors, 3 warnings, 321 lines checked
Patch 6/22 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
7/22 Checking commit 628859e5cd4e (acpi: madt: skip pci override on pci-less systems.)
WARNING: line over 80 characters
#62: FILE: hw/i386/acpi-common.c:128:
+ intsrcovr->flags = cpu_to_le16(0xd); /* active high, level triggered */
total: 0 errors, 1 warnings, 56 lines checked
Patch 7/22 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
8/22 Checking commit ffcb8350661b (acpi: fadt: add hw-reduced sleep register support) 9/22 Checking commit 963229ef8a9a (acpi: ged: rename event memory region) 10/22 Checking commit 42157e12a08c (acpi: ged: add control regs)
11/22 Checking commit 570b71e5b8fa (acpi: ged: add x86 device variant.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #24:
new file mode 100644
total: 0 errors, 1 warnings, 51 lines checked
Patch 11/22 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
12/22 Checking commit 873496e2d411 (acpi: move acpi_dsdt_add_power_button() to ged) 13/22 Checking commit 9a8690b252cc (x86: coldplug cpus)
14/22 Checking commit 8473717fafed (microvm: use 2G split unconditionally) 15/22 Checking commit b44d3ee2c4d2 (microvm: make virtio irq base runtime configurable) 16/22 Checking commit 50bd7654bd78 (microvm/acpi: add minimal acpi support)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #34:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #39: FILE: hw/i386/acpi-microvm.c:1:
+/* Support for generating ACPI tables and passing them to Guests
WARNING: Block comments use a leading /* on a separate line #150: FILE: hw/i386/acpi-microvm.c:112:
+ table_offsets = g_array_new(false, true /* clear */,
WARNING: Block comments use a leading /* on a separate line #154: FILE: hw/i386/acpi-microvm.c:116:
+ 64 /* Ensure FACS is aligned */,
WARNING: Block comments use a leading /* on a separate line #155: FILE: hw/i386/acpi-microvm.c:117:
+ false /* high memory */);
total: 0 errors, 5 warnings, 293 lines checked
Patch 16/22 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
17/22 Checking commit f442b20044f3 (microvm/acpi: add acpi_dsdt_add_virtio() for x86) 18/22 Checking commit 00de58be2c9d (microvm/acpi: use GSI 16-23 for virtio) 19/22 Checking commit 88c8990ffa2f (microvm/acpi: use seabios with acpi=on) 20/22 Checking commit 3932159d5e0c (microvm/acpi: disable virtio-mmio cmdline hack) 21/22 Checking commit 0c46cb7b51d7 (acpi: add per machine type acpi default) 22/22 Checking commit 7280d5050ee8 (acpi: flip default to off 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 asan 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
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END ===
CC x86_64-softmmu/hw/i386/xen/xen_pvdevice.o
CC x86_64-softmmu/hw/i386/xen/xen-hvm.o
CC x86_64-softmmu/hw/i386/xen/xen-mapcache.o
/tmp/qemu-test/src/hw/i386/acpi-microvm.c:109:5: error: implicit declaration of function 'fw_cfg_add_acpi_dsdt' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
fw_cfg_add_acpi_dsdt(sb_scope, x86ms->fw_cfg);
^/tmp/qemu-test/src/hw/i386/acpi-microvm.c:109:5: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes] 2 errors generated.
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: hw/i386/acpi-microvm.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:527: x86_64-softmmu/all] Error 2
Traceback (most recent call last):
File "./tests/docker/docker.py", line 664, in <module>
sys.exit(main())
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=3620f0cf6349445fb42a098ed6ef40c8', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=x86_64-softmmu', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-lc0gao83/src/docker-src.2020-05-20-11.47.05.9825:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-debug']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=3620f0cf6349445fb42a098ed6ef40c8
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-lc0gao83/src'
make: *** [docker-run-test-debug@fedora] Error 2
real 3m56.264s
user 0m8.551s
The full log is available at
http://patchew.org/logs/[email protected]/testing.asan/?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-mingw@fedora 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
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===
CC x86_64-softmmu/target/i386/mpx_helper.o
CC x86_64-softmmu/target/i386/seg_helper.o/tmp/qemu-test/src/hw/i386/acpi-microvm.c: In function 'build_dsdt_microvm':/tmp/qemu-test/src/hw/i386/acpi-microvm.c:109:5: error: implicit declaration of function 'fw_cfg_add_acpi_dsdt'; did you mean 'fw_cfg_add_file'? [-Werror=implicit-function-declaration]
fw_cfg_add_acpi_dsdt(sb_scope, x86ms->fw_cfg);
^~~~~~~~~~~~~~~~~~~~
fw_cfg_add_file/tmp/qemu-test/src/hw/i386/acpi-microvm.c:109:5: error: nested extern declaration of 'fw_cfg_add_acpi_dsdt' [-Werror=nested-externs]
cc1: all warnings being treated as errors
CC x86_64-softmmu/target/i386/smm_helper.o
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: hw/i386/acpi-microvm.o] Error 1
make[1]: *** Waiting for unfinished jobs....
CC aarch64-softmmu/hw/arm/digic_boards.o
CC aarch64-softmmu/hw/arm/exynos4_boards.o
---
CC aarch64-softmmu/hw/arm/vexpress.o CC aarch64-softmmu/hw/arm/xilinx_zynq.o CC aarch64-softmmu/hw/arm/sabrelite.o
make: *** [Makefile:527: x86_64-softmmu/all] Error 2
make: *** Waiting for unfinished jobs....
CC aarch64-softmmu/hw/arm/armv7m.o
CC aarch64-softmmu/hw/arm/exynos4210.o
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=87e79745f2ae42ae974eb9b247d4af76', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-43fhva9t/src/docker-src.2020-05-20-11.50.45.16713:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=87e79745f2ae42ae974eb9b247d4af76
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-43fhva9t/src'
make: *** [docker-run-test-mingw@fedora] Error 2
real 3m1.622s
user 0m7.423s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Re: [PATCH v3 09/22] acpi: ged: rename event memory region
In reply to Gerd HoffmannQuoted 4 lines · On Wed, 20 May 2020 15:19:50 +0200 Gerd Hoffmann <[email protected]> wrote:
Rename memory region and callbacks and ops to carry "evt" in the name because a second region will be added shortly.
Signed-off-by Gerd Hoffmann <[email protected]>
Quoted 63 lines
--- include/hw/acpi/generic_event_device.h | 2 +- hw/acpi/generic_event_device.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-)(quoted diff) +0
-0
b/include/hw/acpi/generic_event_device.hindex83917de02425..90a9180db572100644 ---a/include/hw/acpi/generic_event_device.h+++b/include/hw/acpi/generic_event_device.h@@ -86,7 +86,7 @@
#defineACPI_GED_NVDIMM_HOTPLUG_EVT0x4typedef struct GEDState {
include/hw/acpi/generic_event_device.h +1
-1-MemoryRegion io; +MemoryRegion evt;uint32_t sel; } GEDState;(quoted diff) +0
-0
b/hw/acpi/generic_event_device.cindexb1cbdd86b66c..1cb34111e59a100644 ---a/hw/acpi/generic_event_device.c
+++b/hw/acpi/generic_event_device.chw/acpi/generic_event_device.c +8
-8@@ -142,7 +142,7 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev, }/* Memory read by the GED _EVT AML dynamic method */ -static uint64_t ged_read (void *opaque,hwaddr addr,unsigned size) +static uint64_t ged_evt_read (void *opaque,hwaddr addr,unsigned size) {uint64_t val =0 ;GEDState *ged_st = opaque;@@ -161,14 +161,14 @@ static uint64_t ged_read(void *opaque, hwaddr addr, unsigned size) }/* Nothing is expected to be written to the GED memory region */ -static void ged_write (void *opaque,hwaddr addr,uint64_t data, -unsigned int size) +static void ged_evt_write (void *opaque,hwaddr addr,uint64_t data, +unsigned int size) { } -static const MemoryRegionOps ged_ops = { - .read = ged_read, - .write = ged_write, +static const MemoryRegionOps ged_evt_ops = { + .read = ged_evt_read, + .write = ged_evt_write, .endianness =DEVICE_LITTLE_ENDIAN , .valid = { .min_access_size =4 ,@@ -287,9 +287,9 @@ static void acpi_ged_initfn(Object *obj)SysBusDevice *sbd =SYS_BUS_DEVICE (obj);GEDState *ged_st = &s->ged_state; -memory_region_init_io (&ged_st->io, obj, &ged_ops, ged_st, +memory_region_init_io (&ged_st->evt, obj, &ged_evt_ops, ged_st,TYPE_ACPI_GED ,ACPI_GED_EVT_SEL_LEN ); -sysbus_init_mmio (sbd, &ged_st->io); +sysbus_init_mmio (sbd, &ged_st->evt);sysbus_init_irq (sbd, &s->irq);
Re: [PATCH v3 10/22] acpi: ged: add control regs
In reply to Gerd HoffmannQuoted 3 lines · On Wed, 20 May 2020 15:19:51 +0200 Gerd Hoffmann <[email protected]> wrote:
Add control regs (sleep, reset) for hw-reduced acpi.
Signed-off-by Gerd Hoffmann <[email protected]>
this should be acompanied by docs update
docs/specs/acpi_hw_reduced_hotplug.rst
to document new registers and their semantics and probaly rename file to something more appropriate
Quoted 99 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 +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@@ -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, +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 ) { +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) {@@ -305,6 +345,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)
Re: [PATCH v3 11/22] acpi: ged: add x86 device variant.
In reply to Gerd HoffmannQuoted 4 lines · On Wed, 20 May 2020 15:19:52 +0200 Gerd Hoffmann <[email protected]> wrote:
Set
AcpiDeviceIfClass->madt_cpu,
otherwise identical toTYPE_ACPI_GED.Signed-off-by Gerd Hoffmann <[email protected]>
Quoted 74 lines
--- 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.cinclude/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 0x4hw/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
Re: [PATCH v3 12/22] acpi: move acpi_dsdt_add_power_button() to ged
In reply to Gerd HoffmannQuoted 3 lines · On Wed, 20 May 2020 15:19:53 +0200 Gerd Hoffmann <[email protected]> wrote:
Allow reuse for microvm.
Signed-off-by Gerd Hoffmann <[email protected]>
Quoted 55 lines
--- 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@@ -354,14 +354,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 build_iort (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) {
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
In reply to Gerd HoffmannQuoted 6 lines · On Wed, 20 May 2020 15:19:55 +0200 Gerd Hoffmann <[email protected]> wrote:
Looks like the logiv was copied over from q35.
q35 does this for backward compatibility, there is no reason to do this on microvm though. So split @ 2G unconditionally.
Signed-off-by Gerd Hoffmann <[email protected]>
Quoted 33 lines
--- hw/i386/microvm.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)hw/i386/microvm.c +1
-15@@ -170,23 +170,9 @@ static void microvm_memory_init(MicrovmMachineState *mms)MemoryRegion *ram_below_4g, *ram_above_4g;MemoryRegion *system_memory =get_system_memory ();FWCfgState *fw_cfg; -ram_addr_t lowmem; +ram_addr_t lowmem =0x80000000 ;/* 2G */ int i; -/* -* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory -* and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping -* also known as MMCFG). -* If it doesn't, we need to split it in chunks below and above 4G. -* In any case, try to make sure that guest addresses aligned at -* 1G boundaries get mapped to host addresses aligned at 1G boundaries. -*/ -if (machine->ram_size >=0xb0000000 ) { - lowmem =0x80000000 ; - }else { - lowmem =0xb0000000 ; - } -/* * Handle the machine opt max-ram-below-4g. It is basically doing * min(qemu limit, user limit).
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
In reply to Gerd HoffmannQuoted 4 lines · On Wed, 20 May 2020 15:19:55 +0200 Gerd Hoffmann <[email protected]> wrote:
Looks like the logiv was copied over from q35.
q35 does this for backward compatibility, there is no reason to do this on microvm though. So split @ 2G unconditionally.
not related to your ACPI rework, but just an idea for future of microvm
I wonder if we should carry over all this fixed RAM layout legacy from pc/q35 with a bunch of knobs to tweak it (along with complicated logic).
Can we just re-use pc-dimms for main RAM and let user specify RAM layout the way they wish?
Quoted 34 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/i386/microvm.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)hw/i386/microvm.c +1
-15@@ -170,23 +170,9 @@ static void microvm_memory_init(MicrovmMachineState *mms)MemoryRegion *ram_below_4g, *ram_above_4g;MemoryRegion *system_memory =get_system_memory ();FWCfgState *fw_cfg; -ram_addr_t lowmem; +ram_addr_t lowmem =0x80000000 ;/* 2G */ int i; -/* -* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory -* and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping -* also known as MMCFG). -* If it doesn't, we need to split it in chunks below and above 4G. -* In any case, try to make sure that guest addresses aligned at -* 1G boundaries get mapped to host addresses aligned at 1G boundaries. -*/ -if (machine->ram_size >=0xb0000000 ) { - lowmem =0x80000000 ; - }else { - lowmem =0xb0000000 ; - } -/* * Handle the machine opt max-ram-below-4g. It is basically doing * min(qemu limit, user limit).
Re: [PATCH v3 16/22] microvm/acpi: add minimal acpi support
In reply to Gerd HoffmannQuoted 1 line · On Wed, 20 May 2020 15:19:57 +0200 Gerd Hoffmann <[email protected]> wrote:
$subject says all. Can be controlled using -M microvm,acpi=on/off.
thanks for really nice and clean impl. There are a couple minor notes below, but otherwise
Quoted 64 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/i386/acpi-microvm.h | 6 ++ include/hw/i386/microvm.h | 9 ++ hw/i386/acpi-microvm.c | 182 ++++++++++++++++++++++++++++++++++++++ hw/i386/microvm.c | 37 ++++++++ hw/i386/Kconfig | 1 + hw/i386/Makefile.objs | 1 + 6 files changed, 236 insertions(+) create mode 100644 hw/i386/acpi-microvm.h create mode 100644 hw/i386/acpi-microvm.chw/i386/acpi-microvm.h new file +6
-0@@ -0,0 +1,6 @@ +#ifndef HW_I386_ACPI_MICROVM_H +#define HW_I386_ACPI_MICROVM_H + +void acpi_setup_microvm (void ); + +#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 0xc0000000#define VIRTIO_NUM_TRANSPORTS 8#define VIRTIO_CMDLINE_MAXLEN 64 +#define GED_MMIO_BASE 0xc1000000 +#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 +0
-0
hw/i386/acpi-microvm.c line 7
Quoted 7 lines
hw/i386/acpi-microvm.c new file +7
-0@@ -0,0 +1,182 @@ +/* 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]>
since you wrote it s/^^^/Gerd/
Quoted 201 lines
hw/i386/acpi-microvm.c new file +175
-0+* +* 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" ); +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 */ +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,5 ,NULL ,NULL ); +free_aml_allocator (); +} + +static void acpi_build_microvm (AcpiBuildTables *tables, +MicrovmMachineState *mms) +{ +MachineState *machine =MACHINE (mms); +GArray *table_offsets; +GArray *tables_blob = tables->table_data; +unsigned dsdt, xsdt; +AcpiFadtData pmfadt = { + .rev =5 , + .minor_ver =1 , + .flags = ((1 <<ACPI_FADT_F_HW_REDUCED_ACPI ) | + (1 <<ACPI_FADT_F_RESET_REG_SUP )), + .sleep_ctl = { + .space_id =AML_AS_SYSTEM_MEMORY , + .bit_width =8 , + .address =GED_MMIO_BASE_REGS +ACPI_GED_REG_SLEEP_CTL , + }, + .sleep_sts = { + .space_id =AML_AS_SYSTEM_MEMORY , + .bit_width =8 , + .address =GED_MMIO_BASE_REGS +ACPI_GED_REG_SLEEP_STS , + }, + .reset_reg = { + .space_id =AML_AS_SYSTEM_MEMORY , + .bit_width =8 , + .address =GED_MMIO_BASE_REGS +ACPI_GED_REG_RESET , + }, + .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); +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 = { + .revision =2 , + .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 (void ) +{ +MicrovmMachineState *mms =MICROVM_MACHINE (qdev_get_machine ()); +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 +4
-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 */
hw/i386/microvm.c static void microvm_devices_init(MicrovmMachineState *mms) · line 145
Quoted 10 lines
hw/i386/microvm.c +10
-0+if (x86_machine_is_acpi_enabled (x86ms)) { +DeviceState *dev =qdev_create (NULL ,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 ]); +qdev_init_nofail (dev); + mms->acpi_dev =ACPI_DEVICE_IF (dev);
considering all x86 machines have it, maybe move acpi_dev field to parent type?
hw/i386/microvm.c static void microvm_machine_set_auto_kernel_cmdline(Object *obj, bool value, · line 477
Quoted 11 lines
hw/i386/microvm.c +4
-0+ }if (mms->pic ==ON_OFF_AUTO_ON || mms->pic ==ON_OFF_AUTO_AUTO ) {qemu_irq *i8259;@@ -457,6 +472,23 @@ 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) +{ +acpi_setup_microvm ();
pass MicrovmMachineState down to acpi_setup_microvm() the same way you are doing below? (and avoid qdev_get_machine() in acpi_setup_microvm())
Quoted 50 lines
hw/i386/microvm.c +19
-0+} + +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);@@ -471,6 +503,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.o
Re: [PATCH v3 17/22] microvm/acpi: add acpi_dsdt_add_virtio() for x86
In reply to Gerd HoffmannQuoted 4 lines · On Wed, 20 May 2020 15:19:58 +0200 Gerd Hoffmann <[email protected]> wrote:
Makes x86 linux kernel find virtio-mmio devices automatically.
Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Sergio Lopez <[email protected]>
Quoted 85 lines
--- 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 ("\\" );
Re: [PATCH v3 18/22] microvm/acpi: use GSI 16-23 for virtio
In reply to Gerd HoffmannQuoted 7 lines · On Wed, 20 May 2020 15:19:59 +0200 Gerd Hoffmann <[email protected]> wrote:
With ACPI enabled and IO-APIC being properly declared in the ACPI tables we can use interrupt lines 16-23 for virtio and avoid shared interrupts.
With acpi disabled we continue to use lines 8-15.
Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Sergio Lopez <[email protected]>
Quoted 17 lines
--- 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 =8 ; + mms->virtio_irq_base =x86_machine_is_acpi_enabled (x86ms) ?16 :8 ;for (i =0 ; i <VIRTIO_NUM_TRANSPORTS ; i++) { sysbus_create_simple("virtio-mmio", VIRTIO_MMIO_BASE + i * 512,
Re: [PATCH v3 19/22] microvm/acpi: use seabios with acpi=on
In reply to Gerd HoffmannQuoted 3 lines · On Wed, 20 May 2020 15:20:00 +0200 Gerd Hoffmann <[email protected]> wrote:
With acpi=off continue to use qboot.
Signed-off-by Gerd Hoffmann <[email protected]>
Quoted 27 lines
--- 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.bin" +#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); }
Re: [PATCH v3 21/22] [RfC] acpi: add per machine type acpi default
In reply to Gerd HoffmannQuoted 37 lines · On Wed, 20 May 2020 15:20:02 +0200 Gerd Hoffmann <[email protected]> wrote:
Allow setting acpi default value for each machine type.
Signed-off-by Gerd Hoffmann <[email protected]>--- include/hw/i386/x86.h | 1 + hw/i386/x86.c | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-)include/hw/i386/x86.h +1
-0@@ -37,6 +37,7 @@ typedef struct {bool save_tsc_khz;/* Enables contiguous-apic-ID mode */ bool compat_apic_id_mode; +bool acpi_default; } X86MachineClass; typedef struct {hw/i386/x86.c +7
-2@@ -940,10 +940,22 @@ static void x86_machine_set_smm(Object *obj, Visitor *v, const char *name,bool x86_machine_is_acpi_enabled (X86MachineState *x86ms) { -if (x86ms->acpi ==ON_OFF_AUTO_OFF ) { -return false; +X86MachineClass *x86mc =X86_MACHINE_GET_CLASS (x86ms); +bool enabled; + +switch (x86ms->acpi) { +case ON_OFF_AUTO_ON : + enabled = true; +break ;
hw/i386/x86.c static void x86_machine_set_smm(Object *obj, Visitor *v, const char *name, · line 958
Quoted 10 lines
hw/i386/x86.c +8
-1+case ON_OFF_AUTO_OFF : + enabled = false; +break ; +case ON_OFF_AUTO_AUTO : +default : + enabled = x86mc->acpi_default; +break ; } -return true; +return enabled;
why not make x86ms->acpi a boolean and move logic from here to x86_machine_[get|set]_acpi() to avoid extra helper, the external users would use property acessesors and internal (microvm code) can just access x86ms->acpi directly
Quoted 13 lines
hw/i386/x86.c +3
-0} static void x86_machine_get_acpi(Object *obj, Visitor *v, const char *name,@@ -991,6 +1003,9 @@ static void x86_machine_class_init(ObjectClass *oc, void *data) x86mc->save_tsc_khz = true; nc->nmi_monitor_handler = x86_nmi; +/* acpi is on by default */ + x86mc->acpi_default = true; +object_class_property_add (oc,X86_MACHINE_MAX_RAM_BELOW_4G ,"size" , x86_machine_get_max_ram_below_4g, x86_machine_set_max_ram_below_4g,NULL ,NULL );
Re: [PATCH v3 22/22] [RfC] acpi: flip default to off for microvm
In reply to Gerd HoffmannQuoted 18 lines · On Wed, 20 May 2020 15:20:03 +0200 Gerd Hoffmann <[email protected]> wrote:
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/i386/microvm.c | 4 ++++ 1 file changed, 4 insertions(+)hw/i386/microvm.c +1
-0@@ -517,6 +517,7 @@ static void microvm_machine_initfn(Object *obj)static void microvm_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +X86MachineClass *x86mc =X86_MACHINE_CLASS (oc); mc->init = microvm_machine_state_init;
hw/i386/microvm.c static void microvm_class_init(ObjectClass *oc, void *data) · line 542
Quoted 5 lines
hw/i386/microvm.c +2
-0@@ -537,6 +538,9 @@ static void microvm_class_init(ObjectClass *oc, void *data)/* Machine class handlers */ mc->reset = microvm_machine_reset; +/* acpi is off by default */ + x86mc->acpi_default = false;
Since we don't care about compat stuff for microvm yet,
I'd preffer default 'on', as in long run it allows to boot larger range of guests without need for tuning QEMU and guest configuration
(i.e. it's the least troublesome case for ordinary user)
Quoted 4 lines
hw/i386/microvm.c +1
-0+ object_class_property_add(oc, MICROVM_MACHINE_PIC, "OnOffAuto", microvm_machine_get_pic, microvm_machine_set_pic,
Re: [PATCH v3 01/22] microvm: name qboot binary qboot.bin
In reply to Philippe Mathieu-DaudéQuoted 6 lines · Philippe Mathieu-Daudé
Hi Gerd,
Quoted 1 line · Gerd Hoffmann
qboot isn't a bios and shouldnt be named that way.
Still it resides in a directory named pc-bios =)
Yep, that should be named "firmware" but changing that is beyond the scope of this patch ;)
Quoted 15 lines
It is used later in
x86_bios_rom_init()as:bios = g_malloc(sizeof(*bios)); memory_region_init_ram(bios, NULL, "pc.bios", bios_size, &error_fatal); if (!isapc_ram_fw) { memory_region_set_readonly(bios, true); } ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1); if (ret != 0) { bios_error: fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name); exit(1); } g_free(filename);
Quoted 3 lines
Many 'bios' occurrences.
Should it be called 'qboot.rom' instead?
I don't care much, I only want bios*.bin for seabios which actually is a complete bios implementation ...
take care,
Gerd
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
In reply to Igor MammedovQuoted 5 lines · Igor Mammedov
Quoted 2 lines · On Wed, 20 May 2020 15:19:55 +0200 Gerd Hoffmann <[email protected]> wrote:
Looks like the logiv was copied over from q35.
Quoted 7 lines
Quoted 2 lines
q35 does this for backward compatibility, there is no reason to do this on microvm though. So split @ 2G unconditionally.
not related to your ACPI rework, but just an idea for future of microvm
I wonder if we should carry over all this fixed RAM layout legacy from pc/q35 with a bunch of knobs to tweak it (along with complicated logic).
Well, I think we can (should) drop max-ram-below-4g too. There is no reason to use that with microvm, other that shooting yourself into the foot (by making mmio overlap with ram).
With that being gone too there isn't much logic left ...
take care,
Gerd
Re: [PATCH v3 15/22] microvm: make virtio irq base runtime configurable
In reply to Philippe Mathieu-DaudéHi,
Quoted 6 lines
include/hw/i386/microvm.h
Quoted 3 lines
include/hw/i386/microvm.h +1
-1-#define VIRTIO_IRQ_BASE 5 + mms->virtio_irq_base =8 ;Hmm you made it runtime configurable indeed, but you also changed it from 5 to 8. Worth a different patch, or at least mentioning in commit description.
Oops, that wasn't intentional. I'll change it back to 5.
take care,
Gerd
Re: [PATCH v3 22/22] [RfC] acpi: flip default to off for microvm
In reply to Igor MammedovQuoted 24 lines · Igor Mammedov
Quoted 21 lines · On Wed, 20 May 2020 15:20:03 +0200 Gerd Hoffmann <[email protected]> wrote:
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/i386/microvm.c | 4 ++++ 1 file changed, 4 insertions(+)hw/i386/microvm.c +1
-0@@ -517,6 +517,7 @@ static void microvm_machine_initfn(Object *obj)static void microvm_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +X86MachineClass *x86mc =X86_MACHINE_CLASS (oc); mc->init = microvm_machine_state_init;@@ -537,6 +538,9 @@ static void microvm_class_init(ObjectClass *oc, void *data)/* Machine class handlers */ mc->reset = microvm_machine_reset;
Quoted 7 lines
hw/i386/microvm.c static void microvm_class_init(ObjectClass *oc, void *data) · line 542
Quoted 2 lines
hw/i386/microvm.c +2
-0+/* acpi is off by default */ + x86mc->acpi_default = false;Since we don't care about compat stuff for microvm yet,
I'd preffer default 'on', as in long run it allows to boot larger range of guests without need for tuning QEMU and guest configuration
(i.e. it's the least troublesome case for ordinary user)
I fully agree and I'll happily drop patches 21+22 and have microvm default to acpi=on. See also:
https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg01315.html
Older patch versions got multiple review comments asking for acpi=off by default, so I've added these two patches as RfC to show how this could be done. RfC because (1) the topic is controversial and (2) these are not final. I'd move 21/22 up in the series and squash 22/22 into the "add acpi to microvm" patch in case we decide for acpi=off as default.
take care,
Gerd
Philippe Mathieu-Daudé
Reviewed-byRe: [PATCH v3 01/22] microvm: name qboot binary qboot.bin
In reply to Gerd HoffmannQuoted 26 lines · Gerd Hoffmann
Quoted 6 lines · Philippe Mathieu-Daudé
Hi Gerd,
Quoted 1 line · Gerd Hoffmann
qboot isn't a bios and shouldnt be named that way.
Still it resides in a directory named pc-bios =)
Yep, that should be named "firmware" but changing that is beyond the scope of this patch ;)
Quoted 15 lines
It is used later in
x86_bios_rom_init()as:bios = g_malloc(sizeof(*bios)); memory_region_init_ram(bios, NULL, "pc.bios", bios_size, &error_fatal); if (!isapc_ram_fw) { memory_region_set_readonly(bios, true); } ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1); if (ret != 0) { bios_error: fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name); exit(1); } g_free(filename);
Quoted 6 lines
Quoted 3 lines
Many 'bios' occurrences.
Should it be called 'qboot.rom' instead?
I don't care much, I only want bios*.bin for seabios which actually is a complete bios implementation ...
OK.
Preferably named 'qboot.rom':
Philippe Mathieu-Daudé
Reviewed-byRe: [PATCH v3 15/22] microvm: make virtio irq base runtime configurable
In reply to Gerd HoffmannQuoted 10 lines · Gerd Hoffmann
Hi,
Quoted 6 lines
include/hw/i386/microvm.h
Quoted 3 lines
include/hw/i386/microvm.h +1
-1-#define VIRTIO_IRQ_BASE 5 + mms->virtio_irq_base =8 ;Hmm you made it runtime configurable indeed, but you also changed it from 5 to 8. Worth a different patch, or at least mentioning in commit description.
Oops, that wasn't intentional. I'll change it back to 5.
OK. Using 5:
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
In reply to Gerd HoffmannQuoted 11 lines · On Mon, 25 May 2020 13:45:08 +0200 Gerd Hoffmann <[email protected]> wrote:
Quoted 10 lines · Igor Mammedov
Quoted 4 lines · On Wed, 20 May 2020 15:19:55 +0200 Gerd Hoffmann <[email protected]> wrote:
Looks like the logiv was copied over from q35.
q35 does this for backward compatibility, there is no reason to do this on microvm though. So split @ 2G unconditionally.
not related to your ACPI rework, but just an idea for future of microvm
Quoted 8 lines
Quoted 2 lines
I wonder if we should carry over all this fixed RAM layout legacy from pc/q35 with a bunch of knobs to tweak it (along with complicated logic).
Well, I think we can (should) drop max-ram-below-4g too. There is no reason to use that with microvm, other that shooting yourself into the foot (by making mmio overlap with ram).
With that being gone too there isn't much logic left ...
I wonder if we need 2G split for microvm at all?
Can we map 1 contiguous big blob from 0 GPA and overlay bios & other x86 TOLUD stuff?
Quoted 3 lines
take care,
Gerd
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
Quoted 8 lines
Quoted 5 lines
Well, I think we can (should) drop max-ram-below-4g too. There is no reason to use that with microvm, other that shooting yourself into the foot (by making mmio overlap with ram).
With that being gone too there isn't much logic left ...
I wonder if we need 2G split for microvm at all?
Can we map 1 contiguous big blob from 0 GPA and overlay bios & other x86 TOLUD stuff?
I think it would work, but it has some drawbacks:
(1) we loose a bit of memory.
(2) we loose a gigabyte page.
(3) we wouldn't have guard pages (unused address space) between between ram and mmio space.
take care,
Gerd
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
Quoted 4 lines · On Tue, 26 May 2020 06:48:39 +0200 Gerd Hoffmann <[email protected]> wrote:
Quoted 4 lines
Quoted 4 lines
Well, I think we can (should) drop max-ram-below-4g too. There is no reason to use that with microvm, other that shooting yourself into the foot (by making mmio overlap with ram).
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
With that being gone too there isn't much logic left ...
I wonder if we need 2G split for microvm at all?
Can we map 1 contiguous big blob from 0 GPA and overlay bios & other x86 TOLUD stuff?I think it would work, but it has some drawbacks:
(1) we loose a bit of memory.
it's probably not a big enough to care about, we do similar ovarlay mapping on pc/q35 at the beginning of RAM
Quoted 1 line
(2) we loose a gigabyte page.
I'm not sure waht exactly we loose in this case.
Lets assume we allocating guest 5G of continuous RAM using 1G huge pages, in this case I'd think that on host side MMIO overlay won't affect RAM blob on guest side pagetables will be fragmented due to MMIO holes, but guest still could use huge pages smaller ones in fragmented area and 1G where there is no fragmentation.
Quoted 2 lines
(3) we wouldn't have guard pages (unused address space) between between ram and mmio space.
if it's holes' mmio,then do we really need them (access is going to be terminated either in always valid RAM or in valid mmio hole)?
Quoted 5 lines
take care,
Gerd
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
Quoted 6 lines · Igor Mammedov
Quoted 1 line
(2) we loose a gigabyte page.
I'm not sure waht exactly we loose in this case.
Lets assume we allocating guest 5G of continuous RAM using 1G huge pages, in this case I'd think that on host side MMIO overlay won't affect RAM blob on guest side pagetables will be fragmented due to MMIO holes, but guest still could use huge pages smaller ones in fragmented area and 1G where there is no fragmentation.
Access to the 3G-4G area would not be able to use 1G EPT pages.
But why use 2G split instead of 3G? There's only very little MMIO and no PCI hole (including no huge MMCONFIG BAR) on microvm.
Paolo
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
Quoted 9 lines · On Wed, 27 May 2020 15:06:28 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 6 lines · Igor Mammedov
Quoted 1 line
(2) we loose a gigabyte page.
I'm not sure waht exactly we loose in this case.
Lets assume we allocating guest 5G of continuous RAM using 1G huge pages, in this case I'd think that on host side MMIO overlay won't affect RAM blob on guest side pagetables will be fragmented due to MMIO holes, but guest still could use huge pages smaller ones in fragmented area and 1G where there is no fragmentation.Access to the 3G-4G area would not be able to use 1G EPT pages.
Could it use 2Mb pages instead of 1Gb?
Do we really care about 1 gigabyte huge page in microvm intended usecase?
(fast starting VMs for microservices like FaaS, which unlikely would use much memory to begin with)
Quoted 5 lines
But why use 2G split instead of 3G? There's only very little MMIO and no PCI hole (including no huge MMCONFIG BAR) on microvm.
Paolo
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
Quoted 11 lines · On Wed, 27 May 2020 16:26:46 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 8 lines · On Wed, 27 May 2020 15:06:28 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 6 lines · Igor Mammedov
Quoted 1 line
(2) we loose a gigabyte page.
I'm not sure waht exactly we loose in this case.
Lets assume we allocating guest 5G of continuous RAM using 1G huge pages, in this case I'd think that on host side MMIO overlay won't affect RAM blob on guest side pagetables will be fragmented due to MMIO holes, but guest still could use huge pages smaller ones in fragmented area and 1G where there is no fragmentation.
Quoted 4 lines
Quoted 1 line
Access to the 3G-4G area would not be able to use 1G EPT pages.
Could it use 2Mb pages instead of 1Gb?
Do we really care about 1 gigabyte huge page in microvm intended usecase?
(fast starting VMs for microservices like FaaS, which unlikely would use much memory to begin with)
my interest in having single memory region, is in possibility of drop in conversion to [nv|pc-dimm] later on without breaking ABI. (I'm not sure that we actually need it though)
Quoted 7 lines
Quoted 5 lines
But why use 2G split instead of 3G? There's only very little MMIO and no PCI hole (including no huge MMCONFIG BAR) on microvm.
Paolo
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
In reply to Igor MammedovQuoted 5 lines · Igor Mammedov
Quoted 2 lines · On Wed, 27 May 2020 15:06:28 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 1 line · Igor Mammedov
Quoted 1 line
(2) we loose a gigabyte page.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
I'm not sure waht exactly we loose in this case.
Lets assume we allocating guest 5G of continuous RAM using 1G huge pages, in this case I'd think that on host side MMIO overlay won't affect RAM blob on guest side pagetables will be fragmented due to MMIO holes, but guest still could use huge pages smaller ones in fragmented area and 1G where there is no fragmentation.Access to the 3G-4G area would not be able to use 1G EPT pages.
Could it use 2Mb pages instead of 1Gb?
Yes, probably a mix of 2 MiB pages and 4 KiB pages around the memslot splits.
Quoted 2 lines
Do we really care about 1 gigabyte huge page in microvm intended usecase?
(fast starting VMs for microservices like FaaS, which unlikely would use much memory to begin with)
I honestly don't think it's measurable, but at least in theory we care because such workloads could have more TLB misses (relative to the execution time) than long-lasting VMs.
Paolo
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
In reply to Igor MammedovHi,
Quoted 3 lines
Quoted 1 line
(1) we loose a bit of memory.
it's probably not a big enough to care about, we do similar ovarlay mapping on pc/q35 at the beginning of RAM
Yes, shouldn't be too much.
Quoted 2 lines
Quoted 1 line
(2) we loose a gigabyte page.
I'm not sure waht exactly we loose in this case.
The 1G page for 0xc0000000 -> 0xffffffff (as explained by paolo).
Quoted 4 lines
Quoted 2 lines
(3) we wouldn't have guard pages (unused address space) between between ram and mmio space.
if it's holes' mmio,then do we really need them (access is going to be terminated either in always valid RAM or in valid mmio hole)?
Not required, but more robust. Less likely that the guest touches mmio by accident.
I'd expect it also requires some e820 hacks.
cheers,
Gerd
Re: [PATCH v3 14/22] microvm: use 2G split unconditionally
In reply to Paolo BonziniHi,
Quoted 2 lines
But why use 2G split instead of 3G? There's only very little MMIO and no PCI hole (including no huge MMCONFIG BAR) on microvm.
Yes, we can go for 3G, we are indeed not short on address space ;)
take care,
Gerd