1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef ASM__RISCV__P2M_H
3 #define ASM__RISCV__P2M_H
4
5 #include <xen/errno.h>
6
7 #include <asm/page-bits.h>
8
9 #define paddr_bits PADDR_BITS
10
11 /*
12 * List of possible type for each page in the p2m entry.
13 * The number of available bit per page in the pte for this purpose is 2 bits.
14 * So it's possible to only have 4 fields. If we run out of value in the
15 * future, it's possible to use higher value for pseudo-type and don't store
16 * them in the p2m entry.
17 */
18 typedef enum {
19 p2m_invalid = 0, /* Nothing mapped here */
20 p2m_ram_rw, /* Normal read/write domain RAM */
21 } p2m_type_t;
22
23 #include <xen/p2m-common.h>
24
get_page_and_type(struct page_info * page,struct domain * domain,unsigned long type)25 static inline int get_page_and_type(struct page_info *page,
26 struct domain *domain,
27 unsigned long type)
28 {
29 BUG_ON("unimplemented");
30 return -EINVAL;
31 }
32
33 /* Look up a GFN and take a reference count on the backing page. */
34 typedef unsigned int p2m_query_t;
35 #define P2M_ALLOC (1u<<0) /* Populate PoD and paged-out entries */
36 #define P2M_UNSHARE (1u<<1) /* Break CoW sharing */
37
get_page_from_gfn(struct domain * d,unsigned long gfn,p2m_type_t * t,p2m_query_t q)38 static inline struct page_info *get_page_from_gfn(
39 struct domain *d, unsigned long gfn, p2m_type_t *t, p2m_query_t q)
40 {
41 BUG_ON("unimplemented");
42 return NULL;
43 }
44
memory_type_changed(struct domain * d)45 static inline void memory_type_changed(struct domain *d)
46 {
47 BUG_ON("unimplemented");
48 }
49
50
guest_physmap_mark_populate_on_demand(struct domain * d,unsigned long gfn,unsigned int order)51 static inline int guest_physmap_mark_populate_on_demand(struct domain *d,
52 unsigned long gfn,
53 unsigned int order)
54 {
55 return -EOPNOTSUPP;
56 }
57
guest_physmap_add_entry(struct domain * d,gfn_t gfn,mfn_t mfn,unsigned long page_order,p2m_type_t t)58 static inline int guest_physmap_add_entry(struct domain *d,
59 gfn_t gfn, mfn_t mfn,
60 unsigned long page_order,
61 p2m_type_t t)
62 {
63 BUG_ON("unimplemented");
64 return -EINVAL;
65 }
66
67 /* Untyped version for RAM only, for compatibility */
68 static inline int __must_check
guest_physmap_add_page(struct domain * d,gfn_t gfn,mfn_t mfn,unsigned int page_order)69 guest_physmap_add_page(struct domain *d, gfn_t gfn, mfn_t mfn,
70 unsigned int page_order)
71 {
72 return guest_physmap_add_entry(d, gfn, mfn, page_order, p2m_ram_rw);
73 }
74
gfn_to_mfn(struct domain * d,gfn_t gfn)75 static inline mfn_t gfn_to_mfn(struct domain *d, gfn_t gfn)
76 {
77 BUG_ON("unimplemented");
78 return INVALID_MFN;
79 }
80
arch_acquire_resource_check(struct domain * d)81 static inline bool arch_acquire_resource_check(struct domain *d)
82 {
83 /*
84 * Requires refcounting the foreign mappings and walking the p2m on
85 * teardown in order to remove foreign pages from the p2m and drop the
86 * extra reference counts.
87 */
88 return false;
89 }
90
p2m_altp2m_check(struct vcpu * v,uint16_t idx)91 static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx)
92 {
93 /* Not supported on RISCV. */
94 }
95
96 #endif /* ASM__RISCV__P2M_H */
97
98 /*
99 * Local variables:
100 * mode: C
101 * c-file-style: "BSD"
102 * c-basic-offset: 4
103 * indent-tabs-mode: nil
104 * End:
105 */
106