pc, pci, virtio: fixes for rc3
The following changes since commit c11d61271b9e6e7a1f0479ef1ca8fb55fa457a62:
Update version for v2.11.0-rc3 release (2017-11-29 17:59:34 +0000)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
for you to fetch changes up to 75ba2ddb188fa07c3442446766782036e3085cba:
pc: fix crash on attempted cpu unplug (2017-12-01 19:05:58 +0200)
----------------------------------------------------------------
pc, pci, virtio: fixes for rc3
A bunch of fixes all over the place.
----------------------------------------------------------------
Chao Gao (1):
i386/msi: Correct mask of destination ID in MSI address
Greg Kurz (1):
vhost: fix error check in vhost_verify_ring_mappings()
Igor Mammedov (1):
pc: fix crash on attempted cpu unplug
Marc-André Lureau (1):
dump-guest-memory.py: fix No symbol "vmcoreinfo_find"
Maxime Coquelin (2):
virtio: Add queue interface to restore avail index from vring used index
vhost: restore avail index from vring used index on disconnection
Prasad J Pandit (1):
virtio: check VirtQueue Vring object is set
include/hw/i386/apic-msidef.h | 2 +- include/hw/virtio/virtio.h | 1 + hw/i386/pc.c | 5 +++++ hw/virtio/vhost.c | 10 +++++++--- hw/virtio/virtio.c | 24 +++++++++++++++++++++--- scripts/dump-guest-memory.py | 12 +++++++----- 6 files changed, 42 insertions(+), 12 deletions(-)
[Qemu-devel] [PULL 1/7] i386/msi: Correct mask of destination ID in MSI address
From: Chao Gao <[email protected]>
According to SDM 10.11.1, only [19:12] bits of MSI address are Destination ID, change the mask to avoid ambiguity for VT-d spec has used the bit 4 to indicate a remappable interrupt request.
--- include/hw/i386/apic-msidef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/i386/apic-msidef.h +1 -1
@@ -26,6 +26,6 @@#define MSI_ADDR_DEST_ID_SHIFT 12#define MSI_ADDR_DEST_IDX_SHIFT 4 -#define MSI_ADDR_DEST_ID_MASK 0x00ffff0 +#define MSI_ADDR_DEST_ID_MASK 0x000ff000#endif /* HW_APIC_MSIDEF_H */
Signature · 1 line
MST
[Qemu-devel] [PULL 2/7] virtio: Add queue interface to restore avail index from vring used index
In reply to Michael S. TsirkinFrom: Maxime Coquelin <[email protected]>
In case of backend crash, it is not possible to restore internal avail index from the backend value as vhost_get_vring_base callback fails.
This patch provides a new interface to restore internal avail index from the vring used index, as done by some vhost-user backend on reconnection.
--- include/hw/virtio/virtio.h | 1 + hw/virtio/virtio.c | 10 ++++++++++ 2 files changed, 11 insertions(+)
include/hw/virtio/virtio.h +1 -0
@@ -272,6 +272,7 @@ hwaddr virtio_queue_get_avail_size(VirtIODevice *vdev, int n);hwaddr virtio_queue_get_used_size (VirtIODevice *vdev,int n);uint16_t virtio_queue_get_last_avail_idx (VirtIODevice *vdev,int n);void virtio_queue_set_last_avail_idx (VirtIODevice *vdev,int n,uint16_t idx); +void virtio_queue_restore_last_avail_idx (VirtIODevice *vdev,int n);void virtio_queue_invalidate_signalled_used (VirtIODevice *vdev,int n);void virtio_queue_update_used_idx (VirtIODevice *vdev,int n);VirtQueue *virtio_get_queue (VirtIODevice *vdev,int n);
hw/virtio/virtio.c +10 -0
@@ -2310,6 +2310,16 @@ void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx) vdev->vq[n].shadow_avail_idx = idx; } +void virtio_queue_restore_last_avail_idx (VirtIODevice *vdev,int n) +{ +rcu_read_lock (); +if (vdev->vq[n].vring.desc) { + vdev->vq[n].last_avail_idx =vring_used_idx (&vdev->vq[n]); + vdev->vq[n].shadow_avail_idx = vdev->vq[n].last_avail_idx; + } +rcu_read_unlock (); +} +void virtio_queue_update_used_idx (VirtIODevice *vdev,int n) {rcu_read_lock ();
Signature · 1 line
MST
[Qemu-devel] [PULL 3/7] vhost: restore avail index from vring used index on disconnection
In reply to Michael S. TsirkinFrom: Maxime Coquelin <[email protected]>
vhost_virtqueue_stop() gets avail index value from the backend, except if the backend is not responding.
It happens when the backend crashes, and in this case, internal state of the virtio queue is inconsistent, making packets to corrupt the vring state.
With a Linux guest, it results in following error message on backend reconnection:
[ 22.444905] virtio_net virtio0: output.0:id 0 is not a head! [ 22.446746] net enp0s3: Unexpected TXQ (0) queue failure: -5 [ 22.476360] net enp0s3: Unexpected TXQ (0) queue failure: -5
--- hw/virtio/vhost.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/virtio/vhost.c +4 -0
@@ -1138,6 +1138,10 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev, r = dev->vhost_ops->vhost_get_vring_base (dev, &state);if (r <0 ) {VHOST_OPS_DEBUG ("vhost VQ %d ring restore failed: %d" , idx, r); +/* Connection to the backend is broken, so let's sync internal +* last avail idx to the device used idx. +*/ +virtio_queue_restore_last_avail_idx (vdev, idx); }else {virtio_queue_set_last_avail_idx (vdev, idx, state.num); }
Signature · 1 line
MST
[Qemu-devel] [PULL 4/7] dump-guest-memory.py: fix No symbol "vmcoreinfo_find"
In reply to Michael S. TsirkinFrom: Marc-André Lureau <[email protected]>
When qemu is compiled without debug, the dump gdb python script can fail with:
Error occurred in Python command: No symbol "vmcoreinfo_find" in current context.
Because vmcoreinfo_find() is inlined and not exported.
Use the underlying object_resolve_path_type() to get the instance instead.
--- scripts/dump-guest-memory.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
scripts/dump-guest-memory.py +7 -5
@@ -546,13 +546,15 @@ shape and this command should mostly work.""" return None def add_vmcoreinfo(self): - if not gdb.parse_and_eval("vmcoreinfo_find()") \ - or not gdb.parse_and_eval("vmcoreinfo_find()->has_vmcoreinfo"): + vmci = '(VMCoreInfoState *)' + \ + 'object_resolve_path_type("", "vmcoreinfo", 0)' + if not gdb.parse_and_eval("%s" % vmci) \ + or not gdb.parse_and_eval("(%s)->has_vmcoreinfo" % vmci): return - fmt = gdb.parse_and_eval("vmcoreinfo_find()->vmcoreinfo.guest_format") - addr = gdb.parse_and_eval("vmcoreinfo_find()->vmcoreinfo.paddr") - size = gdb.parse_and_eval("vmcoreinfo_find()->vmcoreinfo.size") + fmt = gdb.parse_and_eval("(%s)->vmcoreinfo.guest_format" % vmci) + addr = gdb.parse_and_eval("(%s)->vmcoreinfo.paddr" % vmci) + size = gdb.parse_and_eval("(%s)->vmcoreinfo.size" % vmci) fmt = le16_to_cpu(fmt) addr = le64_to_cpu(addr)
Signature · 1 line
MST
[Qemu-devel] [PULL 5/7] vhost: fix error check in vhost_verify_ring_mappings()
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
Since commit f1f9e6c5 "vhost: adapt vhost_verify_ring_mappings() to virtio 1 ring layout", we check the mapping of each part (descriptor table, available ring and used ring) of each virtqueue separately.
The checking of a part is done by the vhost_verify_ring_part_mapping()
function: it returns either 0 on success or a negative errno if the part cannot be mapped at the same place.
Unfortunately, the vhost_verify_ring_mappings() function checks its return value the other way round. It means that we either:
- only verify the descriptor table of the first virtqueue, and if it is valid we ignore all the other mappings
- or ignore all broken mappings until we reach a valid one
ie, we only raise an error if all mappings are broken, and we consider all mappings are valid otherwise (false success), which is obviously wrong.
This patch ensures that vhost_verify_ring_mappings() only returns success if ALL mappings are okay.
--- hw/virtio/vhost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/virtio/vhost.c +3 -3
@@ -493,21 +493,21 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev, j =0 ; r =vhost_verify_ring_part_mapping (dev, vq->desc, vq->desc_phys, vq->desc_size, start_addr, size); -if (!r) { +if (r) {break ; } j++; r =vhost_verify_ring_part_mapping (dev, vq->avail, vq->avail_phys, vq->avail_size, start_addr, size); -if (!r) { +if (r) {break ; } j++; r =vhost_verify_ring_part_mapping (dev, vq->used, vq->used_phys, vq->used_size, start_addr, size); -if (!r) { +if (r) {break ; } }
Signature · 1 line
MST
[Qemu-devel] [PULL 6/7] virtio: check VirtQueue Vring object is set
In reply to Michael S. TsirkinFrom: Prasad J Pandit <[email protected]>
A guest could attempt to use an uninitialised VirtQueue object or unset Vring.align leading to a arithmetic exception. Add check to avoid it.
--- hw/virtio/virtio.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
hw/virtio/virtio.c +11 -3
@@ -182,7 +182,7 @@ void virtio_queue_update_rings(VirtIODevice *vdev, int n) {VRing *vring = &vdev->vq[n].vring; -if (!vring->desc) { +if (!vring->num || !vring->desc || !vring->align) {/* not yet setup -> nothing to do */ return ; }
@@ -1414,6 +1414,9 @@ void virtio_config_modern_writel(VirtIODevice *vdev,void virtio_queue_set_addr (VirtIODevice *vdev,int n,hwaddr addr) { +if (!vdev->vq[n].vring.num) { +return ; + } vdev->vq[n].vring.desc = addr;virtio_queue_update_rings (vdev, n); }
@@ -1426,6 +1429,9 @@ hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n)void virtio_queue_set_rings (VirtIODevice *vdev,int n,hwaddr desc,hwaddr avail,hwaddr used) { +if (!vdev->vq[n].vring.num) { +return ; + } vdev->vq[n].vring.desc = desc; vdev->vq[n].vring.avail = avail; vdev->vq[n].vring.used = used;
@@ -1494,8 +1500,10 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align)*/ assert (k->has_variable_vring_alignment); - vdev->vq[n].vring.align = align; -virtio_queue_update_rings (vdev, n); +if (align) { + vdev->vq[n].vring.align = align; +virtio_queue_update_rings (vdev, n); + } }static bool virtio_queue_notify_aio_vq (VirtQueue *vq)
Signature · 1 line
MST
[Qemu-devel] [PULL 7/7] pc: fix crash on attempted cpu unplug
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
when qemu is started with '-no-acpi' CLI option, an attempt to unplug a CPU using device_del results in null pointer dereference at:
#0 object_get_class
#1 pc_machine_device_unplug_request_cb
#2 qmp_marshal_device_del
which is caused by pcms->acpi_dev == NULL due to ACPI support being disabled.
Considering that ACPI support is necessary for unplug to work, check that it's enabled and fail unplug request gracefully if no acpi device were found.
--- hw/i386/pc.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/i386/pc.c +5 -0
@@ -1842,6 +1842,11 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,X86CPU *cpu =X86_CPU (dev);PCMachineState *pcms =PC_MACHINE (hotplug_dev); +if (!pcms->acpi_dev) { +error_setg (&local_err,"CPU hot unplug not supported without ACPI" ); + goto out; + } +pc_find_cpu_slot (MACHINE (pcms), cpu->apic_id, &idx);assert (idx !=-1 );if (idx ==0 ) {
Signature · 1 line
MST
Quoted 12 lines · Michael S. Tsirkin
The following changes since commit
c11d61271b9e6e7a1f0479ef1ca8fb55fa457a62:Update version for v2.11.0-rc3 release (2017-11-29 17:59:34 +0000)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
75ba2ddb188fa07c3442446766782036e3085cba:pc: fix crash on attempted cpu unplug (2017-12-01 19:05:58 +0200)
Quoted 8 lines
----------------------------------------------------------------
pc, pci, virtio: fixes for rc3A bunch of fixes all over the place.
Signed-off-by Michael S. Tsirkin <[email protected]>----------------------------------------------------------------
You can't send fixes for rc3 2 days after rc3 has been tagged :-)
Quoted 12 lines
Chao Gao (1):
i386/msi: Correct mask of destination ID in MSI addressGreg Kurz (1):
vhost: fix error check invhost_verify_ring_mappings()Igor Mammedov (1):
pc: fix crash on attempted cpu unplugMarc-André Lureau (1):
dump-guest-memory.py: fix No symbol "vmcoreinfo_find"
Quoted 6 lines
Maxime Coquelin (2):
virtio: Add queue interface to restore avail index from vring used index
vhost: restore avail index from vring used index on disconnectionPrasad J Pandit (1):
virtio: check VirtQueue Vring object is set
Are any of these so important that we would absolutely refuse to release without the fixes (ie they justify rolling an rc4 that we would otherwise not have needed) ?
thanks
-- PMM
Quoted 16 lines · Peter Maydell
Quoted 15 lines · Michael S. Tsirkin
The following changes since commit
c11d61271b9e6e7a1f0479ef1ca8fb55fa457a62:Update version for v2.11.0-rc3 release (2017-11-29 17:59:34 +0000)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
75ba2ddb188fa07c3442446766782036e3085cba:pc: fix crash on attempted cpu unplug (2017-12-01 19:05:58 +0200)
----------------------------------------------------------------
pc, pci, virtio: fixes for rc3
Quoted 7 lines
Quoted 5 lines
A bunch of fixes all over the place.
Signed-off-by Michael S. Tsirkin <[email protected]>----------------------------------------------------------------
You can't send fixes for rc3 2 days after rc3 has been tagged :-)
Bad wording. I meant they are for bugs present in rc3.
Quoted 19 lines
Quoted 12 lines
Chao Gao (1):
i386/msi: Correct mask of destination ID in MSI addressGreg Kurz (1):
vhost: fix error check invhost_verify_ring_mappings()Igor Mammedov (1):
pc: fix crash on attempted cpu unplugMarc-André Lureau (1):
dump-guest-memory.py: fix No symbol "vmcoreinfo_find"Quoted 6 lines
Maxime Coquelin (2):
virtio: Add queue interface to restore avail index from vring used index
vhost: restore avail index from vring used index on disconnectionPrasad J Pandit (1):
virtio: check VirtQueue Vring object is set
Quoted 6 lines
Are any of these so important that we would absolutely refuse to release without the fixes (ie they justify rolling an rc4 that we would otherwise not have needed) ?
thanks
-- PMM
The msi one is less important it just happened to be queued a while ago and I didn't want to rebase all testing. Others are crashers but they don't affect everyone. So I wouldn't be sure, but there's also a security fix in there, so yes, I suspect we are better off with rc4, and if we do I think including others is justified (except maybe the msi one, if you feel strongly I'll rebase and drop it).
Signature · 1 line
MST
Quoted 25 lines · Michael S. Tsirkin
Quoted 17 lines · Peter Maydell
Quoted 16 lines · Michael S. Tsirkin
Chao Gao (1):
i386/msi: Correct mask of destination ID in MSI addressGreg Kurz (1):
vhost: fix error check invhost_verify_ring_mappings()Igor Mammedov (1):
pc: fix crash on attempted cpu unplugMarc-André Lureau (1):
dump-guest-memory.py: fix No symbol "vmcoreinfo_find"Maxime Coquelin (2):
virtio: Add queue interface to restore avail index from vring used index
vhost: restore avail index from vring used index on disconnectionQuoted 6 lines
Quoted 2 lines
Prasad J Pandit (1):
virtio: check VirtQueue Vring object is setAre any of these so important that we would absolutely refuse to release without the fixes (ie they justify rolling an rc4 that we would otherwise not have needed) ?
Quoted 6 lines
The msi one is less important it just happened to be queued a while ago and I didn't want to rebase all testing. Others are crashers but they don't affect everyone. So I wouldn't be sure, but there's also a security fix in there, so yes, I suspect we are better off with rc4, and if we do I think including others is justified (except maybe the msi one, if you feel strongly I'll rebase and drop it).
The bar has to be set quite high here, because if it turns out that there are problems with a bug fix then we are out of time to rework or revert it. And the more fixes we throw in at the last minute, even if they're individually simple, the more likely that one of them turns out to have unexpected consequences.
So: were any of these bugs present in the 2.10 release? If so, that strongly argues for not trying to fix them at this point.
With all of these patches plus David Gibson's, that would be 10 new patches in rc4. That is definitely more than would be ideal.
thanks
-- PMM
Quoted 19 lines · Peter Maydell
Quoted 11 lines · Michael S. Tsirkin
Quoted 3 lines · Peter Maydell
Are any of these so important that we would absolutely refuse to release without the fixes (ie they justify rolling an rc4 that we would otherwise not have needed) ?
The msi one is less important it just happened to be queued a while ago and I didn't want to rebase all testing. Others are crashers but they don't affect everyone. So I wouldn't be sure, but there's also a security fix in there, so yes, I suspect we are better off with rc4, and if we do I think including others is justified (except maybe the msi one, if you feel strongly I'll rebase and drop it).
The bar has to be set quite high here, because if it turns out that there are problems with a bug fix then we are out of time to rework or revert it. And the more fixes we throw in at the last minute, even if they're individually simple, the more likely that one of them turns out to have unexpected consequences.
Quoted 6 lines
So: were any of these bugs present in the 2.10 release? If so, that strongly argues for not trying to fix them at this point.
With all of these patches plus David Gibson's, that would be 10 new patches in rc4. That is definitely more than would be ideal.
After some discussion on IRC we decided that these should go in.
Thanks for the further information; pull applied to master.
-- PMM
Quoted 42 lines · Peter Maydell
Quoted 25 lines · Michael S. Tsirkin
Quoted 17 lines · Peter Maydell
Quoted 16 lines · Michael S. Tsirkin
Chao Gao (1):
i386/msi: Correct mask of destination ID in MSI addressGreg Kurz (1):
vhost: fix error check invhost_verify_ring_mappings()Igor Mammedov (1):
pc: fix crash on attempted cpu unplugMarc-André Lureau (1):
dump-guest-memory.py: fix No symbol "vmcoreinfo_find"Maxime Coquelin (2):
virtio: Add queue interface to restore avail index from vring used index
vhost: restore avail index from vring used index on disconnectionQuoted 6 lines
Quoted 2 lines
Prasad J Pandit (1):
virtio: check VirtQueue Vring object is setAre any of these so important that we would absolutely refuse to release without the fixes (ie they justify rolling an rc4 that we would otherwise not have needed) ?
Quoted 6 lines
The msi one is less important it just happened to be queued a while ago and I didn't want to rebase all testing. Others are crashers but they don't affect everyone. So I wouldn't be sure, but there's also a security fix in there, so yes, I suspect we are better off with rc4, and if we do I think including others is justified (except maybe the msi one, if you feel strongly I'll rebase and drop it).
The bar has to be set quite high here, because if it turns out that there are problems with a bug fix then we are out of time to rework or revert it. And the more fixes we throw in at the last minute, even if they're individually simple, the more likely that one of them turns out to have unexpected consequences.
So: were any of these bugs present in the 2.10 release? If so, that strongly argues for not trying to fix them at this point.
Quoted 6 lines
With all of these patches plus David Gibson's, that would be 10 new patches in rc4. That is definitely more than would be ideal.
thanks
-- PMM
None of these are regressions. Except for the msix one, they do fix major bugs for features new in this release though. I'll resend it without msix, pls go ahead and ignore if you think a .1 stable release is a better place to put them.
Signature · 1 line
MST