diff options
author | Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> | 2011-04-27 18:08:36 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-05-22 08:39:58 -0400 |
commit | 8f74d8e16812d63639871b4e56409b08bdcb66fc (patch) | |
tree | 5004b63ab74194b615fc51c10528332e38a95348 /arch | |
parent | b74323dc2b7b5690d18bc7934b98e4665e778a7b (diff) |
KVM: MMU: Fix 64-bit paging breakage on x86_32
Fix regression introduced by
commit e30d2a170506830d5eef5e9d7990c5aedf1b0a51
KVM: MMU: Optimize guest page table walk
On x86_32, get_user() does not support 64-bit values and we fail to
build KVM at the point of 64-bit paging.
This patch fixes this by using get_user() twice for that condition.
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Reported-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/paging_tmpl.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 652d56c081f7..52450a6b784f 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h | |||
@@ -115,6 +115,20 @@ static unsigned FNAME(gpte_access)(struct kvm_vcpu *vcpu, pt_element_t gpte) | |||
115 | return access; | 115 | return access; |
116 | } | 116 | } |
117 | 117 | ||
118 | static int FNAME(read_gpte)(pt_element_t *pte, pt_element_t __user *ptep_user) | ||
119 | { | ||
120 | #if defined(CONFIG_X86_32) && (PTTYPE == 64) | ||
121 | u32 *p = (u32 *)pte; | ||
122 | u32 __user *p_user = (u32 __user *)ptep_user; | ||
123 | |||
124 | if (unlikely(get_user(*p, p_user))) | ||
125 | return -EFAULT; | ||
126 | return get_user(*(p + 1), p_user + 1); | ||
127 | #else | ||
128 | return get_user(*pte, ptep_user); | ||
129 | #endif | ||
130 | } | ||
131 | |||
118 | /* | 132 | /* |
119 | * Fetch a guest pte for a guest virtual address | 133 | * Fetch a guest pte for a guest virtual address |
120 | */ | 134 | */ |
@@ -185,7 +199,7 @@ walk: | |||
185 | } | 199 | } |
186 | 200 | ||
187 | ptep_user = (pt_element_t __user *)((void *)host_addr + offset); | 201 | ptep_user = (pt_element_t __user *)((void *)host_addr + offset); |
188 | if (unlikely(get_user(pte, ptep_user))) { | 202 | if (unlikely(FNAME(read_gpte)(&pte, ptep_user))) { |
189 | present = false; | 203 | present = false; |
190 | break; | 204 | break; |
191 | } | 205 | } |