diff mbox

x86/HVM: correct last address emulation acceptance check

Message ID 571F417A02000078000E5A98@prv-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Beulich April 26, 2016, 8:22 a.m. UTC
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>
x86/HVM: correct last address emulation acceptance check

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>

--- a/xen/arch/x86/hvm/intercept.c
+++ b/xen/arch/x86/hvm/intercept.c
@@ -34,16 +34,16 @@
 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);

Comments

Paul Durrant April 26, 2016, 8:37 a.m. UTC | #1
> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: 26 April 2016 09:23
> To: xen-devel
> Cc: Paul Durrant; Wei Liu
> Subject: [PATCH] x86/HVM: correct last address emulation acceptance check
> 
> 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>

> 
> --- a/xen/arch/x86/hvm/intercept.c
> +++ b/xen/arch/x86/hvm/intercept.c
> @@ -34,16 +34,16 @@
>  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);
> 
> 
>
Wei Liu April 26, 2016, 10:33 a.m. UTC | #2
On Tue, Apr 26, 2016 at 02:22:50AM -0600, Jan Beulich wrote:
> 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>

Release-acked-by: Wei Liu <wei.liu2@citrix.com>
diff mbox

Patch

--- a/xen/arch/x86/hvm/intercept.c
+++ b/xen/arch/x86/hvm/intercept.c
@@ -34,16 +34,16 @@ 
 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);