From: Sean Christopherson <seanjc@google.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Maksim Davydov <davydov-max@yandex-team.ru>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
x86@kernel.org, babu.moger@amd.com, mingo@redhat.com,
tglx@linutronix.de, dave.hansen@linux.intel.com, hpa@zytor.com,
jmattson@google.com, pbonzini@redhat.com
Subject: Re: [PATCH v3 1/2] x86: KVM: Advertise FSRS and FSRC on AMD to userspace
Date: Fri, 11 Apr 2025 06:49:54 -0700 [thread overview]
Message-ID: <Z_keAsy09KU0kDFj@google.com> (raw)
In-Reply-To: <20250411094059.GIZ_jjq0DxLhJOEQ9B@fat_crate.local>
On Fri, Apr 11, 2025, Borislav Petkov wrote:
> On Wed, Dec 04, 2024 at 04:43:44PM +0300, Maksim Davydov wrote:
> > diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
> > index 17b6590748c0..45f87a026bba 100644
> > --- a/arch/x86/include/asm/cpufeatures.h
> > +++ b/arch/x86/include/asm/cpufeatures.h
> > @@ -460,6 +460,8 @@
> > #define X86_FEATURE_NULL_SEL_CLR_BASE (20*32+ 6) /* Null Selector Clears Base */
> > #define X86_FEATURE_AUTOIBRS (20*32+ 8) /* Automatic IBRS */
> > #define X86_FEATURE_NO_SMM_CTL_MSR (20*32+ 9) /* SMM_CTL MSR is not present */
> > +#define X86_FEATURE_AMD_FSRS (20*32+10) /* AMD Fast short REP STOSB supported */
> > +#define X86_FEATURE_AMD_FSRC (20*32+11) /* AMD Fast short REP CMPSB supported */
>
> Since Intel has the same flags, you should do
>
> if (cpu_has(c, X86_FEATURE_AMD_FSRS))
> set_cpu_cap(c, X86_FEATURE_FSRS);
>
> and the other one too. Probably in init_amd() so that guest userspace doesn't
> need to differentiate between the two and you don't have to do...
>
> > #define X86_FEATURE_SBPB (20*32+27) /* Selective Branch Prediction Barrier */
> > #define X86_FEATURE_IBPB_BRTYPE (20*32+28) /* MSR_PRED_CMD[IBPB] flushes all branch type predictions */
> > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> > index 097bdc022d0f..7bc095add8ee 100644
> > --- a/arch/x86/kvm/cpuid.c
> > +++ b/arch/x86/kvm/cpuid.c
> > @@ -799,8 +799,8 @@ void kvm_set_cpu_caps(void)
> >
> > kvm_cpu_cap_mask(CPUID_8000_0021_EAX,
> > F(NO_NESTED_DATA_BP) | F(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ |
> > - F(NULL_SEL_CLR_BASE) | F(AUTOIBRS) | 0 /* PrefetchCtlMsr */ |
> > - F(WRMSR_XX_BASE_NS)
> > + F(NULL_SEL_CLR_BASE) | F(AUTOIBRS) | F(AMD_FSRS) |
> > + F(AMD_FSRC) | 0 /* PrefetchCtlMsr */ | F(WRMSR_XX_BASE_NS)
>
> ... this.
KVM should still explicitly advertise support for AMD's flavor. There are KVM
use cases where KVM's advertised CPUID support is used almost verbatim, in which
case not advertising AMD_FSRC would result it the features not be enumerated to
the guest. Linux might cross-pollinate, but KVM can't rely on all software to do
so.
next prev parent reply other threads:[~2025-04-11 13:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 13:43 [PATCH v3 0/2] x86: KVM: Add missing AMD features Maksim Davydov
2024-12-04 13:43 ` [PATCH v3 1/2] x86: KVM: Advertise FSRS and FSRC on AMD to userspace Maksim Davydov
2024-12-04 16:57 ` Jim Mattson
[not found] ` <69fa0014-a5bd-4e1f-94b6-f22e9688ab71@amd.com>
2024-12-09 12:11 ` Maksim Davydov
2024-12-09 19:22 ` Moger, Babu
2025-04-11 9:40 ` Borislav Petkov
2025-04-11 13:49 ` Sean Christopherson [this message]
2025-04-11 14:44 ` Borislav Petkov
2025-04-11 15:19 ` Sean Christopherson
2025-04-11 9:42 ` Borislav Petkov
2024-12-04 13:43 ` [PATCH v3 2/2] x86: KVM: Advertise AMD's speculation control features Maksim Davydov
2025-04-11 9:44 ` Borislav Petkov
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=Z_keAsy09KU0kDFj@google.com \
--to=seanjc@google.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=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.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