x86: allow grant table originating ptes to have their guest available
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 4 Nov 2008 11:46:00 +0000 (11:46 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 4 Nov 2008 11:46:00 +0000 (11:46 +0000)
bits set.

In order to allow 2.6.27's get_user_pages_fast() to correctly detect
granted pages (so they would be passed to get_user_pages()), it must
be possible to tell the grant table code in Xen to set the three
available bits in the pte-s it creates.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
xen/arch/x86/mm.c
xen/common/kernel.c
xen/include/public/features.h
xen/include/public/grant_table.h

index 97359e7e947b5370f1d7a21cefb6c320b60f17c3..f05ca57586317438784ba5cf9b81f65091a7180d 100644 (file)
@@ -3332,6 +3332,10 @@ int create_grant_host_mapping(uint64_t addr, unsigned long frame,
     if ( !(flags & GNTMAP_readonly) )
         l1e_add_flags(pte,_PAGE_RW);
 
+    l1e_add_flags(pte,
+                  ((flags >> _GNTMAP_guest_avail0) * _PAGE_AVAIL0)
+                   & _PAGE_AVAIL);
+
     l1e_add_flags(pte, cacheattr_to_pte_flags(cache_flags >> 5));
 
     if ( flags & GNTMAP_contains_pte )
index f3af91f2ed83aafd418d69838cb2d2031e38a459..91376718176e042f62f7acbe420f050f196c7c41 100644 (file)
@@ -222,7 +222,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE(void) arg)
 #ifdef CONFIG_X86
             if ( !is_hvm_vcpu(current) )
                 fi.submap |= (1U << XENFEAT_mmu_pt_update_preserve_ad) |
-                             (1U << XENFEAT_highmem_assist);
+                             (1U << XENFEAT_highmem_assist) |
+                             (1U << XENFEAT_gnttab_map_avail_bits);
 #endif
             break;
         default:
index 16e5ee4d493f7831597698de6649f40ce5ce1eb5..879131cda12a53c25199c3f3e9575d266b13d76b 100644 (file)
 /* x86: Does this Xen host support the MMU_{CLEAR,COPY}_PAGE hypercall? */
 #define XENFEAT_highmem_assist             6
 
+/*
+ * If set, GNTTABOP_map_grant_ref honors flags to be placed into guest kernel
+ * available pte bits.
+ */
+#define XENFEAT_gnttab_map_avail_bits      7
+
 #define XENFEAT_NR_SUBMAPS 1
 
 #endif /* __XEN_PUBLIC_FEATURES_H__ */
index 26f2c35b1813d38e99b0086161055ed46c3f2bac..ad116e71e18e0ff1dca14745a4b782ad05000cea 100644 (file)
@@ -360,7 +360,7 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_and_replace_t);
 
 
 /*
- * Bitfield values for update_pin_status.flags.
+ * Bitfield values for gnttab_map_grant_ref.flags.
  */
  /* Map the grant entry for access by I/O devices. */
 #define _GNTMAP_device_map      (0)
@@ -387,6 +387,13 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_and_replace_t);
 #define _GNTMAP_contains_pte    (4)
 #define GNTMAP_contains_pte     (1<<_GNTMAP_contains_pte)
 
+/*
+ * Bits to be placed in guest kernel available PTE bits (architecture
+ * dependent; only supported when XENFEAT_gnttab_map_avail_bits is set).
+ */
+#define _GNTMAP_guest_avail0    (16)
+#define GNTMAP_guest_avail_mask ((uint32_t)~0 << _GNTMAP_guest_avail0)
+
 /*
  * Values for error status returns. All errors are -ve.
  */