From patchwork Wed Apr 27 22:08:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 737841 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 p3RM8kPu027905 for ; Wed, 27 Apr 2011 22:08:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754217Ab1D0WIn (ORCPT ); Wed, 27 Apr 2011 18:08:43 -0400 Received: from mail-pw0-f46.google.com ([209.85.160.46]:50447 "EHLO mail-pw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752349Ab1D0WIl (ORCPT ); Wed, 27 Apr 2011 18:08:41 -0400 Received: by pwi15 with SMTP id 15so920998pwi.19 for ; Wed, 27 Apr 2011 15:08:41 -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=VuOukE7c9fJC5ZQO/Z8Hup5dVhIxyyGsTAUdD8RvTOo=; b=MRplaxyGIAe6C1ed8EVlDjhSymErCvXUxMOYAuRKr4E4mM2+pznre/Rn7EwVaqZVpW JhGIMGZxSUdzB3BKSDHrRCoxCR/V5d4aC7NS7o0/AnaF0EwngHAc7Mmoy+0cFP26b2jk ++S6lSX8Y4FbFSUcSoGiFqCJtoTTG/lWd0JKo= 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=UyGxmIAzs/yXHUhdSPHpnw7zdbbadOae5j3msthEQjDyLemFa8YLj4/IGz8c4mU/8R AhwVzMe3PZ3M4r9TKx6tTGYuyLORcaTRRjypg0Wf1lY6BiEtOjq0L1cQbJ3BkYDfytMS 1NYcFq/lGXtdxwIec8DVb7rA6Ka7PtGzc7iAg= Received: by 10.68.34.38 with SMTP id w6mr2950789pbi.26.1303942120968; Wed, 27 Apr 2011 15:08:40 -0700 (PDT) Received: from amd (s198099.dynamic.ppp.asahi-net.or.jp [220.157.198.99]) by mx.google.com with ESMTPS id b9sm792702pba.86.2011.04.27.15.08.38 (version=SSLv3 cipher=OTHER); Wed, 27 Apr 2011 15:08:39 -0700 (PDT) Date: Thu, 28 Apr 2011 07:08:36 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: jan.kiszka@web.de, kvm@vger.kernel.org Subject: [PATCH 1/1] KVM: MMU: Fix 64-bit paging breakage on x86_32 Message-Id: <20110428070836.4099477c.takuya.yoshikawa@gmail.com> In-Reply-To: <20110428070238.ba6e67aa.takuya.yoshikawa@gmail.com> References: <20110428070238.ba6e67aa.takuya.yoshikawa@gmail.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]); Wed, 27 Apr 2011 22:08:47 +0000 (UTC) From: Takuya Yoshikawa 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 Reported-by: Jan Kiszka --- 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 652d56c..7d36ac9 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 (unlikely(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 (unlikely(get_user(pte, ptep_user))) { + if (unlikely(FNAME(read_gpte)(&pte, ptep_user))) { present = false; break; }