xen: fix quad word bufioreq handling
authorJan Beulich <JBeulich@suse.com>
Fri, 25 Nov 2016 10:05:57 +0000 (03:05 -0700)
committerStefano Stabellini <sstabellini@kernel.org>
Mon, 28 Nov 2016 19:25:23 +0000 (11:25 -0800)
We should not consume the second slot if it didn't get written yet.
Normal writers - i.e. Xen - would not update write_pointer between the
two writes, but the page may get fiddled with by the guest itself, and
we're better off avoiding to enter an infinite loop in that case.

Reported-by: yanghongke <yanghongke@huawei.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
xen-hvm.c

index 99b8ee8a4f367ec8e8a4299e017d54b6dd340305..d74e23305426bff59bfeb7ca827dc1b5f19a9347 100644 (file)
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -1021,6 +1021,9 @@ static int handle_buffered_iopage(XenIOState *state)
         xen_rmb();
         qw = (req.size == 8);
         if (qw) {
+            if (rdptr + 1 == wrptr) {
+                hw_error("Incomplete quad word buffered ioreq");
+            }
             buf_req = &buf_page->buf_ioreq[(rdptr + 1) %
                                            IOREQ_BUFFER_SLOT_NUM];
             req.data |= ((uint64_t)buf_req->data) << 32;