page.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef _ASM_ARM_XEN_PAGE_H
  2. #define _ASM_ARM_XEN_PAGE_H
  3. #include <asm/page.h>
  4. #include <asm/pgtable.h>
  5. #include <linux/pfn.h>
  6. #include <linux/types.h>
  7. #include <linux/dma-mapping.h>
  8. #include <xen/xen.h>
  9. #include <xen/interface/grant_table.h>
  10. #define phys_to_machine_mapping_valid(pfn) (1)
  11. /* Xen machine address */
  12. typedef struct xmaddr {
  13. phys_addr_t maddr;
  14. } xmaddr_t;
  15. /* Xen pseudo-physical address */
  16. typedef struct xpaddr {
  17. phys_addr_t paddr;
  18. } xpaddr_t;
  19. #define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
  20. #define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
  21. #define INVALID_P2M_ENTRY (~0UL)
  22. /*
  23. * The pseudo-physical frame (pfn) used in all the helpers is always based
  24. * on Xen page granularity (i.e 4KB).
  25. *
  26. * A Linux page may be split across multiple non-contiguous Xen page so we
  27. * have to keep track with frame based on 4KB page granularity.
  28. *
  29. * PV drivers should never make a direct usage of those helpers (particularly
  30. * pfn_to_gfn and gfn_to_pfn).
  31. */
  32. unsigned long __pfn_to_mfn(unsigned long pfn);
  33. extern struct rb_root phys_to_mach;
  34. /* Pseudo-physical <-> Guest conversion */
  35. static inline unsigned long pfn_to_gfn(unsigned long pfn)
  36. {
  37. return pfn;
  38. }
  39. static inline unsigned long gfn_to_pfn(unsigned long gfn)
  40. {
  41. return gfn;
  42. }
  43. /* Pseudo-physical <-> BUS conversion */
  44. static inline unsigned long pfn_to_bfn(unsigned long pfn)
  45. {
  46. unsigned long mfn;
  47. if (phys_to_mach.rb_node != NULL) {
  48. mfn = __pfn_to_mfn(pfn);
  49. if (mfn != INVALID_P2M_ENTRY)
  50. return mfn;
  51. }
  52. return pfn;
  53. }
  54. static inline unsigned long bfn_to_pfn(unsigned long bfn)
  55. {
  56. return bfn;
  57. }
  58. #define bfn_to_local_pfn(bfn) bfn_to_pfn(bfn)
  59. /* VIRT <-> GUEST conversion */
  60. #define virt_to_gfn(v) (pfn_to_gfn(virt_to_phys(v) >> XEN_PAGE_SHIFT))
  61. #define gfn_to_virt(m) (__va(gfn_to_pfn(m) << XEN_PAGE_SHIFT))
  62. /* Only used in PV code. But ARM guests are always HVM. */
  63. static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
  64. {
  65. BUG();
  66. }
  67. extern int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
  68. struct gnttab_map_grant_ref *kmap_ops,
  69. struct page **pages, unsigned int count);
  70. extern int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
  71. struct gnttab_unmap_grant_ref *kunmap_ops,
  72. struct page **pages, unsigned int count);
  73. bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn);
  74. bool __set_phys_to_machine_multi(unsigned long pfn, unsigned long mfn,
  75. unsigned long nr_pages);
  76. static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
  77. {
  78. return __set_phys_to_machine(pfn, mfn);
  79. }
  80. #define xen_remap(cookie, size) ioremap_cache((cookie), (size))
  81. #define xen_unmap(cookie) iounmap((cookie))
  82. bool xen_arch_need_swiotlb(struct device *dev,
  83. phys_addr_t phys,
  84. dma_addr_t dev_addr);
  85. unsigned long xen_get_swiotlb_free_pages(unsigned int order);
  86. #endif /* _ASM_ARM_XEN_PAGE_H */