x86: allow building without PC machine types
v2 cover x86: allow building without PC machine types
In fact I went one step further and ensured that microvm could build without pc.h even. :)
Paolo
v1->v2: more thorough cleansing of pc.h (new patches 3/7/8) [Sergio]
move SMM property to X86MachineState (patch 5) [Sergio]
Paolo Bonzini (8):
i386: conditionally compile more files
fw_cfg: allow building without other devices
hw: replace hw/i386/pc.h with a header just for the i8259
pci-stub: add more MSI functions
x86: move SMM property to X86MachineState
x86: move more x86-generic functions out of PC files
acpi: move PC stubs out of stubs/
pc: stubify x86 iommu
hw/acpi/Makefile.objs | 2 +- .../pc_madt_cpu_entry.c => hw/acpi/acpi-x86-stub.c | 0 hw/alpha/alpha_sys.h | 3 +- hw/alpha/dp264.c | 1 + hw/hppa/hppa_sys.h | 3 +- hw/hppa/machine.c | 1 + hw/i386/Kconfig | 6 + hw/i386/Makefile.objs | 9 +- hw/i386/acpi-build.c | 1 + hw/i386/fw_cfg.c | 8 +- hw/i386/fw_cfg.h | 2 + hw/i386/kvm/Makefile.objs | 6 +- hw/i386/kvm/i8259.c | 1 + hw/i386/kvm/ioapic.c | 2 +- hw/i386/microvm.c | 4 +- hw/i386/pc.c | 153 +-------------------- hw/i386/pc_piix.c | 6 +- hw/i386/pc_q35.c | 2 +- hw/i386/x86-iommu-stub.c | 34 +++++ hw/i386/x86-iommu.c | 1 - hw/i386/x86.c | 151 +++++++++++++++++++- hw/input/pckbd.c | 1 - hw/intc/Kconfig | 2 + hw/intc/apic.c | 2 +- hw/intc/i8259.c | 2 +- hw/intc/i8259_common.c | 2 +- hw/intc/ioapic.c | 3 +- hw/isa/i82378.c | 2 +- hw/isa/lpc_ich9.c | 1 - hw/isa/piix4.c | 2 +- hw/mips/gt64xxx_pci.c | 2 +- hw/mips/mips_fulong2e.c | 2 +- hw/mips/mips_jazz.c | 2 +- hw/mips/mips_r4k.c | 2 +- hw/pci-host/bonito.c | 1 - hw/pci-host/prep.c | 2 +- hw/pci/pci-stub.c | 27 ++++ include/hw/i386/pc.h | 31 ----- include/hw/i386/x86.h | 23 ++++ include/hw/intc/i8259.h | 12 ++ include/hw/isa/i8259_internal.h | 2 +- stubs/Makefile.objs | 1 - target/i386/kvm.c | 5 +- target/i386/machine.c | 2 +- target/i386/monitor.c | 1 - 45 files changed, 307 insertions(+), 221 deletions(-) rename stubs/pc_madt_cpu_entry.c => hw/acpi/acpi-x86-stub.c (100%) create mode 100644 hw/i386/x86-iommu-stub.c create mode 100644 include/hw/intc/i8259.h
Signature · 1 line
1.8.3.1
PATCH v2 1/8 i386: conditionally compile more files
--- hw/i386/Makefile.objs | 6 +++--- hw/i386/kvm/Makefile.objs | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-)
hw/i386/Makefile.objs +3 -3
@@ -1,11 +1,11 @@ obj-$(CONFIG_KVM) += kvm/ obj-y += e820_memory_layout.o multiboot.o obj-y += x86.o -obj-y += pc.o +obj-$(CONFIG_PC) += pc.o pc_sysfw.o obj-$(CONFIG_I440FX) += pc_piix.o obj-$(CONFIG_Q35) += pc_q35.o obj-$(CONFIG_MICROVM) += microvm.o -obj-y += fw_cfg.o pc_sysfw.o +obj-y += fw_cfg.o obj-y += x86-iommu.o obj-$(CONFIG_VTD) += intel_iommu.o obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o
@@ -14,4 +14,4 @@ obj-$(CONFIG_VMPORT) += vmport.o obj-$(CONFIG_VMMOUSE) += vmmouse.o obj-y += kvmvapic.o -obj-y += acpi-build.o +obj-$(CONFIG_PC) += acpi-build.o
hw/i386/kvm/Makefile.objs +5 -1
@@ -1 +1,5 @@ -obj-y += clock.o apic.o i8259.o ioapic.o i8254.o +obj-y += clock.o +obj-$(CONFIG_APIC) += apic.o +obj-$(CONFIG_IOAPIC) += ioapic.o +obj-$(CONFIG_I8254) += i8254.o +obj-$(CONFIG_I8259) += i8259.o
Signature · 1 line
1.8.3.1
PATCH v2 2/8 fw_cfg: allow building without other devices
In reply to Paolo BonziniThe microvm machine type uses fw_cfg but lacks SMBIOS and ACPI. Do not include the files if the symbol is not present in QEMU and remove dependencies on machine-specific files.
--- hw/i386/fw_cfg.c | 7 +++++++ hw/i386/pc.c | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-)
hw/i386/fw_cfg.c +7 -0
@@ -22,6 +22,9 @@#include "hw/nvram/fw_cfg.h" #include "e820_memory_layout.h" #include "kvm_i386.h" +#include "config-devices.h" + +struct hpet_fw_config hpet_cfg = {.count =UINT8_MAX };const char *fw_cfg_arch_key_name (uint16_t key) {
@@ -46,6 +49,7 @@ const char *fw_cfg_arch_key_name(uint16_t key)void fw_cfg_build_smbios (MachineState *ms,FWCfgState *fw_cfg) { +#ifdef CONFIG_SMBIOS uint8_t *smbios_tables, *smbios_anchor;size_t smbios_tables_len, smbios_anchor_len;struct smbios_phys_mem_area *mem_array;
@@ -83,6 +87,7 @@ void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg)fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , smbios_anchor, smbios_anchor_len); } +#endif } FWCfgState *fw_cfg_arch_create(MachineState *ms,
@@ -114,8 +119,10 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms,*/ fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , apic_id_limit);fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )ram_size); +#ifdef CONFIG_ACPI fw_cfg_add_bytes (fw_cfg,FW_CFG_ACPI_TABLES , acpi_tables, acpi_tables_len); +#endif fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE,
hw/i386/pc.c +0 -2
@@ -101,8 +101,6 @@#define DPRINTF (fmt, ...)#endif -struct hpet_fw_config hpet_cfg = {.count =UINT8_MAX }; -GlobalProperty pc_compat_4_1[] = {};const size_t pc_compat_4_1_len =G_N_ELEMENTS (pc_compat_4_1);
Signature · 1 line
1.8.3.1
PATCH v2 3/8 hw: replace hw/i386/pc.h with a header just for the i8259
In reply to Paolo BonziniRemove the need to include i386/pc.h to get to the i8259 functions. This is enough to remove the inclusion of hw/i386/pc.h from all non-x86 files.
--- hw/alpha/alpha_sys.h | 3 ++- hw/alpha/dp264.c | 1 + hw/hppa/hppa_sys.h | 3 ++- hw/hppa/machine.c | 1 + hw/i386/kvm/i8259.c | 1 + hw/i386/microvm.c | 1 + hw/i386/pc.c | 1 + hw/i386/x86.c | 1 + hw/input/pckbd.c | 1 - hw/intc/Kconfig | 2 ++ hw/intc/apic.c | 2 +- hw/intc/i8259.c | 2 +- hw/intc/i8259_common.c | 2 +- hw/intc/ioapic.c | 3 ++- hw/isa/i82378.c | 2 +- hw/isa/lpc_ich9.c | 1 - hw/isa/piix4.c | 2 +- hw/mips/gt64xxx_pci.c | 2 +- hw/mips/mips_fulong2e.c | 2 +- hw/mips/mips_jazz.c | 2 +- hw/mips/mips_r4k.c | 2 +- hw/pci-host/bonito.c | 1 - hw/pci-host/prep.c | 2 +- include/hw/i386/pc.h | 8 -------- include/hw/intc/i8259.h | 12 ++++++++++++ include/hw/isa/i8259_internal.h | 2 +- target/i386/monitor.c | 1 - 27 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 include/hw/intc/i8259.h
hw/alpha/alpha_sys.h +2 -1
@@ -7,7 +7,8 @@#include "hw/pci/pci.h" #include "hw/pci/pci_host.h" #include "hw/ide.h" -#include "hw/i386/pc.h" +#include "hw/boards.h" +#include "hw/intc/i8259.h" PCIBus *typhoon_init(ram_addr_t, ISABus **, qemu_irq *, AlphaCPU *[4],
hw/alpha/dp264.c +1 -0
@@ -20,6 +20,7 @@#include "hw/timer/i8254.h" #include "hw/isa/superio.h" #include "hw/dma/i8257.h" +#include "net/net.h" #include "qemu/cutils.h" #define MAX_IDE_BUS 2
hw/hppa/hppa_sys.h +2 -1
@@ -6,7 +6,8 @@#include "hw/pci/pci.h" #include "hw/pci/pci_host.h" #include "hw/ide.h" -#include "hw/i386/pc.h" +#include "hw/boards.h" +#include "hw/intc/i8259.h" #include "hppa_hardware.h"
hw/hppa/machine.c +1 -0
@@ -19,6 +19,7 @@#include "hppa_sys.h" #include "qemu/units.h" #include "qapi/error.h" +#include "net/net.h" #include "qemu/log.h" #define MAX_IDE_BUS 2
hw/i386/kvm/i8259.c +1 -0
@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "hw/isa/i8259_internal.h" +#include "hw/intc/i8259.h" #include "qemu/module.h" #include "hw/i386/apic_internal.h" #include "hw/irq.h"
hw/i386/microvm.c +1 -0
@@ -34,6 +34,7 @@#include "hw/i386/x86.h" #include "hw/i386/pc.h" #include "target/i386/cpu.h" +#include "hw/intc/i8259.h" #include "hw/timer/i8254.h" #include "hw/rtc/mc146818rtc.h" #include "hw/char/serial.h"
hw/i386/pc.c +1 -0
@@ -44,6 +44,7 @@#include "migration/vmstate.h" #include "multiboot.h" #include "hw/rtc/mc146818rtc.h" +#include "hw/intc/i8259.h" #include "hw/dma/i8257.h" #include "hw/timer/i8254.h" #include "hw/input/i8042.h"
hw/i386/x86.c +1 -0
@@ -39,6 +39,7 @@#include "target/i386/cpu.h" #include "hw/i386/topology.h" #include "hw/i386/fw_cfg.h" +#include "hw/intc/i8259.h" #include "hw/acpi/cpu_hotplug.h" #include "hw/nmi.h"
hw/input/pckbd.c +0 -1
@@ -26,7 +26,6 @@#include "qemu/log.h" #include "hw/isa/isa.h" #include "migration/vmstate.h" -#include "hw/i386/pc.h" #include "hw/input/ps2.h" #include "hw/irq.h" #include "hw/input/i8042.h"
hw/intc/Kconfig +2 -0
@@ -9,6 +9,7 @@ config PL190 config IOAPIC bool + select I8259 config ARM_GIC bool
@@ -21,6 +22,7 @@ config OPENPIC config APIC bool select MSI_NONBROKEN + select I8259 config ARM_GIC_KVM bool
hw/intc/apic.c +1 -1
@@ -22,10 +22,10 @@#include "hw/i386/apic_internal.h" #include "hw/i386/apic.h" #include "hw/i386/ioapic.h" +#include "hw/intc/i8259.h" #include "hw/pci/msi.h" #include "qemu/host-utils.h" #include "trace.h" -#include "hw/i386/pc.h" #include "hw/i386/apic-msidef.h" #include "qapi/error.h"
hw/intc/i8259.c +1 -1
@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/irq.h" #include "hw/isa/isa.h" #include "qemu/timer.h"
hw/intc/i8259_common.c +1 -1
@@ -24,7 +24,7 @@*/ #include "qemu/osdep.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/isa/i8259_internal.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h"
hw/intc/ioapic.c +2 -1
@@ -23,10 +23,11 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "monitor/monitor.h" -#include "hw/i386/pc.h" #include "hw/i386/apic.h" #include "hw/i386/ioapic.h" #include "hw/i386/ioapic_internal.h" +#include "hw/i386/x86.h" +#include "hw/intc/i8259.h" #include "hw/pci/msi.h" #include "hw/qdev-properties.h" #include "sysemu/kvm.h"
hw/isa/i82378.c +1 -1
@@ -19,8 +19,8 @@#include "qemu/osdep.h" #include "hw/pci/pci.h" -#include "hw/i386/pc.h" #include "hw/irq.h" +#include "hw/intc/i8259.h" #include "hw/timer/i8254.h" #include "migration/vmstate.h" #include "hw/audio/pcspk.h"
hw/isa/lpc_ich9.c +0 -1
@@ -35,7 +35,6 @@#include "hw/isa/isa.h" #include "hw/sysbus.h" #include "migration/vmstate.h" -#include "hw/i386/pc.h" #include "hw/irq.h" #include "hw/isa/apm.h" #include "hw/i386/ioapic.h"
hw/isa/piix4.c +1 -1
@@ -26,11 +26,11 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/irq.h" -#include "hw/i386/pc.h" #include "hw/southbridge/piix.h" #include "hw/pci/pci.h" #include "hw/isa/isa.h" #include "hw/sysbus.h" +#include "hw/intc/i8259.h" #include "hw/dma/i8257.h" #include "hw/timer/i8254.h" #include "hw/rtc/mc146818rtc.h"
hw/mips/gt64xxx_pci.c +1 -1
@@ -30,7 +30,7 @@#include "hw/pci/pci_host.h" #include "hw/southbridge/piix.h" #include "migration/vmstate.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/irq.h" #include "exec/address-spaces.h" #include "trace.h"
hw/mips/mips_fulong2e.c +1 -1
@@ -23,7 +23,7 @@#include "qemu/units.h" #include "qapi/error.h" #include "cpu.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/dma/i8257.h" #include "hw/isa/superio.h" #include "net/net.h"
hw/mips/mips_jazz.c +1 -1
@@ -26,7 +26,7 @@#include "qemu-common.h" #include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/dma/i8257.h" #include "hw/char/serial.h" #include "hw/char/parallel.h"
hw/mips/mips_r4k.c +1 -1
@@ -15,7 +15,7 @@#include "cpu.h" #include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/char/serial.h" #include "hw/isa/isa.h" #include "net/net.h"
hw/pci-host/bonito.c +0 -1
@@ -40,7 +40,6 @@#include "qemu/osdep.h" #include "qemu/error-report.h" #include "hw/pci/pci.h" -#include "hw/i386/pc.h" #include "hw/irq.h" #include "hw/mips/mips.h" #include "hw/pci/pci_host.h"
hw/pci-host/prep.c +1 -1
@@ -32,7 +32,7 @@#include "hw/pci/pci_host.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/irq.h" #include "hw/loader.h" #include "hw/or-irq.h"
include/hw/i386/pc.h +0 -8
@@ -134,14 +134,6 @@ typedef struct PCMachineClass {#define PC_MACHINE_CLASS (klass) \ OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE) -/* i8259.c */ - -extern DeviceState *isa_pic; -qemu_irq *i8259_init (ISABus *bus,qemu_irq parent_irq); -qemu_irq *kvm_i8259_init (ISABus *bus); -int pic_read_irq (DeviceState *d); -int pic_get_output (DeviceState *d); -/* ioapic.c */ /* Global System Interrupts */
include/hw/intc/i8259.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef HW_I8259_H +#define HW_I8259_H + +/* i8259.c */ + +extern DeviceState *isa_pic; +qemu_irq *i8259_init (ISABus *bus,qemu_irq parent_irq); +qemu_irq *kvm_i8259_init (ISABus *bus); +int pic_get_output (DeviceState *d); +int pic_read_irq (DeviceState *d); + +#endif
include/hw/isa/i8259_internal.h +1 -1
@@ -25,9 +25,9 @@#ifndef QEMU_I8259_INTERNAL_H #define QEMU_I8259_INTERNAL_H -#include "hw/i386/pc.h" #include "hw/isa/isa.h" #include "hw/intc/intc.h" +#include "hw/intc/i8259.h" typedef struct PICCommonState PICCommonState ;
target/i386/monitor.c +0 -1
@@ -28,7 +28,6 @@#include "monitor/hmp-target.h" #include "monitor/hmp.h" #include "qapi/qmp/qdict.h" -#include "hw/i386/pc.h" #include "sysemu/kvm.h" #include "sysemu/sev.h" #include "qapi/error.h"
Signature · 1 line
1.8.3.1
Re: [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259
Quoted 3 lines · Paolo Bonzini
Remove the need to include
i386/pc.hto get to the i8259 functions. This is enough to remove the inclusion ofhw/i386/pc.hfrom all non-x86 files.
Eh this is very similar to the patch I'v staged for 5.0, now than the Malta/PC split got merged.
Quoted 31 lines
Signed-off-by Paolo Bonzini <[email protected]>--- hw/alpha/alpha_sys.h | 3 ++- hw/alpha/dp264.c | 1 + hw/hppa/hppa_sys.h | 3 ++- hw/hppa/machine.c | 1 + hw/i386/kvm/i8259.c | 1 + hw/i386/microvm.c | 1 + hw/i386/pc.c | 1 + hw/i386/x86.c | 1 + hw/input/pckbd.c | 1 - hw/intc/Kconfig | 2 ++ hw/intc/apic.c | 2 +- hw/intc/i8259.c | 2 +- hw/intc/i8259_common.c | 2 +- hw/intc/ioapic.c | 3 ++- hw/isa/i82378.c | 2 +- hw/isa/lpc_ich9.c | 1 - hw/isa/piix4.c | 2 +- hw/mips/gt64xxx_pci.c | 2 +- hw/mips/mips_fulong2e.c | 2 +- hw/mips/mips_jazz.c | 2 +- hw/mips/mips_r4k.c | 2 +- hw/pci-host/bonito.c | 1 - hw/pci-host/prep.c | 2 +- include/hw/i386/pc.h | 8 -------- include/hw/intc/i8259.h | 12 ++++++++++++ include/hw/isa/i8259_internal.h | 2 +- target/i386/monitor.c | 1 - 27 files changed, 37 insertions(+), 26 deletions(-)
Quoted 1 line
create mode 100644
include/hw/intc/i8259.h
Can you setup QEMU scripts/git.orderfile?
Quoted 337 lines
hw/alpha/alpha_sys.h +2
-1@@ -7,7 +7,8 @@#include "hw/pci/pci.h" #include "hw/pci/pci_host.h" #include "hw/ide.h" -#include "hw/i386/pc.h" +#include "hw/boards.h" +#include "hw/intc/i8259.h" PCIBus *typhoon_init(ram_addr_t, ISABus **, qemu_irq *, AlphaCPU *[4],hw/alpha/dp264.c +1
-0@@ -20,6 +20,7 @@#include "hw/timer/i8254.h" #include "hw/isa/superio.h" #include "hw/dma/i8257.h" +#include "net/net.h" #include "qemu/cutils.h" #define MAX_IDE_BUS 2hw/hppa/hppa_sys.h +2
-1@@ -6,7 +6,8 @@#include "hw/pci/pci.h" #include "hw/pci/pci_host.h" #include "hw/ide.h" -#include "hw/i386/pc.h" +#include "hw/boards.h" +#include "hw/intc/i8259.h" #include "hppa_hardware.h" hw/hppa/machine.c +1
-0@@ -19,6 +19,7 @@#include "hppa_sys.h" #include "qemu/units.h" #include "qapi/error.h" +#include "net/net.h" #include "qemu/log.h" #define MAX_IDE_BUS 2hw/i386/kvm/i8259.c +1
-0@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "hw/isa/i8259_internal.h" +#include "hw/intc/i8259.h" #include "qemu/module.h" #include "hw/i386/apic_internal.h" #include "hw/irq.h" hw/i386/microvm.c +1
-0@@ -34,6 +34,7 @@#include "hw/i386/x86.h" #include "hw/i386/pc.h" #include "target/i386/cpu.h" +#include "hw/intc/i8259.h" #include "hw/timer/i8254.h" #include "hw/rtc/mc146818rtc.h" #include "hw/char/serial.h" hw/i386/pc.c +1
-0@@ -44,6 +44,7 @@#include "migration/vmstate.h" #include "multiboot.h" #include "hw/rtc/mc146818rtc.h" +#include "hw/intc/i8259.h" #include "hw/dma/i8257.h" #include "hw/timer/i8254.h" #include "hw/input/i8042.h" hw/i386/x86.c +1
-0@@ -39,6 +39,7 @@#include "target/i386/cpu.h" #include "hw/i386/topology.h" #include "hw/i386/fw_cfg.h" +#include "hw/intc/i8259.h" #include "hw/acpi/cpu_hotplug.h" #include "hw/nmi.h" hw/input/pckbd.c +0
-1@@ -26,7 +26,6 @@#include "qemu/log.h" #include "hw/isa/isa.h" #include "migration/vmstate.h" -#include "hw/i386/pc.h" #include "hw/input/ps2.h" #include "hw/irq.h" #include "hw/input/i8042.h" hw/intc/Kconfig +2
-0@@ -9,6 +9,7 @@ config PL190 config IOAPIC bool + select I8259 config ARM_GIC bool@@ -21,6 +22,7 @@ config OPENPIC config APIC bool select MSI_NONBROKEN + select I8259 config ARM_GIC_KVM boolhw/intc/apic.c +1
-1@@ -22,10 +22,10 @@#include "hw/i386/apic_internal.h" #include "hw/i386/apic.h" #include "hw/i386/ioapic.h" +#include "hw/intc/i8259.h" #include "hw/pci/msi.h" #include "qemu/host-utils.h" #include "trace.h" -#include "hw/i386/pc.h" #include "hw/i386/apic-msidef.h" #include "qapi/error.h" hw/intc/i8259.c +1
-1@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/irq.h" #include "hw/isa/isa.h" #include "qemu/timer.h" hw/intc/i8259_common.c +1
-1@@ -24,7 +24,7 @@*/ #include "qemu/osdep.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/isa/i8259_internal.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" hw/intc/ioapic.c +2
-1@@ -23,10 +23,11 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "monitor/monitor.h" -#include "hw/i386/pc.h" #include "hw/i386/apic.h" #include "hw/i386/ioapic.h" #include "hw/i386/ioapic_internal.h" +#include "hw/i386/x86.h" +#include "hw/intc/i8259.h" #include "hw/pci/msi.h" #include "hw/qdev-properties.h" #include "sysemu/kvm.h" hw/isa/i82378.c +1
-1@@ -19,8 +19,8 @@#include "qemu/osdep.h" #include "hw/pci/pci.h" -#include "hw/i386/pc.h" #include "hw/irq.h" +#include "hw/intc/i8259.h" #include "hw/timer/i8254.h" #include "migration/vmstate.h" #include "hw/audio/pcspk.h" hw/isa/lpc_ich9.c +0
-1@@ -35,7 +35,6 @@#include "hw/isa/isa.h" #include "hw/sysbus.h" #include "migration/vmstate.h" -#include "hw/i386/pc.h" #include "hw/irq.h" #include "hw/isa/apm.h" #include "hw/i386/ioapic.h" hw/isa/piix4.c +1
-1@@ -26,11 +26,11 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/irq.h" -#include "hw/i386/pc.h" #include "hw/southbridge/piix.h" #include "hw/pci/pci.h" #include "hw/isa/isa.h" #include "hw/sysbus.h" +#include "hw/intc/i8259.h" #include "hw/dma/i8257.h" #include "hw/timer/i8254.h" #include "hw/rtc/mc146818rtc.h" hw/mips/gt64xxx_pci.c +1
-1@@ -30,7 +30,7 @@#include "hw/pci/pci_host.h" #include "hw/southbridge/piix.h" #include "migration/vmstate.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/irq.h" #include "exec/address-spaces.h" #include "trace.h" hw/mips/mips_fulong2e.c +1
-1@@ -23,7 +23,7 @@#include "qemu/units.h" #include "qapi/error.h" #include "cpu.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/dma/i8257.h" #include "hw/isa/superio.h" #include "net/net.h" hw/mips/mips_jazz.c +1
-1@@ -26,7 +26,7 @@#include "qemu-common.h" #include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/dma/i8257.h" #include "hw/char/serial.h" #include "hw/char/parallel.h" hw/mips/mips_r4k.c +1
-1@@ -15,7 +15,7 @@#include "cpu.h" #include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/char/serial.h" #include "hw/isa/isa.h" #include "net/net.h" hw/pci-host/bonito.c +0
-1@@ -40,7 +40,6 @@#include "qemu/osdep.h" #include "qemu/error-report.h" #include "hw/pci/pci.h" -#include "hw/i386/pc.h" #include "hw/irq.h" #include "hw/mips/mips.h" #include "hw/pci/pci_host.h" hw/pci-host/prep.c +1
-1@@ -32,7 +32,7 @@#include "hw/pci/pci_host.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" -#include "hw/i386/pc.h" +#include "hw/intc/i8259.h" #include "hw/irq.h" #include "hw/loader.h" #include "hw/or-irq.h" include/hw/i386/pc.h +0
-8@@ -134,14 +134,6 @@ typedef struct PCMachineClass {#define PC_MACHINE_CLASS (klass) \ OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE) -/* i8259.c */ - -extern DeviceState *isa_pic; -qemu_irq *i8259_init (ISABus *bus,qemu_irq parent_irq); -qemu_irq *kvm_i8259_init (ISABus *bus); -int pic_read_irq (DeviceState *d); -int pic_get_output (DeviceState *d); -/* ioapic.c */ /* Global System Interrupts */ include/hw/intc/i8259.h new file +0
-0
include/hw/intc/i8259.h line 4
Quoted 4 lines
include/hw/intc/i8259.h new file +4
-0@@ -0,0 +1,12 @@ +#ifndef HW_I8259_H +#define HW_I8259_H + +/* i8259.c */
Instead:
/*
* QEMU 8259 interrupt controller emulation
*
* Copyright (c) 2003-2004 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person
obtaining a copy
* of this software and associated documentation files (the
"Software"), to deal
* in the Software without restriction, including without limitation
the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN
* THE SOFTWARE.
*/
include/hw/intc/i8259.h line 8
Quoted 4 lines
include/hw/intc/i8259.h new file +4
-0+ +extern DeviceState *isa_pic; +qemu_irq *i8259_init (ISABus *bus,qemu_irq parent_irq); +qemu_irq *kvm_i8259_init (ISABus *bus);
I moved this particular one to hw/i386/kvm/.
Quoted 32 lines
include/hw/intc/i8259.h new file +4
-0+int pic_get_output (DeviceState *d); +int pic_read_irq (DeviceState *d); + +#endif include/hw/isa/i8259_internal.h +1
-1@@ -25,9 +25,9 @@#ifndef QEMU_I8259_INTERNAL_H #define QEMU_I8259_INTERNAL_H -#include "hw/i386/pc.h" #include "hw/isa/isa.h" #include "hw/intc/intc.h" +#include "hw/intc/i8259.h" typedef struct PICCommonState PICCommonState ;target/i386/monitor.c +0
-1@@ -28,7 +28,6 @@#include "monitor/hmp-target.h" #include "monitor/hmp.h" #include "qapi/qmp/qdict.h" -#include "hw/i386/pc.h" #include "sysemu/kvm.h" #include "sysemu/sev.h" #include "qapi/error.h"
Re: [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259
Il gio 12 dic 2019, 20:04 Philippe Mathieu-Daudé <[email protected]> ha scritto:
Quoted 8 lines · Paolo Bonzini
Quoted 3 lines
Remove the need to include
i386/pc.hto get to the i8259 functions. This is enough to remove the inclusion ofhw/i386/pc.hfrom all non-x86 files.Eh this is very similar to the patch I'v staged for 5.0, now than the Malta/PC split got merged.
Ok, these patches are not urgent so I will just wait for yours to go in and rebase.
Paolo
Re: [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259
Quoted 8 lines · Paolo Bonzini
Il gio 12 dic 2019, 20:04 Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> ha scritto:
On 12/12/19 6:29 PM, Paolo Bonzini wrote:
> Remove the need to includei386/pc.hto get to the i8259 functions. > This is enough to remove the inclusion ofhw/i386/pc.hfrom all
non-x86
> files.
Quoted 5 lines
Eh this is very similar to the patch I'v staged for 5.0, now than the Malta/PC split got merged.
Ok, these patches are not urgent so I will just wait for yours to go in and rebase.
Oh, I don't want to delay your series, this was more of a "comment to self" while reviewing your.
The MicroVM series introduced changes that outdated my work, and since having MicroVM was more important that global cleanup, I didn't insist a that time. Now GSI and IOAPIC are more exposed so my previous work doesn't apply at all. Well, current code diverged. I'll need some time to figure out if it is worthwhile salvaging, so don't wait for that.
Re: [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259
Quoted 8 lines · Philippe Mathieu-Daudé
The MicroVM series introduced changes that outdated my work, and since having MicroVM was more important that global cleanup, I didn't insist a that time. Now GSI and IOAPIC are more exposed so my previous work doesn't apply at all. Well, current code diverged.
I'll need some time to figure out if it is worthwhile salvaging, so don't wait for that.
Can you just point me to it? (Patchew URL)
Paolo
PATCH v2 4/8 pci-stub: add more MSI functions
In reply to Paolo BonziniOn x86, KVM needs some function from the PCI subsystem in order to set up interrupt routes. Provide some stubs to support x86 machines that lack PCI.
--- hw/pci/pci-stub.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
hw/pci/pci-stub.c +27 -0
@@ -26,6 +26,7 @@#include "qapi/qmp/qerror.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" +#include "hw/pci/msix.h" bool msi_nonbroken;bool pci_available;
@@ -64,3 +65,29 @@ void msi_notify(PCIDevice *dev, unsigned int vector) {g_assert_not_reached (); } + +/* Required by target/i386/kvm.c */ +bool msi_is_masked (const PCIDevice *dev,unsigned vector) +{ +g_assert_not_reached (); +} + +MSIMessage msi_get_message (PCIDevice *dev,unsigned int vector) +{ +g_assert_not_reached (); +} + +int msix_enabled (PCIDevice *dev) +{ +return false; +} + +bool msix_is_masked (PCIDevice *dev,unsigned vector) +{ +g_assert_not_reached (); +} + +MSIMessage msix_get_message (PCIDevice *dev,unsigned int vector) +{ +g_assert_not_reached (); +}
Signature · 1 line
1.8.3.1
Re: [PATCH v2 4/8] pci-stub: add more MSI functions
Quoted 6 lines · Paolo Bonzini
On x86, KVM needs some function from the PCI subsystem in order to set up interrupt routes. Provide some stubs to support x86 machines that lack PCI.
Reviewed-by Sergio Lopez <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>
Quoted 47 lines
--- hw/pci/pci-stub.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)hw/pci/pci-stub.c +27
-0@@ -26,6 +26,7 @@#include "qapi/qmp/qerror.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" +#include "hw/pci/msix.h" bool msi_nonbroken;bool pci_available;@@ -64,3 +65,29 @@ void msi_notify(PCIDevice *dev, unsigned int vector) {g_assert_not_reached (); } + +/* Required by target/i386/kvm.c */ +bool msi_is_masked (const PCIDevice *dev,unsigned vector) +{ +g_assert_not_reached (); +} + +MSIMessage msi_get_message (PCIDevice *dev,unsigned int vector) +{ +g_assert_not_reached (); +} + +int msix_enabled (PCIDevice *dev) +{ +return false; +} + +bool msix_is_masked (PCIDevice *dev,unsigned vector) +{ +g_assert_not_reached (); +} + +MSIMessage msix_get_message (PCIDevice *dev,unsigned int vector) +{ +g_assert_not_reached (); +}
PATCH v2 5/8 x86: move SMM property to X86MachineState
In reply to Paolo BonziniAdd it to microvm as well, it is a generic property of the x86 architecture.
--- hw/i386/pc.c | 49 ------------------------------------------------- hw/i386/pc_piix.c | 6 +++--- hw/i386/pc_q35.c | 2 +- hw/i386/x86.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- include/hw/i386/pc.h | 3 --- include/hw/i386/x86.h | 5 +++++ target/i386/kvm.c | 3 +-- 7 files changed, 59 insertions(+), 59 deletions(-)
hw/i386/pc.c +0 -49
@@ -2028,48 +2028,6 @@ static void pc_machine_set_vmport(Object *obj, Visitor *v, const char *name,visit_type_OnOffAuto (v, name, &pcms->vmport, errp); } -bool pc_machine_is_smm_enabled (PCMachineState *pcms) -{ -bool smm_available = false; - -if (pcms->smm ==ON_OFF_AUTO_OFF ) { -return false; - } - -if (tcg_enabled () ||qtest_enabled ()) { - smm_available = true; - }else if (kvm_enabled ()) { - smm_available =kvm_has_smm (); - } - -if (smm_available) { -return true; - } - -if (pcms->smm ==ON_OFF_AUTO_ON ) { -error_report ("System Management Mode not supported by this hypervisor." ); -exit (1 ); - } -return false; -} - -static void pc_machine_get_smm (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp) -{ -PCMachineState *pcms =PC_MACHINE (obj); -OnOffAuto smm = pcms->smm; - -visit_type_OnOffAuto (v, name, &smm, errp); -} - -static void pc_machine_set_smm (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp) -{ -PCMachineState *pcms =PC_MACHINE (obj); - -visit_type_OnOffAuto (v, name, &pcms->smm, errp); -} -static bool pc_machine_get_smbus (Object *obj,Error **errp) {PCMachineState *pcms =PC_MACHINE (obj);
@@ -2116,7 +2074,6 @@ static void pc_machine_initfn(Object *obj) {PCMachineState *pcms =PC_MACHINE (obj); - pcms->smm =ON_OFF_AUTO_AUTO ;#ifdef CONFIG_VMPORT pcms->vmport =ON_OFF_AUTO_AUTO ;#else
@@ -2223,12 +2180,6 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pc_machine_get_device_memory_region_size,NULL , NULL, NULL, &error_abort); -object_class_property_add (oc,PC_MACHINE_SMM ,"OnOffAuto" , - pc_machine_get_smm, pc_machine_set_smm, -NULL ,NULL , &error_abort); -object_class_property_set_description (oc,PC_MACHINE_SMM , -"Enable SMM (pc & q35)" , &error_abort); -object_class_property_add (oc,PC_MACHINE_VMPORT ,"OnOffAuto" , pc_machine_get_vmport, pc_machine_set_vmport,NULL ,NULL , &error_abort);
hw/i386/pc_piix.c +3 -3
@@ -281,7 +281,7 @@ else {/* TODO: Populate SPD eeprom data. */ pcms->smbus =piix4_pm_init (pci_bus, piix3_devfn +3 ,0xb100 , x86ms->gsi[9 ], smi_irq, -pc_machine_is_smm_enabled (pcms), +x86_machine_is_smm_enabled (x86ms), &piix4_pm);smbus_eeprom_init (pcms->smbus,8 ,NULL ,0 );
@@ -309,9 +309,9 @@ else {static void pc_compat_2_3_fn (MachineState *machine) { -PCMachineState *pcms =PC_MACHINE (machine); +X86MachineState *x86ms =X86_MACHINE (machine);if (kvm_enabled ()) { - pcms->smm =ON_OFF_AUTO_OFF ; + x86ms->smm =ON_OFF_AUTO_OFF ; } }
hw/i386/pc_q35.c +1 -1
@@ -276,7 +276,7 @@ static void pc_q35_init(MachineState *machine) 0xff0104);/* connect pm stuff to lpc */ -ich9_lpc_pm_init (lpc,pc_machine_is_smm_enabled (pcms)); +ich9_lpc_pm_init (lpc,x86_machine_is_smm_enabled (x86ms));if (pcms->sata_enabled) {/* ahci and SATA device, for q35 1 ahci controller is built-in */
hw/i386/x86.c +49 -1
68 lines not on this page · raw message
include/hw/i386/pc.h +0 -3
@@ -43,7 +43,6 @@ struct PCMachineState {/* Configuration options: */ OnOffAuto vmport; -OnOffAuto smm;bool acpi_build_enabled;bool smbus_enabled;
@@ -61,7 +60,6 @@ struct PCMachineState {#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"#define PC_MACHINE_DEVMEM_REGION_SIZE "device-memory-region-size"#define PC_MACHINE_VMPORT "vmport" -#define PC_MACHINE_SMM "smm"#define PC_MACHINE_SMBUS "smbus"#define PC_MACHINE_SATA "sata"#define PC_MACHINE_PIT "pit"
@@ -165,7 +163,6 @@ void vmmouse_set_data(const uint32_t *data);/* pc.c */ extern int fd_bootchk; -bool pc_machine_is_smm_enabled (PCMachineState *pcms);void pc_acpi_smi_interrupt (void *opaque,int irq,int level);void pc_hot_add_cpu (MachineState *ms,const int64_t id,Error **errp);
include/hw/i386/x86.h +5 -0
@@ -60,6 +60,8 @@ typedef struct {uint16_t boot_cpus;unsigned smp_dies; +OnOffAuto smm; +/* * Address space used by IOAPIC device. All IOAPIC interrupts * will be translated to MSI messages in the address space.
@@ -68,6 +70,7 @@ typedef struct { } X86MachineState;#define X86_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g" +#define X86_MACHINE_SMM "smm"#define TYPE_X86_MACHINE MACHINE_TYPE_NAME("x86")#define X86_MACHINE (obj) \
@@ -95,4 +98,6 @@ void x86_load_linux(X86MachineState *x86ms,bool pvh_enabled, bool linuxboot_dma_enabled); +bool x86_machine_is_smm_enabled (X86MachineState *x86ms); +#endif
target/i386/kvm.c +1 -2
@@ -2173,8 +2173,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) }if (kvm_check_extension (s,KVM_CAP_X86_SMM ) && -object_dynamic_cast (OBJECT (ms),TYPE_PC_MACHINE ) && -pc_machine_is_smm_enabled (PC_MACHINE (ms))) { +x86_machine_is_smm_enabled (X86_MACHINE (ms))) { smram_machine_done.notify = register_smram_listener;qemu_add_machine_init_done_notifier (&smram_machine_done); }
Signature · 1 line
1.8.3.1
Re: [PATCH v2 5/8] x86: move SMM property to X86MachineState
Quoted 5 lines · Paolo Bonzini
Add it to microvm as well, it is a generic property of the x86 architecture.
Suggested-by Sergio Lopez <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>
Quoted 267 lines
--- hw/i386/pc.c | 49 ------------------------------------------------- hw/i386/pc_piix.c | 6 +++--- hw/i386/pc_q35.c | 2 +- hw/i386/x86.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- include/hw/i386/pc.h | 3 --- include/hw/i386/x86.h | 5 +++++ target/i386/kvm.c | 3 +-- 7 files changed, 59 insertions(+), 59 deletions(-)hw/i386/pc.c +0
-49@@ -2028,48 +2028,6 @@ static void pc_machine_set_vmport(Object *obj, Visitor *v, const char *name,visit_type_OnOffAuto (v, name, &pcms->vmport, errp); } -bool pc_machine_is_smm_enabled (PCMachineState *pcms) -{ -bool smm_available = false; - -if (pcms->smm ==ON_OFF_AUTO_OFF ) { -return false; - } - -if (tcg_enabled () ||qtest_enabled ()) { - smm_available = true; - }else if (kvm_enabled ()) { - smm_available =kvm_has_smm (); - } - -if (smm_available) { -return true; - } - -if (pcms->smm ==ON_OFF_AUTO_ON ) { -error_report ("System Management Mode not supported by this hypervisor." ); -exit (1 ); - } -return false; -} - -static void pc_machine_get_smm (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp) -{ -PCMachineState *pcms =PC_MACHINE (obj); -OnOffAuto smm = pcms->smm; - -visit_type_OnOffAuto (v, name, &smm, errp); -} - -static void pc_machine_set_smm (Object *obj,Visitor *v,const char *name, -void *opaque,Error **errp) -{ -PCMachineState *pcms =PC_MACHINE (obj); - -visit_type_OnOffAuto (v, name, &pcms->smm, errp); -} -static bool pc_machine_get_smbus (Object *obj,Error **errp) {PCMachineState *pcms =PC_MACHINE (obj);@@ -2116,7 +2074,6 @@ static void pc_machine_initfn(Object *obj) {PCMachineState *pcms =PC_MACHINE (obj); - pcms->smm =ON_OFF_AUTO_AUTO ;#ifdef CONFIG_VMPORT pcms->vmport =ON_OFF_AUTO_AUTO ;#else @@ -2223,12 +2180,6 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pc_machine_get_device_memory_region_size,NULL , NULL, NULL, &error_abort); -object_class_property_add (oc,PC_MACHINE_SMM ,"OnOffAuto" , - pc_machine_get_smm, pc_machine_set_smm, -NULL ,NULL , &error_abort); -object_class_property_set_description (oc,PC_MACHINE_SMM , -"Enable SMM (pc & q35)" , &error_abort); -object_class_property_add (oc,PC_MACHINE_VMPORT ,"OnOffAuto" , pc_machine_get_vmport, pc_machine_set_vmport,NULL ,NULL , &error_abort);hw/i386/pc_piix.c +3
-3@@ -281,7 +281,7 @@ else {/* TODO: Populate SPD eeprom data. */ pcms->smbus =piix4_pm_init (pci_bus, piix3_devfn +3 ,0xb100 , x86ms->gsi[9 ], smi_irq, -pc_machine_is_smm_enabled (pcms), +x86_machine_is_smm_enabled (x86ms), &piix4_pm);smbus_eeprom_init (pcms->smbus,8 ,NULL ,0 );@@ -309,9 +309,9 @@ else {static void pc_compat_2_3_fn (MachineState *machine) { -PCMachineState *pcms =PC_MACHINE (machine); +X86MachineState *x86ms =X86_MACHINE (machine);if (kvm_enabled ()) { - pcms->smm =ON_OFF_AUTO_OFF ; + x86ms->smm =ON_OFF_AUTO_OFF ; } }hw/i386/pc_q35.c +1
-1@@ -276,7 +276,7 @@ static void pc_q35_init(MachineState *machine) 0xff0104);/* connect pm stuff to lpc */ -ich9_lpc_pm_init (lpc,pc_machine_is_smm_enabled (pcms)); +ich9_lpc_pm_init (lpc,x86_machine_is_smm_enabled (x86ms));if (pcms->sata_enabled) {/* ahci and SATA device, for q35 1 ahci controller is built-in */ hw/i386/x86.c +49
-1@@ -746,10 +746,53 @@ static void x86_machine_set_max_ram_below_4g(Object *obj, Visitor *v, x86ms->max_ram_below_4g = value; } +bool x86_machine_is_smm_enabled (X86MachineState *x86ms) +{ +bool smm_available = false; + +if (x86ms->smm ==ON_OFF_AUTO_OFF ) { +return false; + } + +if (tcg_enabled () ||qtest_enabled ()) { + smm_available = true; + }else if (kvm_enabled ()) { + smm_available =kvm_has_smm (); + } + +if (smm_available) { +return true; + } + +if (x86ms->smm ==ON_OFF_AUTO_ON ) { +error_report ("System Management Mode not supported by this hypervisor." ); +exit (1 ); + } +return false; +} + +static void x86_machine_get_smm (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +X86MachineState *x86ms =X86_MACHINE (obj); +OnOffAuto smm = x86ms->smm; + +visit_type_OnOffAuto (v, name, &smm, errp); +} + +static void x86_machine_set_smm (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +X86MachineState *x86ms =X86_MACHINE (obj); + +visit_type_OnOffAuto (v, name, &x86ms->smm, errp); +} +static void x86_machine_initfn (Object *obj) {X86MachineState *x86ms =X86_MACHINE (obj); + x86ms->smm =ON_OFF_AUTO_AUTO ; x86ms->max_ram_below_4g =0 ;/* use default */ x86ms->smp_dies =1 ; }@@ -770,9 +813,14 @@ static void x86_machine_class_init(ObjectClass *oc, void *data)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 , &error_abort); -object_class_property_set_description (oc,X86_MACHINE_MAX_RAM_BELOW_4G ,"Maximum ram below the 4G boundary (32bit boundary)" , &error_abort); + +object_class_property_add (oc,X86_MACHINE_SMM ,"OnOffAuto" , + x86_machine_get_smm, x86_machine_set_smm, +NULL ,NULL , &error_abort); +object_class_property_set_description (oc,X86_MACHINE_SMM , +"Enable SMM" , &error_abort); }static const TypeInfo x86_machine_info = {include/hw/i386/pc.h +0
-3@@ -43,7 +43,6 @@ struct PCMachineState {/* Configuration options: */ OnOffAuto vmport; -OnOffAuto smm;bool acpi_build_enabled;bool smbus_enabled;@@ -61,7 +60,6 @@ struct PCMachineState {#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"#define PC_MACHINE_DEVMEM_REGION_SIZE "device-memory-region-size"#define PC_MACHINE_VMPORT "vmport" -#define PC_MACHINE_SMM "smm"#define PC_MACHINE_SMBUS "smbus"#define PC_MACHINE_SATA "sata"#define PC_MACHINE_PIT "pit"@@ -165,7 +163,6 @@ void vmmouse_set_data(const uint32_t *data);/* pc.c */ extern int fd_bootchk; -bool pc_machine_is_smm_enabled (PCMachineState *pcms);void pc_acpi_smi_interrupt (void *opaque,int irq,int level);void pc_hot_add_cpu (MachineState *ms,const int64_t id,Error **errp);include/hw/i386/x86.h +5
-0@@ -60,6 +60,8 @@ typedef struct {uint16_t boot_cpus;unsigned smp_dies; +OnOffAuto smm; +/* * Address space used by IOAPIC device. All IOAPIC interrupts * will be translated to MSI messages in the address space. @@ -68,6 +70,7 @@ typedef struct { } X86MachineState;#define X86_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g" +#define X86_MACHINE_SMM "smm"#define TYPE_X86_MACHINE MACHINE_TYPE_NAME("x86")#define X86_MACHINE (obj) \@@ -95,4 +98,6 @@ void x86_load_linux(X86MachineState *x86ms,bool pvh_enabled, bool linuxboot_dma_enabled); +bool x86_machine_is_smm_enabled (X86MachineState *x86ms); +#endif target/i386/kvm.c +1
-2@@ -2173,8 +2173,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) }if (kvm_check_extension (s,KVM_CAP_X86_SMM ) && -object_dynamic_cast (OBJECT (ms),TYPE_PC_MACHINE ) && -pc_machine_is_smm_enabled (PC_MACHINE (ms))) { +x86_machine_is_smm_enabled (X86_MACHINE (ms))) { smram_machine_done.notify = register_smram_listener;qemu_add_machine_init_done_notifier (&smram_machine_done); }
PATCH v2 6/8 x86: move more x86-generic functions out of PC files
In reply to Paolo BonziniThese are needed by microvm too, so move them outside of PC-specific files. With this patch, microvm.c need not include pc.h anymore.
--- hw/i386/acpi-build.c | 1 + hw/i386/fw_cfg.c | 1 - hw/i386/fw_cfg.h | 2 + hw/i386/kvm/ioapic.c | 2 +- hw/i386/microvm.c | 3 +- hw/i386/pc.c | 101 +------------------------------------------------- hw/i386/x86.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/i386/pc.h | 20 ---------- include/hw/i386/x86.h | 18 +++++++++ target/i386/kvm.c | 2 +- target/i386/machine.c | 2 +- 11 files changed, 126 insertions(+), 126 deletions(-)
hw/i386/acpi-build.c +1 -0
@@ -53,6 +53,7 @@/* Supported chipsets: */ #include "hw/southbridge/piix.h" #include "hw/acpi/pcihp.h" +#include "hw/i386/fw_cfg.h" #include "hw/i386/ich9.h" #include "hw/pci/pci_bus.h" #include "hw/pci-host/q35.h"
hw/i386/fw_cfg.c +0 -1
@@ -16,7 +16,6 @@#include "sysemu/numa.h" #include "hw/acpi/acpi.h" #include "hw/firmware/smbios.h" -#include "hw/i386/pc.h" #include "hw/i386/fw_cfg.h" #include "hw/timer/hpet.h" #include "hw/nvram/fw_cfg.h"
hw/i386/fw_cfg.h +2 -0
@@ -12,6 +12,8 @@#include "hw/boards.h" #include "hw/nvram/fw_cfg.h" +#define FW_CFG_IO_BASE 0x510 +#define FW_CFG_ACPI_TABLES (FW_CFG_ARCH_LOCAL + 0)#define FW_CFG_SMBIOS_ENTRIES (FW_CFG_ARCH_LOCAL + 1)#define FW_CFG_IRQ0_OVERRIDE (FW_CFG_ARCH_LOCAL + 2)
hw/i386/kvm/ioapic.c +1 -1
@@ -12,7 +12,7 @@#include "qemu/osdep.h" #include "monitor/monitor.h" -#include "hw/i386/pc.h" +#include "hw/i386/x86.h" #include "hw/irq.h" #include "hw/qdev-properties.h" #include "hw/i386/ioapic_internal.h"
hw/i386/microvm.c +1 -2
@@ -32,7 +32,6 @@#include "hw/kvm/clock.h" #include "hw/i386/microvm.h" #include "hw/i386/x86.h" -#include "hw/i386/pc.h" #include "target/i386/cpu.h" #include "hw/intc/i8259.h" #include "hw/timer/i8254.h"
@@ -133,7 +132,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)if (mms->pic ==ON_OFF_AUTO_ON || mms->pic ==ON_OFF_AUTO_AUTO ) {qemu_irq *i8259; - i8259 =i8259_init (isa_bus,pc_allocate_cpu_irq ()); + i8259 =i8259_init (isa_bus,x86_allocate_cpu_irq ());for (i =0 ; i <ISA_NUM_IRQS ; i++) { gsi_state->i8259_irq[i] = i8259[i]; }
hw/i386/pc.c +1 -100
137 lines not on this page · raw message
hw/i386/x86.c +100 -0
117 lines not on this page · raw message
include/hw/i386/pc.h +0 -20
@@ -3,11 +3,9 @@#include "exec/memory.h" #include "hw/boards.h" -#include "hw/isa/isa.h" #include "hw/block/fdc.h" #include "hw/block/flash.h" #include "net/net.h" -#include "hw/i386/ioapic.h" #include "hw/i386/x86.h" #include "qemu/range.h"
@@ -134,17 +132,6 @@ typedef struct PCMachineClass {/* ioapic.c */ -/* Global System Interrupts */ - -#define GSI_NUM_PINS IOAPIC_NUM_PINS - -typedef struct GSIState { -qemu_irq i8259_irq[ISA_NUM_IRQS ]; -qemu_irq ioapic_irq[IOAPIC_NUM_PINS ]; -}GSIState ; - -void gsi_handler (void *opaque,int n,int level); -GSIState *pc_gsi_create (qemu_irq **irqs,bool pci_enabled);/* vmport.c */
@@ -188,7 +175,6 @@ void pc_memory_init(PCMachineState *pcms, MemoryRegion *rom_memory, MemoryRegion **ram_memory);uint64_t pc_pci_hole64_start (void ); -qemu_irq pc_allocate_cpu_irq (void );DeviceState *pc_vga_init (ISABus *isa_bus,PCIBus *pci_bus); void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, ISADevice **rtc_state,
@@ -206,18 +192,12 @@ void pc_pci_device_init(PCIBus *pci_bus);typedef void (*cpu_set_smm_t )(int smm,void *arg);void pc_i8259_create (ISABus *isa_bus,qemu_irq *i8259_irqs); -void ioapic_init_gsi (GSIState *gsi_state,const char *parent_name);ISADevice *pc_find_fdc0 (void );int cmos_get_fd_drive_type (FloppyDriveType fd0); -#define FW_CFG_IO_BASE 0x510 -#define PORT92_A20_LINE "a20" -/* hpet.c */ -extern int no_hpet; -/* pc_sysfw.c */ void pc_system_flash_create (PCMachineState *pcms);void pc_system_firmware_init (PCMachineState *pcms,MemoryRegion *rom_memory);
include/hw/i386/x86.h +18 -0
@@ -23,6 +23,8 @@#include "hw/boards.h" #include "hw/nmi.h" +#include "hw/isa/isa.h" +#include "hw/i386/ioapic.h" typedef struct { /*< private >*/
@@ -100,4 +102,20 @@ void x86_load_linux(X86MachineState *x86ms,bool x86_machine_is_smm_enabled (X86MachineState *x86ms); +/* Global System Interrupts */ + +#define GSI_NUM_PINS IOAPIC_NUM_PINS + +typedef struct GSIState { +qemu_irq i8259_irq[ISA_NUM_IRQS ]; +qemu_irq ioapic_irq[IOAPIC_NUM_PINS ]; +}GSIState ; + +qemu_irq x86_allocate_cpu_irq (void ); +void gsi_handler (void *opaque,int n,int level); +void ioapic_init_gsi (GSIState *gsi_state,const char *parent_name); + +/* hpet.c */ +extern int no_hpet; +#endif
target/i386/kvm.c +1 -1
@@ -35,7 +35,7 @@#include "qemu/main-loop.h" #include "qemu/config-file.h" #include "qemu/error-report.h" -#include "hw/i386/pc.h" +#include "hw/i386/x86.h" #include "hw/i386/apic.h" #include "hw/i386/apic_internal.h" #include "hw/i386/apic-msidef.h"
target/i386/machine.c +1 -1
@@ -1,10 +1,10 @@#include "qemu/osdep.h" #include "cpu.h" #include "exec/exec-all.h" -#include "hw/i386/pc.h" #include "hw/isa/isa.h" #include "migration/cpu.h" #include "hyperv.h" +#include "hw/i386/x86.h" #include "kvm_i386.h" #include "sysemu/kvm.h"
Signature · 1 line
1.8.3.1
Re: [PATCH v2 6/8] x86: move more x86-generic functions out of PC files
Quoted 4 lines · Paolo Bonzini
These are needed by microvm too, so move them outside of PC-specific files. With this patch,
microvm.cneed not includepc.hanymore.Signed-off-by Paolo Bonzini <[email protected]>
Current master does not work with libvirt ...
$ virsh start fedora-org-base error: Failed to start domain fedora-org-base error: internal error: Failed to probe QEMU binary with QMP: /home/kraxel/projects/qemu/target/i386/kvm.c:2176:kvm_arch_init: Object 0x5608f33be1f0 is not an instance of type x86-machine
... and git bisect lands at this patch.
cheers,
Gerd
Re: [PATCH v2 6/8] x86: move more x86-generic functions out of PC files
Yes, I am preparing a pull request now.
Paolo
Il mer 8 gen 2020, 09:04 Gerd Hoffmann <[email protected]> ha scritto:
Quoted 21 lines · Paolo Bonzini
Quoted 1 line
These are needed by microvm too, so move them outside of PC-specific
files.
Quoted 3 lines
With this patch,
microvm.cneed not includepc.hanymore.Signed-off-by Paolo Bonzini <[email protected]>Current master does not work with libvirt ...
$ virsh start fedora-org-base error: Failed to start domain fedora-org-base error: internal error: Failed to probe QEMU binary with QMP: /home/kraxel/projects/qemu/target/i386/kvm.c:2176:kvm_arch_init: Object 0x5608f33be1f0 is not an instance of type x86-machine... and git bisect lands at this patch.
cheers,
Gerd
PATCH v2 7/8 acpi: move PC stubs out of stubs/
In reply to Paolo BonziniThis is a small cleanup that lets libqemuutil build without include/hw/i386/pc.h.
--- hw/acpi/Makefile.objs | 1 + stubs/pc_madt_cpu_entry.c => hw/acpi/acpi-x86-stub.c | 0 stubs/Makefile.objs | 1 - 3 files changed, 1 insertion(+), 1 deletion(-) rename stubs/pc_madt_cpu_entry.c => hw/acpi/acpi-x86-stub.c (100%)
hw/acpi/Makefile.objs +1 -0
@@ -8,6 +8,7 @@ common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o common-obj-$(CONFIG_ACPI_HW_REDUCED) += generic_event_device.o common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o +common-obj-$(call lnot,$(CONFIG_PC)) += acpi-x86-stub.o common-obj-y += acpi_interface.o common-obj-y += bios-linker-loader.o
hw/acpi/acpi-x86-stub.c renamed from stubs/pc_madt_cpu_entry.c +0 -0
stubs/Makefile.objs +0 -1
@@ -33,7 +33,6 @@ stub-obj-y += fd-register.o stub-obj-y += qmp_memory_device.o stub-obj-y += target-monitor-defs.o stub-obj-y += target-get-monitor-def.o -stub-obj-y += pc_madt_cpu_entry.o stub-obj-y += vmgenid.o stub-obj-y += xen-common.o stub-obj-y += xen-hvm.o
Signature · 1 line
1.8.3.1
PATCH v2 8/8 pc: stubify x86 iommu
In reply to Paolo BonziniAllow building microvm without x86-iommu.c and in turn hw/i386/pc.h.
--- hw/i386/Kconfig | 6 ++++++ hw/i386/Makefile.objs | 3 ++- hw/i386/x86-iommu-stub.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletions(-) create mode 100644 hw/i386/x86-iommu-stub.c
hw/i386/Kconfig +6 -0
@@ -103,11 +103,17 @@ config MICROVM select MC146818RTC select VIRTIO_MMIO +config X86_IOMMU + bool + depends on PC + config VTD bool + select X86_IOMMU config AMD_IOMMU bool + select X86_IOMMU config VMPORT bool
hw/i386/Makefile.objs +2 -1
@@ -6,7 +6,8 @@ obj-$(CONFIG_I440FX) += pc_piix.o obj-$(CONFIG_Q35) += pc_q35.o obj-$(CONFIG_MICROVM) += microvm.o obj-y += fw_cfg.o -obj-y += x86-iommu.o +obj-$(CONFIG_X86_IOMMU) += x86-iommu.o +obj-$(call lnot,$(CONFIG_X86_IOMMU)) += x86-iommu-stub.o obj-$(CONFIG_VTD) += intel_iommu.o obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o obj-$(CONFIG_XEN) += ../xenpv/ xen/
hw/i386/x86-iommu-stub.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Stubs for X86 IOMMU emulation +* +* Copyright (C) 2019 Red Hat, Inc. +* +* Author: Paolo Bonzini <[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 "hw/i386/x86-iommu.h" + +void x86_iommu_iec_register_notifier (X86IOMMUState *iommu, +iec_notify_fn fn,void *data) +{ +} + +X86IOMMUState *x86_iommu_get_default (void ) +{ +return NULL ; +} +
Signature · 1 line
1.8.3.1
Re: [PATCH v2 8/8] pc: stubify x86 iommu
Quoted 9 lines · Paolo Bonzini
Allow building microvm without
x86-iommu.cand in turnhw/i386/pc.h.Signed-off-by Paolo Bonzini <[email protected]>--- hw/i386/Kconfig | 6 ++++++ hw/i386/Makefile.objs | 3 ++- hw/i386/x86-iommu-stub.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletions(-) create mode 100644 hw/i386/x86-iommu-stub.c
I just ran into this strange Travis build issue:
https://travis-ci.com/huth/qemu/jobs/273007378#L3509
... I think it might be related to this patch?
CONFIG_Q35 only does "imply AMD_IOMMU", so when compiling with "--without-default-devices", x86-iommu.c is not used... Do x86_iommu_ir_supported() and x86_iommu_get_type() need to be added to the x86-iommu-stub.c file?
Thomas
Re: [PATCH v2 8/8] pc: stubify x86 iommu
Quoted 13 lines · Thomas Huth
Quoted 9 lines · Paolo Bonzini
Allow building microvm without
x86-iommu.cand in turnhw/i386/pc.h.Signed-off-by Paolo Bonzini <[email protected]>--- hw/i386/Kconfig | 6 ++++++ hw/i386/Makefile.objs | 3 ++- hw/i386/x86-iommu-stub.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletions(-) create mode 100644 hw/i386/x86-iommu-stub.cI just ran into this strange Travis build issue:
Quoted 8 lines
https://travis-ci.com/huth/qemu/jobs/273007378#L3509
... I think it might be related to this patch?
CONFIG_Q35only does "implyAMD_IOMMU", so when compiling with "--without-default-devices",x86-iommu.cis not used... Dox86_iommu_ir_supported()andx86_iommu_get_type()need to be added to thex86-iommu-stub.cfile?
FWIW, I just found Phil's patch which should fix this issue:
https://lists.gnu.org/archive/html/qemu-devel/2020-01/msg00959.html
Thomas