WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] linux/blktap, gntdev: fix highpte handling

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] linux/blktap, gntdev: fix highpte handling
From: "Jan Beulich" <jbeulich@xxxxxxxxxx>
Date: Wed, 10 Dec 2008 11:07:31 +0000
Delivery-date: Wed, 10 Dec 2008 03:07:41 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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 <yamahata@xxxxxxxxxxxxx>

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

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- a/arch/i386/mm/hypervisor.c
+++ b/arch/i386/mm/hypervisor.c
@@ -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);
 }
--- a/drivers/xen/blktap/blktap.c
+++ b/drivers/xen/blktap/blktap.c
@@ -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,
--- a/drivers/xen/gntdev/gntdev.c
+++ b/drivers/xen/gntdev/gntdev.c
@@ -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);
--- a/include/asm-i386/mach-xen/asm/pgtable.h
+++ b/include/asm-i386/mach-xen/asm/pgtable.h
@@ -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
--- a/include/asm-ia64/maddr.h
+++ b/include/asm-ia64/maddr.h
@@ -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)
 
--- a/include/asm-x86_64/mach-xen/asm/pgtable.h
+++ b/include/asm-x86_64/mach-xen/asm/pgtable.h
@@ -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];




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] linux/blktap, gntdev: fix highpte handling, Jan Beulich <=