# HG changeset patch
# User Tim Deegan <Tim.Deegan@xxxxxxxxxx>
# Date 1274798621 -3600
# Node ID 0b3b2b31e962561390cac4896a4a70841990f0e6
# Parent  fef1e7dc74e64cf25d817991dc2594579abf5bd0
HVM guests are allowed to use the entire virtual address space for
whatever they want, without any Xen hole.  __addr_ok() is therefore
always true for such guests.

Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>

diff -r fef1e7dc74e6 -r 0b3b2b31e962 xen/arch/x86/usercopy.c
--- a/xen/arch/x86/usercopy.c	Tue May 25 15:36:25 2010 +0100
+++ b/xen/arch/x86/usercopy.c	Tue May 25 15:43:41 2010 +0100
@@ -7,6 +7,7 @@
  */
 
 #include <xen/config.h>
+#include <xen/sched.h>
 #include <xen/lib.h>
 #include <asm/uaccess.h>
 
diff -r fef1e7dc74e6 -r 0b3b2b31e962 xen/include/asm-x86/x86_32/uaccess.h
--- a/xen/include/asm-x86/x86_32/uaccess.h	Tue May 25 15:36:25 2010 +0100
+++ b/xen/include/asm-x86/x86_32/uaccess.h	Tue May 25 15:43:41 2010 +0100
@@ -15,7 +15,8 @@
 		:"1" (addr),"g" ((int)(size)),"r" (HYPERVISOR_VIRT_START)); \
 	flag; })
 
-#define access_ok(addr,size) (likely(__range_not_ok(addr,size) == 0))
+#define access_ok(addr,size) \
+    (is_hvm_vcpu(current) || likely(__range_not_ok(addr,size) == 0))
 
 #define array_access_ok(addr,count,size) \
     (likely(count < (~0UL/size)) && access_ok(addr,count*size))
diff -r fef1e7dc74e6 -r 0b3b2b31e962 xen/include/asm-x86/x86_64/uaccess.h
--- a/xen/include/asm-x86/x86_64/uaccess.h	Tue May 25 15:36:25 2010 +0100
+++ b/xen/include/asm-x86/x86_64/uaccess.h	Tue May 25 15:43:41 2010 +0100
@@ -14,13 +14,15 @@
 })
 
 /*
- * Valid if in +ve half of 48-bit address space, or above Xen-reserved area.
+ * Valid if in +ve half of 48-bit address space, or above Xen-reserved
+ * area or anywhere in HVM guests (which have no Xen-reserved area).
  * This is also valid for range checks (addr, addr+size). As long as the
  * start address is outside the Xen-reserved area then we will access a
  * non-canonical address (and thus fault) before ever reaching VIRT_START.
  */
-#define __addr_ok(addr) \
-    (((unsigned long)(addr) < (1UL<<48)) || \
+#define __addr_ok(addr)                                 \
+    (is_hvm_vcpu(current) ||                            \
+     ((unsigned long)(addr) < (1UL<<48)) ||             \
      ((unsigned long)(addr) >= HYPERVISOR_VIRT_END))
 
 #define access_ok(addr, size) \
@@ -32,8 +34,9 @@
 #define __compat_addr_ok(d, addr) \
     ((unsigned long)(addr) < HYPERVISOR_COMPAT_VIRT_START(d))
 
-#define __compat_access_ok(d, addr, size) \
-    __compat_addr_ok(d, (unsigned long)(addr) + ((size) ? (size) - 1 : 0))
+#define __compat_access_ok(d, addr, size)                               \
+    (is_hvm_vcpu(current) ||                                            \
+     __compat_addr_ok(d, (unsigned long)(addr) + ((size) ? (size) - 1 : 0)))
 
 #define compat_access_ok(addr, size) \
     __compat_access_ok(current->domain, addr, size)