pci, pc, virtio: fixes, features
Subsystems (2)
Changes from v1:
- fix an out of tree build by unmangling a patch I mangled when applying
- fix a gcc 8 build by applying philippe's patches
The following changes since commit 89bd861c2b470e3fb45596945509079c72af3ac2:
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging (2019-01-14 17:35:00 +0000)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
for you to fetch changes up to 64ed76db175f7ccb5f47195a7617d0106bf01245:
migration: Use strnlen() for fixed-size string (2019-01-15 14:56:57 -0500)
----------------------------------------------------------------
pci, pc, virtio: fixes, features
tpm physical presence interface
rsc support in virtio net
ivshmem is removed
misc cleanups and fixes all over the place
----------------------------------------------------------------
David Hildenbrand (1):
pci/pcie: stop plug/unplug if the slot is locked
Dongli Zhang (1):
msix: make pba size math more uniform
Eduardo Habkost (2):
globals: Allow global properties to be optional
virtio: Make disable-legacy/disable-modern compat properties optional
Fei Li (1):
hw/misc/edu: add msi_uninit() for pci_edu_uninit()
Igor Mammedov (8):
tests: acpi: use AcpiSdtTable::aml in consistent way
tests: acpi: make sure FADT is fetched only once
tests: acpi: simplify rsdt handling
tests: acpi: reuse fetch_table() for fetching FACS and DSDT
tests: acpi: reuse fetch_table() in vmgenid-test
tests: smbios: fetch whole table in one step instead of reading it step by step
tests: acpi: squash sanitize_fadt_ptrs() into test_acpi_fadt_table()
tests: acpi: use AcpiSdtTable::aml instead of AcpiSdtTable::header::signature
Jian Wang (1):
qemu: avoid memory leak while remove disk
Juan Quintela (16):
virtio: split vhost vsock bits from virtio-pci
virtio: split virtio input host bits from virtio-pci
virtio: split virtio input bits from virtio-pci
virtio: split virtio rng bits from virtio-pci
virtio: split virtio balloon bits from virtio-pci
virtio: split virtio 9p bits from virtio-pci
virtio: split vhost user blk bits from virtio-pci
virtio: split vhost user scsi bits from virtio-pci
virtio: split vhost scsi bits from virtio-pci
virtio: split virtio scsi bits from virtio-pci
virtio: split virtio blk bits from virtio-pci
virtio: split virtio net bits from virtio-pci
virtio: split virtio serial bits from virtio-pci
virtio: split virtio gpu bits from virtio-pci.h
virtio: split virtio crypto bits from virtio-pci.h
virtio: virtio 9p really requires CONFIG_VIRTFS to work
Li Qiang (3):
tests: vhost-user-test: initialize 'fd' in chr_read
vhost-user: fix ioeventfd_enabled
util: check the return value of fcntl in qemu_set_{block, nonblock}
Marc-André Lureau (4):
tpm: add a "ppi" boolean property
acpi: add ACPI memory clear interface
tpm: clear RAM when "memory overwrite" requested
migration: Fix stringop-truncation warning
Michael S. Tsirkin (1):
acpi: update expected files
Philippe Mathieu-Daudé (4):
qemu/compiler: Define QEMU_NONSTRING
block/sheepdog: Use QEMU_NONSTRING for non NUL-terminated arrays hw/acpi: Use QEMU_NONSTRING for non NUL-terminated arrays
migration: Use strnlen() for fixed-size string
Stefan Berger (3):
tpm: allocate/map buffer for TPM Physical Presence interface
acpi: expose TPM/PPI configuration parameters to firmware via fw_cfg
acpi: build TPM Physical Presence interface
Thomas Huth (1):
hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device
Yang Zhong (1):
hw: acpi: Fix memory hotplug AML generation error
Yuri Benditovich (2):
virtio-net: support RSC v4/v6 tcp traffic for Windows HCK
virtio-net: changed VIRTIO_NET_F_RSC_EXT to be 61
docs/specs/ivshmem-spec.txt | 8 +- docs/specs/tpm.txt | 104 +++++ default-configs/virtio.mak | 3 +- hw/tpm/tpm_ppi.h | 46 +++ hw/virtio/virtio-pci.h | 234 ----------- include/hw/acpi/acpi-defs.h | 13 +- include/hw/acpi/tpm.h | 21 + include/hw/pci/pcie.h | 2 + include/hw/qdev-core.h | 3 + include/hw/virtio/virtio-net.h | 83 ++++ include/net/eth.h | 2 + include/qemu/compiler.h | 15 + tests/acpi-utils.h | 44 +-- block/sheepdog.c | 2 +- hw/acpi/core.c | 12 +- hw/acpi/memory_hotplug.c | 10 +- hw/acpi/tpm.c | 459 +++++++++++++++++++++ hw/block/vhost-user-blk.c | 7 +- hw/core/machine.c | 7 +- hw/display/virtio-gpu-pci.c | 14 + hw/display/virtio-vga.c | 1 + hw/i386/acpi-build.c | 29 +- hw/i386/pc_piix.c | 1 - hw/misc/edu.c | 1 + hw/misc/ivshmem.c | 210 +--------- hw/net/virtio-net.c | 667 ++++++++++++++++++++++++++++++- hw/pci/msix.c | 2 +- hw/pci/pcie.c | 25 +- hw/pci/pcie_port.c | 1 + hw/scsi/vhost-scsi.c | 3 +- hw/scsi/vhost-user-scsi.c | 3 +- hw/tpm/tpm_crb.c | 13 + hw/tpm/tpm_ppi.c | 53 +++ hw/tpm/tpm_tis.c | 13 + hw/virtio/vhost-scsi-pci.c | 97 +++++ hw/virtio/vhost-user-blk-pci.c | 103 +++++ hw/virtio/vhost-user-scsi-pci.c | 103 +++++ hw/virtio/vhost-user.c | 2 +- hw/virtio/vhost-vsock-pci.c | 86 ++++ hw/virtio/virtio-9p-pci.c | 88 +++++ hw/virtio/virtio-balloon-pci.c | 95 +++++ hw/virtio/virtio-blk-pci.c | 100 +++++ hw/virtio/virtio-crypto-pci.c | 14 + hw/virtio/virtio-input-host-pci.c | 48 +++ hw/virtio/virtio-input-pci.c | 157 ++++++++ hw/virtio/virtio-net-pci.c | 98 +++++ hw/virtio/virtio-pci.c | 811 +------------------------------------- hw/virtio/virtio-rng-pci.c | 88 +++++ hw/virtio/virtio-scsi-pci.c | 107 +++++ hw/virtio/virtio-serial-pci.c | 115 ++++++ migration/global_state.c | 15 +- qom/object.c | 3 + stubs/tpm.c | 5 + tests/acpi-utils.c | 35 +- tests/bios-tables-test.c | 271 ++++--------- tests/ivshmem-test.c | 67 ++-- tests/vhost-user-test.c | 2 +- tests/vmgenid-test.c | 64 +-- util/oslib-posix.c | 8 +- hw/acpi/Makefile.objs | 1 + hw/tpm/Makefile.objs | 1 + hw/tpm/trace-events | 3 + hw/virtio/Makefile.objs | 15 + qemu-deprecated.texi | 5 - scripts/device-crash-test | 1 - tests/Makefile.include | 20 +- tests/data/acpi/pc/DSDT.dimmpxm | Bin 6790 -> 6784 bytes tests/data/acpi/pc/DSDT.memhp | Bin 6496 -> 6490 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9474 -> 9468 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9180 -> 9174 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8947 -> 8945 bytes 71 files changed, 3101 insertions(+), 1638 deletions(-) create mode 100644 hw/tpm/tpm_ppi.h create mode 100644 hw/acpi/tpm.c create mode 100644 hw/tpm/tpm_ppi.c create mode 100644 hw/virtio/vhost-scsi-pci.c create mode 100644 hw/virtio/vhost-user-blk-pci.c create mode 100644 hw/virtio/vhost-user-scsi-pci.c create mode 100644 hw/virtio/vhost-vsock-pci.c create mode 100644 hw/virtio/virtio-9p-pci.c create mode 100644 hw/virtio/virtio-balloon-pci.c create mode 100644 hw/virtio/virtio-blk-pci.c create mode 100644 hw/virtio/virtio-input-host-pci.c create mode 100644 hw/virtio/virtio-input-pci.c create mode 100644 hw/virtio/virtio-net-pci.c create mode 100644 hw/virtio/virtio-rng-pci.c create mode 100644 hw/virtio/virtio-scsi-pci.c create mode 100644 hw/virtio/virtio-serial-pci.c
[Qemu-devel] [PULL v2 02/49] msix: make pba size math more uniform
From: Dongli Zhang <[email protected]>
In msix_exclusive_bar the bar_pba_size is more than what the pba is expected to have, although this never affects the bar size.
Specifically, the math in msix_init_exclusive_bar allocates too much memory in some cases.
For example consider nentries = 8. msix_exclusive_bar will give us bar_pba_size = 16. So 16 bytes. However 8 bytes would be enough - this is all that the spec requires.
So in practice bar_pba_size sometimes allocates an extra 8 bytes but never more.
Since each MSIX entry size is 16 bytes, and since we make sure that table+pba is a power of two, this always leaves a multiple of 16 bytes for the PBA, so extra 8 bytes have no effect.
However, its ugly to have pba size temporary variable have an incorrect value. For consistency switch to the formula used in msix_init.
--- hw/pci/msix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci/msix.c +1 -1
@@ -345,7 +345,7 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,char *name;uint32_t bar_size =4096 ;uint32_t bar_pba_offset = bar_size /2 ; -uint32_t bar_pba_size = (nentries /8 +1 ) *8 ; +uint32_t bar_pba_size =QEMU_ALIGN_UP (nentries,64 ) /8 ;/* * Migration compatibility dictates that this remains a 4k
Signature · 1 line
MST
[Qemu-devel] [PULL v2 01/49] pci/pcie: stop plug/unplug if the slot is locked
In reply to Michael S. TsirkinFrom: David Hildenbrand <[email protected]>
We better stop right away. For now, errors would be partially ignored (so the guest might get informed or the device might get unplugged), although actual plug/unplug will be reported as failed to the user.
While at it, properly move the check to the pre_plug handler for the plug case, as we can test the slot state before the device will be realized.
--- include/hw/pci/pcie.h | 2 ++ hw/pci/pcie.c | 25 +++++++++++++++++-------- hw/pci/pcie_port.c | 1 + 3 files changed, 20 insertions(+), 8 deletions(-)
include/hw/pci/pcie.h +2 -0
@@ -132,6 +132,8 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);void pcie_dev_ser_num_init (PCIDevice *dev,uint16_t offset,uint64_t ser_num);void pcie_ats_init (PCIDevice *dev,uint16_t offset); +void pcie_cap_slot_pre_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp);void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); void pcie_cap_slot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
hw/pci/pcie.c +17 -8
@@ -391,10 +391,10 @@ static void pcie_cap_slot_event(PCIDevice *dev, PCIExpressHotPlugEvent event) }static void pcie_cap_slot_plug_common (PCIDevice *hotplug_dev,DeviceState *dev, -uint8_t **exp_cap,Error **errp) +Error **errp) { - *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; -uint16_t sltsta =pci_get_word (*exp_cap +PCI_EXP_SLTSTA ); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint16_t sltsta =pci_get_word (exp_cap +PCI_EXP_SLTSTA );PCIE_DEV_PRINTF (PCI_DEVICE (dev),"hotplug state: 0x%x\n" , sltsta);if (sltsta &PCI_EXP_SLTSTA_EIS ) {
@@ -405,14 +405,19 @@ static void pcie_cap_slot_plug_common(PCIDevice *hotplug_dev, DeviceState *dev, } } +void pcie_cap_slot_pre_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) +{ +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, errp); +} +void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) { -uint8_t *exp_cap; +PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev); +uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;PCIDevice *pci_dev =PCI_DEVICE (dev); -pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); -/* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an * event when the device is disabled later. */
@@ -458,11 +463,15 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) { -uint8_t *exp_cap; +Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);PCIBus *bus =pci_get_bus (pci_dev); -pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }/* In case user cancel the operation of multi-function hot-add, * remove the function that is unexposed to guest individually,
hw/pci/pcie_port.c +1 -0
@@ -154,6 +154,7 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data)HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc); dc->props = pcie_slot_props; + hc->pre_plug = pcie_cap_slot_pre_plug_cb; hc->plug = pcie_cap_slot_plug_cb; hc->unplug = pcie_cap_slot_unplug_cb; hc->unplug_request = pcie_cap_slot_unplug_request_cb;
Signature · 1 line
MST
[Qemu-devel] [PULL v2 03/49] hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device
In reply to Michael S. TsirkinFrom: Thomas Huth <[email protected]>
It's been marked as deprecated in QEMU v2.6.0 already, so really nobody should use the legacy "ivshmem" device anymore (but use ivshmem-plain or ivshmem-doorbell instead). Time to remove the deprecated device now.
Belatedly also update a mention of the deprecated "ivshmem" in the file docs/specs/ivshmem-spec.txt to "ivshmem-doorbell". Missed in commit 5400c02b90b ("ivshmem: Split ivshmem-plain, ivshmem-doorbell off ivshmem").
--- docs/specs/ivshmem-spec.txt | 8 +- hw/i386/pc_piix.c | 1 - hw/misc/ivshmem.c | 210 +----------------------------------- tests/ivshmem-test.c | 67 ++++-------- qemu-deprecated.texi | 5 - scripts/device-crash-test | 1 - 6 files changed, 34 insertions(+), 258 deletions(-)
docs/specs/ivshmem-spec.txt +6 -2
@@ -17,12 +17,16 @@ get interrupted by its peers. There are two basic configurations: -- Just shared memory: -device ivshmem-plain,memdev=HMB,... +- Just shared memory: + + -device ivshmem-plain,memdev=HMB,... This uses host memory backend HMB. It should have option "share" set. -- Shared memory plus interrupts: -device ivshmem,chardev=CHR,vectors=N,... +- Shared memory plus interrupts: + + -device ivshmem-doorbell,chardev=CHR,vectors=N,... An ivshmem server must already be running on the host. The device connects to the server's UNIX domain socket via character device
hw/i386/pc_piix.c +0 -1
@@ -715,7 +715,6 @@ static void pc_i440fx_1_2_machine_options(MachineClass *m) PC_CPU_MODEL_IDS("1.2.0") { "nec-usb-xhci", "msi", "off" }, { "nec-usb-xhci", "msix", "off" }, - { "ivshmem", "use64", "0" }, { "qxl", "revision", "3" }, { "qxl-vga", "revision", "3" }, { "VGA", "mmio", "off" },
hw/misc/ivshmem.c +5 -205
269 lines not on this page · raw message
tests/ivshmem-test.c +23 -44
125 lines not on this page · raw message
qemu-deprecated.texi +0 -5
@@ -126,11 +126,6 @@ documentation of ``query-hotpluggable-cpus'' for additional details. @section System emulator devices -@subsection ivshmem (since 2.6.0) - -The ``ivshmem'' device type is replaced by either the ``ivshmem-plain'' -or ``ivshmem-doorbell`` device types. - @subsection bluetooth (since 3.1) The bluetooth subsystem is unmaintained since many years and likely bitrotten
scripts/device-crash-test +0 -1
@@ -83,7 +83,6 @@ ERROR_WHITELIST = [ {'device':'isa-ipmi-bt', 'expected':True}, # IPMI device requires a bmc attribute to be set {'device':'isa-ipmi-kcs', 'expected':True}, # IPMI device requires a bmc attribute to be set {'device':'isa-parallel', 'expected':True}, # Can't create serial device, empty char device - {'device':'ivshmem', 'expected':True}, # You must specify either 'shm' or 'chardev' {'device':'ivshmem-doorbell', 'expected':True}, # You must specify a 'chardev' {'device':'ivshmem-plain', 'expected':True}, # You must specify a 'memdev' {'device':'loader', 'expected':True}, # please include valid arguments
Signature · 1 line
MST
[Qemu-devel] [PULL v2 07/49] util: check the return value of fcntl in qemu_set_{block, nonblock}
In reply to Michael S. TsirkinFrom: Li Qiang <[email protected]>
Assert that the return value is not an error. This is like commit 7e6478e7d4f for qemu_set_cloexec.
--- util/oslib-posix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
util/oslib-posix.c +6 -2
@@ -233,14 +233,18 @@ void qemu_set_block(int fd) {int f; f =fcntl (fd,F_GETFL ); -fcntl (fd,F_SETFL , f & ~O_NONBLOCK ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFL , f & ~O_NONBLOCK ); +assert (f !=-1 ); }void qemu_set_nonblock (int fd) {int f; f =fcntl (fd,F_GETFL ); -fcntl (fd,F_SETFL , f |O_NONBLOCK ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFL , f |O_NONBLOCK ); +assert (f !=-1 ); }int socket_set_fast_reuse (int fd)
Signature · 1 line
MST
Re: [Qemu-devel] [PULL v2 07/49] util: check the return value of fcntl in qemu_set_{block, nonblock}
Hi,
Quoted 25 lines · Michael S. Tsirkin
From: Li Qiang <[email protected]>
Assert that the return value is not an error. This is like commit
7e6478e7d4fforqemu_set_cloexec.Signed-off-by Li Qiang <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- util/oslib-posix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)util/oslib-posix.c +3
-1@@ -233,14 +233,18 @@ void qemu_set_block(int fd) {int f; f =fcntl (fd,F_GETFL ); -fcntl (fd,F_SETFL , f & ~O_NONBLOCK ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFL , f & ~O_NONBLOCK ); +assert (f !=-1 );
util/oslib-posix.c void qemu_set_block(int fd) · line 247
Quoted 10 lines
util/oslib-posix.c +3
-1}void qemu_set_nonblock (int fd) {int f; f =fcntl (fd,F_GETFL ); -fcntl (fd,F_SETFL , f |O_NONBLOCK ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFL , f |O_NONBLOCK ); +assert (f !=-1 );
This commit breaks OpenBSD, when trying to start QEMU I get:
assertion "f != -1" failed: file "util/oslib-posix.c", line 247, function "qemu_set_nonblock"
Having a quick look at gdb, the last device opened is /dev/null, and when fcntl() fails we have errno = ENODEV.
19 ENODEV Operation not supported by device.
An attempt was made to apply an inappropriate function to a device, for example, trying to read a write-only device such as a printer.
Digging further I found a recent commit which could fix this problem:
https://github.com/openbsd/src/commit/c2a35b387f9d3c
"fcntl(F_SETFL) invokes the FIONBIO and FIOASYNC ioctls internally, so the memory devices (/dev/null, /dev/zero, etc) need to permit them."
Brad: Do you think this might be the fix? If so, any idea what is the first release to contain this fix? I don't know OpenBSD and can't figure this out... Also, what would be the cleaner QEMU fix?
Thanks,
Phil.
Quoted 4 lines
util/oslib-posix.c +0
-0}int socket_set_fast_reuse (int fd)
Re: [Qemu-devel] [PULL v2 07/49] util: check the return value of fcntl in qemu_set_{block, nonblock}
Quoted 55 lines · Philippe Mathieu-Daudé
Hi,
Quoted 25 lines · Michael S. Tsirkin
From: Li Qiang <[email protected]>
Assert that the return value is not an error. This is like commit
7e6478e7d4fforqemu_set_cloexec.Signed-off-by Li Qiang <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- util/oslib-posix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)util/oslib-posix.c +3
-1@@ -233,14 +233,18 @@ void qemu_set_block(int fd) {int f; f =fcntl (fd,F_GETFL ); -fcntl (fd,F_SETFL , f & ~O_NONBLOCK ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFL , f & ~O_NONBLOCK ); +assert (f !=-1 );util/oslib-posix.c void qemu_set_block(int fd) · line 247
Quoted 10 lines
util/oslib-posix.c +3
-1}void qemu_set_nonblock (int fd) {int f; f =fcntl (fd,F_GETFL ); -fcntl (fd,F_SETFL , f |O_NONBLOCK ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFL , f |O_NONBLOCK ); +assert (f !=-1 );This commit breaks OpenBSD, when trying to start QEMU I get:
assertion "f != -1" failed: file "util/oslib-posix.c", line 247, function "qemu_set_nonblock"Having a quick look at gdb, the last device opened is
/dev/null, and whenfcntl()fails we have errno = ENODEV.19 ENODEV Operation not supported by device.
An attempt was made to apply an inappropriate function to a device, for example, trying to read a write-only device such as a printer.Digging further I found a recent commit which could fix this problem:
https://github.com/openbsd/src/commit/c2a35b387f9d3c
"fcntl(F_SETFL)invokes the FIONBIO and FIOASYNC ioctls internally, so the memory devices (/dev/null,/dev/zero, etc) need to permit them."
Quoted 6 lines
Brad: Do you think this might be the fix? If so, any idea what is the first release to contain this fix? I don't know OpenBSD and can't figure this out... Also, what would be the cleaner QEMU fix?
Thanks,
I cannot speak for OpenBSD (never installed it myself), but if there is a critical patch to test on NetBSD - please let me know.
Quoted 7 lines
Phil.
Quoted 4 lines
util/oslib-posix.c +0
-0}int socket_set_fast_reuse (int fd)
Re: [Qemu-devel] [PULL v2 07/49] util: check the return value of fcntl in qemu_set_{block, nonblock}
In reply to Philippe Mathieu-DaudéQuoted 49 lines · Philippe Mathieu-Daudé
Hi,
Quoted 25 lines · Michael S. Tsirkin
From: Li Qiang <[email protected]>
Assert that the return value is not an error. This is like commit
7e6478e7d4fforqemu_set_cloexec.Signed-off-by Li Qiang <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- util/oslib-posix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)util/oslib-posix.c +3
-1@@ -233,14 +233,18 @@ void qemu_set_block(int fd) {int f; f =fcntl (fd,F_GETFL ); -fcntl (fd,F_SETFL , f & ~O_NONBLOCK ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFL , f & ~O_NONBLOCK ); +assert (f !=-1 );util/oslib-posix.c void qemu_set_block(int fd) · line 247
Quoted 10 lines
util/oslib-posix.c +3
-1}void qemu_set_nonblock (int fd) {int f; f =fcntl (fd,F_GETFL ); -fcntl (fd,F_SETFL , f |O_NONBLOCK ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFL , f |O_NONBLOCK ); +assert (f !=-1 );This commit breaks OpenBSD, when trying to start QEMU I get:
assertion "f != -1" failed: file "util/oslib-posix.c", line 247, function "qemu_set_nonblock"Having a quick look at gdb, the last device opened is
/dev/null, and whenfcntl()fails we have errno = ENODEV.19 ENODEV Operation not supported by device.
An attempt was made to apply an inappropriate function to a device, for example, trying to read a write-only device such as a printer.
Quoted 8 lines
Digging further I found a recent commit which could fix this problem:
https://github.com/openbsd/src/commit/c2a35b387f9d3c
"fcntl(F_SETFL)invokes the FIONBIO and FIOASYNC ioctls internally, so the memory devices (/dev/null,/dev/zero, etc) need to permit them."Brad: Do you think this might be the fix? If so, any idea what is the first release to contain this fix? I don't know OpenBSD and can't figure this out... Also, what would be the cleaner QEMU fix?
I don't know. But that commit was included with 6.3 or newer.
Re: [Qemu-devel] [PULL v2 07/49] util: check the return value of fcntl in qemu_set_{block, nonblock}
Quoted 55 lines · Brad Smith
Quoted 53 lines · Philippe Mathieu-Daudé
Hi,
Quoted 24 lines · Michael S. Tsirkin
From: Li Qiang <[email protected]>
Assert that the return value is not an error. This is like commit
7e6478e7d4fforqemu_set_cloexec.Signed-off-by Li Qiang <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- util/oslib-posix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)util/oslib-posix.c +2
-1@@ -233,14 +233,18 @@ void qemu_set_block(int fd) {int f; f =fcntl (fd,F_GETFL ); -fcntl (fd,F_SETFL , f & ~O_NONBLOCK ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFL , f & ~O_NONBLOCK );util/oslib-posix.c void qemu_set_block(int fd) · line 246
Quoted 10 lines
util/oslib-posix.c +4
-1+assert (f !=-1 ); }void qemu_set_nonblock (int fd) {int f; f =fcntl (fd,F_GETFL ); -fcntl (fd,F_SETFL , f |O_NONBLOCK ); +assert (f !=-1 ); + f =fcntl (fd,F_SETFL , f |O_NONBLOCK ); +assert (f !=-1 );This commit breaks OpenBSD, when trying to start QEMU I get:
assertion "f != -1" failed: file "util/oslib-posix.c", line 247, function "qemu_set_nonblock"Having a quick look at gdb, the last device opened is
/dev/null, and whenfcntl()fails we have errno = ENODEV.19 ENODEV Operation not supported by device.
An attempt was made to apply an inappropriate function to a device, for example, trying to read a write-only device such as a printer.Digging further I found a recent commit which could fix this problem:
https://github.com/openbsd/src/commit/c2a35b387f9d3c
"fcntl(F_SETFL)invokes the FIONBIO and FIOASYNC ioctls internally, so the memory devices (/dev/null,/dev/zero, etc) need to permit them."
Quoted 5 lines
Quoted 3 lines
Brad: Do you think this might be the fix? If so, any idea what is the first release to contain this fix? I don't know OpenBSD and can't figure this out... Also, what would be the cleaner QEMU fix?
I don't know. But that commit was included with 6.3 or newer.
I'm quite prepared to revert that - the value of spreading asserts around is marginal and if we don't set fd even on a real file to non-blocking qemu doesn't explode - it just hangs which isn't much worse than an assert.
Let me know.
Signature · 1 line
MST
[Qemu-devel] [PULL v2 14/49] tests: acpi: squash sanitize_fadt_ptrs() into test_acpi_fadt_table()
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
some parts of sanitize_fadt_ptrs() do redundant job
- locating FADT
- checking original checksum
There is no need to do it as test_acpi_fadt_table() already does that, so drop duplicate code and move remaining fixup code into test_acpi_fadt_table().
--- tests/bios-tables-test.c | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-)
tests/bios-tables-test.c +10 -29
@@ -128,6 +128,7 @@ static void test_acpi_fadt_table(test_data *data)/* FADT table is 1st */ AcpiSdtTable table =g_array_index (data->tables,typeof (table),0 );uint8_t *fadt_aml = table.aml; +uint32_t fadt_len = table.aml_len;ACPI_ASSERT_CMP (table.header->signature,"FACP" );
@@ -139,35 +140,17 @@ static void test_acpi_fadt_table(test_data *data)acpi_fetch_table (data->qts, &table.aml, &table.aml_len, fadt_aml +40 /* DSDT */ ,"DSDT" , true);g_array_append_val (data->tables, table); -} -static void sanitize_fadt_ptrs (test_data *data) -{ -/* fixup pointers in FADT */ -int i; - -for (i =0 ; i < data->tables->len; i++) { -AcpiSdtTable *sdt = &g_array_index (data->tables, AcpiSdtTable, i); - -if (memcmp (&sdt->header->signature,"FACP" ,4 )) { -continue ; - } - -/* check original FADT checksum before sanitizing table */ -g_assert (!acpi_calc_checksum (sdt->aml, sdt->aml_len)); - -memset (sdt->aml +36 ,0 ,4 );/* sanitize FIRMWARE_CTRL ptr */ -memset (sdt->aml +40 ,0 ,4 );/* sanitize DSDT ptr */ -if (sdt->header->revision >=3 ) { -memset (sdt->aml +132 ,0 ,8 );/* sanitize X_FIRMWARE_CTRL ptr */ -memset (sdt->aml +140 ,0 ,8 );/* sanitize X_DSDT ptr */ - } - -/* update checksum */ - sdt->header->checksum =0 ; - sdt->header->checksum -=acpi_calc_checksum (sdt->aml, sdt->aml_len); -break ; +memset (fadt_aml +36 ,0 ,4 );/* sanitize FIRMWARE_CTRL ptr */ +memset (fadt_aml +40 ,0 ,4 );/* sanitize DSDT ptr */ +if (fadt_aml[8 /* FADT Major Version */ ] >=3 ) { +memset (fadt_aml +132 ,0 ,8 );/* sanitize X_FIRMWARE_CTRL ptr */ +memset (fadt_aml +140 ,0 ,8 );/* sanitize X_DSDT ptr */ } + +/* update checksum */ + fadt_aml[9 /* Checksum */ ] =0 ; + fadt_aml[9 /* Checksum */ ] -=acpi_calc_checksum (fadt_aml, fadt_len); }static void dump_aml_files (test_data *data,bool rebuild)
@@ -541,8 +524,6 @@ static void test_acpi_one(const char *params, test_data *data)test_acpi_rsdt_table (data);test_acpi_fadt_table (data); -sanitize_fadt_ptrs (data); -if (iasl) {if (getenv (ACPI_REBUILD_EXPECTED_AML )) {dump_aml_files (data, true);
Signature · 1 line
MST
[Qemu-devel] [PULL v2 05/49] tests: vhost-user-test: initialize 'fd' in chr_read
In reply to Michael S. TsirkinFrom: Li Qiang <[email protected]>
Currently when processing VHOST_USER_SET_VRING_CALL if 'qemu_chr_fe_get_msgfds' get no fd, the 'fd' will be a stack uninitialized value.
--- tests/vhost-user-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/vhost-user-test.c +1 -1
@@ -309,7 +309,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)CharBackend *chr = &s->chr;VhostUserMsg msg;uint8_t *p = (uint8_t *) &msg; -int fd; +int fd =-1 ;if (s->test_fail) {qemu_chr_fe_disconnect (chr);
Signature · 1 line
MST
[Qemu-devel] [PULL v2 06/49] vhost-user: fix ioeventfd_enabled
In reply to Michael S. TsirkinFrom: Li Qiang <[email protected]>
Currently, the vhost-user-test assumes the eventfd is available. However it's not true because the accel is qtest. So the 'vhost_set_vring_file' will not add fds to the msg and the server side of vhost-user-test will be broken. The bug is in 'ioeventfd_enabled'. We should make this function return true if not using kvm accel.
--- hw/virtio/vhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/vhost-user.c +1 -1
@@ -207,7 +207,7 @@ struct vhost_user {static bool ioeventfd_enabled (void ) { -return kvm_enabled () &&kvm_eventfds_enabled (); +return !kvm_enabled () ||kvm_eventfds_enabled (); }static int vhost_user_read (struct vhost_dev *dev,VhostUserMsg *msg)
Signature · 1 line
MST
[Qemu-devel] [PULL v2 13/49] tests: smbios: fetch whole table in one step instead of reading it step by step
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
replace a bunch of ACPI_READ_ARRAY/ACPI_READ_FIELD macro, that read SMBIOS table field by field with one memread() to fetch whole table at once and drop no longer used ACPI_READ_ARRAY/ACPI_READ_FIELD macro.
--- tests/acpi-utils.h | 17 ----------------- tests/bios-tables-test.c | 15 +-------------- 2 files changed, 1 insertion(+), 31 deletions(-)
tests/acpi-utils.h +0 -17
@@ -30,23 +30,6 @@ typedef struct {bool tmp_files_retain;/* do not delete the temp asl/aml */ } AcpiSdtTable; -#define ACPI_READ_FIELD (qts, field, addr) \ - do { \ - qtest_memread(qts, addr, &field, sizeof(field)); \ - addr += sizeof(field); \ - } while (0) - -#define ACPI_READ_ARRAY_PTR (qts, arr, length, addr) \ - do { \ - int idx; \ - for (idx = 0; idx < length; ++idx) { \ - ACPI_READ_FIELD(qts, arr[idx], addr); \ - } \ - } while (0) - -#define ACPI_READ_ARRAY (qts, arr, addr) \ - ACPI_READ_ARRAY_PTR(qts, arr, sizeof(arr) / sizeof(arr[0]), addr) -#define ACPI_ASSERT_CMP (actual, expected) do { \ char ACPI_ASSERT_CMP_str[5] = {}; \ memcpy(ACPI_ASSERT_CMP_str, &actual, 4); \
tests/bios-tables-test.c +1 -14
@@ -406,32 +406,19 @@ static bool smbios_ep_table_ok(test_data *data)struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;uint32_t addr = data->smbios_ep_addr; -ACPI_READ_ARRAY (data->qts, ep_table->anchor_string, addr); +qtest_memread (data->qts, addr, ep_table,sizeof (*ep_table));if (memcmp (ep_table->anchor_string,"_SM_" ,4 )) {return false; } -ACPI_READ_FIELD (data->qts, ep_table->checksum, addr); -ACPI_READ_FIELD (data->qts, ep_table->length, addr); -ACPI_READ_FIELD (data->qts, ep_table->smbios_major_version, addr); -ACPI_READ_FIELD (data->qts, ep_table->smbios_minor_version, addr); -ACPI_READ_FIELD (data->qts, ep_table->max_structure_size, addr); -ACPI_READ_FIELD (data->qts, ep_table->entry_point_revision, addr); -ACPI_READ_ARRAY (data->qts, ep_table->formatted_area, addr); -ACPI_READ_ARRAY (data->qts, ep_table->intermediate_anchor_string, addr);if (memcmp (ep_table->intermediate_anchor_string,"_DMI_" ,5 )) {return false; } -ACPI_READ_FIELD (data->qts, ep_table->intermediate_checksum, addr); -ACPI_READ_FIELD (data->qts, ep_table->structure_table_length, addr);if (ep_table->structure_table_length ==0 ) {return false; } -ACPI_READ_FIELD (data->qts, ep_table->structure_table_address, addr); -ACPI_READ_FIELD (data->qts, ep_table->number_of_structures, addr);if (ep_table->number_of_structures ==0 ) {return false; } -ACPI_READ_FIELD (data->qts, ep_table->smbios_bcd_revision, addr);if (acpi_calc_checksum ((uint8_t *)ep_table,sizeof *ep_table) ||acpi_calc_checksum ((uint8_t *)ep_table +0x10 ,sizeof *ep_table -0x10 )) {
Signature · 1 line
MST
[Qemu-devel] [PULL v2 08/49] tests: acpi: use AcpiSdtTable::aml in consistent way
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Currently in the 1st case we store table body fetched from QEMU in AcpiSdtTable::aml minus it's header but in the 2nd case when we load reference aml from disk, it holds whole blob including header. More over in the 1st case, we read header in separate AcpiSdtTable::header structure and then jump over hoops to fixup tables and combine both.
Treat AcpiSdtTable::aml as whole table blob approach in both cases and when fetching tables from QEMU, first get table length and then fetch whole table into AcpiSdtTable::aml instead if doing it field by field.
As result
* AcpiSdtTable::aml is used in consistent manner
* FADT fixups use offsets from spec instead of being shifted by header length
* calculating checksums and dumping blobs becomes simpler
--- tests/acpi-utils.h | 6 ++-- tests/bios-tables-test.c | 62 +++++++++++++++------------------------- 2 files changed, 27 insertions(+), 41 deletions(-)
tests/acpi-utils.h +4 -2
@@ -18,8 +18,10 @@/* DSDT and SSDTs format */ typedef struct { - AcpiTableHeader header; - gchar *aml; /* aml bytecode from guest */ + union { + AcpiTableHeader *header; + uint8_t *aml; /* aml bytecode from guest */ + }; gsize aml_len; gchar *aml_file; gchar *asl; /* asl code generated from aml */
tests/bios-tables-test.c +23 -39
136 lines not on this page · raw message
Signature · 1 line
MST
[Qemu-devel] [PULL v2 09/49] tests: acpi: make sure FADT is fetched only once
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Whole FADT is fetched as part of RSDT referenced tables in fetch_rsdt_referenced_tables() albeit a bit later than when FADT is partially parsed in fadt_fetch_facs_and_dsdt_ptrs(). However there is no reason for calling fetch_rsdt_referenced_tables() so late, just move it right after we fetched RSDT and before fadt_fetch_facs_and_dsdt_ptrs(). That way we can reuse whole FADT fetched by fetch_rsdt_referenced_tables() and avoid duplicate custom fields fetching in fadt_fetch_facs_and_dsdt_ptrs().
While at it rename fadt_fetch_facs_and_dsdt_ptrs() to test_acpi_fadt_table(). The follow up patch will merge fadt_fetch_facs_and_dsdt_ptrs() into test_acpi_rsdt_table(), so that we would end up calling only test_acpi_FOO_table() for consistency for tables that require special processing.
--- tests/bios-tables-test.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
tests/bios-tables-test.c +8 -11
@@ -141,18 +141,15 @@ static void test_acpi_rsdt_table(test_data *data) data->rsdt_tables_nr = tables_nr; } -static void fadt_fetch_facs_and_dsdt_ptrs (test_data *data) +static void test_acpi_fadt_table (test_data *data) { -uint32_t addr; -AcpiTableHeader hdr; +/* FADT table is 1st */ +AcpiSdtTable *fadt = &g_array_index (data->tables,typeof (*fadt),0 ); -/* FADT table comes first */ - addr =le32_to_cpu (data->rsdt_tables_addr[0 ]); -ACPI_READ_TABLE_HEADER (data->qts, &hdr, addr); -ACPI_ASSERT_CMP (hdr.signature,"FACP" ); +ACPI_ASSERT_CMP (fadt->header->signature,"FACP" ); -ACPI_READ_FIELD (data->qts, data->facs_addr, addr); -ACPI_READ_FIELD (data->qts, data->dsdt_addr, addr); +memcpy (&data->facs_addr, fadt->aml +36 /* FIRMWARE_CTRL */ ,4 ); +memcpy (&data->dsdt_addr, fadt->aml +40 /* DSDT */ ,4 ); }static void sanitize_fadt_ptrs (test_data *data)
@@ -628,10 +625,10 @@ static void test_acpi_one(const char *params, test_data *data)test_acpi_rsdp_address (data);test_acpi_rsdp_table (data);test_acpi_rsdt_table (data); -fadt_fetch_facs_and_dsdt_ptrs (data); +fetch_rsdt_referenced_tables (data); +test_acpi_fadt_table (data);test_acpi_facs_table (data);test_acpi_dsdt_table (data); -fetch_rsdt_referenced_tables (data);sanitize_fadt_ptrs (data);
Signature · 1 line
MST
[Qemu-devel] [PULL v2 12/49] tests: acpi: reuse fetch_table() in vmgenid-test
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Move fetch_table() into acpi-utils.c renaming it to acpi_fetch_table() and reuse it in vmgenid-test that reads RSDT and then tables it references, to find and parse VMGNEID SSDT.
While at it wrap RSDT referenced tables enumeration into FOREACH macro (similar to what we do with QLIST_FOREACH & co) to reuse it with bios and vmgenid tests.
--- tests/acpi-utils.h | 23 +++++---------- tests/acpi-utils.c | 35 +++++++++++++++++----- tests/bios-tables-test.c | 55 ++++++++-------------------------- tests/vmgenid-test.c | 64 +++++++++++++--------------------------- 4 files changed, 67 insertions(+), 110 deletions(-)
tests/acpi-utils.h +8 -15
@@ -22,7 +22,7 @@ typedef struct {AcpiTableHeader *header;uint8_t *aml;/* aml bytecode from guest */ }; -gsize aml_len; +uint32_t aml_len;gchar *aml_file;gchar *asl;/* asl code generated from aml */ gsize asl_len;
@@ -47,19 +47,6 @@ typedef struct {#define ACPI_READ_ARRAY (qts, arr, addr) \ ACPI_READ_ARRAY_PTR(qts, arr, sizeof(arr) / sizeof(arr[0]), addr) -#define ACPI_READ_TABLE_HEADER (qts, table, addr) \ - do { \ - ACPI_READ_FIELD(qts, (table)->signature, addr); \ - ACPI_READ_FIELD(qts, (table)->length, addr); \ - ACPI_READ_FIELD(qts, (table)->revision, addr); \ - ACPI_READ_FIELD(qts, (table)->checksum, addr); \ - ACPI_READ_ARRAY(qts, (table)->oem_id, addr); \ - ACPI_READ_ARRAY(qts, (table)->oem_table_id, addr); \ - ACPI_READ_FIELD(qts, (table)->oem_revision, addr); \ - ACPI_READ_ARRAY(qts, (table)->asl_compiler_id, addr); \ - ACPI_READ_FIELD(qts, (table)->asl_compiler_revision, addr); \ - } while (0) -#define ACPI_ASSERT_CMP (actual, expected) do { \ char ACPI_ASSERT_CMP_str[5] = {}; \ memcpy(ACPI_ASSERT_CMP_str, &actual, 4); \
@@ -73,11 +60,17 @@ typedef struct { } while (0) +#define ACPI_FOREACH_RSDT_ENTRY (table, table_len, entry_ptr, entry_size) \ + for (entry_ptr = table + 36/* 1st Entry */ ; \ + entry_ptr < table + table_len; \ + entry_ptr += entry_size)uint8_t acpi_calc_checksum (const uint8_t *data,int len);uint32_t acpi_find_rsdp_address (QTestState *qts); -uint32_t acpi_get_rsdt_address (uint8_t *rsdp_table);uint64_t acpi_get_xsdt_address (uint8_t *rsdp_table);void acpi_parse_rsdp_table (QTestState *qts,uint32_t addr,uint8_t *rsdp_table); +void acpi_fetch_table (QTestState *qts,uint8_t **aml,uint32_t *aml_len, +const uint8_t *addr_ptr,const char *sig, +bool verify_checksum);#endif /* TEST_ACPI_UTILS_H */
tests/acpi-utils.c +27 -8
@@ -51,14 +51,6 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)return off; } -uint32_t acpi_get_rsdt_address (uint8_t *rsdp_table) -{ -uint32_t rsdt_physical_address; - -memcpy (&rsdt_physical_address, &rsdp_table[16 /* RsdtAddress offset */ ],4 ); -return le32_to_cpu (rsdt_physical_address); -} -uint64_t acpi_get_xsdt_address (uint8_t *rsdp_table) {uint64_t xsdt_physical_address;
@@ -92,3 +84,30 @@ void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)ACPI_ASSERT_CMP64 (*((uint64_t *)(rsdp_table)),"RSD PTR " ); } + +/** acpi_fetch_table +* load ACPI table at @addr_ptr offset pointer into buffer and return it in +* @aml, its length in @aml_len and check that signature/checksum matches +* actual one. +*/ +void acpi_fetch_table (QTestState *qts,uint8_t **aml,uint32_t *aml_len, +const uint8_t *addr_ptr,const char *sig, +bool verify_checksum) +{ +uint32_t addr, len; + +memcpy (&addr, addr_ptr ,sizeof (addr)); + addr =le32_to_cpu (addr); +qtest_memread (qts, addr +4 , &len,4 );/* Length of ACPI table */ + *aml_len =le32_to_cpu (len); + *aml =g_malloc0 (*aml_len); +/* get whole table */ +qtest_memread (qts, addr, *aml, *aml_len); + +if (sig) { +ACPI_ASSERT_CMP (**aml, sig); + } +if (verify_checksum) { +g_assert (!acpi_calc_checksum (*aml, *aml_len)); + } +}
tests/bios-tables-test.c +12 -43
87 lines not on this page · raw message
tests/vmgenid-test.c +20 -44
94 lines not on this page · raw message
Signature · 1 line
MST
[Qemu-devel] [PULL v2 15/49] tests: acpi: use AcpiSdtTable::aml instead of AcpiSdtTable::header::signature
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
AcpiSdtTable::header::signature is the only remained field from AcpiTableHeader structure used by tests. Instead of using packed structure to access signature, just read it directly from table blob and remove no longer used AcpiSdtTable::header / union and keep only AcpiSdtTable::aml byte array.
--- tests/acpi-utils.h | 6 +----- tests/bios-tables-test.c | 20 +++++++++----------- 2 files changed, 10 insertions(+), 16 deletions(-)
tests/acpi-utils.h +1 -5
@@ -13,15 +13,11 @@ #ifndef TEST_ACPI_UTILS_H #define TEST_ACPI_UTILS_H -#include "hw/acpi/acpi-defs.h" #include "libqtest.h" /* DSDT and SSDTs format */ typedef struct { - union { - AcpiTableHeader *header; - uint8_t *aml; /* aml bytecode from guest */ - }; + uint8_t *aml; /* aml bytecode from guest */ uint32_t aml_len; gchar *aml_file; gchar *asl; /* asl code generated from aml */
tests/bios-tables-test.c +9 -11
@@ -44,6 +44,11 @@ static const char *iasl = stringify(CONFIG_IASL);static const char *iasl;#endif +static bool compare_signature (const AcpiSdtTable *sdt,const char *signature) +{ +return !memcmp (sdt->aml, signature,4 ); +} +static void cleanup_table_descriptor (AcpiSdtTable *table) {g_free (table->aml);
@@ -130,7 +135,7 @@ static void test_acpi_fadt_table(test_data *data)uint8_t *fadt_aml = table.aml;uint32_t fadt_len = table.aml_len; -ACPI_ASSERT_CMP (table.header->signature,"FACP" ); +g_assert (compare_signature (&table,"FACP" ));/* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */ acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
@@ -169,7 +174,7 @@ static void dump_aml_files(test_data *data, bool rebuild)if (rebuild) { aml_file =g_strdup_printf ("%s/%s/%.4s%s" , data_dir, data->machine, - (gchar *)&sdt->header->signature, ext); + sdt->aml, ext); fd =g_open (aml_file,O_WRONLY |O_TRUNC |O_CREAT ,S_IRUSR |S_IWUSR |S_IRGRP |S_IWGRP |S_IROTH ); }else {
@@ -187,11 +192,6 @@ static void dump_aml_files(test_data *data, bool rebuild) } } -static bool compare_signature (AcpiSdtTable *sdt,const char *signature) -{ -return !memcmp (&sdt->header->signature, signature,4 ); -} -static bool load_asl (GArray *sdts,AcpiSdtTable *sdt) {AcpiSdtTable *temp;
@@ -290,7 +290,7 @@ static GArray *load_expected_aml(test_data *data) try_again: aml_file =g_strdup_printf ("%s/%s/%.4s%s" , data_dir, data->machine, - (gchar *)&sdt->header->signature, ext); + sdt->aml, ext);if (getenv ("V" )) {fprintf (stderr,"Looking for expected file '%s'\n" , aml_file); }
@@ -350,14 +350,12 @@ static void test_acpi_asl(test_data *data)fprintf (stderr,"Warning! iasl couldn't parse the expected aml\n" ); }else { -uint32_t signature =cpu_to_le32 (exp_sdt->header->signature); sdt->tmp_files_retain = true; exp_sdt->tmp_files_retain = true;fprintf (stderr,"acpi-test: Warning! %.4s mismatch. " "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n" , - (gchar *)&signature, - sdt->asl_file, sdt->aml_file, + exp_sdt->aml, sdt->asl_file, sdt->aml_file, exp_sdt->asl_file, exp_sdt->aml_file);if (getenv ("V" )) {const char *diff_cmd =getenv ("DIFF" );
Signature · 1 line
MST
[Qemu-devel] [PULL v2 11/49] tests: acpi: reuse fetch_table() for fetching FACS and DSDT
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
It allows to remove a bit more of code duplication and reuse common utility to get ACPI tables from guest (modulo RSDP).
While at it, consolidate signature checking into fetch_table() instead of open-codding it.
Considering FACS is special and doesn't have checksum, make checksum validation optin, the same goes for signature verification.
PS:
By pure accident, patch also fixes FACS not being tested against reference table since it wasn't added to data::tables list. But we managed not to regress it since reference file was added by commit
(d25979380 acpi unit-test: add test files)
back in 2013
--- tests/bios-tables-test.c | 78 ++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 48 deletions(-)
tests/bios-tables-test.c +30 -48
@@ -28,9 +28,6 @@ typedef struct {const char *variant;uint32_t rsdp_addr;uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */ ]; -uint32_t dsdt_addr; -uint32_t facs_addr; -AcpiFacsDescriptorRev1 facs_table;GArray *tables;uint32_t smbios_ep_addr;struct smbios_21_entry_point smbios_ep_table;
@@ -76,11 +73,18 @@ static void free_test_data(test_data *data) }/** fetch_table -* load ACPI table at @addr into table descriptor @sdt_table -* and check that header checksum matches actual one. +* load ACPI table at @addr_ptr offset pointer into table descriptor +* @sdt_table and check that signature/checksum matches actual one. */ -static void fetch_table (QTestState *qts,AcpiSdtTable *sdt_table,uint32_t addr) +static void fetch_table (QTestState *qts,AcpiSdtTable *sdt_table, +uint8_t *addr_ptr,const char *sig, +bool verify_checksum) { +uint32_t addr; + +memcpy (&addr, addr_ptr ,sizeof (addr)); + addr =le32_to_cpu (addr); +qtest_memread (qts, addr +4 /* Length of ACPI table */ , &sdt_table->aml_len,4 ); sdt_table->aml_len =le32_to_cpu (sdt_table->aml_len);
@@ -88,7 +92,12 @@ static void fetch_table(QTestState *qts, AcpiSdtTable *sdt_table, uint32_t addr)/* get whole table */ qtest_memread (qts, addr, sdt_table->aml, sdt_table->aml_len); -g_assert (!acpi_calc_checksum (sdt_table->aml, sdt_table->aml_len)); +if (sig) { +ACPI_ASSERT_CMP (sdt_table->header->signature, sig); + } +if (verify_checksum) { +g_assert (!acpi_calc_checksum (sdt_table->aml, sdt_table->aml_len)); + } }static void test_acpi_rsdp_address (test_data *data)
@@ -123,15 +132,13 @@ static void test_acpi_rsdp_table(test_data *data)static void test_acpi_rsdt_table (test_data *data) { -uint32_t addr =acpi_get_rsdt_address (data->rsdp_table);const int entry_size =4 /* 32-bit Entry size */ ;const int tables_off =36 /* 1st Entry */ ;AcpiSdtTable rsdt = {};int i, table_len, table_nr; -uint32_t *entry; -fetch_table (data->qts, &rsdt, addr); -ACPI_ASSERT_CMP (rsdt.header->signature,"RSDT" ); +fetch_table (data->qts, &rsdt, &data->rsdp_table[16 /* RsdtAddress */ ], +"RSDT" , true);/* Load all tables and add to test list directly RSDT referenced tables */ table_len =le32_to_cpu (rsdt.header->length);
@@ -139,9 +146,8 @@ static void test_acpi_rsdt_table(test_data *data)for (i =0 ; i < table_nr; i++) {AcpiSdtTable ssdt_table = {}; - entry = (uint32_t *)(rsdt.aml + tables_off + i * entry_size); - addr =le32_to_cpu (*entry); -fetch_table (data->qts, &ssdt_table, addr); +fetch_table (data->qts, &ssdt_table, + rsdt.aml + tables_off + i * entry_size,NULL , true);/* Add table to ASL test tables list */ g_array_append_val (data->tables, ssdt_table);
@@ -152,12 +158,18 @@ static void test_acpi_rsdt_table(test_data *data)static void test_acpi_fadt_table (test_data *data) {/* FADT table is 1st */ -AcpiSdtTable *fadt = &g_array_index (data->tables,typeof (*fadt),0 ); +AcpiSdtTable table =g_array_index (data->tables,typeof (table),0 ); +uint8_t *fadt_aml = table.aml; -ACPI_ASSERT_CMP (fadt->header->signature,"FACP" ); +ACPI_ASSERT_CMP (table.header->signature,"FACP" ); -memcpy (&data->facs_addr, fadt->aml +36 /* FIRMWARE_CTRL */ ,4 ); -memcpy (&data->dsdt_addr, fadt->aml +40 /* DSDT */ ,4 ); +/* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */ +fetch_table (data->qts, &table, fadt_aml +36 /* FIRMWARE_CTRL */ , +"FACS" , false); +g_array_append_val (data->tables, table); + +fetch_table (data->qts, &table, fadt_aml +40 /* DSDT */ ,"DSDT" , true); +g_array_append_val (data->tables, table); }static void sanitize_fadt_ptrs (test_data *data)
@@ -189,34 +201,6 @@ static void sanitize_fadt_ptrs(test_data *data) } } -static void test_acpi_facs_table (test_data *data) -{ -AcpiFacsDescriptorRev1 *facs_table = &data->facs_table; -uint32_t addr =le32_to_cpu (data->facs_addr); - -ACPI_READ_FIELD (data->qts, facs_table->signature, addr); -ACPI_READ_FIELD (data->qts, facs_table->length, addr); -ACPI_READ_FIELD (data->qts, facs_table->hardware_signature, addr); -ACPI_READ_FIELD (data->qts, facs_table->firmware_waking_vector, addr); -ACPI_READ_FIELD (data->qts, facs_table->global_lock, addr); -ACPI_READ_FIELD (data->qts, facs_table->flags, addr); -ACPI_READ_ARRAY (data->qts, facs_table->resverved3, addr); - -ACPI_ASSERT_CMP (facs_table->signature,"FACS" ); -} - -static void test_acpi_dsdt_table (test_data *data) -{ -AcpiSdtTable dsdt_table = {}; -uint32_t addr =le32_to_cpu (data->dsdt_addr); - -fetch_table (data->qts, &dsdt_table, addr); -ACPI_ASSERT_CMP (dsdt_table.header->signature,"DSDT" ); - -/* Since DSDT isn't in RSDT, add DSDT to ASL test tables list manually */ -g_array_append_val (data->tables, dsdt_table); -} -static void dump_aml_files (test_data *data,bool rebuild) {AcpiSdtTable *sdt;
@@ -600,8 +584,6 @@ static void test_acpi_one(const char *params, test_data *data)test_acpi_rsdp_table (data);test_acpi_rsdt_table (data);test_acpi_fadt_table (data); -test_acpi_facs_table (data); -test_acpi_dsdt_table (data);sanitize_fadt_ptrs (data);
Signature · 1 line
MST
[Qemu-devel] [PULL v2 10/49] tests: acpi: simplify rsdt handling
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
RSDT referenced tables always have length at offset 4 and checksum at offset 9, that's enough for reusing fetch_table() and replacing custom RSDT fetching code with it.
While at it
* merge fetch_rsdt_referenced_tables() into test_acpi_rsdt_table()
* drop test_data::rsdt_table/rsdt_tables_addr/rsdt_tables_nr since we need this data only for duration of test_acpi_rsdt_table() to fetch other tables and use locals instead.
--- tests/bios-tables-test.c | 133 ++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 80 deletions(-)
tests/bios-tables-test.c +53 -80
@@ -28,12 +28,9 @@ typedef struct {const char *variant;uint32_t rsdp_addr;uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */ ]; -AcpiRsdtDescriptorRev1 rsdt_table;uint32_t dsdt_addr;uint32_t facs_addr;AcpiFacsDescriptorRev1 facs_table; -uint32_t *rsdt_tables_addr; -int rsdt_tables_nr;GArray *tables;uint32_t smbios_ep_addr;struct smbios_21_entry_point smbios_ep_table;
@@ -50,33 +47,50 @@ static const char *iasl = stringify(CONFIG_IASL);static const char *iasl;#endif +static void cleanup_table_descriptor (AcpiSdtTable *table) +{ +g_free (table->aml); +if (table->aml_file && + !table->tmp_files_retain && +g_strstr_len (table->aml_file,-1 ,"aml-" )) { +unlink (table->aml_file); + } +g_free (table->aml_file); +g_free (table->asl); +if (table->asl_file && + !table->tmp_files_retain) { +unlink (table->asl_file); + } +g_free (table->asl_file); +} +static void free_test_data (test_data *data) { -AcpiSdtTable *temp;int i; -g_free (data->rsdt_tables_addr); -for (i =0 ; i < data->tables->len; ++i) { - temp = &g_array_index (data->tables, AcpiSdtTable, i); -g_free (temp->aml); -if (temp->aml_file && - !temp->tmp_files_retain && -g_strstr_len (temp->aml_file,-1 ,"aml-" )) { -unlink (temp->aml_file); - } -g_free (temp->aml_file); -g_free (temp->asl); -if (temp->asl_file && - !temp->tmp_files_retain) { -unlink (temp->asl_file); - } -g_free (temp->asl_file); +cleanup_table_descriptor (&g_array_index (data->tables, AcpiSdtTable, i)); }g_array_free (data->tables, true); } +/** fetch_table +* load ACPI table at @addr into table descriptor @sdt_table +* and check that header checksum matches actual one. +*/ +static void fetch_table (QTestState *qts,AcpiSdtTable *sdt_table,uint32_t addr) +{ +qtest_memread (qts, addr +4 /* Length of ACPI table */ , + &sdt_table->aml_len,4 ); + sdt_table->aml_len =le32_to_cpu (sdt_table->aml_len); + sdt_table->aml =g_malloc0 (sdt_table->aml_len); +/* get whole table */ +qtest_memread (qts, addr, sdt_table->aml, sdt_table->aml_len); + +g_assert (!acpi_calc_checksum (sdt_table->aml, sdt_table->aml_len)); +} +static void test_acpi_rsdp_address (test_data *data) {uint32_t off =acpi_find_rsdp_address (data->qts);
@@ -109,36 +123,30 @@ static void test_acpi_rsdp_table(test_data *data)static void test_acpi_rsdt_table (test_data *data) { -AcpiRsdtDescriptorRev1 *rsdt_table = &data->rsdt_table;uint32_t addr =acpi_get_rsdt_address (data->rsdp_table); -uint32_t *tables; -int tables_nr; -uint8_t checksum; -uint32_t rsdt_table_length; +const int entry_size =4 /* 32-bit Entry size */ ; +const int tables_off =36 /* 1st Entry */ ; +AcpiSdtTable rsdt = {}; +int i, table_len, table_nr; +uint32_t *entry; -/* read the header */ -ACPI_READ_TABLE_HEADER (data->qts, rsdt_table, addr); -ACPI_ASSERT_CMP (rsdt_table->signature,"RSDT" ); +fetch_table (data->qts, &rsdt, addr); +ACPI_ASSERT_CMP (rsdt.header->signature,"RSDT" ); - rsdt_table_length =le32_to_cpu (rsdt_table->length); +/* Load all tables and add to test list directly RSDT referenced tables */ + table_len =le32_to_cpu (rsdt.header->length); + table_nr = (table_len - tables_off) / entry_size; +for (i =0 ; i < table_nr; i++) { +AcpiSdtTable ssdt_table = {}; -/* compute the table entries in rsdt */ - tables_nr = (rsdt_table_length -sizeof (AcpiRsdtDescriptorRev1)) / -sizeof (uint32_t ); -g_assert (tables_nr >0 ); + entry = (uint32_t *)(rsdt.aml + tables_off + i * entry_size); + addr =le32_to_cpu (*entry); +fetch_table (data->qts, &ssdt_table, addr); -/* get the addresses of the tables pointed by rsdt */ - tables =g_new0 (uint32_t, tables_nr); -ACPI_READ_ARRAY_PTR (data->qts, tables, tables_nr, addr); - - checksum =acpi_calc_checksum ((uint8_t *)rsdt_table, rsdt_table_length) + -acpi_calc_checksum ((uint8_t *)tables, - tables_nr *sizeof (uint32_t )); -g_assert (!checksum); - -/* SSDT tables after FADT */ - data->rsdt_tables_addr = tables; - data->rsdt_tables_nr = tables_nr; +/* Add table to ASL test tables list */ +g_array_append_val (data->tables, ssdt_table); + } +cleanup_table_descriptor (&rsdt); }static void test_acpi_fadt_table (test_data *data)
@@ -197,22 +205,6 @@ static void test_acpi_facs_table(test_data *data)ACPI_ASSERT_CMP (facs_table->signature,"FACS" ); } -/** fetch_table -* load ACPI table at @addr into table descriptor @sdt_table -* and check that header checksum matches actual one. -*/ -static void fetch_table (QTestState *qts,AcpiSdtTable *sdt_table,uint32_t addr) -{ -qtest_memread (qts, addr +4 /* Length of ACPI table */ , - &sdt_table->aml_len,4 ); - sdt_table->aml_len =le32_to_cpu (sdt_table->aml_len); - sdt_table->aml =g_malloc0 (sdt_table->aml_len); -/* get whole table */ -qtest_memread (qts, addr, sdt_table->aml, sdt_table->aml_len); - -g_assert (!acpi_calc_checksum (sdt_table->aml, sdt_table->aml_len)); -} -static void test_acpi_dsdt_table (test_data *data) {AcpiSdtTable dsdt_table = {};
@@ -225,24 +217,6 @@ static void test_acpi_dsdt_table(test_data *data)g_array_append_val (data->tables, dsdt_table); } -/* Load all tables and add to test list directly RSDT referenced tables */ -static void fetch_rsdt_referenced_tables (test_data *data) -{ -int tables_nr = data->rsdt_tables_nr; -int i; - -for (i =0 ; i < tables_nr; i++) { -AcpiSdtTable ssdt_table = {}; -uint32_t addr; - - addr =le32_to_cpu (data->rsdt_tables_addr[i]); -fetch_table (data->qts, &ssdt_table, addr); - -/* Add table to ASL test tables list */ -g_array_append_val (data->tables, ssdt_table); - } -} -static void dump_aml_files (test_data *data,bool rebuild) {AcpiSdtTable *sdt;
@@ -625,7 +599,6 @@ static void test_acpi_one(const char *params, test_data *data)test_acpi_rsdp_address (data);test_acpi_rsdp_table (data);test_acpi_rsdt_table (data); -fetch_rsdt_referenced_tables (data);test_acpi_fadt_table (data);test_acpi_facs_table (data);test_acpi_dsdt_table (data);
Signature · 1 line
MST
[Qemu-devel] [PULL v2 04/49] qemu: avoid memory leak while remove disk
In reply to Michael S. TsirkinFrom: Jian Wang <[email protected]>
Memset vhost_dev to zero in the vhost_dev_cleanup function. This causes dev.vqs to be NULL, so that
vqs does not free up space when calling the g_free function. This will result in a memory leak. But you can't release vqs directly in the vhost_dev_cleanup function, because vhost_net will also call this function, and vhost_net's vqs is assigned by array. In order to solve this problem, we first save the pointer of vqs, and release the space of vqs after vhost_dev_cleanup is called.
--- hw/block/vhost-user-blk.c | 7 +++++-- hw/scsi/vhost-scsi.c | 3 ++- hw/scsi/vhost-user-scsi.c | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-)
hw/block/vhost-user-blk.c +5 -2
@@ -250,6 +250,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)VirtIODevice *vdev =VIRTIO_DEVICE (dev);VHostUserBlk *s =VHOST_USER_BLK (vdev);VhostUserState *user; +struct vhost_virtqueue *vqs =NULL ;int i, ret;if (!s->chardev.chr) {
@@ -288,6 +289,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) s->dev.vqs = g_new(struct vhost_virtqueue, s->dev.nvqs); s->dev.vq_index =0 ; s->dev.backend_features =0 ; + vqs = s->dev.vqs;vhost_dev_set_config_notifier (&s->dev, &blk_ops);
@@ -314,7 +316,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) vhost_err:vhost_dev_cleanup (&s->dev); virtio_err: -g_free (s->dev.vqs); +g_free (vqs);virtio_cleanup (vdev);vhost_user_cleanup (user);
@@ -326,10 +328,11 @@ static void vhost_user_blk_device_unrealize(DeviceState *dev, Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);VHostUserBlk *s =VHOST_USER_BLK (dev); +struct vhost_virtqueue *vqs = s->dev.vqs;vhost_user_blk_set_status (vdev,0 );vhost_dev_cleanup (&s->dev); -g_free (s->dev.vqs); +g_free (vqs);virtio_cleanup (vdev);if (s->vhost_user) {
hw/scsi/vhost-scsi.c +2 -1
@@ -215,6 +215,7 @@ static void vhost_scsi_unrealize(DeviceState *dev, Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);VHostSCSICommon *vsc =VHOST_SCSI_COMMON (dev); +struct vhost_virtqueue *vqs = vsc->dev.vqs;migrate_del_blocker (vsc->migration_blocker);error_free (vsc->migration_blocker);
@@ -223,7 +224,7 @@ static void vhost_scsi_unrealize(DeviceState *dev, Error **errp)vhost_scsi_set_status (vdev,0 );vhost_dev_cleanup (&vsc->dev); -g_free (vsc->dev.vqs); +g_free (vqs);virtio_scsi_common_unrealize (dev, errp); }
hw/scsi/vhost-user-scsi.c +2 -1
@@ -121,12 +121,13 @@ static void vhost_user_scsi_unrealize(DeviceState *dev, Error **errp)VirtIODevice *vdev =VIRTIO_DEVICE (dev);VHostUserSCSI *s =VHOST_USER_SCSI (dev);VHostSCSICommon *vsc =VHOST_SCSI_COMMON (s); +struct vhost_virtqueue *vqs = vsc->dev.vqs;/* This will stop the vhost backend. */ vhost_user_scsi_set_status (vdev,0 );vhost_dev_cleanup (&vsc->dev); -g_free (vsc->dev.vqs); +g_free (vqs);virtio_scsi_common_unrealize (dev, errp);
Signature · 1 line
MST
[Qemu-devel] [PULL v2 16/49] virtio-net: support RSC v4/v6 tcp traffic for Windows HCK
In reply to Michael S. TsirkinFrom: Yuri Benditovich <[email protected]>
This commit adds implementation of RX packets coalescing, compatible with requirements of Windows Hardware compatibility kit.
The device enables feature VIRTIO_NET_F_RSC_EXT in host features if it supports extended RSC functionality as defined in the specification.
This feature requires at least one of VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6. Windows guest driver acks this feature only if VIRTIO_NET_F_CTRL_GUEST_OFFLOADS is also present.
If the guest driver acks VIRTIO_NET_F_RSC_EXT feature, the device coalesces TCPv4 and TCPv6 packets (if respective VIRTIO_NET_F_GUEST_TSO feature is on, populates extended RSC information in virtio header and sets VIRTIO_NET_HDR_F_RSC_INFO bit in header flags. The device does not recalculate checksums in the coalesced packet, so they are not valid.
In this case:
All the data packets in a tcp connection are cached to a single buffer in every receive interval, and will be sent out via a timer, the 'virtio_net_rsc_timeout' controls the interval, this value may impact the performance and response time of tcp connection, 50000(50us) is an experience value to gain a performance improvement, since the whql test sends packets every 100us, so '300000(300us)' passes the test case, it is the default value as well, tune it via the command line parameter 'rsc_interval' within 'virtio-net-pci' device, for example, to launch a guest with interval set as '500000':
'virtio-net-pci,netdev=hostnet1,bus=pci.0,id=net1,mac=00, guest_rsc_ext=on,rsc_interval=500000'
The timer will only be triggered if the packets pool is not empty, and it'll drain off all the cached packets.
'NetRscChain' is used to save the segments of IPv4/6 in a VirtIONet device.
A new segment becomes a 'Candidate' as well as it passed sanity check, the main handler of TCP includes TCP window update, duplicated ACK check and the real data coalescing.
An 'Candidate' segment means:
1. Segment is within current window and the sequence is the expected one.
2. 'ACK' of the segment is in the valid window.
Sanity check includes:
1. Incorrect version in IP header
2. An IP options or IP fragment
3. Not a TCP packet
4. Sanity size check to prevent buffer overflow attack.
5. An ECN packet
Even though, there might more cases should be considered such as ip identification other flags, while it breaks the test because windows set it to the same even it's not a fragment.
Normally it includes 2 typical ways to handle a TCP control flag, 'bypass' and 'finalize', 'bypass' means should be sent out directly, while 'finalize' means the packets should also be bypassed, but this should be done after search for the same connection packets in the pool and drain all of them out, this is to avoid out of order fragment.
All the 'SYN' packets will be bypassed since this always begin a new' connection, other flags such 'URG/FIN/RST/CWR/ECE' will trigger a finalization, because this normally happens upon a connection is going to be closed, an 'URG' packet also finalize current coalescing unit.
Statistics can be used to monitor the basic coalescing status, the 'out of order' and 'out of window' means how many retransmitting packets, thus describe the performance intuitively.
Difference between ip v4 and v6 processing:
Fragment length in ipv4 header includes itself, while it's not included for ipv6, thus means ipv6 can carry a real 65535 payload.
Note that main goal of implementing this feature in software is to create reference setup for certification tests. In such setups guest migration is not required, so the coalesced packets not yet delivered to the guest will be lost in case of migration.
--- include/hw/virtio/virtio-net.h | 83 ++++ include/net/eth.h | 2 + hw/net/virtio-net.c | 667 ++++++++++++++++++++++++++++++++- 3 files changed, 751 insertions(+), 1 deletion(-)
include/hw/virtio/virtio-net.h +83 -0
@@ -44,6 +44,83 @@ typedef struct virtio_net_confuint8_t duplex; } virtio_net_conf; +/* Coalesced packets type & status */ +typedef enum { +RSC_COALESCE ,/* Data been coalesced */ +RSC_FINAL ,/* Will terminate current connection */ +RSC_NO_MATCH ,/* No matched in the buffer pool */ +RSC_BYPASS ,/* Packet to be bypass, not tcp, tcp ctrl, etc */ +RSC_CANDIDATE /* Data want to be coalesced */ +}CoalesceStatus ; + +typedef struct VirtioNetRscStat { +uint32_t received; +uint32_t coalesced; +uint32_t over_size; +uint32_t cache; +uint32_t empty_cache; +uint32_t no_match_cache; +uint32_t win_update; +uint32_t no_match; +uint32_t tcp_syn; +uint32_t tcp_ctrl_drain; +uint32_t dup_ack; +uint32_t dup_ack1; +uint32_t dup_ack2; +uint32_t pure_ack; +uint32_t ack_out_of_win; +uint32_t data_out_of_win; +uint32_t data_out_of_order; +uint32_t data_after_pure_ack; +uint32_t bypass_not_tcp; +uint32_t tcp_option; +uint32_t tcp_all_opt; +uint32_t ip_frag; +uint32_t ip_ecn; +uint32_t ip_hacked; +uint32_t ip_option; +uint32_t purge_failed; +uint32_t drain_failed; +uint32_t final_failed; +int64_t timer; +}VirtioNetRscStat ; + +/* Rsc unit general info used to checking if can coalescing */ +typedef struct VirtioNetRscUnit { +void *ip;/* ip header */ +uint16_t *ip_plen;/* data len pointer in ip header field */ +struct tcp_header *tcp;/* tcp header */ +uint16_t tcp_hdrlen;/* tcp header len */ +uint16_t payload;/* pure payload without virtio/eth/ip/tcp */ +}VirtioNetRscUnit ; + +/* Coalesced segmant */ +typedef struct VirtioNetRscSeg { +QTAILQ_ENTRY (VirtioNetRscSeg) next; +void *buf; +size_t size; +uint16_t packets; +uint16_t dup_ack; +bool is_coalesced;/* need recal ipv4 header checksum, mark here */ +VirtioNetRscUnit unit; +NetClientState *nc; +}VirtioNetRscSeg ; + +struct VirtIONet ; +typedef struct VirtIONet VirtIONet ; + +/* Chain is divided by protocol(ipv4/v6) and NetClientInfo */ +typedef struct VirtioNetRscChain { +QTAILQ_ENTRY (VirtioNetRscChain) next; +VirtIONet *n;/* VirtIONet */ +uint16_t proto; +uint8_t gso_type; +uint16_t max_payload; +QEMUTimer *drain_timer; + QTAILQ_HEAD(, VirtioNetRscSeg) buffers; +VirtioNetRscStat stat; +}VirtioNetRscChain ; +/* Maximum packet size we can receive from tap device: header + 64k */ #define VIRTIO_NET_MAX_BUFSIZE (sizeof(struct virtio_net_hdr) + (64 * KiB))
@@ -66,12 +143,18 @@ typedef struct VirtIONet {VirtIONetQueue *vqs;VirtQueue *ctrl_vq;NICState *nic; +/* RSC Chains - temporary storage of coalesced data, +all these data are lost in case of migration */ + QTAILQ_HEAD(, VirtioNetRscChain) rsc_chains;uint32_t tx_timeout;int32_t tx_burst;uint32_t has_vnet_hdr;size_t host_hdr_len;size_t guest_hdr_len;uint64_t host_features; +uint32_t rsc_timeout; +uint8_t rsc4_enabled; +uint8_t rsc6_enabled;uint8_t has_ufo;uint32_t mergeable_rx_bufs;uint8_t promisc;
include/net/eth.h +2 -0
@@ -177,6 +177,8 @@ struct tcp_hdr {#define TH_PUSH 0x08#define TH_ACK 0x10#define TH_URG 0x20 +#define TH_ECE 0x40 +#define TH_CWR 0x80u_short th_win;/* window */ u_short th_sum;/* checksum */ u_short th_urp;/* urgent pointer */
hw/net/virtio-net.c +666 -1
721 lines not on this page · raw message
Signature · 1 line
MST
[Qemu-devel] [PULL v2 17/49] virtio-net: changed VIRTIO_NET_F_RSC_EXT to be 61
In reply to Michael S. TsirkinFrom: Yuri Benditovich <[email protected]>
Allocated feature bit changed in spec draft per TC request.
--- hw/net/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/virtio-net.c +1 -1
@@ -66,7 +66,7 @@#if !defined(VIRTIO_NET_HDR_F_RSC_INFO )#define VIRTIO_NET_HDR_F_RSC_INFO 4/* rsc_ext data in csum_ fields */ -#define VIRTIO_NET_F_RSC_EXT 38 +#define VIRTIO_NET_F_RSC_EXT 61static inline __virtio16 *virtio_net_rsc_ext_num_packets (struct virtio_net_hdr *hdr)
Signature · 1 line
MST
[Qemu-devel] [PULL v2 18/49] virtio: split vhost vsock bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 18 -------- hw/virtio/vhost-vsock-pci.c | 86 +++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 53 ----------------------- hw/virtio/Makefile.objs | 3 ++ 4 files changed, 89 insertions(+), 71 deletions(-) create mode 100644 hw/virtio/vhost-vsock-pci.c
hw/virtio/virtio-pci.h +0 -18
@@ -37,9 +37,6 @@#ifdef CONFIG_VHOST_SCSI #include "hw/virtio/vhost-scsi.h" #endif -#ifdef CONFIG_VHOST_VSOCK -#include "hw/virtio/vhost-vsock.h" -#endif typedef struct VirtIOPCIProxy VirtIOPCIProxy ;typedef struct VirtIOBlkPCI VirtIOBlkPCI ;
@@ -55,7 +52,6 @@ typedef struct VirtIOInputPCI VirtIOInputPCI;typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI ;typedef struct VirtIOInputHostPCI VirtIOInputHostPCI ;typedef struct VirtIOGPUPCI VirtIOGPUPCI ; -typedef struct VHostVSockPCI VHostVSockPCI ;typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ;/* virtio-pci-bus */
@@ -388,20 +384,6 @@ struct VirtIOGPUPCI {VirtIOGPU vdev; }; -#ifdef CONFIG_VHOST_VSOCK -/* -* vhost-vsock-pci: This extends VirtioPCIProxy. -*/ -#define TYPE_VHOST_VSOCK_PCI "vhost-vsock-pci-base" -#define VHOST_VSOCK_PCI (obj) \ - OBJECT_CHECK(VHostVSockPCI, (obj), TYPE_VHOST_VSOCK_PCI) - -struct VHostVSockPCI { -VirtIOPCIProxy parent_obj; -VHostVSock vdev; -}; -#endif -/* * virtio-crypto-pci: This extends VirtioPCIProxy. */
hw/virtio/vhost-vsock-pci.c new file +86 -0
86 lines not on this page · raw message
hw/virtio/virtio-pci.c +0 -53
65 lines not on this page · raw message
hw/virtio/Makefile.objs +3 -0
@@ -11,6 +11,9 @@ obj-$(call land,$(CONFIG_VIRTIO_CRYPTO),$(CONFIG_VIRTIO_PCI)) += virtio-crypto-p obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o +ifeq ($(CONFIG_PCI),y) +obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-pci.o +endif endif common-obj-$(call lnot,$(call land,$(CONFIG_VIRTIO),$(CONFIG_LINUX))) += vhost-stub.o
Signature · 1 line
MST
[Qemu-devel] [PULL v2 31/49] virtio: split virtio gpu bits from virtio-pci.h
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 14 -------------- hw/display/virtio-gpu-pci.c | 14 ++++++++++++++ hw/display/virtio-vga.c | 1 + 3 files changed, 15 insertions(+), 14 deletions(-)
hw/virtio/virtio-pci.h +0 -14
@@ -17,11 +17,9 @@#include "hw/pci/msi.h" #include "hw/virtio/virtio-bus.h" -#include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-crypto.h" typedef struct VirtIOPCIProxy VirtIOPCIProxy ; -typedef struct VirtIOGPUPCI VirtIOGPUPCI ;typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ;/* virtio-pci-bus */
@@ -184,18 +182,6 @@ static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy)*/ #define TYPE_VIRTIO_INPUT_PCI "virtio-input-pci" -/* -* virtio-gpu-pci: This extends VirtioPCIProxy. -*/ -#define TYPE_VIRTIO_GPU_PCI "virtio-gpu-pci" -#define VIRTIO_GPU_PCI (obj) \ - OBJECT_CHECK(VirtIOGPUPCI, (obj), TYPE_VIRTIO_GPU_PCI) - -struct VirtIOGPUPCI { -VirtIOPCIProxy parent_obj; -VirtIOGPU vdev; -}; -/* * virtio-crypto-pci: This extends VirtioPCIProxy. */
hw/display/virtio-gpu-pci.c +14 -0
@@ -19,6 +19,20 @@#include "hw/virtio/virtio-pci.h" #include "hw/virtio/virtio-gpu.h" +typedef struct VirtIOGPUPCI VirtIOGPUPCI ; + +/* +* virtio-gpu-pci: This extends VirtioPCIProxy. +*/ +#define TYPE_VIRTIO_GPU_PCI "virtio-gpu-pci" +#define VIRTIO_GPU_PCI (obj) \ + OBJECT_CHECK(VirtIOGPUPCI, (obj), TYPE_VIRTIO_GPU_PCI) + +struct VirtIOGPUPCI { +VirtIOPCIProxy parent_obj; +VirtIOGPU vdev; +}; +static Property virtio_gpu_pci_properties[] = {DEFINE_VIRTIO_GPU_PCI_PROPERTIES (VirtIOPCIProxy),DEFINE_PROP_END_OF_LIST (),
hw/display/virtio-vga.c +1 -0
@@ -3,6 +3,7 @@#include "hw/pci/pci.h" #include "vga_int.h" #include "hw/virtio/virtio-pci.h" +#include "hw/virtio/virtio-gpu.h" #include "qapi/error.h" /*
Signature · 1 line
MST
[Qemu-devel] [PULL v2 26/49] virtio: split vhost scsi bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 19 -------- hw/virtio/vhost-scsi-pci.c | 97 ++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 61 ------------------------ hw/virtio/Makefile.objs | 1 + 4 files changed, 98 insertions(+), 80 deletions(-) create mode 100644 hw/virtio/vhost-scsi-pci.c
hw/virtio/virtio-pci.h +0 -19
@@ -24,16 +24,11 @@#include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-crypto.h" -#ifdef CONFIG_VHOST_SCSI -#include "hw/virtio/vhost-scsi.h" -#endif -typedef struct VirtIOPCIProxy VirtIOPCIProxy ;typedef struct VirtIOBlkPCI VirtIOBlkPCI ;typedef struct VirtIOSCSIPCI VirtIOSCSIPCI ;typedef struct VirtIOSerialPCI VirtIOSerialPCI ;typedef struct VirtIONetPCI VirtIONetPCI ; -typedef struct VHostSCSIPCI VHostSCSIPCI ;typedef struct VirtIOGPUPCI VirtIOGPUPCI ;typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ;
@@ -204,20 +199,6 @@ struct VirtIOSCSIPCI {VirtIOSCSI vdev; }; -#ifdef CONFIG_VHOST_SCSI -/* -* vhost-scsi-pci: This extends VirtioPCIProxy. -*/ -#define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci-base" -#define VHOST_SCSI_PCI (obj) \ - OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI) - -struct VHostSCSIPCI { -VirtIOPCIProxy parent_obj; -VHostSCSI vdev; -}; -#endif -/* * virtio-blk-pci: This extends VirtioPCIProxy. */
hw/virtio/vhost-scsi-pci.c new file +97 -0
97 lines not on this page · raw message
hw/virtio/virtio-pci.c +0 -61
73 lines not on this page · raw message
hw/virtio/Makefile.objs +1 -0
@@ -15,6 +15,7 @@ ifeq ($(CONFIG_PCI),y) obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-pci.o obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk-pci.o obj-$(CONFIG_VHOST_USER_SCSI) += vhost-user-scsi-pci.o +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi-pci.o obj-$(CONFIG_VIRTIO_INPUT_HOST) += virtio-input-host-pci.o obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-pci.o obj-$(CONFIG_VIRTIO_RNG) += virtio-rng-pci.o
Signature · 1 line
MST
[Qemu-devel] [PULL v2 28/49] virtio: split virtio blk bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 14 ------ hw/virtio/virtio-blk-pci.c | 100 +++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 61 ---------------------- hw/virtio/Makefile.objs | 1 + tests/Makefile.include | 4 +- 5 files changed, 103 insertions(+), 77 deletions(-) create mode 100644 hw/virtio/virtio-blk-pci.c
hw/virtio/virtio-pci.h +0 -14
@@ -16,7 +16,6 @@#define QEMU_VIRTIO_PCI_H #include "hw/pci/msi.h" -#include "hw/virtio/virtio-blk.h" #include "hw/virtio/virtio-net.h" #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-bus.h"
@@ -24,7 +23,6 @@#include "hw/virtio/virtio-crypto.h" typedef struct VirtIOPCIProxy VirtIOPCIProxy ; -typedef struct VirtIOBlkPCI VirtIOBlkPCI ;typedef struct VirtIOSerialPCI VirtIOSerialPCI ;typedef struct VirtIONetPCI VirtIONetPCI ;typedef struct VirtIOGPUPCI VirtIOGPUPCI ;
@@ -185,18 +183,6 @@ static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy) proxy->disable_modern = true; } -/* -* virtio-blk-pci: This extends VirtioPCIProxy. -*/ -#define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci-base" -#define VIRTIO_BLK_PCI (obj) \ - OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI) - -struct VirtIOBlkPCI { -VirtIOPCIProxy parent_obj; -VirtIOBlock vdev; -}; -/* * virtio-serial-pci: This extends VirtioPCIProxy. */
hw/virtio/virtio-blk-pci.c new file +100 -0
100 lines not on this page · raw message
hw/virtio/virtio-pci.c +0 -61
79 lines not on this page · raw message
hw/virtio/Makefile.objs +1 -0
@@ -22,6 +22,7 @@ obj-$(CONFIG_VIRTIO_RNG) += virtio-rng-pci.o obj-$(CONFIG_VIRTIO_BALLOON) += virtio-balloon-pci.o obj-$(CONFIG_VIRTIO_9P) += virtio-9p-pci.o obj-$(CONFIG_VIRTIO_SCSI) += virtio-scsi-pci.o +obj-$(CONFIG_VIRTIO_BLK) += virtio-blk-pci.o endif endif
tests/Makefile.include +2 -2
@@ -148,7 +148,7 @@ check-qtest-virtioserial-y += tests/virtio-console-test$(EXESUF) check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_BALLOON) += tests/virtio-balloon-test$(EXESUF) -check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) +check-qtest-virtio-$(CONFIG_VIRTIO_BLK) += tests/virtio-blk-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_RNG) += tests/virtio-rng-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_SCSI) += tests/virtio-scsi-test$(EXESUF) ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy)
@@ -285,7 +285,7 @@ check-qtest-arm-y += tests/pca9552-test$(EXESUF) check-qtest-arm-y += tests/ds1338-test$(EXESUF) check-qtest-arm-y += tests/microbit-test$(EXESUF) check-qtest-arm-y += tests/m25p80-test$(EXESUF) -check-qtest-arm-y += tests/virtio-blk-test$(EXESUF) +check-qtest-arm-$(CONFIG_VIRTIO_BLK) += tests/virtio-blk-test$(EXESUF) check-qtest-arm-y += tests/test-arm-mptimer$(EXESUF) check-qtest-arm-y += tests/boot-serial-test$(EXESUF) check-qtest-arm-$(CONFIG_SDHCI) += tests/sdhci-test$(EXESUF)
Signature · 1 line
MST
[Qemu-devel] [PULL v2 25/49] virtio: split vhost user scsi bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 11 ---- hw/virtio/vhost-user-scsi-pci.c | 103 ++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 60 ------------------- hw/virtio/Makefile.objs | 1 + 4 files changed, 104 insertions(+), 71 deletions(-) create mode 100644 hw/virtio/vhost-user-scsi-pci.c
hw/virtio/virtio-pci.h +0 -11
@@ -23,7 +23,6 @@#include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-crypto.h" -#include "hw/virtio/vhost-user-scsi.h" #ifdef CONFIG_VHOST_SCSI #include "hw/virtio/vhost-scsi.h"
@@ -35,7 +34,6 @@ typedef struct VirtIOSCSIPCI VirtIOSCSIPCI;typedef struct VirtIOSerialPCI VirtIOSerialPCI ;typedef struct VirtIONetPCI VirtIONetPCI ;typedef struct VHostSCSIPCI VHostSCSIPCI ; -typedef struct VHostUserSCSIPCI VHostUserSCSIPCI ;typedef struct VirtIOGPUPCI VirtIOGPUPCI ;typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ;
@@ -220,15 +218,6 @@ struct VHostSCSIPCI { };#endif -#define TYPE_VHOST_USER_SCSI_PCI "vhost-user-scsi-pci-base" -#define VHOST_USER_SCSI_PCI (obj) \ - OBJECT_CHECK(VHostUserSCSIPCI, (obj), TYPE_VHOST_USER_SCSI_PCI) - -struct VHostUserSCSIPCI { -VirtIOPCIProxy parent_obj; -VHostUserSCSI vdev; -}; -/* * virtio-blk-pci: This extends VirtioPCIProxy. */
hw/virtio/vhost-user-scsi-pci.c new file +103 -0
103 lines not on this page · raw message
hw/virtio/virtio-pci.c +0 -60
72 lines not on this page · raw message
hw/virtio/Makefile.objs +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o ifeq ($(CONFIG_PCI),y) obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-pci.o obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk-pci.o +obj-$(CONFIG_VHOST_USER_SCSI) += vhost-user-scsi-pci.o obj-$(CONFIG_VIRTIO_INPUT_HOST) += virtio-input-host-pci.o obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-pci.o obj-$(CONFIG_VIRTIO_RNG) += virtio-rng-pci.o
Signature · 1 line
MST
[Qemu-devel] [PULL v2 29/49] virtio: split virtio net bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 14 ------ hw/virtio/virtio-net-pci.c | 98 ++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 59 ----------------------- hw/virtio/Makefile.objs | 1 + tests/Makefile.include | 2 +- 5 files changed, 100 insertions(+), 74 deletions(-) create mode 100644 hw/virtio/virtio-net-pci.c
hw/virtio/virtio-pci.h +0 -14
@@ -16,7 +16,6 @@#define QEMU_VIRTIO_PCI_H #include "hw/pci/msi.h" -#include "hw/virtio/virtio-net.h" #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-gpu.h"
@@ -24,7 +23,6 @@typedef struct VirtIOPCIProxy VirtIOPCIProxy ;typedef struct VirtIOSerialPCI VirtIOSerialPCI ; -typedef struct VirtIONetPCI VirtIONetPCI ;typedef struct VirtIOGPUPCI VirtIOGPUPCI ;typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ;
@@ -195,18 +193,6 @@ struct VirtIOSerialPCI {VirtIOSerial vdev; }; -/* -* virtio-net-pci: This extends VirtioPCIProxy. -*/ -#define TYPE_VIRTIO_NET_PCI "virtio-net-pci-base" -#define VIRTIO_NET_PCI (obj) \ - OBJECT_CHECK(VirtIONetPCI, (obj), TYPE_VIRTIO_NET_PCI) - -struct VirtIONetPCI { -VirtIOPCIProxy parent_obj; -VirtIONet vdev; -}; -/* * virtio-input-pci: This extends VirtioPCIProxy. */
hw/virtio/virtio-net-pci.c new file +98 -0
98 lines not on this page · raw message
hw/virtio/virtio-pci.c +0 -59
77 lines not on this page · raw message
hw/virtio/Makefile.objs +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_VIRTIO_BALLOON) += virtio-balloon-pci.o obj-$(CONFIG_VIRTIO_9P) += virtio-9p-pci.o obj-$(CONFIG_VIRTIO_SCSI) += virtio-scsi-pci.o obj-$(CONFIG_VIRTIO_BLK) += virtio-blk-pci.o +obj-$(CONFIG_VIRTIO_NET) += virtio-net-pci.o endif endif
tests/Makefile.include +1 -1
@@ -146,7 +146,7 @@ check-qtest-ipack-y += tests/ipoctal232-test$(EXESUF) check-qtest-virtioserial-y += tests/virtio-console-test$(EXESUF) -check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) +check-qtest-virtio-$(CONFIG_VIRTIO_NET) += tests/virtio-net-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_BALLOON) += tests/virtio-balloon-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_BLK) += tests/virtio-blk-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_RNG) += tests/virtio-rng-test$(EXESUF)
Signature · 1 line
MST
[Qemu-devel] [PULL v2 27/49] virtio: split virtio scsi bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
Notice that we can't still run tests with it disabled. Both cdrom-test and drive_del-test use virtio-scsi without checking if it is enabled.
--- hw/virtio/virtio-pci.h | 14 ----- hw/virtio/virtio-pci.c | 71 ------------------------ hw/virtio/virtio-scsi-pci.c | 107 ++++++++++++++++++++++++++++++++++++ hw/virtio/Makefile.objs | 1 + tests/Makefile.include | 2 +- 5 files changed, 109 insertions(+), 86 deletions(-) create mode 100644 hw/virtio/virtio-scsi-pci.c
hw/virtio/virtio-pci.h +0 -14
@@ -19,14 +19,12 @@#include "hw/virtio/virtio-blk.h" #include "hw/virtio/virtio-net.h" #include "hw/virtio/virtio-serial.h" -#include "hw/virtio/virtio-scsi.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-crypto.h" typedef struct VirtIOPCIProxy VirtIOPCIProxy ;typedef struct VirtIOBlkPCI VirtIOBlkPCI ; -typedef struct VirtIOSCSIPCI VirtIOSCSIPCI ;typedef struct VirtIOSerialPCI VirtIOSerialPCI ;typedef struct VirtIONetPCI VirtIONetPCI ;typedef struct VirtIOGPUPCI VirtIOGPUPCI ;
@@ -187,18 +185,6 @@ static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy) proxy->disable_modern = true; } -/* -* virtio-scsi-pci: This extends VirtioPCIProxy. -*/ -#define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci-base" -#define VIRTIO_SCSI_PCI (obj) \ - OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI) - -struct VirtIOSCSIPCI { -VirtIOPCIProxy parent_obj; -VirtIOSCSI vdev; -}; -/* * virtio-blk-pci: This extends VirtioPCIProxy. */
hw/virtio/virtio-pci.c +0 -71
89 lines not on this page · raw message
hw/virtio/virtio-scsi-pci.c new file +107 -0
107 lines not on this page · raw message
hw/virtio/Makefile.objs +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-pci.o obj-$(CONFIG_VIRTIO_RNG) += virtio-rng-pci.o obj-$(CONFIG_VIRTIO_BALLOON) += virtio-balloon-pci.o obj-$(CONFIG_VIRTIO_9P) += virtio-9p-pci.o +obj-$(CONFIG_VIRTIO_SCSI) += virtio-scsi-pci.o endif endif
tests/Makefile.include +1 -1
@@ -150,7 +150,7 @@ check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_BALLOON) += tests/virtio-balloon-test$(EXESUF) check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_RNG) += tests/virtio-rng-test$(EXESUF) -check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF) +check-qtest-virtio-$(CONFIG_VIRTIO_SCSI) += tests/virtio-scsi-test$(EXESUF) ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) check-qtest-virtio-$(CONFIG_VIRTIO_9P) += tests/virtio-9p-test$(EXESUF) endif
Signature · 1 line
MST
[Qemu-devel] [PULL v2 35/49] virtio: Make disable-legacy/disable-modern compat properties optional
In reply to Michael S. TsirkinFrom: Eduardo Habkost <[email protected]>
The disable-legacy and disable-modern properties apply only to some virtio-pci devices. Make those properties optional.
This fixes the crash introduced by commit f6e501a28ef9 ("virtio: Provide version-specific variants of virtio PCI devices"):
$ qemu-system-x86_64 -machine pc-i440fx-2.6 \
-device virtio-net-pci-non-transitional
Unexpected error in object_property_find() at qom/object.c:1092:
qemu-system-x86_64: -device virtio-net-pci-non-transitional: can't apply \
global virtio-pci.disable-modern=on: Property '.disable-modern' not found
Aborted (core dumped)--- hw/core/machine.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/core/machine.c +3 -2
@@ -91,8 +91,9 @@ const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);GlobalProperty hw_compat_2_6[] = { {"virtio-mmio" ,"format_transport_address" ,"off" }, - {"virtio-pci" ,"disable-modern" ,"on" }, - {"virtio-pci" ,"disable-legacy" ,"off" }, +/* Optional because not all virtio-pci devices support legacy mode */ + {"virtio-pci" ,"disable-modern" ,"on" , .optional = true }, + {"virtio-pci" ,"disable-legacy" ,"off" , .optional = true }, };const size_t hw_compat_2_6_len =G_N_ELEMENTS (hw_compat_2_6);
Signature · 1 line
MST
[Qemu-devel] [PULL v2 33/49] virtio: virtio 9p really requires CONFIG_VIRTFS to work
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- default-configs/virtio.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
default-configs/virtio.mak +1 -1
@@ -1,7 +1,7 @@ CONFIG_VHOST_USER_SCSI=$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX)) CONFIG_VHOST_USER_BLK=$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX)) CONFIG_VIRTIO=y -CONFIG_VIRTIO_9P=y +CONFIG_VIRTIO_9P=$(CONFIG_VIRTFS) CONFIG_VIRTIO_BALLOON=y CONFIG_VIRTIO_BLK=y CONFIG_VIRTIO_CRYPTO=y
Signature · 1 line
MST
[Qemu-devel] [PULL v2 37/49] tpm: add a "ppi" boolean property
In reply to Michael S. TsirkinFrom: Marc-André Lureau <[email protected]>
The following patches implement the TPM Physical Presence Interface, make use of a new memory region and a fw_cfg entry. Enable PPI by default with >=4.0 machine type, to avoid migration issues.
--- hw/core/machine.c | 2 ++ hw/tpm/tpm_crb.c | 3 +++ hw/tpm/tpm_tis.c | 3 +++ 3 files changed, 8 insertions(+)
hw/core/machine.c +2 -0
@@ -28,6 +28,8 @@ GlobalProperty hw_compat_3_1[] = { { "pcie-root-port", "x-width", "1" }, { "memory-backend-file", "x-use-canonical-path-for-ramblock-id", "true" }, { "memory-backend-memfd", "x-use-canonical-path-for-ramblock-id", "true" }, + { "tpm-crb", "ppi", "false" }, + { "tpm-tis", "ppi", "false" }, };const size_t hw_compat_3_1_len =G_N_ELEMENTS (hw_compat_3_1);
hw/tpm/tpm_crb.c +3 -0
@@ -41,6 +41,8 @@ typedef struct CRBState {MemoryRegion cmdmem;size_t be_buffer_size; + +bool ppi_enabled; } CRBState;#define CRB (obj) OBJECT_CHECK(CRBState, (obj), TYPE_TPM_CRB)
@@ -221,6 +223,7 @@ static const VMStateDescription vmstate_tpm_crb = {static Property tpm_crb_properties[] = {DEFINE_PROP_TPMBE ("tpmdev" , CRBState, tpmbe), +DEFINE_PROP_BOOL ("ppi" , CRBState, ppi_enabled, true),DEFINE_PROP_END_OF_LIST (), };
hw/tpm/tpm_tis.c +3 -0
@@ -81,6 +81,8 @@ typedef struct TPMState {TPMVersion be_tpm_version;size_t be_buffer_size; + +bool ppi_enabled; } TPMState;#define TPM (obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS)
@@ -954,6 +956,7 @@ static const VMStateDescription vmstate_tpm_tis = {static Property tpm_tis_properties[] = {DEFINE_PROP_UINT32 ("irq" , TPMState, irq_num,TPM_TIS_IRQ ),DEFINE_PROP_TPMBE ("tpmdev" , TPMState, be_driver), +DEFINE_PROP_BOOL ("ppi" , TPMState, ppi_enabled, true),DEFINE_PROP_END_OF_LIST (), };
Signature · 1 line
MST
[Qemu-devel] [PULL v2 19/49] virtio: split virtio input host bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
For consistency with other devices, rename virtio_host_{initfn,pci_info} to virtio_input_host_{initfn,info}.
--- default-configs/virtio.mak | 1 + hw/virtio/virtio-pci.h | 14 --------- hw/virtio/virtio-input-host-pci.c | 48 +++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 23 --------------- hw/virtio/Makefile.objs | 1 + 5 files changed, 50 insertions(+), 37 deletions(-) create mode 100644 hw/virtio/virtio-input-host-pci.c
default-configs/virtio.mak +1 -0
@@ -12,3 +12,4 @@ CONFIG_VIRTIO_RNG=y CONFIG_SCSI=y CONFIG_VIRTIO_SCSI=y CONFIG_VIRTIO_SERIAL=y +CONFIG_VIRTIO_INPUT_HOST=$(CONFIG_LINUX)
hw/virtio/virtio-pci.h +0 -14
@@ -50,7 +50,6 @@ typedef struct VHostUserBlkPCI VHostUserBlkPCI;typedef struct VirtIORngPCI VirtIORngPCI ;typedef struct VirtIOInputPCI VirtIOInputPCI ;typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI ; -typedef struct VirtIOInputHostPCI VirtIOInputHostPCI ;typedef struct VirtIOGPUPCI VirtIOGPUPCI ;typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ;
@@ -359,19 +358,6 @@ struct VirtIOInputHIDPCI {VirtIOInputHID vdev; }; -#ifdef CONFIG_LINUX - -#define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci-base" -#define VIRTIO_INPUT_HOST_PCI (obj) \ - OBJECT_CHECK(VirtIOInputHostPCI, (obj), TYPE_VIRTIO_INPUT_HOST_PCI) - -struct VirtIOInputHostPCI { -VirtIOPCIProxy parent_obj; -VirtIOInputHost vdev; -}; - -#endif -/* * virtio-gpu-pci: This extends VirtioPCIProxy. */
hw/virtio/virtio-input-host-pci.c new file +48 -0
48 lines not on this page · raw message
hw/virtio/virtio-pci.c +0 -23
@@ -2707,26 +2707,6 @@ static const VirtioPCIDeviceTypeInfo virtio_tablet_pci_info = { .instance_init = virtio_tablet_initfn, }; -#ifdef CONFIG_LINUX -static void virtio_host_initfn (Object *obj) -{ -VirtIOInputHostPCI *dev =VIRTIO_INPUT_HOST_PCI (obj); - -virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev), -TYPE_VIRTIO_INPUT_HOST ); -} - -static const VirtioPCIDeviceTypeInfo virtio_host_pci_info = { - .base_name =TYPE_VIRTIO_INPUT_HOST_PCI , - .generic_name ="virtio-input-host-pci" , - .transitional_name ="virtio-input-host-pci-transitional" , - .non_transitional_name ="virtio-input-host-pci-non-transitional" , - .parent =TYPE_VIRTIO_INPUT_PCI , - .instance_size =sizeof (VirtIOInputHostPCI), - .instance_init = virtio_host_initfn, -}; -#endif -/* virtio-pci-bus */ static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
@@ -2785,9 +2765,6 @@ static void virtio_pci_register_types(void)virtio_pci_types_register (&virtio_keyboard_pci_info);virtio_pci_types_register (&virtio_mouse_pci_info);virtio_pci_types_register (&virtio_tablet_pci_info); -#ifdef CONFIG_LINUX -virtio_pci_types_register (&virtio_host_pci_info); -#endif #ifdef CONFIG_VIRTFS virtio_pci_types_register (&virtio_9p_pci_info);#endif
hw/virtio/Makefile.objs +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o ifeq ($(CONFIG_PCI),y) obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-pci.o +obj-$(CONFIG_VIRTIO_INPUT_HOST) += virtio-input-host-pci.o endif endif
Signature · 1 line
MST
[Qemu-devel] [PULL v2 38/49] tpm: allocate/map buffer for TPM Physical Presence interface
In reply to Michael S. TsirkinFrom: Stefan Berger <[email protected]>
Implement a virtual memory device for the TPM Physical Presence interface. The memory is located at 0xFED45000 and used by ACPI to send messages to the firmware (BIOS) and by the firmware to provide parameters for each one of the supported codes.
This interface should be used by all TPM devices on x86 and can be added by calling tpm_ppi_init_io().
Note: bios_linker cannot be used to allocate the PPI memory region, since the reserved memory should stay stable across reboots, and might be needed before the ACPI tables are installed.
--- hw/tpm/tpm_ppi.h | 36 ++++++++++++++++++++++++++++++++++++ include/hw/acpi/tpm.h | 6 ++++++ hw/tpm/tpm_crb.c | 7 +++++++ hw/tpm/tpm_ppi.c | 31 +++++++++++++++++++++++++++++++ hw/tpm/tpm_tis.c | 7 +++++++ hw/tpm/Makefile.objs | 1 + 6 files changed, 88 insertions(+) create mode 100644 hw/tpm/tpm_ppi.h create mode 100644 hw/tpm/tpm_ppi.c
hw/tpm/tpm_ppi.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* TPM Physical Presence Interface +* +* Copyright (C) 2018 IBM Corporation +* +* Authors: +* Stefan Berger <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ +#ifndef TPM_TPM_PPI_H +#define TPM_TPM_PPI_H + +#include "hw/acpi/tpm.h" +#include "exec/address-spaces.h" + +typedef struct TPMPPI { +MemoryRegion ram; +uint8_t *buf; +}TPMPPI ; + +/** +* tpm_ppi_init: +* @tpmppi: a TPMPPI +* @m: the address-space / MemoryRegion to use +* @addr: the address of the PPI region +* @obj: the owner object +* +* Register the TPM PPI memory region at @addr on the given address +* space for the object @obj. +**/ +void tpm_ppi_init (TPMPPI *tpmppi,struct MemoryRegion *m, +hwaddr addr,Object *obj); + +#endif /* TPM_TPM_PPI_H */
include/hw/acpi/tpm.h +6 -0
@@ -188,4 +188,10 @@ REG32(CRB_DATA_BUFFER, 0x80)#define TPM2_START_METHOD_MMIO 6#define TPM2_START_METHOD_CRB 7 +/* +* Physical Presence Interface +*/ +#define TPM_PPI_ADDR_SIZE 0x400 +#define TPM_PPI_ADDR_BASE 0xFED45000 +#endif /* HW_ACPI_TPM_H */
hw/tpm/tpm_crb.c +7 -0
@@ -29,6 +29,7 @@#include "sysemu/reset.h" #include "tpm_int.h" #include "tpm_util.h" +#include "tpm_ppi.h" #include "trace.h" typedef struct CRBState {
@@ -43,6 +44,7 @@ typedef struct CRBState {size_t be_buffer_size;bool ppi_enabled; +TPMPPI ppi; } CRBState;#define CRB (obj) OBJECT_CHECK(CRBState, (obj), TYPE_TPM_CRB)
@@ -294,6 +296,11 @@ static void tpm_crb_realize(DeviceState *dev, Error **errp)memory_region_add_subregion (get_system_memory (),TPM_CRB_ADDR_BASE +sizeof (s->regs), &s->cmdmem); +if (s->ppi_enabled) { +tpm_ppi_init (&s->ppi,get_system_memory (), +TPM_PPI_ADDR_BASE ,OBJECT (s)); + } +qemu_register_reset (tpm_crb_reset, dev); }
hw/tpm/tpm_ppi.c new file +31 -0
@@ -0,0 +1,31 @@ +/* +* tpm_ppi.c - TPM Physical Presence Interface +* +* Copyright (C) 2018 IBM Corporation +* +* Authors: +* Stefan Berger <[email protected]> +* +* 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 "qapi/error.h" +#include "cpu.h" +#include "sysemu/memory_mapping.h" +#include "migration/vmstate.h" +#include "tpm_ppi.h" + +void tpm_ppi_init (TPMPPI *tpmppi,struct MemoryRegion *m, +hwaddr addr,Object *obj) +{ + tpmppi->buf =g_malloc0 (HOST_PAGE_ALIGN (TPM_PPI_ADDR_SIZE )); +memory_region_init_ram_device_ptr (&tpmppi->ram, obj,"tpm-ppi" , +TPM_PPI_ADDR_SIZE , tpmppi->buf); +vmstate_register_ram (&tpmppi->ram,DEVICE (obj)); + +memory_region_add_subregion (m, addr, &tpmppi->ram); +}
hw/tpm/tpm_tis.c +7 -0
@@ -31,6 +31,7 @@#include "sysemu/tpm_backend.h" #include "tpm_int.h" #include "tpm_util.h" +#include "tpm_ppi.h" #include "trace.h" #define TPM_TIS_NUM_LOCALITIES 5/* per spec */
@@ -83,6 +84,7 @@ typedef struct TPMState {size_t be_buffer_size;bool ppi_enabled; +TPMPPI ppi; } TPMState;#define TPM (obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS)
@@ -983,6 +985,11 @@ static void tpm_tis_realizefn(DeviceState *dev, Error **errp)memory_region_add_subregion (isa_address_space (ISA_DEVICE (dev)),TPM_TIS_ADDR_BASE , &s->mmio); + +if (s->ppi_enabled) { +tpm_ppi_init (&s->ppi,isa_address_space (ISA_DEVICE (dev)), +TPM_PPI_ADDR_BASE ,OBJECT (s)); + } }static void tpm_tis_initfn (Object *obj)
hw/tpm/Makefile.objs +1 -0
@@ -1,4 +1,5 @@ common-obj-y += tpm_util.o +obj-y += tpm_ppi.o common-obj-$(CONFIG_TPM_TIS) += tpm_tis.o common-obj-$(CONFIG_TPM_CRB) += tpm_crb.o common-obj-$(CONFIG_TPM_PASSTHROUGH) += tpm_passthrough.o
Signature · 1 line
MST
[Qemu-devel] [PULL v2 39/49] acpi: expose TPM/PPI configuration parameters to firmware via fw_cfg
In reply to Michael S. TsirkinFrom: Stefan Berger <[email protected]>
To avoid having to hard code the base address of the PPI virtual memory device we introduce a fw_cfg file etc/tpm/config that holds the base address of the PPI device, the version of the PPI interface and the version of the attached TPM.
--- docs/specs/tpm.txt | 19 +++++++++++++++++++ include/hw/acpi/tpm.h | 3 +++ hw/i386/acpi-build.c | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+)
docs/specs/tpm.txt +19 -0
@@ -34,6 +34,25 @@ The CRB interface makes a memory mapped IO region in the area 0xfed40000 - QEMU files related to TPM CRB interface: - hw/tpm/tpm_crb.c += fw_cfg interface = + +The bios/firmware may read the "etc/tpm/config" fw_cfg entry for +configuring the guest appropriately. + +The entry of 6 bytes has the following content, in little-endian: + + #define TPM_VERSION_UNSPEC 0 + #define TPM_VERSION_1_2 1 + #define TPM_VERSION_2_0 2 + + #define TPM_PPI_VERSION_NONE 0 + #define TPM_PPI_VERSION_1_30 1 + + struct FwCfgTPMConfig { + uint32_t tpmppi_address; /* PPI memory location */ + uint8_t tpm_version; /* TPM version */ + uint8_t tpmppi_version; /* PPI version */ + }; = ACPI Interface =
include/hw/acpi/tpm.h +3 -0
@@ -194,4 +194,7 @@ REG32(CRB_DATA_BUFFER, 0x80)#define TPM_PPI_ADDR_SIZE 0x400#define TPM_PPI_ADDR_BASE 0xFED45000 +#define TPM_PPI_VERSION_NONE 0 +#define TPM_PPI_VERSION_1_30 1 +#endif /* HW_ACPI_TPM_H */
hw/i386/acpi-build.c +19 -0
@@ -119,6 +119,12 @@ typedef struct AcpiBuildPciBusHotplugState {bool pcihp_bridge_en; } AcpiBuildPciBusHotplugState; +typedef struct FwCfgTPMConfig { +uint32_t tpmppi_address; +uint8_t tpm_version; +uint8_t tpmppi_version; +} QEMU_PACKED FwCfgTPMConfig; +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 );
@@ -2847,6 +2853,8 @@ void acpi_setup(void)AcpiBuildTables tables;AcpiBuildState *build_state;Object *vmgenid_dev; +TPMIf *tpm; +static FwCfgTPMConfig tpm_config;if (!pcms->fw_cfg) {ACPI_BUILD_DPRINTF ("No fw cfg. Bailing out.\n" );
@@ -2881,6 +2889,17 @@ void acpi_setup(void)fw_cfg_add_file (pcms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data,acpi_data_len (tables.tcpalog)); + tpm =tpm_find (); +if (tpm &&object_property_get_bool (OBJECT (tpm),"ppi" , &error_abort)) { + tpm_config = (FwCfgTPMConfig ) { + .tpmppi_address =cpu_to_le32 (TPM_PPI_ADDR_BASE ), + .tpm_version =tpm_get_version (tpm), + .tpmppi_version =TPM_PPI_VERSION_NONE + }; +fw_cfg_add_file (pcms->fw_cfg,"etc/tpm/config" , + &tpm_config,sizeof tpm_config); + } + vmgenid_dev =find_vmgenid_dev ();if (vmgenid_dev) { vmgenid_add_fw_cfg(VMGENID(vmgenid_dev), pcms->fw_cfg,
Signature · 1 line
MST
[Qemu-devel] [PULL v2 34/49] globals: Allow global properties to be optional
In reply to Michael S. TsirkinFrom: Eduardo Habkost <[email protected]>
Making some global properties optional will let us simplify compat code when a given property works on most (but not all) subclasses of a given type.
Device types will be able to opt out from optional compat properties by simply not registering those properties.
--- include/hw/qdev-core.h | 3 +++ qom/object.c | 3 +++ 2 files changed, 6 insertions(+)
include/hw/qdev-core.h +3 -0
@@ -250,6 +250,8 @@ struct PropertyInfo {/** * GlobalProperty: * @used: Set to true if property was used when initializing a device. +* @optional: If set to true, GlobalProperty will be skipped without errors +* if the property doesn't exist. * * An error is fatal for non-hotplugged devices, when the global is applied. */
@@ -258,6 +260,7 @@ typedef struct GlobalProperty {const char *property;const char *value;bool used; +bool optional; } GlobalProperty; static inline void
qom/object.c +3 -0
@@ -385,6 +385,9 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errpif (object_dynamic_cast (obj, p->driver) ==NULL ) {continue ; } +if (p->optional && !object_property_find (obj, p->property,NULL )) { +continue ; + } p->used = true;object_property_parse (obj, p->value, p->property, &err);if (err !=NULL ) {
Signature · 1 line
MST
[Qemu-devel] [PULL v2 36/49] hw/misc/edu: add msi_uninit() for pci_edu_uninit()
In reply to Michael S. TsirkinFrom: Fei Li <[email protected]>
Let's supplement the msi_uninit() when failing to realize the pci edu device.
--- hw/misc/edu.c | 1 + 1 file changed, 1 insertion(+)
hw/misc/edu.c +1 -0
@@ -377,6 +377,7 @@ static void pci_edu_uninit(PCIDevice *pdev)qemu_mutex_destroy (&edu->thr_mutex);timer_del (&edu->dma_timer); +msi_uninit (pdev); } static void edu_obj_uint64(Object *obj, Visitor *v, const char *name,
Signature · 1 line
MST
[Qemu-devel] [PULL v2 21/49] virtio: split virtio rng bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 14 ------ hw/virtio/virtio-pci.c | 54 ----------------------- hw/virtio/virtio-rng-pci.c | 88 ++++++++++++++++++++++++++++++++++++++ hw/virtio/Makefile.objs | 1 + tests/Makefile.include | 2 +- 5 files changed, 90 insertions(+), 69 deletions(-) create mode 100644 hw/virtio/virtio-rng-pci.c
hw/virtio/virtio-pci.h +0 -14
@@ -18,7 +18,6 @@#include "hw/pci/msi.h" #include "hw/virtio/virtio-blk.h" #include "hw/virtio/virtio-net.h" -#include "hw/virtio/virtio-rng.h" #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-scsi.h" #include "hw/virtio/virtio-balloon.h"
@@ -46,7 +45,6 @@ typedef struct VirtIONetPCI VirtIONetPCI;typedef struct VHostSCSIPCI VHostSCSIPCI ;typedef struct VHostUserSCSIPCI VHostUserSCSIPCI ;typedef struct VHostUserBlkPCI VHostUserBlkPCI ; -typedef struct VirtIORngPCI VirtIORngPCI ;typedef struct VirtIOGPUPCI VirtIOGPUPCI ;typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ;
@@ -319,18 +317,6 @@ typedef struct V9fsPCIState {#endif -/* -* virtio-rng-pci: This extends VirtioPCIProxy. -*/ -#define TYPE_VIRTIO_RNG_PCI "virtio-rng-pci-base" -#define VIRTIO_RNG_PCI (obj) \ - OBJECT_CHECK(VirtIORngPCI, (obj), TYPE_VIRTIO_RNG_PCI) - -struct VirtIORngPCI { -VirtIOPCIProxy parent_obj; -VirtIORNG vdev; -}; -/* * virtio-input-pci: This extends VirtioPCIProxy. */
hw/virtio/virtio-pci.c +0 -54
66 lines not on this page · raw message
hw/virtio/virtio-rng-pci.c new file +88 -0
88 lines not on this page · raw message
hw/virtio/Makefile.objs +1 -0
@@ -15,6 +15,7 @@ ifeq ($(CONFIG_PCI),y) obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-pci.o obj-$(CONFIG_VIRTIO_INPUT_HOST) += virtio-input-host-pci.o obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-pci.o +obj-$(CONFIG_VIRTIO_RNG) += virtio-rng-pci.o endif endif
tests/Makefile.include +1 -1
@@ -149,7 +149,7 @@ check-qtest-virtioserial-y += tests/virtio-console-test$(EXESUF) check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) check-qtest-virtio-y += tests/virtio-balloon-test$(EXESUF) check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) -check-qtest-virtio-y += tests/virtio-rng-test$(EXESUF) +check-qtest-virtio-$(CONFIG_VIRTIO_RNG) += tests/virtio-rng-test$(EXESUF) check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF) ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) check-qtest-virtio-y += tests/virtio-9p-test$(EXESUF)
Signature · 1 line
MST
[Qemu-devel] [PULL v2 22/49] virtio: split virtio balloon bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 14 ----- hw/virtio/virtio-balloon-pci.c | 95 ++++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 61 +--------------------- hw/virtio/Makefile.objs | 1 + tests/Makefile.include | 2 +- 5 files changed, 98 insertions(+), 75 deletions(-) create mode 100644 hw/virtio/virtio-balloon-pci.c
hw/virtio/virtio-pci.h +0 -14
@@ -20,7 +20,6 @@#include "hw/virtio/virtio-net.h" #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-scsi.h" -#include "hw/virtio/virtio-balloon.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-crypto.h"
@@ -39,7 +38,6 @@typedef struct VirtIOPCIProxy VirtIOPCIProxy ;typedef struct VirtIOBlkPCI VirtIOBlkPCI ;typedef struct VirtIOSCSIPCI VirtIOSCSIPCI ; -typedef struct VirtIOBalloonPCI VirtIOBalloonPCI ;typedef struct VirtIOSerialPCI VirtIOSerialPCI ;typedef struct VirtIONetPCI VirtIONetPCI ;typedef struct VHostSCSIPCI VHostSCSIPCI ;
@@ -264,18 +262,6 @@ struct VirtIOBlkPCI {VirtIOBlock vdev; }; -/* -* virtio-balloon-pci: This extends VirtioPCIProxy. -*/ -#define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci-base" -#define VIRTIO_BALLOON_PCI (obj) \ - OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI) - -struct VirtIOBalloonPCI { -VirtIOPCIProxy parent_obj; -VirtIOBalloon vdev; -}; -/* * virtio-serial-pci: This extends VirtioPCIProxy. */
hw/virtio/virtio-balloon-pci.c new file +95 -0
95 lines not on this page · raw message
hw/virtio/virtio-pci.c +1 -60
82 lines not on this page · raw message
hw/virtio/Makefile.objs +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-pci.o obj-$(CONFIG_VIRTIO_INPUT_HOST) += virtio-input-host-pci.o obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-pci.o obj-$(CONFIG_VIRTIO_RNG) += virtio-rng-pci.o +obj-$(CONFIG_VIRTIO_BALLOON) += virtio-balloon-pci.o endif endif
tests/Makefile.include +1 -1
@@ -147,7 +147,7 @@ check-qtest-ipack-y += tests/ipoctal232-test$(EXESUF) check-qtest-virtioserial-y += tests/virtio-console-test$(EXESUF) check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) -check-qtest-virtio-y += tests/virtio-balloon-test$(EXESUF) +check-qtest-virtio-$(CONFIG_VIRTIO_BALLOON) += tests/virtio-balloon-test$(EXESUF) check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_RNG) += tests/virtio-rng-test$(EXESUF) check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF)
Signature · 1 line
MST
[Qemu-devel] [PULL v2 20/49] virtio: split virtio input bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 22 ----- hw/virtio/virtio-input-pci.c | 157 +++++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 113 ------------------------- hw/virtio/Makefile.objs | 1 + 4 files changed, 158 insertions(+), 135 deletions(-) create mode 100644 hw/virtio/virtio-input-pci.c
hw/virtio/virtio-pci.h +0 -22
@@ -23,7 +23,6 @@#include "hw/virtio/virtio-scsi.h" #include "hw/virtio/virtio-balloon.h" #include "hw/virtio/virtio-bus.h" -#include "hw/virtio/virtio-input.h" #include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-crypto.h" #include "hw/virtio/vhost-user-scsi.h"
@@ -48,8 +47,6 @@ typedef struct VHostSCSIPCI VHostSCSIPCI;typedef struct VHostUserSCSIPCI VHostUserSCSIPCI ;typedef struct VHostUserBlkPCI VHostUserBlkPCI ;typedef struct VirtIORngPCI VirtIORngPCI ; -typedef struct VirtIOInputPCI VirtIOInputPCI ; -typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI ;typedef struct VirtIOGPUPCI VirtIOGPUPCI ;typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ;
@@ -338,25 +335,6 @@ struct VirtIORngPCI {* virtio-input-pci: This extends VirtioPCIProxy. */ #define TYPE_VIRTIO_INPUT_PCI "virtio-input-pci" -#define VIRTIO_INPUT_PCI (obj) \ - OBJECT_CHECK(VirtIOInputPCI, (obj), TYPE_VIRTIO_INPUT_PCI) - -struct VirtIOInputPCI { -VirtIOPCIProxy parent_obj; -VirtIOInput vdev; -}; - -#define TYPE_VIRTIO_INPUT_HID_PCI "virtio-input-hid-pci" -#define TYPE_VIRTIO_KEYBOARD_PCI "virtio-keyboard-pci" -#define TYPE_VIRTIO_MOUSE_PCI "virtio-mouse-pci" -#define TYPE_VIRTIO_TABLET_PCI "virtio-tablet-pci" -#define VIRTIO_INPUT_HID_PCI (obj) \ - OBJECT_CHECK(VirtIOInputHIDPCI, (obj), TYPE_VIRTIO_INPUT_HID_PCI) - -struct VirtIOInputHIDPCI { -VirtIOPCIProxy parent_obj; -VirtIOInputHID vdev; -};/* * virtio-gpu-pci: This extends VirtioPCIProxy.
hw/virtio/virtio-input-pci.c new file +157 -0
157 lines not on this page · raw message
hw/virtio/virtio-pci.c +0 -113
134 lines not on this page · raw message
hw/virtio/Makefile.objs +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o ifeq ($(CONFIG_PCI),y) obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-pci.o obj-$(CONFIG_VIRTIO_INPUT_HOST) += virtio-input-host-pci.o +obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-pci.o endif endif
Signature · 1 line
MST
[Qemu-devel] [PULL v2 23/49] virtio: split virtio 9p bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 20 --------- hw/virtio/virtio-9p-pci.c | 88 +++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 54 ------------------------ hw/virtio/Makefile.objs | 1 + tests/Makefile.include | 2 +- 5 files changed, 90 insertions(+), 75 deletions(-) create mode 100644 hw/virtio/virtio-9p-pci.c
hw/virtio/virtio-pci.h +0 -20
@@ -28,9 +28,6 @@#include "hw/virtio/vhost-user-blk.h" #endif -#ifdef CONFIG_VIRTFS -#include "hw/9pfs/virtio-9p.h" -#endif #ifdef CONFIG_VHOST_SCSI #include "hw/virtio/vhost-scsi.h" #endif
@@ -286,23 +283,6 @@ struct VirtIONetPCI {VirtIONet vdev; }; -/* -* virtio-9p-pci: This extends VirtioPCIProxy. -*/ - -#ifdef CONFIG_VIRTFS - -#define TYPE_VIRTIO_9P_PCI "virtio-9p-pci-base" -#define VIRTIO_9P_PCI (obj) \ - OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI) - -typedef struct V9fsPCIState { -VirtIOPCIProxy parent_obj; -V9fsVirtioState vdev; -}V9fsPCIState ; - -#endif -/* * virtio-input-pci: This extends VirtioPCIProxy. */
hw/virtio/virtio-9p-pci.c new file +88 -0
88 lines not on this page · raw message
hw/virtio/virtio-pci.c +0 -54
66 lines not on this page · raw message
hw/virtio/Makefile.objs +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_VIRTIO_INPUT_HOST) += virtio-input-host-pci.o obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-pci.o obj-$(CONFIG_VIRTIO_RNG) += virtio-rng-pci.o obj-$(CONFIG_VIRTIO_BALLOON) += virtio-balloon-pci.o +obj-$(CONFIG_VIRTIO_9P) += virtio-9p-pci.o endif endif
tests/Makefile.include +1 -1
@@ -152,7 +152,7 @@ check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_RNG) += tests/virtio-rng-test$(EXESUF) check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF) ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) -check-qtest-virtio-y += tests/virtio-9p-test$(EXESUF) +check-qtest-virtio-$(CONFIG_VIRTIO_9P) += tests/virtio-9p-test$(EXESUF) endif check-qtest-virtio-y += tests/virtio-serial-test$(EXESUF) check-qtest-virtio-y += $(check-qtest-virtioserial-y)
Signature · 1 line
MST
[Qemu-devel] [PULL v2 24/49] virtio: split vhost user blk bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 18 ------ hw/virtio/vhost-user-blk-pci.c | 103 +++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 62 -------------------- hw/virtio/Makefile.objs | 1 + 4 files changed, 104 insertions(+), 80 deletions(-) create mode 100644 hw/virtio/vhost-user-blk-pci.c
hw/virtio/virtio-pci.h +0 -18
@@ -24,9 +24,6 @@#include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-crypto.h" #include "hw/virtio/vhost-user-scsi.h" -#if defined(CONFIG_VHOST_USER ) && defined(CONFIG_LINUX ) -#include "hw/virtio/vhost-user-blk.h" -#endif #ifdef CONFIG_VHOST_SCSI #include "hw/virtio/vhost-scsi.h"
@@ -39,7 +36,6 @@ typedef struct VirtIOSerialPCI VirtIOSerialPCI;typedef struct VirtIONetPCI VirtIONetPCI ;typedef struct VHostSCSIPCI VHostSCSIPCI ;typedef struct VHostUserSCSIPCI VHostUserSCSIPCI ; -typedef struct VHostUserBlkPCI VHostUserBlkPCI ;typedef struct VirtIOGPUPCI VirtIOGPUPCI ;typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ;
@@ -233,20 +229,6 @@ struct VHostUserSCSIPCI {VHostUserSCSI vdev; }; -#if defined(CONFIG_VHOST_USER ) && defined(CONFIG_LINUX ) -/* -* vhost-user-blk-pci: This extends VirtioPCIProxy. -*/ -#define TYPE_VHOST_USER_BLK_PCI "vhost-user-blk-pci-base" -#define VHOST_USER_BLK_PCI (obj) \ - OBJECT_CHECK(VHostUserBlkPCI, (obj), TYPE_VHOST_USER_BLK_PCI) - -struct VHostUserBlkPCI { -VirtIOPCIProxy parent_obj; -VHostUserBlk vdev; -}; -#endif -/* * virtio-blk-pci: This extends VirtioPCIProxy. */
hw/virtio/vhost-user-blk-pci.c new file +103 -0
103 lines not on this page · raw message
hw/virtio/virtio-pci.c +0 -62
74 lines not on this page · raw message
hw/virtio/Makefile.objs +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o ifeq ($(CONFIG_PCI),y) obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-pci.o +obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk-pci.o obj-$(CONFIG_VIRTIO_INPUT_HOST) += virtio-input-host-pci.o obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-pci.o obj-$(CONFIG_VIRTIO_RNG) += virtio-rng-pci.o
Signature · 1 line
MST
[Qemu-devel] [PULL v2 32/49] virtio: split virtio crypto bits from virtio-pci.h
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
--- hw/virtio/virtio-pci.h | 14 -------------- hw/virtio/virtio-crypto-pci.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-)
hw/virtio/virtio-pci.h +0 -14
@@ -17,10 +17,8 @@#include "hw/pci/msi.h" #include "hw/virtio/virtio-bus.h" -#include "hw/virtio/virtio-crypto.h" typedef struct VirtIOPCIProxy VirtIOPCIProxy ; -typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ;/* virtio-pci-bus */
@@ -182,18 +180,6 @@ static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy)*/ #define TYPE_VIRTIO_INPUT_PCI "virtio-input-pci" -/* -* virtio-crypto-pci: This extends VirtioPCIProxy. -*/ -#define TYPE_VIRTIO_CRYPTO_PCI "virtio-crypto-pci" -#define VIRTIO_CRYPTO_PCI (obj) \ - OBJECT_CHECK(VirtIOCryptoPCI, (obj), TYPE_VIRTIO_CRYPTO_PCI) - -struct VirtIOCryptoPCI { -VirtIOPCIProxy parent_obj; -VirtIOCrypto vdev; -}; -/* Virtio ABI version, if we increment this, we break the guest driver. */ #define VIRTIO_PCI_ABI_VERSION 0
hw/virtio/virtio-crypto-pci.c +14 -0
@@ -19,6 +19,20 @@#include "hw/virtio/virtio-crypto.h" #include "qapi/error.h" +typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ; + +/* +* virtio-crypto-pci: This extends VirtioPCIProxy. +*/ +#define TYPE_VIRTIO_CRYPTO_PCI "virtio-crypto-pci" +#define VIRTIO_CRYPTO_PCI (obj) \ + OBJECT_CHECK(VirtIOCryptoPCI, (obj), TYPE_VIRTIO_CRYPTO_PCI) + +struct VirtIOCryptoPCI { +VirtIOPCIProxy parent_obj; +VirtIOCrypto vdev; +}; +static Property virtio_crypto_pci_properties[] = {DEFINE_PROP_BIT ("ioeventfd" , VirtIOPCIProxy, flags,VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT , true),
Signature · 1 line
MST
[Qemu-devel] [PULL v2 41/49] acpi: add ACPI memory clear interface
In reply to Michael S. TsirkinFrom: Marc-André Lureau <[email protected]>
The interface is described in the "TCG Platform Reset Attack Mitigation Specification", chapter 6 "ACPI _DSM Function". According to Laszlo, it's not so easy to implement in OVMF, he suggested to do it in qemu instead.
See specification documentation for more details, and next commit for memory clear on reset handling.
The underlying TCG specification is accessible from the following page.
This patch implements version 1.0.
--- docs/specs/tpm.txt | 2 ++ hw/acpi/tpm.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+)
docs/specs/tpm.txt +2 -0
@@ -135,6 +135,8 @@ layout: +----------+--------+--------+-------------------------------------------+ | next_step| 0x1 | 0x159 | Operation to execute after reboot by | | | | | firmware. Used by firmware. | + +----------+--------+--------+-------------------------------------------+ + | movv | 0x1 | 0x15a | Memory overwrite variable | +----------+--------+--------+-------------------------------------------+ The following values are supported for the 'func' field. They correspond
hw/acpi/tpm.c +55 -0
67 lines not on this page · raw message
Signature · 1 line
MST
[Qemu-devel] [PULL v2 42/49] tpm: clear RAM when "memory overwrite" requested
In reply to Michael S. TsirkinFrom: Marc-André Lureau <[email protected]>
Note: the "Platform Reset Attack Mitigation" specification isn't explicit about NVDIMM, since they could have different usages. It uses the term "system memory" generally (and also "volatile memory RAM" in its introduction). For initial support, I propose to consider non-volatile memory as not being subject to the memory clear. There is an on-going discussion in the TCG "pcclientwg" working group for future revisions.
CPU cache clearing is done unconditionally in edk2 since commit d20ae95a13e851 (edk2-stable201811).
--- hw/tpm/tpm_ppi.h | 10 ++++++++++ hw/tpm/tpm_crb.c | 3 +++ hw/tpm/tpm_ppi.c | 22 ++++++++++++++++++++++ hw/tpm/tpm_tis.c | 3 +++ hw/tpm/trace-events | 3 +++ 5 files changed, 41 insertions(+)
hw/tpm/tpm_ppi.h +10 -0
@@ -33,4 +33,14 @@ typedef struct TPMPPI {void tpm_ppi_init (TPMPPI *tpmppi,struct MemoryRegion *m,hwaddr addr,Object *obj); +/** +* tpm_ppi_reset: +* @tpmppi: a TPMPPI +* +* Function to call on machine reset. It will check if the "Memory +* overwrite" variable is set, and perform a memory clear on volatile +* memory if requested. +**/ +void tpm_ppi_reset (TPMPPI *tpmppi); +#endif /* TPM_TPM_PPI_H */
hw/tpm/tpm_crb.c +3 -0
@@ -233,6 +233,9 @@ static void tpm_crb_reset(void *dev) {CRBState *s =CRB (dev); +if (s->ppi_enabled) { +tpm_ppi_reset (&s->ppi); + }tpm_backend_reset (s->tpmbe);memset (s->regs,0 ,sizeof (s->regs));
hw/tpm/tpm_ppi.c +22 -0
@@ -16,8 +16,30 @@#include "qapi/error.h" #include "cpu.h" #include "sysemu/memory_mapping.h" +#include "sysemu/reset.h" #include "migration/vmstate.h" #include "tpm_ppi.h" +#include "trace.h" + +void tpm_ppi_reset (TPMPPI *tpmppi) +{ +if (tpmppi->buf[0x15a /* movv, docs/specs/tpm.txt */ ] &0x1 ) { +GuestPhysBlockList guest_phys_blocks; +GuestPhysBlock *block; + +guest_phys_blocks_init (&guest_phys_blocks); +guest_phys_blocks_append (&guest_phys_blocks); + QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) { +trace_tpm_ppi_memset (block->host_addr, + block->target_end - block->target_start); +memset (block->host_addr,0 , + block->target_end - block->target_start); +memory_region_set_dirty (block->mr,0 , + block->target_end - block->target_start); + } +guest_phys_blocks_free (&guest_phys_blocks); + } +}void tpm_ppi_init (TPMPPI *tpmppi,struct MemoryRegion *m,hwaddr addr,Object *obj)
hw/tpm/tpm_tis.c +3 -0
@@ -872,6 +872,9 @@ static void tpm_tis_reset(DeviceState *dev) s->be_buffer_size =MIN (tpm_backend_get_buffer_size (s->be_driver),TPM_TIS_BUFFER_MAX ); +if (s->ppi_enabled) { +tpm_ppi_reset (&s->ppi); + }tpm_backend_reset (s->be_driver); s->active_locty =TPM_TIS_NO_LOCALITY ;
hw/tpm/trace-events +3 -0
@@ -51,3 +51,6 @@ tpm_tis_mmio_write_init_abort(void) "Initiating abort" tpm_tis_mmio_write_lowering_irq(void) "Lowering IRQ" tpm_tis_mmio_write_data2send(uint32_t value, unsigned size) "Data to send to TPM: 0x%08x (size=%d)" tpm_tis_pre_save(uint8_t locty, uint32_t rw_offset) "locty: %d, rw_offset = %u" + +# hw/tpm/tpm_ppi.c +tpm_ppi_memset(uint8_t *ptr, size_t size) "memset: %p %zu"
Signature · 1 line
MST
[Qemu-devel] [PULL v2 43/49] hw: acpi: Fix memory hotplug AML generation error
In reply to Michael S. TsirkinFrom: Yang Zhong <[email protected]>
When using the generated memory hotplug AML, the iasl compiler would give the following error:
dsdt.dsl 266: Return (MOST (_UID, Arg0, Arg1, Arg2)) Error 6080 - Called method returns no value ^
--- hw/acpi/memory_hotplug.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
hw/acpi/memory_hotplug.c +5 -5
@@ -686,15 +686,15 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); s =MEMORY_SLOT_OST_METHOD ; -aml_append (method,aml_return (aml_call4 ( - s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) - ))); +aml_append (method, +aml_call4 (s,aml_name ("_UID" ),aml_arg (0 ), +aml_arg (1 ),aml_arg (2 )));aml_append (dev, method); method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); s =MEMORY_SLOT_EJECT_METHOD ; -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (method, +aml_call2 (s,aml_name ("_UID" ),aml_arg (0 )));aml_append (dev, method);aml_append (dev_container, dev);
Signature · 1 line
MST
[Qemu-devel] [PULL v2 30/49] virtio: split virtio serial bits from virtio-pci
In reply to Michael S. TsirkinFrom: Juan Quintela <[email protected]>
Virtio console and qga tests also depend on CONFIG_VIRTIO_SERIAL.
--- hw/virtio/virtio-pci.h | 14 ----- hw/virtio/virtio-pci.c | 79 ----------------------- hw/virtio/virtio-serial-pci.c | 115 ++++++++++++++++++++++++++++++++++ hw/virtio/Makefile.objs | 1 + tests/Makefile.include | 6 +- 5 files changed, 119 insertions(+), 96 deletions(-) create mode 100644 hw/virtio/virtio-serial-pci.c
hw/virtio/virtio-pci.h +0 -14
@@ -16,13 +16,11 @@#define QEMU_VIRTIO_PCI_H #include "hw/pci/msi.h" -#include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-crypto.h" typedef struct VirtIOPCIProxy VirtIOPCIProxy ; -typedef struct VirtIOSerialPCI VirtIOSerialPCI ;typedef struct VirtIOGPUPCI VirtIOGPUPCI ;typedef struct VirtIOCryptoPCI VirtIOCryptoPCI ;
@@ -181,18 +179,6 @@ static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy) proxy->disable_modern = true; } -/* -* virtio-serial-pci: This extends VirtioPCIProxy. -*/ -#define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci-base" -#define VIRTIO_SERIAL_PCI (obj) \ - OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI) - -struct VirtIOSerialPCI { -VirtIOPCIProxy parent_obj; -VirtIOSerial vdev; -}; -/* * virtio-input-pci: This extends VirtioPCIProxy. */
hw/virtio/virtio-pci.c +0 -79
97 lines not on this page · raw message
hw/virtio/virtio-serial-pci.c new file +115 -0
115 lines not on this page · raw message
hw/virtio/Makefile.objs +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_VIRTIO_9P) += virtio-9p-pci.o obj-$(CONFIG_VIRTIO_SCSI) += virtio-scsi-pci.o obj-$(CONFIG_VIRTIO_BLK) += virtio-blk-pci.o obj-$(CONFIG_VIRTIO_NET) += virtio-net-pci.o +obj-$(CONFIG_VIRTIO_SERIAL) += virtio-serial-pci.o endif endif
tests/Makefile.include +3 -3
@@ -108,7 +108,7 @@ check-unit-y += tests/test-crypto-secret$(EXESUF) check-unit-$(CONFIG_GNUTLS) += tests/test-crypto-tlscredsx509$(EXESUF) check-unit-$(CONFIG_GNUTLS) += tests/test-crypto-tlssession$(EXESUF) ifneq (,$(findstring qemu-ga,$(TOOLS))) -check-unit-$(CONFIG_LINUX) += tests/test-qga$(EXESUF) +check-unit-$(land,$(CONFIG_LINUX),$(CONFIG_VIRTIO_SERIAL)) += tests/test-qga$(EXESUF) endif check-unit-y += tests/test-timed-average$(EXESUF) check-unit-y += tests/test-util-sockets$(EXESUF)
@@ -144,7 +144,7 @@ check-qtest-generic-y += tests/cdrom-test$(EXESUF) check-qtest-ipack-y += tests/ipoctal232-test$(EXESUF) -check-qtest-virtioserial-y += tests/virtio-console-test$(EXESUF) +check-qtest-virtioserial-$(CONFIG_VIRTIO_SERIAL) += tests/virtio-console-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_NET) += tests/virtio-net-test$(EXESUF) check-qtest-virtio-$(CONFIG_VIRTIO_BALLOON) += tests/virtio-balloon-test$(EXESUF)
@@ -154,7 +154,7 @@ check-qtest-virtio-$(CONFIG_VIRTIO_SCSI) += tests/virtio-scsi-test$(EXESUF) ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) check-qtest-virtio-$(CONFIG_VIRTIO_9P) += tests/virtio-9p-test$(EXESUF) endif -check-qtest-virtio-y += tests/virtio-serial-test$(EXESUF) +check-qtest-virtio-$(CONFIG_VIRTIO_SERIAL) += tests/virtio-serial-test$(EXESUF) check-qtest-virtio-y += $(check-qtest-virtioserial-y) check-qtest-pci-y += tests/e1000-test$(EXESUF)
Signature · 1 line
MST
[Qemu-devel] [PULL v2 40/49] acpi: build TPM Physical Presence interface
In reply to Michael S. TsirkinFrom: Stefan Berger <[email protected]>
The TPM Physical Presence interface consists of an ACPI part, a shared memory part, and code in the firmware. Users can send messages to the firmware by writing a code into the shared memory through invoking the ACPI code. When a reboot happens, the firmware looks for the code and acts on it by sending sequences of commands to the TPM.
This patch adds the ACPI code. It is similar to the one in EDK2 but doesn't assume that SMIs are necessary to use. It uses a similar datastructure for the shared memory as EDK2 does so that EDK2 and SeaBIOS could both make use of it. I extended the shared memory data structure with an array of 256 bytes, one for each code that could be implemented. The array contains flags describing the individual codes. This decouples the ACPI implementation from the firmware implementation.
The underlying TCG specification is accessible from the following page.
https://trustedcomputinggroup.org/tcg-physical-presence-interface-specification/
This patch implements version 1.30.
--- docs/specs/tpm.txt | 83 +++++++++ include/hw/acpi/tpm.h | 12 ++ hw/acpi/tpm.c | 404 ++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 12 +- stubs/tpm.c | 5 + hw/acpi/Makefile.objs | 1 + 6 files changed, 514 insertions(+), 3 deletions(-) create mode 100644 hw/acpi/tpm.c
docs/specs/tpm.txt +83 -0
@@ -76,6 +76,89 @@ URL: https://trustedcomputinggroup.org/tcg-acpi-specification/ +== ACPI PPI Interface == + +QEMU supports the Physical Presence Interface (PPI) for TPM 1.2 and TPM 2. This +interface requires ACPI and firmware support. The specification can be found at +the following URL: + +https://trustedcomputinggroup.org/resource/tcg-physical-presence-interface-specification/ + +PPI enables a system administrator (root) to request a modification to the +TPM upon reboot. The PPI specification defines the operation requests and the +actions the firmware has to take. The system administrator passes the operation +request number to the firmware through an ACPI interface which writes this +number to a memory location that the firmware knows. Upon reboot, the firmware +finds the number and sends commands to the the TPM. The firmware writes the TPM +result code and the operation request number to a memory location that ACPI can +read from and pass the result on to the administrator. + +The PPI specification defines a set of mandatory and optional operations for +the firmware to implement. The ACPI interface also allows an administrator to +list the supported operations. In QEMU the ACPI code is generated by QEMU, yet +the firmware needs to implement support on a per-operations basis, and +different firmwares may support a different subset. Therefore, QEMU introduces +the virtual memory device for PPI where the firmware can indicate which +operations it supports and ACPI can enable the ones that are supported and +disable all others. This interface lies in main memory and has the following +layout: + + +----------+--------+--------+-------------------------------------------+ + | Field | Length | Offset | Description | + +----------+--------+--------+-------------------------------------------+ + | func | 0x100 | 0x000 | Firmware sets values for each supported | + | | | | operation. See defined values below. | + +----------+--------+--------+-------------------------------------------+ + | ppin | 0x1 | 0x100 | SMI interrupt to use. Set by firmware. | + | | | | Not supported. | + +----------+--------+--------+-------------------------------------------+ + | ppip | 0x4 | 0x101 | ACPI function index to pass to SMM code. | + | | | | Set by ACPI. Not supported. | + +----------+--------+--------+-------------------------------------------+ + | pprp | 0x4 | 0x105 | Result of last executed operation. Set by | + | | | | firmware. See function index 5 for values.| + +----------+--------+--------+-------------------------------------------+ + | pprq | 0x4 | 0x109 | Operation request number to execute. See | + | | | | 'Physical Presence Interface Operation | + | | | | Summary' tables in specs. Set by ACPI. | + +----------+--------+--------+-------------------------------------------+ + | pprm | 0x4 | 0x10d | Operation request optional parameter. | + | | | | Values depend on operation. Set by ACPI. | + +----------+--------+--------+-------------------------------------------+ + | lppr | 0x4 | 0x111 | Last executed operation request number. | + | | | | Copied from pprq field by firmware. | + +----------+--------+--------+-------------------------------------------+ + | fret | 0x4 | 0x115 | Result code from SMM function. | + | | | | Not supported. | + +----------+--------+--------+-------------------------------------------+ + | res1 | 0x40 | 0x119 | Reserved for future use | + +----------+--------+--------+-------------------------------------------+ + | next_step| 0x1 | 0x159 | Operation to execute after reboot by | + | | | | firmware. Used by firmware. | + +----------+--------+--------+-------------------------------------------+ + + The following values are supported for the 'func' field. They correspond + to the values used by ACPI function index 8. + + +----------+-------------------------------------------------------------+ + | value | Description | + +----------+-------------------------------------------------------------+ + | 0 | Operation is not implemented. | + +----------+-------------------------------------------------------------+ + | 1 | Operation is only accessible through firmware. | + +----------+-------------------------------------------------------------+ + | 2 | Operation is blocked for OS by firmware configuration. | + +----------+-------------------------------------------------------------+ + | 3 | Operation is allowed and physically present user required. | + +----------+-------------------------------------------------------------+ + | 4 | Operation is allowed and physically present user is not | + | | required. | + +----------+-------------------------------------------------------------+ + +The location of the table is given by the fw_cfg tpmppi_address field. +The PPI memory region size is 0x400 (TPM_PPI_ADDR_SIZE) to leave +enough room for future updates. + QEMU files related to TPM ACPI tables: - hw/i386/acpi-build.c
include/hw/acpi/tpm.h +12 -0
@@ -18,6 +18,8 @@#include "qemu/units.h" #include "hw/registerfields.h" +#include "hw/acpi/aml-build.h" +#include "sysemu/tpm.h" #define TPM_TIS_ADDR_BASE 0xFED40000#define TPM_TIS_ADDR_SIZE 0x5000
@@ -197,4 +199,14 @@ REG32(CRB_DATA_BUFFER, 0x80)#define TPM_PPI_VERSION_NONE 0#define TPM_PPI_VERSION_1_30 1 +/* whether function is blocked by BIOS settings; bits 0, 1, 2 */ +#define TPM_PPI_FUNC_NOT_IMPLEMENTED (0 << 0) +#define TPM_PPI_FUNC_BIOS_ONLY (1 << 0) +#define TPM_PPI_FUNC_BLOCKED (2 << 0) +#define TPM_PPI_FUNC_ALLOWED_USR_REQ (3 << 0) +#define TPM_PPI_FUNC_ALLOWED_USR_NOT_REQ (4 << 0) +#define TPM_PPI_FUNC_MASK (7 << 0) + +void tpm_build_ppi_acpi (TPMIf *tpm,Aml *dev); +#endif /* HW_ACPI_TPM_H */
hw/acpi/tpm.c new file +404 -0
404 lines not on this page · raw message
hw/i386/acpi-build.c +9 -3
@@ -1802,6 +1802,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,uint32_t nr_mem = machine->ram_slots;int root_bus_limit =0xFF ;PCIBus *bus =NULL ; +TPMIf *tpm =tpm_find ();int i; dsdt =init_aml_allocator ();
@@ -2139,7 +2140,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,/* Scan all PCI buses. Generate tables to support hotplug. */ build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en); -if (TPM_IS_TIS (tpm_find ())) { +if (TPM_IS_TIS (tpm)) { dev =aml_device ("ISA.TPM" );aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C31" )));aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xF )));
@@ -2153,6 +2154,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,*/ /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */ aml_append (dev,aml_name_decl ("_CRS" , crs)); + +tpm_build_ppi_acpi (tpm, dev); +aml_append (scope, dev); }
@@ -2160,7 +2164,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, } } -if (TPM_IS_CRB (tpm_find ())) { +if (TPM_IS_CRB (tpm)) { dev =aml_device ("TPM" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("MSFT0101" ))); crs =aml_resource_template ();
@@ -2172,6 +2176,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (method,aml_return (aml_int (0x0f )));aml_append (dev, method); +tpm_build_ppi_acpi (tpm, dev); +aml_append (sb_scope, dev); }
@@ -2894,7 +2900,7 @@ void acpi_setup(void) tpm_config = (FwCfgTPMConfig ) { .tpmppi_address =cpu_to_le32 (TPM_PPI_ADDR_BASE ), .tpm_version =tpm_get_version (tpm), - .tpmppi_version =TPM_PPI_VERSION_NONE + .tpmppi_version =TPM_PPI_VERSION_1_30 };fw_cfg_add_file (pcms->fw_cfg,"etc/tpm/config" , &tpm_config,sizeof tpm_config);
stubs/tpm.c +5 -0
@@ -8,6 +8,7 @@#include "qemu/osdep.h" #include "qapi/qapi-commands-tpm.h" #include "sysemu/tpm.h" +#include "hw/acpi/tpm.h" void tpm_init (void ) {
@@ -31,3 +32,7 @@ TpmModelList *qmp_query_tpm_models(Error **errp) {return NULL ; } + +void tpm_build_ppi_acpi (TPMIf *tpm,Aml *dev) +{ +}
hw/acpi/Makefile.objs +1 -0
@@ -11,6 +11,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-$(CONFIG_TPM) += tpm.o common-obj-$(CONFIG_IPMI) += ipmi.o common-obj-$(call lnot,$(CONFIG_IPMI)) += ipmi-stub.o
Signature · 1 line
MST
[Qemu-devel] [PULL v2 45/49] qemu/compiler: Define QEMU_NONSTRING
In reply to Michael S. TsirkinFrom: Philippe Mathieu-Daudé <[email protected]>
GCC 8 introduced the -Wstringop-truncation checker to detect truncation by the strncat and strncpy functions (closely related to -Wstringop-overflow, which detect buffer overflow by string-modifying functions declared in <string.h>).
In tandem of -Wstringop-truncation, the "nonstring" attribute was added:
The nonstring variable attribute specifies that an object or member declaration with type array of char, signed char, or unsigned char, or pointer to such a type is intended to store character arrays that do not necessarily contain a terminating NUL. This is useful in detecting uses of such arrays or pointers with functions that expect NUL-terminated strings, and to avoid warnings when such an array or pointer is used as an argument to a bounded string manipulation function such as strncpy.
From the GCC manual: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-nonstring-variable-attribute
Add the QEMU_NONSTRING macro which checks if the compiler supports this attribute.
--- include/qemu/compiler.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
include/qemu/compiler.h +15 -0
@@ -151,6 +151,21 @@# define QEMU_ERROR (X )#endif +/* +* The nonstring variable attribute specifies that an object or member +* declaration with type array of char or pointer to char is intended +* to store character arrays that do not necessarily contain a terminating +* NUL character. This is useful in detecting uses of such arrays or pointers +* with functions that expect NUL-terminated strings, and to avoid warnings +* when such an array or pointer is used as an argument to a bounded string +* manipulation function such as strncpy. +*/ +#if __has_attribute (nonstring) +# define QEMU_NONSTRING __attribute__((nonstring)) +#else +# define QEMU_NONSTRING +#endif +/* Implement C11 _Generic via GCC builtins. Example: * * QEMU_GENERIC(x, (float, sinf), (long double, sinl), sin) (x)
Signature · 1 line
MST
[Qemu-devel] [PULL v2 49/49] migration: Use strnlen() for fixed-size string
In reply to Michael S. TsirkinFrom: Philippe Mathieu-Daudé <[email protected]>
GCC 8 introduced the -Wstringop-overflow, which detect buffer overflow by string-modifying functions declared in <string.h>, such strncpy(), used in global_state_store_running().
GCC indeed found an incorrect use of strlen(), because this array is loaded by VMSTATE_BUFFER(runstate, GlobalState) then parsed using qapi_enum_parse which does not get the buffer length.
Use strnlen() which returns sizeof(s->runstate) if the array is not NUL-terminated, assert the size is within range, and enforce the array to be NUL-terminated to avoid an overflow in qapi_enum_parse().
This fixes:
CC migration/global_state.o
qemu/migration/global_state.c: In function 'global_state_pre_save':
qemu/migration/global_state.c:109:15: error: 'strlen' argument 1 declared attribute 'nonstring' [-Werror=stringop-overflow=]
s->size = strlen((char *)s->runstate) + 1;
^~~~~~~~~~~~~~~~~~~~~~~~~~~
qemu/migration/global_state.c:24:13: note: argument 'runstate' declared here
uint8_t runstate[100] QEMU_NONSTRING;
^~~~~~~~ cc1: all warnings being treated as errors
make: *** [qemu/rules.mak:69: migration/global_state.o] Error 1
--- migration/global_state.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
migration/global_state.c +13 -1
@@ -89,6 +89,17 @@ static int global_state_post_load(void *opaque, int version_id) s->received = true;trace_migrate_global_state_post_load (runstate); +if (strnlen ((char *)s->runstate, +sizeof (s->runstate)) ==sizeof (s->runstate)) { +/* +* This condition should never happen during migration, because +* all runstate names are shorter than 100 bytes (the size of +* s->runstate). However, a malicious stream could overflow +* the qapi_enum_parse() call, so we force the last character +* to a NUL byte. +*/ + s->runstate[sizeof (s->runstate) -1 ] ='\0' ; + } r =qapi_enum_parse (&RunState_lookup, runstate,-1 , &local_err);if (r ==-1 ) {
@@ -107,7 +118,8 @@ static int global_state_pre_save(void *opaque)GlobalState *s = opaque;trace_migrate_global_state_pre_save ((char *)s->runstate); - s->size =strlen ((char *)s->runstate) +1 ; + s->size =strnlen ((char *)s->runstate,sizeof (s->runstate)) +1 ; +assert (s->size <=sizeof (s->runstate));return 0 ; }
Signature · 1 line
MST
[Qemu-devel] [PULL v2 44/49] acpi: update expected files
In reply to Michael S. TsirkinUpdate expected files affected by:
hw: acpi: Fix memory hotplug AML generation error
--- tests/data/acpi/pc/DSDT.dimmpxm | Bin 6790 -> 6784 bytes tests/data/acpi/pc/DSDT.memhp | Bin 6496 -> 6490 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9474 -> 9468 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9180 -> 9174 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8947 -> 8945 bytes 5 files changed, 0 insertions(+), 0 deletions(-)
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
tests/data/acpi/q35/DSDT.memhp binary +0 -0
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
Signature · 1 line
MST
[Qemu-devel] [PULL v2 47/49] hw/acpi: Use QEMU_NONSTRING for non NUL-terminated arrays
In reply to Michael S. TsirkinFrom: Philippe Mathieu-Daudé <[email protected]>
GCC 8 added a -Wstringop-truncation warning:
The -Wstringop-truncation warning added in GCC 8.0 via r254630 for bug 81117 is specifically intended to highlight likely unintended uses of the strncpy function that truncate the terminating NUL character from the source string.
This new warning leads to compilation failures:
CC hw/acpi/core.o
In function 'acpi_table_install', inlined from 'acpi_table_add' at qemu/hw/acpi/core.c:296:5:
qemu/hw/acpi/core.c:184:9: error: 'strncpy' specified bound 4 equals destination size [-Werror=stringop-truncation]
strncpy(ext_hdr->sig, hdrs->sig, sizeof ext_hdr->sig);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make: *** [qemu/rules.mak:69: hw/acpi/core.o] Error 1
Use the QEMU_NONSTRING attribute, since ACPI tables don't require the strings to be NUL-terminated.
--- include/hw/acpi/acpi-defs.h | 13 ++++++++----- hw/acpi/core.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-)
include/hw/acpi/acpi-defs.h +8 -5
@@ -41,8 +41,8 @@ enum { }; typedef struct AcpiRsdpData { - uint8_t oem_id[6]; /* OEM identification */ - uint8_t revision; /* Must be 0 for 1.0, 2 for 2.0 */ + uint8_t oem_id[6] QEMU_NONSTRING; /* OEM identification */ + uint8_t revision; /* Must be 0 for 1.0, 2 for 2.0 */ unsigned *rsdt_tbl_offset; unsigned *xsdt_tbl_offset;
@@ -57,10 +57,13 @@ typedef struct AcpiRsdpData {uint32_t length;/* Length of table, in bytes, including header */ \uint8_t revision;/* ACPI Specification minor version # */ \uint8_t checksum;/* To make sum of entire table == 0 */ \ -uint8_t oem_id [6 ];/* OEM identification */ \ -uint8_t oem_table_id [8 ];/* OEM table identification */ \ + uint8_t oem_id[6] \ +QEMU_NONSTRING ;/* OEM identification */ \ + uint8_t oem_table_id[8] \ +QEMU_NONSTRING ;/* OEM table identification */ \uint32_t oem_revision;/* OEM revision number */ \ -uint8_t asl_compiler_id [4 ];/* ASL compiler vendor ID */ \ + uint8_t asl_compiler_id[4] \ +QEMU_NONSTRING ;/* ASL compiler vendor ID */ \uint32_t asl_compiler_revision;/* ASL compiler revision number */
hw/acpi/core.c +8 -4
@@ -35,14 +35,18 @@struct acpi_table_header {uint16_t _length;/* our length, not actual part of the hdr */ /* allows easier parsing for fw_cfg clients */ -char sig[4 ];/* ACPI signature (4 ASCII characters) */ + char sig[4] + QEMU_NONSTRING;/* ACPI signature (4 ASCII characters) */ uint32_t length;/* Length of table, in bytes, including header */ uint8_t revision;/* ACPI Specification minor version # */ uint8_t checksum;/* To make sum of entire table == 0 */ -char oem_id[6 ];/* OEM identification */ -char oem_table_id[8 ];/* OEM table identification */ + char oem_id[6] + QEMU_NONSTRING;/* OEM identification */ + char oem_table_id[8] +QEMU_NONSTRING ;/* OEM table identification */ uint32_t oem_revision;/* OEM revision number */ -char asl_compiler_id[4 ];/* ASL compiler vendor ID */ + char asl_compiler_id[4] +QEMU_NONSTRING ;/* ASL compiler vendor ID */ uint32_t asl_compiler_revision;/* ASL compiler revision number */ }QEMU_PACKED ;
Signature · 1 line
MST
[Qemu-devel] [PULL v2 48/49] migration: Fix stringop-truncation warning
In reply to Michael S. TsirkinFrom: Marc-André Lureau <[email protected]>
GCC 8 added a -Wstringop-truncation warning:
The -Wstringop-truncation warning added in GCC 8.0 via r254630 for bug 81117 is specifically intended to highlight likely unintended uses of the strncpy function that truncate the terminating NUL character from the source string.
This new warning leads to compilation failures:
CC migration/global_state.o
qemu/migration/global_state.c: In function 'global_state_store_running':
qemu/migration/global_state.c:45:5: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation]
strncpy((char *)global_state.runstate, state, sizeof(global_state.runstate));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make: *** [qemu/rules.mak:69: migration/global_state.o] Error 1
Adding an assert is enough to silence GCC.
(alternatively, we could hard-code "running")
--- migration/global_state.c | 1 + 1 file changed, 1 insertion(+)
migration/global_state.c +1 -0
@@ -42,6 +42,7 @@ int global_state_store(void)void global_state_store_running (void ) {const char *state =RunState_str (RUN_STATE_RUNNING ); +assert (strlen (state) <sizeof (global_state.runstate));strncpy ((char *)global_state.runstate, state,sizeof (global_state.runstate)); }
Signature · 1 line
MST
[Qemu-devel] [PULL v2 46/49] block/sheepdog: Use QEMU_NONSTRING for non NUL-terminated arrays
In reply to Michael S. TsirkinFrom: Philippe Mathieu-Daudé <[email protected]>
GCC 8 added a -Wstringop-truncation warning:
The -Wstringop-truncation warning added in GCC 8.0 via r254630 for bug 81117 is specifically intended to highlight likely unintended uses of the strncpy function that truncate the terminating NUL character from the source string.
This new warning leads to compilation failures:
CC block/sheepdog.o
qemu/block/sheepdog.c: In function 'find_vdi_name':
qemu/block/sheepdog.c:1239:5: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation]
strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make: *** [qemu/rules.mak:69: block/sheepdog.o] Error 1
As described previous to the strncpy() calls, the use of strncpy() is correct here:
/* This pair of strncpy calls ensures that the buffer is zero-filled,
* which is desirable since we'll soon be sending those bytes, and
* don't want the send_req to read uninitialized data.
*/
strncpy(buf, filename, SD_MAX_VDI_LEN);
strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN);Use the QEMU_NONSTRING attribute, since this array is intended to store character arrays that do not necessarily contain a terminating NUL.
--- block/sheepdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/sheepdog.c +1 -1
@@ -1224,7 +1224,7 @@ static int find_vdi_name(BDRVSheepdogState *s, const char *filename,SheepdogVdiReq hdr;SheepdogVdiRsp *rsp = (SheepdogVdiRsp *)&hdr;unsigned int wlen, rlen =0 ; -char buf[SD_MAX_VDI_LEN +SD_MAX_VDI_TAG_LEN ]; + char buf[SD_MAX_VDI_LEN + SD_MAX_VDI_TAG_LEN] QEMU_NONSTRING; fd =connect_to_sdog (s, errp);if (fd <0 ) {
Signature · 1 line
MST
Quoted 21 lines · Michael S. Tsirkin
Changes from v1:
- fix an out of tree build by unmangling a patch I mangled when applying
- fix a gcc 8 build by applying philippe's patchesThe following changes since commit
89bd861c2b470e3fb45596945509079c72af3ac2:Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging (2019-01-14 17:35:00 +0000)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
64ed76db175f7ccb5f47195a7617d0106bf01245:migration: Use
strnlen()for fixed-size string (2019-01-15 14:56:57 -0500)----------------------------------------------------------------
pci, pc, virtio: fixes, features
Quoted 7 lines
tpm physical presence interface
rsc support in virtio net
ivshmem is removed
misc cleanups and fixes all over the placeSigned-off-by Michael S. Tsirkin <[email protected]>
This fails 'make check' on s390x host:
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))} QTEST_QEMU_BINARY=i386-softmmu/qemu-system-i386 QTEST_QEMU_IMG=qemu-img tests/bios-tables-test -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="bios-tables-test"
Looking for expected file 'tests/data/acpi/pc/FACP'
Using expected file 'tests/data/acpi/pc/FACP'
** ERROR:/home/linux1/qemu/tests/bios-tables-test.c:314:load_expected_aml:
assertion failed: (exp_sdt.aml_len)
ERROR - too few tests run (expected 15, got 0)
Aborted (core dumped) /home/linux1/qemu/tests/Makefile.include:856: recipe for target 'check-qtest-i386' failed
(all the other build hosts passed)
thanks
-- PMM
Quoted 47 lines · Peter Maydell
Quoted 21 lines · Michael S. Tsirkin
Changes from v1:
- fix an out of tree build by unmangling a patch I mangled when applying
- fix a gcc 8 build by applying philippe's patchesThe following changes since commit
89bd861c2b470e3fb45596945509079c72af3ac2:Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging (2019-01-14 17:35:00 +0000)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
64ed76db175f7ccb5f47195a7617d0106bf01245:migration: Use
strnlen()for fixed-size string (2019-01-15 14:56:57 -0500)----------------------------------------------------------------
pci, pc, virtio: fixes, featuresQuoted 7 lines
tpm physical presence interface
rsc support in virtio net
ivshmem is removed
misc cleanups and fixes all over the placeSigned-off-by Michael S. Tsirkin <[email protected]>This fails 'make check' on s390x host:
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))} QTEST_QEMU_BINARY=i386-softmmu/qemu-system-i386 QTEST_QEMU_IMG=qemu-img tests/bios-tables-test -m=quick -k --tap <
/dev/null|./scripts/tap-driver.pl--test-name="bios-tables-test"Looking for expected file 'tests/data/acpi/pc/FACP'
Using expected file 'tests/data/acpi/pc/FACP'
** ERROR:/home/linux1/qemu/tests/bios-tables-test.c:314:load_expected_aml:
assertion failed: (exp_sdt.aml_len)
ERROR - too few tests run (expected 15, got 0)
Aborted (core dumped)/home/linux1/qemu/tests/Makefile.include:856: recipe for target 'check-qtest-i386' failed
Quoted 4 lines
(all the other build hosts passed)
thanks
-- PMM
Oh. I am pretty sure it's endian-ness :(
Any chance you can quickly test the below?
That would be appreciated ...
tests/bios-tables-test.c +3 -1
@@ -274,6 +274,7 @@ static GArray *load_expected_aml(test_data *data)AcpiSdtTable *sdt;GError *error =NULL ;gboolean ret; +gsize aml_len;GArray *exp_tables =g_array_new (false, true,sizeof (AcpiSdtTable));if (getenv ("V" )) {
@@ -307,7 +308,8 @@ try_again:fprintf (stderr,"Using expected file '%s'\n" , aml_file); } ret =g_file_get_contents (aml_file, (gchar **)&exp_sdt.aml, - (gsize *)&exp_sdt.aml_len, &error); + &aml_len, &error); + exp_sdt.aml_len = aml_len;g_assert (ret);g_assert_no_error (error);g_assert (exp_sdt.aml);
Quoted 20 lines · Michael S. Tsirkin
Oh. I am pretty sure it's endian-ness :(
Any chance you can quickly test the below?
That would be appreciated ...
tests/bios-tables-test.c +1
-0@@ -274,6 +274,7 @@ static GArray *load_expected_aml(test_data *data)AcpiSdtTable *sdt;GError *error =NULL ;gboolean ret; +gsize aml_len;GArray *exp_tables =g_array_new (false, true,sizeof (AcpiSdtTable));if (getenv ("V" )) {
tests/bios-tables-test.c try_again: · line 315
Quoted 9 lines
tests/bios-tables-test.c +2
-1@@ -307,7 +308,8 @@ try_again:fprintf (stderr,"Using expected file '%s'\n" , aml_file); } ret =g_file_get_contents (aml_file, (gchar **)&exp_sdt.aml, - (gsize *)&exp_sdt.aml_len, &error); + &aml_len, &error); + exp_sdt.aml_len = aml_len;g_assert (ret);g_assert_no_error (error);g_assert (exp_sdt.aml);
I can test that once I've finished processing the other pullreq I'm currently testing... That's not so much an endianness issue as trying to fit a 64-bit value into a 32-bit field, though. That cast in the code that is fixed here is an indication of the bug :-)
thanks
-- PMM
Quoted 38 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin
Oh. I am pretty sure it's endian-ness :(
Any chance you can quickly test the below?
That would be appreciated ...
tests/bios-tables-test.c +1
-0@@ -274,6 +274,7 @@ static GArray *load_expected_aml(test_data *data)AcpiSdtTable *sdt;GError *error =NULL ;gboolean ret; +gsize aml_len;GArray *exp_tables =g_array_new (false, true,sizeof (AcpiSdtTable));if (getenv ("V" )) {tests/bios-tables-test.c try_again: · line 315
Quoted 9 lines
tests/bios-tables-test.c +2
-1@@ -307,7 +308,8 @@ try_again:fprintf (stderr,"Using expected file '%s'\n" , aml_file); } ret =g_file_get_contents (aml_file, (gchar **)&exp_sdt.aml, - (gsize *)&exp_sdt.aml_len, &error); + &aml_len, &error); + exp_sdt.aml_len = aml_len;g_assert (ret);g_assert_no_error (error);g_assert (exp_sdt.aml);I can test that once I've finished processing the other pullreq I'm currently testing... That's not so much an endianness issue as trying to fit a 64-bit value into a 32-bit field, though. That cast in the code that is fixed here is an indication of the bug :-)
Quoted 2 lines
thanks
-- PMM
Right but it fits on LE.
Signature · 1 line
MST
Quoted 40 lines · Michael S. Tsirkin
Quoted 29 lines · Peter Maydell
Quoted 28 lines · Michael S. Tsirkin
Oh. I am pretty sure it's endian-ness :(
Any chance you can quickly test the below?
That would be appreciated ...
tests/bios-tables-test.c +3
-1@@ -274,6 +274,7 @@ static GArray *load_expected_aml(test_data *data)AcpiSdtTable *sdt;GError *error =NULL ;gboolean ret; +gsize aml_len;GArray *exp_tables =g_array_new (false, true,sizeof (AcpiSdtTable));if (getenv ("V" )) {@@ -307,7 +308,8 @@ try_again:fprintf (stderr,"Using expected file '%s'\n" , aml_file); } ret =g_file_get_contents (aml_file, (gchar **)&exp_sdt.aml, - (gsize *)&exp_sdt.aml_len, &error); + &aml_len, &error); + exp_sdt.aml_len = aml_len;g_assert (ret);g_assert_no_error (error);Quoted 8 lines
tests/bios-tables-test.c try_again: · line 315
Quoted 1 line
tests/bios-tables-test.c +0
-0g_assert (exp_sdt.aml);I can test that once I've finished processing the other pullreq I'm currently testing... That's not so much an endianness issue as trying to fit a 64-bit value into a 32-bit field, though. That cast in the code that is fixed here is an indication of the bug :-)
Quoted 1 line
Right but it fits on LE.
It still doesn't fit, you just don't notice that you've blown away the following item in the struct. Anyway I'm currently running the test, which I agree ought to fix things.
thanks
-- PMM
Quoted 41 lines · Peter Maydell
Quoted 39 lines · Michael S. Tsirkin
Quoted 37 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin
Oh. I am pretty sure it's endian-ness :(
Any chance you can quickly test the below?
That would be appreciated ...
tests/bios-tables-test.c +1
-0@@ -274,6 +274,7 @@ static GArray *load_expected_aml(test_data *data)AcpiSdtTable *sdt;GError *error =NULL ;gboolean ret; +gsize aml_len;GArray *exp_tables =g_array_new (false, true,sizeof (AcpiSdtTable));if (getenv ("V" )) {tests/bios-tables-test.c try_again: · line 315
Quoted 9 lines
tests/bios-tables-test.c +2
-1@@ -307,7 +308,8 @@ try_again:fprintf (stderr,"Using expected file '%s'\n" , aml_file); } ret =g_file_get_contents (aml_file, (gchar **)&exp_sdt.aml, - (gsize *)&exp_sdt.aml_len, &error); + &aml_len, &error); + exp_sdt.aml_len = aml_len;g_assert (ret);g_assert_no_error (error);g_assert (exp_sdt.aml);I can test that once I've finished processing the other pullreq I'm currently testing... That's not so much an endianness issue as trying to fit a 64-bit value into a 32-bit field, though. That cast in the code that is fixed here is an indication of the bug :-)
Quoted 4 lines
Quoted 1 line
Right but it fits on LE.
It still doesn't fit, you just don't notice that you've blown away the following item in the struct.
Oh right. that one just happens to be unused.
Quoted 5 lines
Anyway I'm currently
running the test, which I agree ought to fix things.thanks
-- PMM
Quoted 7 lines · Michael S. Tsirkin
Quoted 1 line · Peter Maydell
This fails 'make check' on s390x host:
Oh. I am pretty sure it's endian-ness :(
Any chance you can quickly test the below?
Yes, that change allows the tests to pass on the s390 box.
thanks
-- PMM
Quoted 5 lines · Peter Maydell
Quoted 3 lines · Michael S. Tsirkin
Quoted 1 line · Peter Maydell
This fails 'make check' on s390x host:
Quoted 8 lines
Quoted 3 lines
Oh. I am pretty sure it's endian-ness :(
Any chance you can quickly test the below?
Yes, that change allows the tests to pass on the s390 box.
thanks
-- PMM
Re-pushed a fixed patch to the same tag.
Igor, in the future pls remember to be conscious of size of integers:
it's not safe to cast uint32_t* to gsize *!
Thanks!
Signature · 1 line
MST
Quoted 12 lines · On Thu, 17 Jan 2019 21:12:53 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 11 lines · Peter Maydell
Quoted 7 lines · Michael S. Tsirkin
Quoted 1 line · Peter Maydell
This fails 'make check' on s390x host:
Oh. I am pretty sure it's endian-ness :(
Any chance you can quickly test the below?
Yes, that change allows the tests to pass on the s390 box.
Quoted 7 lines
Quoted 2 lines
thanks
-- PMMRe-pushed a fixed patch to the same tag.
Igor, in the future pls remember to be conscious of size of integers:
it's not safe to cast uint32_t* to gsize *!
sure,
Thanks for fixing it up!
Quoted 3 lines
Thanks!
Peter Maydell
AppliedQuoted 9 lines · Michael S. Tsirkin
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Michael S. Tsirkin
Quoted 1 line · Peter Maydell
This fails 'make check' on s390x host:
Oh. I am pretty sure it's endian-ness :(
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Any chance you can quickly test the below?
Yes, that change allows the tests to pass on the s390 box.
thanks
-- PMMRe-pushed a fixed patch to the same tag.
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/4.0
for any user-visible changes.
-- PMM