[XEN, 32on64]: Correct continuation translation for large
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 6 Dec 2007 11:24:02 +0000 (11:24 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 6 Dec 2007 11:24:02 +0000 (11:24 +0000)
compat_mmuext hypercalls.

At the point where we translate the continuation "nat_ops" points to
the beginning of the batch of "i" entries, therefore it must be
incremented by the number of entries processed "i - left". At the same
point "cmp_uops" points to the end of the batch of entries and must
therefore be decremented by "left".

The new count value has already been set by do_mmuext_op to "left" and
therefore it is correct to add "count - i" since that is the number of
entries that remain after this batch.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
xen/arch/x86/x86_64/compat/mm.c
xen/include/asm-x86/guest_access.h

index 6fc1206c5f6162fe3510e380d5881c2c6a8e3cf3..14a5f3001f7ecb9337656ddd4b204e0a48b52696 100644 (file)
@@ -298,9 +298,8 @@ int compat_mmuext_op(XEN_GUEST_HANDLE(mmuext_op_compat_t) cmp_uops,
 
                 BUG_ON(left == arg1);
                 BUG_ON(left > count);
-                guest_handle_add_offset(nat_ops, count - left);
-                BUG_ON(left + i < count);
-                guest_handle_add_offset(cmp_uops, (signed int)(count - left - i));
+                guest_handle_add_offset(nat_ops, i - left);
+                guest_handle_subtract_offset(cmp_uops, left);
                 left = 1;
                 BUG_ON(!hypercall_xlat_continuation(&left, 0x01, nat_ops, cmp_uops));
                 BUG_ON(left != arg1);
index f95a4d16946eee6eb5e5a4fc3fcae4c62ae654ca..75f1f3097d7afc303295cd863900ed90fc78fd92 100644 (file)
@@ -17,6 +17,7 @@
 
 /* Offset the given guest handle into the array it refers to. */
 #define guest_handle_add_offset(hnd, nr) ((hnd).p += (nr))
+#define guest_handle_subtract_offset(hnd, nr) ((hnd).p -= (nr))
 
 /* Cast a guest handle to the specified type of handle. */
 #define guest_handle_cast(hnd, type) ({         \