aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/paging_tmpl.h
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-05-30 07:21:51 -0400
committerAvi Kivity <avi@qumranet.com>2007-07-16 05:05:43 -0400
commitef0197e8d9273ad8fbfb1bbd30e46e42a32c79e8 (patch)
treea3fd2b5306b41cd18b47550e5269940b3321eb75 /drivers/kvm/paging_tmpl.h
parentd3d25b048b9c7e5c1c20918157a71df734f71766 (diff)
KVM: MMU: Simplify fetch() a little bit
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/paging_tmpl.h')
-rw-r--r--drivers/kvm/paging_tmpl.h34
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h
index 183d4ca9b315..e094a8ba17a8 100644
--- a/drivers/kvm/paging_tmpl.h
+++ b/drivers/kvm/paging_tmpl.h
@@ -241,6 +241,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
241{ 241{
242 hpa_t shadow_addr; 242 hpa_t shadow_addr;
243 int level; 243 int level;
244 u64 *shadow_ent;
244 u64 *prev_shadow_ent = NULL; 245 u64 *prev_shadow_ent = NULL;
245 pt_element_t *guest_ent = walker->ptep; 246 pt_element_t *guest_ent = walker->ptep;
246 247
@@ -257,13 +258,13 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
257 258
258 for (; ; level--) { 259 for (; ; level--) {
259 u32 index = SHADOW_PT_INDEX(addr, level); 260 u32 index = SHADOW_PT_INDEX(addr, level);
260 u64 *shadow_ent = ((u64 *)__va(shadow_addr)) + index;
261 struct kvm_mmu_page *shadow_page; 261 struct kvm_mmu_page *shadow_page;
262 u64 shadow_pte; 262 u64 shadow_pte;
263 int metaphysical; 263 int metaphysical;
264 gfn_t table_gfn; 264 gfn_t table_gfn;
265 unsigned hugepage_access = 0; 265 unsigned hugepage_access = 0;
266 266
267 shadow_ent = ((u64 *)__va(shadow_addr)) + index;
267 if (is_present_pte(*shadow_ent) || is_io_pte(*shadow_ent)) { 268 if (is_present_pte(*shadow_ent) || is_io_pte(*shadow_ent)) {
268 if (level == PT_PAGE_TABLE_LEVEL) 269 if (level == PT_PAGE_TABLE_LEVEL)
269 return shadow_ent; 270 return shadow_ent;
@@ -272,22 +273,8 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
272 continue; 273 continue;
273 } 274 }
274 275
275 if (level == PT_PAGE_TABLE_LEVEL) { 276 if (level == PT_PAGE_TABLE_LEVEL)
276 277 break;
277 if (walker->level == PT_DIRECTORY_LEVEL) {
278 if (prev_shadow_ent)
279 *prev_shadow_ent |= PT_SHADOW_PS_MARK;
280 FNAME(set_pde)(vcpu, *guest_ent, shadow_ent,
281 walker->inherited_ar,
282 walker->gfn);
283 } else {
284 ASSERT(walker->level == PT_PAGE_TABLE_LEVEL);
285 FNAME(set_pte)(vcpu, *guest_ent, shadow_ent,
286 walker->inherited_ar,
287 walker->gfn);
288 }
289 return shadow_ent;
290 }
291 278
292 if (level - 1 == PT_PAGE_TABLE_LEVEL 279 if (level - 1 == PT_PAGE_TABLE_LEVEL
293 && walker->level == PT_DIRECTORY_LEVEL) { 280 && walker->level == PT_DIRECTORY_LEVEL) {
@@ -310,6 +297,19 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
310 *shadow_ent = shadow_pte; 297 *shadow_ent = shadow_pte;
311 prev_shadow_ent = shadow_ent; 298 prev_shadow_ent = shadow_ent;
312 } 299 }
300
301 if (walker->level == PT_DIRECTORY_LEVEL) {
302 if (prev_shadow_ent)
303 *prev_shadow_ent |= PT_SHADOW_PS_MARK;
304 FNAME(set_pde)(vcpu, *guest_ent, shadow_ent,
305 walker->inherited_ar, walker->gfn);
306 } else {
307 ASSERT(walker->level == PT_PAGE_TABLE_LEVEL);
308 FNAME(set_pte)(vcpu, *guest_ent, shadow_ent,
309 walker->inherited_ar,
310 walker->gfn);
311 }
312 return shadow_ent;
313} 313}
314 314
315/* 315/*