All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/CPU/AMD: Fix AMD TLBI Erratum #1718
@ 2026-10-02 21:16 Borislav Petkov
  2026-10-03  0:31 ` Rik van Riel
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Borislav Petkov @ 2026-10-02 21:16 UTC (permalink / raw)
  To: X86; +Cc: LKML, Borislav Petkov (AMD), stable

From: "Borislav Petkov (AMD)" <bp@alien8.de>

The processor may fail to invalidate a TLB entry while executing an
INVLPGB/TLBSYNC instruction pair.

Detect the erratum and apply a software workaround when a microcode fix
is not present.

Fixes: 82378c6c2f43 ("x86/mm: Use INVLPGB for kernel TLB flushes")
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Cc: <stable@kernel.org>
---
 arch/x86/include/asm/cpufeatures.h | 3 +++
 arch/x86/include/asm/tlb.h         | 6 ++++++
 arch/x86/kernel/cpu/amd.c          | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index f70ee74b5f92..fe84cf4e97d3 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -477,6 +477,8 @@
 #define X86_FEATURE_NO_NESTED_DATA_BP	(20*32+ 0) /* No Nested Data Breakpoints */
 #define X86_FEATURE_WRMSR_XX_BASE_NS	(20*32+ 1) /* WRMSR to {FS,GS,KERNEL_GS}_BASE is non-serializing */
 #define X86_FEATURE_LFENCE_RDTSC	(20*32+ 2) /* LFENCE always serializing / synchronizes RDTSC */
+
+#define X86_FEATURE_TLBSYNC_SFW_NO	(20*32+ 4) /* TLBI Erratum #1718 fixed in microcode */
 #define X86_FEATURE_VERW_CLEAR		(20*32+ 5) /* The memory form of VERW mitigates TSA */
 #define X86_FEATURE_NULL_SEL_CLR_BASE	(20*32+ 6) /* Null Selector Clears Base */
 
@@ -587,4 +589,5 @@
 #define X86_BUG_TSA			X86_BUG( 1*32+ 9) /* "tsa" CPU is affected by Transient Scheduler Attacks */
 #define X86_BUG_VMSCAPE			X86_BUG( 1*32+10) /* "vmscape" CPU is affected by VMSCAPE attacks from guests */
 #define X86_BUG_SEAMRET_INVD_VMCS	X86_BUG( 1*32+11) /* "seamret_invd_vmcs" SEAMRET from P-SEAMLDR clears the current VMCS */
+#define X86_BUG_TLBI			X86_BUG( 1*32+12) /* "tlbi" AMD TLBI Erratum #1718 */
 #endif /* _ASM_X86_CPUFEATURES_H */
diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h
index 866ea78ba156..eba925c85f52 100644
--- a/arch/x86/include/asm/tlb.h
+++ b/arch/x86/include/asm/tlb.h
@@ -110,6 +110,12 @@ static inline void __tlbsync(void)
 
 	/* TLBSYNC: supported in binutils >= 0.36. */
 	asm volatile(".byte 0x0f, 0x01, 0xff" ::: "memory");
+
+	if (!static_cpu_has_bug(X86_BUG_TLBI))
+		return;
+
+	/* TLBSYNC: supported in binutils >= 0.36. */
+	asm volatile(".byte 0x0f, 0x01, 0xff" ::: "memory");
 }
 #else
 /* Some compilers (I'm looking at you clang!) simply can't do DCE */
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 54e14ed276b5..40463bad1078 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -1049,6 +1049,10 @@ static void init_amd_zen5(struct cpuinfo_x86 *c)
 		msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
 		pr_emerg_once("RDSEED32 is broken. Disabling the corresponding CPUID bit.\n");
 	}
+
+	if (cpu_has(c, X86_FEATURE_INVLPGB) &&
+	    !cpu_has(c, X86_FEATURE_TLBSYNC_SFW_NO))
+		set_cpu_bug(c, X86_BUG_TLBI);
 }
 
 static void init_amd(struct cpuinfo_x86 *c)
-- 
2.53.0


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

* Re: [PATCH] x86/CPU/AMD: Fix AMD TLBI Erratum #1718
  2026-10-02 21:16 [PATCH] x86/CPU/AMD: Fix AMD TLBI Erratum #1718 Borislav Petkov
@ 2026-10-03  0:31 ` Rik van Riel
  2026-10-03  0:44   ` Borislav Petkov
  2026-10-03 21:24 ` Lorenzo Stoakes (ARM)
  2026-10-05 17:42 ` [tip: x86/urgent] " tip-bot2 for Borislav Petkov (AMD)
  2 siblings, 1 reply; 6+ messages in thread
From: Rik van Riel @ 2026-10-03  0:31 UTC (permalink / raw)
  To: Borislav Petkov, X86; +Cc: LKML, Borislav Petkov (AMD), stable

On Fri, 2026-10-02 at 14:16 -0700, Borislav Petkov wrote:
> From: "Borislav Petkov (AMD)" <bp@alien8.de>
> 
> The processor may fail to invalidate a TLB entry while executing an
> INVLPGB/TLBSYNC instruction pair.
> 
> Detect the erratum and apply a software workaround when a microcode
> fix
> is not present.
> 
> Fixes: 82378c6c2f43 ("x86/mm: Use INVLPGB for kernel TLB flushes")
> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
> Cc: <stable@kernel.org>
> 
This same change fell out of my testing with
a reproducer earlier this year, so I know it
works, at least for the test case I have.

I am surprised that it was good enough to be 
a real workaround, but I'll take it ;)

Tested-by: Rik van Riel <riel@surriel.com>
Reviewed-by: Rik van Riel <riel@surriel.com>

-- 
All Rights Reversed.

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

* Re: [PATCH] x86/CPU/AMD: Fix AMD TLBI Erratum #1718
  2026-10-03  0:31 ` Rik van Riel
