lkml.org 
[lkml]   [2022]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v10 052/108] KVM: x86/tdp_mmu: Ignore unsupported mmu operation on private GFNs
Date
On Friday, December 16, 2022 7:21 AM, Yamahata, Isaku wrote:
> > > + /*
> > > + * First TDX generation doesn't support clearing dirty bit,
> > > + * since there's no secure EPT API to support it. It is a
> > > + * bug to reach here for TDX guest.
> > > + */
> > > + if (WARN_ON_ONCE(!kvm_arch_dirty_log_supported(kvm)))
> > > + return false;
> > > +
> >
> > It might not be a good choice to intercept everywhere in kvm_mmu just
> > as tdx doesn't support it. I'm thinking maybe we could do the check in
> > tdx.c, which is much simpler. For example:
> >
> > @@ -2592,6 +2605,12 @@ static void
> tdx_handle_changed_private_spte(struct kvm *kvm,
> > lockdep_assert_held(&kvm->mmu_lock);
> >
> > if (change->new.is_present) {
> > + /* Only flags change. This isn't supported currently. */
> > + KVM_BUG_ON(change->old.is_present, kvm);
> >
> > Then we can have kvm_arch_dirty_log_supported completely removed.
>
> Do you mean WARN_ON_ONCE()? If so, they can be removed from this
> patches because the code should be blocked by "if
> (!kvm_arch_dirty_log_supported(kvm))" at the caller.
>

As you also mentioned in the comment "It is a bug to reach here", we could keep using KVM_BUG_ON. The suggestion is that we don't need to add such checks in all the callers as it is more complicated (and error-prone) to consider all of them.
Why not let callers run into tdx_handle_changed_private_spte to do the check (at this only place)? From what I understand, we don’t support an spte change with flags update only for this version. This would be much simpler.
\
 
 \ /
  Last update: 2022-12-19 14:16    [W:0.232 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site