diff options
author | Avi Kivity <avi@redhat.com> | 2010-07-13 07:27:04 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-08-01 23:40:40 -0400 |
commit | 32ef26a3598636be520abed90ed0c2f439d36bbe (patch) | |
tree | bf6cff9c68d5ed9116656dfb1f40d9bc8bae7ace /arch/x86/kvm | |
parent | 4a994358b919c3b14de61be5e30d9edc9089ba3f (diff) |
KVM: MMU: Add link_shadow_page() helper
To simplify the process of fetching an spte, add a helper that links
a shadow page to an spte.
Reviewed-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/mmu.c | 10 | ||||
-rw-r--r-- | arch/x86/kvm/paging_tmpl.h | 7 |
2 files changed, 12 insertions, 5 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 89d7a2cae53b..df3a7a79cce3 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -1482,6 +1482,16 @@ static void shadow_walk_next(struct kvm_shadow_walk_iterator *iterator) | |||
1482 | --iterator->level; | 1482 | --iterator->level; |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | static void link_shadow_page(u64 *sptep, struct kvm_mmu_page *sp) | ||
1486 | { | ||
1487 | u64 spte; | ||
1488 | |||
1489 | spte = __pa(sp->spt) | ||
1490 | | PT_PRESENT_MASK | PT_ACCESSED_MASK | ||
1491 | | PT_WRITABLE_MASK | PT_USER_MASK; | ||
1492 | *sptep = spte; | ||
1493 | } | ||
1494 | |||
1485 | static void kvm_mmu_page_unlink_children(struct kvm *kvm, | 1495 | static void kvm_mmu_page_unlink_children(struct kvm *kvm, |
1486 | struct kvm_mmu_page *sp) | 1496 | struct kvm_mmu_page *sp) |
1487 | { | 1497 | { |
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 1cea41cad069..36dc0749c878 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h | |||
@@ -309,7 +309,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, | |||
309 | { | 309 | { |
310 | unsigned access = gw->pt_access; | 310 | unsigned access = gw->pt_access; |
311 | struct kvm_mmu_page *sp; | 311 | struct kvm_mmu_page *sp; |
312 | u64 spte, *sptep = NULL; | 312 | u64 *sptep = NULL; |
313 | int direct; | 313 | int direct; |
314 | gfn_t table_gfn; | 314 | gfn_t table_gfn; |
315 | int r; | 315 | int r; |
@@ -395,10 +395,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, | |||
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | spte = __pa(sp->spt) | 398 | link_shadow_page(sptep, sp); |
399 | | PT_PRESENT_MASK | PT_ACCESSED_MASK | ||
400 | | PT_WRITABLE_MASK | PT_USER_MASK; | ||
401 | *sptep = spte; | ||
402 | } | 399 | } |
403 | 400 | ||
404 | return sptep; | 401 | return sptep; |