Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Jim Mattson <jmattson@google.com>
Cc: amit.shah@amd.com, kvm@vger.kernel.org, pbonzini@redhat.com,
	 venkateshs@google.com, yosry@kernel.org
Subject: Re: [PATCH v2 1/3] KVM: SVM: Configure ALLOW_LARGER_RAP in svm_vcpu_after_set_cpuid()
Date: Mon, 20 Jul 2026 08:52:28 -0700	[thread overview]
Message-ID: <al5EPBD0KQDpbNiA@google.com> (raw)
In-Reply-To: <20260717230542.3555587-2-jmattson@google.com>

On Fri, Jul 17, 2026, Jim Mattson wrote:
> 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 <jmattson@google.com>
> ---
>  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 we handle ERAPS here, can't we drop the code in init_vmcb()?  In the context
of PML enablement, AMD is updating the APM to clarify that the control area remains
valid after shutdown, i.e. KVM doesn't need to re-initialize erap_ctl when
synthesizing INIT from shutdown_interception().

  "After an intercepted shutdown, the VMCB control area is valid (with the
   exception of offsets 60h, 61h, and 68h) and the VMCB state save area is
   undefined."

https://lore.kernel.org/all/6688fe2e-c723-404a-80e1-3f4c5f5cc4c6@amd.com


> +
>  	if (is_sev_guest(vcpu))
>  		sev_vcpu_after_set_cpuid(svm);
>  }
> -- 
> 2.55.0.229.g6434b31f56-goog
> 

  reply	other threads:[~2026-07-20 15:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 23:05 [PATCH v2 0/3] KVM: x86/SVM: Fixes for AMD ERAPS virtualization Jim Mattson
2026-07-17 23:05 ` [PATCH v2 1/3] KVM: SVM: Configure ALLOW_LARGER_RAP in svm_vcpu_after_set_cpuid() Jim Mattson
2026-07-20 15:52   ` Sean Christopherson [this message]
2026-07-20 16:12     ` Sean Christopherson
2026-07-17 23:05 ` [PATCH v2 2/3] KVM: SVM: Dirty ERAPS register on all ASID TLB flushes Jim Mattson
2026-07-20 15:33   ` Sean Christopherson
2026-07-20 16:41     ` Jim Mattson
2026-07-17 23:05 ` [PATCH v2 3/3] KVM: x86: Flush guest TLB on MTRR MSR writes Jim Mattson
2026-07-20 15:46   ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=al5EPBD0KQDpbNiA@google.com \
    --to=seanjc@google.com \
    --cc=amit.shah@amd.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=venkateshs@google.com \
    --cc=yosry@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox