qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/8] x86: allow building without PC machine types
@ 2019-12-12 17:29 Paolo Bonzini
  2019-12-12 17:29 ` [PATCH v2 1/8] i386: conditionally compile more files Paolo Bonzini
                   ` (7 more replies)
  0 siblings, 8 replies; 19+ messages in thread
From: Paolo Bonzini @ 2019-12-12 17:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, slp

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

-- 
1.8.3.1



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 1/8] i386: conditionally compile more files
  2019-12-12 17:29 [PATCH v2 0/8] x86: allow building without PC machine types Paolo Bonzini
@ 2019-12-12 17:29 ` Paolo Bonzini
  2019-12-12 17:29 ` [PATCH v2 2/8] fw_cfg: allow building without other devices Paolo Bonzini
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Paolo Bonzini @ 2019-12-12 17:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, slp

Reviewed-by: Sergio Lopez <slp@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/Makefile.objs     | 6 +++---
 hw/i386/kvm/Makefile.objs | 6 +++++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 0d195b5..01ae202 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -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
diff --git a/hw/i386/kvm/Makefile.objs b/hw/i386/kvm/Makefile.objs
index 4224ed9..0c8d5f2 100644
--- a/hw/i386/kvm/Makefile.objs
+++ b/hw/i386/kvm/Makefile.objs
@@ -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
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 2/8] fw_cfg: allow building without other devices
  2019-12-12 17:29 [PATCH v2 0/8] x86: allow building without PC machine types Paolo Bonzini
  2019-12-12 17:29 ` [PATCH v2 1/8] i386: conditionally compile more files Paolo Bonzini
@ 2019-12-12 17:29 ` Paolo Bonzini
  2019-12-12 17:29 ` [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259 Paolo Bonzini
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Paolo Bonzini @ 2019-12-12 17:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, slp

The 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.

Reviewed-by: Sergio Lopez <slp@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/fw_cfg.c | 7 +++++++
 hw/i386/pc.c     | 2 --
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c
index 39b6bc6..326e33e 100644
--- a/hw/i386/fw_cfg.c
+++ b/hw/i386/fw_cfg.c
@@ -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,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index b9f3b38..3d2c5d8 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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);
 
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259
  2019-12-12 17:29 [PATCH v2 0/8] x86: allow building without PC machine types Paolo Bonzini
  2019-12-12 17:29 ` [PATCH v2 1/8] i386: conditionally compile more files Paolo Bonzini
  2019-12-12 17:29 ` [PATCH v2 2/8] fw_cfg: allow building without other devices Paolo Bonzini
@ 2019-12-12 17:29 ` Paolo Bonzini
  2019-12-12 19:03   ` Philippe Mathieu-Daudé
  2019-12-12 17:29 ` [PATCH v2 4/8] pci-stub: add more MSI functions Paolo Bonzini
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Paolo Bonzini @ 2019-12-12 17:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, slp

Remove 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.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 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

diff --git a/hw/alpha/alpha_sys.h b/hw/alpha/alpha_sys.h
index 4e127a6..95033d7 100644
--- a/hw/alpha/alpha_sys.h
+++ b/hw/alpha/alpha_sys.h
@@ -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],
diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index 4320497..5ed9a5a 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -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
diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index 43d25d2..4e50196 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -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"
 
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index b30aba6..5d0de26 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -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
diff --git a/hw/i386/kvm/i8259.c b/hw/i386/kvm/i8259.c
index d0c1b1d..e404fdc 100644
--- a/hw/i386/kvm/i8259.c
+++ b/hw/i386/kvm/i8259.c
@@ -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"
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index def37e6..2068319 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -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"
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 3d2c5d8..fdbd2bf 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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"
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 394edc2..3e4aee5 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -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"
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index f0acfd8..2f09f78 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -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"
diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig
index 5347f84..10a680b 100644
--- a/hw/intc/Kconfig
+++ b/hw/intc/Kconfig
@@ -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
diff --git a/hw/intc/apic.c b/hw/intc/apic.c
index 2a74f7b..bd40467 100644
--- a/hw/intc/apic.c
+++ b/hw/intc/apic.c
@@ -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"
 
diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
index 211a989..51b27f6 100644
--- a/hw/intc/i8259.c
+++ b/hw/intc/i8259.c
@@ -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"
diff --git a/hw/intc/i8259_common.c b/hw/intc/i8259_common.c
index bd37bb5..e7b1a10 100644
--- a/hw/intc/i8259_common.c
+++ b/hw/intc/i8259_common.c
@@ -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"
diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c
index ead14e1..4f55776 100644
--- a/hw/intc/ioapic.c
+++ b/hw/intc/ioapic.c
@@ -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"
diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index de276cd..dcb6b47 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -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"
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 17c292e..170792a 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -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"
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 86678e6..7edec5e 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -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"
diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c
index f1af840..b2ea13f 100644
--- a/hw/mips/gt64xxx_pci.c
+++ b/hw/mips/gt64xxx_pci.c
@@ -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"
diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index 55c143e..6199c54 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -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"
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index d978bb6..c40b23f 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -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"
diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
index 7002423..fbbd59e 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -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"
diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index ceee463..c924007 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -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"
diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
index 85d7ba9..afa136d 100644
--- a/hw/pci-host/prep.c
+++ b/hw/pci-host/prep.c
@@ -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"
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 1f86eba..82447f8 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -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 */
diff --git a/include/hw/intc/i8259.h b/include/hw/intc/i8259.h
new file mode 100644
index 0000000..e2b1e8c
--- /dev/null
+++ b/include/hw/intc/i8259.h
@@ -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
diff --git a/include/hw/isa/i8259_internal.h b/include/hw/isa/i8259_internal.h
index ee189e4..861d70d 100644
--- a/include/hw/isa/i8259_internal.h
+++ b/include/hw/isa/i8259_internal.h
@@ -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;
 
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index 9fb4d64..27ebfa3 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -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"
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 4/8] pci-stub: add more MSI functions
  2019-12-12 17:29 [PATCH v2 0/8] x86: allow building without PC machine types Paolo Bonzini
                   ` (2 preceding siblings ...)
  2019-12-12 17:29 ` [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259 Paolo Bonzini
@ 2019-12-12 17:29 ` Paolo Bonzini
  2019-12-12 19:49   ` Philippe Mathieu-Daudé
  2019-12-12 17:29 ` [PATCH v2 5/8] x86: move SMM property to X86MachineState Paolo Bonzini
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Paolo Bonzini @ 2019-12-12 17:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, slp

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 <slp@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/pci/pci-stub.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c
index c04a5df..cc2a2e1 100644
--- a/hw/pci/pci-stub.c
+++ b/hw/pci/pci-stub.c
@@ -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();
+}
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 5/8] x86: move SMM property to X86MachineState
  2019-12-12 17:29 [PATCH v2 0/8] x86: allow building without PC machine types Paolo Bonzini
                   ` (3 preceding siblings ...)
  2019-12-12 17:29 ` [PATCH v2 4/8] pci-stub: add more MSI functions Paolo Bonzini
@ 2019-12-12 17:29 ` Paolo Bonzini
  2019-12-13 14:50   ` Philippe Mathieu-Daudé
  2019-12-12 17:29 ` [PATCH v2 6/8] x86: move more x86-generic functions out of PC files Paolo Bonzini
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Paolo Bonzini @ 2019-12-12 17:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, slp

Add it to microvm as well, it is a generic property of the x86
architecture.

Suggested-by: Sergio Lopez <slp@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 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(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index fdbd2bf..6a3212e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 1bd70d1..dd0f00e 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -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;
     }
 }
 
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 385e5cf..bccaaee 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -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 */
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 3e4aee5..6fb01e4 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -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 = {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 82447f8..ca641e8 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -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);
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index 4b84917..97d1575 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -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
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index ef63f3a..c7ff67a 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -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);
     }
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 6/8] x86: move more x86-generic functions out of PC files
  2019-12-12 17:29 [PATCH v2 0/8] x86: allow building without PC machine types Paolo Bonzini
                   ` (4 preceding siblings ...)
  2019-12-12 17:29 ` [PATCH v2 5/8] x86: move SMM property to X86MachineState Paolo Bonzini
@ 2019-12-12 17:29 ` Paolo Bonzini
  2020-01-08  8:03   ` Gerd Hoffmann
  2019-12-12 17:29 ` [PATCH v2 7/8] acpi: move PC stubs out of stubs/ Paolo Bonzini
  2019-12-12 17:29 ` [PATCH v2 8/8] pc: stubify x86 iommu Paolo Bonzini
  7 siblings, 1 reply; 19+ messages in thread
From: Paolo Bonzini @ 2019-12-12 17:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, slp

These are needed by microvm too, so move them outside of PC-specific files.
With this patch, microvm.c need not include pc.h anymore.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 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(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 12ff55f..7b8da62 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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"
diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c
index 326e33e..da60ada 100644
--- a/hw/i386/fw_cfg.c
+++ b/hw/i386/fw_cfg.c
@@ -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"
diff --git a/hw/i386/fw_cfg.h b/hw/i386/fw_cfg.h
index e0856a3..9e74278 100644
--- a/hw/i386/fw_cfg.h
+++ b/hw/i386/fw_cfg.h
@@ -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)
diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c
index f94729c..8703f19 100644
--- a/hw/i386/kvm/ioapic.c
+++ b/hw/i386/kvm/ioapic.c
@@ -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"
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 2068319..827ce29 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -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];
         }
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 6a3212e..545b855 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -343,17 +343,6 @@ GlobalProperty pc_compat_1_4[] = {
 };
 const size_t pc_compat_1_4_len = G_N_ELEMENTS(pc_compat_1_4);
 
-void gsi_handler(void *opaque, int n, int level)
-{
-    GSIState *s = opaque;
-
-    DPRINTF("pc: %s GSI %d\n", level ? "raising" : "lowering", n);
-    if (n < ISA_NUM_IRQS) {
-        qemu_set_irq(s->i8259_irq[n], level);
-    }
-    qemu_set_irq(s->ioapic_irq[n], level);
-}
-
 GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled)
 {
     GSIState *s;
@@ -393,55 +382,6 @@ static uint64_t ioportF0_read(void *opaque, hwaddr addr, unsigned size)
     return 0xffffffffffffffffULL;
 }
 
-/* TSC handling */
-uint64_t cpu_get_tsc(CPUX86State *env)
-{
-    return cpu_get_ticks();
-}
-
-/* IRQ handling */
-int cpu_get_pic_interrupt(CPUX86State *env)
-{
-    X86CPU *cpu = env_archcpu(env);
-    int intno;
-
-    if (!kvm_irqchip_in_kernel()) {
-        intno = apic_get_interrupt(cpu->apic_state);
-        if (intno >= 0) {
-            return intno;
-        }
-        /* read the irq from the PIC */
-        if (!apic_accept_pic_intr(cpu->apic_state)) {
-            return -1;
-        }
-    }
-
-    intno = pic_read_irq(isa_pic);
-    return intno;
-}
-
-static void pic_irq_request(void *opaque, int irq, int level)
-{
-    CPUState *cs = first_cpu;
-    X86CPU *cpu = X86_CPU(cs);
-
-    DPRINTF("pic_irqs: %s irq %d\n", level? "raise" : "lower", irq);
-    if (cpu->apic_state && !kvm_irqchip_in_kernel()) {
-        CPU_FOREACH(cs) {
-            cpu = X86_CPU(cs);
-            if (apic_accept_pic_intr(cpu->apic_state)) {
-                apic_deliver_pic_intr(cpu->apic_state, level);
-            }
-        }
-    } else {
-        if (level) {
-            cpu_interrupt(cs, CPU_INTERRUPT_HARD);
-        } else {
-            cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
-        }
-    }
-}
-
 /* PC cmos mappings */
 
 #define REG_EQUIPMENT_BYTE          0x14
@@ -885,16 +825,6 @@ void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd)
     nb_ne2k++;
 }
 
-DeviceState *cpu_get_current_apic(void)
-{
-    if (current_cpu) {
-        X86CPU *cpu = X86_CPU(current_cpu);
-        return cpu->apic_state;
-    } else {
-        return NULL;
-    }
-}
-
 void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
 {
     X86CPU *cpu = opaque;
@@ -1290,11 +1220,6 @@ uint64_t pc_pci_hole64_start(void)
     return ROUND_UP(hole64_start, 1 * GiB);
 }
 
-qemu_irq pc_allocate_cpu_irq(void)
-{
-    return qemu_allocate_irq(pic_irq_request, NULL, 0);
-}
-
 DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus)
 {
     DeviceState *dev = NULL;
@@ -1471,7 +1396,7 @@ void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs)
     } else if (xen_enabled()) {
         i8259 = xen_interrupt_controller_init();
     } else {
-        i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());
+        i8259 = i8259_init(isa_bus, x86_allocate_cpu_irq());
     }
 
     for (size_t i = 0; i < ISA_NUM_IRQS; i++) {
@@ -1481,30 +1406,6 @@ void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs)
     g_free(i8259);
 }
 
