On Tue, May 13, 2025, Jon Kohler wrote: > > On May 12, 2025, at 2:23 PM, Sean Christopherson <seanjc@xxxxxxxxxx> wrote: > > > On Thu, Mar 13, 2025, Jon Kohler wrote: > >> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > >> index 7a98f03ef146..116910159a3f 100644 > >> --- a/arch/x86/kvm/vmx/vmx.c > >> +++ b/arch/x86/kvm/vmx/vmx.c > >> @@ -2694,6 +2694,7 @@ static int setup_vmcs_config(struct vmcs_config *vmcs_conf, > >> return -EIO; > >> > >> vmx_cap->ept = 0; > >> + _cpu_based_2nd_exec_control &= ~SECONDARY_EXEC_MODE_BASED_EPT_EXEC; > >> _cpu_based_2nd_exec_control &= ~SECONDARY_EXEC_EPT_VIOLATION_VE; > >> } > >> if (!(_cpu_based_2nd_exec_control & SECONDARY_EXEC_ENABLE_VPID) && > >> @@ -4641,11 +4642,15 @@ static u32 vmx_secondary_exec_control(struct vcpu_vmx *vmx) > >> exec_control &= ~SECONDARY_EXEC_ENABLE_VPID; > >> if (!enable_ept) { > >> exec_control &= ~SECONDARY_EXEC_ENABLE_EPT; > >> + exec_control &= ~SECONDARY_EXEC_MODE_BASED_EPT_EXEC; > >> exec_control &= ~SECONDARY_EXEC_EPT_VIOLATION_VE; > >> enable_unrestricted_guest = 0; > >> } > >> if (!enable_unrestricted_guest) > >> exec_control &= ~SECONDARY_EXEC_UNRESTRICTED_GUEST; > >> + if (!enable_pt_guest_exec_control) > >> + exec_control &= ~SECONDARY_EXEC_MODE_BASED_EPT_EXEC; > > > > This is wrong and unnecessary. As mentioned early, the input that matters is > > vmcs12. This flag should *never* be set for vmcs01. > > I’ll page this back in, but I’m like 75% sure it didn’t work when I did it that way. Then you had other bugs. The control is per-VMCS and thus needs to be emulated as such. Definitely holler if you get stuck, there's no need to develop this in complete isolation.