@ 2026-10-03  0:44   ` Borislav Petkov
  0 siblings, 0 replies; 6+ messages in thread
From: Borislav Petkov @ 2026-10-03  0:44 UTC (permalink / raw)
  To: Rik van Riel; +Cc: Borislav Petkov, X86, LKML, stable

On Fri, Oct 02, 2026 at 08:31:30PM -0400, Rik van Riel wrote:
> This same change fell out of my testing with
> a reproducer earlier this year, so I know it
> works, at least for the test case I have.
> 
> I am surprised that it was good enough to be 
> a real workaround, but I'll take it ;)

Me too, but it really is - there's a good reason why :)

But the most proper workaround is for everyone to update microcode anyway - it
is released too, so we don't even need the sw fallback.

> Tested-by: Rik van Riel <riel@surriel.com>
> Reviewed-by: Rik van Riel <riel@surriel.com>

Thanks, my plan is to queue it next week so that we have it in 7.3 and it
percolates to stable.

-- 
Regards/Gruss,
    Boris.

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

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

* Re: [PATCH] x86/CPU/AMD: Fix AMD TLBI Erratum #1718
  2026-10-02 21:16 [PATCH] x86/CPU/AMD: Fix AMD TLBI Erratum #1718 Borislav Petkov
  2026-10-03  0:31 ` Rik van Riel
@ 2026-10-03 21:24 ` Lorenzo Stoakes (ARM)
  2026-10-03 21:44   ` Borislav Petkov
  2026-10-05 17:42 ` [tip: x86/urgent] " tip-bot2 for Borislav Petkov (AMD)
  2 siblings, 1 reply; 6+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-10-03 21:24 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: X86, LKML, Borislav Petkov (AMD), stable, Rik van Riel

+cc Rik FYI!

On Fri, Oct 02, 2026 at 02:16:17PM -0700, Borislav Petkov wrote:
> From: "Borislav Petkov (AMD)" <bp@alien8.de>
>
> The processor may fail to invalidate a TLB entry while executing an
> INVLPGB/TLBSYNC instruction pair.

Hi,

I've repro'd the issue on a threadripper - a Ryzen Threadripper 9980X
(family 0x1a model 0x08 stepping 1) on microcode 0x0b008121 (the latest I
believe).

It failed Matt's repro in seconds on 7.2.7 (round 3 on the first run, round
1 on the second, same stale-offset signature Rik described).

It doesn't seem there's a microcode fix for the threadripper yet.

I confirmed tlbi=ipi fixed it, 20 rounds with no failures.

And I built and ran a kernel with this patch applied (and tlbi=ipi removed
from the kernel command line) and this patch fixes it it too - 40 rounds
with no failures.

So:

Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Tested-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

Hopefully some useful datapoints also - + I hope there'll be a firmware fix
for the threadripper too :)

--
Cheers, Lorenzo

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

* Re: [PATCH] x86/CPU/AMD: Fix AMD TLBI Erratum #1718
  2026-10-03 21:24 ` Lorenzo Stoakes (ARM)
@ 2026-10-03 21:44   ` Borislav Petkov
  0 siblings, 0 replies; 6+ messages in thread
From: Borislav Petkov @ 2026-10-03 21:44 UTC (permalink / raw)
  To: Lorenzo Stoakes (ARM); +Cc: Borislav Petkov, X86, LKML, stable, Rik van Riel

On Sat, Oct 03, 2026 at 10:24:40PM +0100, Lorenzo Stoakes (ARM) wrote:
> Hopefully some useful datapoints also - + I hope there'll be a firmware fix
> for the threadripper too :)

Yeah, working on it. We'll see.

Thx for the datapoints - very useful.

-- 
Regards/Gruss,
    Boris.

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

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

* [tip: x86/urgent] x86/CPU/AMD: Fix AMD TLBI Erratum #1718
  2026-10-02 21:16 [PATCH] x86/CPU/AMD: Fix AMD TLBI Erratum #1718 Borislav Petkov
  2026-10-03  0:31 ` Rik van Riel
  2026-10-03 21:24 ` Lorenzo Stoakes (ARM)
@ 2026-10-05 17:42 ` tip-bot2 for Borislav Petkov (AMD)
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Borislav Petkov (AMD) @ 2026-10-05 17:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Borislav Petkov (AMD), Rik van Riel, Lorenzo Stoakes (ARM),
	stable, x86, linux-kernel

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     87db7795cbaaf636ae22ae031f4906db7bb77803
Gitweb:        https://git.kernel.org/tip/87db7795cbaaf636ae22ae031f4906db7bb77803
Author:        Borislav Petkov (AMD) <bp@alien8.de>
AuthorDate:    Fri, 02 Oct 2026 14:16:17 -07:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 05 Oct 2026 10:29:08 -07:00

