Merge ~paelzer/ubuntu/+source/qemu:lp-1894942-fix-vfio-ccw-notifications into ubuntu/+source/qemu:ubuntu/groovy-devel

Proposed by Christian Ehrhardt 
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: c9a7db97bcb9d60bbf1a766431ba94e9da44c647
Merge reported by: Christian Ehrhardt 
Merged at revision: c9a7db97bcb9d60bbf1a766431ba94e9da44c647
Proposed branch: ~paelzer/ubuntu/+source/qemu:lp-1894942-fix-vfio-ccw-notifications
Merge into: ubuntu/+source/qemu:ubuntu/groovy-devel
Diff against target: 183 lines (+155/-0)
4 files modified
debian/changelog (+6/-0)
debian/patches/series (+2/-0)
debian/patches/ubuntu/lp-1894942-s390x-pci-fix-set_ind_atomic.patch (+72/-0)
debian/patches/ubuntu/lp-1894942-virtio-ccw-fix-virtio_set_ind_atomic.patch (+75/-0)
Reviewer Review Type Date Requested Status
Andreas Hasenack Approve
Canonical Server Pending
git-ubuntu developers Pending
Review via email: mp+390440@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

LGTM, +1

review: Approve
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thanks, uploading ...

* [new tag] upload/1%5.0-5ubuntu7 -> upload/1%5.0-5ubuntu7

Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading qemu_5.0-5ubuntu7.dsc: done.
  Uploading qemu_5.0-5ubuntu7.debian.tar.xz: done.
  Uploading qemu_5.0-5ubuntu7_source.buildinfo: done.
  Uploading qemu_5.0-5ubuntu7_source.changes: done.
Successfully uploaded packages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 46216b9..f62401c 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,9 @@
6+qemu (1:5.0-5ubuntu7) groovy; urgency=medium
7+
8+ * d/p/u/lp-1894942-*: fix virtio-ccw host/guest notification (LP: #1894942)
9+
10+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Wed, 09 Sep 2020 08:47:12 +0200
11+
12 qemu (1:5.0-5ubuntu6) groovy; urgency=medium
13
14 * d/p/ubuntu/lp-1887935-vfio-ccw-allow-non-prefetch-ORBs.patch: fix boot
15diff --git a/debian/patches/series b/debian/patches/series
16index e9e2ae1..b392cae 100644
17--- a/debian/patches/series
18+++ b/debian/patches/series
19@@ -81,3 +81,5 @@ ubuntu/lp1890881-linux-user-deal-with-address-wrap-for-ARM_COMMPAGE-o.patch
20 ubuntu/lp1890881-linux-user-elfload-use-MAP_FIXED_NOREPLACE-in-pgb_re.patch
21 ubuntu/lp1890881-linux-user-don-t-use-MAP_FIXED-in-pgd_find_hole_fall.patch
22 ubuntu/lp-1887935-vfio-ccw-allow-non-prefetch-ORBs.patch
23+ubuntu/lp-1894942-virtio-ccw-fix-virtio_set_ind_atomic.patch
24+ubuntu/lp-1894942-s390x-pci-fix-set_ind_atomic.patch
25diff --git a/debian/patches/ubuntu/lp-1894942-s390x-pci-fix-set_ind_atomic.patch b/debian/patches/ubuntu/lp-1894942-s390x-pci-fix-set_ind_atomic.patch
26new file mode 100644
27index 0000000..4211f67
28--- /dev/null
29+++ b/debian/patches/ubuntu/lp-1894942-s390x-pci-fix-set_ind_atomic.patch
30@@ -0,0 +1,72 @@
31+From 45175361f1bfc2d3ccdcb4b22570c2352f3de754 Mon Sep 17 00:00:00 2001
32+From: Halil Pasic <pasic@linux.ibm.com>
33+Date: Tue, 16 Jun 2020 06:50:35 +0200
34+Subject: [PATCH] s390x/pci: fix set_ind_atomic
35+
36+The atomic_cmpxchg() loop is broken because we occasionally end up with
37+old and _old having different values (a legit compiler can generate code
38+that accessed *ind_addr again to pick up a value for _old instead of
39+using the value of old that was already fetched according to the
40+rules of the abstract machine). This means the underlying CS instruction
41+may use a different old (_old) than the one we intended to use if
42+atomic_cmpxchg() performed the xchg part.
43+
44+Let us use volatile to force the rules of the abstract machine for
45+accesses to *ind_addr. Let us also rewrite the loop so, we that the
46+new old is used to compute the new desired value if the xchg part
47+is not performed.
48+
49+Fixes: 8cba80c3a0 ("s390: Add PCI bus support")
50+Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
51+Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
52+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
53+Message-Id: <20200616045035.51641-3-pasic@linux.ibm.com>
54+Signed-off-by: Cornelia Huck <cohuck@redhat.com>
55+
56+Origin: upstream, https://git.qemu.org/?p=qemu.git;a=commit;h=45175361f1
57+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1894942
58+Last-Update: 2020-09-09
59+
60+---
61+ hw/s390x/s390-pci-bus.c | 16 +++++++++-------
62+ 1 file changed, 9 insertions(+), 7 deletions(-)
63+
64+diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
65+index 142e52a8ff..736965c928 100644
66+--- a/hw/s390x/s390-pci-bus.c
67++++ b/hw/s390x/s390-pci-bus.c
68+@@ -637,22 +637,24 @@ static AddressSpace *s390_pci_dma_iommu(PCIBus *bus, void *opaque, int devfn)
69+
70+ static uint8_t set_ind_atomic(uint64_t ind_loc, uint8_t to_be_set)
71+ {
72+- uint8_t ind_old, ind_new;
73++ uint8_t expected, actual;
74+ hwaddr len = 1;
75+- uint8_t *ind_addr;
76++ /* avoid multiple fetches */
77++ uint8_t volatile *ind_addr;
78+
79+ ind_addr = cpu_physical_memory_map(ind_loc, &len, true);
80+ if (!ind_addr) {
81+ s390_pci_generate_error_event(ERR_EVENT_AIRERR, 0, 0, 0, 0);
82+ return -1;
83+ }
84++ actual = *ind_addr;
85+ do {
86+- ind_old = *ind_addr;
87+- ind_new = ind_old | to_be_set;
88+- } while (atomic_cmpxchg(ind_addr, ind_old, ind_new) != ind_old);
89+- cpu_physical_memory_unmap(ind_addr, len, 1, len);
90++ expected = actual;
91++ actual = atomic_cmpxchg(ind_addr, expected, expected | to_be_set);
92++ } while (actual != expected);
93++ cpu_physical_memory_unmap((void *)ind_addr, len, 1, len);
94+
95+- return ind_old;
96++ return actual;
97+ }
98+
99+ static void s390_msi_ctrl_write(void *opaque, hwaddr addr, uint64_t data,
100+--
101+2.28.0
102+
103diff --git a/debian/patches/ubuntu/lp-1894942-virtio-ccw-fix-virtio_set_ind_atomic.patch b/debian/patches/ubuntu/lp-1894942-virtio-ccw-fix-virtio_set_ind_atomic.patch
104new file mode 100644
105index 0000000..0a3a568
106--- /dev/null
107+++ b/debian/patches/ubuntu/lp-1894942-virtio-ccw-fix-virtio_set_ind_atomic.patch
108@@ -0,0 +1,75 @@
109+From 1a8242f7c3f53341dd66253b142ecd06ce1d2a97 Mon Sep 17 00:00:00 2001
110+From: Halil Pasic <pasic@linux.ibm.com>
111+Date: Tue, 16 Jun 2020 06:50:34 +0200
112+Subject: [PATCH] virtio-ccw: fix virtio_set_ind_atomic
113+
114+The atomic_cmpxchg() loop is broken because we occasionally end up with
115+old and _old having different values (a legit compiler can generate code
116+that accessed *ind_addr again to pick up a value for _old instead of
117+using the value of old that was already fetched according to the
118+rules of the abstract machine). This means the underlying CS instruction
119+may use a different old (_old) than the one we intended to use if
120+atomic_cmpxchg() performed the xchg part.
121+
122+Let us use volatile to force the rules of the abstract machine for
123+accesses to *ind_addr. Let us also rewrite the loop so, we that the
124+new old is used to compute the new desired value if the xchg part
125+is not performed.
126+
127+Fixes: 7e7494627f ("s390x/virtio-ccw: Adapter interrupt support.")
128+Reported-by: Andre Wild <Andre.Wild1@ibm.com>
129+Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
130+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
131+Message-Id: <20200616045035.51641-2-pasic@linux.ibm.com>
132+Signed-off-by: Cornelia Huck <cohuck@redhat.com>
133+
134+Origin: upstream, https://git.qemu.org/?p=qemu.git;a=commit;h=1a8242f7c3
135+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1894942
136+Last-Update: 2020-09-09
137+
138+---
139+ hw/s390x/virtio-ccw.c | 18 ++++++++++--------
140+ 1 file changed, 10 insertions(+), 8 deletions(-)
141+
142+diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
143+index c1f4bb1d33..3c988a000b 100644
144+--- a/hw/s390x/virtio-ccw.c
145++++ b/hw/s390x/virtio-ccw.c
146+@@ -786,9 +786,10 @@ static inline VirtioCcwDevice *to_virtio_ccw_dev_fast(DeviceState *d)
147+ static uint8_t virtio_set_ind_atomic(SubchDev *sch, uint64_t ind_loc,
148+ uint8_t to_be_set)
149+ {
150+- uint8_t ind_old, ind_new;
151++ uint8_t expected, actual;
152+ hwaddr len = 1;
153+- uint8_t *ind_addr;
154++ /* avoid multiple fetches */
155++ uint8_t volatile *ind_addr;
156+
157+ ind_addr = cpu_physical_memory_map(ind_loc, &len, true);
158+ if (!ind_addr) {
159+@@ -796,14 +797,15 @@ static uint8_t virtio_set_ind_atomic(SubchDev *sch, uint64_t ind_loc,
160+ __func__, sch->cssid, sch->ssid, sch->schid);
161+ return -1;
162+ }
163++ actual = *ind_addr;
164+ do {
165+- ind_old = *ind_addr;
166+- ind_new = ind_old | to_be_set;
167+- } while (atomic_cmpxchg(ind_addr, ind_old, ind_new) != ind_old);
168+- trace_virtio_ccw_set_ind(ind_loc, ind_old, ind_new);
169+- cpu_physical_memory_unmap(ind_addr, len, 1, len);
170++ expected = actual;
171++ actual = atomic_cmpxchg(ind_addr, expected, expected | to_be_set);
172++ } while (actual != expected);
173++ trace_virtio_ccw_set_ind(ind_loc, actual, actual | to_be_set);
174++ cpu_physical_memory_unmap((void *)ind_addr, len, 1, len);
175+
176+- return ind_old;
177++ return actual;
178+ }
179+
180+ static void virtio_ccw_notify(DeviceState *d, uint16_t vector)
181+--
182+2.28.0
183+

Subscribers

People subscribed via source and target branches