page.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 (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. static inline xmaddr_t phys_to_machine(xpaddr_t phys)
  25. {
  26. unsigned offset = phys.paddr & ~PAGE_MASK;
  27. return XMADDR(PFN_PHYS(pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
  28. }
  29. static inline xpaddr_t machine_to_phys(xmaddr_t machine)
  30. {
  31. unsigned offset = machine.maddr & ~PAGE_MASK;
  32. return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
  33. }
  34. /* VIRT <-> MACHINE conversion */
  35. #define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v))))
  36. #define virt_to_pfn(v) (PFN_DOWN(__pa(v)))
  37. #define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v)))
  38. #define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
  39. static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
  40. {
  41. /* TODO: assuming it is mapped in the kernel 1:1 */
  42. return virt_to_machine(vaddr);
  43. }
  44. /* TODO: this shouldn't be here but it is because the frontend drivers
  45. * are using it (its rolled in headers) even though we won't hit the code path.
  46. * So for right now just punt with this.
  47. */
  48. static inline pte_t *lookup_address(unsigned long address, unsigned int *level)
  49. {
  50. BUG();
  51. return NULL;
  52. }
  53. static inline int m2p_add_override(unsigned long mfn, struct page *page,
  54. struct gnttab_map_grant_ref *kmap_op)
  55. {
  56. return 0;
  57. }
  58. static inline int m2p_remove_override(struct page *page, bool clear_pte)
  59. {
  60. return 0;
  61. }
  62. static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
  63. {
  64. BUG();
  65. return false;
  66. }
  67. #endif /* _ASM_ARM_XEN_PAGE_H */