All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH 2/3] KVM: MMU: Remove user access when allowing kernel access to gpte.w=0 page
Date: Thu, 27 May 2010 20:07:01 +0800	[thread overview]
Message-ID: <4BFE6065.9020901@cn.fujitsu.com> (raw)
In-Reply-To: <1274961006-19413-3-git-send-email-avi@redhat.com>



Avi Kivity wrote:
> 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.
> 

Yeah, it's really a nice way :-)

Reviewed-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>

> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  arch/x86/kvm/mmu.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 39dd8d3..56f8c3c 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -1894,6 +1894,9 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
>  
>  		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

  reply	other threads:[~2010-05-27 12:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27 11:50 [PATCH 0/3] Fix cr0.wp=0 emulation Avi Kivity
2010-05-27 11:50 ` [PATCH 1/3] KVM: MMU: Allow spte.w=1 for gpte.w=0 and cr0.wp=0 only in shadow mode Avi Kivity
2010-05-27 11:50 ` [PATCH 2/3] KVM: MMU: Remove user access when allowing kernel access to gpte.w=0 page Avi Kivity
2010-05-27 12:07   ` Xiao Guangrong [this message]
2010-05-27 11:50 ` [PATCH 3/3] KVM: MMU: Document cr0.wp emulation 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=4BFE6065.9020901@cn.fujitsu.com \
    --to=xiaoguangrong@cn.fujitsu.com \
    --cc=avi@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.