From: Marcelo Tosatti <mtosatti@redhat.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
kvm@vger.kernel.org, Avi Kivity <avi@redhat.com>
Subject: Re: [PATCH 4/6] kvm: add host_writable parameter
Date: Fri, 16 Jul 2010 20:18:55 -0300 [thread overview]
Message-ID: <20100716231855.GA8946@amt.cnet> (raw)
In-Reply-To: <4C3FC030.2050301@cn.fujitsu.com>
On Fri, Jul 16, 2010 at 10:13:04AM +0800, Lai Jiangshan wrote:
> add host_writable parameter for some functions,
> no functionality changed, prepare for using RO pages.
>
>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> ---
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 0867ced..8ba9b0d 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -1861,7 +1861,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
> unsigned pte_access, int user_fault,
> int write_fault, int dirty, int level,
> gfn_t gfn, pfn_t pfn, bool speculative,
> - bool can_unsync, bool reset_host_protection)
> + bool can_unsync, bool host_writable)
> {
> u64 spte;
> int ret = 0;
> @@ -1888,8 +1888,10 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
> spte |= kvm_x86_ops->get_mt_mask(vcpu, gfn,
> kvm_is_mmio_pfn(pfn));
>
> - if (reset_host_protection)
> + if (host_writable)
> spte |= SPTE_HOST_WRITEABLE;
> + else
> + pte_access &= ~ACC_WRITE_MASK;
Two vcpus faulting the same address with different access type can
now race:
vcpu0 vcpu1
read fault write fault
gfn_to_pfn readonly
gfn_to_pfn write, break COW
set writable spte to COWed page
vcpu writes to page
set spte to original page
vcpu reads stale content
Should not instantiate a new spte if (pfn != spte_to_pfn(*sptep)), to
cause a refault.
next prev parent reply other threads:[~2010-07-17 1:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-16 2:13 [PATCH 4/6] kvm: add host_writable parameter Lai Jiangshan
2010-07-16 23:18 ` Marcelo Tosatti [this message]
2010-07-18 14:09 ` 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=20100716231855.GA8946@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
/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