lkml.org 
[lkml]   [2021]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] KVM: x86/mmu: Don't skip non-leaf SPTEs when zapping all SPTEs
On Thu, Aug 12, 2021, Sean Christopherson wrote:
> On Thu, Aug 12, 2021, Paolo Bonzini wrote:
> > On 12/08/21 07:07, Sean Christopherson wrote:
> > > @@ -739,8 +749,16 @@ static bool zap_gfn_range(struct kvm *kvm, struct kvm_mmu_page *root,
> > > gfn_t start, gfn_t end, bool can_yield, bool flush,
> > > bool shared)
> > > {
> > > + bool zap_all = (end == ZAP_ALL_END);
> > > struct tdp_iter iter;
> > > + /*
> > > + * Bound the walk at host.MAXPHYADDR, guest accesses beyond that will
> > > + * hit a #PF(RSVD) and never get to an EPT Violation/Misconfig / #NPF,
> > > + * and so KVM will never install a SPTE for such addresses.
> > > + */
> > > + end = min(end, 1ULL << (shadow_phys_bits - PAGE_SHIFT));
> >
> > Then zap_all need not have any magic value. You can use 0/-1ull, it's
> > readable enough. ZAP_ALL_END is also unnecessary here if you do:
> >
> > gfn_t max_gfn_host = 1ULL << (shadow_phys_bits - PAGE_SHIFT);
> > bool zap_all = (start == 0 && end >= max_gfn_host);
>
> Aha! Nice. I was both too clever and yet not clever enough.

And as a bonus, this also works for kvm_post_set_cr0(), which calls the common
kvm_zap_gfn_range() with 0 - ALL_ONES.

\
 
 \ /
  Last update: 2021-08-12 20:11    [W:0.041 / U:2.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site