Linux Audio

Check our new training course

Loading...
v6.13.7
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef _ASM_ARM_XEN_PAGE_H
  3#define _ASM_ARM_XEN_PAGE_H
  4
  5#include <asm/page.h>
 
  6
  7#include <linux/pfn.h>
  8#include <linux/types.h>
  9#include <linux/dma-mapping.h>
 10#include <linux/pgtable.h>
 11
 12#include <xen/xen.h>
 13#include <xen/interface/grant_table.h>
 14
 15#define phys_to_machine_mapping_valid(pfn) (1)
 16
 17/* Xen machine address */
 18typedef struct xmaddr {
 19	phys_addr_t maddr;
 20} xmaddr_t;
 21
 22/* Xen pseudo-physical address */
 23typedef struct xpaddr {
 24	phys_addr_t paddr;
 25} xpaddr_t;
 26
 27#define XMADDR(x)	((xmaddr_t) { .maddr = (x) })
 28#define XPADDR(x)	((xpaddr_t) { .paddr = (x) })
 29
 30#define INVALID_P2M_ENTRY      (~0UL)
 31
 32/*
 33 * The pseudo-physical frame (pfn) used in all the helpers is always based
 34 * on Xen page granularity (i.e 4KB).
 35 *
 36 * A Linux page may be split across multiple non-contiguous Xen page so we
 37 * have to keep track with frame based on 4KB page granularity.
 38 *
 39 * PV drivers should never make a direct usage of those helpers (particularly
 40 * pfn_to_gfn and gfn_to_pfn).
 41 */
 42
 43unsigned long __pfn_to_mfn(unsigned long pfn);
 44extern struct rb_root phys_to_mach;
 45
 46/* Pseudo-physical <-> Guest conversion */
 47static inline unsigned long pfn_to_gfn(unsigned long pfn)
 48{
 49	return pfn;
 50}
 51
 52static inline unsigned long gfn_to_pfn(unsigned long gfn)
 53{
 54	return gfn;
 55}
 56
 57/* Pseudo-physical <-> BUS conversion */
 58static inline unsigned long pfn_to_bfn(unsigned long pfn)
 59{
 60	unsigned long mfn;
 61
 62	if (phys_to_mach.rb_node != NULL) {
 63		mfn = __pfn_to_mfn(pfn);
 64		if (mfn != INVALID_P2M_ENTRY)
 65			return mfn;
 66	}
 67
 68	return pfn;
 69}
 70
 71static inline unsigned long bfn_to_pfn(unsigned long bfn)
 72{
 73	return bfn;
 74}
 75
 76#define bfn_to_local_pfn(bfn)	bfn_to_pfn(bfn)
 77
 78/* VIRT <-> GUEST conversion */
 79#define virt_to_gfn(v)                                                         \
 80	({                                                                     \
 81		WARN_ON_ONCE(!virt_addr_valid(v));                              \
 82		pfn_to_gfn(virt_to_phys(v) >> XEN_PAGE_SHIFT);                 \
 83	})
 84#define gfn_to_virt(m)		(__va(gfn_to_pfn(m) << XEN_PAGE_SHIFT))
 85
 86#define percpu_to_gfn(v)	\
 87	(pfn_to_gfn(per_cpu_ptr_to_phys(v) >> XEN_PAGE_SHIFT))
 88
 89/* Only used in PV code. But ARM guests are always HVM. */
 90static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
 91{
 92	BUG();
 93}
 94
 
 
 
 
 
 
 
 
 
 
 95extern int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
 96				   struct gnttab_map_grant_ref *kmap_ops,
 97				   struct page **pages, unsigned int count);
 98
 99extern int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
100				     struct gnttab_unmap_grant_ref *kunmap_ops,
101				     struct page **pages, unsigned int count);
102
103bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn);
104bool __set_phys_to_machine_multi(unsigned long pfn, unsigned long mfn,
105		unsigned long nr_pages);
106
107static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
108{
109	return __set_phys_to_machine(pfn, mfn);
110}
111
 
 
 
112bool xen_arch_need_swiotlb(struct device *dev,
113			   phys_addr_t phys,
114			   dma_addr_t dev_addr);
 
