All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Lai Jiangshan <jiangshan.ljs@antgroup.com>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	 Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org,  "H. Peter Anvin" <hpa@zytor.com>,
	kvm@vger.kernel.org
Subject: Re: [PATCH 2/2] KVM: x86/mmu: KVM: x86/mmu: Skip unsync when large pages are allowed
Date: Thu, 12 Mar 2026 10:22:46 -0700	[thread overview]
Message-ID: <abL2Zuy_gOQin-7w@google.com> (raw)
In-Reply-To: <abLy7cEDz7VlWtWS@google.com>

On Thu, Mar 12, 2026, Sean Christopherson wrote:
> On Fri, Jan 23, 2026, Lai Jiangshan wrote:
> This is what I have locally, please holler if you object to landing the code
> after the write-tracked check.
> 
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 363967a17069..3d0e0c1b5332 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -2940,6 +2940,15 @@ int mmu_try_to_unsync_pages(struct kvm *kvm, const struct kvm_memory_slot *slot,
>         if (kvm_gfn_is_write_tracked(kvm, slot, gfn))
>                 return -EPERM;
>  
> +       /*
> +        * Only 4KiB mappings can become unsync, and KVM disallows hugepages
> +        * for unsync gfns.  Upper-level gPTEs (leaf or non-leaf) are always
> +        * write-protected (see above), thus if the gfn can be mapped with a
> +        * hugepage and isn't write-tracked, it can't be unsync.

Gah, I swapped the ordering of who is doing what.  The comment should be this:

	/*
	 * Only 4KiB mappings can become unsync, and KVM disallows hugepages
	 * when accounting 4KiB shadow pages.  Upper-level gPTEs are always
	 * write-protected (see above), thus if the gfn can be mapped with a
	 * hugepage and isn't write-tracked, it can't have a shadow page.
	 */
	if (!lpage_info_slot(gfn, slot, PG_LEVEL_2M)->disallow_lpage)
		return 0;

> +        */
> +       if (!lpage_info_slot(gfn, slot, PG_LEVEL_2M)->disallow_lpage)
> +               return 0;
> +
>         /*
>          * The page is not write-tracked, mark existing shadow pages unsync
>          * unless KVM is synchronizing an unsync SP.  In that case, KVM must
> 
> 
> >  	/*
> >  	 * Force write-protection if the page is being tracked.  Note, the page
> >  	 * track machinery is used to write-protect upper-level shadow pages,
> > -- 
> > 2.19.1.6.gb485710b
> > 

  reply	other threads:[~2026-03-12 17:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-23  9:03 [PATCH 1/2] KVM: x86/mmu: Don't check old SPTE permissions when trying to unsync Lai Jiangshan
2026-01-23  9:03 ` [PATCH 2/2] KVM: x86/mmu: KVM: x86/mmu: Skip unsync when large pages are allowed Lai Jiangshan
2026-03-12 17:07   ` Sean Christopherson
2026-03-12 17:22     ` Sean Christopherson [this message]
2026-03-12 17:35 ` [PATCH 1/2] KVM: x86/mmu: Don't check old SPTE permissions when trying to unsync Sean Christopherson
2026-04-03 15:13 ` Sean Christopherson

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=abL2Zuy_gOQin-7w@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jiangshan.ljs@antgroup.com \
    --cc=jiangshanlai@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=tglx@kernel.org \
    --cc=x86@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 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.