Skip to contentSkip to conversation

linux/blktap, gntdev: fix highpte handling

PATCH New Jan Beulich 1 participant 1 message Dec 10, 2008 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux/blktap, gntdev: fix highpte handling

Subject: blktap, gntdev: fix highpte handling

In case of highpte, virt_to_machine() can't be used. Introduce ptep_to_machine() and use it, also to simplify xen_l1_entry_update().

Original patch from: Isaku Yamahata <[email protected]>

As usual, written and tested on 2.6.27.8 and made apply to the 2.6.18 tree without further testing.

arch/i386/mm/hypervisor.c +1 -6
@@ -47,12 +47,7 @@ int xen_multi_mmuext_op(struct mmuext_op
 void xen_l1_entry_update(pte_t *ptr, pte_t val)
 {
 	mmu_update_t u;
-#ifdef CONFIG_HIGHPTE
-	u.ptr = ((unsigned long)ptr >= (unsigned long)high_memory) ?
-		arbitrary_virt_to_machine(ptr) : virt_to_machine(ptr);
-#else
-	u.ptr = virt_to_machine(ptr);
-#endif
+	u.ptr = ptep_to_machine(ptr);
 	u.val = __pte_val(val);
 	BUG_ON(HYPERVISOR_mmu_update(&u, 1, NULL, DOMID_SELF) < 0);
 }
drivers/xen/blktap/blktap.c +1 -1
@@ -364,7 +364,7 @@ static pte_t blktap_clear_pte(struct vm_
 		BUG_ON(xen_feature(XENFEAT_auto_translated_physmap));
 
 		copy = *ptep;
-		gnttab_set_unmap_op(&unmap[count], virt_to_machine(ptep), 
+		gnttab_set_unmap_op(&unmap[count], ptep_to_machine(ptep),
 				    GNTMAP_host_map 
 				    | GNTMAP_application_map 
 				    | GNTMAP_contains_pte,
drivers/xen/gntdev/gntdev.c +1 -1
@@ -769,7 +769,7 @@ static pte_t gntdev_clear_pte(struct vm_
 		    GNTDEV_INVALID_HANDLE && 
 		    !xen_feature(XENFEAT_auto_translated_physmap)) {
 			/* NOT USING SHADOW PAGE TABLES. */
-			gnttab_set_unmap_op(&op, virt_to_machine(ptep), 
+			gnttab_set_unmap_op(&op, ptep_to_machine(ptep), 
 					    GNTMAP_contains_pte,
 					    private_data->grants[slot_index]
 					    .u.valid.user_handle);
include/asm-i386/mach-xen/asm/pgtable.h +13 -0
@@ -488,6 +488,19 @@ void make_pages_writable(void *va, unsig
 	(((maddr_t)pte_mfn(*virt_to_ptep(va)) << PAGE_SHIFT)		\
 	 | ((unsigned long)(va) & (PAGE_SIZE - 1)))
 
+#ifdef CONFIG_HIGHPTE
+#include <asm/io.h>
+struct page *kmap_atomic_to_page(void *);
+#define ptep_to_machine(ptep)						\
+({									\
+	pte_t *__ptep = (ptep);						\
+	page_to_phys(kmap_atomic_to_page(__ptep))			\
+		| ((unsigned long)__ptep & (PAGE_SIZE - 1));		\
+})
+#else
+#define ptep_to_machine(ptep)	virt_to_machine(ptep)
+#endif
+
 #endif /* !__ASSEMBLY__ */
 
 #ifdef CONFIG_FLATMEM
include/asm-ia64/maddr.h +1 -0
@@ -100,6 +100,7 @@ mfn_to_local_pfn(unsigned long mfn)
 #define virt_to_mfn(virt) (__pa(virt) >> PAGE_SHIFT)
 #define virt_to_machine(virt) __pa(virt) /* for tpmfront.c */
 #define arbitrary_virt_to_machine(virt) virt_to_machine(ia64_imva(virt))
+#define ptep_to_machine(virt) virt_to_machine(virt)
 
 #define set_phys_to_machine(pfn, mfn) do { } while (0)
 
include/asm-x86_64/mach-xen/asm/pgtable.h +2 -0
@@ -30,6 +30,8 @@ extern pte_t *lookup_address(unsigned lo
 #define arbitrary_virt_to_machine(va)					\
 	(((maddr_t)pte_mfn(*virt_to_ptep(va)) << PAGE_SHIFT)		\
 	 | ((unsigned long)(va) & (PAGE_SIZE - 1)))
+
+#define ptep_to_machine(ptep)	virt_to_machine(ptep)
 #endif
 
 extern pud_t level3_kernel_pgt[512];