From: "Moger, Babu" <bmoger@amd.com>
To: Maksim Davydov <davydov-max@yandex-team.ru>, kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, babu.moger@amd.com, x86@kernel.org,
seanjc@google.com, sandipan.das@amd.com, bp@alien8.de,
mingo@redhat.com, tglx@linutronix.de,
dave.hansen@linux.intel.com, hpa@zytor.com, pbonzini@redhat.com
Subject: Re: [PATCH 2/2] x86: KVM: Advertise AMD's speculation control features
Date: Fri, 15 Nov 2024 14:12:18 -0600 [thread overview]
Message-ID: <2813ba0d-7e5d-03d4-26df-d5283b9c0549@amd.com> (raw)
In-Reply-To: <20241113133042.702340-3-davydov-max@yandex-team.ru>
Hi Maksim,
On 11/13/2024 7:30 AM, Maksim Davydov wrote:
> It seems helpful to expose to userspace some speculation control features
> from 0x80000008_EBX function:
> * 16 bit. IBRS always on. Indicates whether processor prefers that
> IBRS is always on. It simplifies speculation managing.
Spec say bit 16 is reserved.
16 Reserved
https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/programmer-references/57238.zip
> * 18 bit. IBRS is preferred over software solution. Indicates that
> software mitigations can be replaced with more performant IBRS.
> * 19 bit. IBRS provides Same Mode Protection. Indicates that when IBRS
> is set indirect branch predictions are not influenced by any prior
> indirect branches.
> * 29 bit. BTC_NO. Indicates that processor isn't affected by branch type
> confusion. It's used during mitigations setting up.
> * 30 bit. IBPB clears return address predictor. It's used during
> mitigations setting up.
>
> Signed-off-by: Maksim Davydov <davydov-max@yandex-team.ru>
> ---
> arch/x86/include/asm/cpufeatures.h | 3 +++
> arch/x86/kvm/cpuid.c | 5 +++--
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
> index 2f8a858325a4..f5491bba75fc 100644
> --- a/arch/x86/include/asm/cpufeatures.h
> +++ b/arch/x86/include/asm/cpufeatures.h
> @@ -340,7 +340,10 @@
> #define X86_FEATURE_AMD_IBPB (13*32+12) /* Indirect Branch Prediction Barrier */
> #define X86_FEATURE_AMD_IBRS (13*32+14) /* Indirect Branch Restricted Speculation */
> #define X86_FEATURE_AMD_STIBP (13*32+15) /* Single Thread Indirect Branch Predictors */
> +#define X86_FEATURE_AMD_IBRS_ALWAYS_ON (13*32+16) /* Indirect Branch Restricted Speculation always-on preferred */
You might have to remove this.
> #define X86_FEATURE_AMD_STIBP_ALWAYS_ON (13*32+17) /* Single Thread Indirect Branch Predictors always-on preferred */
> +#define X86_FEATURE_AMD_IBRS_PREFERRED (13*32+18) /* Indirect Branch Restricted Speculation is preferred over SW solution */
> +#define X86_FEATURE_AMD_IBRS_SMP (13*32+19) /* Indirect Branch Restricted Speculation provides Same Mode Protection */
> #define X86_FEATURE_AMD_PPIN (13*32+23) /* "amd_ppin" Protected Processor Inventory Number */
> #define X86_FEATURE_AMD_SSBD (13*32+24) /* Speculative Store Bypass Disable */
> #define X86_FEATURE_VIRT_SSBD (13*32+25) /* "virt_ssbd" Virtualized Speculative Store Bypass Disable */
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 30ce1bcfc47f..5b2d52913b18 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -754,8 +754,9 @@ void kvm_set_cpu_caps(void)
> kvm_cpu_cap_mask(CPUID_8000_0008_EBX,
> F(CLZERO) | F(XSAVEERPTR) |
> F(WBNOINVD) | F(AMD_IBPB) | F(AMD_IBRS) | F(AMD_SSBD) | F(VIRT_SSBD) |
> - F(AMD_SSB_NO) | F(AMD_STIBP) | F(AMD_STIBP_ALWAYS_ON) |
> - F(AMD_PSFD)
> + F(AMD_SSB_NO) | F(AMD_STIBP) | F(AMD_IBRS_ALWAYS_ON) |
> + F(AMD_STIBP_ALWAYS_ON) | F(AMD_IBRS_PREFERRED) |
> + F(AMD_IBRS_SMP) | F(AMD_PSFD) | F(BTC_NO) | F(AMD_IBPB_RET)
> );
>
> /*
--
- Babu Moger
next prev parent reply other threads:[~2024-11-15 20:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-13 13:30 [PATCH 0/2] x86: KVM: Add missing AMD features Maksim Davydov
2024-11-13 13:30 ` [PATCH 1/2] x86: KVM: Advertise FSRS and FSRC on AMD to userspace Maksim Davydov
2024-11-15 19:51 ` Moger, Babu
2024-11-16 10:34 ` Maksim Davydov
2024-11-13 13:30 ` [PATCH 2/2] x86: KVM: Advertise AMD's speculation control features Maksim Davydov
2024-11-15 20:12 ` Moger, Babu [this message]
2024-11-15 20:32 ` Jim Mattson
2024-11-15 21:29 ` Moger, Babu
2024-11-16 11:51 ` Maksim Davydov
2024-11-18 17:37 ` Tom Lendacky
2024-11-16 11:47 ` [PATCH 0/2] x86: KVM: Add missing AMD features Borislav Petkov
2024-11-16 12:02 ` Maksim Davydov
2024-11-16 12:10 ` Borislav Petkov
2024-11-18 14:07 ` Maksim Davydov
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=2813ba0d-7e5d-03d4-26df-d5283b9c0549@amd.com \
--to=bmoger@amd.com \
--cc=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=davydov-max@yandex-team.ru \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=sandipan.das@amd.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®