diff options
-rw-r--r-- | contrib/vhost-user-gpu/main.c | 29 | ||||
-rw-r--r-- | contrib/vhost-user-input/main.c | 12 | ||||
-rw-r--r-- | docs/interop/vhost-user.json | 6 | ||||
-rw-r--r-- | hw/acpi/Makefile.objs | 2 | ||||
-rw-r--r-- | hw/acpi/utils.c | 35 | ||||
-rw-r--r-- | hw/arm/virt-acpi-build.c | 26 | ||||
-rw-r--r-- | hw/i386/acpi-build.c | 40 | ||||
-rw-r--r-- | hw/pci-host/q35.c | 31 | ||||
-rw-r--r-- | hw/virtio/vhost.c | 10 | ||||
-rw-r--r-- | include/hw/acpi/utils.h | 9 | ||||
-rw-r--r-- | tests/data/acpi/q35/DSDT | bin | 7815 -> 7841 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.bridge | bin | 7832 -> 7858 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.cphp | bin | 8278 -> 8304 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.dimmpxm | bin | 9468 -> 9494 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.ipmibt | bin | 7890 -> 7916 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.memhp | bin | 9174 -> 9200 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.mmio64 | bin | 8945 -> 8971 bytes | |||
-rw-r--r-- | tests/data/acpi/q35/DSDT.numamem | bin | 7821 -> 7847 bytes | |||
-rwxr-xr-x | tests/data/acpi/rebuild-expected-aml.sh | 3 |
19 files changed, 127 insertions, 76 deletions
diff --git a/contrib/vhost-user-gpu/main.c b/contrib/vhost-user-gpu/main.c index f9e2146b69..04b753046f 100644 --- a/contrib/vhost-user-gpu/main.c +++ b/contrib/vhost-user-gpu/main.c @@ -138,22 +138,20 @@ static int vg_sock_fd_write(int sock, const void *buf, ssize_t buflen, int fd) { ssize_t ret; - struct msghdr msg; - struct iovec iov; + struct iovec iov = { + .iov_base = (void *)buf, + .iov_len = buflen, + }; + struct msghdr msg = { + .msg_iov = &iov, + .msg_iovlen = 1, + }; union { struct cmsghdr cmsghdr; char control[CMSG_SPACE(sizeof(int))]; } cmsgu; struct cmsghdr *cmsg; - iov.iov_base = (void *)buf; - iov.iov_len = buflen; - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - if (fd != -1) { msg.msg_control = cmsgu.control; msg.msg_controllen = sizeof(cmsgu.control); @@ -164,9 +162,6 @@ vg_sock_fd_write(int sock, const void *buf, ssize_t buflen, int fd) cmsg->cmsg_type = SCM_RIGHTS; *((int *)CMSG_DATA(cmsg)) = fd; - } else { - msg.msg_control = NULL; - msg.msg_controllen = 0; } do { @@ -354,7 +349,7 @@ vg_disable_scanout(VuGpu *g, int scanout_id) scanout->width = 0; scanout->height = 0; - { + if (g->sock_fd >= 0) { VhostUserGpuMsg msg = { .request = VHOST_USER_GPU_SCANOUT, .size = sizeof(VhostUserGpuScanout), @@ -1160,13 +1155,17 @@ main(int argc, char *argv[]) if (opt_socket_path) { int lsock = unix_listen(opt_socket_path, &error_fatal); + if (lsock < 0) { + g_printerr("Failed to listen on %s.\n", opt_socket_path); + exit(EXIT_FAILURE); + } fd = accept(lsock, NULL, NULL); close(lsock); } else { fd = opt_fdnum; } if (fd == -1) { - g_printerr("Invalid socket"); + g_printerr("Invalid vhost-user socket.\n"); exit(EXIT_FAILURE); } diff --git a/contrib/vhost-user-input/main.c b/contrib/vhost-user-input/main.c index 8d493f598e..8b4e7d2536 100644 --- a/contrib/vhost-user-input/main.c +++ b/contrib/vhost-user-input/main.c @@ -342,7 +342,11 @@ main(int argc, char *argv[]) vi.config = g_array_new(false, false, sizeof(virtio_input_config)); memset(&id, 0, sizeof(id)); - ioctl(vi.evdevfd, EVIOCGNAME(sizeof(id.u.string) - 1), id.u.string); + if (ioctl(vi.evdevfd, EVIOCGNAME(sizeof(id.u.string) - 1), + id.u.string) < 0) { + g_printerr("Failed to get evdev name: %s\n", g_strerror(errno)); + exit(EXIT_FAILURE); + } id.select = VIRTIO_INPUT_CFG_ID_NAME; id.size = strlen(id.u.string); g_array_append_val(vi.config, id); @@ -367,13 +371,17 @@ main(int argc, char *argv[]) if (opt_socket_path) { int lsock = unix_listen(opt_socket_path, &error_fatal); + if (lsock < 0) { + g_printerr("Failed to listen on %s.\n", opt_socket_path); + exit(EXIT_FAILURE); + } fd = accept(lsock, NULL, NULL); close(lsock); } else { fd = opt_fdnum; } if (fd == -1) { - g_printerr("Invalid socket"); + g_printerr("Invalid vhost-user socket.\n"); exit(EXIT_FAILURE); } vug_init(&vi.dev, fd, vi_panic, &vuiface); diff --git a/docs/interop/vhost-user.json b/docs/interop/vhost-user.json index ae88c03117..da6aaf51c8 100644 --- a/docs/interop/vhost-user.json +++ b/docs/interop/vhost-user.json @@ -178,11 +178,11 @@ # # - /usr/share/qemu/vhost-user/50-crosvm-gpu.json # -# then the sysadmin can prevent the default QEMU being used at all with +# then the sysadmin can prevent the default QEMU GPU being used at all with # # $ touch /etc/qemu/vhost-user/50-qemu-gpu.json # -# The sysadmin can replace/alter the distro default OVMF with +# The sysadmin can replace/alter the distro default QEMU GPU with # # $ vim /etc/qemu/vhost-user/50-qemu-gpu.json # @@ -190,7 +190,7 @@ # # $ vim /etc/qemu/vhost-user/10-qemu-gpu.json # -# or they can provide a parallel OVMF with lower priority +# or they can provide a parallel QEMU GPU with lower priority # # $ vim /etc/qemu/vhost-user/99-qemu-gpu.json # diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 661a9b8c2f..9bb2101e3b 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o common-obj-y += acpi_interface.o common-obj-y += bios-linker-loader.o -common-obj-y += aml-build.o +common-obj-y += aml-build.o utils.o common-obj-$(CONFIG_ACPI_PCI) += pci.o common-obj-$(CONFIG_TPM) += tpm.o diff --git a/hw/acpi/utils.c b/hw/acpi/utils.c new file mode 100644 index 0000000000..a134a4d554 --- /dev/null +++ b/hw/acpi/utils.c @@ -0,0 +1,35 @@ +/* + * Utilities for generating ACPI tables and passing them to Guests + * + * Copyright (C) 2019 Intel Corporation + * Copyright (C) 2019 Red Hat Inc + * + * Author: Wei Yang <richardw.yang@linux.intel.com> + * Author: Michael S. Tsirkin <mst@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/acpi/aml-build.h" +#include "hw/acpi/utils.h" +#include "hw/loader.h" + +MemoryRegion *acpi_add_rom_blob(FWCfgCallback update, void *opaque, + GArray *blob, const char *name, + uint64_t max_size) +{ + return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1, + name, update, opaque, NULL, true); +} diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 9e8b84988d..0afb372769 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -36,9 +36,9 @@ #include "hw/acpi/acpi.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/hw.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "hw/acpi/pci.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" @@ -865,14 +865,6 @@ static void virt_acpi_build_reset(void *build_opaque) build_state->patched = false; } -static MemoryRegion *acpi_add_rom_blob(AcpiBuildState *build_state, - GArray *blob, const char *name, - uint64_t max_size) -{ - return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1, - name, virt_acpi_build_update, build_state, NULL, true); -} - static const VMStateDescription vmstate_virt_acpi_build = { .name = "virt_acpi_build", .version_id = 1, @@ -904,20 +896,22 @@ void virt_acpi_setup(VirtMachineState *vms) virt_acpi_build(vms, &tables); /* Now expose it all to Guest */ - build_state->table_mr = acpi_add_rom_blob(build_state, tables.table_data, - ACPI_BUILD_TABLE_FILE, - ACPI_BUILD_TABLE_MAX_SIZE); + build_state->table_mr = acpi_add_rom_blob(virt_acpi_build_update, + build_state, tables.table_data, + ACPI_BUILD_TABLE_FILE, + ACPI_BUILD_TABLE_MAX_SIZE); assert(build_state->table_mr != NULL); build_state->linker_mr = - acpi_add_rom_blob(build_state, tables.linker->cmd_blob, - "etc/table-loader", 0); + acpi_add_rom_blob(virt_acpi_build_update, build_state, + tables.linker->cmd_blob, "etc/table-loader", 0); fw_cfg_add_file(vms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->data, acpi_data_len(tables.tcpalog)); - build_state->rsdp_mr = acpi_add_rom_blob(build_state, tables.rsdp, - ACPI_BUILD_RSDP_FILE, 0); + build_state->rsdp_mr = acpi_add_rom_blob(virt_acpi_build_update, + build_state, tables.rsdp, + ACPI_BUILD_RSDP_FILE, 0); qemu_register_reset(virt_acpi_build_reset, build_state); virt_acpi_build_reset(build_state); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 45c369c923..31a1c1e3ad 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -37,7 +37,6 @@ #include "hw/acpi/piix4.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/isa/isa.h" #include "hw/block/fdc.h" #include "hw/acpi/memory_hotplug.h" @@ -58,6 +57,7 @@ #include "hw/i386/x86-iommu.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "hw/acpi/pci.h" #include "qom/qom-qobject.h" @@ -121,6 +121,8 @@ typedef struct FwCfgTPMConfig { uint8_t tpmppi_version; } QEMU_PACKED FwCfgTPMConfig; +static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg); + static void init_common_fadt_data(Object *o, AcpiFadtData *data) { uint32_t io = object_property_get_uint(o, ACPI_PM_PROP_PM_IO_BASE, NULL); @@ -1806,6 +1808,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, CrsRangeSet crs_range_set; PCMachineState *pcms = PC_MACHINE(machine); PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine); + AcpiMcfgInfo mcfg; uint32_t nr_mem = machine->ram_slots; int root_bus_limit = 0xFF; PCIBus *bus = NULL; @@ -1920,6 +1923,17 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, } } + /* + * At this point crs_range_set has all the ranges used by pci + * busses *other* than PCI0. These ranges will be excluded from + * the PCI0._CRS. Add mmconfig to the set so it will be excluded + * too. + */ + if (acpi_get_mcfg(&mcfg)) { + crs_range_insert(crs_range_set.mem_ranges, + mcfg.base, mcfg.base + mcfg.size - 1); + } + scope = aml_scope("\\_SB.PCI0"); /* build PCI0._CRS */ crs = aml_resource_template(); @@ -2823,14 +2837,6 @@ static void acpi_build_reset(void *build_opaque) build_state->patched = 0; } -static MemoryRegion *acpi_add_rom_blob(AcpiBuildState *build_state, - GArray *blob, const char *name, - uint64_t max_size) -{ - return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1, - name, acpi_build_update, build_state, NULL, true); -} - static const VMStateDescription vmstate_acpi_build = { .name = "acpi_build", .version_id = 1, @@ -2872,14 +2878,15 @@ void acpi_setup(void) acpi_build(&tables, MACHINE(pcms)); /* Now expose it all to Guest */ - build_state->table_mr = acpi_add_rom_blob(build_state, tables.table_data, - ACPI_BUILD_TABLE_FILE, - ACPI_BUILD_TABLE_MAX_SIZE); + build_state->table_mr = acpi_add_rom_blob(acpi_build_update, + build_state, tables.table_data, + ACPI_BUILD_TABLE_FILE, + ACPI_BUILD_TABLE_MAX_SIZE); assert(build_state->table_mr != NULL); build_state->linker_mr = - acpi_add_rom_blob(build_state, tables.linker->cmd_blob, - "etc/table-loader", 0); + acpi_add_rom_blob(acpi_build_update, build_state, + tables.linker->cmd_blob, "etc/table-loader", 0); fw_cfg_add_file(pcms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->data, acpi_data_len(tables.tcpalog)); @@ -2916,8 +2923,9 @@ void acpi_setup(void) build_state->rsdp_mr = NULL; } else { build_state->rsdp = NULL; - build_state->rsdp_mr = acpi_add_rom_blob(build_state, tables.rsdp, - ACPI_BUILD_RSDP_FILE, 0); + build_state->rsdp_mr = acpi_add_rom_blob(acpi_build_update, + build_state, tables.rsdp, + ACPI_BUILD_RSDP_FILE, 0); } qemu_register_reset(acpi_build_reset, build_state); diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 172b0bc435..0a010be4cf 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -260,15 +260,6 @@ static void q35_host_initfn(Object *obj) object_property_add_link(obj, MCH_HOST_PROP_IO_MEM, TYPE_MEMORY_REGION, (Object **) &s->mch.address_space_io, qdev_prop_allow_set_link_before_realize, 0, NULL); - - /* Leave enough space for the biggest MCFG BAR */ - /* TODO: this matches current bios behaviour, but - * it's not a power of two, which means an MTRR - * can't cover it exactly. - */ - range_set_bounds(&s->mch.pci_hole, - MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT + MCH_HOST_BRIDGE_PCIEXBAR_MAX, - IO_APIC_DEFAULT_ADDRESS - 1); } static const TypeInfo q35_host_info = { @@ -340,20 +331,6 @@ static void mch_update_pciexbar(MCHPCIState *mch) } addr = pciexbar & addr_mask; pcie_host_mmcfg_update(pehb, enable, addr, length); - /* Leave enough space for the MCFG BAR */ - /* - * TODO: this matches current bios behaviour, but it's not a power of two, - * which means an MTRR can't cover it exactly. - */ - if (enable) { - range_set_bounds(&mch->pci_hole, - addr + length, - IO_APIC_DEFAULT_ADDRESS - 1); - } else { - range_set_bounds(&mch->pci_hole, - MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT, - IO_APIC_DEFAULT_ADDRESS - 1); - } } /* PAM */ @@ -486,6 +463,14 @@ static void mch_update(MCHPCIState *mch) mch_update_pam(mch); mch_update_smram(mch); mch_update_ext_tseg_mbytes(mch); + + /* + * pci hole goes from end-of-low-ram to io-apic. + * mmconfig will be excluded by the dsdt builder. + */ + range_set_bounds(&mch->pci_hole, + mch->below_4g_mem_size, + IO_APIC_DEFAULT_ADDRESS - 1); } static int mch_post_load(void *opaque, int version_id) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 60747a6f93..bc899fc60e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -131,6 +131,11 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev, } for (i = 0; i < dev->nvqs; ++i) { struct vhost_virtqueue *vq = dev->vqs + i; + + if (!vq->used_phys && !vq->used_size) { + continue; + } + vhost_dev_sync_region(dev, section, start_addr, end_addr, vq->used_phys, range_get_last(vq->used_phys, vq->used_size)); } @@ -168,6 +173,11 @@ static uint64_t vhost_get_log_size(struct vhost_dev *dev) } for (i = 0; i < dev->nvqs; ++i) { struct vhost_virtqueue *vq = dev->vqs + i; + + if (!vq->used_phys && !vq->used_size) { + continue; + } + uint64_t last = vq->used_phys + vq->used_size - 1; log_size = MAX(log_size, last / VHOST_LOG_CHUNK + 1); } diff --git a/include/hw/acpi/utils.h b/include/hw/acpi/utils.h new file mode 100644 index 0000000000..140b4de603 --- /dev/null +++ b/include/hw/acpi/utils.h @@ -0,0 +1,9 @@ +#ifndef HW_ACPI_UTILS_H +#define HW_ACPI_UTILS_H + +#include "hw/nvram/fw_cfg.h" + +MemoryRegion *acpi_add_rom_blob(FWCfgCallback update, void *opaque, + GArray *blob, const char *name, + uint64_t max_size); +#endif diff --git a/tests/data/acpi/q35/DSDT b/tests/data/acpi/q35/DSDT Binary files differindex 7576ffcd05..f9f36d1645 100644 --- a/tests/data/acpi/q35/DSDT +++ b/tests/data/acpi/q35/DSDT diff --git a/tests/data/acpi/q35/DSDT.bridge b/tests/data/acpi/q35/DSDT.bridge Binary files differindex c623cc5d72..29176832ca 100644 --- a/tests/data/acpi/q35/DSDT.bridge +++ b/tests/data/acpi/q35/DSDT.bridge diff --git a/tests/data/acpi/q35/DSDT.cphp b/tests/data/acpi/q35/DSDT.cphp Binary files differindex 7ac526e466..19bdb5d210 100644 --- a/tests/data/acpi/q35/DSDT.cphp +++ b/tests/data/acpi/q35/DSDT.cphp diff --git a/tests/data/acpi/q35/DSDT.dimmpxm b/tests/data/acpi/q35/DSDT.dimmpxm Binary files differindex 7177116a21..727fe489b4 100644 --- a/tests/data/acpi/q35/DSDT.dimmpxm +++ b/tests/data/acpi/q35/DSDT.dimmpxm diff --git a/tests/data/acpi/q35/DSDT.ipmibt b/tests/data/acpi/q35/DSDT.ipmibt Binary files differindex c7f431f058..9634930e61 100644 --- a/tests/data/acpi/q35/DSDT.ipmibt +++ b/tests/data/acpi/q35/DSDT.ipmibt diff --git a/tests/data/acpi/q35/DSDT.memhp b/tests/data/acpi/q35/DSDT.memhp Binary files differindex 0235461391..dad5dc8db2 100644 --- a/tests/data/acpi/q35/DSDT.memhp +++ b/tests/data/acpi/q35/DSDT.memhp diff --git a/tests/data/acpi/q35/DSDT.mmio64 b/tests/data/acpi/q35/DSDT.mmio64 Binary files differindex f60ee77fb4..20f627ed08 100644 --- a/tests/data/acpi/q35/DSDT.mmio64 +++ b/tests/data/acpi/q35/DSDT.mmio64 diff --git a/tests/data/acpi/q35/DSDT.numamem b/tests/data/acpi/q35/DSDT.numamem Binary files differindex 6c0d4f2bcb..7b96a97280 100644 --- a/tests/data/acpi/q35/DSDT.numamem +++ b/tests/data/acpi/q35/DSDT.numamem diff --git a/tests/data/acpi/rebuild-expected-aml.sh b/tests/data/acpi/rebuild-expected-aml.sh index d2853218dd..f89d4624bc 100755 --- a/tests/data/acpi/rebuild-expected-aml.sh +++ b/tests/data/acpi/rebuild-expected-aml.sh @@ -29,5 +29,8 @@ for qemu in $qemu_bins; do TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test done +eval `grep SRC_PATH= config-host.mak` + +echo '/* List of comma-separated changed AML files to ignore */' > ${SRC_PATH}/tests/bios-tables-test-allowed-diff.h echo "The files were rebuilt and can be added to git." |