ia64/linux-2.6.18-xen.hg

annotate include/asm-ia64/maddr.h @ 761:5e1269aa5c29

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@valinux.co.jp>
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 10 13:32:32 2008 +0000 (2008-12-10)
parents ca213a56dba1
children
rev   line source
ian@26 1 #ifndef _ASM_IA64_MADDR_H
ian@26 2 #define _ASM_IA64_MADDR_H
ian@26 3
ian@26 4 #include <linux/kernel.h>
ian@26 5 #include <asm/hypervisor.h>
ian@26 6 #include <xen/features.h>
ian@26 7 #include <xen/interface/xen.h>
ian@26 8
ian@26 9 #ifdef CONFIG_XEN
ian@26 10
ian@26 11 #define INVALID_P2M_ENTRY (~0UL)
ian@26 12
ian@26 13 #ifdef CONFIG_XEN_IA64_EXPOSE_P2M
ian@26 14 extern int p2m_initialized;
ian@26 15 extern unsigned long p2m_min_low_pfn;
ian@26 16 extern unsigned long p2m_max_low_pfn;
ian@26 17 extern unsigned long p2m_convert_min_pfn;
ian@26 18 extern unsigned long p2m_convert_max_pfn;
ian@26 19 extern volatile const pte_t* p2m_pte;
ian@26 20 unsigned long p2m_phystomach(unsigned long gpfn);
ian@26 21 #else
ian@26 22 #define p2m_initialized (0)
ian@26 23 #define p2m_phystomach(gpfn) INVALID_MFN
ian@26 24 #endif
ian@26 25
ian@26 26 /* XXX xen page size != page size */
ian@26 27 static inline unsigned long
ian@26 28 pfn_to_mfn_for_dma(unsigned long pfn)
ian@26 29 {
ian@26 30 unsigned long mfn;
ian@26 31 if (p2m_initialized)
ian@26 32 return p2m_phystomach(pfn);
ian@26 33 mfn = HYPERVISOR_phystomach(pfn);
alex@392 34 BUG_ON(mfn == 0); /* XXX */
alex@392 35 BUG_ON(mfn == INVALID_P2M_ENTRY); /* XXX */
ian@26 36 BUG_ON(mfn == INVALID_MFN);
ian@26 37 return mfn;
ian@26 38 }
ian@26 39
ian@26 40 static inline unsigned long
ian@26 41 phys_to_machine_for_dma(unsigned long phys)
ian@26 42 {
ian@26 43 unsigned long machine =
ian@26 44 pfn_to_mfn_for_dma(phys >> PAGE_SHIFT) << PAGE_SHIFT;
ian@26 45 machine |= (phys & ~PAGE_MASK);
ian@26 46 return machine;
ian@26 47 }
ian@26 48
ian@26 49 static inline unsigned long
ian@26 50 mfn_to_pfn_for_dma(unsigned long mfn)
ian@26 51 {
ian@26 52 unsigned long pfn;
ian@26 53 pfn = HYPERVISOR_machtophys(mfn);
ian@26 54 BUG_ON(pfn == 0);
alex@392 55 /* BUG_ON(pfn == INVALID_M2P_ENTRY); */
ian@26 56 return pfn;
ian@26 57 }
ian@26 58
ian@26 59 static inline unsigned long
ian@26 60 machine_to_phys_for_dma(unsigned long machine)
ian@26 61 {
ian@26 62 unsigned long phys =
ian@26 63 mfn_to_pfn_for_dma(machine >> PAGE_SHIFT) << PAGE_SHIFT;
ian@26 64 phys |= (machine & ~PAGE_MASK);
ian@26 65 return phys;
ian@26 66 }
ian@26 67
ian@26 68 #ifdef CONFIG_SPARSEMEM
ian@26 69 /*
ian@26 70 * When CONFIG_SPARSEMEM=y, pfn_valid() is defined in
ian@26 71 * linux/include/linux/mmzone.h. Hoever #include <linux/mmzone.h>
ian@26 72 * causes the header inclusion hell.
ian@26 73 */
ian@26 74 static inline int pfn_valid(unsigned long pfn);
ian@26 75 #endif
ian@26 76
ian@26 77 static inline unsigned long
ian@26 78 mfn_to_local_pfn(unsigned long mfn)
ian@26 79 {
ian@26 80 unsigned long pfn = mfn_to_pfn_for_dma(mfn);
ian@26 81 if (!pfn_valid(pfn))
ian@26 82 return INVALID_P2M_ENTRY;
ian@26 83 return pfn;
ian@26 84 }
ian@26 85
ian@26 86 #else /* !CONFIG_XEN */
ian@26 87
ian@26 88 #define pfn_to_mfn_for_dma(pfn) (pfn)
ian@26 89 #define mfn_to_pfn_for_dma(mfn) (mfn)
ian@26 90 #define phys_to_machine_for_dma(phys) (phys)
ian@26 91 #define machine_to_phys_for_dma(machine) (machine)
ian@26 92 #define mfn_to_local_pfn(mfn) (mfn)
ian@26 93
ian@26 94 #endif /* !CONFIG_XEN */
ian@26 95
ian@26 96 #define mfn_to_pfn(mfn) (mfn)
ian@26 97 #define pfn_to_mfn(pfn) (pfn)
ian@26 98
ian@26 99 #define mfn_to_virt(mfn) (__va((mfn) << PAGE_SHIFT))
ian@26 100 #define virt_to_mfn(virt) (__pa(virt) >> PAGE_SHIFT)
alex@392 101 #define virt_to_machine(virt) __pa(virt) /* for tpmfront.c */
keir@752 102 #define arbitrary_virt_to_machine(virt) virt_to_machine(ia64_imva(virt))
keir@761 103 #define ptep_to_machine(virt) virt_to_machine(virt)
ian@26 104
ian@26 105 #define set_phys_to_machine(pfn, mfn) do { } while (0)
ian@26 106
alex@392 107 typedef unsigned long maddr_t; /* to compile netback, netfront */
alex@44 108 #ifndef _ASM_IA64_SN_TYPES_H /* paddr_t is defined in asm-ia64/sn/types.h */
alex@44 109 typedef unsigned long paddr_t;
alex@44 110 #endif
ian@26 111
alex@126 112 #ifdef CONFIG_XEN
alex@507 113 int range_straddles_page_boundary(paddr_t p, size_t size);
alex@126 114 #else
alex@126 115 #define range_straddles_page_boundary(addr, size) (0)
alex@126 116 #endif
alex@126 117
ian@26 118 #endif /* _ASM_IA64_MADDR_H */