On Mon, 2024-06-10 at 11:23 +0200, Paolo Bonzini wrote: > > The previous versions checked kvm_gfn_shared_mask() more readily in various > > open > > coded spots. In this v2 we tried to reduce this and instead always rely on > > the "private" concept to switch between the roots in the generic code. I > > think > > it's arguably a little easier to understand if we stick to a single way of > > deciding which root to use. > > But there isn't any other place that relies on is_private, right? So... I meant the "private" concept in general, like triggering off of KVM_PROCESS_PRIVATE to use the mirror. > > > But I don't feel like any of these solutions discussed is perfectly clean. > > So > > I'm ok taking the benefits you prefer. I guess doing bitwise operations when > > possible is kind of the KVM way, haha. :) > > ... while I'm definitely guilty of that, :) it does seem the cleanest > option to use fault->addr to go from struct kvm_page_fault to the kind > of root. > > If you prefer, you can introduce a bool kvm_is_addr_direct(struct kvm > *kvm, gpa_t gpa), and use it here as kvm_is_addr_direct(kvm, > fault->addr). Maybe that's the best of both worlds. Yes, I think a helper will make it easier for non-TDX readers.