Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758906Ab0G3RUV (ORCPT ); Fri, 30 Jul 2010 13:20:21 -0400 Received: from kroah.org ([198.145.64.141]:52126 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758211Ab0G3RT7 (ORCPT ); Fri, 30 Jul 2010 13:19:59 -0400 X-Mailbox-Line: From gregkh@clark.site Fri Jul 30 10:15:11 2010 Message-Id: <20100730171511.707283543@clark.site> User-Agent: quilt/0.48-11.2 Date: Fri, 30 Jul 2010 10:16:01 -0700 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: stable-review@kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Avi Kivity Subject: [133/165] KVM: MMU: Remove user access when allowing kernel access to gpte.w=0 page In-Reply-To: <20100730171550.GA1299@kroah.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1249 Lines: 35 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 Signed-off-by: Avi Kivity (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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/