From: Sean Christopherson <seanjc@google.com>
To: Vipin Sharma <vipinsh@google.com>
Cc: David Matlack <dmatlack@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH v2 4/6] KVM: x86/mmu: Recover TDP MMU huge page mappings in-place instead of zapping
Date: Wed, 9 Oct 2024 10:35:50 -0700 [thread overview]
Message-ID: <Zwa-9mItmmiKeVsd@google.com> (raw)
In-Reply-To: <CAHVum0ffQFnu2-uGYCsxQJt4HxmC+dTKP=StzRJgHxajJ7tYoA@mail.gmail.com>
On Wed, Oct 09, 2024, Vipin Sharma wrote:
> On Fri, Aug 23, 2024 at 4:57 PM David Matlack <dmatlack@google.com> wrote:
> > +static u64 modify_spte_protections(u64 spte, u64 set, u64 clear)
> > {
> > bool is_access_track = is_access_track_spte(spte);
> >
> > if (is_access_track)
> > spte = restore_acc_track_spte(spte);
> >
> > - spte &= ~shadow_nx_mask;
> > - spte |= shadow_x_mask;
> > + spte = (spte | set) & ~clear;
>
> We should add a check here WARN_ON_ONCE(set & clear) because if both
> have a common bit set to 1 then the result will be different between:
> 1. spte = (spt | set) & ~clear
> 2. spte = (spt | ~clear) & set
>
> In the current form, 'clear' has more authority in the final value of spte.
KVM_MMU_WARN_ON(), overlapping @set and @clear is definitely something that should
be caught during development, i.e. we don't need to carry the WARN_ON_ONCE() in
production kernels
> > +u64 make_huge_spte(struct kvm *kvm, u64 small_spte, int level)
> > +{
> > + u64 huge_spte;
> > +
> > + if (KVM_BUG_ON(!is_shadow_present_pte(small_spte), kvm))
> > + return SHADOW_NONPRESENT_VALUE;
> > +
> > + if (KVM_BUG_ON(level == PG_LEVEL_4K, kvm))
> > + return SHADOW_NONPRESENT_VALUE;
> > +
>
> KVM_BUG_ON() is very aggressive. We should replace it with WARN_ON_ONCE()
I'm tempted to say KVM_MMU_WARN_ON() here too.
next prev parent reply other threads:[~2024-10-09 17:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 23:56 [PATCH v2 0/6] KVM: x86/mmu: Optimize TDP MMU huge page recovery during disable-dirty-log David Matlack
2024-08-23 23:56 ` [PATCH v2 1/6] KVM: x86/mmu: Drop @max_level from kvm_mmu_max_mapping_level() David Matlack
2024-08-23 23:56 ` [PATCH v2 2/6] KVM: x86/mmu: Batch TLB flushes when zapping collapsible TDP MMU SPTEs David Matlack
2024-08-23 23:56 ` [PATCH v2 3/6] KVM: x86/mmu: Refactor TDP MMU iter need resched check David Matlack
2024-10-31 0:04 ` Sean Christopherson
2024-08-23 23:56 ` [PATCH v2 4/6] KVM: x86/mmu: Recover TDP MMU huge page mappings in-place instead of zapping David Matlack
2024-10-09 16:23 ` Vipin Sharma
2024-10-09 17:35 ` Sean Christopherson [this message]
2024-10-09 20:21 ` Vipin Sharma
2024-10-30 23:42 ` Sean Christopherson
2024-11-01 20:37 ` Vipin Sharma
2024-11-04 22:39 ` Sean Christopherson
2024-08-23 23:56 ` [PATCH v2 5/6] KVM: x86/mmu: Rename make_huge_page_split_spte() to make_small_spte() David Matlack
2024-08-23 23:56 ` [PATCH v2 6/6] KVM: x86/mmu: WARN if huge page recovery triggered during dirty logging David Matlack
2024-10-31 20:00 ` [PATCH v2 0/6] KVM: x86/mmu: Optimize TDP MMU huge page recovery during disable-dirty-log Sean Christopherson
2024-11-05 5:56 ` 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=Zwa-9mItmmiKeVsd@google.com \
--to=seanjc@google.com \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=vipinsh@google.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.