direct-io.hg

view xen/include/asm-powerpc/mm.h @ 11487:4fdf5151b187

[POWERPC] merge with xen-unstable.hg
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author hollisb@localhost
date Mon Sep 18 12:48:56 2006 -0500 (2006-09-18)
parents bc349d862a5d
children a817acb39386
line source
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 *
16 * Copyright (C) IBM Corp. 2005
17 *
18 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
19 */
21 #ifndef _ASM_MM_H_
22 #define _ASM_MM_H_
24 #include <public/xen.h>
25 #include <xen/list.h>
26 #include <xen/types.h>
27 #include <xen/mm.h>
28 #include <asm/misc.h>
29 #include <asm/system.h>
30 #include <asm/flushtlb.h>
31 #include <asm/uaccess.h>
33 #define memguard_guard_range(_p,_l) ((void)0)
34 #define memguard_unguard_range(_p,_l) ((void)0)
36 extern unsigned long xenheap_phys_end;
38 /*
39 * Per-page-frame information.
40 *
41 * Every architecture must ensure the following:
42 * 1. 'struct page_info' contains a 'struct list_head list'.
43 * 2. Provide a PFN_ORDER() macro for accessing the order of a free page.
44 */
45 #define PFN_ORDER(_pfn) ((_pfn)->u.free.order)
47 /* XXX copy-and-paste job; re-examine me */
48 struct page_info
49 {
50 /* Each frame can be threaded onto a doubly-linked list. */
51 struct list_head list;
53 /* Timestamp from 'TLB clock', used to reduce need for safety flushes. */
54 u32 tlbflush_timestamp;
56 /* Reference count and various PGC_xxx flags and fields. */
57 unsigned long count_info;
59 /* Context-dependent fields follow... */
60 union {
62 /* Page is in use: ((count_info & PGC_count_mask) != 0). */
63 struct {
64 /* Owner of this page (NULL if page is anonymous). */
65 u32 _domain;
66 /* Type reference count and various PGT_xxx flags and fields. */
67 unsigned long type_info;
68 } inuse;
70 /* Page is on a free list: ((count_info & PGC_count_mask) == 0). */
71 struct {
72 /* Mask of possibly-tainted TLBs. */
73 cpumask_t cpumask;
74 /* Order-size of the free chunk this page is the head of. */
75 u8 order;
76 } free;
78 } u;
80 };
82 struct page_extents {
83 /* Each frame can be threaded onto a doubly-linked list. */
84 struct list_head pe_list;
86 /* page extent */
87 struct page_info *pg;
88 uint order;
89 ulong pfn;
90 };
92 /* The following page types are MUTUALLY EXCLUSIVE. */
93 #define PGT_none (0<<29) /* no special uses of this page */
94 #define PGT_RMA (1<<29) /* This page is an RMA page? */
95 #define PGT_writable_page (7<<29) /* has writable mappings of this page? */
96 #define PGT_type_mask (7<<29) /* Bits 29-31. */
98 /* Owning guest has pinned this page to its current type? */
99 #define _PGT_pinned 28
100 #define PGT_pinned (1U<<_PGT_pinned)
101 /* Has this page been validated for use as its current type? */
102 #define _PGT_validated 27
103 #define PGT_validated (1U<<_PGT_validated)
105 /* The 27 most significant bits of virt address if this is a page table. */
106 #define PGT_va_shift 32
107 #define PGT_va_mask ((unsigned long)((1U<<28)-1)<<PGT_va_shift)
108 /* Is the back pointer still mutable (i.e. not fixed yet)? */
109 #define PGT_va_mutable ((unsigned long)((1U<<28)-1)<<PGT_va_shift)
110 /* Is the back pointer unknown (e.g., p.t. is mapped at multiple VAs)? */
111 #define PGT_va_unknown ((unsigned long)((1U<<28)-2)<<PGT_va_shift)
113 /* 16-bit count of uses of this frame as its current type. */
114 #define PGT_count_mask ((1U<<16)-1)
116 /* Cleared when the owning guest 'frees' this page. */
117 #define _PGC_allocated 31
118 #define PGC_allocated (1U<<_PGC_allocated)
119 /* Set on a *guest* page to mark it out-of-sync with its shadow */
120 #define _PGC_out_of_sync 30
121 #define PGC_out_of_sync (1U<<_PGC_out_of_sync)
122 /* Set when is using a page as a page table */
123 #define _PGC_page_table 29
124 #define PGC_page_table (1U<<_PGC_page_table)
125 /* 29-bit count of references to this frame. */
126 #define PGC_count_mask ((1U<<29)-1)
128 #define IS_XEN_HEAP_FRAME(_pfn) (page_to_maddr(_pfn) < xenheap_phys_end)
130 static inline struct domain *unpickle_domptr(u32 _domain)
131 { return ((_domain == 0) || (_domain & 1)) ? NULL : __va(_domain); }
133 static inline u32 pickle_domptr(struct domain *domain)
134 { return (domain == NULL) ? 0 : (u32)__pa(domain); }
136 #define PRtype_info "016lx"/* should only be used for printk's */
138 #define page_get_owner(_p) (unpickle_domptr((_p)->u.inuse._domain))
139 #define page_set_owner(_p,_d) ((_p)->u.inuse._domain = pickle_domptr(_d))
141 extern struct page_info *frame_table;
142 extern unsigned long max_page;
143 extern unsigned long total_pages;
144 void init_frametable(void);
146 static inline void put_page(struct page_info *page)
147 {
148 u32 nx, x, y = page->count_info;
150 do {
151 x = y;
152 nx = x - 1;
153 }
154 while ( unlikely((y = cmpxchg(&page->count_info, x, nx)) != x) );
156 if ( unlikely((nx & PGC_count_mask) == 0) ) {
157 panic("about to free page\n");
158 free_domheap_page(page);
159 }
160 }
162 static inline int get_page(struct page_info *page,
163 struct domain *domain)
164 {
165 u32 x, nx, y = page->count_info;
166 u32 d, nd = page->u.inuse._domain;
167 u32 _domain = pickle_domptr(domain);
169 do {
170 x = y;
171 nx = x + 1;
172 d = nd;
173 if ( unlikely((x & PGC_count_mask) == 0) || /* Not allocated? */
174 unlikely((nx & PGC_count_mask) == 0) || /* Count overflow? */
175 unlikely(d != _domain) ) /* Wrong owner? */
176 {
177 return 0;
178 }
179 y = cmpxchg(&page->count_info, x, nx);
180 }
181 while ( unlikely(y != x) );
183 return 1;
184 }
186 extern void put_page_type(struct page_info *page);
187 extern int get_page_type(struct page_info *page, unsigned long type);
189 static inline void put_page_and_type(struct page_info *page)
190 {
191 put_page_type(page);
192 put_page(page);
193 }
195 static inline int get_page_and_type(struct page_info *page,
196 struct domain *domain,
197 unsigned long type)
198 {
199 int rc = get_page(page, domain);
201 if ( likely(rc) && unlikely(!get_page_type(page, type)) )
202 {
203 put_page(page);
204 rc = 0;
205 }
207 return rc;
208 }
210 static inline int page_is_removable(struct page_info *page)
211 {
212 return ((page->count_info & PGC_count_mask) == 1);
213 }
215 extern void synchronise_pagetables(unsigned long cpu_mask);
217 /* XXX don't know what this is for */
218 typedef struct {
219 void (*enable)(struct domain *);
220 void (*disable)(struct domain *);
221 } vm_assist_info_t;
222 extern vm_assist_info_t vm_assist_info[];
224 #define share_xen_page_with_guest(p, d, r) do { } while (0)
225 #define share_xen_page_with_privileged_guests(p, r) do { } while (0)
227 extern unsigned long frame_table_size;
229 /* hope that accesses to this will fail spectacularly */
230 #define machine_to_phys_mapping ((u32 *)-1UL)
232 extern int update_grant_va_mapping(unsigned long va,
233 unsigned long val,
234 struct domain *,
235 struct vcpu *);
237 #define INVALID_MFN (~0UL)
238 #define PFN_TYPE_NONE 0
239 #define PFN_TYPE_RMA 1
240 #define PFN_TYPE_LOGICAL 2
241 #define PFN_TYPE_IO 3
242 #define PFN_TYPE_REMOTE 4
244 extern ulong pfn2mfn(struct domain *d, long pfn, int *type);
246 /* Arch-specific portion of memory_op hypercall. */
247 long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg);
249 /* XXX implement me? */
250 #define set_gpfn_from_mfn(mfn, pfn) do { } while (0)
251 /* XXX only used for debug print right now... */
252 #define get_gpfn_from_mfn(mfn) (mfn)
254 static inline unsigned long gmfn_to_mfn(struct domain *d, unsigned long gmfn)
255 {
256 return pfn2mfn(d, gmfn, NULL);
257 }
259 #define mfn_to_gmfn(_d, mfn) (mfn)
261 extern int allocate_rma(struct domain *d, unsigned int order_pages);
262 extern uint allocate_extents(struct domain *d, uint nrpages, uint rma_nrpages);
263 extern void free_extents(struct domain *d);
265 extern int steal_page(struct domain *d, struct page_info *page,
266 unsigned int memflags);
268 #endif