From: Andres Lagar-Cavilla Date: Thu, 1 Dec 2011 14:21:28 +0000 (+0000) Subject: x86: Add conversion from a xen map to an mfn X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6f76ec6118c6be95c5ad87c4c138e876cad2d90f;p=xen.git x86: Add conversion from a xen map to an mfn This conversion is a trivial invocation of virt_to_mfn in 64 bits. In 32 bits it uses the linear_map. Signed-off-by: Andres Lagar-Cavilla Acked-by: Tim Deegan Committed-by: Tim Deegan --- diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h index 59b42cc348..666fb3ffd0 100644 --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -272,6 +272,7 @@ void copy_page_sse2(void *, const void *); #define pfn_to_paddr(pfn) __pfn_to_paddr(pfn) #define paddr_to_pfn(pa) __paddr_to_pfn(pa) #define paddr_to_pdx(pa) pfn_to_pdx(paddr_to_pfn(pa)) +#define xen_map_to_mfn(va) __xen_map_to_mfn(va) #endif /* !defined(__ASSEMBLY__) */ diff --git a/xen/include/asm-x86/x86_32/page.h b/xen/include/asm-x86/x86_32/page.h index 9b2c7733cf..fa268eff78 100644 --- a/xen/include/asm-x86/x86_32/page.h +++ b/xen/include/asm-x86/x86_32/page.h @@ -71,6 +71,17 @@ static inline void *__maddr_to_virt(unsigned long ma) return (void *)(ma + DIRECTMAP_VIRT_START); } +static inline unsigned long __xen_map_to_mfn(void *va) +{ + l1_pgentry_t *l1e; + + ASSERT( (((unsigned long) va) >= MAPCACHE_VIRT_START) && + (((unsigned long) va) <= MAPCACHE_VIRT_END) ); + l1e = &__linear_l1_table[ + l1_linear_offset((unsigned long) va)]; + return l1e_get_pfn(*l1e); +} + /* read access (should only be used for debug printk's) */ typedef u64 intpte_t; #define PRIpte "016llx" diff --git a/xen/include/asm-x86/x86_64/page.h b/xen/include/asm-x86/x86_64/page.h index 2f46ba2c5a..7fe831bf6d 100644 --- a/xen/include/asm-x86/x86_64/page.h +++ b/xen/include/asm-x86/x86_64/page.h @@ -104,6 +104,11 @@ static inline void *__maddr_to_virt(unsigned long ma) ((ma & ma_top_mask) >> pfn_pdx_hole_shift))); } +static inline unsigned long __xen_map_to_mfn(void *va) +{ + return (__virt_to_maddr((unsigned long) va) >> PAGE_SHIFT); +} + /* read access (should only be used for debug printk's) */ typedef u64 intpte_t; #define PRIpte "016lx"