On Mon, Jun 10, 2024 at 2:09 AM Edgecombe, Rick P <rick.p.edgecombe@xxxxxxxxx> wrote: > Agreed that this is less TDX specific and it means that this part of the generic > MMU code doesn't need to know that the mirror/direct matches to private vs > shared. I don't love that it has such a complicated conditional for the normal > VM case, though. Just for readability. > > 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... > 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. Paolo