From b804d9a1c19ab9c1cfc3fb244b0f684d2cf49edf Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 10 Dec 2008 13:32:32 +0000 Subject: [PATCH] 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 Signed-off-by: Jan Beulich --- arch/i386/mm/hypervisor.c | 7 +------ drivers/xen/blktap/blktap.c | 2 +- drivers/xen/gntdev/gntdev.c | 2 +- include/asm-i386/mach-xen/asm/pgtable.h | 13 +++++++++++++ include/asm-ia64/maddr.h | 1 + include/asm-x86_64/mach-xen/asm/pgtable.h | 2 ++ 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/arch/i386/mm/hypervisor.c b/arch/i386/mm/hypervisor.c index 9fb9e6b4..5d533e48 100644 --- a/arch/i386/mm/hypervisor.c +++ b/arch/i386/mm/hypervisor.c @@ -47,12 +47,7 @@ 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); } diff --git a/drivers/xen/blktap/blktap.c b/drivers/xen/blktap/blktap.c index 54ec71ea..c69c5401 100644 --- a/drivers/xen/blktap/blktap.c +++ b/drivers/xen/blktap/blktap.c @@ -364,7 +364,7 @@ static pte_t blktap_clear_pte(struct vm_area_struct *vma, 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, diff --git a/drivers/xen/gntdev/gntdev.c b/drivers/xen/gntdev/gntdev.c index 3e21d41a..660b9a4e 100644 --- a/drivers/xen/gntdev/gntdev.c +++ b/drivers/xen/gntdev/gntdev.c @@ -769,7 +769,7 @@ static pte_t gntdev_clear_pte(struct vm_area_struct *vma, unsigned long addr, 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); diff --git a/include/asm-i386/mach-xen/asm/pgtable.h b/include/asm-i386/mach-xen/asm/pgtable.h index a1b7f49f..207f8c07 100644 --- 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, unsigned int nr, unsigned int feature); (((maddr_t)pte_mfn(*virt_to_ptep(va)) << PAGE_SHIFT) \ | ((unsigned long)(va) & (PAGE_SIZE - 1))) +#ifdef CONFIG_HIGHPTE +#include +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 diff --git a/include/asm-ia64/maddr.h b/include/asm-ia64/maddr.h index bb5a5f62..5bf6cce4 100644 --- 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) diff --git a/include/asm-x86_64/mach-xen/asm/pgtable.h b/include/asm-x86_64/mach-xen/asm/pgtable.h index fb1e2120..8ea38633 100644 --- 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 long address); #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]; -- 2.39.5