All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
Cc: kvm-devel <kvm@vger.kernel.org>, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: KVM: MMU: drop read-only large sptes when creating lower level sptes
Date: Tue, 25 Feb 2014 19:52:49 -0300	[thread overview]
Message-ID: <20140225225249.GA16552@amt.cnet> (raw)
In-Reply-To: <1D2584DA-BA76-4065-9153-9B765F16AF29@linux.vnet.ibm.com>

On Tue, Feb 25, 2014 at 11:11:19PM +0800, Xiao Guangrong wrote:
> 
> On Feb 25, 2014, at 9:13 PM, Marcelo Tosatti <mtosatti@redhat.com> wrote:
> 
> > On Tue, Feb 25, 2014 at 11:30:37AM +0800, Xiao Guangrong wrote:
> >> On 02/25/2014 12:59 AM, Marcelo Tosatti wrote:
> >>> 
> >>> Read-only large sptes can be created due to read-only faults as
> >>> follows:
> >>> 
> >>> - QEMU pagetable entry that maps guest memory is read-only 
> >>> due to COW.
> >>> - Guest read faults such memory, COW is not broken, because
> >>> it is a read-only fault.
> >>> - Enable dirty logging, large spte not nuked because it is read-only.
> >>> - Write-fault on such memory causes guest to loop endlessly
> >>> (which must go down to level 1 because dirty logging is enabled).
> >> 
> >> Hi Marcelo,
> >> 
> >> It surprised me that the large-readonly mapping was not dropped
> >> by mmu-notifer as this is write fault on readonly mapping in Qemu.
> >> Hmm... i missed something?
> > 
> > You mean COW was not broken by gup? (that is the problem, so a
> > read-only large spte is created).
> > 
> 
> I mean the final step that “Write-fault on such memory causes guest” should
> break the readonly QEMU pagetable entry and change it to writable, at that
> time, mmu-notifier should be called since the page’s permission has been
> changed.
> 
> After read the code more carefully, i figure the reason out that mmu-notifier
> is not called when the page can be reused. 

Well a transition from read-only host-pte to read-write host-pte does
not require the read-only spte to be upgraded immediatelly, right?
Permission is upgraded lazily.

> I am thinking whether it is
> reasonable:
> - anyway, the permission bits on the pre are changed, why not call
>  mmu-notifier->change_pte()?

It could, but lazy updates are better i suppose.

> - kvm and other users of mum-notifier need to check the permission
>  changing very carefully, that is really subtle, like the case fixed here.

Yes.

> - if we do proper prefetch when it happen, the addition page-fault can
>  be avoided, that is good for the performance.

Agree. 


  reply	other threads:[~2014-02-25 22:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-24 16:59 KVM: MMU: drop read-only large sptes when creating lower level sptes Marcelo Tosatti
2014-02-25  3:30 ` Xiao Guangrong
2014-02-25 13:13   ` Marcelo Tosatti
2014-02-25 15:11     ` Xiao Guangrong
2014-02-25 22:52       ` Marcelo Tosatti [this message]
2014-02-25  8:23 ` Paolo Bonzini

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=20140225225249.GA16552@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=xiaoguangrong.eric@gmail.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.