1 /* $NetBSD: xenpmap.h,v 1.23 2009/07/29 12:02:06 cegger Exp $ */
5 * Copyright (c) 2004 Christian Limpach.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef _XEN_XENPMAP_H_
31 #define _XEN_XENPMAP_H_
34 #define INVALID_P2M_ENTRY (~0UL)
36 void xpq_queue_machphys_update(paddr_t
, paddr_t
);
37 void xpq_queue_invlpg(vaddr_t
);
38 void xpq_queue_pte_update(paddr_t
, pt_entry_t
);
39 void xpq_queue_pt_switch(paddr_t
);
40 void xpq_flush_queue(void);
41 void xpq_queue_set_ldt(vaddr_t
, uint32_t);
42 void xpq_queue_tlb_flush(void);
43 void xpq_queue_pin_table(paddr_t
);
44 void xpq_queue_unpin_table(paddr_t
);
45 int xpq_update_foreign(paddr_t
, pt_entry_t
, int);
47 extern unsigned long *xpmap_phys_to_machine_mapping
;
50 * On Xen-2, the start of the day virtual memory starts at KERNTEXTOFF
51 * (0xc0100000). On Xen-3 for domain0 it starts at KERNBASE (0xc0000000).
52 * So the offset between physical and virtual address is different on
53 * Xen-2 and Xen-3 for domain0.
54 * starting with xen-3.0.2, we can add notes so that virtual memory starts
55 * at KERNBASE for domU as well.
57 #if defined(DOM0OPS) || !defined(XEN_COMPAT_030001)
58 #define XPMAP_OFFSET 0
60 #define XPMAP_OFFSET (KERNTEXTOFF - KERNBASE)
63 #define mfn_to_pfn(mfn) (machine_to_phys_mapping[(mfn)])
64 #define pfn_to_mfn(pfn) (xpmap_phys_to_machine_mapping[(pfn)])
66 static __inline paddr_t
67 xpmap_mtop(paddr_t mpa
)
70 ((paddr_t
)machine_to_phys_mapping
[mpa
>> PAGE_SHIFT
] << PAGE_SHIFT
)
71 + XPMAP_OFFSET
) | (mpa
& ~PG_FRAME
);
74 static __inline paddr_t
75 xpmap_mtop_masked(paddr_t mpa
)
78 ((paddr_t
)machine_to_phys_mapping
[mpa
>> PAGE_SHIFT
] << PAGE_SHIFT
)
82 static __inline paddr_t
83 xpmap_ptom(paddr_t ppa
)
85 return (((paddr_t
)xpmap_phys_to_machine_mapping
[(ppa
-
86 XPMAP_OFFSET
) >> PAGE_SHIFT
]) << PAGE_SHIFT
)
90 static __inline paddr_t
91 xpmap_ptom_masked(paddr_t ppa
)
93 return (((paddr_t
)xpmap_phys_to_machine_mapping
[(ppa
-
94 XPMAP_OFFSET
) >> PAGE_SHIFT
]) << PAGE_SHIFT
);
98 MULTI_update_va_mapping(
99 multicall_entry_t
*mcl
, vaddr_t va
,
100 pt_entry_t new_val
, unsigned long flags
)
102 mcl
->op
= __HYPERVISOR_update_va_mapping
;
104 #if defined(__x86_64__)
105 mcl
->args
[1] = new_val
;
106 mcl
->args
[2] = flags
;
108 mcl
->args
[1] = (new_val
& 0xffffffff);
110 mcl
->args
[2] = (new_val
>> 32);
114 mcl
->args
[3] = flags
;
119 MULTI_update_va_mapping_otherdomain(
120 multicall_entry_t
*mcl
, vaddr_t va
,
121 pt_entry_t new_val
, unsigned long flags
, domid_t domid
)
123 mcl
->op
= __HYPERVISOR_update_va_mapping_otherdomain
;
125 #if defined(__x86_64__)
126 mcl
->args
[1] = new_val
;
127 mcl
->args
[2] = flags
;
128 mcl
->args
[3] = domid
;
130 mcl
->args
[1] = (new_val
& 0xffffffff);
132 mcl
->args
[2] = (new_val
>> 32);
136 mcl
->args
[3] = flags
;
137 mcl
->args
[4] = domid
;
140 #if defined(__x86_64__)
141 #define MULTI_UVMFLAGS_INDEX 2
142 #define MULTI_UVMDOMID_INDEX 3
144 #define MULTI_UVMFLAGS_INDEX 3
145 #define MULTI_UVMDOMID_INDEX 4
148 #if defined(__x86_64__)
149 void xen_set_user_pgd(paddr_t
);
152 #endif /* _XEN_XENPMAP_H_ */