From: Takuya Yoshikawa <takuya.yoshikawa@gmail.com>
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
Date: Thu, 28 Apr 2011 07:08:36 +0900 [thread overview]
Message-ID: <20110428070836.4099477c.takuya.yoshikawa@gmail.com> (raw)
In-Reply-To: <20110428070238.ba6e67aa.takuya.yoshikawa@gmail.com>
From: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
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>
---
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;
}
--
1.7.1
next prev parent reply other threads:[~2011-04-27 22:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-27 22:02 [PATCH 0/1] KVM: MMU: Fix 64-bit paging breakage on x86_32 Takuya Yoshikawa
2011-04-27 22:08 ` Takuya Yoshikawa [this message]
2011-04-28 10:06 ` [PATCH 1/1] " Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110428070836.4099477c.takuya.yoshikawa@gmail.com \
--to=takuya.yoshikawa@gmail.com \
--cc=avi@redhat.com \
--cc=jan.kiszka@web.de \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox