From 4f5604c41d4a4d41964dfacaa87b08178abcc838 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Fri, 15 Mar 2019 20:05:36 +0000 Subject: [PATCH 01/23] riscv: plic: Set msi_nonbroken as true Set msi_nonbroken as true for the PLIC. According to the comment located here: https://git.qemu.org/?p=qemu.git;a=blob;f=hw/pci/msi.c;h=47d2b0f33c664533b8dbd5cb17faa8e6a01afe1f;hb=HEAD#l38 the msi_nonbroken variable should be set to true even if they don't support MSI. In this case that is what we are doing as we don't support MSI. Signed-off-by: Alistair Francis Reported-by: Andrea Bolognani Reported-by: David Abdurachmanov Message-Id: <256afbb2da005dc62c159b0f4a4fc0d95c050660.1552679970.git.alistair.francis@wdc.com> Signed-off-by: Paolo Bonzini --- hw/riscv/sifive_plic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/riscv/sifive_plic.c b/hw/riscv/sifive_plic.c index d12ec3fc9a..4b0537c912 100644 --- a/hw/riscv/sifive_plic.c +++ b/hw/riscv/sifive_plic.c @@ -22,6 +22,7 @@ #include "qemu/log.h" #include "qemu/error-report.h" #include "hw/sysbus.h" +#include "hw/pci/msi.h" #include "target/riscv/cpu.h" #include "hw/riscv/sifive_plic.h" @@ -443,6 +444,8 @@ static void sifive_plic_realize(DeviceState *dev, Error **errp) plic->enable = g_new0(uint32_t, plic->bitfield_words * plic->num_addrs); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &plic->mmio); qdev_init_gpio_in(dev, sifive_plic_irq_request, plic->num_sources); + + msi_nonbroken = true; } static void sifive_plic_class_init(ObjectClass *klass, void *data) From ca9b7e29de3e79d6fe21bfc21297770a98d54e58 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 14 Mar 2019 14:13:34 +0100 Subject: [PATCH 02/23] kconfig: add CONFIG_MSI_NONBROKEN Not all interrupt controllers have a working implementation of message-signalled interrupts; in some cases, the guest may expect MSI to work but it won't due to the buggy or lacking emulation. In QEMU this is represented by the "msi_nonbroken" variable. This patch adds a new configuration symbol enabled whenever the binary contains an interrupt controller that will set "msi_nonbroken". We can then use it to remove devices that cannot be possibly added to the machine, because they require MSI. Signed-off-by: Paolo Bonzini --- hw/intc/Kconfig | 3 +++ hw/pci-host/Kconfig | 1 + hw/pci/Kconfig | 6 ++++++ hw/ppc/Kconfig | 1 + hw/riscv/Kconfig | 1 + hw/s390x/Kconfig | 1 + 6 files changed, 13 insertions(+) diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig index de10a6bcbf..5347f8412c 100644 --- a/hw/intc/Kconfig +++ b/hw/intc/Kconfig @@ -12,12 +12,15 @@ config IOAPIC config ARM_GIC bool + select MSI_NONBROKEN config OPENPIC bool + select MSI_NONBROKEN config APIC bool + select MSI_NONBROKEN config ARM_GIC_KVM bool diff --git a/hw/pci-host/Kconfig b/hw/pci-host/Kconfig index b39ea297ba..8c16d96b3f 100644 --- a/hw/pci-host/Kconfig +++ b/hw/pci-host/Kconfig @@ -49,3 +49,4 @@ config PCI_EXPRESS_XILINX config PCI_EXPRESS_DESIGNWARE bool select PCI_EXPRESS + select MSI_NONBROKEN diff --git a/hw/pci/Kconfig b/hw/pci/Kconfig index 3b8638b51d..77f8b005ff 100644 --- a/hw/pci/Kconfig +++ b/hw/pci/Kconfig @@ -7,3 +7,9 @@ config PCI_EXPRESS config PCI_DEVICES bool + +config MSI_NONBROKEN + # selected by interrupt controllers that do not support MSI, + # or support it and have a good implementation. See commit + # 47d2b0f33c664533b8dbd5cb17faa8e6a01afe1f. + bool diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index 2b83637511..73b473ca24 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -8,6 +8,7 @@ config PSERIES select VFIO if LINUX # needed by spapr_pci_vfio.c select XICS_SPAPR select XIVE_SPAPR + select MSI_NONBROKEN config SPAPR_RNG bool diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index 8c7fc1f31d..8674211085 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -6,6 +6,7 @@ config HART config SIFIVE bool + select MSI_NONBROKEN config SIFIVE_E bool diff --git a/hw/s390x/Kconfig b/hw/s390x/Kconfig index a7046ea41f..5e7d8a2bae 100644 --- a/hw/s390x/Kconfig +++ b/hw/s390x/Kconfig @@ -9,3 +9,4 @@ config S390_CCW_VIRTIO select S390_FLIC select SCLPCONSOLE select VIRTIO_CCW + select MSI_NONBROKEN From d6c1bd4a223776aaa6ef3845be12d3c7408b4ffb Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 14 Mar 2019 14:09:09 +0100 Subject: [PATCH 03/23] kconfig: add dependencies on CONFIG_MSI_NONBROKEN For devices that require msi_init/msix_init to succeed, add a dependency on CONFIG_MSI_NONBROKEN. This will prevent those devices from appearing in a binary that cannot instantiate them. Signed-off-by: Paolo Bonzini --- Kconfig.host | 3 +++ Makefile | 3 ++- hw/Kconfig | 1 + hw/misc/Kconfig | 4 ++-- hw/net/Kconfig | 4 ++-- hw/pci-bridge/Kconfig | 6 +++--- hw/rdma/Kconfig | 3 +++ hw/rdma/Makefile.objs | 6 ++---- 8 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 hw/rdma/Kconfig diff --git a/Kconfig.host b/Kconfig.host index add5b179f7..aec95365ff 100644 --- a/Kconfig.host +++ b/Kconfig.host @@ -31,3 +31,6 @@ config XEN config VIRTFS bool + +config PVRDMA + bool diff --git a/Makefile b/Makefile index d8dad39c5d..dbb8e136a3 100644 --- a/Makefile +++ b/Makefile @@ -356,7 +356,8 @@ MINIKCONF_ARGS = \ CONFIG_X11=$(CONFIG_X11) \ CONFIG_VHOST_USER=$(CONFIG_VHOST_USER) \ CONFIG_VIRTFS=$(CONFIG_VIRTFS) \ - CONFIG_LINUX=$(CONFIG_LINUX) + CONFIG_LINUX=$(CONFIG_LINUX) \ + CONFIG_PVRDMA=$(CONFIG_PVRDMA) MINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host $(SRC_PATH)/hw/Kconfig MINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py \ diff --git a/hw/Kconfig b/hw/Kconfig index d5ecd02070..88b9f15007 100644 --- a/hw/Kconfig +++ b/hw/Kconfig @@ -26,6 +26,7 @@ source pci-bridge/Kconfig source pci-host/Kconfig source pcmcia/Kconfig source pci/Kconfig +source rdma/Kconfig source scsi/Kconfig source sd/Kconfig source smbios/Kconfig diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 2c60be99bc..5f67d0d6d9 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -34,7 +34,7 @@ config PCI_TESTDEV config EDU bool default y if TEST_DEVICES - depends on PCI + depends on PCI && MSI_NONBROKEN config PCA9552 bool @@ -67,7 +67,7 @@ config MACIO config IVSHMEM_DEVICE bool default y if PCI_DEVICES - depends on PCI && LINUX && IVSHMEM + depends on PCI && LINUX && IVSHMEM && MSI_NONBROKEN config ECCMEMCTL bool diff --git a/hw/net/Kconfig b/hw/net/Kconfig index c00ec03cd1..7d7bbc5d7c 100644 --- a/hw/net/Kconfig +++ b/hw/net/Kconfig @@ -28,7 +28,7 @@ config E1000_PCI config E1000E_PCI_EXPRESS bool default y if PCI_DEVICES - depends on PCI_EXPRESS + depends on PCI_EXPRESS && MSI_NONBROKEN config RTL8139_PCI bool @@ -107,7 +107,7 @@ config ETSEC config ROCKER bool default y if PCI_DEVICES - depends on PCI + depends on PCI && MSI_NONBROKEN config CAN_BUS bool diff --git a/hw/pci-bridge/Kconfig b/hw/pci-bridge/Kconfig index b167b98497..a51ec716f5 100644 --- a/hw/pci-bridge/Kconfig +++ b/hw/pci-bridge/Kconfig @@ -1,7 +1,7 @@ config PCIE_PORT bool default y if PCI_DEVICES - depends on PCI_EXPRESS + depends on PCI_EXPRESS && MSI_NONBROKEN config PXB bool @@ -10,12 +10,12 @@ config PXB config XIO3130 bool default y if PCI_DEVICES - depends on PCI_EXPRESS + depends on PCI_EXPRESS && MSI_NONBROKEN config IOH3420 bool default y if PCI_DEVICES - depends on PCI_EXPRESS + depends on PCI_EXPRESS && MSI_NONBROKEN config I82801B11 bool diff --git a/hw/rdma/Kconfig b/hw/rdma/Kconfig new file mode 100644 index 0000000000..8e2211288f --- /dev/null +++ b/hw/rdma/Kconfig @@ -0,0 +1,3 @@ +config VMW_PVRDMA + default y if PCI_DEVICES + depends on PVRDMA && PCI && MSI_NONBROKEN diff --git a/hw/rdma/Makefile.objs b/hw/rdma/Makefile.objs index bd36cbf51c..533ab2f84a 100644 --- a/hw/rdma/Makefile.objs +++ b/hw/rdma/Makefile.objs @@ -1,5 +1,3 @@ -ifeq ($(CONFIG_PVRDMA),y) -obj-$(CONFIG_PCI) += rdma_utils.o rdma_backend.o rdma_rm.o -obj-$(CONFIG_PCI) += vmw/pvrdma_dev_ring.o vmw/pvrdma_cmd.o \ +obj-$(CONFIG_VMW_PVRDMA) += rdma_utils.o rdma_backend.o rdma_rm.o +obj-$(CONFIG_VMW_PVRDMA) += vmw/pvrdma_dev_ring.o vmw/pvrdma_cmd.o \ vmw/pvrdma_qp_ops.o vmw/pvrdma_main.o -endif From 2ddb89b00f947f785c9ca6742f28f954e3b75e62 Mon Sep 17 00:00:00 2001 From: "Singh, Brijesh" Date: Mon, 4 Feb 2019 22:23:39 +0000 Subject: [PATCH 04/23] memory: Fix the memory region type assignment order Currently, a callback registered through the RAMBlock notifier is not able to get the memory region type (i.e callback is not able to use memory_region_is_ram_device function). This is because mr->ram assignment happens _after_ the memory is allocated whereas the callback is executed during allocation. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1667249 Suggested-by: Alex Williamson Cc: Paolo Bonzini Reviewed-by: Alex Williamson Signed-off-by: Brijesh Singh Message-Id: <20190204222322.26766-2-brijesh.singh@amd.com> Signed-off-by: Paolo Bonzini --- memory.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/memory.c b/memory.c index e49369d85d..9fbca52e05 100644 --- a/memory.c +++ b/memory.c @@ -1649,10 +1649,17 @@ void memory_region_init_ram_device_ptr(MemoryRegion *mr, uint64_t size, void *ptr) { - memory_region_init_ram_ptr(mr, owner, name, size, ptr); + memory_region_init(mr, owner, name, size); + mr->ram = true; + mr->terminates = true; mr->ram_device = true; mr->ops = &ram_device_mem_ops; mr->opaque = mr; + mr->destructor = memory_region_destructor_ram; + mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; + /* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL. */ + assert(ptr != NULL); + mr->ram_block = qemu_ram_alloc_from_ptr(size, ptr, mr, &error_fatal); } void memory_region_init_alias(MemoryRegion *mr, From cedc0ad539afbbb669dba9e73dfad2915bc1c25b Mon Sep 17 00:00:00 2001 From: "Singh, Brijesh" Date: Mon, 4 Feb 2019 22:23:40 +0000 Subject: [PATCH 05/23] target/i386: sev: Do not pin the ram device memory region The RAM device presents a memory region that should be handled as an IO region and should not be pinned. In the case of the vfio-pci, RAM device represents a MMIO BAR and the memory region is not backed by pages hence KVM_MEMORY_ENCRYPT_REG_REGION fails to lock the memory range. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1667249 Cc: Alex Williamson Cc: Paolo Bonzini Signed-off-by: Brijesh Singh Message-Id: <20190204222322.26766-3-brijesh.singh@amd.com> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/i386/sev.c b/target/i386/sev.c index 20b2d325d8..cd77f6b5d4 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -131,6 +131,17 @@ sev_ram_block_added(RAMBlockNotifier *n, void *host, size_t size) { int r; struct kvm_enc_region range; + ram_addr_t offset; + MemoryRegion *mr; + + /* + * The RAM device presents a memory region that should be treated + * as IO region and should not be pinned. + */ + mr = memory_region_from_host(host, &offset); + if (mr && memory_region_is_ram_device(mr)) { + return; + } range.addr = (__u64)(unsigned long)host; range.size = size; From 3e3fdad6e1b980bd570790a8eaa6333023b4dcab Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Mon, 11 Mar 2019 10:50:54 +0100 Subject: [PATCH 06/23] hw/char/parallel: Make it possible to compile also without CONFIG_PARALLEL For the downstream distribution of QEMU, we want to compile without CONFIG_PARALLEL. Commit 9157eee1b1c076ff3 already moved the function parallel_hds_isa_init() (which is still required for linking) into a file that is included anyway, but commit bb3d5ea858e7f888563a moved it to a separate file which is only compiled again if CONFIG_PARALLEL is set. To be able to link QEMU again without CONFIG_PARALLEL, the file should be considered for linking for all targets that have CONFIG_ISA_BUS. And while we're at it, add a proper comment in there with the rationale for the separate file. Signed-off-by: Thomas Huth Message-Id: <1552297854-25847-1-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- hw/char/Makefile.objs | 2 +- hw/char/parallel-isa.c | 3 +++ hw/i386/Kconfig | 3 +-- hw/sparc64/Kconfig | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/char/Makefile.objs b/hw/char/Makefile.objs index c4947d7ae7..cf086e7114 100644 --- a/hw/char/Makefile.objs +++ b/hw/char/Makefile.objs @@ -2,7 +2,7 @@ common-obj-$(CONFIG_IPACK) += ipoctal232.o common-obj-$(CONFIG_ESCC) += escc.o common-obj-$(CONFIG_NRF51_SOC) += nrf51_uart.o common-obj-$(CONFIG_PARALLEL) += parallel.o -common-obj-$(CONFIG_PARALLEL) += parallel-isa.o +common-obj-$(CONFIG_ISA_BUS) += parallel-isa.o common-obj-$(CONFIG_PL011) += pl011.o common-obj-$(CONFIG_SERIAL) += serial.o common-obj-$(CONFIG_SERIAL_ISA) += serial-isa.o diff --git a/hw/char/parallel-isa.c b/hw/char/parallel-isa.c index 639e179585..a043832e72 100644 --- a/hw/char/parallel-isa.c +++ b/hw/char/parallel-isa.c @@ -1,6 +1,9 @@ /* * QEMU Parallel PORT (ISA bus helpers) * + * These functions reside in a separate file since they also might be + * required for linking when compiling QEMU without CONFIG_PARALLEL. + * * Copyright (c) 2003 Fabrice Bellard * * SPDX-License-Identifier: MIT diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index 78fd70396a..4e4415fc88 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -9,6 +9,7 @@ config PC imply ISA_IPMI_KCS imply ISA_IPMI_BT imply ISA_DEBUG + imply PARALLEL imply PCI_DEVICES imply PVPANIC imply QXL @@ -25,8 +26,6 @@ config PC select I82374 select I8257 select MC146818RTC - # Needed by the board code: - select PARALLEL # For ACPI builder: select SERIAL_ISA select ACPI_VMGENID diff --git a/hw/sparc64/Kconfig b/hw/sparc64/Kconfig index 4a8166ebb7..d4d76a89be 100644 --- a/hw/sparc64/Kconfig +++ b/hw/sparc64/Kconfig @@ -3,13 +3,13 @@ config SUN4U imply PCI_DEVICES imply SUNHME imply TEST_DEVICES + imply PARALLEL select M48T59 select ISA_BUS select FDC select SERIAL_ISA select PCI_SABRE select IDE_CMD646 - select PARALLEL select PCKBD select SIMBA From b377471ac89052ca9af8cafd7c3ff01e2ed263cd Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 20 Mar 2019 10:32:35 +0100 Subject: [PATCH 07/23] hw/i386/Kconfig: PC uses I8257, not I82374 CONFIG_I82374 is not needed for PC machines, since they create i8257 directly instead. Reported-by: Miroslav Rezanina Reviewed-by: Stefano Garzarella Signed-off-by: Paolo Bonzini --- hw/i386/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index 4e4415fc88..756b1eaef8 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -23,7 +23,6 @@ config PC select I8254 select PCKBD select PCSPK - select I82374 select I8257 select MC146818RTC # For ACPI builder: From b4f15fc4c1fd0d31137125b09e5dd201f134e2d0 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 20 Mar 2019 10:34:53 +0100 Subject: [PATCH 08/23] prep: do not select I82374 It is only needed through I82378, which also selects it. Reviewed-by: Stefano Garzarella Signed-off-by: Paolo Bonzini --- hw/ppc/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index 73b473ca24..bbe5a64865 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -64,7 +64,6 @@ config PREP imply TEST_DEVICES select CS4231A select PREP_PCI - select I82374 select I82378 select LSI_SCSI_PCI select M48T59 From aa889f73044ca0566a77e9980a371cc99b7939b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 16 Mar 2019 21:08:06 +0100 Subject: [PATCH 09/23] hw/isa/Kconfig: i82378 SuperIO requires PC speaker device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes when configuring with --without-default-devices: $ qemu-system-ppc -M prep qemu-system-ppc: Machine type 'prep' is deprecated: use 40p machine type instead qemu-system-ppc: Unknown device 'isa-pcspk' for bus 'ISA' Fixes: dd0ff8191ab Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190316200818.8265-3-philmd@redhat.com> --- hw/isa/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig index 57e09a0cb8..c9a26c7c52 100644 --- a/hw/isa/Kconfig +++ b/hw/isa/Kconfig @@ -11,6 +11,7 @@ config I82378 select I8254 select I82374 select MC146818RTC + select PCSPK config PC87312 bool From fa80da7b6984f3a32632da81baea8d4c0c6df68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 16 Mar 2019 21:08:05 +0100 Subject: [PATCH 10/23] hw/isa/Kconfig: PIIX4 southbridge requires USB UHCI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes when configuring with --without-default-devices: $ qemu-system-mips64 -bios /dev/null -M malta qemu-system-mips64: Unknown device 'piix4-usb-uhci' for bus 'PCI' Fixes: 7c28b925b7e Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190316200818.8265-2-philmd@redhat.com> --- hw/isa/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig index c9a26c7c52..6db0d7970c 100644 --- a/hw/isa/Kconfig +++ b/hw/isa/Kconfig @@ -30,6 +30,7 @@ config PIIX4 # For historical reasons, SuperIO devices are created in the board # for PIIX4. select ISA_BUS + select USB_UHCI config VT82C686 bool From 09cba51e4f3ebe3ed726db37f2b00e5c227e4197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 16 Mar 2019 21:08:07 +0100 Subject: [PATCH 11/23] hw/i386/Kconfig: enable devices that can be created by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes when configuring with CONFIG_PCI_DEVICES=n: $ qemu-system-x86_64 -M q35 qemu-system-x86_64: Unsupported NIC model: e1000e $ qemu-system-x86_64 -M pc qemu-system-x86_64: Unsupported NIC model: e1000 Fixes: 7c28b925b7e Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190316200818.8265-4-philmd@redhat.com> --- hw/i386/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index 756b1eaef8..8e8444dbf9 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -18,6 +18,7 @@ config PC imply TEST_DEVICES imply TPM_CRB imply TPM_TIS + imply VGA_PCI select FDC select I8259 select I8254 @@ -47,6 +48,7 @@ config PC_ACPI config I440FX bool + imply E1000_PCI select PC_PCI select PC_ACPI select ACPI_SMBUS @@ -72,6 +74,7 @@ config Q35 bool imply VTD imply AMD_IOMMU + imply E1000E_PCI_EXPRESS select PC_PCI select PC_ACPI select PCI_EXPRESS_Q35 From 892da02848afa931ebe9d5892d651725f2ff0554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 16 Mar 2019 21:08:10 +0100 Subject: [PATCH 12/23] hw/mips/Kconfig: Malta machine requires the pcnet network card MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes when configuring with --without-default-devices: $ qemu-system-mips64 -bios /dev/null -M malta qemu-system-mips64: Unsupported NIC model: pcnet Fixes: 7c28b925b7e Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190316200818.8265-7-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- default-configs/mips-softmmu-common.mak | 1 + 1 file changed, 1 insertion(+) diff --git a/default-configs/mips-softmmu-common.mak b/default-configs/mips-softmmu-common.mak index 0795d522db..8e54a74b7a 100644 --- a/default-configs/mips-softmmu-common.mak +++ b/default-configs/mips-softmmu-common.mak @@ -35,6 +35,7 @@ CONFIG_MIPS_CPS=y CONFIG_MIPS_ITU=y CONFIG_R4K=y CONFIG_MALTA=y +CONFIG_PCNET_PCI=y CONFIG_MIPSSIM=y CONFIG_ACPI_SMBUS=y CONFIG_SMBUS_EEPROM=y From b5ea7070e56dc95dba4019b1dc6e830a6b06ab50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 16 Mar 2019 21:08:11 +0100 Subject: [PATCH 13/23] hw/mips/Kconfig: Fulong 2e board requires ati-vga/rtl8139 PCI devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes when configuring with --without-default-devices: $ qemu-system-mips64el -bios /dev/null -M fulong2e qemu-system-mips64el: Unknown device 'ati-vga' for bus 'PCI' Aborted (core dumped) (gdb) bt #0 0x00007ffff5a2753f in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007ffff5a11895 in __GI_abort () at abort.c:79 #2 0x00005555558768d3 in qdev_create (bus=bus@entry=0x5555562664b0, name=name@entry=0x555555b24efb "ati-vga") at hw/core/qdev.c:131 #3 0x00005555558d15e1 in pci_create_multifunction (bus=bus@entry=0x5555562664b0, devfn=devfn@entry=-1, multifunction=multifunction@entry=false, name=name@entry=0x555555b24efb "ati-vga") at hw/pci/pci.c:2104 #4 0x00005555558d1a7a in pci_create (bus=bus@entry=0x5555562664b0, devfn=devfn@entry=-1, name=name@entry=0x555555b24efb "ati-vga") at hw/pci/pci.c:2121 #5 0x0000555555763081 in mips_fulong2e_init (machine=) at hw/mips/mips_fulong2e.c:352 #6 0x000055555587e23b in machine_run_board_init (machine=0x5555560b2000) at hw/core/machine.c:1030 #7 0x00005555556cbea2 in main (argc=, argv=, envp=) at vl.c:4463 And then: $ qemu-system-mips64el -bios /dev/null -M fulong2e qemu-system-mips64el: Unsupported NIC model: rtl8139 Fixes: 862b4a291dc and 7c28b925b7e Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190316200818.8265-8-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- default-configs/mips64el-softmmu.mak | 2 ++ 1 file changed, 2 insertions(+) diff --git a/default-configs/mips64el-softmmu.mak b/default-configs/mips64el-softmmu.mak index 8b255efc54..a67c9517a2 100644 --- a/default-configs/mips64el-softmmu.mak +++ b/default-configs/mips64el-softmmu.mak @@ -6,6 +6,8 @@ CONFIG_RC4030=y CONFIG_DP8393X=y CONFIG_DS1225Y=y CONFIG_FULONG=y +CONFIG_ATI_VGA=y +CONFIG_RTL8139_PCI=y CONFIG_JAZZ=y CONFIG_G364FB=y CONFIG_JAZZ_LED=y From f7b5cdcbf27104d67d8ff860d83c22687f58eece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 16 Mar 2019 21:08:12 +0100 Subject: [PATCH 14/23] hw/ppc/Kconfig: Bamboo machine requires e1000 network card MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes when configuring with CONFIG_PCI_DEVICES=n: $ qemu-system-ppc64 -bios /dev/null -M bamboo qemu-system-ppc64: Unsupported NIC model: e1000 Fixes: 7c28b925b7e Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson Message-Id: <20190316200818.8265-9-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/ppc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index bbe5a64865..0024873fd9 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -37,6 +37,7 @@ config PPC440 bool imply PCI_DEVICES imply TEST_DEVICES + imply E1000_PCI select PCI_EXPRESS select PPC4XX select SERIAL From bcb7ef9d1b2f40410869ed2c1ffda769b2ef4ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 16 Mar 2019 21:08:13 +0100 Subject: [PATCH 15/23] hw/ppc/Kconfig: e500 based machines require virtio-net-pci device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes when configuring with CONFIG_PCI_DEVICES=n: $ qemu-system-ppc64 -bios /dev/null -M ppce500 qemu-system-ppc64: Unsupported NIC model: virtio-net-pci And: $ qemu-system-ppc64 -bios /dev/null -M mpc8544ds qemu-system-ppc64: Unsupported NIC model: virtio-net-pci Fixes: 98bd1db99f Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson Message-Id: <20190316200818.8265-10-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/ppc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index 0024873fd9..ae07b4da63 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -98,6 +98,7 @@ config MAC_NEWWORLD config E500 bool imply AT24C + imply VIRTIO_PCI select ETSEC select OPENPIC select PLATFORM_BUS From 364efd1a15de02a514188b930937cb04b7968432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 16 Mar 2019 21:08:16 +0100 Subject: [PATCH 16/23] hw/sh4/Kconfig: r2d machine requires the rtl8139 network card MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes when configuring with CONFIG_PCI_DEVICES=n: $ qemu-system-sh4 -M r2d qemu-system-sh4: Unsupported NIC model: rtl8139 Fixes: 7ab58d4c84 Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190316200818.8265-13-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/sh4/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/sh4/Kconfig b/hw/sh4/Kconfig index 8597613a35..593662d28a 100644 --- a/hw/sh4/Kconfig +++ b/hw/sh4/Kconfig @@ -2,6 +2,7 @@ config R2D bool imply PCI_DEVICES imply TEST_DEVICES + imply RTL8139_PCI select I82378 if TEST_DEVICES select IDE_MMIO select PFLASH_CFI02 From b6dbcdb7b3a1ed8f3df11129e61e8c05daaebbaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 16 Mar 2019 21:08:17 +0100 Subject: [PATCH 17/23] hw/hppa/Kconfig: Dino board requires e1000 network card MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes when configuring with CONFIG_PCI_DEVICES=n: $ qemu-system-hppa qemu-system-hppa: Unsupported NIC model: e1000 Fixes: 9483cf27dd Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190316200818.8265-14-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/hppa/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig index 2d9b072c21..7334f57081 100644 --- a/hw/hppa/Kconfig +++ b/hw/hppa/Kconfig @@ -1,6 +1,7 @@ config DINO bool imply PCI_DEVICES + imply E1000_PCI select PCI select SERIAL select ISA_BUS From 9ad4994661b8e478975475b37488973c5c15116f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 16 Mar 2019 21:08:18 +0100 Subject: [PATCH 18/23] hw/alpha/Kconfig: DP264 hardware requires e1000 network card MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes when configuring with CONFIG_PCI_DEVICES=n: $ qemu-system-alpha qemu-system-alpha: Unsupported NIC model: e1000 Fixes: d1a95ef4ac Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190316200818.8265-15-philmd@redhat.com> Signed-off-by: Paolo Bonzini --- hw/alpha/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/alpha/Kconfig b/hw/alpha/Kconfig index 22cefd9577..15c59ff264 100644 --- a/hw/alpha/Kconfig +++ b/hw/alpha/Kconfig @@ -2,6 +2,7 @@ config DP264 bool imply PCI_DEVICES imply TEST_DEVICES + imply E1000_PCI select I82374 select I8254 select I8259 From 8b159699d49bf340cad90a3291f6ce631ce58c8c Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 12 Mar 2019 17:31:30 +0100 Subject: [PATCH 19/23] test-announce-self: convert to qgraph This removes the duplicated initialization code. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Paolo Bonzini --- tests/Makefile.include | 3 -- tests/test-announce-self.c | 73 -------------------------------------- tests/virtio-net-test.c | 30 ++++++++++++++++ 3 files changed, 30 insertions(+), 76 deletions(-) delete mode 100644 tests/test-announce-self.c diff --git a/tests/Makefile.include b/tests/Makefile.include index 852f17b8c7..6b904d7430 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -195,7 +195,6 @@ check-qtest-i386-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF) check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF) check-qtest-i386-$(CONFIG_RTL8139_PCI) += tests/test-filter-redirector$(EXESUF) check-qtest-i386-y += tests/migration-test$(EXESUF) -check-qtest-i386-y += tests/test-announce-self$(EXESUF) check-qtest-i386-y += tests/test-x86-cpuid-compat$(EXESUF) check-qtest-i386-y += tests/numa-test$(EXESUF) check-qtest-x86_64-y += $(check-qtest-i386-y) @@ -232,7 +231,6 @@ check-qtest-ppc64-y += $(check-qtest-ppc-y) check-qtest-ppc64-$(CONFIG_PSERIES) += tests/device-plug-test$(EXESUF) check-qtest-ppc64-$(CONFIG_POWERNV) += tests/pnv-xscom-test$(EXESUF) check-qtest-ppc64-y += tests/migration-test$(EXESUF) -check-qtest-ppc64-y += tests/test-announce-self$(EXESUF) check-qtest-ppc64-$(CONFIG_PSERIES) += tests/rtas-test$(EXESUF) check-qtest-ppc64-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF) check-qtest-ppc64-$(CONFIG_USB_UHCI) += tests/usb-hcd-uhci-test$(EXESUF) @@ -817,7 +815,6 @@ tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-usb-obj-y) tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y) tests/cpu-plug-test$(EXESUF): tests/cpu-plug-test.o tests/migration-test$(EXESUF): tests/migration-test.o -tests/test-announce-self$(EXESUF): tests/test-announce-self.o tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o $(test-util-obj-y) tests/test-keyval$(EXESUF): tests/test-keyval.o $(test-util-obj-y) $(test-qapi-obj-y) diff --git a/tests/test-announce-self.c b/tests/test-announce-self.c deleted file mode 100644 index 0e6d466aa4..0000000000 --- a/tests/test-announce-self.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * QTest testcase for qemu_announce_self - * - * Copyright (c) 2017 Red hat, Inc. - * Copyright (c) 2014 SUSE LINUX Products GmbH - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#include "qemu/osdep.h" -#include "libqtest.h" -#include "qapi/qmp/qdict.h" -#include "qemu-common.h" -#include "qemu/sockets.h" -#include "qemu/iov.h" -#include "libqos/libqos-pc.h" -#include "libqos/libqos-spapr.h" - -#ifndef ETH_P_RARP -#define ETH_P_RARP 0x8035 -#endif - - -static void test_announce(QTestState *qs, int socket) -{ - char buffer[60]; - int len; - QDict *rsp; - int ret; - uint16_t *proto = (uint16_t *)&buffer[12]; - - rsp = qtest_qmp(qs, "{ 'execute' : 'announce-self', " - " 'arguments': {" - " 'initial': 50, 'max': 550," - " 'rounds': 10, 'step': 50 } }"); - assert(!qdict_haskey(rsp, "error")); - qobject_unref(rsp); - - /* Catch the packet and make sure it's a RARP */ - ret = qemu_recv(socket, &len, sizeof(len), 0); - g_assert_cmpint(ret, ==, sizeof(len)); - len = ntohl(len); - - ret = qemu_recv(socket, buffer, len, 0); - g_assert_cmpint(*proto, ==, htons(ETH_P_RARP)); -} - -static void setup(gconstpointer data) -{ - QTestState *qs; - void (*func) (QTestState *qs, int socket) = data; - int sv[2], ret; - - ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sv); - g_assert_cmpint(ret, !=, -1); - - qs = qtest_initf("-netdev socket,fd=%d,id=hs0 -device " - "virtio-net-pci,netdev=hs0", sv[1]); - func(qs, sv[0]); - - /* End test */ - close(sv[0]); - qtest_quit(qs); -} - -int main(int argc, char **argv) -{ - g_test_init(&argc, &argv, NULL); - qtest_add_data_func("/virtio/net/test_announce_self", test_announce, setup); - - return g_test_run(); -} diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index c58e670e2f..0d956f36fe 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -15,6 +15,10 @@ #include "libqos/qgraph.h" #include "libqos/virtio-net.h" +#ifndef ETH_P_RARP +#define ETH_P_RARP 0x8035 +#endif + #define PCI_SLOT_HP 0x06 #define PCI_SLOT 0x04 @@ -168,6 +172,31 @@ static void hotplug(void *obj, void *data, QGuestAllocator *t_alloc) } } +static void announce_self(void *obj, void *data, QGuestAllocator *t_alloc) +{ + int *sv = data; + char buffer[60]; + int len; + QDict *rsp; + int ret; + uint16_t *proto = (uint16_t *)&buffer[12]; + + rsp = qmp("{ 'execute' : 'announce-self', " + " 'arguments': {" + " 'initial': 50, 'max': 550," + " 'rounds': 10, 'step': 50 } }"); + assert(!qdict_haskey(rsp, "error")); + qobject_unref(rsp); + + /* Catch the packet and make sure it's a RARP */ + ret = qemu_recv(sv[0], &len, sizeof(len), 0); + g_assert_cmpint(ret, ==, sizeof(len)); + len = ntohl(len); + + ret = qemu_recv(sv[0], buffer, len, 0); + g_assert_cmpint(*proto, ==, htons(ETH_P_RARP)); +} + static void virtio_net_test_cleanup(void *sockets) { int *sv = sockets; @@ -233,6 +262,7 @@ static void register_virtio_net_test(void) qos_add_test("basic", "virtio-net", send_recv_test, &opts); qos_add_test("rx_stop_cont", "virtio-net", stop_cont_test, &opts); #endif + qos_add_test("announce-self", "virtio-net", announce_self, &opts); /* These tests do not need a loopback backend. */ opts.before = virtio_net_test_setup_nosocket; From 4b519ef1de9a7cb8123abadab9e6c5697373087c Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Wed, 13 Mar 2019 17:43:23 +0800 Subject: [PATCH 20/23] intel-iommu: optimize nodmar memory regions Previously we have per-device system memory aliases when DMAR is disabled by the system. It will slow the system down if there are lots of devices especially when DMAR is disabled, because each of the aliased system address space will contain O(N) slots, and rendering such N address spaces will be O(N^2) complexity. This patch introduces a shared nodmar memory region and for each device we only create an alias to the shared memory region. With the aliasing, QEMU memory core API will be able to detect when devices are sharing the same address space (which is the nodmar address space) when rendering the FlatViews and the total number of FlatViews can be dramatically reduced when there are a lot of devices. Suggested-by: Paolo Bonzini Signed-off-by: Peter Xu Message-Id: <20190313094323.18263-1-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/intel_iommu.c | 93 ++++++++++++++++++++++------------- include/hw/i386/intel_iommu.h | 7 ++- 2 files changed, 64 insertions(+), 36 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index b90de6c664..055a1e865d 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1485,11 +1485,11 @@ static bool vtd_switch_address_space(VTDAddressSpace *as) /* Turn off first then on the other */ if (use_iommu) { - memory_region_set_enabled(&as->sys_alias, false); + memory_region_set_enabled(&as->nodmar, false); memory_region_set_enabled(MEMORY_REGION(&as->iommu), true); } else { memory_region_set_enabled(MEMORY_REGION(&as->iommu), false); - memory_region_set_enabled(&as->sys_alias, true); + memory_region_set_enabled(&as->nodmar, true); } if (take_bql) { @@ -3286,7 +3286,8 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) vtd_dev_as = vtd_bus->dev_as[devfn]; if (!vtd_dev_as) { - snprintf(name, sizeof(name), "intel_iommu_devfn_%d", devfn); + snprintf(name, sizeof(name), "vtd-%02x.%x", PCI_SLOT(devfn), + PCI_FUNC(devfn)); vtd_bus->dev_as[devfn] = vtd_dev_as = g_malloc0(sizeof(VTDAddressSpace)); vtd_dev_as->bus = bus; @@ -3295,44 +3296,53 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) vtd_dev_as->context_cache_entry.context_cache_gen = 0; vtd_dev_as->iova_tree = iova_tree_new(); + memory_region_init(&vtd_dev_as->root, OBJECT(s), name, UINT64_MAX); + address_space_init(&vtd_dev_as->as, &vtd_dev_as->root, "vtd-root"); + /* - * Memory region relationships looks like (Address range shows - * only lower 32 bits to make it short in length...): - * - * |-----------------+-------------------+----------| - * | Name | Address range | Priority | - * |-----------------+-------------------+----------+ - * | vtd_root | 00000000-ffffffff | 0 | - * | intel_iommu | 00000000-ffffffff | 1 | - * | vtd_sys_alias | 00000000-ffffffff | 1 | - * | intel_iommu_ir | fee00000-feefffff | 64 | - * |-----------------+-------------------+----------| - * - * We enable/disable DMAR by switching enablement for - * vtd_sys_alias and intel_iommu regions. IR region is always - * enabled. + * Build the DMAR-disabled container with aliases to the + * shared MRs. Note that aliasing to a shared memory region + * could help the memory API to detect same FlatViews so we + * can have devices to share the same FlatView when DMAR is + * disabled (either by not providing "intel_iommu=on" or with + * "iommu=pt"). It will greatly reduce the total number of + * FlatViews of the system hence VM runs faster. */ + memory_region_init_alias(&vtd_dev_as->nodmar, OBJECT(s), + "vtd-nodmar", &s->mr_nodmar, 0, + memory_region_size(&s->mr_nodmar)); + + /* + * Build the per-device DMAR-enabled container. + * + * TODO: currently we have per-device IOMMU memory region only + * because we have per-device IOMMU notifiers for devices. If + * one day we can abstract the IOMMU notifiers out of the + * memory regions then we can also share the same memory + * region here just like what we've done above with the nodmar + * region. + */ + strcat(name, "-dmar"); memory_region_init_iommu(&vtd_dev_as->iommu, sizeof(vtd_dev_as->iommu), TYPE_INTEL_IOMMU_MEMORY_REGION, OBJECT(s), - "intel_iommu_dmar", - UINT64_MAX); - memory_region_init_alias(&vtd_dev_as->sys_alias, OBJECT(s), - "vtd_sys_alias", get_system_memory(), - 0, memory_region_size(get_system_memory())); - memory_region_init_io(&vtd_dev_as->iommu_ir, OBJECT(s), - &vtd_mem_ir_ops, s, "intel_iommu_ir", - VTD_INTERRUPT_ADDR_SIZE); - memory_region_init(&vtd_dev_as->root, OBJECT(s), - "vtd_root", UINT64_MAX); - memory_region_add_subregion_overlap(&vtd_dev_as->root, + name, UINT64_MAX); + memory_region_init_alias(&vtd_dev_as->iommu_ir, OBJECT(s), "vtd-ir", + &s->mr_ir, 0, memory_region_size(&s->mr_ir)); + memory_region_add_subregion_overlap(MEMORY_REGION(&vtd_dev_as->iommu), VTD_INTERRUPT_ADDR_FIRST, - &vtd_dev_as->iommu_ir, 64); - address_space_init(&vtd_dev_as->as, &vtd_dev_as->root, name); - memory_region_add_subregion_overlap(&vtd_dev_as->root, 0, - &vtd_dev_as->sys_alias, 1); + &vtd_dev_as->iommu_ir, 1); + + /* + * Hook both the containers under the root container, we + * switch between DMAR & noDMAR by enable/disable + * corresponding sub-containers + */ memory_region_add_subregion_overlap(&vtd_dev_as->root, 0, MEMORY_REGION(&vtd_dev_as->iommu), - 1); + 0); + memory_region_add_subregion_overlap(&vtd_dev_as->root, 0, + &vtd_dev_as->nodmar, 0); + vtd_switch_address_space(vtd_dev_as); } return vtd_dev_as; @@ -3676,6 +3686,21 @@ static void vtd_realize(DeviceState *dev, Error **errp) memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num)); memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s, "intel_iommu", DMAR_REG_SIZE); + + /* Create the shared memory regions by all devices */ + memory_region_init(&s->mr_nodmar, OBJECT(s), "vtd-nodmar", + UINT64_MAX); + memory_region_init_io(&s->mr_ir, OBJECT(s), &vtd_mem_ir_ops, + s, "vtd-ir", VTD_INTERRUPT_ADDR_SIZE); + memory_region_init_alias(&s->mr_sys_alias, OBJECT(s), + "vtd-sys-alias", get_system_memory(), 0, + memory_region_size(get_system_memory())); + memory_region_add_subregion_overlap(&s->mr_nodmar, 0, + &s->mr_sys_alias, 0); + memory_region_add_subregion_overlap(&s->mr_nodmar, + VTD_INTERRUPT_ADDR_FIRST, + &s->mr_ir, 1); + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem); /* No corresponding destroy */ s->iotlb = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal, diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index c11e3d5b34..536f62667b 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -105,8 +105,8 @@ struct VTDAddressSpace { uint8_t devfn; AddressSpace as; IOMMUMemoryRegion iommu; - MemoryRegion root; - MemoryRegion sys_alias; + MemoryRegion root; /* The root container of the device */ + MemoryRegion nodmar; /* The alias of shared nodmar MR */ MemoryRegion iommu_ir; /* Interrupt region: 0xfeeXXXXX */ IntelIOMMUState *iommu_state; VTDContextCacheEntry context_cache_entry; @@ -221,6 +221,9 @@ union VTD_IR_MSIAddress { struct IntelIOMMUState { X86IOMMUState x86_iommu; MemoryRegion csrmem; + MemoryRegion mr_nodmar; + MemoryRegion mr_ir; + MemoryRegion mr_sys_alias; uint8_t csr[DMAR_REG_SIZE]; /* register values */ uint8_t wmask[DMAR_REG_SIZE]; /* R/W bytes */ uint8_t w1cmask[DMAR_REG_SIZE]; /* RW1C(Write 1 to Clear) bytes */ From 67163caebaff04d82f7080da902663780e29e74c Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 12 Mar 2019 17:48:48 +0100 Subject: [PATCH 21/23] minikconf: fix parser typo The result of this typo would be that "select_foo" would be treated as a "select" keyword followed by "_foo". Nothing too bad, but easy to fix so let's be clean. Signed-off-by: Paolo Bonzini --- scripts/minikconf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/minikconf.py b/scripts/minikconf.py index 5421db0ed0..0ffc6c38da 100644 --- a/scripts/minikconf.py +++ b/scripts/minikconf.py @@ -592,7 +592,7 @@ class KconfigParser: if not self.src.startswith(rest, self.cursor): return False length = len(rest) - if self.src[self.cursor + length].isalnum() or self.src[self.cursor + length] == '|': + if self.src[self.cursor + length].isalnum() or self.src[self.cursor + length] == '_': return False self.cursor += length return True From b7c11e574977a0addfbbdb89377c6f52affe64ec Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Mar 2019 11:51:14 +0100 Subject: [PATCH 22/23] config-all-devices.mak: rebuild on reconfigure This ensures that softmmu directories are culled after a "./configure --target-list=x86_64-linux-user". Reviewed-by: Stefano Garzarella Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dbb8e136a3..04a0d45050 100644 --- a/Makefile +++ b/Makefile @@ -331,10 +331,10 @@ SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(filter %-softmmu, $(TAR SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %.d, $(SUBDIR_DEVICES_MAK)) ifeq ($(SUBDIR_DEVICES_MAK),) -config-all-devices.mak: +config-all-devices.mak: config-host.mak $(call quiet-command,echo '# no devices' > $@,"GEN","$@") else -config-all-devices.mak: $(SUBDIR_DEVICES_MAK) +config-all-devices.mak: $(SUBDIR_DEVICES_MAK) config-host.mak $(call quiet-command, sed -n \ 's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \ $(SUBDIR_DEVICES_MAK) | sort -u > $@, \ From 938912a866114deb5660c93907a80635b16e5807 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 21 Mar 2019 15:29:50 +0100 Subject: [PATCH 23/23] virtio-vga: only enable for specific boards When virtio-vga was added, the intention was to only support it for those machines where the firmware does not know about virtio-gpu, and supported VGA legacy hardware before virtio-{gpu,vga} were introduced. The Kconfig switch however enabled virtio-vga for all machines with a PCI bus, and libvirt then prefers it even on hardware where virtio-gpu would be preferrable. At least for now, only enable virtio-vga for PC, hppa and pSeries machines, as was the case before Kconfig dependencies were introduced. Reported-by: Laszlo Ersek Reviewed-by: Thomas Huth Signed-off-by: Paolo Bonzini --- hw/display/Kconfig | 2 +- hw/hppa/Kconfig | 1 + hw/i386/Kconfig | 1 + hw/ppc/Kconfig | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/display/Kconfig b/hw/display/Kconfig index 86c1d544c5..72be57a403 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -100,7 +100,7 @@ config VIRTIO_GPU config VIRTIO_VGA bool - default y if PCI_DEVICES + # defaults to "N", enabled by specific boards depends on VIRTIO_PCI select VGA diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig index 7334f57081..6e5d74a825 100644 --- a/hw/hppa/Kconfig +++ b/hw/hppa/Kconfig @@ -2,6 +2,7 @@ config DINO bool imply PCI_DEVICES imply E1000_PCI + imply VIRTIO_VGA select PCI select SERIAL select ISA_BUS diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index 8e8444dbf9..a6aed7c131 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -19,6 +19,7 @@ config PC imply TPM_CRB imply TPM_TIS imply VGA_PCI + imply VIRTIO_VGA select FDC select I8259 select I8254 diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index ae07b4da63..a3465155f0 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -2,6 +2,7 @@ config PSERIES bool imply PCI_DEVICES imply TEST_DEVICES + imply VIRTIO_VGA select DIMM select PCI select SPAPR_VSCSI