The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [133/165] KVM: MMU: Remove user access when allowing kernel access to gpte.w=0 page
@ 2010-07-30 17:16 Greg KH
  0 siblings, 0 replies; only message in thread
From: Greg KH @ 2010-07-30 17:16 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: stable-review, torvalds, akpm, alan, Avi Kivity

2.6.32-stable review patch.  If anyone has any objections, please let us know.

------------------

If cr0.wp=0, we have to allow the guest kernel access to a page with pte.w=0.
We do that by setting spte.w=1, since the host cr0.wp must remain set so the
host can write protect pages.  Once we allow write access, we must remove
user access otherwise we mistakenly allow the user to write the page.

Reviewed-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
(cherry picked from commit 69325a122580d3a7b26589e8efdd6663001c3297)
---
 arch/x86/kvm/mmu.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1843,6 +1843,9 @@ static int set_spte(struct kvm_vcpu *vcp
 
 		spte |= PT_WRITABLE_MASK;
 
+		if (!tdp_enabled && !(pte_access & ACC_WRITE_MASK))
+			spte &= ~PT_USER_MASK;
+
 		/*
 		 * Optimization: for pte sync, if spte was writable the hash
 		 * lookup is unnecessary (and expensive). Write protection



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-07-30 17:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-30 17:16 [133/165] KVM: MMU: Remove user access when allowing kernel access to gpte.w=0 page Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox