diff options
author | Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> | 2011-06-30 12:37:24 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-07-12 06:16:44 -0400 |
commit | 3c8c652ae4c984a950d0672597085db866509914 (patch) | |
tree | fd7e197f05c178a1311147dd292356fc217cdf44 /arch/x86/kvm | |
parent | 92c1c1e85bdd72b41f9fd39b9d43d4b3c146d02d (diff) |
KVM: MMU: Introduce is_last_gpte() to clean up walk_addr_generic()
Suggested by Ingo and Avi.
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/paging_tmpl.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 9c0afba1ab8..1e1c2444cef 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h | |||
@@ -113,6 +113,24 @@ static unsigned FNAME(gpte_access)(struct kvm_vcpu *vcpu, pt_element_t gpte) | |||
113 | return access; | 113 | return access; |
114 | } | 114 | } |
115 | 115 | ||
116 | static bool FNAME(is_last_gpte)(struct guest_walker *walker, | ||
117 | struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, | ||
118 | pt_element_t gpte) | ||
119 | { | ||
120 | if (walker->level == PT_PAGE_TABLE_LEVEL) | ||
121 | return true; | ||
122 | |||
123 | if ((walker->level == PT_DIRECTORY_LEVEL) && is_large_pte(gpte) && | ||
124 | (PTTYPE == 64 || is_pse(vcpu))) | ||
125 | return true; | ||
126 | |||
127 | if ((walker->level == PT_PDPE_LEVEL) && is_large_pte(gpte) && | ||
128 | (mmu->root_level == PT64_ROOT_LEVEL)) | ||
129 | return true; | ||
130 | |||
131 | return false; | ||
132 | } | ||
133 | |||
116 | /* | 134 | /* |
117 | * Fetch a guest pte for a guest virtual address | 135 | * Fetch a guest pte for a guest virtual address |
118 | */ | 136 | */ |
@@ -221,13 +239,7 @@ retry_walk: | |||
221 | 239 | ||
222 | walker->ptes[walker->level - 1] = pte; | 240 | walker->ptes[walker->level - 1] = pte; |
223 | 241 | ||
224 | if ((walker->level == PT_PAGE_TABLE_LEVEL) || | 242 | if (FNAME(is_last_gpte)(walker, vcpu, mmu, pte)) { |
225 | ((walker->level == PT_DIRECTORY_LEVEL) && | ||
226 | is_large_pte(pte) && | ||
227 | (PTTYPE == 64 || is_pse(vcpu))) || | ||
228 | ((walker->level == PT_PDPE_LEVEL) && | ||
229 | is_large_pte(pte) && | ||
230 | mmu->root_level == PT64_ROOT_LEVEL)) { | ||
231 | int lvl = walker->level; | 243 | int lvl = walker->level; |
232 | gpa_t real_gpa; | 244 | gpa_t real_gpa; |
233 | gfn_t gfn; | 245 | gfn_t gfn; |