mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Shah, Amit" <Amit.Shah@amd.com>
To: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"seanjc@google.com" <seanjc@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>
Cc: "tglx@linutronix.de" <tglx@linutronix.de>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"Kaplan, David" <David.Kaplan@amd.com>,
	"Phillips, Kim" <kim.phillips@amd.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
Subject: Re: [PATCH v4] KVM: SVM: let alternatives handle the cases when RSB filling is required
Date: Thu, 22 Aug 2024 14:09:39 +0000	[thread overview]
Message-ID: <2d3f3b45af726bd65f081819fbfe2ae2a9eb6b76.camel@amd.com> (raw)
In-Reply-To: <20240807123531.69677-1-amit@kernel.org>

Pinging to bring attention to this fix.

On Wed, 2024-08-07 at 14:35 +0200, Amit Shah wrote:
> From: Amit Shah <amit.shah@amd.com>
> 
> Remove superfluous RSB filling after a VMEXIT when the CPU already
> has
> flushed the RSB after a VMEXIT when AutoIBRS is enabled.
> 
> The initial implementation for adding RETPOLINES added an
> ALTERNATIVES
> implementation for filling the RSB after a VMEXIT in
> 
> commit 117cc7a908c836 ("x86/retpoline: Fill return stack buffer on
> vmexit")
> 
> Later, X86_FEATURE_RSB_VMEXIT was added in
> 
> commit 2b129932201673 ("x86/speculation: Add RSB VM Exit
> protections")
> 
> The AutoIBRS (on AMD CPUs) feature implementation added in
> 
> commit e7862eda309ecf ("x86/cpu: Support AMD Automatic IBRS")
> 
> used the already-implemented logic for EIBRS in
> spectre_v2_determine_rsb_fill_type_on_vmexit() -- but did not update
> the
> code at VMEXIT to act on the mode selected in that function --
> resulting
> in VMEXITs continuing to clear the RSB when RETPOLINES are enabled,
> despite the presence of AutoIBRS.
> 
> Signed-off-by: Amit Shah <amit.shah@amd.com>
> 
> ---
> v4: resend of v3 with subject-prefix fixed
> 
> v3:
>  - Add a comment mentioning SVM does not need RSB_VMEXIT_LITE unlike
>    VMX.
> v2:
>  - tweak commit message re: Boris's comments.
> 
>  arch/x86/kvm/svm/vmenter.S | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S
> index a0c8eb37d3e1..69d9825ebdd9 100644
> --- a/arch/x86/kvm/svm/vmenter.S
> +++ b/arch/x86/kvm/svm/vmenter.S
> @@ -209,10 +209,14 @@ SYM_FUNC_START(__svm_vcpu_run)
>  7:	vmload %_ASM_AX
>  8:
>  
> -#ifdef CONFIG_MITIGATION_RETPOLINE
> -	/* IMPORTANT: Stuff the RSB immediately after VM-Exit,
> before RET! */
> -	FILL_RETURN_BUFFER %_ASM_AX, RSB_CLEAR_LOOPS,
> X86_FEATURE_RETPOLINE
> -#endif
> +	/*
> +	 * IMPORTANT: Stuff the RSB immediately after VM-Exit,
> before RET!
> +	 *
> +	 * Unlike VMX, AMD does not have the hardware bug that
> necessitates
> +	 * RSB_VMEXIT_LITE
> +	 */
> +
> +	FILL_RETURN_BUFFER %_ASM_AX, RSB_CLEAR_LOOPS,
> X86_FEATURE_RSB_VMEXIT
>  
>  	/* Clobbers RAX, RCX, RDX.  */
>  	RESTORE_HOST_SPEC_CTRL
> @@ -348,10 +352,14 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run)
>  
>  2:	cli
>  
> -#ifdef CONFIG_MITIGATION_RETPOLINE
> -	/* IMPORTANT: Stuff the RSB immediately after VM-Exit,
> before RET! */
> -	FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS,
> X86_FEATURE_RETPOLINE
> -#endif
> +	/*
> +	 * IMPORTANT: Stuff the RSB immediately after VM-Exit,
> before RET!
> +	 *
> +	 * Unlike VMX, AMD does not have the hardware bug that
> necessitates
> +	 * RSB_VMEXIT_LITE
> +	 */
> +
> +	FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS,
> X86_FEATURE_RSB_VMEXIT
>  
>  	/* Clobbers RAX, RCX, RDX, consumes RDI (@svm) and RSI
> (@spec_ctrl_intercepted). */
>  	RESTORE_HOST_SPEC_CTRL


  reply	other threads:[~2024-08-22 14:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07 12:35 Amit Shah
2024-08-22 14:09 ` Shah, Amit [this message]
2024-09-10 19:59 ` 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=2d3f3b45af726bd65f081819fbfe2ae2a9eb6b76.camel@amd.com \
    --to=amit.shah@amd.com \
    --cc=David.Kaplan@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kim.phillips@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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

all inboxes | Powered by JetHome®