On Wed, Mar 18, 2020 at 06:11:28PM +0100, Paolo Bonzini wrote: > On 18/03/20 18:02, Sean Christopherson wrote: > > So something like this? > > > > if (!nested_ept) > > kvm_mmu_new_cr3(vcpu, cr3, enable_ept || > > nested_cpu_has_vpid(vmcs12)); > > ... which is exactly nested_has_guest_tlb_tag(vcpu). Well, not exactly > but it's a bug in your code above. :) I don't think it's a bug, it's intentionally different. When enable_ept=0, nested_has_guest_tlb_tag() returns true if and only if L1 has enabled VPID for L2 *and* L2 has been assigned a unique VPID by L0. For sync purposes, whether or not L2 has been assigned a unique VPID is irrelevant. L0 needs to invalidate TLB entries to prevent resuing L1's entries (assuming L1 has been assigned a VPID), but L0 doesn't need to sync SPTEs because L2 doesn't expect them to be refreshed. > It completely makes sense to use that as the third argument, and while a > comment is still needed it will be much smaller. Ya, agreed.