From patchwork Tue Apr 26 16:26:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 733282 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3QGR8j7016509 for ; Tue, 26 Apr 2011 16:27:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757378Ab1DZQ0s (ORCPT ); Tue, 26 Apr 2011 12:26:48 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding; bh=ljE25zVxVzChNF2Y+gSTXfyRIAhGEs2PPehNvGRYvlg=; b=nM6crjQV+TZmHDUA4DZGzXJVOMFK+ksM5ebXnwjHwIuUYjV902BUlBRBfbil81sdmP iPIg8muTvhmFqGR7JshdDds4oYQzZv8K7THH7eDZ4pWiBXSLomJRHjHqsvRjtJqeqKHr efFMfWDFqRD/YqGGysj+Dm97VvUcVzAH1mQRY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=VopJjyJhS5qdaK2+TEFqwHZEYA+Qe/AlhvbEvEUqMyKC+pS1pnQgXioqAZaHWnsuv1 RZFD7IrylOJwFtGEJTwuH7YYzjlAt+yHdlvwkdondfLTh29S7ZL5Jh1YpV0gGjYlLPiz ulCNSAoN5aKuJXH6NFQO4wZ7JVwyrKpQJpsLU= Received: by 10.68.69.43 with SMTP id b11mr1152595pbu.18.1303835182190; Tue, 26 Apr 2011 09:26:22 -0700 (PDT) Received: from amd (s198099.dynamic.ppp.asahi-net.or.jp [220.157.198.99]) by mx.google.com with ESMTPS id m7sm4634122pbd.33.2011.04.26.09.26.19 (version=SSLv3 cipher=OTHER); Tue, 26 Apr 2011 09:26:20 -0700 (PDT) Date: Wed, 27 Apr 2011 01:26:17 +0900 From: Takuya Yoshikawa To: Avi Kivity Cc: Jan Kiszka , Takuya Yoshikawa , mtosatti@redhat.com, kvm@vger.kernel.org, xiaoguangrong@cn.fujitsu.com, Joerg.Roedel@amd.com Subject: Re: [PATCH 1/1 v2] KVM: MMU: Optimize guest page table walk Message-Id: <20110427012617.36fdc6d7.takuya.yoshikawa@gmail.com> In-Reply-To: <4DB6DCA0.1000303@redhat.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> X-Mailer: Sylpheed 3.1.0beta2 (GTK+ 2.22.0; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 26 Apr 2011 16:27:09 +0000 (UTC) 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; }