page.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 <xen/interface/grant_table.h>
  8. #define pfn_to_mfn(pfn) (pfn)
  9. #define phys_to_machine_mapping_valid(pfn) (1)
  10. #define mfn_to_pfn(mfn) (mfn)
  11. #define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
  12. #define pte_mfn pte_pfn
  13. #define mfn_pte pfn_pte
  14. /* Xen machine address */
  15. typedef struct xmaddr {
  16. phys_addr_t maddr;
  17. } xmaddr_t;
  18. /* Xen pseudo-physical address */
  19. typedef struct xpaddr {
  20. phys_addr_t paddr;
  21. } xpaddr_t;
  22. #define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
  23. #define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
  24. #define INVALID_P2M_ENTRY (~0UL)
  25. static inline xmaddr_t phys_to_machine(xpaddr_t phys)
  26. {
  27. unsigned offset = phys.paddr & ~PAGE_MASK;
  28. return XMADDR(PFN_PHYS(pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
  29. }
  30. static inline xpaddr_t machine_to_phys(xmaddr_t machine)
  31. {
  32. unsigned offset = machine.maddr & ~PAGE_MASK;
  33. return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
  34. }
  35. /* VIRT <-> MACHINE conversion */
  36. #define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v))))
  37. #define virt_to_pfn(v) (PFN_DOWN(__pa(v)))
  38. #define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v)))
  39. #define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
  40. static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
  41. {
  42. /* TODO: assuming it is mapped in the kernel 1:1 */
  43. return virt_to_machine(vaddr);
  44. }
  45. /* TODO: this shouldn't be here but it is because the frontend drivers
  46. * are using it (its rolled in headers) even though we won't hit the code path.
  47. * So for right now just punt with this.
  48. */
  49. static inline pte_t *lookup_address(unsigned long address, unsigned int *level)
  50. {
  51. BUG();
  52. return NULL;
  53. }
  54. static inline int m2p_add_override(unsigned long mfn, struct page *page,
  55. struct gnttab_map_grant_ref *kmap_op)
  56. {
  57. return 0;
  58. }
  59. static inline int m2p_remove_override(struct page *page, bool clear_pte)
  60. {
  61. return 0;
  62. }
  63. static inline bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
  64. {
  65. BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
  66. return true;
  67. }
  68. static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
  69. {
  70. return __set_phys_to_machine(pfn, mfn);
  71. }
  72. #endif /* _ASM_ARM_XEN_PAGE_H */