linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Sean Christopherson" <sean.j.christopherson@intel.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: Manually flush collapsible SPTEs only when toggling flags
Date: Tue, 17 Sep 2019 15:33:53 +0200	[thread overview]
Message-ID: <47331a39-7f74-661c-b248-266eec420efa@redhat.com> (raw)
In-Reply-To: <20190911191952.31126-1-sean.j.christopherson@intel.com>

On 11/09/19 21:19, Sean Christopherson wrote:
> Zapping collapsible sptes, a.k.a. 4k sptes that can be promoted into a
> large page, is only necessary when changing only the dirty logging flag
> of a memory region.  If the memslot is also being moved, then all sptes
> for the memslot are zapped when it is invalidated.  When a memslot is
> being created, it is impossible for there to be existing dirty mappings,
> e.g. KVM can have MMIO sptes, but not present, and thus dirty, sptes.
> 
> Note, the comment and logic are shamelessly borrowed from MIPS's version
> of kvm_arch_commit_memory_region().
> 
> Fixes: 3ea3b7fa9af06 ("kvm: mmu: lazy collapse small sptes into large sptes")
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  arch/x86/kvm/x86.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index b4cfd786d0b6..70e82e8f5c41 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -9635,8 +9635,13 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
>  	 * Scan sptes if dirty logging has been stopped, dropping those
>  	 * which can be collapsed into a single large-page spte.  Later
>  	 * page faults will create the large-page sptes.
> +	 *
> +	 * There is no need to do this in any of the following cases:
> +	 * CREATE:	No dirty mappings will already exist.
> +	 * MOVE/DELETE:	The old mappings will already have been cleaned up by
> +	 *		kvm_arch_flush_shadow_memslot()
>  	 */
> -	if ((change != KVM_MR_DELETE) &&
> +	if (change == KVM_MR_FLAGS_ONLY &&
>  		(old->flags & KVM_MEM_LOG_DIRTY_PAGES) &&
>  		!(new->flags & KVM_MEM_LOG_DIRTY_PAGES))
>  		kvm_mmu_zap_collapsible_sptes(kvm, new);
> 

Queued, thanks.

Paolo

      reply	other threads:[~2019-09-17 13:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11 19:19 [PATCH] KVM: x86: Manually flush collapsible SPTEs only when toggling flags Sean Christopherson
2019-09-17 13:33 ` Paolo Bonzini [this message]

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=47331a39-7f74-661c-b248-266eec420efa@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.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).