x86/CPU/AMD: Fix AMD TLBI Erratum #1718

The processor may fail to invalidate a TLB entry while executing an
INVLPGB/TLBSYNC instruction pair.

Detect the erratum and apply a software workaround when a microcode fix
is not present.

Fixes: 82378c6c2f43 ("x86/mm: Use INVLPGB for kernel TLB flushes")
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Rik van Riel <riel@surriel.com>
Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Tested-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Tested-by: Rik van Riel <riel@surriel.com>
Cc: stable@kernel.org
Link: https://patch.msgid.link/20261002211617.1001617-1-bp@kernel.org
---
 arch/x86/include/asm/cpufeatures.h | 3 +++
 arch/x86/include/asm/tlb.h         | 6 ++++++
 arch/x86/kernel/cpu/amd.c          | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index f70ee74..fe84cf4 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -477,6 +477,8 @@
 #define X86_FEATURE_NO_NESTED_DATA_BP	(20*32+ 0) /* No Nested Data Breakpoints */
 #define X86_FEATURE_WRMSR_XX_BASE_NS	(20*32+ 1) /* WRMSR to {FS,GS,KERNEL_GS}_BASE is non-serializing */
 #define X86_FEATURE_LFENCE_RDTSC	(20*32+ 2) /* LFENCE always serializing / synchronizes RDTSC */
+
+#define X86_FEATURE_TLBSYNC_SFW_NO	(20*32+ 4) /* TLBI Erratum #1718 fixed in microcode */
 #define X86_FEATURE_VERW_CLEAR		(20*32+ 5) /* The memory form of VERW mitigates TSA */
 #define X86_FEATURE_NULL_SEL_CLR_BASE	(20*32+ 6) /* Null Selector Clears Base */
 
@@ -587,4 +589,5 @@
 #define X86_BUG_TSA			X86_BUG( 1*32+ 9) /* "tsa" CPU is affected by Transient Scheduler Attacks */
 #define X86_BUG_VMSCAPE			X86_BUG( 1*32+10) /* "vmscape" CPU is affected by VMSCAPE attacks from guests */
 #define X86_BUG_SEAMRET_INVD_VMCS	X86_BUG( 1*32+11) /* "seamret_invd_vmcs" SEAMRET from P-SEAMLDR clears the current VMCS */
+#define X86_BUG_TLBI			X86_BUG( 1*32+12) /* "tlbi" AMD TLBI Erratum #1718 */
 #endif /* _ASM_X86_CPUFEATURES_H */
diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h
index 866ea78..eba925c 100644
--- a/arch/x86/include/asm/tlb.h
+++ b/arch/x86/include/asm/tlb.h
@@ -110,6 +110,12 @@ static inline void __tlbsync(void)
 
 	/* TLBSYNC: supported in binutils >= 0.36. */
 	asm volatile(".byte 0x0f, 0x01, 0xff" ::: "memory");
+
+	if (!static_cpu_has_bug(X86_BUG_TLBI))
+		return;
+
+	/* TLBSYNC: supported in binutils >= 0.36. */
+	asm volatile(".byte 0x0f, 0x01, 0xff" ::: "memory");
 }
 #else
 /* Some compilers (I'm looking at you clang!) simply can't do DCE */
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 54e14ed..40463ba 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -1049,6 +1049,10 @@ static void init_amd_zen5(struct cpuinfo_x86 *c)
 		msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
 		pr_emerg_once("RDSEED32 is broken. Disabling the corresponding CPUID bit.\n");
 	}
+
+	if (cpu_has(c, X86_FEATURE_INVLPGB) &&
+	    !cpu_has(c, X86_FEATURE_TLBSYNC_SFW_NO))
+		set_cpu_bug(c, X86_BUG_TLBI);
 }
 
 static void init_amd(struct cpuinfo_x86 *c)

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

end of thread, other threads:[~2026-10-05 17:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02 21:16 [PATCH] x86/CPU/AMD: Fix AMD TLBI Erratum #1718 Borislav Petkov
2026-10-03  0:31 ` Rik van Riel
2026-10-03  0:44   ` Borislav Petkov
2026-10-03 21:24 ` Lorenzo Stoakes (ARM)
2026-10-03 21:44   ` Borislav Petkov
2026-10-05 17:42 ` [tip: x86/urgent] " tip-bot2 for Borislav Petkov (AMD)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.