pc,virtio: features, tests, fixes, cleanups
[PULL 07/55] hw/virtio: move vm_running check to virtio_device_started
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong.
Message-Id: <[email protected]>
--- include/hw/virtio/virtio.h | 5 +++++ hw/virtio/vhost-user-fs.c | 6 +----- hw/virtio/vhost-user-i2c.c | 6 +----- hw/virtio/vhost-user-rng.c | 6 +----- hw/virtio/vhost-user-vsock.c | 6 +----- hw/virtio/vhost-vsock.c | 6 +----- 6 files changed, 10 insertions(+), 25 deletions(-)
include/hw/virtio/virtio.h +5 -0
@@ -100,6 +100,7 @@ struct VirtIODeviceVirtQueue *vq;MemoryListener listener;uint16_t device_id; +/* @vm_running: current VM running state via virtio_vmstate_change() */ bool vm_running;bool broken;/* device in invalid state, needs reset */ bool use_disabled_flag;/* allow use of 'disable' flag when needed */
@@ -376,6 +377,10 @@ static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status)return vdev->started; } +if (!vdev->vm_running) { +return false; + } +return status &VIRTIO_CONFIG_S_DRIVER_OK ; }
hw/virtio/vhost-user-fs.c +1 -5
@@ -122,11 +122,7 @@ static void vuf_stop(VirtIODevice *vdev)static void vuf_set_status (VirtIODevice *vdev,uint8_t status) {VHostUserFS *fs =VHOST_USER_FS (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (fs->vhost_dev.started == should_start) {return ;
hw/virtio/vhost-user-i2c.c +1 -5
@@ -93,11 +93,7 @@ static void vu_i2c_stop(VirtIODevice *vdev)static void vu_i2c_set_status (VirtIODevice *vdev,uint8_t status) {VHostUserI2C *i2c =VHOST_USER_I2C (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (i2c->vhost_dev.started == should_start) {return ;
hw/virtio/vhost-user-rng.c +1 -5
@@ -90,11 +90,7 @@ static void vu_rng_stop(VirtIODevice *vdev)static void vu_rng_set_status (VirtIODevice *vdev,uint8_t status) {VHostUserRNG *rng =VHOST_USER_RNG (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (rng->vhost_dev.started == should_start) {return ;
hw/virtio/vhost-user-vsock.c +1 -5
@@ -55,11 +55,7 @@ const VhostDevConfigOps vsock_ops = {static void vuv_set_status (VirtIODevice *vdev,uint8_t status) {VHostVSockCommon *vvc =VHOST_VSOCK_COMMON (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (vvc->vhost_dev.started == should_start) {return ;
hw/virtio/vhost-vsock.c +1 -5
@@ -70,13 +70,9 @@ static int vhost_vsock_set_running(VirtIODevice *vdev, int start)static void vhost_vsock_set_status (VirtIODevice *vdev,uint8_t status) {VHostVSockCommon *vvc =VHOST_VSOCK_COMMON (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; +bool should_start =virtio_device_started (vdev, status);int ret; -if (!vdev->vm_running) { - should_start = false; - } -if (vvc->vhost_dev.started == should_start) {return ; }
Signature · 1 line
MST
[PULL 08/55] hw/virtio: move vhd->started check into helper and add FIXME
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
The started field is manipulated internally within the vhost code except for one place, vhost-user-blk via f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine). Mark that as a FIXME because it introduces a potential race. I think the referenced fix should be tracking its state locally.
Message-Id: <[email protected]>
--- include/hw/virtio/vhost.h | 12 ++++++++++++ hw/block/vhost-user-blk.c | 10 ++++++++-- hw/scsi/vhost-scsi.c | 4 ++-- hw/scsi/vhost-user-scsi.c | 2 +- hw/virtio/vhost-user-fs.c | 3 ++- hw/virtio/vhost-user-i2c.c | 4 ++-- hw/virtio/vhost-user-rng.c | 4 ++-- hw/virtio/vhost-user-vsock.c | 2 +- hw/virtio/vhost-vsock-common.c | 3 ++- hw/virtio/vhost-vsock.c | 2 +- 10 files changed, 33 insertions(+), 13 deletions(-)
include/hw/virtio/vhost.h +12 -0
@@ -94,6 +94,7 @@ struct vhost_dev {uint64_t protocol_features;uint64_t max_queues;uint64_t backend_cap; +/* @started: is the vhost device started? */ bool started;bool log_enabled;uint64_t log_size;
@@ -165,6 +166,17 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);*/ void vhost_dev_disable_notifiers (struct vhost_dev *hdev,VirtIODevice *vdev); +/** +* vhost_dev_is_started() - report status of vhost device +* @hdev: common vhost_dev structure +* +* Return the started status of the vhost device +*/ +static inline bool vhost_dev_is_started (struct vhost_dev *hdev) +{ +return hdev->started; +} +/** * vhost_dev_start() - start the vhost device * @hdev: common vhost_dev structure
hw/block/vhost-user-blk.c +8 -2
@@ -229,7 +229,7 @@ static void vhost_user_blk_set_status(VirtIODevice *vdev, uint8_t status)return ; } -if (s->dev.started == should_start) { +if (vhost_dev_is_started (&s->dev) == should_start) {return ; }
@@ -286,7 +286,7 @@ static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)return ; } -if (s->dev.started) { +if (vhost_dev_is_started (&s->dev)) {return ; }
@@ -415,6 +415,12 @@ static void vhost_user_blk_event(void *opaque, QEMUChrEvent event)* the vhost migration code. If disconnect was caught there is an * option for the general vhost code to get the dev state without * knowing its type (in this case vhost-user). +* +* FIXME: this is sketchy to be reaching into vhost_dev +* now because we are forcing something that implies we +* have executed vhost_dev_stop() but that won't happen +* until vhost_user_blk_stop() gets called from the bh. +* Really this state check should be tracked locally. */ s->dev.started = false; }
hw/scsi/vhost-scsi.c +2 -2
@@ -120,7 +120,7 @@ static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val) start = false; } -if (vsc->dev.started == start) { +if (vhost_dev_is_started (&vsc->dev) == start) {return ; }
@@ -147,7 +147,7 @@ static int vhost_scsi_pre_save(void *opaque)/* At this point, backend must be stopped, otherwise * it might keep writing to memory. */ -assert (!vsc->dev.started); +assert (!vhost_dev_is_started (&vsc->dev));return 0 ; }
hw/scsi/vhost-user-scsi.c +1 -1
@@ -49,7 +49,7 @@ static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status)VHostSCSICommon *vsc =VHOST_SCSI_COMMON (s);bool start = (status &VIRTIO_CONFIG_S_DRIVER_OK ) && vdev->vm_running; -if (vsc->dev.started == start) { +if (vhost_dev_is_started (&vsc->dev) == start) {return ; }
hw/virtio/vhost-user-fs.c +2 -1
@@ -20,6 +20,7 @@#include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" +#include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user-fs.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h"
@@ -124,7 +125,7 @@ static void vuf_set_status(VirtIODevice *vdev, uint8_t status)VHostUserFS *fs =VHOST_USER_FS (vdev);bool should_start =virtio_device_started (vdev, status); -if (fs->vhost_dev.started == should_start) { +if (vhost_dev_is_started (&fs->vhost_dev) == should_start) {return ; }
hw/virtio/vhost-user-i2c.c +2 -2
@@ -95,7 +95,7 @@ static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status)VHostUserI2C *i2c =VHOST_USER_I2C (vdev);bool should_start =virtio_device_started (vdev, status); -if (i2c->vhost_dev.started == should_start) { +if (vhost_dev_is_started (&i2c->vhost_dev) == should_start) {return ; }
@@ -174,7 +174,7 @@ static void vu_i2c_disconnect(DeviceState *dev) } i2c->connected = false; -if (i2c->vhost_dev.started) { +if (vhost_dev_is_started (&i2c->vhost_dev)) {vu_i2c_stop (vdev); } }
hw/virtio/vhost-user-rng.c +2 -2
@@ -92,7 +92,7 @@ static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status)VHostUserRNG *rng =VHOST_USER_RNG (vdev);bool should_start =virtio_device_started (vdev, status); -if (rng->vhost_dev.started == should_start) { +if (vhost_dev_is_started (&rng->vhost_dev) == should_start) {return ; }
@@ -160,7 +160,7 @@ static void vu_rng_disconnect(DeviceState *dev) rng->connected = false; -if (rng->vhost_dev.started) { +if (vhost_dev_is_started (&rng->vhost_dev)) {vu_rng_stop (vdev); } }
hw/virtio/vhost-user-vsock.c +1 -1
@@ -57,7 +57,7 @@ static void vuv_set_status(VirtIODevice *vdev, uint8_t status)VHostVSockCommon *vvc =VHOST_VSOCK_COMMON (vdev);bool should_start =virtio_device_started (vdev, status); -if (vvc->vhost_dev.started == should_start) { +if (vhost_dev_is_started (&vvc->vhost_dev) == should_start) {return ; }
hw/virtio/vhost-vsock-common.c +2 -1
@@ -14,6 +14,7 @@#include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" #include "hw/qdev-properties.h" +#include "hw/virtio/vhost.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h" #include "monitor/monitor.h"
@@ -199,7 +200,7 @@ int vhost_vsock_common_pre_save(void *opaque)* At this point, backend must be stopped, otherwise * it might keep writing to memory. */ -assert (!vvc->vhost_dev.started); +assert (!vhost_dev_is_started (&vvc->vhost_dev));return 0 ; }
hw/virtio/vhost-vsock.c +1 -1
@@ -73,7 +73,7 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status)bool should_start =virtio_device_started (vdev, status);int ret; -if (vvc->vhost_dev.started == should_start) { +if (vhost_dev_is_started (&vvc->vhost_dev) == should_start) {return ; }
Signature · 1 line
MST
[PULL 03/55] include/hw: document vhost_dev feature life-cycle
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
Try and explicitly document the various state of feature bits as related to the vhost_dev structure. Importantly the backend_features can advertise things like VHOST_USER_F_PROTOCOL_FEATURES which is never exposed to the driver and is only present in the vhost-user feature negotiation.
Message-Id: <[email protected]>
--- include/hw/virtio/vhost.h | 3 +++ 1 file changed, 3 insertions(+)
include/hw/virtio/vhost.h +3 -0
@@ -86,8 +86,11 @@ struct vhost_dev {/* if non-zero, minimum required value for max_queues */ int num_queues;uint64_t features; +/** @acked_features: final set of negotiated features */ uint64_t acked_features; +/** @backend_features: backend specific feature bits */ uint64_t backend_features; +/** @protocol_features: final negotiated protocol features */ uint64_t protocol_features;uint64_t max_queues;uint64_t backend_cap;
Signature · 1 line
MST
[PULL 01/55] hw/virtio: incorporate backend features in features
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
There are some extra bits used over a vhost-user connection which are hidden from the device itself. We need to set them here to ensure we enable things like the protocol extensions.
Currently net/vhost-user.c has it's own inscrutable way of persisting this data but it really should live in the core vhost_user code.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
--- hw/virtio/vhost-user.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
hw/virtio/vhost-user.c +8 -1
@@ -1460,7 +1460,14 @@ static int vhost_user_set_features(struct vhost_dev *dev,*/ bool log_enabled = features & (0x1ULL <<VHOST_F_LOG_ALL ); -return vhost_user_set_u64 (dev,VHOST_USER_SET_FEATURES , features, +/* +* We need to include any extra backend only feature bits that +* might be needed by our device. Currently this includes the +* VHOST_USER_F_PROTOCOL_FEATURES bit for enabling protocol +* features. +*/ +return vhost_user_set_u64 (dev,VHOST_USER_SET_FEATURES , + features | dev->backend_features, log_enabled); }
Signature · 1 line
MST
[PULL 04/55] hw/virtio: fix some coding style issues
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
Message-Id: <[email protected]>
--- hw/virtio/vhost-user.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
hw/virtio/vhost-user.c +4 -3
@@ -200,7 +200,7 @@ typedef struct {VhostUserRequest request;#define VHOST_USER_VERSION_MASK (0x3) -#define VHOST_USER_REPLY_MASK (0x1<<2) +#define VHOST_USER_REPLY_MASK (0x1 << 2)#define VHOST_USER_NEED_REPLY_MASK (0x1 << 3)uint32_t flags;uint32_t size;/* the following payload size */
@@ -208,7 +208,7 @@ typedef struct { typedef union { #define VHOST_USER_VRING_IDX_MASK (0xff) -#define VHOST_USER_VRING_NOFD_MASK (0x1<<8) +#define VHOST_USER_VRING_NOFD_MASK (0x1 << 8) uint64_t u64; struct vhost_vring_state state; struct vhost_vring_addr addr;
@@ -248,7 +248,8 @@ struct vhost_user {size_t region_rb_len;/* RAMBlock associated with a given region */ RAMBlock **region_rb; -/* The offset from the start of the RAMBlock to the start of the +/* +* The offset from the start of the RAMBlock to the start of the * vhost region. */ ram_addr_t *region_rb_offset;
Signature · 1 line
MST
[PULL 02/55] include/hw/virtio: more comment for VIRTIO_F_BAD_FEATURE
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
When debugging a new vhost user you may be surprised to see VHOST_USER_F_PROTOCOL getting squashed in the maze of backend_features, acked_features and guest_features. Expand the description here to help the next poor soul trying to work through this.
Message-Id: <[email protected]>
--- include/hw/virtio/virtio.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/hw/virtio/virtio.h +6 -1
@@ -24,7 +24,12 @@#include "qom/object.h" #include "hw/virtio/vhost.h" -/* A guest should never accept this. It implies negotiation is broken. */ +/* +* A guest should never accept this. It implies negotiation is broken +* between the driver frontend and the device. This bit is re-used for +* vhost-user to advertise VHOST_USER_F_PROTOCOL_FEATURES between QEMU +* and a vhost-user backend. +*/ #define VIRTIO_F_BAD_FEATURE 30#define VIRTIO_LEGACY_FEATURES ((0x1ULL << VIRTIO_F_BAD_FEATURE) | \
Signature · 1 line
MST
[PULL 06/55] hw/virtio: add some vhost-user trace events
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
These are useful for tracing the lifetime of vhost-user connections.
Message-Id: <[email protected]>
--- hw/virtio/vhost.c | 6 ++++++ hw/virtio/trace-events | 4 ++++ 2 files changed, 10 insertions(+)
hw/virtio/vhost.c +6 -0
@@ -1477,6 +1477,8 @@ void vhost_dev_cleanup(struct vhost_dev *hdev) {int i; +trace_vhost_dev_cleanup (hdev); +for (i =0 ; i < hdev->nvqs; ++i) {vhost_virtqueue_cleanup (hdev->vqs + i); }
@@ -1783,6 +1785,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)/* should only be called after backend is connected */ assert (hdev->vhost_ops); +trace_vhost_dev_start (hdev, vdev->name); + vdev->vhost_started = true; hdev->started = true; hdev->vdev = vdev;
@@ -1869,6 +1873,8 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev)/* should only be called after backend is connected */ assert (hdev->vhost_ops); +trace_vhost_dev_stop (hdev, vdev->name); +if (hdev->vhost_ops->vhost_dev_start) { hdev->vhost_ops->vhost_dev_start (hdev, false); }
hw/virtio/trace-events +4 -0
@@ -8,6 +8,10 @@ vhost_region_add_section_aligned(const char *name, uint64_t gpa, uint64_t size, vhost_section(const char *name) "%s" vhost_reject_section(const char *name, int d) "%s:%d" vhost_iotlb_miss(void *dev, int step) "%p step %d" +vhost_dev_cleanup(void *dev) "%p" +vhost_dev_start(void *dev, const char *name) "%p:%s" +vhost_dev_stop(void *dev, const char *name) "%p:%s" + # vhost-user.c vhost_user_postcopy_end_entry(void) ""
Signature · 1 line
MST
[PULL 11/55] tests/qtest: pass stdout/stderr down to subtests
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
When trying to work out what the virtio-net-tests where doing it was hard because the g_test_trap_subprocess redirects all output to /dev/null. Lift this restriction by using the appropriate flags so you can see something similar to what the vhost-user-blk tests show when running.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
--- tests/qtest/qos-test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tests/qtest/qos-test.c +3 -1
@@ -185,7 +185,9 @@ static void run_one_test(const void *arg)static void subprocess_run_one_test (const void *arg) {const gchar *path = arg; -g_test_trap_subprocess (path,0 ,0 ); +g_test_trap_subprocess (path,0 , +G_TEST_SUBPROCESS_INHERIT_STDOUT | +G_TEST_SUBPROCESS_INHERIT_STDERR );g_test_trap_assert_passed (); }
Signature · 1 line
MST
[PULL 05/55] hw/virtio: log potentially buggy guest drivers
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
If the guest driver attempts to use the UNUSED(30) bit it is potentially buggy as 6.3 Legacy Interface: Reserved Feature Bits states it "SHOULD NOT be negotiated". For now just log this guest error.
Message-Id: <[email protected]>
--- hw/virtio/virtio.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/virtio/virtio.c +7 -0
@@ -2980,6 +2980,13 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t val)if (vdev->status &VIRTIO_CONFIG_S_FEATURES_OK ) {return -EINVAL ; } + +if (val & (1ull <<VIRTIO_F_BAD_FEATURE )) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: guest driver for %s has enabled UNUSED(30) feature bit!\n" , + __func__, vdev->name); + } + ret =virtio_set_features_nocheck (vdev, val);if (virtio_vdev_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) {/* VIRTIO_RING_F_EVENT_IDX changes the size of the caches. */
Signature · 1 line
MST
The following changes since commit f1d33f55c47dfdaf8daacd618588ad3ae4c452d1:
Merge tag 'pull-testing-gdbstub-plugins-gitdm-061022-3' of https://github.com/stsquad/qemu into staging (2022-10-06 07:11:56 -0400)
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 3216ab2acb08b47d4ff83e709406690d37e44aff:
x86: pci: acpi: consolidate PCI slots creation (2022-10-09 16:38:46 -0400)
----------------------------------------------------------------
pc,virtio: features, tests, fixes, cleanups
virtio introspection
new serial number opton for cxl
vhost user blk dynamic config size
virtio-gpio vhost user backend
Tests fixes cleanups all over the place
----------------------------------------------------------------
Alex Bennée (17):
hw/virtio: incorporate backend features in features include/hw/virtio: more comment for VIRTIO_F_BAD_FEATURE include/hw: document vhost_dev feature life-cycle hw/virtio: fix some coding style issues
hw/virtio: log potentially buggy guest drivers hw/virtio: add some vhost-user trace events hw/virtio: move vm_running check to virtio_device_started hw/virtio: move vhd->started check into helper and add FIXME tests/qtest: pass stdout/stderr down to subtests tests/qtest: add a timeout for subprocess_run_one_test tests/qtest: use qos_printf instead of g_test_message tests/qtest: catch unhandled vhost-user messages tests/qtest: plain g_assert for VHOST_USER_F_PROTOCOL_FEATURES tests/qtest: add assert to catch bad features tests/qtest: implement stub for VHOST_USER_GET_CONFIG tests/qtest: add a get_features op to vhost-user-test tests/qtest: enable tests for virtio-gpio
Daniil Tatianin (5):
virtio: introduce VirtIOConfigSizeParams & virtio_get_config_size
virtio-blk: move config size params to virtio-blk-common
vhost-user-blk: make it possible to disable write-zeroes/discard
vhost-user-blk: make 'config_wce' part of 'host_features'
vhost-user-blk: dynamically resize config space based on features
Hal Martin (1):
hw/smbios: support for type 8 (port connector)
Igor Mammedov (17):
tests: acpi: whitelist pc/q35 DSDT due to HPET AML move
acpi: x86: deduplicate HPET AML building
tests: acpi: update expected blobs after HPET move
tests: acpi: whitelist pc/q35 DSDT due to HPET AML move
acpi: x86: refactor PDSM method to reduce nesting
x86: acpi: _DSM: use Package to pass parameters
tests: acpi: update expected blobs
tests: acpi: whitelist pc/q35 DSDT before switching _DSM to use ASUN
x86: acpi: cleanup PCI device _DSM duplication
tests: acpi: update expected blobs
tests: acpi: whitelist pc/q35 DSDT before moving _ADR field
x86: pci: acpi: reorder Device's _ADR and _SUN fields
tests: acpi: update expected blobs
tests: acpi: whitelist pc/q35 DSDT before moving _ADR field
x86: pci: acpi: reorder Device's _DSM method
tests: acpi: update expected blobs
x86: pci: acpi: consolidate PCI slots creation
Jonathan Cameron (1):
mem/cxl-type3: Add sn option to provide serial number for PCI ecap
Laurent Vivier (6):
qmp: add QMP command x-query-virtio
qmp: add QMP command x-query-virtio-status
qmp: decode feature & status bits in virtio-status
qmp: add QMP commands for virtio/vhost queue-status
qmp: add QMP command x-query-virtio-queue-element
hmp: add virtio commands
Miguel Luis (3):
tests/acpi: virt: allow acpi GTDT changes
acpi: arm/virt: build_gtdt: fix invalid 64-bit physical addresses tests/acpi: virt: update ACPI GTDT binaries
Peter Maydell (2):
pci: Remove unused pci_get_*_by_mask() functions
pci: Sanity check mask argument to pci_set_*_by_mask()
Peter Xu (1):
Revert "intel_iommu: Fix irqchip / X2APIC configuration checks"
Viresh Kumar (2):
hw/virtio: add boilerplate for vhost-user-gpio device hw/virtio: add vhost-user-gpio-pci boilerplate
qapi/qapi-schema.json | 1 + qapi/virtio.json | 954 ++++++++++++++++++++++++++++++ include/hw/cxl/cxl_device.h | 1 + include/hw/firmware/smbios.h | 10 + include/hw/pci/pci.h | 48 +- include/hw/virtio/vhost-user-blk.h | 1 - include/hw/virtio/vhost-user-gpio.h | 35 ++ include/hw/virtio/vhost.h | 18 + include/hw/virtio/virtio-blk-common.h | 20 + include/hw/virtio/virtio.h | 28 +- include/monitor/hmp.h | 5 + tests/qtest/libqos/virtio-gpio.h | 35 ++ hw/arm/virt-acpi-build.c | 5 +- hw/block/vhost-user-blk.c | 39 +- hw/block/virtio-blk-common.c | 39 ++ hw/block/virtio-blk.c | 28 +- hw/i386/acpi-build.c | 300 +++++----- hw/i386/intel_iommu.c | 5 + hw/mem/cxl_type3.c | 14 +- hw/net/virtio-net.c | 9 +- hw/scsi/vhost-scsi.c | 4 +- hw/scsi/vhost-user-scsi.c | 2 +- hw/smbios/smbios.c | 63 ++ hw/virtio/vhost-user-fs.c | 9 +- hw/virtio/vhost-user-gpio-pci.c | 69 +++ hw/virtio/vhost-user-gpio.c | 411 +++++++++++++ hw/virtio/vhost-user-i2c.c | 10 +- hw/virtio/vhost-user-rng.c | 10 +- hw/virtio/vhost-user-vsock.c | 8 +- hw/virtio/vhost-user.c | 16 +- hw/virtio/vhost-vsock-common.c | 3 +- hw/virtio/vhost-vsock.c | 8 +- hw/virtio/vhost.c | 6 + hw/virtio/virtio-stub.c | 42 ++ hw/virtio/virtio.c | 1049 ++++++++++++++++++++++++++++++++- monitor/hmp-cmds.c | 310 ++++++++++ tests/qtest/libqos/virtio-gpio.c | 171 ++++++ tests/qtest/libqos/virtio.c | 4 +- tests/qtest/qmp-cmd-test.c | 1 + tests/qtest/qos-test.c | 9 +- tests/qtest/vhost-user-test.c | 177 +++++- MAINTAINERS | 12 + hmp-commands-info.hx | 70 +++ hw/block/meson.build | 4 +- hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 4 + hw/virtio/trace-events | 9 + qapi/meson.build | 1 + qemu-options.hx | 2 + tests/data/acpi/pc/DSDT | Bin 5987 -> 6422 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 5954 -> 6382 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7312 -> 7747 bytes tests/data/acpi/pc/DSDT.bridge | Bin 8653 -> 9496 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6451 -> 6886 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 7641 -> 8076 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5954 -> 6382 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3069 -> 3069 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6059 -> 6494 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7346 -> 7781 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 5845 -> 6280 bytes tests/data/acpi/pc/DSDT.numamem | Bin 5993 -> 6428 bytes tests/data/acpi/pc/DSDT.roothp | Bin 6195 -> 6656 bytes tests/data/acpi/q35/DSDT | Bin 8274 -> 8320 bytes tests/data/acpi/q35/DSDT.acpierst | Bin 8291 -> 8337 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9599 -> 9645 bytes tests/data/acpi/q35/DSDT.applesmc | Bin 8320 -> 8366 bytes tests/data/acpi/q35/DSDT.bridge | Bin 10988 -> 11449 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8738 -> 8784 bytes tests/data/acpi/q35/DSDT.cxl | Bin 9600 -> 9646 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9928 -> 9974 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 8349 -> 8395 bytes tests/data/acpi/q35/DSDT.ipmismbus | Bin 8363 -> 8409 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 8291 -> 8337 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9633 -> 9679 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9404 -> 9450 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 8568 -> 8640 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 8132 -> 8178 bytes tests/data/acpi/q35/DSDT.numamem | Bin 8280 -> 8326 bytes tests/data/acpi/q35/DSDT.pvpanic-isa | Bin 8375 -> 8421 bytes tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8880 -> 8926 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8906 -> 8952 bytes tests/data/acpi/q35/DSDT.viot | Bin 9383 -> 9429 bytes tests/data/acpi/q35/DSDT.xapic | Bin 35637 -> 35683 bytes tests/data/acpi/virt/GTDT | Bin 96 -> 96 bytes tests/data/acpi/virt/GTDT.memhp | Bin 96 -> 96 bytes tests/data/acpi/virt/GTDT.numamem | Bin 96 -> 96 bytes tests/qtest/libqos/meson.build | 1 + 87 files changed, 3796 insertions(+), 289 deletions(-) create mode 100644 qapi/virtio.json create mode 100644 include/hw/virtio/vhost-user-gpio.h create mode 100644 include/hw/virtio/virtio-blk-common.h create mode 100644 tests/qtest/libqos/virtio-gpio.h create mode 100644 hw/block/virtio-blk-common.c create mode 100644 hw/virtio/vhost-user-gpio-pci.c create mode 100644 hw/virtio/vhost-user-gpio.c create mode 100644 hw/virtio/virtio-stub.c create mode 100644 tests/qtest/libqos/virtio-gpio.c
[PULL 09/55] hw/virtio: add boilerplate for vhost-user-gpio device
From: Viresh Kumar <[email protected]>
This creates the QEMU side of the vhost-user-gpio device which connects to the remote daemon. It is based of vhost-user-i2c code.
Message-Id: <5390324a748194a21bc99b1538e19761a8c64092.1641987128.git.viresh.kumar@linaro.org>
Message-Id: <[email protected]>
--- include/hw/virtio/vhost-user-gpio.h | 35 +++ hw/virtio/vhost-user-gpio.c | 411 ++++++++++++++++++++++++++++ MAINTAINERS | 7 + hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 1 + hw/virtio/trace-events | 5 + 6 files changed, 464 insertions(+) create mode 100644 include/hw/virtio/vhost-user-gpio.h create mode 100644 hw/virtio/vhost-user-gpio.c
include/hw/virtio/vhost-user-gpio.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Vhost-user GPIO virtio device +* +* Copyright (c) 2021 Viresh Kumar <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef _QEMU_VHOST_USER_GPIO_H +#define _QEMU_VHOST_USER_GPIO_H + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" +#include "standard-headers/linux/virtio_gpio.h" +#include "chardev/char-fe.h" + +#define TYPE_VHOST_USER_GPIO "vhost-user-gpio-device" +OBJECT_DECLARE_SIMPLE_TYPE (VHostUserGPIO,VHOST_USER_GPIO ); + +struct VHostUserGPIO { +/*< private >*/ +VirtIODevice parent_obj; +CharBackend chardev; +struct virtio_gpio_config config; +struct vhost_virtqueue *vhost_vq; +struct vhost_dev vhost_dev; +VhostUserState vhost_user; +VirtQueue *command_vq; +VirtQueue *interrupt_vq; +bool connected; +/*< public >*/ +}; + +#endif /* _QEMU_VHOST_USER_GPIO_H */
hw/virtio/vhost-user-gpio.c new file +411 -0
411 lines not on this page · raw message
MAINTAINERS +7 -0
@@ -2098,6 +2098,13 @@ F: hw/virtio/vhost-user-rng-pci.c F: include/hw/virtio/vhost-user-rng.h F: tools/vhost-user-rng/* +vhost-user-gpio +M: Alex Bennée <[email protected]> +R: Viresh Kumar <[email protected]> +S: Maintained +F: hw/virtio/vhost-user-gpio.c +F: include/hw/virtio/vhost-user-gpio.h + virtio-crypto M: Gonglei <[email protected]> S: Supported
hw/virtio/Kconfig +5 -0
@@ -80,3 +80,8 @@ config VHOST_USER_FS bool default y depends on VIRTIO && VHOST_USER + +config VHOST_USER_GPIO + bool + default y + depends on VIRTIO && VHOST_USER
hw/virtio/meson.build +1 -0
@@ -29,6 +29,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) +virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
hw/virtio/trace-events +5 -0
@@ -144,3 +144,8 @@ virtio_mem_state_response(uint16_t state) "state=%" PRIu16 virtio_pmem_flush_request(void) "flush request" virtio_pmem_response(void) "flush response" virtio_pmem_flush_done(int type) "fsync return=%d" + +# virtio-gpio.c +virtio_gpio_start(void) "start" +virtio_gpio_stop(void) "stop" +virtio_gpio_set_status(uint8_t status) "0x%x"
Signature · 1 line
MST
[PULL 12/55] tests/qtest: add a timeout for subprocess_run_one_test
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
Hangs have been observed in the tests and currently we don't timeout if a subprocess hangs. Rectify that.
Message-Id: <[email protected]>
--- tests/qtest/qos-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/qos-test.c +1 -1
@@ -185,7 +185,7 @@ static void run_one_test(const void *arg)static void subprocess_run_one_test (const void *arg) {const gchar *path = arg; -g_test_trap_subprocess (path,0 , +g_test_trap_subprocess (path,180 *G_USEC_PER_SEC ,G_TEST_SUBPROCESS_INHERIT_STDOUT |G_TEST_SUBPROCESS_INHERIT_STDERR );g_test_trap_assert_passed ();
Signature · 1 line
MST
[PULL 10/55] hw/virtio: add vhost-user-gpio-pci boilerplate
In reply to Michael S. TsirkinFrom: Viresh Kumar <[email protected]>
This allows is to instantiate a vhost-user-gpio device as part of a PCI bus. It is mostly boilerplate which looks pretty similar to the vhost-user-fs-pci device.
Message-Id: <5f560cab92d0d789b1c94295ec74b9952907d69d.1641987128.git.viresh.kumar@linaro.org>
Message-Id: <[email protected]>
--- hw/virtio/vhost-user-gpio-pci.c | 69 +++++++++++++++++++++++++++++++++ MAINTAINERS | 2 +- hw/virtio/meson.build | 1 + 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 hw/virtio/vhost-user-gpio-pci.c
hw/virtio/vhost-user-gpio-pci.c new file +69 -0
@@ -0,0 +1,69 @@ +/* +* Vhost-user gpio virtio device PCI glue +* +* Copyright (c) 2022 Viresh Kumar <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-gpio.h" +#include "hw/virtio/virtio-pci.h" + +struct VHostUserGPIOPCI { +VirtIOPCIProxy parent_obj; +VHostUserGPIO vdev; +}; + +typedef struct VHostUserGPIOPCI VHostUserGPIOPCI ; + +#define TYPE_VHOST_USER_GPIO_PCI "vhost-user-gpio-pci-base" + +DECLARE_INSTANCE_CHECKER (VHostUserGPIOPCI,VHOST_USER_GPIO_PCI , + TYPE_VHOST_USER_GPIO_PCI) + +static void vhost_user_gpio_pci_realize (VirtIOPCIProxy *vpci_dev,Error **errp) +{ +VHostUserGPIOPCI *dev =VHOST_USER_GPIO_PCI (vpci_dev); +DeviceState *vdev =DEVICE (&dev->vdev); + + vpci_dev->nvectors =1 ; +qdev_realize (vdev,BUS (&vpci_dev->bus), errp); +} + +static void vhost_user_gpio_pci_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +VirtioPCIClass *k =VIRTIO_PCI_CLASS (klass); +PCIDeviceClass *pcidev_k =PCI_DEVICE_CLASS (klass); + k->realize = vhost_user_gpio_pci_realize; +set_bit (DEVICE_CATEGORY_INPUT , dc->categories); + pcidev_k->vendor_id =PCI_VENDOR_ID_REDHAT_QUMRANET ; + pcidev_k->device_id =0 ;/* Set by virtio-pci based on virtio id */ + pcidev_k->revision =0x00 ; + pcidev_k->class_id =PCI_CLASS_COMMUNICATION_OTHER ; +} + +static void vhost_user_gpio_pci_instance_init (Object *obj) +{ +VHostUserGPIOPCI *dev =VHOST_USER_GPIO_PCI (obj); + +virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev), +TYPE_VHOST_USER_GPIO ); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_gpio_pci_info = { + .base_name =TYPE_VHOST_USER_GPIO_PCI , + .non_transitional_name ="vhost-user-gpio-pci" , + .instance_size =sizeof (VHostUserGPIOPCI), + .instance_init = vhost_user_gpio_pci_instance_init, + .class_init = vhost_user_gpio_pci_class_init, +}; + +static void vhost_user_gpio_pci_register (void ) +{ +virtio_pci_types_register (&vhost_user_gpio_pci_info); +} + +type_init (vhost_user_gpio_pci_register);
MAINTAINERS +1 -1
@@ -2102,7 +2102,7 @@ vhost-user-gpio M: Alex Bennée <[email protected]> R: Viresh Kumar <[email protected]> S: Maintained -F: hw/virtio/vhost-user-gpio.c +F: hw/virtio/vhost-user-gpio* F: include/hw/virtio/vhost-user-gpio.h virtio-crypto
hw/virtio/meson.build +1 -0
@@ -30,6 +30,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) +virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
Signature · 1 line
MST
[PULL 14/55] tests/qtest: catch unhandled vhost-user messages
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
We don't need to action every message but lets document the ones we are expecting to consume so future tests don't get confused about unhandled bits.
Message-Id: <[email protected]>
--- tests/qtest/vhost-user-test.c | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
tests/qtest/vhost-user-test.c +43 -0
@@ -358,12 +358,44 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) }break ; +case VHOST_USER_SET_OWNER : +/* +* We don't need to do anything here, the remote is just +* letting us know it is in charge. Just log it. +*/ +qos_printf ("set_owner: start of session\n" ); +break ; +case VHOST_USER_GET_PROTOCOL_FEATURES :if (s->vu_ops->get_protocol_features) { s->vu_ops->get_protocol_features (s, chr, &msg); }break ; +case VHOST_USER_SET_PROTOCOL_FEATURES : +/* +* We did set VHOST_USER_F_PROTOCOL_FEATURES so its valid for +* the remote end to send this. There is no handshake reply so +* just log the details for debugging. +*/ +qos_printf ("set_protocol_features: 0x%" PRIx64"\n" , msg.payload.u64); +break ; + +/* +* A real vhost-user backend would actually set the size and +* address of the vrings but we can simply report them. +*/ +case VHOST_USER_SET_VRING_NUM : +qos_printf ("set_vring_num: %d/%d\n" , + msg.payload.state.index, msg.payload.state.num); +break ; +case VHOST_USER_SET_VRING_ADDR : +qos_printf ("set_vring_addr: 0x%" PRIx64"/0x%" PRIx64"/0x%" PRIx64"\n" , + msg.payload.addr.avail_user_addr, + msg.payload.addr.desc_user_addr, + msg.payload.addr.used_user_addr); +break ; +case VHOST_USER_GET_VRING_BASE :/* send back vring base to qemu */ msg.flags |=VHOST_USER_REPLY_MASK ;
@@ -428,7 +460,18 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)qemu_chr_fe_write_all (chr, p,VHOST_USER_HDR_SIZE + msg.size);break ; +case VHOST_USER_SET_VRING_ENABLE : +/* +* Another case we ignore as we don't need to respond. With a +* fully functioning vhost-user we would enable/disable the +* vring monitoring. +*/ +qos_printf ("set_vring(%d)=%s\n" , msg.payload.state.index, + msg.payload.state.num ?"enabled" :"disabled" ); +break ; +default : +qos_printf ("vhost-user: un-handled message: %d\n" , msg.request);break ; }
Signature · 1 line
MST
[PULL 13/55] tests/qtest: use qos_printf instead of g_test_message
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
The vhost-user tests respawn qos-test as a standalone process. As a result the gtester framework squashes all messages coming out of it which make it hard to debug. As the test does not care about asserting certain messages just convert the tests to use the direct qos_printf.
Message-Id: <[email protected]>
--- tests/qtest/qos-test.c | 5 +++++ tests/qtest/vhost-user-test.c | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-)
tests/qtest/qos-test.c +5 -0
@@ -321,6 +321,11 @@ static void walk_path(QOSGraphNode *orig_path, int len)int main (int argc,char **argv,char ** envp) {g_test_init (&argc, &argv,NULL ); + +if (g_test_subprocess ()) { +qos_printf ("qos_test running single test in subprocess\n" ); + } +if (g_test_verbose ()) {qos_printf ("ENVIRONMENT VARIABLES: {\n" );for (char **env = envp; *env !=0 ; env++) {
tests/qtest/vhost-user-test.c +7 -6
@@ -26,6 +26,7 @@#include "libqos/virtio-pci.h" #include "libqos/malloc-pc.h" +#include "libqos/qgraph_internal.h" #include "hw/virtio/virtio-net.h" #include "standard-headers/linux/vhost_types.h"
@@ -316,7 +317,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) }if (size !=VHOST_USER_HDR_SIZE ) { -g_test_message ("Wrong message size received %d" , size); +qos_printf ("%s: Wrong message size received %d\n" , __func__, size);return ; }
@@ -327,8 +328,8 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) p +=VHOST_USER_HDR_SIZE ; size =qemu_chr_fe_read_all (chr, p, msg.size);if (size != msg.size) { -g_test_message ("Wrong message size received %d != %d" , - size, msg.size); +qos_printf ("%s: Wrong message size received %d != %d\n" , + __func__, size, msg.size);return ; } }
@@ -450,7 +451,7 @@ static const char *init_hugepagefs(void) }if (access (path,R_OK |W_OK |X_OK )) { -g_test_message ("access on path (%s): %s" , path,strerror (errno)); +qos_printf ("access on path (%s): %s" , path,strerror (errno));g_test_fail ();return NULL ; }
@@ -460,13 +461,13 @@ static const char *init_hugepagefs(void) }while (ret !=0 && errno ==EINTR );if (ret !=0 ) { -g_test_message ("statfs on path (%s): %s" , path,strerror (errno)); +qos_printf ("statfs on path (%s): %s" , path,strerror (errno));g_test_fail ();return NULL ; }if (fs.f_type !=HUGETLBFS_MAGIC ) { -g_test_message ("Warning: path not on HugeTLBFS: %s" , path); +qos_printf ("Warning: path not on HugeTLBFS: %s" , path);g_test_fail ();return NULL ; }
Signature · 1 line
MST
[PULL 16/55] tests/qtest: add assert to catch bad features
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
No device driver (which is what the qvirtio_ access functions represent) should be setting UNUSED(30) in the feature space. Although existing libqos users mask it out lets ensure nothing sneaks through.
Message-Id: <[email protected]>
--- tests/qtest/libqos/virtio.c | 2 ++ 1 file changed, 2 insertions(+)
tests/qtest/libqos/virtio.c +2 -0
@@ -101,6 +101,8 @@ uint64_t qvirtio_get_features(QVirtioDevice *d)void qvirtio_set_features (QVirtioDevice *d,uint64_t features) { +g_assert (!(features &QVIRTIO_F_BAD_FEATURE )); + d->features = features; d->bus->set_features (d, features);
Signature · 1 line
MST
[PULL 18/55] tests/qtest: add a get_features op to vhost-user-test
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
As we expand this test for more virtio devices we will need to support different feature sets. Add a mandatory op field to fetch the list of features needed for the test itself.
Message-Id: <[email protected]>
--- tests/qtest/vhost-user-test.c | 37 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
tests/qtest/vhost-user-test.c +27 -10
@@ -171,10 +171,11 @@ struct vhost_user_ops { const char *chr_opts);/* VHOST-USER commands. */ +uint64_t (*get_features)(TestServer *s);void (*set_features)(TestServer *s,CharBackend *chr, -VhostUserMsg *msg); +VhostUserMsg *msg);void (*get_protocol_features)(TestServer *s, -CharBackend *chr,VhostUserMsg *msg); +CharBackend *chr,VhostUserMsg *msg); };static const char *init_hugepagefs (void );
@@ -338,20 +339,22 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)switch (msg.request) {case VHOST_USER_GET_FEATURES : +/* Mandatory for tests to define get_features */ +g_assert (s->vu_ops->get_features); +/* send back features to qemu */ msg.flags |=VHOST_USER_REPLY_MASK ; msg.size =sizeof (m.payload.u64); - msg.payload.u64 =0x1ULL <<VHOST_F_LOG_ALL | -0x1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ; -if (s->queues >1 ) { - msg.payload.u64 |=0x1ULL <<VIRTIO_NET_F_MQ ; - } +if (s->test_flags >=TEST_FLAGS_BAD ) { msg.payload.u64 =0 ; s->test_flags =TEST_FLAGS_END ; + }else { + msg.payload.u64 = s->vu_ops->get_features (s); } - p = (uint8_t *) &msg; -qemu_chr_fe_write_all (chr, p,VHOST_USER_HDR_SIZE + msg.size); + +qemu_chr_fe_write_all (chr, (uint8_t *) &msg, +VHOST_USER_HDR_SIZE + msg.size);break ;case VHOST_USER_SET_FEATURES :
@@ -995,8 +998,21 @@ static void test_multiqueue(void *obj, void *arg, QGuestAllocator *alloc)wait_for_rings_started (s, s->queues *2 ); } + +static uint64_t vu_net_get_features (TestServer *s) +{ +uint64_t features =0x1ULL <<VHOST_F_LOG_ALL | +0x1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ; + +if (s->queues >1 ) { + features |=0x1ULL <<VIRTIO_NET_F_MQ ; + } + +return features; +} +static void vu_net_set_features (TestServer *s,CharBackend *chr, -VhostUserMsg *msg) +VhostUserMsg *msg) {g_assert (msg->payload.u64 & (0x1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ));if (s->test_flags ==TEST_FLAGS_DISCONNECT ) {
@@ -1025,6 +1041,7 @@ static struct vhost_user_ops g_vu_net_ops = { .append_opts = append_vhost_net_opts, + .get_features = vu_net_get_features, .set_features = vu_net_set_features, .get_protocol_features = vu_net_get_protocol_features, };
Signature · 1 line
MST
[PULL 17/55] tests/qtest: implement stub for VHOST_USER_GET_CONFIG
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
We don't implement the full solution because frankly none of the tests need to at the moment. We may end up re-implementing libvhostuser in the end.
Message-Id: <[email protected]>
--- tests/qtest/vhost-user-test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
tests/qtest/vhost-user-test.c +13 -0
@@ -79,6 +79,8 @@ typedef enum VhostUserRequest {VHOST_USER_SET_PROTOCOL_FEATURES =16 ,VHOST_USER_GET_QUEUE_NUM =17 ,VHOST_USER_SET_VRING_ENABLE =18 , +VHOST_USER_GET_CONFIG =24 , +VHOST_USER_SET_CONFIG =25 , VHOST_USER_MAX } VhostUserRequest;
@@ -372,6 +374,17 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) }break ; +case VHOST_USER_GET_CONFIG : +/* +* Treat GET_CONFIG as a NOP and just reply and let the guest +* consider we have updated its memory. Tests currently don't +* require working configs. +*/ + msg.flags |=VHOST_USER_REPLY_MASK ; + p = (uint8_t *) &msg; +qemu_chr_fe_write_all (chr, p,VHOST_USER_HDR_SIZE + msg.size); +break ; +case VHOST_USER_SET_PROTOCOL_FEATURES :/* * We did set VHOST_USER_F_PROTOCOL_FEATURES so its valid for
Signature · 1 line
MST
[PULL 19/55] tests/qtest: enable tests for virtio-gpio
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
We don't have a virtio-gpio implementation in QEMU and only support a vhost-user backend. The QEMU side of the code is minimal so it should be enough to instantiate the device and pass some vhost-user messages over the control socket. To do this we hook into the existing vhost-user-test code and just add the bits required for gpio.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
--- tests/qtest/libqos/virtio-gpio.h | 35 +++++++ tests/qtest/libqos/virtio-gpio.c | 171 +++++++++++++++++++++++++++++++ tests/qtest/libqos/virtio.c | 2 +- tests/qtest/vhost-user-test.c | 66 ++++++++++++ MAINTAINERS | 1 + tests/qtest/libqos/meson.build | 1 + 6 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/libqos/virtio-gpio.h create mode 100644 tests/qtest/libqos/virtio-gpio.c
tests/qtest/libqos/virtio-gpio.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* virtio-gpio structures +* +* Copyright (c) 2022 Linaro Ltd +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef TESTS_LIBQOS_VIRTIO_GPIO_H +#define TESTS_LIBQOS_VIRTIO_GPIO_H + +#include "qgraph.h" +#include "virtio.h" +#include "virtio-pci.h" + +typedef struct QVhostUserGPIO QVhostUserGPIO ; +typedef struct QVhostUserGPIOPCI QVhostUserGPIOPCI ; +typedef struct QVhostUserGPIODevice QVhostUserGPIODevice ; + +struct QVhostUserGPIO { +QVirtioDevice *vdev; +QVirtQueue **queues; +}; + +struct QVhostUserGPIOPCI { +QVirtioPCIDevice pci_vdev; +QVhostUserGPIO gpio; +}; + +struct QVhostUserGPIODevice { +QOSGraphObject obj; +QVhostUserGPIO gpio; +}; + +#endif
tests/qtest/libqos/virtio-gpio.c new file +171 -0
171 lines not on this page · raw message
tests/qtest/libqos/virtio.c +1 -1
@@ -110,7 +110,7 @@ void qvirtio_set_features(QVirtioDevice *d, uint64_t features)* This could be a separate function for drivers that want to access * configuration space before setting FEATURES_OK, but no existing users * need that and it's less code for callers if this is done implicitly. -*/ +*/ if (features & (1ull <<VIRTIO_F_VERSION_1 )) {uint8_t status = d->bus->get_status (d) |VIRTIO_CONFIG_S_FEATURES_OK ;
tests/qtest/vhost-user-test.c +66 -0
96 lines not on this page · raw message
MAINTAINERS +1 -0
@@ -2104,6 +2104,7 @@ R: Viresh Kumar <[email protected]> S: Maintained F: hw/virtio/vhost-user-gpio* F: include/hw/virtio/vhost-user-gpio.h +F: tests/qtest/libqos/virtio-gpio.* virtio-crypto M: Gonglei <[email protected]>
tests/qtest/libqos/meson.build +1 -0
@@ -45,6 +45,7 @@ libqos_srcs = files( 'virtio-scsi.c', 'virtio-serial.c', 'virtio-iommu.c', + 'virtio-gpio.c', 'generic-pcihost.c', # qgraph machines:
Signature · 1 line
MST
[PULL 21/55] virtio-blk: move config size params to virtio-blk-common
In reply to Michael S. TsirkinFrom: Daniil Tatianin <[email protected]>
This way we can reuse it for other virtio-blk devices, e.g vhost-user-blk, which currently does not control its config space size dynamically.
Message-Id: <[email protected]>
--- include/hw/virtio/virtio-blk-common.h | 20 ++++++++++++++ hw/block/virtio-blk-common.c | 39 +++++++++++++++++++++++++++ hw/block/virtio-blk.c | 24 ++--------------- MAINTAINERS | 2 ++ hw/block/meson.build | 2 +- 5 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 include/hw/virtio/virtio-blk-common.h create mode 100644 hw/block/virtio-blk-common.c
include/hw/virtio/virtio-blk-common.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* Virtio Block Device common helpers +* +* Copyright IBM, Corp. 2007 +* +* Authors: +* Anthony Liguori <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2. See +* the COPYING file in the top-level directory. +*/ + +#ifndef VIRTIO_BLK_COMMON_H +#define VIRTIO_BLK_COMMON_H + +#include "hw/virtio/virtio.h" + +extern const VirtIOConfigSizeParams virtio_blk_cfg_size_params; + +#endif
hw/block/virtio-blk-common.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Virtio Block Device common helpers +* +* Copyright IBM, Corp. 2007 +* +* Authors: +* Anthony Liguori <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2. See +* the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" + +#include "standard-headers/linux/virtio_blk.h" +#include "hw/virtio/virtio.h" +#include "hw/virtio/virtio-blk-common.h" + +/* Config size before the discard support (hide associated config fields) */ +#define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \ + max_discard_sectors) + +/* +* Starting from the discard feature, we can use this array to properly +* set the config size depending on the features enabled. +*/ +static const VirtIOFeature feature_sizes[] = { + {.flags =1ULL <<VIRTIO_BLK_F_DISCARD , + .end = endof(struct virtio_blk_config, discard_sector_alignment)}, + {.flags =1ULL <<VIRTIO_BLK_F_WRITE_ZEROES , + .end = endof(struct virtio_blk_config, write_zeroes_may_unmap)}, + {} +}; + +const VirtIOConfigSizeParams virtio_blk_cfg_size_params = { + .min_size =VIRTIO_BLK_CFG_SIZE , + .max_size =sizeof (struct virtio_blk_config ), + .feature_sizes = feature_sizes +};
hw/block/virtio-blk.c +2 -22
@@ -32,29 +32,9 @@#include "hw/virtio/virtio-bus.h" #include "migration/qemu-file-types.h" #include "hw/virtio/virtio-access.h" +#include "hw/virtio/virtio-blk-common.h" #include "qemu/coroutine.h" -/* Config size before the discard support (hide associated config fields) */ -#define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \ - max_discard_sectors) -/* -* Starting from the discard feature, we can use this array to properly -* set the config size depending on the features enabled. -*/ -static const VirtIOFeature feature_sizes[] = { - {.flags =1ULL <<VIRTIO_BLK_F_DISCARD , - .end = endof(struct virtio_blk_config, discard_sector_alignment)}, - {.flags =1ULL <<VIRTIO_BLK_F_WRITE_ZEROES , - .end = endof(struct virtio_blk_config, write_zeroes_may_unmap)}, - {} -}; - -static const VirtIOConfigSizeParams cfg_size_params = { - .min_size =VIRTIO_BLK_CFG_SIZE , - .max_size =sizeof (struct virtio_blk_config ), - .feature_sizes = feature_sizes -}; -static void virtio_blk_init_request (VirtIOBlock *s,VirtQueue *vq,VirtIOBlockReq *req) {
@@ -1202,7 +1182,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)return ; } - s->config_size =virtio_get_config_size (&cfg_size_params, + s->config_size =virtio_get_config_size (&virtio_blk_cfg_size_params, s->host_features);virtio_init (vdev,VIRTIO_ID_BLOCK , s->config_size);
MAINTAINERS +2 -0
@@ -2030,8 +2030,10 @@ virtio-blk M: Stefan Hajnoczi <[email protected]> L: [email protected] S: Supported +F: hw/block/virtio-blk-common.c F: hw/block/virtio-blk.c F: hw/block/dataplane/* +F: include/hw/virtio/virtio-blk-common.h F: tests/qtest/virtio-blk-test.c T: git https://github.com/stefanha/qemu.git block
hw/block/meson.build +1 -1
@@ -16,7 +16,7 @@ softmmu_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.c')) softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c')) softmmu_ss.add(when: 'CONFIG_TC58128', if_true: files('tc58128.c')) -specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c')) +specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c', 'virtio-blk-common.c')) specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c')) subdir('dataplane')
Signature · 1 line
MST
[PULL 15/55] tests/qtest: plain g_assert for VHOST_USER_F_PROTOCOL_FEATURES
In reply to Michael S. TsirkinFrom: Alex Bennée <[email protected]>
checkpatch.pl warns that non-plain asserts should be avoided so convert the check to a plain g_assert.
Message-Id: <[email protected]>
--- tests/qtest/vhost-user-test.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tests/qtest/vhost-user-test.c +1 -2
@@ -985,8 +985,7 @@ static void test_multiqueue(void *obj, void *arg, QGuestAllocator *alloc)static void vu_net_set_features (TestServer *s,CharBackend *chr,VhostUserMsg *msg) { -g_assert_cmpint (msg->payload.u64 & - (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES), !=, 0ULL); +g_assert (msg->payload.u64 & (0x1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ));if (s->test_flags ==TEST_FLAGS_DISCONNECT ) {qemu_chr_fe_disconnect (chr); s->test_flags =TEST_FLAGS_BAD ;
Signature · 1 line
MST
[PULL 20/55] virtio: introduce VirtIOConfigSizeParams & virtio_get_config_size
In reply to Michael S. TsirkinFrom: Daniil Tatianin <[email protected]>
This is the first step towards moving all device config size calculation logic into the virtio core code. In particular, this adds a struct that contains all the necessary information for common virtio code to be able to calculate the final config size for a device. This is expected to be used with the new virtio_get_config_size helper, which calculates the final length based on the provided host features.
This builds on top of already existing code like VirtIOFeature and virtio_feature_get_config_size(), but adds additional fields, as well as sanity checking so that device-specifc code doesn't have to duplicate it.
An example usage would be:
static const VirtIOFeature dev_features[] = {
{.flags = 1ULL << FEATURE_1_BIT,
.end = endof(struct virtio_dev_config, feature_1)},
{.flags = 1ULL << FEATURE_2_BIT,
.end = endof(struct virtio_dev_config, feature_2)},
{}
};
static const VirtIOConfigSizeParams dev_cfg_size_params = {
.min_size = DEV_BASE_CONFIG_SIZE,
.max_size = sizeof(struct virtio_dev_config),
.feature_sizes = dev_features
};
// code inside my_dev_device_realize()
size_t config_size = virtio_get_config_size(&dev_cfg_size_params,
host_features);
virtio_init(vdev, VIRTIO_ID_MYDEV, config_size);Currently every device is expected to write its own boilerplate from the example above in device_realize(), however, the next step of this transition is moving VirtIOConfigSizeParams into VirtioDeviceClass, so that it can be done automatically by the virtio initialization code.
All of the users of virtio_feature_get_config_size have been converted to use virtio_get_config_size so it's no longer needed and is removed with this commit.
Message-Id: <[email protected]>
--- include/hw/virtio/virtio.h | 10 ++++++++-- hw/block/virtio-blk.c | 16 +++++++--------- hw/net/virtio-net.c | 9 +++++++-- hw/virtio/virtio.c | 10 ++++++---- 4 files changed, 28 insertions(+), 17 deletions(-)
include/hw/virtio/virtio.h +8 -2
@@ -49,8 +49,14 @@ typedef struct VirtIOFeature {size_t end; } VirtIOFeature; -size_t virtio_feature_get_config_size (const VirtIOFeature *features, -uint64_t host_features); +typedef struct VirtIOConfigSizeParams { +size_t min_size; +size_t max_size; +const VirtIOFeature *feature_sizes; +}VirtIOConfigSizeParams ; + +size_t virtio_get_config_size (const VirtIOConfigSizeParams *params, +uint64_t host_features);typedef struct VirtQueue VirtQueue ;
hw/block/virtio-blk.c +7 -9
@@ -49,13 +49,11 @@ static const VirtIOFeature feature_sizes[] = { {} }; -static void virtio_blk_set_config_size (VirtIOBlock *s,uint64_t host_features) -{ - s->config_size =MAX (VIRTIO_BLK_CFG_SIZE , -virtio_feature_get_config_size (feature_sizes, host_features)); - -assert (s->config_size <=sizeof (struct virtio_blk_config )); -} +static const VirtIOConfigSizeParams cfg_size_params = { + .min_size =VIRTIO_BLK_CFG_SIZE , + .max_size =sizeof (struct virtio_blk_config ), + .feature_sizes = feature_sizes +};static void virtio_blk_init_request (VirtIOBlock *s,VirtQueue *vq,VirtIOBlockReq *req)
@@ -1204,8 +1202,8 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)return ; } -virtio_blk_set_config_size (s, s->host_features); - + s->config_size =virtio_get_config_size (&cfg_size_params, + s->host_features);virtio_init (vdev,VIRTIO_ID_BLOCK , s->config_size); s->blk = conf->conf.blk;
hw/net/virtio-net.c +7 -2
@@ -106,6 +106,12 @@ static const VirtIOFeature feature_sizes[] = { {} }; +static const VirtIOConfigSizeParams cfg_size_params = { + .min_size = endof(struct virtio_net_config, mac), + .max_size =sizeof (struct virtio_net_config ), + .feature_sizes = feature_sizes +}; +static VirtIONetQueue *virtio_net_get_subqueue (NetClientState *nc) {VirtIONet *n =qemu_get_nic_opaque (nc);
@@ -3241,8 +3247,7 @@ static void virtio_net_set_config_size(VirtIONet *n, uint64_t host_features) {virtio_add_feature (&host_features,VIRTIO_NET_F_MAC ); - n->config_size =virtio_feature_get_config_size (feature_sizes, - host_features); + n->config_size =virtio_get_config_size (&cfg_size_params, host_features); } void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
hw/virtio/virtio.c +6 -4
@@ -3006,11 +3006,12 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t val)return ret; } -size_t virtio_feature_get_config_size (const VirtIOFeature *feature_sizes, -uint64_t host_features) +size_t virtio_get_config_size (const VirtIOConfigSizeParams *params, +uint64_t host_features) { -size_t config_size =0 ; -int i; +size_t config_size = params->min_size; +const VirtIOFeature *feature_sizes = params->feature_sizes; +size_t i;for (i =0 ; feature_sizes[i].flags !=0 ; i++) {if (host_features & feature_sizes[i].flags) {
@@ -3018,6 +3019,7 @@ size_t virtio_feature_get_config_size(const VirtIOFeature *feature_sizes, } } +assert (config_size <= params->max_size);return config_size; }
Signature · 1 line
MST
[PULL 22/55] vhost-user-blk: make it possible to disable write-zeroes/discard
In reply to Michael S. TsirkinFrom: Daniil Tatianin <[email protected]>
It is useful to have the ability to disable these features for compatibility with older VMs that don't have these implemented.
Message-Id: <[email protected]>
--- hw/block/vhost-user-blk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/block/vhost-user-blk.c +4 -2
@@ -259,8 +259,6 @@ static uint64_t vhost_user_blk_get_features(VirtIODevice *vdev,virtio_add_feature (&features,VIRTIO_BLK_F_BLK_SIZE );virtio_add_feature (&features,VIRTIO_BLK_F_FLUSH );virtio_add_feature (&features,VIRTIO_BLK_F_RO ); -virtio_add_feature (&features,VIRTIO_BLK_F_DISCARD ); -virtio_add_feature (&features,VIRTIO_BLK_F_WRITE_ZEROES );if (s->config_wce) {virtio_add_feature (&features,VIRTIO_BLK_F_CONFIG_WCE );
@@ -598,6 +596,10 @@ static Property vhost_user_blk_properties[] = { VHOST_USER_BLK_AUTO_NUM_QUEUES),DEFINE_PROP_UINT32 ("queue-size" , VHostUserBlk, queue_size,128 ),DEFINE_PROP_BIT ("config-wce" , VHostUserBlk, config_wce,0 , true), +DEFINE_PROP_BIT64 ("discard" , VHostUserBlk, parent_obj.host_features, +VIRTIO_BLK_F_DISCARD , true), +DEFINE_PROP_BIT64 ("write-zeroes" , VHostUserBlk, parent_obj.host_features, +VIRTIO_BLK_F_WRITE_ZEROES , true), DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
MST
[PULL 29/55] Revert "intel_iommu: Fix irqchip / X2APIC configuration checks"
In reply to Michael S. TsirkinFrom: Peter Xu <[email protected]>
It's true that when vcpus<=255 we don't require the length of 32bit APIC IDs. However here since we already have EIM=ON it means the hypervisor will declare the VM as x2apic supported (e.g. VT-d ECAP register will have EIM bit 4 set), so the guest should assume the APIC IDs are 32bits width even if vcpus<=255. In short, commit 77250171bdc breaks any simple cmdline that wants to boot a VM with >=9 but <=255 vcpus with:
-device intel-iommu,intremap=on
For anyone who does not want to enable x2apic, we can use eim=off in the intel-iommu parameters to skip enabling KVM x2apic.
This partly reverts commit 77250171bdc02aee106083fd2a068147befa1a38, while keeping the valid bit on checking split irqchip, but revert the other change.
One thing to mention is that this patch may break migration compatibility of such VM, however that's probably the best thing we can do, because the old behavior was simply wrong and not working for >8 vcpus. For <=8 vcpus, there could be a light guest ABI change (by enabling KVM x2apic after this patch), but logically it shouldn't affect the migration from working.
Also, this is not the 1st commit to change x2apic behavior. Igor provided a full history of how this evolved for the past few years:
https://lore.kernel.org/qemu-devel/[email protected]/
Relevant commits for reference:
fb506e701e ("intel_iommu: reject broken EIM", 2016-10-17)
c1bb5418e3 ("target/i386: Support up to 32768 CPUs without IRQ remapping", 2020-12-10) 77250171bd ("intel_iommu: Fix irqchip / X2APIC configuration checks", 2022-05-16) dc89f32d92 ("target/i386: Fix sanity check on max APIC ID / X2APIC enablement", 2022-05-16)
We may want to have this for stable too (mostly for 7.1.0 only). Adding a fixes tag.
Message-Id: <[email protected]>
--- hw/i386/intel_iommu.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/i386/intel_iommu.c +5 -0
@@ -3818,6 +3818,11 @@ static bool vtd_decide_config(IntelIOMMUState *s, Error **errp)error_setg (errp,"eim=on requires accel=kvm,kernel-irqchip=split" );return false; } +if (!kvm_enable_x2apic ()) { +error_setg (errp,"eim=on requires support on the KVM side" +"(X2APIC_API, first shipped in v4.7)" ); +return false; + } }/* Currently only address widths supported are 39 and 48 bits */
Signature · 1 line
MST
[PULL 23/55] vhost-user-blk: make 'config_wce' part of 'host_features'
In reply to Michael S. TsirkinFrom: Daniil Tatianin <[email protected]>
No reason to have this be a separate field. This also makes it more akin to what the virtio-blk device does.
Message-Id: <[email protected]>
--- include/hw/virtio/vhost-user-blk.h | 1 - hw/block/vhost-user-blk.c | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-)
include/hw/virtio/vhost-user-blk.h +0 -1
@@ -34,7 +34,6 @@ struct VHostUserBlk {struct virtio_blk_config blkcfg;uint16_t num_queues;uint32_t queue_size; -uint32_t config_wce;struct vhost_dev dev;struct vhost_inflight *inflight;VhostUserState vhost_user;
hw/block/vhost-user-blk.c +2 -4
@@ -260,9 +260,6 @@ static uint64_t vhost_user_blk_get_features(VirtIODevice *vdev,virtio_add_feature (&features,VIRTIO_BLK_F_FLUSH );virtio_add_feature (&features,VIRTIO_BLK_F_RO ); -if (s->config_wce) { -virtio_add_feature (&features,VIRTIO_BLK_F_CONFIG_WCE ); - }if (s->num_queues >1 ) {virtio_add_feature (&features,VIRTIO_BLK_F_MQ ); }
@@ -595,7 +592,8 @@ static Property vhost_user_blk_properties[] = {DEFINE_PROP_UINT16 ("num-queues" , VHostUserBlk, num_queues,VHOST_USER_BLK_AUTO_NUM_QUEUES ),DEFINE_PROP_UINT32 ("queue-size" , VHostUserBlk, queue_size,128 ), -DEFINE_PROP_BIT ("config-wce" , VHostUserBlk, config_wce,0 , true), +DEFINE_PROP_BIT64 ("config-wce" , VHostUserBlk, parent_obj.host_features, +VIRTIO_BLK_F_CONFIG_WCE , true),DEFINE_PROP_BIT64 ("discard" , VHostUserBlk, parent_obj.host_features,VIRTIO_BLK_F_DISCARD , true), DEFINE_PROP_BIT64("write-zeroes", VHostUserBlk, parent_obj.host_features,
Signature · 1 line
MST
[PULL 24/55] vhost-user-blk: dynamically resize config space based on features
In reply to Michael S. TsirkinFrom: Daniil Tatianin <[email protected]>
Make vhost-user-blk backwards compatible when migrating from older VMs running with modern features turned off, the same way it was done for virtio-blk in 20764be0421c ("virtio-blk: set config size depending on the features enabled")
It's currently impossible to migrate from an older VM with vhost-user-blk (with disable-legacy=off) because of errors like this:
qemu-system-x86_64: get_pci_config_device: Bad config data: i=0x10 read: 41 device: 1 cmask: ff wmask: 80 w1cmask:0
qemu-system-x86_64: Failed to load PCIDevice:config
qemu-system-x86_64: Failed to load virtio-blk:virtio
qemu-system-x86_64: error while loading state for instance 0x0 of device '0000:00:05.0:00.0:02.0/virtio-blk'
qemu-system-x86_64: load of migration failed: Invalid argument
This is caused by the newer (destination) VM requiring a bigger BAR0 alignment because it has to cover a bigger configuration space, which isn't actually needed since those additional config fields are not active (write-zeroes/discard).
Message-Id: <[email protected]>
--- hw/block/vhost-user-blk.c | 17 ++++++++++------- MAINTAINERS | 2 ++ hw/block/meson.build | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-)
hw/block/vhost-user-blk.c +10 -7
@@ -23,6 +23,7 @@#include "hw/qdev-core.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" +#include "hw/virtio/virtio-blk-common.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user-blk.h" #include "hw/virtio/virtio.h"
@@ -63,7 +64,7 @@ static void vhost_user_blk_update_config(VirtIODevice *vdev, uint8_t *config)/* Our num_queues overrides the device backend */ virtio_stw_p (vdev, &s->blkcfg.num_queues, s->num_queues); -memcpy (config, &s->blkcfg,sizeof (struct virtio_blk_config )); +memcpy (config, &s->blkcfg, vdev->config_len); }static void vhost_user_blk_set_config (VirtIODevice *vdev,const uint8_t *config)
@@ -92,12 +93,12 @@ static int vhost_user_blk_handle_config_change(struct vhost_dev *dev) {int ret;struct virtio_blk_config blkcfg; +VirtIODevice *vdev = dev->vdev;VHostUserBlk *s =VHOST_USER_BLK (dev->vdev);Error *local_err =NULL ; ret =vhost_dev_get_config (dev, (uint8_t *)&blkcfg, -sizeof (struct virtio_blk_config ), - &local_err); + vdev->config_len, &local_err);if (ret <0 ) {error_report_err (local_err);return ret;
@@ -106,7 +107,7 @@ static int vhost_user_blk_handle_config_change(struct vhost_dev *dev)/* valid for resize only */ if (blkcfg.capacity != s->blkcfg.capacity) { s->blkcfg.capacity = blkcfg.capacity; -memcpy (dev->vdev->config, &s->blkcfg,sizeof (struct virtio_blk_config )); +memcpy (dev->vdev->config, &s->blkcfg, vdev->config_len);virtio_notify_config (dev->vdev); }
@@ -448,7 +449,7 @@ static int vhost_user_blk_realize_connect(VHostUserBlk *s, Error **errp)assert (s->connected); ret =vhost_dev_get_config (&s->dev, (uint8_t *)&s->blkcfg, -sizeof (struct virtio_blk_config ), errp); + s->parent_obj.config_len, errp);if (ret <0 ) {qemu_chr_fe_disconnect (&s->chardev);vhost_dev_cleanup (&s->dev);
@@ -463,6 +464,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)ERRP_GUARD ();VirtIODevice *vdev =VIRTIO_DEVICE (dev);VHostUserBlk *s =VHOST_USER_BLK (vdev); +size_t config_size;int retries;int i, ret;
@@ -493,8 +495,9 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)return ; } -virtio_init (vdev,VIRTIO_ID_BLOCK , -sizeof (struct virtio_blk_config )); + config_size =virtio_get_config_size (&virtio_blk_cfg_size_params, + vdev->host_features); +virtio_init (vdev,VIRTIO_ID_BLOCK , config_size); s->virtqs = g_new(VirtQueue *, s->num_queues);for (i =0 ; i < s->num_queues; i++) {
MAINTAINERS +2 -0
@@ -2281,11 +2281,13 @@ S: Maintained F: contrib/vhost-user-blk/ F: contrib/vhost-user-scsi/ F: hw/block/vhost-user-blk.c +F: hw/block/virtio-blk-common.c F: hw/scsi/vhost-user-scsi.c F: hw/virtio/vhost-user-blk-pci.c F: hw/virtio/vhost-user-scsi-pci.c F: include/hw/virtio/vhost-user-blk.h F: include/hw/virtio/vhost-user-scsi.h +F: include/hw/virtio/virtio-blk-common.h vhost-user-gpu M: Marc-André Lureau <[email protected]>
hw/block/meson.build +1 -1
@@ -17,6 +17,6 @@ softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c')) softmmu_ss.add(when: 'CONFIG_TC58128', if_true: files('tc58128.c')) specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c', 'virtio-blk-common.c')) -specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c')) +specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c', 'virtio-blk-common.c')) subdir('dataplane')
Signature · 1 line
MST
[PULL 26/55] acpi: arm/virt: build_gtdt: fix invalid 64-bit physical addresses
In reply to Michael S. TsirkinFrom: Miguel Luis <[email protected]>
Per the ACPI 6.5 specification, on the GTDT Table Structure, the Counter Control Block Address and Counter Read Block Address fields of the GTDT table should be set to 0xFFFFFFFFFFFFFFFF if not provided, rather than 0x0.
Message-Id: <[email protected]>
--- hw/arm/virt-acpi-build.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
hw/arm/virt-acpi-build.c +2 -3
@@ -592,8 +592,7 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)acpi_table_begin (&table, table_data);/* CntControlBase Physical Address */ -/* FIXME: invalid value, should be 0xFFFFFFFFFFFFFFFF if not impl. ? */ -build_append_int_noprefix (table_data,0 ,8 ); +build_append_int_noprefix (table_data,0xFFFFFFFFFFFFFFFF ,8 );build_append_int_noprefix (table_data,0 ,4 );/* Reserved */ /* * FIXME: clarify comment:
@@ -618,7 +617,7 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)/* Non-Secure EL2 timer Flags */ build_append_int_noprefix (table_data, irqflags,4 );/* CntReadBase Physical address */ -build_append_int_noprefix (table_data,0 ,8 ); +build_append_int_noprefix (table_data,0xFFFFFFFFFFFFFFFF ,8 );/* Platform Timer Count */ build_append_int_noprefix (table_data,0 ,4 );/* Platform Timer Offset */
Signature · 1 line
MST
[PULL 25/55] tests/acpi: virt: allow acpi GTDT changes
In reply to Michael S. TsirkinFrom: Miguel Luis <[email protected]>
Step 3 from bios-tables-test.c documented procedure.
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 3 +++ 1 file changed, 3 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +3 -0
@@ -1 +1,4 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/virt/GTDT" , +"tests/data/acpi/virt/GTDT.memhp" , +"tests/data/acpi/virt/GTDT.numamem",
Signature · 1 line
MST
[PULL 34/55] qmp: add QMP command x-query-virtio-queue-element
In reply to Michael S. TsirkinFrom: Laurent Vivier <[email protected]>
This new command shows the information of a VirtQueue element.
[Note: Up until v10 of this patch series, virtio.json had many (15+)
enums defined (e.g. decoded device features, statuses, etc.). In v10 most of these enums were removed and replaced with string literals. By doing this we get (1) simpler schema, (2) smaller generated code, and (3) less maintenance burden for when new things are added (e.g. devices, device features, etc.).]
Message-Id: <[email protected]>
--- qapi/virtio.json | 197 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-stub.c | 9 ++ hw/virtio/virtio.c | 154 +++++++++++++++++++++++++++++++ 3 files changed, 360 insertions(+)
qapi/virtio.json +197 -0
@@ -755,3 +755,200 @@ 'data': { 'path': 'str', 'queue': 'uint16' }, 'returns': 'VirtVhostQueueStatus', 'features': [ 'unstable' ] } + +## +# @VirtioRingDesc: +# +# Information regarding the vring descriptor area +# +# @addr: Guest physical address of the descriptor area +# +# @len: Length of the descriptor area +# +# @flags: List of descriptor flags +# +# Since: 7.1 +# +## + +{ 'struct': 'VirtioRingDesc', + 'data': { 'addr': 'uint64', + 'len': 'uint32', + 'flags': [ 'str' ] } } + +## +# @VirtioRingAvail: +# +# Information regarding the avail vring (a.k.a. driver area) +# +# @flags: VRingAvail flags +# +# @idx: VRingAvail index +# +# @ring: VRingAvail ring[] entry at provided index +# +# Since: 7.1 +# +## + +{ 'struct': 'VirtioRingAvail', + 'data': { 'flags': 'uint16', + 'idx': 'uint16', + 'ring': 'uint16' } } + +## +# @VirtioRingUsed: +# +# Information regarding the used vring (a.k.a. device area) +# +# @flags: VRingUsed flags +# +# @idx: VRingUsed index +# +# Since: 7.1 +# +## + +{ 'struct': 'VirtioRingUsed', + 'data': { 'flags': 'uint16', + 'idx': 'uint16' } } + +## +# @VirtioQueueElement: +# +# Information regarding a VirtQueue's VirtQueueElement including +# descriptor, driver, and device areas +# +# @name: Name of the VirtIODevice that uses this VirtQueue +# +# @index: Index of the element in the queue +# +# @descs: List of descriptors (VirtioRingDesc) +# +# @avail: VRingAvail info +# +# @used: VRingUsed info +# +# Since: 7.1 +# +## + +{ 'struct': 'VirtioQueueElement', + 'data': { 'name': 'str', + 'index': 'uint32', + 'descs': [ 'VirtioRingDesc' ], + 'avail': 'VirtioRingAvail', + 'used': 'VirtioRingUsed' } } + +## +# @x-query-virtio-queue-element: +# +# Return the information about a VirtQueue's VirtQueueElement +# +# @path: VirtIODevice canonical QOM path +# +# @queue: VirtQueue index to examine +# +# @index: Index of the element in the queue +# (default: head of the queue) +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtioQueueElement information +# +# Since: 7.1 +# +# Examples: +# +# 1. Introspect on virtio-net's VirtQueue 0 at index 5 +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral-anon/device[1]/virtio-backend", +# "queue": 0, +# "index": 5 } +# } +# <- { "return": { +# "index": 5, +# "name": "virtio-net", +# "descs": [ +# { +# "flags": ["write"], +# "len": 1536, +# "addr": 5257305600 +# } +# ], +# "avail": { +# "idx": 256, +# "flags": 0, +# "ring": 5 +# }, +# "used": { +# "idx": 13, +# "flags": 0 +# } +# } +# } +# +# 2. Introspect on virtio-crypto's VirtQueue 1 at head +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend", +# "queue": 1 } +# } +# <- { "return": { +# "index": 0, +# "name": "virtio-crypto", +# "descs": [ +# { +# "flags": [], +# "len": 0, +# "addr": 8080268923184214134 +# } +# ], +# "avail": { +# "idx": 280, +# "flags": 0, +# "ring": 0 +# }, +# "used": { +# "idx": 280, +# "flags": 0 +# } +# } +# } +# +# 3. Introspect on virtio-scsi's VirtQueue 2 at head +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral-anon/device[2]/virtio-backend", +# "queue": 2 } +# } +# <- { "return": { +# "index": 19, +# "name": "virtio-scsi", +# "descs": [ +# { +# "flags": ["used", "indirect", "write"], +# "len": 4099327944, +# "addr": 12055409292258155293 +# } +# ], +# "avail": { +# "idx": 1147, +# "flags": 0, +# "ring": 19 +# }, +# "used": { +# "idx": 280, +# "flags": 0 +# } +# } +# } +# +## + +{ 'command': 'x-query-virtio-queue-element', + 'data': { 'path': 'str', 'queue': 'uint16', '*index': 'uint16' }, + 'returns': 'VirtioQueueElement', + 'features': [ 'unstable' ] }
hw/virtio/virtio-stub.c +9 -0
@@ -31,3 +31,12 @@ VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, {return qmp_virtio_unsupported (errp); } + +VirtioQueueElement *qmp_x_query_virtio_queue_element (const char *path, +uint16_t queue, +bool has_index, +uint16_t index, +Error **errp) +{ +return qmp_virtio_unsupported (errp); +}
hw/virtio/virtio.c +154 -0
166 lines not on this page · raw message
Signature · 1 line
MST
[PULL 28/55] mem/cxl-type3: Add sn option to provide serial number for PCI ecap
In reply to Michael S. TsirkinFrom: Jonathan Cameron <[email protected]>
The Device Serial Number Extended Capability PCI r6.0 sec 7.9.3 provides a standard way to provide a device serial number as an IEEE defined 64-bit extended unique identifier EUI-64.
CXL 2.0 section 8.1.12.2 Memory Device PCIe Capabilities and Extended Capabilities requires this to be used to uniquely identify CXL memory devices.
Message-Id: <[email protected]>
--- include/hw/cxl/cxl_device.h | 1 + hw/mem/cxl_type3.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
include/hw/cxl/cxl_device.h +1 -0
@@ -237,6 +237,7 @@ struct CXLType3Dev {/* Properties */ HostMemoryBackend *hostmem;HostMemoryBackend *lsa; +uint64_t sn;/* State */ AddressSpace hostmem_as;
hw/mem/cxl_type3.c +13 -1
@@ -14,6 +14,12 @@#include "sysemu/hostmem.h" #include "hw/cxl/cxl.h" +/* +* Null value of all Fs suggested by IEEE RA guidelines for use of +* EU, OUI and CID +*/ +#define UI64_NULL ~(0ULL) +static void build_dvsecs (CXLType3Dev *ct3d) {CXLComponentState *cxl_cstate = &ct3d->cxl_cstate;
@@ -149,7 +155,12 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp)pci_config_set_class (pci_conf,PCI_CLASS_MEMORY_CXL );pcie_endpoint_cap_init (pci_dev,0x80 ); - cxl_cstate->dvsec_offset =0x100 ; +if (ct3d->sn !=UI64_NULL ) { +pcie_dev_ser_num_init (pci_dev,0x100 , ct3d->sn); + cxl_cstate->dvsec_offset =0x100 +0x0c ; + }else { + cxl_cstate->dvsec_offset =0x100 ; + } ct3d->cxl_cstate.pdev = pci_dev;build_dvsecs (ct3d);
@@ -275,6 +286,7 @@ static Property ct3_props[] = { HostMemoryBackend *),DEFINE_PROP_LINK ("lsa" , CXLType3Dev, lsa,TYPE_MEMORY_BACKEND , HostMemoryBackend *), +DEFINE_PROP_UINT64 ("sn" , CXLType3Dev, sn,UI64_NULL ), DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
MST
[PULL 36/55] pci: Remove unused pci_get_*_by_mask() functions
In reply to Michael S. TsirkinFrom: Peter Maydell <[email protected]>
The helper functions pci_get_{byte,word,long,quad}_by_mask() were added in 2012 in commit c9f50cea70a1596. In the decade since we have never added a single use of them.
The helpers clearly aren't that helpful, so drop them rather than carrying around dead code.
Message-Id: <[email protected]>
--- include/hw/pci/pci.h | 28 ---------------------------- 1 file changed, 28 deletions(-)
include/hw/pci/pci.h +0 -28
@@ -692,13 +692,6 @@ pci_set_byte_by_mask(uint8_t *config, uint8_t mask, uint8_t reg)pci_set_byte (config, (~mask & val) | (mask & rval)); } -static inline uint8_t -pci_get_byte_by_mask (uint8_t *config,uint8_t mask) -{ -uint8_t val =pci_get_byte (config); -return (val & mask) >>ctz32 (mask); -} -static inline void pci_set_word_by_mask (uint8_t *config,uint16_t mask,uint16_t reg) {
@@ -707,13 +700,6 @@ pci_set_word_by_mask(uint8_t *config, uint16_t mask, uint16_t reg)pci_set_word (config, (~mask & val) | (mask & rval)); } -static inline uint16_t -pci_get_word_by_mask (uint8_t *config,uint16_t mask) -{ -uint16_t val =pci_get_word (config); -return (val & mask) >>ctz32 (mask); -} -static inline void pci_set_long_by_mask (uint8_t *config,uint32_t mask,uint32_t reg) {
@@ -722,13 +708,6 @@ pci_set_long_by_mask(uint8_t *config, uint32_t mask, uint32_t reg)pci_set_long (config, (~mask & val) | (mask & rval)); } -static inline uint32_t -pci_get_long_by_mask (uint8_t *config,uint32_t mask) -{ -uint32_t val =pci_get_long (config); -return (val & mask) >>ctz32 (mask); -} -static inline void pci_set_quad_by_mask (uint8_t *config,uint64_t mask,uint64_t reg) {
@@ -737,13 +716,6 @@ pci_set_quad_by_mask(uint8_t *config, uint64_t mask, uint64_t reg)pci_set_quad (config, (~mask & val) | (mask & rval)); } -static inline uint64_t -pci_get_quad_by_mask (uint8_t *config,uint64_t mask) -{ -uint64_t val =pci_get_quad (config); -return (val & mask) >>ctz32 (mask); -} -PCIDevice *pci_new_multifunction (int devfn,bool multifunction,const char *name);PCIDevice *pci_new (int devfn,const char *name);
Signature · 1 line
MST
[PULL 31/55] qmp: add QMP command x-query-virtio-status
In reply to Michael S. TsirkinFrom: Laurent Vivier <[email protected]>
This new command shows the status of a VirtIODevice, including its corresponding vhost device's status (if active).
Next patch will improve output by decoding feature bits, including vhost device's feature bits (backend, protocol, acked, and features). Also will decode status bits of a VirtIODevice.
[Jonah: From patch v12; added a check to @virtio_device_find to ensure
synchronicity between @virtio_list and the devices in the QOM composition tree.]
Message-Id: <[email protected]>
--- qapi/virtio.json | 222 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-stub.c | 5 + hw/virtio/virtio.c | 104 +++++++++++++++++++ 3 files changed, 331 insertions(+)
qapi/virtio.json +222 -0
@@ -66,3 +66,225 @@ { 'command': 'x-query-virtio', 'returns': [ 'VirtioInfo' ], 'features': [ 'unstable' ] } + +## +# @VhostStatus: +# +# Information about a vhost device. This information will only be +# displayed if the vhost device is active. +# +# @n-mem-sections: vhost_dev n_mem_sections +# +# @n-tmp-sections: vhost_dev n_tmp_sections +# +# @nvqs: vhost_dev nvqs (number of virtqueues being used) +# +# @vq-index: vhost_dev vq_index +# +# @features: vhost_dev features +# +# @acked-features: vhost_dev acked_features +# +# @backend-features: vhost_dev backend_features +# +# @protocol-features: vhost_dev protocol_features +# +# @max-queues: vhost_dev max_queues +# +# @backend-cap: vhost_dev backend_cap +# +# @log-enabled: vhost_dev log_enabled flag +# +# @log-size: vhost_dev log_size +# +# Since: 7.1 +# +## + +{ 'struct': 'VhostStatus', + 'data': { 'n-mem-sections': 'int', + 'n-tmp-sections': 'int', + 'nvqs': 'uint32', + 'vq-index': 'int', + 'features': 'uint64', + 'acked-features': 'uint64', + 'backend-features': 'uint64', + 'protocol-features': 'uint64', + 'max-queues': 'uint64', + 'backend-cap': 'uint64', + 'log-enabled': 'bool', + 'log-size': 'uint64' } } + +## +# @VirtioStatus: +# +# Full status of the virtio device with most VirtIODevice members. +# Also includes the full status of the corresponding vhost device +# if the vhost device is active. +# +# @name: VirtIODevice name +# +# @device-id: VirtIODevice ID +# +# @vhost-started: VirtIODevice vhost_started flag +# +# @guest-features: VirtIODevice guest_features +# +# @host-features: VirtIODevice host_features +# +# @backend-features: VirtIODevice backend_features +# +# @device-endian: VirtIODevice device_endian +# +# @num-vqs: VirtIODevice virtqueue count. This is the number of active +# virtqueues being used by the VirtIODevice. +# +# @status: VirtIODevice configuration status (VirtioDeviceStatus) +# +# @isr: VirtIODevice ISR +# +# @queue-sel: VirtIODevice queue_sel +# +# @vm-running: VirtIODevice vm_running flag +# +# @broken: VirtIODevice broken flag +# +# @disabled: VirtIODevice disabled flag +# +# @use-started: VirtIODevice use_started flag +# +# @started: VirtIODevice started flag +# +# @start-on-kick: VirtIODevice start_on_kick flag +# +# @disable-legacy-check: VirtIODevice disabled_legacy_check flag +# +# @bus-name: VirtIODevice bus_name +# +# @use-guest-notifier-mask: VirtIODevice use_guest_notifier_mask flag +# +# @vhost-dev: Corresponding vhost device info for a given VirtIODevice. +# Present if the given VirtIODevice has an active vhost +# device. +# +# Since: 7.1 +# +## + +{ 'struct': 'VirtioStatus', + 'data': { 'name': 'str', + 'device-id': 'uint16', + 'vhost-started': 'bool', + 'device-endian': 'str', + 'guest-features': 'uint64', + 'host-features': 'uint64', + 'backend-features': 'uint64', + 'num-vqs': 'int', + 'status': 'uint8', + 'isr': 'uint8', + 'queue-sel': 'uint16', + 'vm-running': 'bool', + 'broken': 'bool', + 'disabled': 'bool', + 'use-started': 'bool', + 'started': 'bool', + 'start-on-kick': 'bool', + 'disable-legacy-check': 'bool', + 'bus-name': 'str', + 'use-guest-notifier-mask': 'bool', + '*vhost-dev': 'VhostStatus' } } + +## +# @x-query-virtio-status: +# +# Poll for a comprehensive status of a given virtio device +# +# @path: Canonical QOM path of the VirtIODevice +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtioStatus of the virtio device +# +# Since: 7.1 +# +# Examples: +# +# 1. Poll for the status of virtio-crypto (no vhost-crypto active) +# +# -> { "execute": "x-query-virtio-status", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend" } +# } +# <- { "return": { +# "device-endian": "little", +# "bus-name": "", +# "disable-legacy-check": false, +# "name": "virtio-crypto", +# "started": true, +# "device-id": 20, +# "backend-features": 0, +# "start-on-kick": false, +# "isr": 1, +# "broken": false, +# "status": 15, +# "num-vqs": 2, +# "guest-features": 5100273664, +# "host-features": 6325010432, +# "use-guest-notifier-mask": true, +# "vm-running": true, +# "queue-sel": 1, +# "disabled": false, +# "vhost-started": false, +# "use-started": true +# } +# } +# +# 2. Poll for the status of virtio-net (vhost-net is active) +# +# -> { "execute": "x-query-virtio-status", +# "arguments": { "path": "/machine/peripheral-anon/device[1]/virtio-backend" } +# } +# <- { "return": { +# "device-endian": "little", +# "bus-name": "", +# "disabled-legacy-check": false, +# "name": "virtio-net", +# "started": true, +# "device-id": 1, +# "vhost-dev": { +# "n-tmp-sections": 4, +# "n-mem-sections": 4, +# "max-queues": 1, +# "backend-cap": 2, +# "log-size": 0, +# "backend-features": 0, +# "nvqs": 2, +# "protocol-features": 0, +# "vq-index": 0, +# "log-enabled": false, +# "acked-features": 5100306432, +# "features": 13908344832 +# }, +# "backend-features": 6337593319, +# "start-on-kick": false, +# "isr": 1, +# "broken": false, +# "status": 15, +# "num-vqs": 3, +# "guest-features": 5111807911, +# "host-features": 6337593319, +# "use-guest-notifier-mask": true, +# "vm-running": true, +# "queue-sel": 2, +# "disabled": false, +# "vhost-started": true, +# "use-started": true +# } +# } +# +## + +{ 'command': 'x-query-virtio-status', + 'data': { 'path': 'str' }, + 'returns': 'VirtioStatus', + 'features': [ 'unstable' ] }
hw/virtio/virtio-stub.c +5 -0
@@ -12,3 +12,8 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp) {return qmp_virtio_unsupported (errp); } + +VirtioStatus *qmp_x_query_virtio_status (const char *path,Error **errp) +{ +return qmp_virtio_unsupported (errp); +}
hw/virtio/virtio.c +104 -0
110 lines not on this page · raw message
Signature · 1 line
MST
[PULL 27/55] tests/acpi: virt: update ACPI GTDT binaries
In reply to Michael S. TsirkinFrom: Miguel Luis <[email protected]>
Step 6 & 7 of the bios-tables-test.c documented procedure.
Differences between disassembled ASL files for GTDT:
@@ -13,14 +13,14 @@
[000h 0000 4] Signature : "GTDT" [Generic Timer Description Table]
[004h 0004 4] Table Length : 00000060
[008h 0008 1] Revision : 02
-[009h 0009 1] Checksum : 8C
+[009h 0009 1] Checksum : 9C
[00Ah 0010 6] Oem ID : "BOCHS "
[010h 0016 8] Oem Table ID : "BXPC "
[018h 0024 4] Oem Revision : 00000001
[01Ch 0028 4] Asl Compiler ID : "BXPC"
[020h 0032 4] Asl Compiler Revision : 00000001
-[024h 0036 8] Counter Block Address : 0000000000000000
+[024h 0036 8] Counter Block Address : FFFFFFFFFFFFFFFF
[02Ch 0044 4] Reserved : 00000000
[030h 0048 4] Secure EL1 Interrupt : 0000001D
@@ -46,16 +46,16 @@
Trigger Mode : 0
Polarity : 0
Always On : 0
-[050h 0080 8] Counter Read Block Address : 0000000000000000
+[050h 0080 8] Counter Read Block Address : FFFFFFFFFFFFFFFF
[058h 0088 4] Platform Timer Count : 00000000
[05Ch 0092 4] Platform Timer Offset : 00000000
Raw Table Data: Length 96 (0x60)
- 0000: 47 54 44 54 60 00 00 00 02 8C 42 4F 43 48 53 20 // GTDT`.....BOCHS
+ 0000: 47 54 44 54 60 00 00 00 02 9C 42 4F 43 48 53 20 // GTDT`.....BOCHS
0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC
- 0020: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
+ 0020: 01 00 00 00 FF FF FF FF FF FF FF FF 00 00 00 00 // ................
0030: 1D 00 00 00 00 00 00 00 1E 00 00 00 04 00 00 00 // ................
0040: 1B 00 00 00 00 00 00 00 1A 00 00 00 00 00 00 00 // ................
- 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
+ 0050: FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 // ................Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 3 --- tests/data/acpi/virt/GTDT | Bin 96 -> 96 bytes tests/data/acpi/virt/GTDT.memhp | Bin 96 -> 96 bytes tests/data/acpi/virt/GTDT.numamem | Bin 96 -> 96 bytes 4 files changed, 3 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -3
@@ -1,4 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/virt/GTDT" , -"tests/data/acpi/virt/GTDT.memhp" , -"tests/data/acpi/virt/GTDT.numamem",
tests/data/acpi/virt/GTDT binary +0 -0
tests/data/acpi/virt/GTDT.memhp binary +0 -0
tests/data/acpi/virt/GTDT.numamem binary +0 -0
Signature · 1 line
MST
[PULL 30/55] qmp: add QMP command x-query-virtio
In reply to Michael S. TsirkinFrom: Laurent Vivier <[email protected]>
This new command lists all the instances of VirtIODevices with their canonical QOM path and name.
[Jonah: @virtio_list duplicates information that already exists in
the QOM composition tree. However, extracting necessary information from this tree seems to be a bit convoluted.
Instead, we still create our own list of realized virtio devices but use @qmp_qom_get with the device's canonical QOM path to confirm that the device exists and is realized. If the device exists but is actually not realized, then we remove it from our list (for synchronicity to the QOM composition tree).
Also, the QMP command @x-query-virtio is redundant as @qom-list and @qom-get are sufficient to search '/machine/' for realized virtio devices. However, @x-query-virtio is much more convenient in listing realized virtio devices.]
Message-Id: <[email protected]>
--- qapi/qapi-schema.json | 1 + qapi/virtio.json | 68 ++++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 1 + hw/virtio/virtio-stub.c | 14 ++++++++ hw/virtio/virtio.c | 44 ++++++++++++++++++++++++ tests/qtest/qmp-cmd-test.c | 1 + hw/virtio/meson.build | 2 ++ qapi/meson.build | 1 + 8 files changed, 132 insertions(+) create mode 100644 qapi/virtio.json create mode 100644 hw/virtio/virtio-stub.c
qapi/qapi-schema.json +1 -0
@@ -94,3 +94,4 @@ { 'include': 'acpi.json' } { 'include': 'pci.json' } { 'include': 'stats.json' } +{ 'include': 'virtio.json' }
qapi/virtio.json new file +68 -0
68 lines not on this page · raw message
include/hw/virtio/virtio.h +1 -0
@@ -122,6 +122,7 @@ struct VirtIODevicebool use_guest_notifier_mask;AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; +QTAILQ_ENTRY (VirtIODevice) next; };struct VirtioDeviceClass {
hw/virtio/virtio-stub.c new file +14 -0
@@ -0,0 +1,14 @@ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-virtio.h" + +static void *qmp_virtio_unsupported (Error **errp) +{ +error_setg (errp,"Virtio is disabled" ); +return NULL ; +} + +VirtioInfoList *qmp_x_query_virtio (Error **errp) +{ +return qmp_virtio_unsupported (errp); +}
hw/virtio/virtio.c +44 -0
86 lines not on this page · raw message
tests/qtest/qmp-cmd-test.c +1 -0
@@ -103,6 +103,7 @@ static bool query_is_ignored(const char *cmd)"query-gic-capabilities" ,/* arm */ /* Success depends on target-specific build configuration: */ "query-pci" ,/* CONFIG_PCI */ +"x-query-virtio" ,/* CONFIG_VIRTIO */ /* Success depends on launching SEV guest */ "query-sev-launch-measure",/* Success depends on Host or Hypervisor SEV support */
hw/virtio/meson.build +2 -0
@@ -62,4 +62,6 @@ virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss) specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: virtio_ss) softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: softmmu_virtio_ss) softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('virtio-stub.c')) softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('virtio-stub.c'))
qapi/meson.build +1 -0
@@ -49,6 +49,7 @@ qapi_all_modules = [ 'stats', 'trace', 'transaction', + 'virtio', 'yank', ] if have_system
Signature · 1 line
MST
[PULL 41/55] tests: acpi: update expected blobs after HPET move
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
HPET AML moved after PCI host bridge description (no functional change)
diff example for PC machine:
@@ -54,47 +54,6 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)
}
}- Scope (_SB)
- {
- Device (HPET)
- {
- Name (_HID, EisaId ("PNP0103") /* HPET System Timer */) // _HID: Hardware ID
- Name (_UID, Zero) // _UID: Unique ID
- OperationRegion (HPTM, SystemMemory, 0xFED00000, 0x0400)
- Field (HPTM, DWordAcc, Lock, Preserve)
- {
- VEND, 32,
- PRD, 32- }
-
- Method (_STA, 0, NotSerialized) // _STA: Status
- {
- Local0 = VEND /* \_SB_.HPET.VEND */
- Local1 = PRD /* \_SB_.HPET.PRD_ */
- Local0 >>= 0x10
- If (((Local0 == Zero) || (Local0 == 0xFFFF)))
- {- Return (Zero)
- }
-
- If (((Local1 == Zero) || (Local1 > 0x05F5E100)))
- {
- Return (Zero)
- }
-
- Return (0x0F)
- }
-
- Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
- {
- Memory32Fixed (ReadOnly,
- 0xFED00000, // Address Base - 0x00000400, // Address Length - )
- })
- }
- }
-
Scope (_SB.PCI0)
{
Device (ISA)
@@ -529,6 +488,47 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)
}
}+ Scope (_SB)
+ {
+ Device (HPET)
+ {
+ Name (_HID, EisaId ("PNP0103") /* HPET System Timer */) // _HID: Hardware ID
+ Name (_UID, Zero) // _UID: Unique ID
+ OperationRegion (HPTM, SystemMemory, 0xFED00000, 0x0400)
+ Field (HPTM, DWordAcc, Lock, Preserve)
+ {
+ VEND, 32,
+ PRD, 32+ }
+
+ Method (_STA, 0, NotSerialized) // _STA: Status
+ {
+ Local0 = VEND /* \_SB_.HPET.VEND */
+ Local1 = PRD /* \_SB_.HPET.PRD_ */
+ Local0 >>= 0x10
+ If (((Local0 == Zero) || (Local0 == 0xFFFF)))
+ {+ Return (Zero)
+ }
+
+ If (((Local1 == Zero) || (Local1 > 0x05F5E100)))
+ {
+ Return (Zero)
+ }
+
+ Return (0x0F)
+ }
+
+ Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
+ {
+ Memory32Fixed (ReadOnly,
+ 0xFED00000, // Address Base + 0x00000400, // Address Length + )
+ })
+ }
+ }
+
Scope (_SB)
{
Device (\_SB.PCI0.PRES)Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 32 -------------------- tests/data/acpi/pc/DSDT | Bin 5987 -> 5987 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 5954 -> 5954 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7312 -> 7312 bytes tests/data/acpi/pc/DSDT.bridge | Bin 8653 -> 8653 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6451 -> 6451 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 7641 -> 7641 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5954 -> 5954 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3069 -> 3069 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6059 -> 6059 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7346 -> 7346 bytes tests/data/acpi/pc/DSDT.numamem | Bin 5993 -> 5993 bytes tests/data/acpi/pc/DSDT.roothp | Bin 6195 -> 6195 bytes tests/data/acpi/q35/DSDT | Bin 8274 -> 8274 bytes tests/data/acpi/q35/DSDT.acpierst | Bin 8291 -> 8291 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9599 -> 9599 bytes tests/data/acpi/q35/DSDT.applesmc | Bin 8320 -> 8320 bytes tests/data/acpi/q35/DSDT.bridge | Bin 10988 -> 10988 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8738 -> 8738 bytes tests/data/acpi/q35/DSDT.cxl | Bin 9600 -> 9600 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9928 -> 9928 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 8349 -> 8349 bytes tests/data/acpi/q35/DSDT.ipmismbus | Bin 8363 -> 8363 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 8291 -> 8291 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9633 -> 9633 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9404 -> 9404 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 8568 -> 8568 bytes tests/data/acpi/q35/DSDT.numamem | Bin 8280 -> 8280 bytes tests/data/acpi/q35/DSDT.pvpanic-isa | Bin 8375 -> 8375 bytes tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8880 -> 8880 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8906 -> 8906 bytes tests/data/acpi/q35/DSDT.viot | Bin 9383 -> 9383 bytes tests/data/acpi/q35/DSDT.xapic | Bin 35637 -> 35637 bytes 33 files changed, 32 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -32
@@ -1,33 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT" , -"tests/data/acpi/pc/DSDT.acpierst" , -"tests/data/acpi/pc/DSDT.acpihmat" , -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.cphp" , -"tests/data/acpi/pc/DSDT.dimmpxm" , -"tests/data/acpi/pc/DSDT.hpbridge" , -"tests/data/acpi/pc/DSDT.hpbrroot" , -"tests/data/acpi/pc/DSDT.ipmikcs" , -"tests/data/acpi/pc/DSDT.memhp" , -"tests/data/acpi/pc/DSDT.numamem" , -"tests/data/acpi/pc/DSDT.roothp" , -"tests/data/acpi/q35/DSDT" , -"tests/data/acpi/q35/DSDT.acpierst" , -"tests/data/acpi/q35/DSDT.acpihmat" , -"tests/data/acpi/q35/DSDT.applesmc" , -"tests/data/acpi/q35/DSDT.bridge" , -"tests/data/acpi/q35/DSDT.cphp" , -"tests/data/acpi/q35/DSDT.cxl" , -"tests/data/acpi/q35/DSDT.dimmpxm" , -"tests/data/acpi/q35/DSDT.ipmibt" , -"tests/data/acpi/q35/DSDT.ipmismbus" , -"tests/data/acpi/q35/DSDT.ivrs" , -"tests/data/acpi/q35/DSDT.memhp" , -"tests/data/acpi/q35/DSDT.mmio64" , -"tests/data/acpi/q35/DSDT.multi-bridge" , -"tests/data/acpi/q35/DSDT.numamem" , -"tests/data/acpi/q35/DSDT.pvpanic-isa" , -"tests/data/acpi/q35/DSDT.tis.tpm12" , -"tests/data/acpi/q35/DSDT.tis.tpm2" , -"tests/data/acpi/q35/DSDT.viot" , -"tests/data/acpi/q35/DSDT.xapic",
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.hpbrroot binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT binary +0 -0
tests/data/acpi/q35/DSDT.acpierst binary +0 -0
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
tests/data/acpi/q35/DSDT.applesmc binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.cphp binary +0 -0
tests/data/acpi/q35/DSDT.cxl binary +0 -0
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
tests/data/acpi/q35/DSDT.ipmismbus binary +0 -0
tests/data/acpi/q35/DSDT.ivrs binary +0 -0
tests/data/acpi/q35/DSDT.memhp binary +0 -0
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
tests/data/acpi/q35/DSDT.numamem binary +0 -0
tests/data/acpi/q35/DSDT.pvpanic-isa binary +0 -0
tests/data/acpi/q35/DSDT.tis.tpm12 binary +0 -0
tests/data/acpi/q35/DSDT.tis.tpm2 binary +0 -0
tests/data/acpi/q35/DSDT.viot binary +0 -0
tests/data/acpi/q35/DSDT.xapic binary +0 -0
Signature · 1 line
MST
[PULL 33/55] qmp: add QMP commands for virtio/vhost queue-status
In reply to Michael S. TsirkinFrom: Laurent Vivier <[email protected]>
These new commands show the internal status of a VirtIODevice's VirtQueue and a vhost device's vhost_virtqueue (if active).
Message-Id: <[email protected]>
--- qapi/virtio.json | 256 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-stub.c | 14 +++ hw/virtio/virtio.c | 103 ++++++++++++++++ 3 files changed, 373 insertions(+)
qapi/virtio.json +256 -0
@@ -499,3 +499,259 @@ 'data': { 'transports': [ 'str' ], '*dev-features': [ 'str' ], '*unknown-dev-features': 'uint64' } } + +## +# @VirtQueueStatus: +# +# Information of a VirtIODevice VirtQueue, including most members of +# the VirtQueue data structure. +# +# @name: Name of the VirtIODevice that uses this VirtQueue +# +# @queue-index: VirtQueue queue_index +# +# @inuse: VirtQueue inuse +# +# @vring-num: VirtQueue vring.num +# +# @vring-num-default: VirtQueue vring.num_default +# +# @vring-align: VirtQueue vring.align +# +# @vring-desc: VirtQueue vring.desc (descriptor area) +# +# @vring-avail: VirtQueue vring.avail (driver area) +# +# @vring-used: VirtQueue vring.used (device area) +# +# @last-avail-idx: VirtQueue last_avail_idx or return of vhost_dev +# vhost_get_vring_base (if vhost active) +# +# @shadow-avail-idx: VirtQueue shadow_avail_idx +# +# @used-idx: VirtQueue used_idx +# +# @signalled-used: VirtQueue signalled_used +# +# @signalled-used-valid: VirtQueue signalled_used_valid flag +# +# Since: 7.1 +# +## + +{ 'struct': 'VirtQueueStatus', + 'data': { 'name': 'str', + 'queue-index': 'uint16', + 'inuse': 'uint32', + 'vring-num': 'uint32', + 'vring-num-default': 'uint32', + 'vring-align': 'uint32', + 'vring-desc': 'uint64', + 'vring-avail': 'uint64', + 'vring-used': 'uint64', + '*last-avail-idx': 'uint16', + '*shadow-avail-idx': 'uint16', + 'used-idx': 'uint16', + 'signalled-used': 'uint16', + 'signalled-used-valid': 'bool' } } + +## +# @x-query-virtio-queue-status: +# +# Return the status of a given VirtIODevice's VirtQueue +# +# @path: VirtIODevice canonical QOM path +# +# @queue: VirtQueue index to examine +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtQueueStatus of the VirtQueue +# +# Notes: last_avail_idx will not be displayed in the case where +# the selected VirtIODevice has a running vhost device and +# the VirtIODevice VirtQueue index (queue) does not exist for +# the corresponding vhost device vhost_virtqueue. Also, +# shadow_avail_idx will not be displayed in the case where +# the selected VirtIODevice has a running vhost device. +# +# Since: 7.1 +# +# Examples: +# +# 1. Get VirtQueueStatus for virtio-vsock (vhost-vsock running) +# +# -> { "execute": "x-query-virtio-queue-status", +# "arguments": { "path": "/machine/peripheral/vsock0/virtio-backend", +# "queue": 1 } +# } +# <- { "return": { +# "signalled-used": 0, +# "inuse": 0, +# "name": "vhost-vsock", +# "vring-align": 4096, +# "vring-desc": 5217370112, +# "signalled-used-valid": false, +# "vring-num-default": 128, +# "vring-avail": 5217372160, +# "queue-index": 1, +# "last-avail-idx": 0, +# "vring-used": 5217372480, +# "used-idx": 0, +# "vring-num": 128 +# } +# } +# +# 2. Get VirtQueueStatus for virtio-serial (no vhost) +# +# -> { "execute": "x-query-virtio-queue-status", +# "arguments": { "path": "/machine/peripheral-anon/device[0]/virtio-backend", +# "queue": 20 } +# } +# <- { "return": { +# "signalled-used": 0, +# "inuse": 0, +# "name": "virtio-serial", +# "vring-align": 4096, +# "vring-desc": 5182074880, +# "signalled-used-valid": false, +# "vring-num-default": 128, +# "vring-avail": 5182076928, +# "queue-index": 20, +# "last-avail-idx": 0, +# "vring-used": 5182077248, +# "used-idx": 0, +# "shadow-avail-idx": 0, +# "vring-num": 128 +# } +# } +# +## + +{ 'command': 'x-query-virtio-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtQueueStatus', + 'features': [ 'unstable' ] } + +## +# @VirtVhostQueueStatus: +# +# Information of a vhost device's vhost_virtqueue, including most +# members of the vhost_dev vhost_virtqueue data structure. +# +# @name: Name of the VirtIODevice that uses this vhost_virtqueue +# +# @kick: vhost_virtqueue kick +# +# @call: vhost_virtqueue call +# +# @desc: vhost_virtqueue desc +# +# @avail: vhost_virtqueue avail +# +# @used: vhost_virtqueue used +# +# @num: vhost_virtqueue num +# +# @desc-phys: vhost_virtqueue desc_phys (descriptor area phys. addr.) +# +# @desc-size: vhost_virtqueue desc_size +# +# @avail-phys: vhost_virtqueue avail_phys (driver area phys. addr.) +# +# @avail-size: vhost_virtqueue avail_size +# +# @used-phys: vhost_virtqueue used_phys (device area phys. addr.) +# +# @used-size: vhost_virtqueue used_size +# +# Since: 7.1 +# +## + +{ 'struct': 'VirtVhostQueueStatus', + 'data': { 'name': 'str', + 'kick': 'int', + 'call': 'int', + 'desc': 'uint64', + 'avail': 'uint64', + 'used': 'uint64', + 'num': 'int', + 'desc-phys': 'uint64', + 'desc-size': 'uint32', + 'avail-phys': 'uint64', + 'avail-size': 'uint32', + 'used-phys': 'uint64', + 'used-size': 'uint32' } } + +## +# @x-query-virtio-vhost-queue-status: +# +# Return information of a given vhost device's vhost_virtqueue +# +# @path: VirtIODevice canonical QOM path +# +# @queue: vhost_virtqueue index to examine +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtVhostQueueStatus of the vhost_virtqueue +# +# Since: 7.1 +# +# Examples: +# +# 1. Get vhost_virtqueue status for vhost-crypto +# +# -> { "execute": "x-query-virtio-vhost-queue-status", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend", +# "queue": 0 } +# } +# <- { "return": { +# "avail-phys": 5216124928, +# "name": "virtio-crypto", +# "used-phys": 5216127040, +# "avail-size": 2054, +# "desc-size": 16384, +# "used-size": 8198, +# "desc": 140141447430144, +# "num": 1024, +# "call": 0, +# "avail": 140141447446528, +# "desc-phys": 5216108544, +# "used": 140141447448640, +# "kick": 0 +# } +# } +# +# 2. Get vhost_virtqueue status for vhost-vsock +# +# -> { "execute": "x-query-virtio-vhost-queue-status", +# "arguments": { "path": "/machine/peripheral/vsock0/virtio-backend", +# "queue": 0 } +# } +# <- { "return": { +# "avail-phys": 5182261248, +# "name": "vhost-vsock", +# "used-phys": 5182261568, +# "avail-size": 262, +# "desc-size": 2048, +# "used-size": 1030, +# "desc": 140141413580800, +# "num": 128, +# "call": 0, +# "avail": 140141413582848, +# "desc-phys": 5182259200, +# "used": 140141413583168, +# "kick": 0 +# } +# } +# +## + +{ 'command': 'x-query-virtio-vhost-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtVhostQueueStatus', + 'features': [ 'unstable' ] }
hw/virtio/virtio-stub.c +14 -0
@@ -17,3 +17,17 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) {return qmp_virtio_unsupported (errp); } + +VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status (const char *path, +uint16_t queue, +Error **errp) +{ +return qmp_virtio_unsupported (errp); +} + +VirtQueueStatus *qmp_x_query_virtio_queue_status (const char *path, +uint16_t queue, +Error **errp) +{ +return qmp_virtio_unsupported (errp); +}
hw/virtio/virtio.c +103 -0
109 lines not on this page · raw message
Signature · 1 line
MST
[PULL 32/55] qmp: decode feature & status bits in virtio-status
In reply to Michael S. TsirkinFrom: Laurent Vivier <[email protected]>
Display feature names instead of bitmaps for host, guest, and backend for VirtIODevices.
Display status names instead of bitmaps for VirtIODevices.
Display feature names instead of bitmaps for backend, protocol, acked, and features (hdev->features) for vhost devices.
Decode features according to device ID. Decode statuses according to configuration status bitmap (config_status_map). Decode vhost user protocol features according to vhost user protocol bitmap (vhost_user_protocol_map).
Transport features are on the first line. Undecoded bits (if any) are stored in a separate field.
[Jonah: Several changes made to this patch from prev. version (v14):
- Moved all device features mappings to hw/virtio/virtio.c
- Renamed device features mappings (less generic)
- Generalized @FEATURE_ENTRY macro for all device mappings
- Virtio device feature map definitions include descriptions of feature bits
- Moved @VHOST_USER_F_PROTOCOL_FEATURES feature bit from transport feature map to vhost-user-supported device feature mappings (blk, fs, i2c, rng, net, gpu, input, scsi, vsock)
- New feature bit added for virtio-vsock: @VIRTIO_VSOCK_F_SEQPACKET
- New feature bit added for virtio-iommu: @VIRTIO_IOMMU_F_BYPASS_CONFIG
- New feature bit added for virtio-mem: @VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE
- New virtio transport feature bit added: @VIRTIO_F_IN_ORDER
- Added device feature map definition for virtio-rng
]
Message-Id: <[email protected]>
--- qapi/virtio.json | 251 +++++++++++++-- include/hw/virtio/vhost.h | 3 + include/hw/virtio/virtio.h | 5 + hw/virtio/virtio.c | 643 ++++++++++++++++++++++++++++++++++++- 4 files changed, 874 insertions(+), 28 deletions(-)
qapi/virtio.json +231 -20
@@ -106,10 +106,10 @@ 'n-tmp-sections': 'int', 'nvqs': 'uint32', 'vq-index': 'int', - 'features': 'uint64', - 'acked-features': 'uint64', - 'backend-features': 'uint64', - 'protocol-features': 'uint64', + 'features': 'VirtioDeviceFeatures', + 'acked-features': 'VirtioDeviceFeatures', + 'backend-features': 'VirtioDeviceFeatures', + 'protocol-features': 'VhostDeviceProtocols', 'max-queues': 'uint64', 'backend-cap': 'uint64', 'log-enabled': 'bool',
@@ -176,11 +176,11 @@ 'device-id': 'uint16', 'vhost-started': 'bool', 'device-endian': 'str', - 'guest-features': 'uint64', - 'host-features': 'uint64', - 'backend-features': 'uint64', + 'guest-features': 'VirtioDeviceFeatures', + 'host-features': 'VirtioDeviceFeatures', + 'backend-features': 'VirtioDeviceFeatures', 'num-vqs': 'int', - 'status': 'uint8', + 'status': 'VirtioDeviceStatus', 'isr': 'uint8', 'queue-sel': 'uint16', 'vm-running': 'bool',
@@ -222,14 +222,41 @@ # "name": "virtio-crypto", # "started": true, # "device-id": 20, -# "backend-features": 0, +# "backend-features": { +# "transports": [], +# "dev-features": [] +# }, # "start-on-kick": false, # "isr": 1, # "broken": false, -# "status": 15, +# "status": { +# "statuses": [ +# "VIRTIO_CONFIG_S_ACKNOWLEDGE: Valid virtio device found", +# "VIRTIO_CONFIG_S_DRIVER: Guest OS compatible with device", +# "VIRTIO_CONFIG_S_FEATURES_OK: Feature negotiation complete", +# "VIRTIO_CONFIG_S_DRIVER_OK: Driver setup and ready" +# ] +# }, # "num-vqs": 2, -# "guest-features": 5100273664, -# "host-features": 6325010432, +# "guest-features": { +# "dev-features": [], +# "transports": [ +# "VIRTIO_RING_F_EVENT_IDX: Used & avail. event fields enabled", +# "VIRTIO_RING_F_INDIRECT_DESC: Indirect descriptors supported", +# "VIRTIO_F_VERSION_1: Device compliant for v1 spec (legacy)" +# ] +# }, +# "host-features": { +# "unknown-dev-features": 1073741824, +# "dev-features": [], +# "transports": [ +# "VIRTIO_RING_F_EVENT_IDX: Used & avail. event fields enabled", +# "VIRTIO_RING_F_INDIRECT_DESC: Indirect descriptors supported", +# "VIRTIO_F_VERSION_1: Device compliant for v1 spec (legacy)", +# "VIRTIO_F_ANY_LAYOUT: Device accepts arbitrary desc. layouts", +# "VIRTIO_F_NOTIFY_ON_EMPTY: Notify when device runs out of avail. descs. on VQ" +# ] +# }, # "use-guest-notifier-mask": true, # "vm-running": true, # "queue-sel": 1,
@@ -257,22 +284,147 @@ # "max-queues": 1, # "backend-cap": 2, # "log-size": 0, -# "backend-features": 0, +# "backend-features": { +# "dev-features": [], +# "transports": [] +# }, # "nvqs": 2, -# "protocol-features": 0, +# "protocol-features": { +# "protocols": [] +# }, # "vq-index": 0, # "log-enabled": false, -# "acked-features": 5100306432, -# "features": 13908344832 +# "acked-features": { +# "dev-features": [ +# "VIRTIO_NET_F_MRG_RXBUF: Driver can merge receive buffers" +# ], +# "transports": [ +# "VIRTIO_RING_F_EVENT_IDX: Used & avail. event fields enabled", +# "VIRTIO_RING_F_INDIRECT_DESC: Indirect descriptors supported", +# "VIRTIO_F_VERSION_1: Device compliant for v1 spec (legacy)" +# ] +# }, +# "features": { +# "dev-features": [ +# "VHOST_F_LOG_ALL: Logging write descriptors supported", +# "VIRTIO_NET_F_MRG_RXBUF: Driver can merge receive buffers" +# ], +# "transports": [ +# "VIRTIO_RING_F_EVENT_IDX: Used & avail. event fields enabled", +# "VIRTIO_RING_F_INDIRECT_DESC: Indirect descriptors supported", +# "VIRTIO_F_IOMMU_PLATFORM: Device can be used on IOMMU platform", +# "VIRTIO_F_VERSION_1: Device compliant for v1 spec (legacy)", +# "VIRTIO_F_ANY_LAYOUT: Device accepts arbitrary desc. layouts", +# "VIRTIO_F_NOTIFY_ON_EMPTY: Notify when device runs out of avail. descs. on VQ" +# ] +# } +# }, +# "backend-features": { +# "dev-features": [ +# "VHOST_USER_F_PROTOCOL_FEATURES: Vhost-user protocol features negotation supported", +# "VIRTIO_NET_F_GSO: Handling GSO-type packets supported", +# "VIRTIO_NET_F_CTRL_MAC_ADDR: MAC address set through control channel", +# "VIRTIO_NET_F_GUEST_ANNOUNCE: Driver sending gratuitous packets supported", +# "VIRTIO_NET_F_CTRL_RX_EXTRA: Extra RX mode control supported", +# "VIRTIO_NET_F_CTRL_VLAN: Control channel VLAN filtering supported", +# "VIRTIO_NET_F_CTRL_RX: Control channel RX mode supported", +# "VIRTIO_NET_F_CTRL_VQ: Control channel available", +# "VIRTIO_NET_F_STATUS: Configuration status field available", +# "VIRTIO_NET_F_MRG_RXBUF: Driver can merge receive buffers", +# "VIRTIO_NET_F_HOST_UFO: Device can receive UFO", +# "VIRTIO_NET_F_HOST_ECN: Device can receive TSO with ECN", +# "VIRTIO_NET_F_HOST_TSO6: Device can receive TSOv6", +# "VIRTIO_NET_F_HOST_TSO4: Device can receive TSOv4", +# "VIRTIO_NET_F_GUEST_UFO: Driver can receive UFO", +# "VIRTIO_NET_F_GUEST_ECN: Driver can receive TSO with ECN", +# "VIRTIO_NET_F_GUEST_TSO6: Driver can receive TSOv6", +# "VIRTIO_NET_F_GUEST_TSO4: Driver can receive TSOv4", +# "VIRTIO_NET_F_MAC: Device has given MAC address", +# "VIRTIO_NET_F_CTRL_GUEST_OFFLOADS: Control channel offloading reconfig. supported", +# "VIRTIO_NET_F_GUEST_CSUM: Driver handling packets with partial checksum supported", +# "VIRTIO_NET_F_CSUM: Device handling packets with partial checksum supported" +# ], +# "transports": [ +# "VIRTIO_RING_F_EVENT_IDX: Used & avail. event fields enabled", +# "VIRTIO_RING_F_INDIRECT_DESC: Indirect descriptors supported", +# "VIRTIO_F_VERSION_1: Device compliant for v1 spec (legacy)", +# "VIRTIO_F_ANY_LAYOUT: Device accepts arbitrary desc. layouts", +# "VIRTIO_F_NOTIFY_ON_EMPTY: Notify when device runs out of avail. descs. on VQ" +# ] # }, -# "backend-features": 6337593319, # "start-on-kick": false, # "isr": 1, # "broken": false, -# "status": 15, +# "status": { +# "statuses": [ +# "VIRTIO_CONFIG_S_ACKNOWLEDGE: Valid virtio device found", +# "VIRTIO_CONFIG_S_DRIVER: Guest OS compatible with device", +# "VIRTIO_CONFIG_S_FEATURES_OK: Feature negotiation complete", +# "VIRTIO_CONFIG_S_DRIVER_OK: Driver setup and ready" +# ] +# }, # "num-vqs": 3, -# "guest-features": 5111807911, -# "host-features": 6337593319, +# "guest-features": { +# "dev-features": [ +# "VIRTIO_NET_F_CTRL_MAC_ADDR: MAC address set through control channel", +# "VIRTIO_NET_F_GUEST_ANNOUNCE: Driver sending gratuitous packets supported", +# "VIRTIO_NET_F_CTRL_VLAN: Control channel VLAN filtering supported", +# "VIRTIO_NET_F_CTRL_RX: Control channel RX mode supported", +# "VIRTIO_NET_F_CTRL_VQ: Control channel available", +# "VIRTIO_NET_F_STATUS: Configuration status field available", +# "VIRTIO_NET_F_MRG_RXBUF: Driver can merge receive buffers", +# "VIRTIO_NET_F_HOST_UFO: Device can receive UFO", +# "VIRTIO_NET_F_HOST_ECN: Device can receive TSO with ECN", +# "VIRTIO_NET_F_HOST_TSO6: Device can receive TSOv6", +# "VIRTIO_NET_F_HOST_TSO4: Device can receive TSOv4", +# "VIRTIO_NET_F_GUEST_UFO: Driver can receive UFO", +# "VIRTIO_NET_F_GUEST_ECN: Driver can receive TSO with ECN", +# "VIRTIO_NET_F_GUEST_TSO6: Driver can receive TSOv6", +# "VIRTIO_NET_F_GUEST_TSO4: Driver can receive TSOv4", +# "VIRTIO_NET_F_MAC: Device has given MAC address", +# "VIRTIO_NET_F_CTRL_GUEST_OFFLOADS: Control channel offloading reconfig. supported", +# "VIRTIO_NET_F_GUEST_CSUM: Driver handling packets with partial checksum supported", +# "VIRTIO_NET_F_CSUM: Device handling packets with partial checksum supported" +# ], +# "transports": [ +# "VIRTIO_RING_F_EVENT_IDX: Used & avail. event fields enabled", +# "VIRTIO_RING_F_INDIRECT_DESC: Indirect descriptors supported", +# "VIRTIO_F_VERSION_1: Device compliant for v1 spec (legacy)" +# ] +# }, +# "host-features": { +# "dev-features": [ +# "VHOST_USER_F_PROTOCOL_FEATURES: Vhost-user protocol features negotation supported", +# "VIRTIO_NET_F_GSO: Handling GSO-type packets supported", +# "VIRTIO_NET_F_CTRL_MAC_ADDR: MAC address set through control channel", +# "VIRTIO_NET_F_GUEST_ANNOUNCE: Driver sending gratuitous packets supported", +# "VIRTIO_NET_F_CTRL_RX_EXTRA: Extra RX mode control supported", +# "VIRTIO_NET_F_CTRL_VLAN: Control channel VLAN filtering supported", +# "VIRTIO_NET_F_CTRL_RX: Control channel RX mode supported", +# "VIRTIO_NET_F_CTRL_VQ: Control channel available", +# "VIRTIO_NET_F_STATUS: Configuration status field available", +# "VIRTIO_NET_F_MRG_RXBUF: Driver can merge receive buffers", +# "VIRTIO_NET_F_HOST_UFO: Device can receive UFO", +# "VIRTIO_NET_F_HOST_ECN: Device can receive TSO with ECN", +# "VIRTIO_NET_F_HOST_TSO6: Device can receive TSOv6", +# "VIRTIO_NET_F_HOST_TSO4: Device can receive TSOv4", +# "VIRTIO_NET_F_GUEST_UFO: Driver can receive UFO", +# "VIRTIO_NET_F_GUEST_ECN: Driver can receive TSO with ECN", +# "VIRTIO_NET_F_GUEST_TSO6: Driver can receive TSOv6", +# "VIRTIO_NET_F_GUEST_TSO4: Driver can receive TSOv4", +# "VIRTIO_NET_F_MAC: Device has given MAC address", +# "VIRTIO_NET_F_CTRL_GUEST_OFFLOADS: Control channel offloading reconfig. supported", +# "VIRTIO_NET_F_GUEST_CSUM: Driver handling packets with partial checksum supported", +# "VIRTIO_NET_F_CSUM: Device handling packets with partial checksum supported" +# ], +# "transports": [ +# "VIRTIO_RING_F_EVENT_IDX: Used & avail. event fields enabled", +# "VIRTIO_RING_F_INDIRECT_DESC: Indirect descriptors supported", +# "VIRTIO_F_VERSION_1: Device compliant for v1 spec (legacy)", +# "VIRTIO_F_ANY_LAYOUT: Device accepts arbitrary desc. layouts", +# "VIRTIO_F_NOTIFY_ON_EMPTY: Notify when device runs out of avail. descs. on VQ" +# ] +# }, # "use-guest-notifier-mask": true, # "vm-running": true, # "queue-sel": 2,
@@ -288,3 +440,62 @@ 'data': { 'path': 'str' }, 'returns': 'VirtioStatus', 'features': [ 'unstable' ] } + +## +# @VirtioDeviceStatus: +# +# A structure defined to list the configuration statuses of a virtio +# device +# +# @statuses: List of decoded configuration statuses of the virtio +# device +# +# @unknown-statuses: Virtio device statuses bitmap that have not been decoded +# +# Since: 7.1 +## + +{ 'struct': 'VirtioDeviceStatus', + 'data': { 'statuses': [ 'str' ], + '*unknown-statuses': 'uint8' } } + +## +# @VhostDeviceProtocols: +# +# A structure defined to list the vhost user protocol features of a +# Vhost User device +# +# @protocols: List of decoded vhost user protocol features of a vhost +# user device +# +# @unknown-protocols: Vhost user device protocol features bitmap that +# have not been decoded +# +# Since: 7.1 +## + +{ 'struct': 'VhostDeviceProtocols', + 'data': { 'protocols': [ 'str' ], + '*unknown-protocols': 'uint64' } } + +## +# @VirtioDeviceFeatures: +# +# The common fields that apply to most Virtio devices. Some devices +# may not have their own device-specific features (e.g. virtio-rng). +# +# @transports: List of transport features of the virtio device +# +# @dev-features: List of device-specific features (if the device has +# unique features) +# +# @unknown-dev-features: Virtio device features bitmap that have not +# been decoded +# +# Since: 7.1 +## + +{ 'struct': 'VirtioDeviceFeatures', + 'data': { 'transports': [ 'str' ], + '*dev-features': [ 'str' ], + '*unknown-dev-features': 'uint64' } }
include/hw/virtio/vhost.h +3 -0
@@ -5,6 +5,9 @@#include "hw/virtio/virtio.h" #include "exec/memory.h" +#define VHOST_F_DEVICE_IOTLB 63 +#define VHOST_USER_F_PROTOCOL_FEATURES 30 +/* Generic structures common for any vhost based device. */ struct vhost_inflight {
include/hw/virtio/virtio.h +5 -0
@@ -82,6 +82,11 @@ typedef struct VirtQueueElement#define TYPE_VIRTIO_DEVICE "virtio-device" OBJECT_DECLARE_TYPE(VirtIODevice, VirtioDeviceClass, VIRTIO_DEVICE) +typedef struct { +int virtio_bit; +const char *feature_desc; +}qmp_virtio_feature_map_t ; +enum virtio_device_endian {VIRTIO_DEVICE_ENDIAN_UNKNOWN ,VIRTIO_DEVICE_ENDIAN_LITTLE ,
hw/virtio/virtio.c +635 -8
677 lines not on this page · raw message
Signature · 1 line
MST
[PULL 35/55] hmp: add virtio commands
In reply to Michael S. TsirkinFrom: Laurent Vivier <[email protected]>
This patch implements the HMP versions of the virtio QMP commands.
[Jonah: Adjusted hmp monitor output format for features / statuses
with their descriptions.]
Message-Id: <[email protected]>
--- include/monitor/hmp.h | 5 + monitor/hmp-cmds.c | 310 ++++++++++++++++++++++++++++++++++++++++++ hmp-commands-info.hx | 70 ++++++++++ 3 files changed, 385 insertions(+)
include/monitor/hmp.h +5 -0
@@ -95,6 +95,11 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict);void hmp_qom_get (Monitor *mon,const QDict *qdict);void hmp_qom_set (Monitor *mon,const QDict *qdict);void hmp_info_qom_tree (Monitor *mon,const QDict *dict); +void hmp_virtio_query (Monitor *mon,const QDict *qdict); +void hmp_virtio_status (Monitor *mon,const QDict *qdict); +void hmp_virtio_queue_status (Monitor *mon,const QDict *qdict); +void hmp_vhost_queue_status (Monitor *mon,const QDict *qdict); +void hmp_virtio_queue_element (Monitor *mon,const QDict *qdict);void object_add_completion (ReadLineState *rs,int nb_args,const char *str);void object_del_completion (ReadLineState *rs,int nb_args,const char *str);void device_add_completion (ReadLineState *rs,int nb_args,const char *str);
monitor/hmp-cmds.c +310 -0
319 lines not on this page · raw message
hmp-commands-info.hx +70 -0
73 lines not on this page · raw message
Signature · 1 line
MST
[PULL 43/55] acpi: x86: refactor PDSM method to reduce nesting
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
.., it will help with code readability and make easier to extend method in followup patches
Message-Id: <[email protected]>
--- hw/i386/acpi-build.c | 139 ++++++++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 62 deletions(-)
hw/i386/acpi-build.c +77 -62
@@ -574,9 +574,12 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,Aml *aml_pci_device_dsm (void ) { -Aml *method, *UUID , *ifctx, *ifctx1, *ifctx2, *ifctx3, *elsectx; -Aml *acpi_index =aml_local (0 ); +Aml *method, *UUID , *ifctx, *ifctx1; +Aml *ret =aml_local (0 ); +Aml *caps =aml_local (1 ); +Aml *acpi_index =aml_local (2 );Aml *zero =aml_int (0 ); +Aml *one =aml_int (1 );Aml *bnum =aml_arg (4 );Aml *func =aml_arg (2 );Aml *rev =aml_arg (1 );
@@ -584,73 +587,85 @@ Aml *aml_pci_device_dsm(void) method =aml_method ("PDSM" ,6 ,AML_SERIALIZED ); -/* -* PCI Firmware Specification 3.1 -* 4.6. _DSM Definitions for PCI -*/ -UUID =aml_touuid ("E5C937D0-3553-4D7A-9117-EA4D19C3434D" ); - ifctx =aml_if (aml_equal (aml_arg (0 ),UUID )); +/* get supported functions */ + ifctx =aml_if (aml_equal (func, zero)); { -aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sunum), acpi_index)); - ifctx1 =aml_if (aml_equal (func, zero)); +uint8_t byte_list[1 ] = {0 };/* nothing supported yet */ +aml_append (ifctx,aml_store (aml_buffer (1 , byte_list), ret)); +aml_append (ifctx,aml_store (zero, caps)); + +/* +* PCI Firmware Specification 3.1 +* 4.6. _DSM Definitions for PCI +*/ +UUID =aml_touuid ("E5C937D0-3553-4D7A-9117-EA4D19C3434D" ); + ifctx1 =aml_if (aml_lnot (aml_equal (aml_arg (0 ),UUID ))); { -uint8_t byte_list[1 ]; +/* call is for unsupported UUID, bail out */ +aml_append (ifctx1,aml_return (ret)); + } +aml_append (ifctx, ifctx1); - ifctx2 =aml_if (aml_equal (rev,aml_int (2 ))); - { -/* -* advertise function 7 if device has acpi-index -* acpi_index values: -* 0: not present (default value) -* FFFFFFFF: not supported (old QEMU without PIDX reg) -* other: device's acpi-index -*/ - ifctx3 =aml_if (aml_lnot ( -aml_or (aml_equal (acpi_index, zero), -aml_equal (acpi_index,aml_int (0xFFFFFFFF )),NULL ) - )); - { - byte_list[0 ] = -1 /* have supported functions */ | -1 <<7 /* support for function 7 */ - ; -aml_append (ifctx3,aml_return (aml_buffer (1 , byte_list))); - } -aml_append (ifctx2, ifctx3); - } -aml_append (ifctx1, ifctx2); + ifctx1 =aml_if (aml_lless (rev,aml_int (2 ))); + { +/* call is for unsupported REV, bail out */ +aml_append (ifctx1,aml_return (ret)); + } +aml_append (ifctx, ifctx1); - byte_list[0 ] =0 ;/* nothing supported */ -aml_append (ifctx1,aml_return (aml_buffer (1 , byte_list))); - } -aml_append (ifctx, ifctx1); - elsectx =aml_else (); -/* -* PCI Firmware Specification 3.1 -* 4.6.7. _DSM for Naming a PCI or PCI Express Device Under -* Operating Systems -*/ - ifctx1 =aml_if (aml_equal (func,aml_int (7 ))); - { -Aml *pkg =aml_package (2 ); -Aml *ret =aml_local (1 ); +aml_append (ifctx, +aml_store (aml_call2 ("AIDX" , bnum, sunum), acpi_index)); +/* +* advertise function 7 if device has acpi-index +* acpi_index values: +* 0: not present (default value) +* FFFFFFFF: not supported (old QEMU without PIDX reg) +* other: device's acpi-index +*/ + ifctx1 =aml_if (aml_lnot ( +aml_or (aml_equal (acpi_index, zero), +aml_equal (acpi_index,aml_int (0xFFFFFFFF )),NULL ) + )); + { +/* have supported functions */ +aml_append (ifctx1,aml_or (caps, one, caps)); +/* support for function 7 */ +aml_append (ifctx1, +aml_or (caps,aml_shiftleft (one,aml_int (7 )), caps)); + } +aml_append (ifctx, ifctx1); -aml_append (pkg, zero); -/* -* optional, if not impl. should return null string -*/ -aml_append (pkg,aml_string ("%s" ,"" )); -aml_append (ifctx1,aml_store (pkg, ret)); -/* -* update acpi-index to actual value -*/ -aml_append (ifctx1,aml_store (acpi_index,aml_index (ret, zero))); -aml_append (ifctx1,aml_return (ret)); - } -aml_append (elsectx, ifctx1); -aml_append (ifctx, elsectx); +aml_append (ifctx,aml_store (caps,aml_index (ret, zero))); +aml_append (ifctx,aml_return (ret)); }aml_append (method, ifctx); + +/* handle specific functions requests */ +/* +* PCI Firmware Specification 3.1 +* 4.6.7. _DSM for Naming a PCI or PCI Express Device Under +* Operating Systems +*/ + ifctx =aml_if (aml_equal (func,aml_int (7 ))); + { +Aml *pkg =aml_package (2 ); + +aml_append (pkg, zero); +/* +* optional, if not impl. should return null string +*/ +aml_append (pkg,aml_string ("%s" ,"" )); +aml_append (ifctx,aml_store (pkg, ret)); + +aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sunum), acpi_index)); +/* +* update acpi-index to actual value +*/ +aml_append (ifctx,aml_store (acpi_index,aml_index (ret, zero))); + } + +aml_append (method, ifctx); +aml_append (method,aml_return (ret));return method; }
Signature · 1 line
MST
[PULL 38/55] hw/smbios: support for type 8 (port connector)
In reply to Michael S. TsirkinFrom: Hal Martin <[email protected]>
PATCH v1: add support for SMBIOS type 8 to qemu
PATCH v2: incorporate patch v1 feedback and add smbios type=8 to qemu-options
internal_reference: internal reference designatorexternal_reference: external reference designatorconnector_type: hex value for port connector type (see SMBIOS 7.9.2)port_type: hex value for port type (see SMBIOS 7.9.3)
After studying various vendor implementationsi (Dell, Lenovo, MSI), the value of internal connector type was hard-coded to 0x0 (None).
Example usage:
-smbios type=8,internal_reference=JUSB1,external_reference=USB1,connector_type=0x12,port_type=0x10 \
-smbios type=8,internal_reference=JAUD1,external_reference="Audio Jack",connector_type=0x1f,port_type=0x1d \
-smbios type=8,internal_reference=LAN,external_reference=Ethernet,connector_type=0x0b,port_type=0x1f \
-smbios type=8,internal_reference=PS2,external_reference=Mouse,connector_type=0x0f,port_type=0x0e \
-smbios type=8,internal_reference=PS2,external_reference=Keyboard,connector_type=0x0f,port_type=0x0d
Message-Id: <[email protected]>
--- include/hw/firmware/smbios.h | 10 ++++++ hw/smbios/smbios.c | 63 ++++++++++++++++++++++++++++++++++++ qemu-options.hx | 2 ++ 3 files changed, 75 insertions(+)
include/hw/firmware/smbios.h +10 -0
@@ -189,6 +189,16 @@ struct smbios_type_4 {uint16_t processor_family2; }QEMU_PACKED ; +/* SMBIOS type 8 - Port Connector Information */ +struct smbios_type_8 { +struct smbios_structure_header header; +uint8_t internal_reference_str; +uint8_t internal_connector_type; +uint8_t external_reference_str; +uint8_t external_connector_type; +uint8_t port_type; +}QEMU_PACKED ; +/* SMBIOS type 11 - OEM strings */ struct smbios_type_11 {struct smbios_structure_header header;
hw/smbios/smbios.c +63 -0
93 lines not on this page · raw message
qemu-options.hx +2 -0
@@ -2572,6 +2572,8 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, " [,asset=str][,part=str][,max-speed=%d][,current-speed=%d]\n" " [,processor-id=%d]\n" " specify SMBIOS type 4 fields\n" + "-smbios type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d]\n" + " specify SMBIOS type 8 fields\n" "-smbios type=11[,value=str][,path=filename]\n" " specify SMBIOS type 11 fields\n" "-smbios type=17[,loc_pfx=str][,bank=str][,manufacturer=str][,serial=str]\n"
Signature · 1 line
MST
[PULL 48/55] tests: acpi: update expected blobs
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
It's expected that hotpluggable slots will, get ASUN variable and use that instead of _SUN with its _DSM method.
For example:
@@ -979,8 +979,9 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)
Device (S18)
{
- Name (_SUN, 0x03) // _SUN: Slot User Number
+ Name (ASUN, 0x03)
Name (_ADR, 0x00030000) // _ADR: Address
+ Name (_SUN, 0x03) // _SUN: Slot User Number
Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device
{
PCEJ (BSEL, _SUN)
@@ -991,7 +992,7 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)
Local0 = Package (0x02)
{
BSEL,
- _SUN
+ ASUN
}
Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
}Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 14 -------------- tests/data/acpi/pc/DSDT | Bin 6219 -> 6422 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 6186 -> 6382 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7544 -> 7747 bytes tests/data/acpi/pc/DSDT.bridge | Bin 9078 -> 9496 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6683 -> 6886 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 7873 -> 8076 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6186 -> 6382 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6291 -> 6494 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7578 -> 7781 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 6077 -> 6280 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6225 -> 6428 bytes tests/data/acpi/pc/DSDT.roothp | Bin 6434 -> 6656 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11227 -> 11449 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 8628 -> 8640 bytes 15 files changed, 14 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -14
@@ -1,15 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT" , -"tests/data/acpi/pc/DSDT.acpierst" , -"tests/data/acpi/pc/DSDT.acpihmat" , -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.cphp" , -"tests/data/acpi/pc/DSDT.dimmpxm" , -"tests/data/acpi/pc/DSDT.hpbridge" , -"tests/data/acpi/pc/DSDT.ipmikcs" , -"tests/data/acpi/pc/DSDT.memhp" , -"tests/data/acpi/pc/DSDT.nohpet" , -"tests/data/acpi/pc/DSDT.numamem" , -"tests/data/acpi/pc/DSDT.roothp" , -"tests/data/acpi/q35/DSDT.bridge" , -"tests/data/acpi/q35/DSDT.multi-bridge",
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
Signature · 1 line
MST
[PULL 37/55] pci: Sanity check mask argument to pci_set_*_by_mask()
In reply to Michael S. TsirkinFrom: Peter Maydell <[email protected]>
Coverity complains that in functions like pci_set_word_by_mask() we might end up shifting by more than 31 bits. This is true, but only if the caller passes in a zero mask. Help Coverity out by asserting that the mask argument is valid.
Message-Id: <[email protected]>
--- include/hw/pci/pci.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
include/hw/pci/pci.h +16 -4
@@ -688,7 +688,10 @@ static inline void pci_set_byte_by_mask(uint8_t *config, uint8_t mask, uint8_t reg) {uint8_t val =pci_get_byte (config); -uint8_t rval = reg <<ctz32 (mask); +uint8_t rval; + +assert (mask); + rval = reg <<ctz32 (mask);pci_set_byte (config, (~mask & val) | (mask & rval)); }
@@ -696,7 +699,10 @@ static inline void pci_set_word_by_mask(uint8_t *config, uint16_t mask, uint16_t reg) {uint16_t val =pci_get_word (config); -uint16_t rval = reg <<ctz32 (mask); +uint16_t rval; + +assert (mask); + rval = reg <<ctz32 (mask);pci_set_word (config, (~mask & val) | (mask & rval)); }
@@ -704,7 +710,10 @@ static inline void pci_set_long_by_mask(uint8_t *config, uint32_t mask, uint32_t reg) {uint32_t val =pci_get_long (config); -uint32_t rval = reg <<ctz32 (mask); +uint32_t rval; + +assert (mask); + rval = reg <<ctz32 (mask);pci_set_long (config, (~mask & val) | (mask & rval)); }
@@ -712,7 +721,10 @@ static inline void pci_set_quad_by_mask(uint8_t *config, uint64_t mask, uint64_t reg) {uint64_t val =pci_get_quad (config); -uint64_t rval = reg <<ctz32 (mask); +uint64_t rval; + +assert (mask); + rval = reg <<ctz32 (mask);pci_set_quad (config, (~mask & val) | (mask & rval)); }
Signature · 1 line
MST
[PULL 49/55] tests: acpi: whitelist pc/q35 DSDT before moving _ADR field
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +14 -0
@@ -1 +1,15 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.acpierst" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.nohpet" , +"tests/data/acpi/pc/DSDT.numamem" , +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/q35/DSDT.bridge" , +"tests/data/acpi/q35/DSDT.multi-bridge",
Signature · 1 line
MST
[PULL 39/55] tests: acpi: whitelist pc/q35 DSDT due to HPET AML move
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +32 -0
@@ -1 +1,33 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.acpierst" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/pc/DSDT.hpbrroot" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.numamem" , +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/q35/DSDT" , +"tests/data/acpi/q35/DSDT.acpierst" , +"tests/data/acpi/q35/DSDT.acpihmat" , +"tests/data/acpi/q35/DSDT.applesmc" , +"tests/data/acpi/q35/DSDT.bridge" , +"tests/data/acpi/q35/DSDT.cphp" , +"tests/data/acpi/q35/DSDT.cxl" , +"tests/data/acpi/q35/DSDT.dimmpxm" , +"tests/data/acpi/q35/DSDT.ipmibt" , +"tests/data/acpi/q35/DSDT.ipmismbus" , +"tests/data/acpi/q35/DSDT.ivrs" , +"tests/data/acpi/q35/DSDT.memhp" , +"tests/data/acpi/q35/DSDT.mmio64" , +"tests/data/acpi/q35/DSDT.multi-bridge" , +"tests/data/acpi/q35/DSDT.numamem" , +"tests/data/acpi/q35/DSDT.pvpanic-isa" , +"tests/data/acpi/q35/DSDT.tis.tpm12" , +"tests/data/acpi/q35/DSDT.tis.tpm2" , +"tests/data/acpi/q35/DSDT.viot" , +"tests/data/acpi/q35/DSDT.xapic",
Signature · 1 line
MST
[PULL 51/55] tests: acpi: update expected blobs
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Expected change:
- Name (_SUN, 0x0X) // _SUN: Slot User Number
Name (_ADR, 0xY) // _ADR: Address
...
+ Name (_SUN, 0xX) // _SUN: Slot User Number
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 14 -------------- tests/data/acpi/pc/DSDT | Bin 6422 -> 6422 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 6382 -> 6382 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7747 -> 7747 bytes tests/data/acpi/pc/DSDT.bridge | Bin 9496 -> 9496 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6886 -> 6886 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 8076 -> 8076 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6382 -> 6382 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6494 -> 6494 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7781 -> 7781 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 6280 -> 6280 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6428 -> 6428 bytes tests/data/acpi/pc/DSDT.roothp | Bin 6656 -> 6656 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11449 -> 11449 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 8640 -> 8640 bytes 15 files changed, 14 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -14
@@ -1,15 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT" , -"tests/data/acpi/pc/DSDT.acpierst" , -"tests/data/acpi/pc/DSDT.acpihmat" , -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.cphp" , -"tests/data/acpi/pc/DSDT.dimmpxm" , -"tests/data/acpi/pc/DSDT.hpbridge" , -"tests/data/acpi/pc/DSDT.ipmikcs" , -"tests/data/acpi/pc/DSDT.memhp" , -"tests/data/acpi/pc/DSDT.nohpet" , -"tests/data/acpi/pc/DSDT.numamem" , -"tests/data/acpi/pc/DSDT.roothp" , -"tests/data/acpi/q35/DSDT.bridge" , -"tests/data/acpi/q35/DSDT.multi-bridge",
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
Signature · 1 line
MST
[PULL 45/55] tests: acpi: update expected blobs
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
An intermediate blobs update to keep changes (last 2 patches) reviewable.
Includes refactored PDSM that uses Package argument for custom parameters.
===== PDSM taking package as arguments
Return (Local0)
}- Method (PDSM, 6, Serialized)
+ Method (PDSM, 5, Serialized)
{
- If ((Arg0 == ToUUID ("e5c937d0-3553-4d7a-9117-ea4d19c3434d") /* Device Labeling Interface */))
+ If ((Arg2 == Zero))
{
- Local0 = AIDX (Arg4, Arg5)
- If ((Arg2 == Zero))
- {
- If ((Arg1 == 0x02))
+ Local0 = Buffer (One)
{- If (!((Local0 == Zero) | (Local0 == 0xFFFFFFFF)))
- {
- Return (Buffer (One)
- {
- 0x81 // .
- })
- }
+ 0x00 // .
}
+ Local1 = Zero
+ If ((Arg0 != ToUUID ("e5c937d0-3553-4d7a-9117-ea4d19c3434d") /* Device Labeling Interface */))
+ {+ Return (Local0)
+ }
- Return (Buffer (One)
- {
- 0x00 // .
- })
+ If ((Arg1 < 0x02))
+ {
+ Return (Local0)
}
- ElseIf ((Arg2 == 0x07))
+
+ Local2 = AIDX (DerefOf (Arg4 [Zero]), DerefOf (Arg4 [One]
+ ))
+ If (!((Local2 == Zero) | (Local2 == 0xFFFFFFFF)))
{- Local1 = Package (0x02)
- {
- Zero,
- ""
- }
- Local1 [Zero] = Local0
- Return (Local1)
+ Local1 |= One
+ Local1 |= (One << 0x07)
}+
+ Local0 [Zero] = Local1
+ Return (Local0)
+ }
+
+ If ((Arg2 == 0x07))
+ {
+ Local0 = Package (0x02)
+ {
+ Zero,
+ ""
+ }
+ Local2 = AIDX (DerefOf (Arg4 [Zero]), DerefOf (Arg4 [One]
+ ))
+ Local0 [Zero] = Local2
+ Return (Local0)
}
}
} ===== PCI slot using Package to pass arguments to _DSM
Name (ASUN, Zero)
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method {
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, ASUN))
+ Local0 = Package (0x02)
+ {
+ BSEL,
+ ASUN
+ }
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
}
} ===== hotpluggable PCI slot using Package to pass arguments to _DSM
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method {
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ Local0 = Package (0x02)
+ {
+ BSEL,
+ _SUN
+ }
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
}
}Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 34 -------------------- tests/data/acpi/pc/DSDT | Bin 5987 -> 6219 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 5954 -> 6186 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7312 -> 7544 bytes tests/data/acpi/pc/DSDT.bridge | Bin 8653 -> 9078 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6451 -> 6683 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 7641 -> 7873 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5954 -> 6186 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6059 -> 6291 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7346 -> 7578 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 5845 -> 6077 bytes tests/data/acpi/pc/DSDT.numamem | Bin 5993 -> 6225 bytes tests/data/acpi/pc/DSDT.roothp | Bin 6195 -> 6434 bytes tests/data/acpi/q35/DSDT | Bin 8274 -> 8320 bytes tests/data/acpi/q35/DSDT.acpierst | Bin 8291 -> 8337 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9599 -> 9645 bytes tests/data/acpi/q35/DSDT.applesmc | Bin 8320 -> 8366 bytes tests/data/acpi/q35/DSDT.bridge | Bin 10988 -> 11227 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8738 -> 8784 bytes tests/data/acpi/q35/DSDT.cxl | Bin 9600 -> 9646 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9928 -> 9974 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 8349 -> 8395 bytes tests/data/acpi/q35/DSDT.ipmismbus | Bin 8363 -> 8409 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 8291 -> 8337 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9633 -> 9679 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9404 -> 9450 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 8568 -> 8628 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 8132 -> 8178 bytes tests/data/acpi/q35/DSDT.numamem | Bin 8280 -> 8326 bytes tests/data/acpi/q35/DSDT.pvpanic-isa | Bin 8375 -> 8421 bytes tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8880 -> 8926 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8906 -> 8952 bytes tests/data/acpi/q35/DSDT.viot | Bin 9383 -> 9429 bytes tests/data/acpi/q35/DSDT.xapic | Bin 35637 -> 35683 bytes 34 files changed, 34 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -34
@@ -1,35 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT" , -"tests/data/acpi/pc/DSDT.acpierst" , -"tests/data/acpi/pc/DSDT.acpihmat" , -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.cphp" , -"tests/data/acpi/pc/DSDT.dimmpxm" , -"tests/data/acpi/pc/DSDT.hpbridge" , -"tests/data/acpi/pc/DSDT.hpbrroot" , -"tests/data/acpi/pc/DSDT.ipmikcs" , -"tests/data/acpi/pc/DSDT.memhp" , -"tests/data/acpi/pc/DSDT.numamem" , -"tests/data/acpi/pc/DSDT.roothp" , -"tests/data/acpi/q35/DSDT" , -"tests/data/acpi/q35/DSDT.acpierst" , -"tests/data/acpi/q35/DSDT.acpihmat" , -"tests/data/acpi/q35/DSDT.applesmc" , -"tests/data/acpi/q35/DSDT.bridge" , -"tests/data/acpi/q35/DSDT.cphp" , -"tests/data/acpi/q35/DSDT.cxl" , -"tests/data/acpi/q35/DSDT.dimmpxm" , -"tests/data/acpi/q35/DSDT.ipmibt" , -"tests/data/acpi/q35/DSDT.ipmismbus" , -"tests/data/acpi/q35/DSDT.ivrs" , -"tests/data/acpi/q35/DSDT.memhp" , -"tests/data/acpi/q35/DSDT.mmio64" , -"tests/data/acpi/q35/DSDT.multi-bridge" , -"tests/data/acpi/q35/DSDT.numamem" , -"tests/data/acpi/q35/DSDT.pvpanic-isa" , -"tests/data/acpi/q35/DSDT.tis.tpm12" , -"tests/data/acpi/q35/DSDT.tis.tpm2" , -"tests/data/acpi/q35/DSDT.viot" , -"tests/data/acpi/q35/DSDT.xapic" , -"tests/data/acpi/q35/DSDT.nohpet" , -"tests/data/acpi/pc/DSDT.nohpet",
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT binary +0 -0
tests/data/acpi/q35/DSDT.acpierst binary +0 -0
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
tests/data/acpi/q35/DSDT.applesmc binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.cphp binary +0 -0
tests/data/acpi/q35/DSDT.cxl binary +0 -0
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
tests/data/acpi/q35/DSDT.ipmismbus binary +0 -0
tests/data/acpi/q35/DSDT.ivrs binary +0 -0
tests/data/acpi/q35/DSDT.memhp binary +0 -0
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
tests/data/acpi/q35/DSDT.nohpet binary +0 -0
tests/data/acpi/q35/DSDT.numamem binary +0 -0
tests/data/acpi/q35/DSDT.pvpanic-isa binary +0 -0
tests/data/acpi/q35/DSDT.tis.tpm12 binary +0 -0
tests/data/acpi/q35/DSDT.tis.tpm2 binary +0 -0
tests/data/acpi/q35/DSDT.viot binary +0 -0
tests/data/acpi/q35/DSDT.xapic binary +0 -0
Signature · 1 line
MST
[PULL 40/55] acpi: x86: deduplicate HPET AML building
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
HPET AML doesn't depend on piix4 nor q35, move code buiding it to common scope to avoid duplication.
Message-Id: <[email protected]>
--- hw/i386/acpi-build.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
hw/i386/acpi-build.c +4 -6
@@ -1467,9 +1467,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (sb_scope, dev);aml_append (dsdt, sb_scope); -if (misc->has_hpet) { -build_hpet_aml (dsdt); - }build_piix4_isa_bridge (dsdt);if (pm->pcihp_bridge_en || pm->pcihp_root_en) {build_x86_acpi_pci_hotplug (dsdt, pm->pcihp_io_base);
@@ -1515,9 +1512,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dsdt, sb_scope); -if (misc->has_hpet) { -build_hpet_aml (dsdt); - }build_q35_isa_bridge (dsdt);if (pm->pcihp_bridge_en) {build_x86_acpi_pci_hotplug (dsdt, pm->pcihp_io_base);
@@ -1528,6 +1522,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, } } +if (misc->has_hpet) { +build_hpet_aml (dsdt); + } +if (vmbus_bridge) { sb_scope =aml_scope ("_SB" );aml_append (sb_scope,build_vmbus_device_aml (vmbus_bridge));
Signature · 1 line
MST
[PULL 50/55] x86: pci: acpi: reorder Device's _ADR and _SUN fields
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
no functional change, align order of fields in empty slot descriptor with a populated slot ordering. Expected diff:
- Name (_SUN, 0x0X) // _SUN: Slot User Number
Name (_ADR, 0xY) // _ADR: Address
...
+ Name (_SUN, 0xX) // _SUN: Slot User Number
that will eliminate contextual changes (causing test failures) when follow up patches merge code generating populated and empty slots descriptors.
Put mandatory _ADR as the 1st field, then ASUN as it can be present for both pupulated and empty slots and only then _SUN which is present only when slot is hotpluggable.
Message-Id: <[email protected]>
--- hw/i386/acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/acpi-build.c +1 -1
@@ -442,8 +442,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,break ; } dev =aml_device ("S%.02X" , devfn); -aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot)));aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); +aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot)));aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); aml_append(method,
Signature · 1 line
MST
[PULL 42/55] tests: acpi: whitelist pc/q35 DSDT due to HPET AML move
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +34 -0
@@ -1 +1,35 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.acpierst" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/pc/DSDT.hpbrroot" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.numamem" , +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/q35/DSDT" , +"tests/data/acpi/q35/DSDT.acpierst" , +"tests/data/acpi/q35/DSDT.acpihmat" , +"tests/data/acpi/q35/DSDT.applesmc" , +"tests/data/acpi/q35/DSDT.bridge" , +"tests/data/acpi/q35/DSDT.cphp" , +"tests/data/acpi/q35/DSDT.cxl" , +"tests/data/acpi/q35/DSDT.dimmpxm" , +"tests/data/acpi/q35/DSDT.ipmibt" , +"tests/data/acpi/q35/DSDT.ipmismbus" , +"tests/data/acpi/q35/DSDT.ivrs" , +"tests/data/acpi/q35/DSDT.memhp" , +"tests/data/acpi/q35/DSDT.mmio64" , +"tests/data/acpi/q35/DSDT.multi-bridge" , +"tests/data/acpi/q35/DSDT.numamem" , +"tests/data/acpi/q35/DSDT.pvpanic-isa" , +"tests/data/acpi/q35/DSDT.tis.tpm12" , +"tests/data/acpi/q35/DSDT.tis.tpm2" , +"tests/data/acpi/q35/DSDT.viot" , +"tests/data/acpi/q35/DSDT.xapic" , +"tests/data/acpi/q35/DSDT.nohpet" , +"tests/data/acpi/pc/DSDT.nohpet",
Signature · 1 line
MST
[PULL 47/55] x86: acpi: cleanup PCI device _DSM duplication
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
add ASUN variable to hotpluggable slots and use it instead of _SUN which has the same value to reuse _DMS code on both branches (hot- and non-hotpluggable). No functional change.
Message-Id: <[email protected]>
--- hw/i386/acpi-build.c | 56 +++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 29 deletions(-)
hw/i386/acpi-build.c +27 -29
@@ -374,6 +374,25 @@ build_facs(GArray *table_data)g_array_append_vals (table_data, reserved,40 );/* Reserved */ } +Aml *aml_pci_device_dsm (void ) +{ +Aml *method; + + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); + { +Aml *params =aml_local (0 ); +Aml *pkg =aml_package (2 ); +aml_append (pkg,aml_name ("BSEL" )); +aml_append (pkg,aml_name ("ASUN" )); +aml_append (method,aml_store (pkg, params)); +aml_append (method, +aml_return (aml_call5 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), params)) + ); + } +return method; +} +static void build_append_pcihp_notify_entry (Aml *method,int slot) {Aml *if_ctx;
@@ -423,26 +442,17 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,break ; } dev =aml_device ("S%.02X" , devfn); -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); +aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot)));aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method,aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) );aml_append (dev, method); - method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); - { -Aml *params =aml_local (0 ); -Aml *pkg =aml_package (2 ); -aml_append (pkg,aml_name ("BSEL" )); -aml_append (pkg,aml_name ("_SUN" )); -aml_append (method,aml_store (pkg, params)); -aml_append (method, -aml_return (aml_call5 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), -aml_arg (2 ),aml_arg (3 ), params)) - ); - } -aml_append (dev, method); + +aml_append (dev,aml_pci_device_dsm ()); +aml_append (parent_scope, dev);build_append_pcihp_notify_entry (notify_method, slot);
@@ -485,19 +495,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,* enumeration order in linux kernel, so use another variable for it */ aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); - method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); - { -Aml *params =aml_local (0 ); -Aml *pkg =aml_package (2 ); -aml_append (pkg,aml_name ("BSEL" )); -aml_append (pkg,aml_name ("ASUN" )); -aml_append (method,aml_store (pkg, params)); -aml_append (method,aml_return ( -aml_call5 ("PDSM" ,aml_arg (0 ),aml_arg (1 ),aml_arg (2 ), -aml_arg (3 ), params) - )); - } -aml_append (dev, method); +aml_append (dev,aml_pci_device_dsm ()); }if (pc->class_id ==PCI_CLASS_DISPLAY_VGA ) {
@@ -585,7 +583,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,qobject_unref (bsel); } -Aml *aml_pci_device_dsm (void ) +static Aml *aml_pci_pdsm (void ) {Aml *method, *UUID , *ifctx, *ifctx1;Aml *ret =aml_local (0 );
@@ -1368,7 +1366,7 @@ static void build_x86_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr)aml_append (method,aml_return (aml_local (0 )));aml_append (scope, method); -aml_append (scope,aml_pci_device_dsm ()); +aml_append (scope,aml_pci_pdsm ());aml_append (table, scope); }
Signature · 1 line
MST
[PULL 55/55] x86: pci: acpi: consolidate PCI slots creation
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
No functional changes nor AML bytecode changes. Consolidate code that generates empty and populated slot descriptors. Besides eliminating duplication, it helps consolidate conditions for generating parts of Device{} desriptor in one place, which makes code more compact and easier to read.
Message-Id: <[email protected]>
--- hw/i386/acpi-build.c | 111 +++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 57 deletions(-)
hw/i386/acpi-build.c +54 -57
@@ -427,13 +427,41 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,int func =PCI_FUNC (devfn);/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ int adr = slot <<16 | func; -bool hotplug_enabled_dev; -bool bridge_in_acpi; -bool cold_plugged_bridge; +bool hotpluggbale_slot = false; +bool bridge_in_acpi = false; +bool cold_plugged_bridge = false; +bool is_vga = false; + +if (pdev) { + pc =PCI_DEVICE_GET_CLASS (pdev); + dc =DEVICE_GET_CLASS (pdev); + +if (pc->class_id ==PCI_CLASS_BRIDGE_ISA ) { +continue ; + } + + is_vga = pc->class_id ==PCI_CLASS_DISPLAY_VGA ; -if (!pdev) {/* -* add hotplug slots for non present devices. +* Cold plugged bridges aren't themselves hot-pluggable. +* Hotplugged bridges *are* hot-pluggable. +*/ + cold_plugged_bridge = pc->is_bridge && !DEVICE (pdev)->hotplugged; + bridge_in_acpi = cold_plugged_bridge && pcihp_bridge_en; + + hotpluggbale_slot = bsel && dc->hotpluggable && + !cold_plugged_bridge; + +/* +* allow describing coldplugged bridges in ACPI even if they are not +* on function 0, as they are not unpluggable, for all other devices +* generate description only for function 0 per slot +*/ +if (func && !bridge_in_acpi) { +continue ; + } + }else { +/* * hotplug is supported only for non-multifunction device * so generate device description only for function 0 */
@@ -441,46 +469,11 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,if (pci_bus_is_express (bus) && slot >0 ) {break ; } - dev =aml_device ("S%.02X" , devfn); -aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); -aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); -aml_append (dev,aml_pci_device_dsm ()); -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) - ); -aml_append (dev, method); -aml_append (parent_scope, dev); - -build_append_pcihp_notify_entry (notify_method, slot); +/* mark it as empty hotpluggable slot */ + hotpluggbale_slot = true; + }else { +continue ; } -continue ; - } - - pc =PCI_DEVICE_GET_CLASS (pdev); - dc =DEVICE_GET_CLASS (pdev); - -/* -* Cold plugged bridges aren't themselves hot-pluggable. -* Hotplugged bridges *are* hot-pluggable. -*/ - cold_plugged_bridge = pc->is_bridge && !DEVICE (pdev)->hotplugged; - bridge_in_acpi = cold_plugged_bridge && pcihp_bridge_en; - - hotplug_enabled_dev = bsel && dc->hotpluggable && !cold_plugged_bridge; - -if (pc->class_id ==PCI_CLASS_BRIDGE_ISA ) { -continue ; - } - -/* -* allow describing coldplugged bridges in ACPI even if they are not -* on function 0, as they are not unpluggable, for all other devices -* generate description only for function 0 per slot -*/ -if (func && !bridge_in_acpi) { -continue ; }/* start to compose PCI device descriptor */
@@ -496,7 +489,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (dev,aml_pci_device_dsm ()); } -if (pc->class_id ==PCI_CLASS_DISPLAY_VGA ) { +if (is_vga) {/* add VGA specific AML methods */ int s3d;
@@ -517,19 +510,10 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, method =aml_method ("_S3D" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); - }else if (hotplug_enabled_dev) { -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); -/* add _EJ0 to make slot hotpluggable */ - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) - ); -aml_append (dev, method); + } -if (bsel) { -build_append_pcihp_notify_entry (notify_method, slot); - } - }else if (bridge_in_acpi) { + bridge_in_acpi = cold_plugged_bridge && pcihp_bridge_en; +if (bridge_in_acpi) {/* * device is coldplugged bridge, * add child device descriptions into its scope
@@ -538,6 +522,19 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,build_append_pci_bus_devices (dev, sec_bus, pcihp_bridge_en); } + +if (hotpluggbale_slot) { +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); +/* add _EJ0 to make slot hotpluggable */ + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) + ); +aml_append (dev, method); + +build_append_pcihp_notify_entry (notify_method, slot); + } +/* device descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev); }
Signature · 1 line
MST
[PULL 44/55] x86: acpi: _DSM: use Package to pass parameters
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Numer of possible arguments to pass to a method is limited in ACPI. The following patches will need to pass over more parameters to PDSM method, will hit that limit.
Prepare for this by passing structure (Package) to method, which let us workaround arguments limitation. Pass to PDSM all standard arguments of _DSM as is, and pack custom parameters into Package that is passed as the last argument to PDSM.
Message-Id: <[email protected]>
--- hw/i386/acpi-build.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-)
hw/i386/acpi-build.c +27 -13
@@ -431,11 +431,17 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, );aml_append (dev, method); method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); -aml_append (method, -aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), -aml_arg (2 ),aml_arg (3 ), -aml_name ("BSEL" ),aml_name ("_SUN" ))) - ); + { +Aml *params =aml_local (0 ); +Aml *pkg =aml_package (2 ); +aml_append (pkg,aml_name ("BSEL" )); +aml_append (pkg,aml_name ("_SUN" )); +aml_append (method,aml_store (pkg, params)); +aml_append (method, +aml_return (aml_call5 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), params)) + ); + }aml_append (dev, method);aml_append (parent_scope, dev);
@@ -480,10 +486,17 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,*/ aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); -aml_append (method,aml_return ( -aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ),aml_arg (2 ), -aml_arg (3 ),aml_name ("BSEL" ),aml_name ("ASUN" )) - )); + { +Aml *params =aml_local (0 ); +Aml *pkg =aml_package (2 ); +aml_append (pkg,aml_name ("BSEL" )); +aml_append (pkg,aml_name ("ASUN" )); +aml_append (method,aml_store (pkg, params)); +aml_append (method,aml_return ( +aml_call5 ("PDSM" ,aml_arg (0 ),aml_arg (1 ),aml_arg (2 ), +aml_arg (3 ), params) + )); + }aml_append (dev, method); }
@@ -580,12 +593,13 @@ Aml *aml_pci_device_dsm(void)Aml *acpi_index =aml_local (2 );Aml *zero =aml_int (0 );Aml *one =aml_int (1 ); -Aml *bnum =aml_arg (4 );Aml *func =aml_arg (2 );Aml *rev =aml_arg (1 ); -Aml *sunum =aml_arg (5 ); +Aml *params =aml_arg (4 ); +Aml *bnum =aml_derefof (aml_index (params,aml_int (0 ))); +Aml *sunum =aml_derefof (aml_index (params,aml_int (1 ))); - method =aml_method ("PDSM" ,6 ,AML_SERIALIZED ); + method =aml_method ("PDSM" ,5 ,AML_SERIALIZED );/* get supported functions */ ifctx =aml_if (aml_equal (func, zero));
@@ -662,10 +676,10 @@ Aml *aml_pci_device_dsm(void)* update acpi-index to actual value */ aml_append (ifctx,aml_store (acpi_index,aml_index (ret, zero))); +aml_append (ifctx,aml_return (ret)); }aml_append (method, ifctx); -aml_append (method,aml_return (ret));return method; }
Signature · 1 line
MST
[PULL 54/55] tests: acpi: update expected blobs
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Expected change:
+ Device (SE8)
+ {
+ Name (_ADR, 0x001D0000) // _ADR: Address
+ Name (ASUN, 0x1D)
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method {
Local0 = Package (0x02)
{
BSEL,
ASUN
}
Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
}
- }
- Device (SE8)
- {
- Name (_ADR, 0x001D0000) // _ADR: Address
- Name (ASUN, 0x1D)
Name (_SUN, 0x1D) // _SUN: Slot User Number Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device {
PCEJ (BSEL, _SUN)
}
+ }
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 14 -------------- tests/data/acpi/pc/DSDT | Bin 6422 -> 6422 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 6382 -> 6382 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7747 -> 7747 bytes tests/data/acpi/pc/DSDT.bridge | Bin 9496 -> 9496 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6886 -> 6886 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 8076 -> 8076 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6382 -> 6382 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6494 -> 6494 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7781 -> 7781 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 6280 -> 6280 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6428 -> 6428 bytes tests/data/acpi/pc/DSDT.roothp | Bin 6656 -> 6656 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11449 -> 11449 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 8640 -> 8640 bytes 15 files changed, 14 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -14
@@ -1,15 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT" , -"tests/data/acpi/pc/DSDT.acpierst" , -"tests/data/acpi/pc/DSDT.acpihmat" , -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.cphp" , -"tests/data/acpi/pc/DSDT.dimmpxm" , -"tests/data/acpi/pc/DSDT.hpbridge" , -"tests/data/acpi/pc/DSDT.ipmikcs" , -"tests/data/acpi/pc/DSDT.memhp" , -"tests/data/acpi/pc/DSDT.nohpet" , -"tests/data/acpi/pc/DSDT.numamem" , -"tests/data/acpi/pc/DSDT.roothp" , -"tests/data/acpi/q35/DSDT.bridge" , -"tests/data/acpi/q35/DSDT.multi-bridge",
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
Signature · 1 line
MST
[PULL 52/55] tests: acpi: whitelist pc/q35 DSDT before moving _ADR field
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +14 -0
@@ -1 +1,15 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.acpierst" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.nohpet" , +"tests/data/acpi/pc/DSDT.numamem" , +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/q35/DSDT.bridge" , +"tests/data/acpi/q35/DSDT.multi-bridge",
Signature · 1 line
MST
[PULL 46/55] tests: acpi: whitelist pc/q35 DSDT before switching _DSM to use ASUN
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test-allowed-diff.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +14 -0
@@ -1 +1,15 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.acpierst" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.nohpet" , +"tests/data/acpi/pc/DSDT.numamem" , +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/q35/DSDT.bridge" , +"tests/data/acpi/q35/DSDT.multi-bridge",
Signature · 1 line
MST
[PULL 53/55] x86: pci: acpi: reorder Device's _DSM method
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
align _DSM method in empty slot descriptor with
a populated slot position.
Expected change:
+ Device (SE8)
+ {
+ Name (_ADR, 0x001D0000) // _ADR: Address
+ Name (ASUN, 0x1D)
Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
{
Local0 = Package (0x02)
{
BSEL,
ASUN
}
Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
}- }
- Device (SE8)
- {
- Name (_ADR, 0x001D0000) // _ADR: Address
- Name (ASUN, 0x1D)
Name (_SUN, 0x1D) // _SUN: Slot User Number
Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device
{
PCEJ (BSEL, _SUN)
}+ }
i.e. put _DSM right after ASUN, with _SUN/_EJ0 following it.
that will eliminate contextual changes (causing test failures) when follow up patches merge code generating populated and empty slots descriptors.
Message-Id: <[email protected]>
--- hw/i386/acpi-build.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/i386/acpi-build.c +1 -3
@@ -444,15 +444,13 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, dev =aml_device ("S%.02X" , devfn);aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr)));aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); +aml_append (dev,aml_pci_device_dsm ());aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method,aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) );aml_append (dev, method); - -aml_append (dev,aml_pci_device_dsm ()); -aml_append (parent_scope, dev);build_append_pcihp_notify_entry (notify_method, slot);
Signature · 1 line
MST
Re: [PULL 29/55] Revert "intel_iommu: Fix irqchip / X2APIC configuration checks"
In reply to Michael S. TsirkinQuoted 10 lines · Michael S. Tsirkin
From: Peter Xu <
[email protected]Quoted 1 line
It's true that when vcpus<=255 we don't require the length of 32bit APIC IDs. However here since we already have EIM=ON it means the hypervisor will declare the VM as x2apic supported (e.g. VT-d ECAP register will have EIM bit 4 set), so the guest should assume the APIC IDs are 32bits width even if vcpus<=255. In short, commit
77250171bdcbreaks any simple cmdline that wants to boot a VM with >=9 but <=255 vcpus with:
I find that paragraph really hard to parse. What does it even mean that "guest should assume the APIC IDs are 32bits"?
In practice, all the EIM bit does is *allow* 32 bits of APIC ID in the tables. Which is perfectly fine if there are only 254 CPUs anyway, and we never need to use a higher value.
I *think* the actual problem here is when logical addressing is used, which puts the APIC cluster ID into higher bits? But it's kind of weird that the message doesn't mention that at all?
That's fixable by just setting the X2APIC_PHYSICAL bit in the ACPI FADT, isn't it? Then the only values that a guest may put into those fields — 32-bit fields or not — are lower than 0xff anyway.
Re: [PULL 29/55] Revert "intel_iommu: Fix irqchip / X2APIC configuration checks"
Quoted 12 lines · David Woodhouse
Quoted 10 lines · Michael S. Tsirkin
From: Peter Xu <
[email protected]Quoted 1 line
It's true that when vcpus<=255 we don't require the length of 32bit APIC IDs. However here since we already have EIM=ON it means the hypervisor will declare the VM as x2apic supported (e.g. VT-d ECAP register will have EIM bit 4 set), so the guest should assume the APIC IDs are 32bits width even if vcpus<=255. In short, commit
77250171bdcbreaks any simple cmdline that wants to boot a VM with >=9 but <=255 vcpus with:
Quoted 2 lines
I find that paragraph really hard to parse. What does it even mean that "guest should assume the APIC IDs are 32bits"?
Quotting EIM definition:
0: On Intel® 64 platforms, hardware supports only 8-bit APIC-IDs (xAPIC
Mode).
1: On Intel® 64 platforms, hardware supports 32-bit APIC- IDs (x2APIC
mode). Hardware implementation reporting Interrupt Remapping support (IR) field as Clear also report this field as Clear.
I hope the statement was matching the spec. Please let me know if you have better way to reword it.
Quoted 8 lines
In practice, all the EIM bit does is *allow* 32 bits of APIC ID in the tables. Which is perfectly fine if there are only 254 CPUs anyway, and we never need to use a higher value.
I *think* the actual problem here is when logical addressing is used, which puts the APIC cluster ID into higher bits? But it's kind of weird that the message doesn't mention that at all?
The commit message actually doesn't even need to contain a lot of information in this case, IMO.
Literally it can be seen as a revert of a commit which breaks guest with
Quoted 1 line
8vcpu from boot. I kept the other lines because that still make sense, or
it can be a full revert with "something broke with commit xxx, revert it to fix" and anything else could be reworked. AFAICT that's how it normally works with QEMU or Linux.
I am not 100% familiar with the original purpose of the patch, would eim=off work for you even after patch applied? Anything severely wrong with this patch?
Quoted 4 lines
That's fixable by just setting the
X2APIC_PHYSICALbit in the ACPI FADT, isn't it? Then the only values that a guest may put into those fields — 32-bit fields or not — are lower than0xffanyway.
It's still not clear to me why we need to make it inconsistent between the EIM we declare to the guest and the KVM behavior on understanding EIM bit. Even if enforced physical mode will work we loose the possibility of cluster mode, and I also don't see what's the major benefit since EIM=off will just work, afaiu, meanwhile make everything aligned.
Are you fine if we proceed with this pull request first and revisit later? Follow up patches will always be fine, and we're unbreaking something. I have copied you since the 1st patch I posted and the small patch was there for weeks, it'll be appreciated if either you could comment earlier next time, or even propose a better fix then we can discuss what's the best way to fix. Thanks.
Signature · 1 line
Peter Xu
Re: [PULL 29/55] Revert "intel_iommu: Fix irqchip / X2APIC configuration checks"
Quoted 19 lines · Peter Xu
Quoted 12 lines · David Woodhouse
Quoted 10 lines · Michael S. Tsirkin
From: Peter Xu <
[email protected]It's true that when vcpus<=255 we don't require the length of 32bit APIC IDs. However here since we already have EIM=ON it means the hypervisor will declare the VM as x2apic supported (e.g. VT-d ECAP register will have EIM bit 4 set), so the guest should assume the APIC IDs are 32bits width even if vcpus<=255. In short, commit
77250171bdcbreaks any simple cmdline that wants to boot a VM with >=9 but <=255 vcpus with:Quoted 2 lines
I find that paragraph really hard to parse. What does it even mean that "guest should assume the APIC IDs are 32bits"?
Quotting EIM definition:
0: On Intel® 64 platforms, hardware supports only 8-bit APIC-IDs (xAPIC
Quoted 8 lines
Mode).1: On Intel® 64 platforms, hardware supports 32-bit APIC- IDs (x2APIC
mode). Hardware implementation reporting Interrupt Remapping support (IR) field as Clear also report this field as Clear.I hope the statement was matching the spec. Please let me know if you have better way to reword it.
It needs to mention logical mode addressing. Because that, I presume, is why it broke only when you had more than 8 vCPUs. Because that's when the *logical* destination ID grew past 0xFF.
Quoted 10 lines
Quoted 7 lines
In practice, all the EIM bit does is *allow* 32 bits of APIC ID in the tables. Which is perfectly fine if there are only 254 CPUs anyway, and we never need to use a higher value.
I *think* the actual problem here is when logical addressing is used, which puts the APIC cluster ID into higher bits? But it's kind of weird that the message doesn't mention that at all?
The commit message actually doesn't even need to contain a lot of information in this case, IMO.
Well, it would be kind of useful if it said what the actual problem was, no?
Quoted 10 lines
Literally it can be seen as a revert of a commit which breaks guest with
Quoted 1 line
8vcpu from boot. I kept the other lines because that still make sense, or
it can be a full revert with "something broke with commit xxx, revert it to fix" and anything else could be reworked. AFAICT that's how it normally works with QEMU or Linux.
I am not 100% familiar with the original purpose of the patch, would eim=off work for you even after patch applied? Anything severely wrong with this patch?
I think the patch itself is fine; I'd just like the commit message to be clearer about what the problem was.
Quoted 9 lines
Quoted 3 lines
That's fixable by just setting the
X2APIC_PHYSICALbit in the ACPI FADT, isn't it? Then the only values that a guest may put into those fields — 32-bit fields or not — are lower than0xffanyway.It's still not clear to me why we need to make it inconsistent between the EIM we declare to the guest and the KVM behavior on understanding EIM bit. Even if enforced physical mode will work we loose the possibility of cluster mode, and I also don't see what's the major benefit since EIM=off will just work, afaiu, meanwhile make everything aligned.
Yeah, I think turning EIM off is absolutely fine.
Quoted 6 lines
Are you fine if we proceed with this pull request first and revisit later? Follow up patches will always be fine, and we're unbreaking something. I have copied you since the 1st patch I posted and the small patch was there for weeks, it'll be appreciated if either you could comment earlier next time, or even propose a better fix then we can discuss what's the best way to fix. Thanks.
Yeah, sorry for the delay. But that was partly because the commit message was confusing me and it took me a while to work out what was actually going on... which is really all I'm heckling now.
Re: [PULL 29/55] Revert "intel_iommu: Fix irqchip / X2APIC configuration checks"
Quoted 26 lines · David Woodhouse
Quoted 25 lines · Peter Xu
Quoted 12 lines · David Woodhouse
Quoted 10 lines · Michael S. Tsirkin
From: Peter Xu <
[email protected]It's true that when vcpus<=255 we don't require the length of 32bit APIC IDs. However here since we already have EIM=ON it means the hypervisor will declare the VM as x2apic supported (e.g. VT-d ECAP register will have EIM bit 4 set), so the guest should assume the APIC IDs are 32bits width even if vcpus<=255. In short, commit
77250171bdcbreaks any simple cmdline that wants to boot a VM with >=9 but <=255 vcpus with:Quoted 2 lines
I find that paragraph really hard to parse. What does it even mean that "guest should assume the APIC IDs are 32bits"?
Quotting EIM definition:
0: On Intel® 64 platforms, hardware supports only 8-bit APIC-IDs (xAPIC
Mode).1: On Intel® 64 platforms, hardware supports 32-bit APIC- IDs (x2APIC
mode). Hardware implementation reporting Interrupt Remapping support (IR) field as Clear also report this field as Clear.
Quoted 6 lines
Quoted 2 lines
I hope the statement was matching the spec. Please let me know if you have better way to reword it.
It needs to mention logical mode addressing. Because that, I presume, is why it broke only when you had more than 8 vCPUs. Because that's when the *logical* destination ID grew past
0xFF.
Agree.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
In practice, all the EIM bit does is *allow* 32 bits of APIC ID in the tables. Which is perfectly fine if there are only 254 CPUs anyway, and we never need to use a higher value.
I *think* the actual problem here is when logical addressing is used, which puts the APIC cluster ID into higher bits? But it's kind of weird that the message doesn't mention that at all?
Quoted 5 lines
Quoted 2 lines
The commit message actually doesn't even need to contain a lot of information in this case, IMO.
Well, it would be kind of useful if it said what the actual problem was, no?
Yes it'll be nice to have.
Quoted 8 lines
Quoted 8 lines
Literally it can be seen as a revert of a commit which breaks guest with
Quoted 1 line
8vcpu from boot. I kept the other lines because that still make sense, or
it can be a full revert with "something broke with commit xxx, revert it to fix" and anything else could be reworked. AFAICT that's how it normally works with QEMU or Linux.
Quoted 6 lines
Quoted 3 lines
I am not 100% familiar with the original purpose of the patch, would eim=off work for you even after patch applied? Anything severely wrong with this patch?
I think the patch itself is fine; I'd just like the commit message to be clearer about what the problem was.
Thanks for confirming.
Quoted 20 lines
Quoted 10 lines
Quoted 4 lines
That's fixable by just setting the
X2APIC_PHYSICALbit in the ACPI FADT, isn't it? Then the only values that a guest may put into those fields — 32-bit fields or not — are lower than0xffanyway.It's still not clear to me why we need to make it inconsistent between the EIM we declare to the guest and the KVM behavior on understanding EIM bit. Even if enforced physical mode will work we loose the possibility of cluster mode, and I also don't see what's the major benefit since EIM=off will just work, afaiu, meanwhile make everything aligned.
Yeah, I think turning EIM off is absolutely fine.
Quoted 6 lines
Are you fine if we proceed with this pull request first and revisit later? Follow up patches will always be fine, and we're unbreaking something. I have copied you since the 1st patch I posted and the small patch was there for weeks, it'll be appreciated if either you could comment earlier next time, or even propose a better fix then we can discuss what's the best way to fix. Thanks.
Quoted 3 lines
Yeah, sorry for the delay. But that was partly because the commit message was confusing me and it took me a while to work out what was actually going on... which is really all I'm heckling now.
I see, that was totally fine, and it'll be definitely also fine to comment anything even on the pull req. It's just that as I tried to argue for this specific case IMHO we should move on and revisit later so we shrink the regression window, rather than redo a pull and let this fix wait for another one. It seems we reached a consensus on this, thanks for that.
In all cases (irrelevant of the pull req), feel free to post any patch either based on this one or as replacement. I'll be happy to read and rethink. So far it still doesn't make sense to me to not enable kvm x2apic with eim=on, but maybe I'm wrong, and I'd be happy to be corrected in that case.
Thanks,
Signature · 1 line
Peter Xu
Quoted 8 lines · Michael S. Tsirkin
The following changes since commit
f1d33f55c47dfdaf8daacd618588ad3ae4c452d1:Merge tag 'pull-testing-gdbstub-plugins-gitdm-061022-3' of https://github.com/stsquad/qemu into staging (2022-10-06 07:11:56 -0400)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstream
Hi Michael,
Please update your .git/config with the https URL for future pull requests:
https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git
The pull request is signed with your GPG, so modifications should be detected when verifying the signature. It still seems like a good idea to use https:// when possible instead of unencrypted git://.
Stefan
Quoted 13 lines · Stefan Hajnoczi
Quoted 8 lines · Michael S. Tsirkin
The following changes since commit
f1d33f55c47dfdaf8daacd618588ad3ae4c452d1:Merge tag 'pull-testing-gdbstub-plugins-gitdm-061022-3' of https://github.com/stsquad/qemu into staging (2022-10-06 07:11:56 -0400)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamHi Michael,
Please update your .git/config with the https URL for future pull requests:
Quoted 7 lines
https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git
The pull request is signed with your GPG, so modifications should be detected when verifying the signature. It still seems like a good idea to use https:// when possible instead of unencrypted
git://.Stefan
I don't think this is from .git/config, this is just a parameter to request-pull. OK, I will switch to that.
Signature · 1 line
MST
Quoted 17 lines · Michael S. Tsirkin
Quoted 15 lines · Stefan Hajnoczi
Quoted 8 lines · Michael S. Tsirkin
The following changes since commit
f1d33f55c47dfdaf8daacd618588ad3ae4c452d1:Merge tag 'pull-testing-gdbstub-plugins-gitdm-061022-3' of https://github.com/stsquad/qemu into staging (2022-10-06 07:11:56 -0400)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamHi Michael,
Please update your .git/config with the https URL for future pull requests:
Quoted 8 lines
Quoted 5 lines
The pull request is signed with your GPG, so modifications should be detected when verifying the signature. It still seems like a good idea to use https:// when possible instead of unencrypted
git://.Stefan
I don't think this is from .git/config, this is just a parameter to request-pull. OK, I will switch to that.
You're right. For some reason I thought the URL was pulled from the remote's configuration in .git/config.
Stefan
Stefan Hajnoczi
AppliedApplied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/7.2 for any user-visible changes.
Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started)
In reply to Michael S. TsirkinAm 10.10.22 um 19:29 schrieb Michael S. Tsirkin:
Quoted 11 lines
From: Alex Bennée <[email protected]>
All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong.
Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>
This results in a regression for our s390x CI when doing save/restore of guests with vsock:
#1 0x000003ff9a248580 raise (libc.so.6 + 0x48580)
#2 0x000003ff9a22b5c0 abort (libc.so.6 + 0x2b5c0)
#3 0x000003ff9a2409da __assert_fail_base (libc.so.6 + 0x409da)
#4 0x000003ff9a240a4e __assert_fail (libc.so.6 + 0x40a4e)
#5 0x000002aa2d69a066 vhost_vsock_common_pre_save (qemu-system-s390x + 0x39a066)
#6 0x000002aa2d55570e vmstate_save_state_v (qemu-system-s390x + 0x25570e)
#7 0x000002aa2d556218 vmstate_save_state (qemu-system-s390x + 0x256218)
#8 0x000002aa2d570ba4 qemu_savevm_state_complete_precopy_non_iterable (qemu-system-s390x + 0x270ba4)
#9 0x000002aa2d5710b6 qemu_savevm_state_complete_precopy (qemu-system-s390x + 0x2710b6)
#10 0x000002aa2d564d0e migration_completion (qemu-system-s390x + 0x264d0e)
#11 0x000002aa2d8db25c qemu_thread_start (qemu-system-s390x + 0x5db25c)
#12 0x000003ff9a296248 start_thread (libc.so.6 + 0x96248)
#13 0x000003ff9a31183e thread_start (libc.so.6 + 0x11183e)Re: Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started)
Am 14.10.22 um 09:30 schrieb Christian Borntraeger:
Quoted 16 lines
Am 10.10.22 um 19:29 schrieb Michael S. Tsirkin:
Quoted 11 lines
From: Alex Bennée <[email protected]>
All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong.
Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>This results in a regression for our s390x CI when doing save/restore of guests with vsock:
Quoted 14 lines
#1
0x000003ff9a248580raise (libc.so.6 +0x48580)
#20x000003ff9a22b5c0abort (libc.so.6 +0x2b5c0)
#30x000003ff9a2409da__assert_fail_base(libc.so.6 +0x409da)
#40x000003ff9a240a4e__assert_fail(libc.so.6 +0x40a4e)
#50x000002aa2d69a066vhost_vsock_common_pre_save(qemu-system-s390x +0x39a066) #60x000002aa2d55570evmstate_save_state_v(qemu-system-s390x +0x25570e)
#70x000002aa2d556218vmstate_save_state(qemu-system-s390x +0x256218)
#80x000002aa2d570ba4qemu_savevm_state_complete_precopy_non_iterable(qemu-system-s390x +0x270ba4) #90x000002aa2d5710b6qemu_savevm_state_complete_precopy(qemu-system-s390x +0x2710b6) #100x000002aa2d564d0emigration_completion(qemu-system-s390x +0x264d0e)
#110x000002aa2d8db25cqemu_thread_start(qemu-system-s390x +0x5db25c)
#120x000003ff9a296248start_thread(libc.so.6 +0x96248)
#130x000003ff9a31183ethread_start(libc.so.6 +0x11183e)
Something like
hw/virtio/vhost-vsock.c +4 -0
@@ -73,6 +73,10 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status)bool should_start =virtio_device_started (vdev, status);int ret; +if (!vdev->vm_running) { + should_start = false; + } +if (vhost_dev_is_started (&vvc->vhost_dev) == should_start) {return ; }
helps.
The problem seems to be that virtio_device_started does ignore vm_running when use_start is set.
Re: Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started)
In reply to Christian BorntraegerQuoted 14 lines · Christian Borntraeger
Am 10.10.22 um 19:29 schrieb Michael S. Tsirkin:
Quoted 9 lines
From: Alex Bennée <[email protected]>
All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong.Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>This results in a regression for our s390x CI when doing save/restore of guests with vsock:
Quoted 15 lines
#1 0x000003ff9a248580 raise (libc.so.6 + 0x48580)
#2 0x000003ff9a22b5c0 abort (libc.so.6 + 0x2b5c0)
#3 0x000003ff9a2409da __assert_fail_base (libc.so.6 + 0x409da)
#4 0x000003ff9a240a4e __assert_fail (libc.so.6 + 0x40a4e)
#5 0x000002aa2d69a066 vhost_vsock_common_pre_save (qemu-system-s390x + 0x39a066)
#6 0x000002aa2d55570e vmstate_save_state_v (qemu-system-s390x + 0x25570e)
#7 0x000002aa2d556218 vmstate_save_state (qemu-system-s390x + 0x256218)
#8 0x000002aa2d570ba4
qemu_savevm_state_complete_precopy_non_iterable (qemu-system-s390x +
0x270ba4)
#9 0x000002aa2d5710b6 qemu_savevm_state_complete_precopy (qemu-system-s390x + 0x2710b6)
#10 0x000002aa2d564d0e migration_completion (qemu-system-s390x + 0x264d0e)
#11 0x000002aa2d8db25c qemu_thread_start (qemu-system-s390x + 0x5db25c)
#12 0x000003ff9a296248 start_thread (libc.so.6 + 0x96248)
#13 0x000003ff9a31183e thread_start (libc.so.6 + 0x11183e)Which test does this break?
Looking at the change the only thing I can think of is there is a subtle change in the order of checks because if the device is set as use_started we return the result regardless of vm or config state:
if (vdev->use_started) {
return vdev->started;
}Could some printfs confirm that?
Signature · 1 line
Alex Bennée
Re: Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started)
Am 14.10.22 um 10:37 schrieb Alex Bennée:
Quoted 33 lines
Quoted 14 lines · Christian Borntraeger
Am 10.10.22 um 19:29 schrieb Michael S. Tsirkin:
Quoted 9 lines
From: Alex Bennée <[email protected]>
All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong.Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>This results in a regression for our s390x CI when doing save/restore of guests with vsock:
Quoted 15 lines
#1 0x000003ff9a248580 raise (libc.so.6 + 0x48580) #2 0x000003ff9a22b5c0 abort (libc.so.6 + 0x2b5c0) #3 0x000003ff9a2409da __assert_fail_base (libc.so.6 + 0x409da) #4 0x000003ff9a240a4e __assert_fail (libc.so.6 + 0x40a4e) #5 0x000002aa2d69a066 vhost_vsock_common_pre_save (qemu-system-s390x + 0x39a066) #6 0x000002aa2d55570e vmstate_save_state_v (qemu-system-s390x + 0x25570e) #7 0x000002aa2d556218 vmstate_save_state (qemu-system-s390x + 0x256218) #8 0x000002aa2d570ba4 qemu_savevm_state_complete_precopy_non_iterable (qemu-system-s390x + 0x270ba4) #9 0x000002aa2d5710b6 qemu_savevm_state_complete_precopy (qemu-system-s390x + 0x2710b6) #10 0x000002aa2d564d0e migration_completion (qemu-system-s390x + 0x264d0e) #11 0x000002aa2d8db25c qemu_thread_start (qemu-system-s390x + 0x5db25c) #12 0x000003ff9a296248 start_thread (libc.so.6 + 0x96248) #13 0x000003ff9a31183e thread_start (libc.so.6 + 0x11183e)
Quoted 1 line
Which test does this break?
migrate to file and restore.
Quoted 10 lines
Looking at the change the only thing I can think of is there is a subtle change in the order of checks because if the device is set as
use_startedwe return the result regardless of vm or config state:if (vdev->use_started) { return vdev->started; }Could some printfs confirm that?
Right. The problem is we now ignore the vm state and thus run into the assertion in vhost_vsock_common_pre_save. Removing the asserting then results in virtio errors, which really indicates that the device must not be started.
Re: Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started)
In reply to Christian BorntraegerQuoted 49 lines · Christian Borntraeger
Am 14.10.22 um 09:30 schrieb Christian Borntraeger:
Quoted 21 lines
Am 10.10.22 um 19:29 schrieb Michael S. Tsirkin:
Quoted 11 lines
From: Alex Bennée <[email protected]>
All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong.
Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>This results in a regression for our s390x CI when doing
save/restore of guests with vsock:
#10x000003ff9a248580raise (libc.so.6 +0x48580)
#20x000003ff9a22b5c0abort (libc.so.6 +0x2b5c0)
#30x000003ff9a2409da__assert_fail_base(libc.so.6 +0x409da) #40x000003ff9a240a4e__assert_fail(libc.so.6 +0x40a4e)
#50x000002aa2d69a066vhost_vsock_common_pre_save(qemu-system-s390x +0x39a066) #60x000002aa2d55570evmstate_save_state_v(qemu-system-s390x +0x25570e) #70x000002aa2d556218vmstate_save_state(qemu-system-s390x +0x256218)Quoted 9 lines
#8
0x000002aa2d570ba4qemu_savevm_state_complete_precopy_non_iterable(qemu-system-s390x +0x270ba4)
#90x000002aa2d5710b6qemu_savevm_state_complete_precopy(qemu-system-s390x +0x2710b6) #100x000002aa2d564d0emigration_completion(qemu-system-s390x +0x264d0e) #110x000002aa2d8db25cqemu_thread_start(qemu-system-s390x +0x5db25c) #120x000003ff9a296248start_thread(libc.so.6 +0x96248)
#130x000003ff9a31183ethread_start(libc.so.6 +0x11183e)Something like
hw/virtio/vhost-vsock.c +3
-0@@ -73,6 +73,10 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status)bool should_start =virtio_device_started (vdev, status);int ret; + if (!vdev->vm_running) { + should_start = false; + } +if (vhost_dev_is_started (&vvc->vhost_dev) == should_start) {return ; }
Quoted 4 lines
helps.
The problem seems to be that
virtio_device_starteddoes ignorevm_runningwhenuse_startis set.
Wouldn't it make more sense to re-order the check there, something like:
static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status)
{
if (!vdev->vm_running) {
return false;
} if (vdev->use_started) {
return vdev->started;
}
return status & VIRTIO_CONFIG_S_DRIVER_OK;}
Is the problem that vdev->started gets filled during the migration but because the VM isn't running yet we can never actually run?
Signature · 1 line
Alex Bennée
Re: Regression save/restore of vsock: (was [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started)
Am 14.10.22 um 13:07 schrieb Alex Bennée:
Quoted 65 lines
Quoted 49 lines · Christian Borntraeger
Am 14.10.22 um 09:30 schrieb Christian Borntraeger:
Quoted 21 lines
Am 10.10.22 um 19:29 schrieb Michael S. Tsirkin:
Quoted 11 lines
From: Alex Bennée <[email protected]>
All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong.
Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>This results in a regression for our s390x CI when doing
save/restore of guests with vsock:
#10x000003ff9a248580raise (libc.so.6 +0x48580)
#20x000003ff9a22b5c0abort (libc.so.6 +0x2b5c0)
#30x000003ff9a2409da__assert_fail_base(libc.so.6 +0x409da) #40x000003ff9a240a4e__assert_fail(libc.so.6 +0x40a4e)
#50x000002aa2d69a066vhost_vsock_common_pre_save(qemu-system-s390x +0x39a066) #60x000002aa2d55570evmstate_save_state_v(qemu-system-s390x +0x25570e) #70x000002aa2d556218vmstate_save_state(qemu-system-s390x +0x256218)Quoted 9 lines
#8
0x000002aa2d570ba4qemu_savevm_state_complete_precopy_non_iterable(qemu-system-s390x +0x270ba4)
#90x000002aa2d5710b6qemu_savevm_state_complete_precopy(qemu-system-s390x +0x2710b6) #100x000002aa2d564d0emigration_completion(qemu-system-s390x +0x264d0e) #110x000002aa2d8db25cqemu_thread_start(qemu-system-s390x +0x5db25c) #120x000003ff9a296248start_thread(libc.so.6 +0x96248)
#130x000003ff9a31183ethread_start(libc.so.6 +0x11183e)Something like
hw/virtio/vhost-vsock.c +3
-0@@ -73,6 +73,10 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status)bool should_start =virtio_device_started (vdev, status);int ret; + if (!vdev->vm_running) { + should_start = false; + } +if (vhost_dev_is_started (&vvc->vhost_dev) == should_start) {return ; }Quoted 4 lines
helps.
The problem seems to be that
virtio_device_starteddoes ignorevm_runningwhenuse_startis set.Wouldn't it make more sense to re-order the check there, something like:
static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status) { if (!vdev->vm_running) { return false; }
Quoted 6 lines
if (vdev->use_started) { return vdev->started; } return status & VIRTIO_CONFIG_S_DRIVER_OK;}
That does work as well. (and it restores the original ordering so that makes sense).
Quoted 3 lines
Is the problem that
vdev->startedgets filled during the migration but because the VM isn't running yet we can never actually run?
I dont know.
Re: [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started
In reply to Michael S. TsirkinQuoted 11 lines · Michael S. Tsirkin
From: Alex Bennée <[email protected]>
All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong.
Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>
So, looking at the resulting code, I missed the fact that this function is also used in virtio core. So this patch does not do what it's saying it does (just refactor code).
Instead it completely changes the meaning for virtio core.
I thunk we should revert upstream, however, gpio has grown a dependency on this since then.
Alex, could you take a look please?
Quoted 122 lines
--- include/hw/virtio/virtio.h | 5 +++++ hw/virtio/vhost-user-fs.c | 6 +----- hw/virtio/vhost-user-i2c.c | 6 +----- hw/virtio/vhost-user-rng.c | 6 +----- hw/virtio/vhost-user-vsock.c | 6 +----- hw/virtio/vhost-vsock.c | 6 +----- 6 files changed, 10 insertions(+), 25 deletions(-)include/hw/virtio/virtio.h +5
-0@@ -100,6 +100,7 @@ struct VirtIODeviceVirtQueue *vq;MemoryListener listener;uint16_t device_id; +/* @vm_running: current VM running state via virtio_vmstate_change() */ bool vm_running;bool broken;/* device in invalid state, needs reset */ bool use_disabled_flag;/* allow use of 'disable' flag when needed */ @@ -376,6 +377,10 @@ static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status)return vdev->started; } +if (!vdev->vm_running) { +return false; + } +return status &VIRTIO_CONFIG_S_DRIVER_OK ; }hw/virtio/vhost-user-fs.c +1
-5@@ -122,11 +122,7 @@ static void vuf_stop(VirtIODevice *vdev)static void vuf_set_status (VirtIODevice *vdev,uint8_t status) {VHostUserFS *fs =VHOST_USER_FS (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (fs->vhost_dev.started == should_start) {return ;hw/virtio/vhost-user-i2c.c +1
-5@@ -93,11 +93,7 @@ static void vu_i2c_stop(VirtIODevice *vdev)static void vu_i2c_set_status (VirtIODevice *vdev,uint8_t status) {VHostUserI2C *i2c =VHOST_USER_I2C (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (i2c->vhost_dev.started == should_start) {return ;hw/virtio/vhost-user-rng.c +1
-5@@ -90,11 +90,7 @@ static void vu_rng_stop(VirtIODevice *vdev)static void vu_rng_set_status (VirtIODevice *vdev,uint8_t status) {VHostUserRNG *rng =VHOST_USER_RNG (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (rng->vhost_dev.started == should_start) {return ;hw/virtio/vhost-user-vsock.c +1
-5@@ -55,11 +55,7 @@ const VhostDevConfigOps vsock_ops = {static void vuv_set_status (VirtIODevice *vdev,uint8_t status) {VHostVSockCommon *vvc =VHOST_VSOCK_COMMON (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (vvc->vhost_dev.started == should_start) {return ;hw/virtio/vhost-vsock.c +1
-5@@ -70,13 +70,9 @@ static int vhost_vsock_set_running(VirtIODevice *vdev, int start)static void vhost_vsock_set_status (VirtIODevice *vdev,uint8_t status) {VHostVSockCommon *vvc =VHOST_VSOCK_COMMON (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; +bool should_start =virtio_device_started (vdev, status);int ret; -if (!vdev->vm_running) { - should_start = false; - } -if (vvc->vhost_dev.started == should_start) {return ; }Signature · 1 line
MST
Re: [PULL 07/55] hw/virtio: move vm_running check to virtio_device_started
Quoted 13 lines · Michael S. Tsirkin
Quoted 11 lines · Michael S. Tsirkin
From: Alex Bennée <[email protected]>
All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong.
Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>
Quoted 7 lines
So, looking at the resulting code, I missed the fact that this function is also used in virtio core. So this patch does not do what it's saying it does (just refactor code).
Instead it completely changes the meaning for virtio core.
I thunk we should revert upstream, however, gpio has grown a dependency on this since then.
Alex, could you take a look please?
So I guess we have three choices:
new function for use by backends
new function for use by core
parameterise virtio_device_started to ignore vm state
I'll add some usage doc comments whichever way.
Do you have a preference?
Quoted 123 lines
Quoted 123 lines
--- include/hw/virtio/virtio.h | 5 +++++ hw/virtio/vhost-user-fs.c | 6 +----- hw/virtio/vhost-user-i2c.c | 6 +----- hw/virtio/vhost-user-rng.c | 6 +----- hw/virtio/vhost-user-vsock.c | 6 +----- hw/virtio/vhost-vsock.c | 6 +----- 6 files changed, 10 insertions(+), 25 deletions(-)include/hw/virtio/virtio.h +5
-0@@ -100,6 +100,7 @@ struct VirtIODeviceVirtQueue *vq;MemoryListener listener;uint16_t device_id; +/* @vm_running: current VM running state via virtio_vmstate_change() */ bool vm_running;bool broken;/* device in invalid state, needs reset */ bool use_disabled_flag;/* allow use of 'disable' flag when needed */ @@ -376,6 +377,10 @@ static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status)return vdev->started; } +if (!vdev->vm_running) { +return false; + } +return status &VIRTIO_CONFIG_S_DRIVER_OK ; }hw/virtio/vhost-user-fs.c +1
-5@@ -122,11 +122,7 @@ static void vuf_stop(VirtIODevice *vdev)static void vuf_set_status (VirtIODevice *vdev,uint8_t status) {VHostUserFS *fs =VHOST_USER_FS (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (fs->vhost_dev.started == should_start) {return ;hw/virtio/vhost-user-i2c.c +1
-5@@ -93,11 +93,7 @@ static void vu_i2c_stop(VirtIODevice *vdev)static void vu_i2c_set_status (VirtIODevice *vdev,uint8_t status) {VHostUserI2C *i2c =VHOST_USER_I2C (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (i2c->vhost_dev.started == should_start) {return ;hw/virtio/vhost-user-rng.c +1
-5@@ -90,11 +90,7 @@ static void vu_rng_stop(VirtIODevice *vdev)static void vu_rng_set_status (VirtIODevice *vdev,uint8_t status) {VHostUserRNG *rng =VHOST_USER_RNG (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (rng->vhost_dev.started == should_start) {return ;hw/virtio/vhost-user-vsock.c +1
-5@@ -55,11 +55,7 @@ const VhostDevConfigOps vsock_ops = {static void vuv_set_status (VirtIODevice *vdev,uint8_t status) {VHostVSockCommon *vvc =VHOST_VSOCK_COMMON (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; - -if (!vdev->vm_running) { - should_start = false; - } +bool should_start =virtio_device_started (vdev, status);if (vvc->vhost_dev.started == should_start) {return ;hw/virtio/vhost-vsock.c +1
-5@@ -70,13 +70,9 @@ static int vhost_vsock_set_running(VirtIODevice *vdev, int start)static void vhost_vsock_set_status (VirtIODevice *vdev,uint8_t status) {VHostVSockCommon *vvc =VHOST_VSOCK_COMMON (vdev); -bool should_start = status &VIRTIO_CONFIG_S_DRIVER_OK ; +bool should_start =virtio_device_started (vdev, status);int ret; -if (!vdev->vm_running) { - should_start = false; - } -if (vvc->vhost_dev.started == should_start) {return ; }Signature · 1 line
MST
Signature · 1 line
Alex Bennée