kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Arcangeli <aarcange@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: Christoffer Dall <c.dall@virtualopensystems.com>,
	android-virt@lists.cs.columbia.edu, kvm@vger.kernel.org,
	Marc Zyngier <marc.zyngier@arm.com>
Subject: Re: [PATCH v8 13/15] ARM: KVM: Handle guest faults in KVM
Date: Tue, 19 Jun 2012 12:41:14 +0200	[thread overview]
Message-ID: <20120619104114.GM4633@redhat.com> (raw)
In-Reply-To: <4FE04716.6090202@redhat.com>

On Tue, Jun 19, 2012 at 12:32:06PM +0300, Avi Kivity wrote:
> On 06/19/2012 01:20 AM, Christoffer Dall wrote:
> > On Mon, Jun 18, 2012 at 9:45 AM, Avi Kivity <avi@redhat.com> wrote:
> >> On 06/15/2012 10:09 PM, Christoffer Dall wrote:
> >>> From: Christoffer Dall <cdall@cs.columbia.edu>
> >>>
> >>> Handles the guest faults in KVM by mapping in corresponding user pages
> >>> in the 2nd stage page tables.
> >>>
> >>> Introduces new ARM-specific kernel memory types, PAGE_KVM_GUEST and
> >>> pgprot_guest variables used to map 2nd stage memory for KVM guests.
> >>>
> >>> Leverages MMU notifiers on KVM/ARM by supporting the kvm_unmap_hva() operation,
> >>> where we remove the HVA from the 2nd stage translation. All other KVM MMU
> >>> notifierhooks are NOPs.
> >>
> >> I think you must at least support change_pte (possibly by unmapping).
> >> Andrea?
> >>
> > hmmm, at least for KSM support we need to support change_pte (are
> > there other callers for this type of memory?)
> > 
> > It's not trivial I guess, since we would need to support COW and
> > thereby stage-2 permission faults... Marc, right?
> 
> As I mentioned, you can support change_pte by unmapping.  This will
> cause ksm to be ineffective (pages will only be shared if the guest
> doesn't touch them at all), but it's enough to get started.

The main reason change_pte initially was required for KSM to be
effective was because gup_fast was called with write=1
unconditionally. change_pte was also responsible to set the spte
readonly. But that should have been fixed now on x86, so KSM should be
effective even despite lack of change_pte on x86.

If the KVM page fault is calling gfn_to_pfn_async(write=0/1) depending
if the vmexit was caused by a write or read access (instead of
gfn_to_pfn which still has the unconditional write=1), and in turn
it's forced to sete the spte readonly after calling
gfn_to_pfn_async(write=0), change_pte is still useful but it's only a
worthwhile optimization to avoid a spte read fault after every KSM
page merged, it's not strictly required for KSM effectiveness anymore.

In short if ARM does the right thing with regard of KVM read faults
passed to gup_fast(write=0) and setting the spte readonly, all should
work good with KSM (even if not as optimal as with change_pte).

  reply	other threads:[~2012-06-19 10:41 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-15 19:06 [PATCH v8 00/15] KVM/ARM Implementation Christoffer Dall
2012-06-15 19:06 ` [PATCH v8 01/15] ARM: add mem_type prot_pte accessor Christoffer Dall
2012-06-15 19:07 ` [PATCH v8 02/15] KVM: use KVM_CAP_IRQ_ROUTING to protect the routing related code Christoffer Dall
2012-06-18 13:06   ` Avi Kivity
2012-06-15 19:07 ` [PATCH v8 03/15] KVM: Introduce __KVM_HAVE_IRQ_LINE Christoffer Dall
2012-06-18 13:07   ` Avi Kivity
2012-06-15 19:07 ` [PATCH v8 04/15] KVM: Guard mmu_notifier specific code with CONFIG_MMU_NOTIFIER Christoffer Dall
2012-06-18 13:08   ` Avi Kivity
2012-06-18 17:47     ` Christoffer Dall
2012-06-19  8:37       ` Avi Kivity
2012-06-28 21:28   ` Marcelo Tosatti
2012-06-15 19:07 ` [PATCH v8 05/15] ARM: KVM: Initial skeleton to compile KVM support Christoffer Dall
2012-06-15 19:07 ` [PATCH v8 06/15] ARM: KVM: Hypervisor identity mapping Christoffer Dall
2012-06-18 13:12   ` Avi Kivity
2012-06-18 17:55     ` Christoffer Dall
2012-06-19  8:38       ` Avi Kivity
2012-06-15 19:07 ` [PATCH v8 07/15] ARM: KVM: Hypervisor inititalization Christoffer Dall
2012-06-28 22:35   ` Marcelo Tosatti
2012-06-28 22:53     ` Christoffer Dall
2012-06-29  1:07       ` Marcelo Tosatti
2012-06-15 19:08 ` [PATCH v8 08/15] ARM: KVM: Module unloading support Christoffer Dall
2012-06-15 19:08 ` [PATCH v8 09/15] ARM: KVM: Memory virtualization setup Christoffer Dall
2012-06-21 12:29   ` Gleb Natapov
2012-06-21 19:48     ` Christoffer Dall
2012-06-28 22:34   ` Marcelo Tosatti
2012-06-28 22:51     ` Christoffer Dall
2012-06-15 19:08 ` [PATCH v8 10/15] ARM: KVM: Inject IRQs and FIQs from userspace Christoffer Dall
2012-06-18 13:32   ` Avi Kivity
2012-06-18 20:56     ` Christoffer Dall
2012-06-19  8:49       ` Avi Kivity
2012-06-20  3:17         ` Christoffer Dall
2012-06-15 19:08 ` [PATCH v8 11/15] ARM: KVM: World-switch implementation Christoffer Dall
2012-06-18 13:41   ` Avi Kivity
2012-06-18 22:05     ` Christoffer Dall
2012-06-19  9:16       ` Avi Kivity
2012-06-20  3:27         ` Christoffer Dall
2012-06-20  4:40           ` Christoffer Dall
2012-06-21  8:13             ` Avi Kivity
2012-06-21 17:54               ` Christoffer Dall
2012-07-02 13:07                 ` Avi Kivity
2012-06-15 19:08 ` [PATCH v8 12/15] ARM: KVM: Emulation framework and CP15 emulation Christoffer Dall
2012-06-15 19:09 ` [PATCH v8 13/15] ARM: KVM: Handle guest faults in KVM Christoffer Dall
2012-06-18 13:45   ` Avi Kivity
2012-06-18 22:20     ` Christoffer Dall
2012-06-19  9:32       ` Avi Kivity
2012-06-19 10:41         ` Andrea Arcangeli [this message]
2012-06-20 15:13           ` Christoffer Dall
2012-06-20 17:49             ` Andrea Arcangeli
2012-06-15 19:09 ` [PATCH v8 14/15] ARM: KVM: Handle I/O aborts Christoffer Dall
2012-06-18 13:48   ` Avi Kivity
2012-06-18 22:28     ` Christoffer Dall
2012-06-15 19:09 ` [PATCH v8 15/15] ARM: KVM: Guest wait-for-interrupts (WFI) support Christoffer Dall
2012-06-28 21:49 ` [PATCH v8 00/15] KVM/ARM Implementation Marcelo Tosatti
2012-06-28 22:44   ` Christoffer Dall

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=20120619104114.GM4633@redhat.com \
    --to=aarcange@redhat.com \
    --cc=android-virt@lists.cs.columbia.edu \
    --cc=avi@redhat.com \
    --cc=c.dall@virtualopensystems.com \
    --cc=kvm@vger.kernel.org \
    --cc=marc.zyngier@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).