-void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name)
-{
-    DeviceState *dev;
-    SysBusDevice *d;
-    unsigned int i;
-
-    if (kvm_ioapic_in_kernel()) {
-        dev = qdev_create(NULL, TYPE_KVM_IOAPIC);
-    } else {
-        dev = qdev_create(NULL, TYPE_IOAPIC);
-    }
-    if (parent_name) {
-        object_property_add_child(object_resolve_path(parent_name, NULL),
-                                  "ioapic", OBJECT(dev), NULL);
-    }
-    qdev_init_nofail(dev);
-    d = SYS_BUS_DEVICE(dev);
-    sysbus_mmio_map(d, 0, IO_APIC_DEFAULT_ADDRESS);
-
-    for (i = 0; i < IOAPIC_NUM_PINS; i++) {
-        gsi_state->ioapic_irq[i] = qdev_get_gpio_in(dev, i);
-    }
-}
-
 static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
                                Error **errp)
 {
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 6fb01e4..b14acca 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -42,11 +42,14 @@
 #include "hw/intc/i8259.h"
 
 #include "hw/acpi/cpu_hotplug.h"
+#include "hw/irq.h"
 #include "hw/nmi.h"
 #include "hw/loader.h"
 #include "multiboot.h"
 #include "elf.h"
 #include "standard-headers/asm-x86/bootparam.h"
+#include "config-devices.h"
+#include "kvm_i386.h"
 
 #define BIOS_FILENAME "bios.bin"
 
@@ -221,6 +224,103 @@ static long get_file_size(FILE *f)
     return size;
 }
 
+/* TSC handling */
+uint64_t cpu_get_tsc(CPUX86State *env)
+{
+    return cpu_get_ticks();
+}
+
+/* IRQ handling */
+static void pic_irq_request(void *opaque, int irq, int level)
+{
+    CPUState *cs = first_cpu;
+    X86CPU *cpu = X86_CPU(cs);
+
+    if (cpu->apic_state && !kvm_irqchip_in_kernel()) {
+        CPU_FOREACH(cs) {
+            cpu = X86_CPU(cs);
+            if (apic_accept_pic_intr(cpu->apic_state)) {
+                apic_deliver_pic_intr(cpu->apic_state, level);
+            }
+        }
+    } else {
+        if (level) {
+            cpu_interrupt(cs, CPU_INTERRUPT_HARD);
+        } else {
+            cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
+        }
+    }
+}
+
+qemu_irq x86_allocate_cpu_irq(void)
+{
+    return qemu_allocate_irq(pic_irq_request, NULL, 0);
+}
+
+int cpu_get_pic_interrupt(CPUX86State *env)
+{
+    X86CPU *cpu = env_archcpu(env);
+    int intno;
+
+    if (!kvm_irqchip_in_kernel()) {
+        intno = apic_get_interrupt(cpu->apic_state);
+        if (intno >= 0) {
+            return intno;
+        }
+        /* read the irq from the PIC */
+        if (!apic_accept_pic_intr(cpu->apic_state)) {
+            return -1;
+        }
+    }
+
+    intno = pic_read_irq(isa_pic);
+    return intno;
+}
+
+DeviceState *cpu_get_current_apic(void)
+{
+    if (current_cpu) {
+        X86CPU *cpu = X86_CPU(current_cpu);
+        return cpu->apic_state;
+    } else {
+        return NULL;
+    }
+}
+
+void gsi_handler(void *opaque, int n, int level)
+{
+    GSIState *s = opaque;
+
+    if (n < ISA_NUM_IRQS) {
+        qemu_set_irq(s->i8259_irq[n], level);
+    }
+    qemu_set_irq(s->ioapic_irq[n], level);
+}
+
+void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name)
+{
+    DeviceState *dev;
+    SysBusDevice *d;
+    unsigned int i;
+
+    if (kvm_ioapic_in_kernel()) {
+        dev = qdev_create(NULL, TYPE_KVM_IOAPIC);
+    } else {
+        dev = qdev_create(NULL, TYPE_IOAPIC);
+    }
+    if (parent_name) {
+        object_property_add_child(object_resolve_path(parent_name, NULL),
+                                  "ioapic", OBJECT(dev), NULL);
+    }
+    qdev_init_nofail(dev);
+    d = SYS_BUS_DEVICE(dev);
+    sysbus_mmio_map(d, 0, IO_APIC_DEFAULT_ADDRESS);
+
+    for (i = 0; i < IOAPIC_NUM_PINS; i++) {
+        gsi_state->ioapic_irq[i] = qdev_get_gpio_in(dev, i);
+    }
+}
+
 struct setup_data {
     uint64_t next;
     uint32_t type;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index ca641e8..e512838 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -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);
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index 97d1575..41fe37b 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -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
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index c7ff67a..55e6265 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -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"
diff --git a/target/i386/machine.c b/target/i386/machine.c
index 2699eed..b6720d8 100644
--- a/target/i386/machine.c
+++ b/target/i386/machine.c
@@ -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"
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 7/8] acpi: move PC stubs out of stubs/
  2019-12-12 17:29 [PATCH v2 0/8] x86: allow building without PC machine types Paolo Bonzini
                   ` (5 preceding siblings ...)
  2019-12-12 17:29 ` [PATCH v2 6/8] x86: move more x86-generic functions out of PC files Paolo Bonzini