115
116#endif /* _ASM_ARM_XEN_PAGE_H */
v4.10.11
 
  1#ifndef _ASM_ARM_XEN_PAGE_H
  2#define _ASM_ARM_XEN_PAGE_H
  3
  4#include <asm/page.h>
  5#include <asm/pgtable.h>
  6
  7#include <linux/pfn.h>
  8#include <linux/types.h>
  9#include <linux/dma-mapping.h>
 
 10
 11#include <xen/xen.h>
 12#include <xen/interface/grant_table.h>
 13
 14#define phys_to_machine_mapping_valid(pfn) (1)
 15
 16/* Xen machine address */
 17typedef struct xmaddr {
 18	phys_addr_t maddr;
 19} xmaddr_t;
 20
 21/* Xen pseudo-physical address */
 22typedef struct xpaddr {
 23	phys_addr_t paddr;
 24} xpaddr_t;
 25
 26#define XMADDR(x)	((xmaddr_t) { .maddr = (x) })
 27#define XPADDR(x)	((xpaddr_t) { .paddr = (x) })
 28
 29#define INVALID_P2M_ENTRY      (~0UL)
 30
 31/*
 32 * The pseudo-physical frame (pfn) used in all the helpers is always based
 33 * on Xen page granularity (i.e 4KB).
 34 *
 35 * A Linux page may be split across multiple non-contiguous Xen page so we
 36 * have to keep track with frame based on 4KB page granularity.
 37 *
 38 * PV drivers should never make a direct usage of those helpers (particularly
 39 * pfn_to_gfn and gfn_to_pfn).
 40 */
 41
 42unsigned long __pfn_to_mfn(unsigned long pfn);
 43extern struct rb_root phys_to_mach;
 44
 45/* Pseudo-physical <-> Guest conversion */
 46static inline unsigned long pfn_to_gfn(unsigned long pfn)
 47{
 48	return pfn;
 49}
 50
 51static inline unsigned long gfn_to_pfn(unsigned long gfn)
 52{
 53	return gfn;
 54}
 55
 56/* Pseudo-physical <-> BUS conversion */
 57static inline unsigned long pfn_to_bfn(unsigned long pfn)
 58{
 59	unsigned long mfn;
 60
 61	if (phys_to_mach.rb_node != NULL) {
 62		mfn = __pfn_to_mfn(pfn);
 63		if (mfn != INVALID_P2M_ENTRY)
 64			return mfn;
 65	}
 66
 67	return pfn;
 68}
 69
 70static inline unsigned long bfn_to_pfn(unsigned long bfn)
 71{
 72	return bfn;
 73}
 74
 75#define bfn_to_local_pfn(bfn)	bfn_to_pfn(bfn)
 76
 77/* VIRT <-> GUEST conversion */
 78#define virt_to_gfn(v)		(pfn_to_gfn(virt_to_phys(v) >> XEN_PAGE_SHIFT))
 
 
 
 
 79#define gfn_to_virt(m)		(__va(gfn_to_pfn(m) << XEN_PAGE_SHIFT))
 80
 
 
 
 81/* Only used in PV code. But ARM guests are always HVM. */
 82static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
 83{
 84	BUG();
 85}
 86
 87/* TODO: this shouldn't be here but it is because the frontend drivers
 88 * are using it (its rolled in headers) even though we won't hit the code path.
 89 * So for right now just punt with this.
 90 */
 91static inline pte_t *lookup_address(unsigned long address, unsigned int *level)
 92{
 93	BUG();
 94	return NULL;
 95}
 96
 97extern int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
 98				   struct gnttab_map_grant_ref *kmap_ops,
 99				   struct page **pages, unsigned int count);
100
101extern int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
102				     struct gnttab_unmap_grant_ref *kunmap_ops,
103				     struct page **pages, unsigned int count);
104
105bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn);
106bool __set_phys_to_machine_multi(unsigned long pfn, unsigned long mfn,
107		unsigned long nr_pages);
108
109static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
110{
111	return __set_phys_to_machine(pfn, mfn);
112}
113
114#define xen_remap(cookie, size) ioremap_cache((cookie), (size))
115#define xen_unmap(cookie) iounmap((cookie))
116
117bool xen_arch_need_swiotlb(struct device *dev,
118			   phys_addr_t phys,
119			   dma_addr_t dev_addr);
120unsigned long xen_get_swiotlb_free_pages(unsigned int order);
121
122#endif /* _ASM_ARM_XEN_PAGE_H */