On initial vCPU creation, init_vmcb() is called before userspace configures guest CPUID via KVM_SET_CPUID2. Consequently, ERAP_CONTROL_ALLOW_LARGER_RAP is never set during initial vCPU creation. If an AP later receives an INIT signal after CPUID has been set, init_vmcb() would set the bit for that AP, but the BSP would be left with ALLOW_LARGER_RAP clear. Configure ALLOW_LARGER_RAP in svm_vcpu_after_set_cpuid() to handle the BSP. Keep the code in init_vmcb() to restore ALLOW_LARGER_RAP after the VMCB has been cleared on the VCPU triple-fault reset path. Fixes: db5e82496492 ("KVM: SVM: Virtualize and advertise support for ERAPS") Assisted-by: Gemini:Gemini-Next Signed-off-by: Jim Mattson --- arch/x86/kvm/svm/svm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 4d2bacd00ec4..bf868da14cd2 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4736,6 +4736,11 @@ static void svm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu) if (guest_cpuid_is_intel_compatible(vcpu)) guest_cpu_cap_clear(vcpu, X86_FEATURE_V_VMSAVE_VMLOAD); + if (guest_cpu_cap_has(vcpu, X86_FEATURE_ERAPS)) + svm->vmcb01.ptr->control.erap_ctl |= ERAP_CONTROL_ALLOW_LARGER_RAP; + else + svm->vmcb01.ptr->control.erap_ctl &= ~ERAP_CONTROL_ALLOW_LARGER_RAP; + if (is_sev_guest(vcpu)) sev_vcpu_after_set_cpuid(svm); } -- 2.55.0.229.g6434b31f56-goog