@ 2019-12-12 17:29 ` Paolo Bonzini
  2019-12-12 17:29 ` [PATCH v2 8/8] pc: stubify x86 iommu Paolo Bonzini
  7 siblings, 0 replies; 19+ messages in thread
From: Paolo Bonzini @ 2019-12-12 17:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, slp

This is a small cleanup that lets libqemuutil build without
include/hw/i386/pc.h.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 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%)

diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index 655a9c1..e772e89 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -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
diff --git a/stubs/pc_madt_cpu_entry.c b/hw/acpi/acpi-x86-stub.c
similarity index 100%
rename from stubs/pc_madt_cpu_entry.c
rename to hw/acpi/acpi-x86-stub.c
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 4a50e95..8b0ff25 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -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
-- 
1.8.3.1





^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 8/8] pc: stubify x86 iommu
  2019-12-12 17:29 [PATCH v2 0/8] x86: allow building without PC machine types Paolo Bonzini
                   ` (6 preceding siblings ...)
  2019-12-12 17:29 ` [PATCH v2 7/8] acpi: move PC stubs out of stubs/ Paolo Bonzini
@ 2019-12-12 17:29 ` Paolo Bonzini
  2020-01-07 14:26   ` Thomas Huth
  7 siblings, 1 reply; 19+ messages in thread
From: Paolo Bonzini @ 2019-12-12 17:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: philmd, slp

Allow building microvm without x86-iommu.c and in turn hw/i386/pc.h.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 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

diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index 5a49434..91cf584 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -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
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 01ae202..1236c3b 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -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/
diff --git a/hw/i386/x86-iommu-stub.c b/hw/i386/x86-iommu-stub.c
new file mode 100644
index 0000000..03576cd
--- /dev/null
+++ b/hw/i386/x86-iommu-stub.c
@@ -0,0 +1,34 @@
+/*
+ * Stubs for X86 IOMMU emulation
+ *
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * Author: Paolo Bonzini <pbonzini@redhat.com>
+ *
+ * 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;
+}
+
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259
  2019-12-12 17:29 ` [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259 Paolo Bonzini
@ 2019-12-12 19:03   ` Philippe Mathieu-Daudé
  2019-12-12 20:05     ` Paolo Bonzini
  0 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-12-12 19:03 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: slp

On 12/12/19 6:29 PM, Paolo Bonzini wrote:
> Remove 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.

Eh this is very similar to the patch I'v staged for 5.0, now than the 
Malta/PC split got merged.

> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   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

Can you setup QEMU scripts/git.orderfile?

> 
> diff --git a/hw/alpha/alpha_sys.h b/hw/alpha/alpha_sys.h
> index 4e127a6..95033d7 100644
> --- a/hw/alpha/alpha_sys.h
> +++ b/hw/alpha/alpha_sys.h
> @@ -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],
> diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
> index 4320497..5ed9a5a 100644
> --- a/hw/alpha/dp264.c
> +++ b/hw/alpha/dp264.c
> @@ -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
> diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
> index 43d25d2..4e50196 100644
> --- a/hw/hppa/hppa_sys.h
> +++ b/hw/hppa/hppa_sys.h
> @@ -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"
>   
> diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
> index b30aba6..5d0de26 100644
> --- a/hw/hppa/machine.c
> +++ b/hw/hppa/machine.c
> @@ -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
> diff --git a/hw/i386/kvm/i8259.c b/hw/i386/kvm/i8259.c
> index d0c1b1d..e404fdc 100644
> --- a/hw/i386/kvm/i8259.c
> +++ b/hw/i386/kvm/i8259.c
> @@ -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"
> diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
> index def37e6..2068319 100644
> --- a/hw/i386/microvm.c
> +++ b/hw/i386/microvm.c
> @@ -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"
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 3d2c5d8..fdbd2bf 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -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"
> diff --git a/hw/i386/x86.c b/hw/i386/x86.c
> index 394edc2..3e4aee5 100644
> --- a/hw/i386/x86.c
> +++ b/hw/i386/x86.c
> @@ -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"
> diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
> index f0acfd8..2f09f78 100644
> --- a/hw/input/pckbd.c
> +++ b/hw/input/pckbd.c
> @@ -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"
> diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig
> index 5347f84..10a680b 100644
> --- a/hw/intc/Kconfig
> +++ b/hw/intc/Kconfig
> @@ -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
> diff --git a/hw/intc/apic.c b/hw/intc/apic.c
> index 2a74f7b..bd40467 100644
> --- a/hw/intc/apic.c
> +++ b/hw/intc/apic.c
> @@ -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"
>   
> diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
> index 211a989..51b27f6 100644
> --- a/hw/intc/i8259.c
> +++ b/hw/intc/i8259.c
> @@ -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"
> diff --git a/hw/intc/i8259_common.c b/hw/intc/i8259_common.c
> index bd37bb5..e7b1a10 100644
> --- a/hw/intc/i8259_common.c
> +++ b/hw/intc/i8259_common.c
> @@ -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"
> diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c
> index ead14e1..4f55776 100644
> --- a/hw/intc/ioapic.c
> +++ b/hw/intc/ioapic.c
> @@ -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"
> diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
> index de276cd..dcb6b47 100644
> --- a/hw/isa/i82378.c
> +++ b/hw/isa/i82378.c
> @@ -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"
> diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
> index 17c292e..170792a 100644
> --- a/hw/isa/lpc_ich9.c
> +++ b/hw/isa/lpc_ich9.c
> @@ -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"
> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
> index 86678e6..7edec5e 100644
> --- a/hw/isa/piix4.c
> +++ b/hw/isa/piix4.c
> @@ -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"
> diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c
> index f1af840..b2ea13f 100644
> --- a/hw/mips/gt64xxx_pci.c
> +++ b/hw/mips/gt64xxx_pci.c
> @@ -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"
> diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
> index 55c143e..6199c54 100644
> --- a/hw/mips/mips_fulong2e.c
> +++ b/hw/mips/mips_fulong2e.c
> @@ -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"
> diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
> index d978bb6..c40b23f 100644
> --- a/hw/mips/mips_jazz.c
> +++ b/hw/mips/mips_jazz.c
> @@ -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"
> diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
> index 7002423..fbbd59e 100644
> --- a/hw/mips/mips_r4k.c
> +++ b/hw/mips/mips_r4k.c
> @@ -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"
> diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
> index ceee463..c924007 100644
> --- a/hw/pci-host/bonito.c
> +++ b/hw/pci-host/bonito.c
> @@ -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"
> diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
> index 85d7ba9..afa136d 100644
> --- a/hw/pci-host/prep.c
> +++ b/hw/pci-host/prep.c
> @@ -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"
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 1f86eba..82447f8 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -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 */
> diff --git a/include/hw/intc/i8259.h b/include/hw/intc/i8259.h
> new file mode 100644
> index 0000000..e2b1e8c
> --- /dev/null
> +++ b/include/hw/intc/i8259.h
> @@ -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.
  */

> +
> +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/.

