debuggers.hg

view xen/include/asm-ia64/vmmu.h @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children 5c0bf00e371d
line source
2 /* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
3 /*
4 * vmmu.h: virtual memory management unit related APIs and data structure.
5 * Copyright (c) 2004, Intel Corporation.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18 * Place - Suite 330, Boston, MA 02111-1307 USA.
19 *
20 * Yaozu Dong (Eddie Dong) (Eddie.dong@intel.com)
21 */
23 #ifndef XEN_TLBthash_H
24 #define XEN_TLBthash_H
26 #define MAX_CCN_DEPTH (15) // collision chain depth
27 #define DEFAULT_VTLB_SZ (14) // 16K hash + 16K c-chain for VTLB
28 #define DEFAULT_VHPT_SZ (23) // 8M hash + 8M c-chain for VHPT
29 #define VTLB(v,_x) (v->arch.vtlb._x)
30 #define VHPT(v,_x) (v->arch.vhpt._x)
32 #ifndef __ASSEMBLY__
34 #include <xen/config.h>
35 #include <xen/types.h>
36 #include <public/xen.h>
37 #include <asm/tlb.h>
38 #include <asm/regionreg.h>
39 #include <asm/vmx_mm_def.h>
40 #include <asm/bundle.h>
42 enum {
43 ISIDE_TLB=0,
44 DSIDE_TLB=1
45 };
46 #endif /* __ASSEMBLY__ */
48 #define VTLB_PTE_P_BIT 0
49 #define VTLB_PTE_IO_BIT 60
50 #define VTLB_PTE_IO (1UL<<VTLB_PTE_IO_BIT)
51 #define VTLB_PTE_P (1UL<<VTLB_PTE_P_BIT)
53 #define ITIR_RV_MASK (((1UL<<32)-1)<<32 | 0x3)
54 #define PAGE_FLAGS_RV_MASK (0x2 | (0x3UL<<50)|(((1UL<<11)-1)<<53))
55 #define PAGE_FLAGS_AR_PL_MASK ((0x7UL<<9)|(0x3UL<<7))
57 #ifndef __ASSEMBLY__
58 typedef struct thash_data {
59 union {
60 struct {
61 u64 p : 1; // 0
62 u64 rv1 : 1; // 1
63 u64 ma : 3; // 2-4
64 u64 a : 1; // 5
65 u64 d : 1; // 6
66 u64 pl : 2; // 7-8
67 u64 ar : 3; // 9-11
68 u64 ppn : 38; // 12-49
69 u64 rv2 : 2; // 50-51
70 u64 ed : 1; // 52
71 u64 ig1 : 3; // 53-63
72 };
73 u64 page_flags;
74 }; // same for VHPT and TLB
76 union {
77 struct {
78 u64 rv3 : 2; // 0-1
79 u64 ps : 6; // 2-7
80 u64 key : 24; // 8-31
81 u64 rv4 : 32; // 32-63
82 };
83 u64 itir;
84 };
85 union {
86 struct { // For TLB
87 u64 ig2 : 12; // 0-11
88 u64 vpn : 49; // 12-60
89 u64 vrn : 3; // 61-63
90 };
91 u64 vadr;
92 u64 ifa;
93 struct { // For VHPT
94 u64 tag : 63; // 0-62
95 u64 ti : 1; // 63, invalid entry for VHPT
96 };
97 u64 etag; // extended tag for VHPT
98 };
99 union {
100 struct thash_data *next;
101 u64 rid; // only used in guest TR
102 // u64 tr_idx;
103 };
104 } thash_data_t;
106 #define INVALIDATE_VHPT_HEADER(hdata) \
107 { ((hdata)->page_flags)=0; \
108 ((hdata)->itir)=PAGE_SHIFT<<2; \
109 ((hdata)->etag)=1UL<<63; \
110 ((hdata)->next)=0;}
112 #define INVALIDATE_TLB_HEADER(hash) INVALIDATE_VHPT_HEADER(hash)
114 #define INVALIDATE_HASH_HEADER(hcb,hash) INVALIDATE_VHPT_HEADER(hash)
116 #define INVALID_VHPT(hdata) ((hdata)->ti)
117 #define INVALID_TLB(hdata) ((hdata)->ti)
118 #define INVALID_TR(hdata) (!(hdata)->p)
119 #define INVALID_ENTRY(hcb, hdata) INVALID_VHPT(hdata)
121 static inline u64 thash_translate(thash_data_t *hdata, u64 vadr)
122 {
123 int ps = hdata->ps;
124 return (hdata->ppn >> (ps - 12) << ps) | (vadr & ((1UL << ps) - 1));
125 }
127 typedef struct thash_cb {
128 /* THASH base information */
129 thash_data_t *hash; // hash table pointer, aligned at thash_sz.
130 u64 hash_sz; // size of above data.
131 void *cch_buf; // base address of collision chain.
132 u64 cch_sz; // size of above data.
133 u64 cch_free_idx; // index of free entry.
134 thash_data_t *cch_freelist;
135 PTA pta;
136 } thash_cb_t;
138 /*
139 * Allocate and initialize internal control data before service.
140 */
141 extern int thash_alloc(thash_cb_t *hcb, u64 sz, char *what);
143 extern void thash_free(thash_cb_t *hcb);
145 /*
146 * Insert an entry to hash table.
147 * NOTES:
148 * 1: TLB entry may be TR, TC or Foreign Map. For TR entry,
149 * itr[]/dtr[] need to be updated too.
150 * 2: Inserting to collision chain may trigger recycling if
151 * the buffer for collision chain is empty.
152 * 3: The new entry is inserted at the hash table.
153 * (I.e. head of the collision chain)
154 * 4: Return the entry in hash table or collision chain.
155 *
156 */
157 //extern void thash_insert(thash_cb_t *hcb, thash_data_t *entry, u64 va);
158 //extern void thash_tr_insert(thash_cb_t *hcb, thash_data_t *entry, u64 va, int idx);
159 extern int vtr_find_overlap(struct vcpu *vcpu, u64 va, u64 ps, int is_data);
161 /*
162 * Find and purge overlap entries in hash table and its collision chain.
163 * PARAS:
164 * 1: in: TLB format entry, rid:ps must be same with vrr[].
165 * rid, va & ps identify the address space for purge
166 * 2: section can be combination of TR, TC and FM. (thash_SECTION_XX)
167 * 3: cl means I side or D side.
168 * NOTES:
169 *
170 */
171 extern void thash_purge_entries(struct vcpu *v, u64 va, u64 ps);
172 extern void thash_purge_entries_remote(struct vcpu *v, u64 va, u64 ps);
173 extern int thash_purge_and_insert(struct vcpu *v, u64 pte, u64 itir, u64 ifa, int type);
175 /*
176 * Purge all TCs or VHPT entries including those in Hash table.
177 *
178 */
179 extern void thash_purge_all(struct vcpu *v);
181 /*
182 * Lookup the hash table and its collision chain to find an entry
183 * covering this address rid:va.
184 *
185 */
186 extern thash_data_t *vtlb_lookup(struct vcpu *v,u64 va,int is_data);
189 extern int init_domain_tlb(struct vcpu *v);
190 extern void free_domain_tlb(struct vcpu *v);
191 extern thash_data_t * vhpt_lookup(u64 va);
192 extern unsigned long fetch_code(struct vcpu *vcpu, u64 gip, IA64_BUNDLE *pbundle);
193 extern void emulate_io_inst(struct vcpu *vcpu, u64 padr, u64 ma, u64 iot);
194 extern void emulate_io_update(struct vcpu *vcpu, u64 word, u64 d, u64 d1);
195 extern int vhpt_enabled(struct vcpu *vcpu, uint64_t vadr, vhpt_ref_t ref);
196 extern void thash_vhpt_insert(struct vcpu *v, u64 pte, u64 itir, u64 ifa,
197 int type);
198 extern u64 guest_vhpt_lookup(u64 iha, u64 *pte);
199 extern int vhpt_access_rights_fixup(struct vcpu *v, u64 ifa, int is_data);
201 /*
202 * Purge machine tlb.
203 * INPUT
204 * rr: guest rr.
205 * va: only bits 0:60 is valid
206 * size: bits format (1<<size) for the address range to purge.
207 *
208 */
209 static inline void machine_tlb_purge(u64 va, u64 ps)
210 {
211 ia64_ptcl(va, ps << 2);
212 }
214 static inline void vmx_vcpu_set_tr (thash_data_t *trp, u64 pte, u64 itir, u64 va, u64 rid)
215 {
216 trp->page_flags = pte;
217 trp->itir = itir;
218 trp->vadr = va;
219 trp->rid = rid;
220 }
222 #endif /* __ASSEMBLY__ */
224 #endif /* XEN_TLBthash_H */