x86/HVM: correct last address emulation acceptance check
authorJan Beulich <jbeulich@suse.com>
Tue, 26 Apr 2016 11:47:02 +0000 (13:47 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 26 Apr 2016 11:47:02 +0000 (13:47 +0200)
For REPeated memory access instructions the repeat count also needs to
be considered. Utilize that "last" already takes this into account.

Also defer computing "last" until we really know we need it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/hvm/intercept.c

index d5cb96c15972cd0e5319915e04f5af01495e874b..fc757d0af7698fe4619c7358a5fd1850fa4eff2f 100644 (file)
 static bool_t hvm_mmio_accept(const struct hvm_io_handler *handler,
                               const ioreq_t *p)
 {
-    paddr_t first = hvm_mmio_first_byte(p);
-    paddr_t last = hvm_mmio_last_byte(p);
+    paddr_t first = hvm_mmio_first_byte(p), last;
 
     BUG_ON(handler->type != IOREQ_TYPE_COPY);
 
     if ( !handler->mmio.ops->check(current, first) )
         return 0;
 
-    /* Make sure the handler will accept the whole access */
-    if ( p->size > 1 &&
+    /* Make sure the handler will accept the whole access. */
+    last = hvm_mmio_last_byte(p);
+    if ( last != first &&
          !handler->mmio.ops->check(current, last) )
         domain_crash(current->domain);