> +int pic_get_output(DeviceState *d);
> +int pic_read_irq(DeviceState *d);
> +
> +#endif
> diff --git a/include/hw/isa/i8259_internal.h b/include/hw/isa/i8259_internal.h
> index ee189e4..861d70d 100644
> --- a/include/hw/isa/i8259_internal.h
> +++ b/include/hw/isa/i8259_internal.h
> @@ -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;
>   
> diff --git a/target/i386/monitor.c b/target/i386/monitor.c
> index 9fb4d64..27ebfa3 100644
> --- a/target/i386/monitor.c
> +++ b/target/i386/monitor.c
> @@ -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"
> 



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 4/8] pci-stub: add more MSI functions
  2019-12-12 17:29 ` [PATCH v2 4/8] pci-stub: add more MSI functions Paolo Bonzini
@ 2019-12-12 19:49   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-12-12 19:49 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: slp

On 12/12/19 6:29 PM, Paolo Bonzini wrote:
> 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 <slp@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   hw/pci/pci-stub.c | 27 +++++++++++++++++++++++++++
>   1 file changed, 27 insertions(+)
> 
> diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c
> index c04a5df..cc2a2e1 100644
> --- a/hw/pci/pci-stub.c
> +++ b/hw/pci/pci-stub.c
> @@ -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();
> +}
> 



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259
  2019-12-12 19:03   ` Philippe Mathieu-Daudé
@ 2019-12-12 20:05     ` Paolo Bonzini
  2019-12-13  9:43       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 19+ messages in thread
From: Paolo Bonzini @ 2019-12-12 20:05 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, Sergio Lopez

[-- Attachment #1: Type: text/plain, Size: 499 bytes --]

Il gio 12 dic 2019, 20:04 Philippe Mathieu-Daudé <philmd@redhat.com> ha
scritto:

> On 12/12/19 6:29 PM, Paolo Bonzini wrote:
> > Remove 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.
>
> 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

[-- Attachment #2: Type: text/html, Size: 883 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259
  2019-12-12 20:05     ` Paolo Bonzini
@ 2019-12-13  9:43       ` Philippe Mathieu-Daudé
  2019-12-13 14:56         ` Paolo Bonzini
  0 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-12-13  9:43 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, Sergio Lopez

On 12/12/19 9:05 PM, Paolo Bonzini wrote:
> Il gio 12 dic 2019, 20:04 Philippe Mathieu-Daudé <philmd@redhat.com 
> <mailto:philmd@redhat.com>> ha scritto:
> 
>     On 12/12/19 6:29 PM, Paolo Bonzini wrote:
>      > Remove 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.
> 
>     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.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 5/8] x86: move SMM property to X86MachineState
  2019-12-12 17:29 ` [PATCH v2 5/8] x86: move SMM property to X86MachineState Paolo Bonzini
@ 2019-12-13 14:50   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-12-13 14:50 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: slp

On 12/12/19 6:29 PM, Paolo Bonzini wrote:
> Add it to microvm as well, it is a generic property of the x86
> architecture.
> 
> Suggested-by: Sergio Lopez <slp@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   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(-)
> 
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index fdbd2bf..6a3212e 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -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);
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 1bd70d1..dd0f00e 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -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;
>       }
>   }
>   
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 385e5cf..bccaaee 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -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 */
> diff --git a/hw/i386/x86.c b/hw/i386/x86.c
> index 3e4aee5..6fb01e4 100644
> --- a/hw/i386/x86.c
> +++ b/hw/i386/x86.c
> @@ -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 = {
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 82447f8..ca641e8 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -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);
> diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
> index 4b84917..97d1575 100644
> --- a/include/hw/i386/x86.h
> +++ b/include/hw/i386/x86.h
> @@ -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
> diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> index ef63f3a..c7ff67a 100644
> --- a/target/i386/kvm.c
> +++ b/target/i386/kvm.c
> @@ -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);
>       }
> 



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259
  2019-12-13  9:43       ` Philippe Mathieu-Daudé
@ 2019-12-13 14:56         ` Paolo Bonzini
  0 siblings, 0 replies; 19+ messages in thread
From: Paolo Bonzini @ 2019-12-13 14:56 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, Sergio Lopez

On 13/12/19 10:43, Philippe Mathieu-Daudé wrote:
> 
> 
> 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



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 8/8] pc: stubify x86 iommu
  2019-12-12 17:29 ` [PATCH v2 8/8] pc: stubify x86 iommu Paolo Bonzini
@ 2020-01-07 14:26   ` Thomas Huth
  2020-01-07 14:59     ` Thomas Huth
  0 siblings, 1 reply; 19+ messages in thread
From: Thomas Huth @ 2020-01-07 14:26 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Alex Bennée, philmd, slp, Peter Maydell

On 12/12/2019 18.29, Paolo Bonzini wrote:
> Allow building microvm without x86-iommu.c and in turn hw/i386/pc.h.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  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



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 8/8] pc: stubify x86 iommu
  2020-01-07 14:26   ` Thomas Huth
@ 2020-01-07 14:59     ` Thomas Huth
  0 siblings, 0 replies; 19+ messages in thread
From: Thomas Huth @ 2020-01-07 14:59 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Alex Bennée, philmd, slp, Peter Maydell

On 07/01/2020 15.26, Thomas Huth wrote:
> On 12/12/2019 18.29, Paolo Bonzini wrote:
>> Allow building microvm without x86-iommu.c and in turn hw/i386/pc.h.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  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?

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



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 6/8] x86: move more x86-generic functions out of PC files
  2019-12-12 17:29 ` [PATCH v2 6/8] x86: move more x86-generic functions out of PC files Paolo Bonzini
@ 2020-01-08  8:03   ` Gerd Hoffmann
  2020-01-08  8:19     ` Paolo Bonzini
  0 siblings, 1 reply; 19+ messages in thread
From: Gerd Hoffmann @ 2020-01-08  8:03 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: philmd, qemu-devel, slp

On Thu, Dec 12, 2019 at 06:29:12PM +0100, Paolo Bonzini wrote:
> These are needed by microvm too, so move them outside of PC-specific files.
> With this patch, microvm.c need not include pc.h anymore.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

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



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 6/8] x86: move more x86-generic functions out of PC files
  2020-01-08  8:03   ` Gerd Hoffmann
@ 2020-01-08  8:19     ` Paolo Bonzini
  0 siblings, 0 replies; 19+ messages in thread
From: Paolo Bonzini @ 2020-01-08  8:19 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Philippe Mathieu-Daudé, qemu-devel, slp

[-- Attachment #1: Type: text/plain, Size: 809 bytes --]

Yes, I am preparing a pull request now.

Paolo

Il mer 8 gen 2020, 09:04 Gerd Hoffmann <kraxel@redhat.com> ha scritto:

> On Thu, Dec 12, 2019 at 06:29:12PM +0100, Paolo Bonzini wrote:
> > These are needed by microvm too, so move them outside of PC-specific
> files.
> > With this patch, microvm.c need not include pc.h anymore.
> >
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>
> 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
>
>

[-- Attachment #2: Type: text/html, Size: 1229 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2020-01-08  8:19 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-12 17:29 [PATCH v2 0/8] x86: allow building without PC machine types Paolo Bonzini
2019-12-12 17:29 ` [PATCH v2 1/8] i386: conditionally compile more files Paolo Bonzini
2019-12-12 17:29 ` [PATCH v2 2/8] fw_cfg: allow building without other devices Paolo Bonzini
2019-12-12 17:29 ` [PATCH v2 3/8] hw: replace hw/i386/pc.h with a header just for the i8259 Paolo Bonzini
2019-12-12 19:03   ` Philippe Mathieu-Daudé
2019-12-12 20:05     ` Paolo Bonzini
2019-12-13  9:43       ` Philippe Mathieu-Daudé
2019-12-13 14:56         ` Paolo Bonzini
2019-12-12 17:29 ` [PATCH v2 4/8] pci-stub: add more MSI functions Paolo Bonzini
2019-12-12 19:49   ` Philippe Mathieu-Daudé
2019-12-12 17:29 ` [PATCH v2 5/8] x86: move SMM property to X86MachineState Paolo Bonzini
2019-12-13 14:50   ` Philippe Mathieu-Daudé
2019-12-12 17:29 ` [PATCH v2 6/8] x86: move more x86-generic functions out of PC files Paolo Bonzini
2020-01-08  8:03   ` Gerd Hoffmann
2020-01-08  8:19     ` Paolo Bonzini
2019-12-12 17:29 ` [PATCH v2 7/8] acpi: move PC stubs out of stubs/ Paolo Bonzini
2019-12-12 17:29 ` [PATCH v2 8/8] pc: stubify x86 iommu Paolo Bonzini
2020-01-07 14:26   ` Thomas Huth
2020-01-07 14:59     ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).