mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/cpufeatures: Define X86_FEATURE_PREFETCHI (AMD)
@ 2025-04-08 22:57 Babu Moger
  2025-04-09  9:23 ` Borislav Petkov
  2025-04-25 23:23 ` Sean Christopherson
  0 siblings, 2 replies; 4+ messages in thread
From: Babu Moger @ 2025-04-08 22:57 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, seanjc, pbonzini
  Cc: x86, hpa, daniel.sneddon, jpoimboe, pawan.kumar.gupta,
	thomas.lendacky, perry.yuan, linux-kernel, kvm

The latest AMD platform has introduced a new instruction called PREFETCHI.
This instruction loads a cache line from a specified memory address into
the indicated data or instruction cache level, based on locality reference
hints.

Feature bit definition:
CPUID_Fn80000021_EAX [bit 20] - Indicates support for IC prefetch.

This feature is analogous to Intel's PREFETCHITI (CPUID.(EAX=7,ECX=1):EDX),
though the CPUID bit definitions differ between AMD and Intel.

Expose the feature to KVM guests.

The feature is documented in Processor Programming Reference (PPR)
for AMD Family 1Ah Model 02h, Revision C1 (Link below).

Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
Signed-off-by: Babu Moger <babu.moger@amd.com>
---
 arch/x86/include/asm/cpufeatures.h | 1 +
 arch/x86/kvm/cpuid.c               | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 6c2c152d8a67..7d7507b3eefd 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -457,6 +457,7 @@
 #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_PREFETCHI		(20*32+20) /* Prefetch Data/Instruction to Cache Level */
 #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 */
 #define X86_FEATURE_SRSO_NO		(20*32+29) /* CPU is not affected by SRSO */
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 5e4d4934c0d3..fba018a730ab 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1178,6 +1178,7 @@ void kvm_set_cpu_caps(void)
 		/* SmmPgCfgLock */
 		F(NULL_SEL_CLR_BASE),
 		F(AUTOIBRS),
+		F(PREFETCHI),
 		EMULATED_F(NO_SMM_CTL_MSR),
 		/* PrefetchCtlMsr */
 		F(WRMSR_XX_BASE_NS),
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/cpufeatures: Define X86_FEATURE_PREFETCHI (AMD)
  2025-04-08 22:57 [PATCH] x86/cpufeatures: Define X86_FEATURE_PREFETCHI (AMD) Babu Moger
@ 2025-04-09  9:23 ` Borislav Petkov
  2025-04-25 23:23 ` Sean Christopherson
  1 sibling, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2025-04-09  9:23 UTC (permalink / raw)
  To: Babu Moger
  Cc: tglx, mingo, dave.hansen, seanjc, pbonzini, x86, hpa,
	daniel.sneddon, jpoimboe, pawan.kumar.gupta, thomas.lendacky,
	perry.yuan, linux-kernel, kvm

On Tue, Apr 08, 2025 at 05:57:09PM -0500, Babu Moger wrote:
> The latest AMD platform has introduced a new instruction called PREFETCHI.
> This instruction loads a cache line from a specified memory address into
> the indicated data or instruction cache level, based on locality reference
> hints.
> 
> Feature bit definition:
> CPUID_Fn80000021_EAX [bit 20] - Indicates support for IC prefetch.
> 
> This feature is analogous to Intel's PREFETCHITI (CPUID.(EAX=7,ECX=1):EDX),
> though the CPUID bit definitions differ between AMD and Intel.
> 
> Expose the feature to KVM guests.
> 
> The feature is documented in Processor Programming Reference (PPR)
> for AMD Family 1Ah Model 02h, Revision C1 (Link below).
> 
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---
>  arch/x86/include/asm/cpufeatures.h | 1 +
>  arch/x86/kvm/cpuid.c               | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
> index 6c2c152d8a67..7d7507b3eefd 100644
> --- a/arch/x86/include/asm/cpufeatures.h
> +++ b/arch/x86/include/asm/cpufeatures.h
> @@ -457,6 +457,7 @@
>  #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_PREFETCHI		(20*32+20) /* Prefetch Data/Instruction to Cache Level */
>  #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 */
>  #define X86_FEATURE_SRSO_NO		(20*32+29) /* CPU is not affected by SRSO */

Acked-by: Borislav Petkov (AMD) <bp@alien8.de>

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/cpufeatures: Define X86_FEATURE_PREFETCHI (AMD)
  2025-04-08 22:57 [PATCH] x86/cpufeatures: Define X86_FEATURE_PREFETCHI (AMD) Babu Moger
  2025-04-09  9:23 ` Borislav Petkov
@ 2025-04-25 23:23 ` Sean Christopherson
  2025-04-28 13:54   ` Moger, Babu
  1 sibling, 1 reply; 4+ messages in thread
From: Sean Christopherson @ 2025-04-25 23:23 UTC (permalink / raw)
  To: Sean Christopherson, tglx, mingo, bp, dave.hansen, pbonzini, Babu Moger
  Cc: x86, hpa, daniel.sneddon, jpoimboe, pawan.kumar.gupta,
	thomas.lendacky, perry.yuan, linux-kernel, kvm

On Tue, 08 Apr 2025 17:57:09 -0500, Babu Moger wrote:
> The latest AMD platform has introduced a new instruction called PREFETCHI.
> This instruction loads a cache line from a specified memory address into
> the indicated data or instruction cache level, based on locality reference
> hints.
> 
> Feature bit definition:
> CPUID_Fn80000021_EAX [bit 20] - Indicates support for IC prefetch.
> 
> [...]

Applied to kvm-x86 misc, with a rewritten shortlog and changelog to make it super
clear this is KVM enabling.

[1/1] KVM: x86: Advertise support for AMD's PREFETCHI
      https://github.com/kvm-x86/linux/commit/d88bb2ded2ef

--
https://github.com/kvm-x86/linux/tree/next

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/cpufeatures: Define X86_FEATURE_PREFETCHI (AMD)
  2025-04-25 23:23 ` Sean Christopherson
@ 2025-04-28 13:54   ` Moger, Babu
  0 siblings, 0 replies; 4+ messages in thread
From: Moger, Babu @ 2025-04-28 13:54 UTC (permalink / raw)
  To: Sean Christopherson, tglx, mingo, bp, dave.hansen, pbonzini
  Cc: x86, hpa, daniel.sneddon, jpoimboe, pawan.kumar.gupta,
	thomas.lendacky, perry.yuan, linux-kernel, kvm



On 4/25/25 18:23, Sean Christopherson wrote:
> On Tue, 08 Apr 2025 17:57:09 -0500, Babu Moger wrote:
>> The latest AMD platform has introduced a new instruction called PREFETCHI.
>> This instruction loads a cache line from a specified memory address into
>> the indicated data or instruction cache level, based on locality reference
>> hints.
>>
>> Feature bit definition:
>> CPUID_Fn80000021_EAX [bit 20] - Indicates support for IC prefetch.
>>
>> [...]
> 
> Applied to kvm-x86 misc, with a rewritten shortlog and changelog to make it super
> clear this is KVM enabling.

Sean, Thank you.
Babu Moger

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-28 13:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-08 22:57 [PATCH] x86/cpufeatures: Define X86_FEATURE_PREFETCHI (AMD) Babu Moger
2025-04-09  9:23 ` Borislav Petkov
2025-04-25 23:23 ` Sean Christopherson
2025-04-28 13:54   ` Moger, Babu

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®