Liran Alon <liran.alon@xxxxxxxxxx> writes: >> On 24 Jun 2019, at 17:16, Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> wrote: >> >> >> That said I'm ok with dropping nested_release_evmcs() for consistency >> but we can't just drop 'if (vmptr == vmx->nested.hv_evmcs_vmptr)’. > > Right. I meant that we can just change code to: > > /* Add relevant comment here as this is not trivial why we do this */ > If (likely(!vmx->nested.enlightened_vmcs_enabled) || > nested_enlightened_vmentry(vcpu, &evmptr)) { > > if (vmptr == vmx->nested.current_vmptr) > nested_release_vmcs12(vcpu); > > kvm_vcpu_write_guest(…); > } > The change, to my surprise, resulted in a set of L2 guest crashes. After some debugging I figured out that clean fields is to blame: after Windows does VMCLEAR it doesn't maintain clean field data before the next VMLAUNCH - and nested_vmx_handle_enlightened_vmptrld() does nothing in case evmcs_vmptr stays unchanged (so VMLAUNCH follows VMCLEAR on the same vCPU). We apparently need to invalidate clean fields data on every VMLAUCH. This is fix of its own, I'll do more testing and send v2. -- Vitaly