Message ID | 20110427012617.36fdc6d7.takuya.yoshikawa@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 04/26/2011 07:26 PM, Takuya Yoshikawa wrote: > On Tue, 26 Apr 2011 17:54:24 +0300 > Avi Kivity<avi@redhat.com> wrote: > > > Please post a simple patch that uses two get_user()s for that case > > (64-bit pte on 32-bit host). Then work with the x86 tree to see if > > they'll accept 64-bit get_user(), and once they do, we can go back to a > > simple get_user() again. > > > > I made a patch which seems to reflect what you said! > If this kind of fix is OK with you, I'll test on both x86_32 and x86_64, > and send the patch with some changelog tomorrow. > Yes, that looks right.
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index a32a1c8..1e44969 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) return access; } +static int FNAME(read_gpte)(pt_element_t *pte, pt_element_t __user *ptep_user) +{ +#if defined(CONFIG_X86_32) && (PTTYPE == 64) + u32 *p = (u32 *)pte; + u32 __user *p_user = (u32 __user *)ptep_user; + + if (get_user(*p, p_user)) + return -EFAULT; + return get_user(*(p + 1), p_user + 1); +#else + return get_user(*pte, ptep_user); +#endif +} + /* * Fetch a guest pte for a guest virtual address */ @@ -185,7 +199,7 @@ walk: } ptep_user = (pt_element_t __user *)((void *)host_addr + offset); - if (get_user(pte, ptep_user)) { + if (FNAME(read_gpte)(&pte, ptep_user)) { present = false; break; }