* [PATCH v3 2/2] KVM: x86: Expose CPUID.(EAX=7,ECX=1).EAX[12:10] to the guest
2022-09-01 21:18 [PATCH v3 1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features Jim Mattson
@ 2022-09-01 21:18 ` Jim Mattson
2022-10-07 1:45 ` Sean Christopherson
2022-09-02 4:14 ` [PATCH v3 1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features H. Peter Anvin
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Jim Mattson @ 2022-09-01 21:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Sean Christopherson, Paolo Bonzini, Peter Zijlstra,
Josh Poimboeuf, Pawan Gupta, Chang S. Bae, Jim Mattson,
Babu Moger, Wyes Karny,
open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:KERNEL VIRTUAL MACHINE FOR X86 (KVM/x86)
Fast zero-length REP MOVSB, fast short REP STOSB, and fast short REP
{CMPSB,SCASB} are inherent features of the processor that cannot be
hidden by the hypervisor. When these features are present on the host,
enumerate them in KVM_GET_SUPPORTED_CPUID.
Signed-off-by: Jim Mattson <jmattson@google.com>
---
arch/x86/kvm/cpuid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 75dcf7a72605..172cbfd60946 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -636,7 +636,7 @@ void kvm_set_cpu_caps(void)
kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD);
kvm_cpu_cap_mask(CPUID_7_1_EAX,
- F(AVX_VNNI) | F(AVX512_BF16)
+ F(AVX_VNNI) | F(AVX512_BF16) | F(FZRM) | F(FSRS) | F(FSRC)
);
kvm_cpu_cap_mask(CPUID_D_1_EAX,
--
2.37.2.789.g6183377224-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v3 2/2] KVM: x86: Expose CPUID.(EAX=7,ECX=1).EAX[12:10] to the guest
2022-09-01 21:18 ` [PATCH v3 2/2] KVM: x86: Expose CPUID.(EAX=7,ECX=1).EAX[12:10] to the guest Jim Mattson
@ 2022-10-07 1:45 ` Sean Christopherson
0 siblings, 0 replies; 7+ messages in thread
From: Sean Christopherson @ 2022-10-07 1:45 UTC (permalink / raw)
To: Jim Mattson
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Paolo Bonzini, Peter Zijlstra, Josh Poimboeuf, Pawan Gupta,
Chang S. Bae, Babu Moger, Wyes Karny,
open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:KERNEL VIRTUAL MACHINE FOR X86 (KVM/x86)
The shortlog is trying to win some kind of award.
And technically, KVM_GET_SUPPORTED_CPUID advertises features to userspace, not
to the guest. How about this?
KVM: x86: Advertise fast REP string features inherent to the CPU
On Thu, Sep 01, 2022, Jim Mattson wrote:
> Fast zero-length REP MOVSB, fast short REP STOSB, and fast short REP
> {CMPSB,SCASB} are inherent features of the processor that cannot be
> hidden by the hypervisor. When these features are present on the host,
> enumerate them in KVM_GET_SUPPORTED_CPUID.
>
> Signed-off-by: Jim Mattson <jmattson@google.com>
With a less cryptic shortlog,
Reviewed-by: Sean Christopherson <seanjc@google.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features
2022-09-01 21:18 [PATCH v3 1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features Jim Mattson
2022-09-01 21:18 ` [PATCH v3 2/2] KVM: x86: Expose CPUID.(EAX=7,ECX=1).EAX[12:10] to the guest Jim Mattson
@ 2022-09-02 4:14 ` H. Peter Anvin
2022-09-02 5:48 ` Borislav Petkov
2022-10-07 1:46 ` Sean Christopherson
2023-01-19 20:48 ` Sean Christopherson
3 siblings, 1 reply; 7+ messages in thread
From: H. Peter Anvin @ 2022-09-02 4:14 UTC (permalink / raw)
To: Jim Mattson, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
Sean Christopherson, Paolo Bonzini, Peter Zijlstra,
Josh Poimboeuf, Pawan Gupta, Babu Moger, Chang S. Bae, Wyes Karny,
open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:KERNEL VIRTUAL MACHINE FOR X86 (KVM/x86)
On 9/1/22 14:18, Jim Mattson wrote:
> KVM_GET_SUPPORTED_CPUID should reflect these host CPUID bits. The bits
> are already cached in word 12. Give the bits X86_FEATURE names, so
> that they can be easily referenced. Hide these bits from
> /proc/cpuinfo, since the host kernel makes no use of them at present.
>
> Signed-off-by: Jim Mattson <jmattson@google.com>
> ---
> arch/x86/include/asm/cpufeatures.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
> index ef4775c6db01..454f0faa8e90 100644
> --- a/arch/x86/include/asm/cpufeatures.h
> +++ b/arch/x86/include/asm/cpufeatures.h
> @@ -308,6 +308,9 @@
> /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
> #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */
> #define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* AVX512 BFLOAT16 instructions */
> +#define X86_FEATURE_FZRM (12*32+10) /* "" Fast zero-length REP MOVSB */
> +#define X86_FEATURE_FSRS (12*32+11) /* "" Fast short REP STOSB */
> +#define X86_FEATURE_FSRC (12*32+12) /* "" Fast short REP {CMPSB,SCASB} */
>
> /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */
> #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */
Any reason why these bits are hidden from /proc/cpuinfo?
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v3 1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features
2022-09-02 4:14 ` [PATCH v3 1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features H. Peter Anvin
@ 2022-09-02 5:48 ` Borislav Petkov
0 siblings, 0 replies; 7+ messages in thread
From: Borislav Petkov @ 2022-09-02 5:48 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Jim Mattson, Thomas Gleixner, Ingo Molnar, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
Sean Christopherson, Paolo Bonzini, Peter Zijlstra,
Josh Poimboeuf, Pawan Gupta, Babu Moger, Chang S. Bae, Wyes Karny,
open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:KERNEL VIRTUAL MACHINE FOR X86 (KVM/x86)
On Thu, Sep 01, 2022 at 09:14:24PM -0700, H. Peter Anvin wrote:
> Any reason why these bits are hidden from /proc/cpuinfo?
Yes, we aim to hide such purely CPUID bits from /proc/cpuinfo because it
becomes a dumping ground for "enablement" of new features. But
1. those features are not really used - most userspace like binutils and
gcc, etc do their own detection. (Yes, yes, I'd like to have ubiquitous
CPUID faulting).
2. /proc/cpuinfo is an ABI so we have to carry *all* those gazillion
flags for no good reason
So we have tools/arch/x86/kcpuid/ which we control and we can extend
with all the CPUID querying needs we have.
These kvm enablement things are kinda needed because guest userspace
gets an emulated CPUID so in order to detect features on its own, it
needs them. And kvm has tied features to x86's X86_FEATURE stuff and
there are sometimes weird interactions with it too but that's another
topic...
Oh and we still do add visible flags to /proc/cpuinfo but only when
they're features which need and have received non-trivial kernel
enablement like TDX or SNP or so.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features
2022-09-01 21:18 [PATCH v3 1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features Jim Mattson
2022-09-01 21:18 ` [PATCH v3 2/2] KVM: x86: Expose CPUID.(EAX=7,ECX=1).EAX[12:10] to the guest Jim Mattson
2022-09-02 4:14 ` [PATCH v3 1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features H. Peter Anvin
@ 2022-10-07 1:46 ` Sean Christopherson
2023-01-19 20:48 ` Sean Christopherson
3 siblings, 0 replies; 7+ messages in thread
From: Sean Christopherson @ 2022-10-07 1:46 UTC (permalink / raw)
To: Jim Mattson
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Paolo Bonzini, Peter Zijlstra, Josh Poimboeuf, Pawan Gupta,
Babu Moger, Chang S. Bae, Wyes Karny,
open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:KERNEL VIRTUAL MACHINE FOR X86 (KVM/x86)
On Thu, Sep 01, 2022, Jim Mattson wrote:
> KVM_GET_SUPPORTED_CPUID should reflect these host CPUID bits. The bits
> are already cached in word 12. Give the bits X86_FEATURE names, so
> that they can be easily referenced. Hide these bits from
> /proc/cpuinfo, since the host kernel makes no use of them at present.
>
> Signed-off-by: Jim Mattson <jmattson@google.com>
> ---
Reviewed-by: Sean Christopherson <seanjc@google.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features
2022-09-01 21:18 [PATCH v3 1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features Jim Mattson
` (2 preceding siblings ...)
2022-10-07 1:46 ` Sean Christopherson
@ 2023-01-19 20:48 ` Sean Christopherson
3 siblings, 0 replies; 7+ messages in thread
From: Sean Christopherson @ 2023-01-19 20:48 UTC (permalink / raw)
To: Sean Christopherson, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Paolo Bonzini, Peter Zijlstra, Josh Poimboeuf, Pawan Gupta,
Babu Moger, Chang S. Bae, Wyes Karny,
open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:KERNEL VIRTUAL MACHINE FOR X86 (KVM/x86), Jim Mattson
On Thu, 01 Sep 2022 14:18:06 -0700, Jim Mattson wrote:
> KVM_GET_SUPPORTED_CPUID should reflect these host CPUID bits. The bits
> are already cached in word 12. Give the bits X86_FEATURE names, so
> that they can be easily referenced. Hide these bits from
> /proc/cpuinfo, since the host kernel makes no use of them at present.
>
>
Applied to kvm-x86 misc, thanks!
[1/2] x86/cpufeatures: Add macros for Intel's new fast rep string features
https://github.com/kvm-x86/linux/commit/751b1e1ee8e9
[2/2] KVM: x86: Expose CPUID.(EAX=7,ECX=1).EAX[12:10] to the guest
https://github.com/kvm-x86/linux/commit/bbbe171ac12f
--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes
^ permalink raw reply [flat|nested] 7+ messages in thread