From: Takuya Yoshikawa Subject: Re: [PATCH 1/1 v2] KVM: MMU: Optimize guest page table walk Date: Wed, 27 Apr 2011 01:26:17 +0900 Message-ID: <20110427012617.36fdc6d7.takuya.yoshikawa@gmail.com> References: <20110422003222.9d08aee3.takuya.yoshikawa@gmail.com> <20110422003444.5b3a876a.takuya.yoshikawa@gmail.com> <4DB52B1B.5080407@web.de> <20110425173215.740417ae.yoshikawa.takuya@oss.ntt.co.jp> <4DB53BA8.60401@web.de> <20110426135035.5f569397.yoshikawa.takuya@oss.ntt.co.jp> <4DB66791.50403@web.de> <20110426234034.ab2ed524.takuya.yoshikawa@gmail.com> <4DB6DCA0.1000303@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Jan Kiszka , Takuya Yoshikawa , mtosatti@redhat.com, kvm@vger.kernel.org, xiaoguangrong@cn.fujitsu.com, Joerg.Roedel@amd.com To: Avi Kivity Return-path: Received: from mail-pv0-f174.google.com ([74.125.83.174]:53654 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757346Ab1DZQ0W (ORCPT ); Tue, 26 Apr 2011 12:26:22 -0400 Received: by pvg12 with SMTP id 12so533029pvg.19 for ; Tue, 26 Apr 2011 09:26:22 -0700 (PDT) In-Reply-To: <4DB6DCA0.1000303@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, 26 Apr 2011 17:54:24 +0300 Avi Kivity 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. Thanks, Takuya --- 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 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; } -- 1.7.1