On Mon, Mar 23, 2020 at 09:36:22AM -0700, Jim Mattson wrote: > On Mon, Mar 23, 2020 at 9:28 AM Sean Christopherson > <sean.j.christopherson@xxxxxxxxx> wrote: > > > > On Mon, Mar 23, 2020 at 09:24:25AM -0700, Jim Mattson wrote: > > > On Fri, Mar 20, 2020 at 2:29 PM Sean Christopherson > > > <sean.j.christopherson@xxxxxxxxx> wrote: > > > > > > > > Free all L2 (guest_mmu) roots when emulating INVEPT for L1. Outstanding > > > > changes to the EPT tables managed by L1 need to be recognized, and > > > > relying on KVM to always flush L2's EPTP context on nested VM-Enter is > > > > dangerous. > > > > > > > > Similar to handle_invpcid(), rely on kvm_mmu_free_roots() to do a remote > > > > TLB flush if necessary, e.g. if L1 has never entered L2 then there is > > > > nothing to be done. > > > > > > > > Nuking all L2 roots is overkill for the single-context variant, but it's > > > > the safe and easy bet. A more precise zap mechanism will be added in > > > > the future. Add a TODO to call out that KVM only needs to invalidate > > > > affected contexts. > > > > > > > > Fixes: b119019847fbc ("kvm: nVMX: Remove unnecessary sync_roots from handle_invept") > > > > > > The bug existed well before the commit indicated in the "Fixes" line. > > > > Ah, my bad. A cursory glance at commit b119019847fbc makes that quite > > obvious. This should be > > > > Fixes: bfd0a56b9000 ("nEPT: Nested INVEPT") > > Actually, I think that things were fine back then (though we > gratuitously flushed L1's TLB as a result of an emulated INVEPT). The > problem started when we stopped flushing the TLB on every emulated > VM-entry (i.e. L1 -> L2 transitions). I'm not sure what that commit > was, but I think you referenced it in an earlier email. Hmm, true. I was thinking it was the original commit because it didn't operate on guest_mmu, but guest_mmu didn't exist back then. So I think Fixes: 14c07ad89f4d ("x86/kvm/mmu: introduce guest_mmu") would be appropriate?