All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add tlbi=off to disable INVLPGB
@ 2026-07-30  0:43 Rik van Riel
  2026-07-30  1:44 ` Borislav Petkov
  0 siblings, 1 reply; 9+ messages in thread
From: Rik van Riel @ 2026-07-30  0:43 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner,
	Ingo Molnar, x86, linux-kernel, kernel-team

With the recently found INVLPGB / TLBSYNC issue, there has been some
interest in disabling invlpgb TLB flushing, in order to rule out
that CPU issue as a cause of userspace crashes.

The top search result shows "clearcpuid=invlpgb"

However, invlpgb is not actually in x86_cap_flags, so booting with
clearcpuid=invlpgb results in an error message:

  clearcpuid: unknown CPU flag: invlpgb

Add a kernel commandline option to turn off AMD TLBI, to make it
easier to rule out INVLPGB as a cause of userspace crashes.

Verified by booting a Bergamo system with tlbi=off and checking
that the INVLPGB bit is clear in boot_cpu_data.x86_capability

Signed-off-by: Rik van Riel <riel@surriel.com>
Suggested-by: Borislav Petkov <bp@alien8.de>
---
 arch/x86/mm/init_64.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index d57f29ca23a5..412ad9cd5fe2 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -130,6 +130,19 @@ static int __init nonx32_setup(char *str)
 }
 __setup("noexec32=", nonx32_setup);
 
+/*
+ * tlbi=off
+ *
+ * Control AMD TLBI feature (INVLPGB TLB flushing)
+ */
+static int __init tlbi_setup(char *str)
+{
+	if (!strcmp(str, "off"))
+		setup_clear_cpu_cap(X86_FEATURE_INVLPGB);
+	return 1;
+}
+__setup("tlbi=", tlbi_setup);
+
 static void sync_global_pgds_l5(unsigned long start, unsigned long end)
 {
 	unsigned long addr;
-- 
2.53.0-Meta


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

* Re: [PATCH] add tlbi=off to disable INVLPGB
  2026-07-30  0:43 [PATCH] add tlbi=off to disable INVLPGB Rik van Riel
@ 2026-07-30  1:44 ` Borislav Petkov
  2026-07-30 10:32   ` Peter Zijlstra
  0 siblings, 1 reply; 9+ messages in thread
From: Borislav Petkov @ 2026-07-30  1:44 UTC (permalink / raw)
  To: Rik van Riel
  Cc: Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner,
	Ingo Molnar, x86, linux-kernel, kernel-team

On Wed, Jul 29, 2026 at 08:43:41PM -0400, Rik van Riel wrote:
> With the recently found INVLPGB / TLBSYNC issue, there has been some
> interest in disabling invlpgb TLB flushing, in order to rule out
> that CPU issue as a cause of userspace crashes.
> 
> The top search result shows "clearcpuid=invlpgb"
> 
> However, invlpgb is not actually in x86_cap_flags, so booting with
> clearcpuid=invlpgb results in an error message:
> 
>   clearcpuid: unknown CPU flag: invlpgb
> 
> Add a kernel commandline option to turn off AMD TLBI, to make it
> easier to rule out INVLPGB as a cause of userspace crashes.
> 
> Verified by booting a Bergamo system with tlbi=off and checking
> that the INVLPGB bit is clear in boot_cpu_data.x86_capability
> 
> Signed-off-by: Rik van Riel <riel@surriel.com>
> Suggested-by: Borislav Petkov <bp@alien8.de>
> ---
>  arch/x86/mm/init_64.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)

I'll take that and raise you with v2:

The rationale for moving it to amd.c is that it won't be there on builds which
don't enable AMD code. And we could still raise it up somewhere
vendor-agnostic later if the other vendor wants to be able to disable their
version if TLB invalidation glue implementation.

From: Rik van Riel <riel@surriel.com>
Date: Wed, 29 Jul 2026 20:43:41 -0400
Subject: [PATCH] x86/CPU/AMD: Add a tlbi= cmdline switch

With the recently found INVLPGB / TLBSYNC issue, there has been some
interest in disabling INVLPGB-based TLB flushing, in order to rule out
that CPU issue as a cause of userspace crashes.

Add a kernel command line option to control AMD TLBI.

  [ bp: Rewrite commit message, move to amd.c, add documentation. ]

Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Rik van Riel <riel@surriel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://patch.msgid.link/20260729204341.3eb0b5ea@fangorn
---
 Documentation/admin-guide/kernel-parameters.txt |  5 +++++
 arch/x86/kernel/cpu/amd.c                       | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 87bb1fb31696..4e3c5fa411d2 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -7568,6 +7568,11 @@ Kernel parameters
 			See Documentation/admin-guide/mm/transhuge.rst for more
 			details.
 
+	tlbi=		[X86-64]
+			Format: {off}
+			Control the AMD TLBI feature support (INVLPGB-based
+			TLB flushing).
+
 	topology=	[S390,EARLY]
 			Format: {off | on}
 			Specify if the kernel should make use of the cpu
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 54e14ed276b5..a3cde941a81d 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -1440,3 +1440,13 @@ static __init int print_dmi_agesa(void)
 	return 0;
 }
 late_initcall(print_dmi_agesa);
+
+/* Control TLBI feature (INVLPGB-based TLB flushing) */
+static int __init tlbi_setup(char *str)
+{
+	if (!strcmp(str, "off"))
+		setup_clear_cpu_cap(X86_FEATURE_INVLPGB);
+
+	return 1;
+}
+__setup("tlbi=", tlbi_setup);
-- 
2.53.0

-- 
Regards/Gruss,
    Boris.

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

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

* Re: [PATCH] add tlbi=off to disable INVLPGB
  2026-07-30  1:44 ` Borislav Petkov
@ 2026-07-30 10:32   ` Peter Zijlstra
  2026-07-30 16:23     ` Borislav Petkov
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Zijlstra @ 2026-07-30 10:32 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Rik van Riel, Dave Hansen, Andy Lutomirski, Thomas Gleixner,
	Ingo Molnar, x86, linux-kernel, kernel-team

On Wed, Jul 29, 2026 at 06:44:12PM -0700, Borislav Petkov wrote:
> On Wed, Jul 29, 2026 at 08:43:41PM -0400, Rik van Riel wrote:
> > With the recently found INVLPGB / TLBSYNC issue, there has been some
> > interest in disabling invlpgb TLB flushing, in order to rule out
> > that CPU issue as a cause of userspace crashes.
> > 
> > The top search result shows "clearcpuid=invlpgb"
> > 
> > However, invlpgb is not actually in x86_cap_flags, so booting with
> > clearcpuid=invlpgb results in an error message:
> > 
> >   clearcpuid: unknown CPU flag: invlpgb
> > 
> > Add a kernel commandline option to turn off AMD TLBI, to make it
> > easier to rule out INVLPGB as a cause of userspace crashes.
> > 
> > Verified by booting a Bergamo system with tlbi=off and checking
> > that the INVLPGB bit is clear in boot_cpu_data.x86_capability
> > 
> > Signed-off-by: Rik van Riel <riel@surriel.com>
> > Suggested-by: Borislav Petkov <bp@alien8.de>
> > ---
> >  arch/x86/mm/init_64.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> 
> I'll take that and raise you with v2:
> 
> The rationale for moving it to amd.c is that it won't be there on builds which
> don't enable AMD code. And we could still raise it up somewhere
> vendor-agnostic later if the other vendor wants to be able to disable their
> version if TLB invalidation glue implementation.
> 
> From: Rik van Riel <riel@surriel.com>
> Date: Wed, 29 Jul 2026 20:43:41 -0400
> Subject: [PATCH] x86/CPU/AMD: Add a tlbi= cmdline switch
> 
> With the recently found INVLPGB / TLBSYNC issue, there has been some
> interest in disabling INVLPGB-based TLB flushing, in order to rule out
> that CPU issue as a cause of userspace crashes.
> 
> Add a kernel command line option to control AMD TLBI.
> 
>   [ bp: Rewrite commit message, move to amd.c, add documentation. ]
> 
> Suggested-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Rik van Riel <riel@surriel.com>
> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
> Link: https://patch.msgid.link/20260729204341.3eb0b5ea@fangorn
> ---
>  Documentation/admin-guide/kernel-parameters.txt |  5 +++++
>  arch/x86/kernel/cpu/amd.c                       | 10 ++++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 87bb1fb31696..4e3c5fa411d2 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -7568,6 +7568,11 @@ Kernel parameters
>  			See Documentation/admin-guide/mm/transhuge.rst for more
>  			details.
>  
> +	tlbi=		[X86-64]
> +			Format: {off}
> +			Control the AMD TLBI feature support (INVLPGB-based
> +			TLB flushing).
> +
>  	topology=	[S390,EARLY]
>  			Format: {off | on}
>  			Specify if the kernel should make use of the cpu
> diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> index 54e14ed276b5..a3cde941a81d 100644
> --- a/arch/x86/kernel/cpu/amd.c
> +++ b/arch/x86/kernel/cpu/amd.c
> @@ -1440,3 +1440,13 @@ static __init int print_dmi_agesa(void)
>  	return 0;
>  }
>  late_initcall(print_dmi_agesa);
> +
> +/* Control TLBI feature (INVLPGB-based TLB flushing) */
> +static int __init tlbi_setup(char *str)
> +{
> +	if (!strcmp(str, "off"))
> +		setup_clear_cpu_cap(X86_FEATURE_INVLPGB);
> +
> +	return 1;
> +}
> +__setup("tlbi=", tlbi_setup);

TLBI stands for Translation Lookaside Buffer Invalidation. So a command
line that says: 'tlbi=off' means no move invalidation *at*all*. This
seems like a very bad option.

Please rename.

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

* Re: [PATCH] add tlbi=off to disable INVLPGB
  2026-07-30 10:32   ` Peter Zijlstra
@ 2026-07-30 16:23     ` Borislav Petkov
  2026-07-30 17:31       ` Peter Zijlstra
  0 siblings, 1 reply; 9+ messages in thread
From: Borislav Petkov @ 2026-07-30 16:23 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Rik van Riel, Dave Hansen, Andy Lutomirski, Thomas Gleixner,
	Ingo Molnar, x86, linux-kernel, kernel-team

On Thu, Jul 30, 2026 at 12:32:27PM +0200, Peter Zijlstra wrote:
> TLBI stands for Translation Lookaside Buffer Invalidation.

... instructions." Both ARM and AMD call it this. The usual abbreviation
overload we're suffering from.

> So a command line that says: 'tlbi=off' means no move invalidation *at*all*.
> This seems like a very bad option.
> 
> Please rename.

You suggest one. :-P

But it needs to be short and relatively easy to type. And "invlpgb" ain't easy
and I can't tell you how many times I've seen it getting typoed.

Thx.

-- 
Regards/Gruss,
    Boris.

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

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

* Re: [PATCH] add tlbi=off to disable INVLPGB
  2026-07-30 16:23     ` Borislav Petkov
@ 2026-07-30 17:31       ` Peter Zijlstra
  2026-07-30 18:24         ` Borislav Petkov
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Zijlstra @ 2026-07-30 17:31 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Rik van Riel, Dave Hansen, Andy Lutomirski, Thomas Gleixner,
	Ingo Molnar, x86, linux-kernel, kernel-team

On Thu, Jul 30, 2026 at 09:23:18AM -0700, Borislav Petkov wrote:
> On Thu, Jul 30, 2026 at 12:32:27PM +0200, Peter Zijlstra wrote:
> > TLBI stands for Translation Lookaside Buffer Invalidation.
> 
> ... instructions." Both ARM and AMD call it this. The usual abbreviation
> overload we're suffering from.

Same difference, that would mean disabling all TLB instructions :-) Very
much including the local invalidation used for IPI based TLB
invalidation.

But also, nah:

  https://support.arm.com/documentation/dui0802/b/A64-General-Instructions/TLBI

"TLBI - TLB invalidate operation."
  
> > So a command line that says: 'tlbi=off' means no move invalidation *at*all*.
> > This seems like a very bad option.
> > 
> > Please rename.
> 
> You suggest one. :-P
> 
> But it needs to be short and relatively easy to type. And "invlpgb" ain't easy
> and I can't tell you how many times I've seen it getting typoed.

  tlbi={ipi,broadcast}

Anyway, INVLPGB stands for INVaLidate PaGe Broadcast, ain'ted that hard
:-) Also, you know who to complain to for that instruction :-)

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

* Re: [PATCH] add tlbi=off to disable INVLPGB
  2026-07-30 17:31       ` Peter Zijlstra
@ 2026-07-30 18:24         ` Borislav Petkov
  2026-07-31  8:46           ` Peter Zijlstra
  0 siblings, 1 reply; 9+ messages in thread
From: Borislav Petkov @ 2026-07-30 18:24 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Rik van Riel, Dave Hansen, Andy Lutomirski, Thomas Gleixner,
	Ingo Molnar, x86, linux-kernel, kernel-team

On Thu, Jul 30, 2026 at 07:31:04PM +0200, Peter Zijlstra wrote:
> But also, nah:
> 
>   https://support.arm.com/documentation/dui0802/b/A64-General-Instructions/TLBI
> 
> "TLBI - TLB invalidate operation."

Yap, that's what I meant.

>   tlbi={ipi,broadcast}
> 
> Anyway, INVLPGB stands for INVaLidate PaGe Broadcast, ain'ted that hard
> :-) Also, you know who to complain to for that instruction :-)

Too late for that. :)

"tlbi=broadcast" is a bit much to type: imagine you're hunched over some box
in the server room, like Spiderman, crouching between racks and balancing the
keyboard on some old pile of cables... :-P

So how about shorter:

"tlbi=bcast"
"tlbi=ipi"

?

We probably won't need to write "bcast" at all, actually, because that would
be the default. So "tlbi=ipi" only. Yeah, that's good.

Thx.

-- 
Regards/Gruss,
    Boris.

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

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

* Re: [PATCH] add tlbi=off to disable INVLPGB
  2026-07-30 18:24         ` Borislav Petkov
@ 2026-07-31  8:46           ` Peter Zijlstra
  2026-07-31  9:14             ` David Laight
  2026-07-31 11:47             ` Rik van Riel
  0 siblings, 2 replies; 9+ messages in thread
From: Peter Zijlstra @ 2026-07-31  8:46 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Rik van Riel, Dave Hansen, Andy Lutomirski, Thomas Gleixner,
	Ingo Molnar, x86, linux-kernel, kernel-team

On Thu, Jul 30, 2026 at 11:24:39AM -0700, Borislav Petkov wrote:
> On Thu, Jul 30, 2026 at 07:31:04PM +0200, Peter Zijlstra wrote:
> > But also, nah:
> > 
> >   https://support.arm.com/documentation/dui0802/b/A64-General-Instructions/TLBI
> > 
> > "TLBI - TLB invalidate operation."
> 
> Yap, that's what I meant.
> 
> >   tlbi={ipi,broadcast}
> > 
> > Anyway, INVLPGB stands for INVaLidate PaGe Broadcast, ain'ted that hard
> > :-) Also, you know who to complain to for that instruction :-)
> 
> Too late for that. :)
> 
> "tlbi=broadcast" is a bit much to type: imagine you're hunched over some box
> in the server room, like Spiderman, crouching between racks and balancing the
> keyboard on some old pile of cables... :-P

There is IPMI and other fancy remote management stuff these days. There
is no reason to suffer hearing loss for entering server rooms anymore
:-)

> So how about shorter:
> 
> "tlbi=bcast"
> "tlbi=ipi"
> 
> ?
> 
> We probably won't need to write "bcast" at all, actually, because that would
> be the default. So "tlbi=ipi" only. Yeah, that's good.

Didn't we have a case where INVLPGB was disabled due to firmware or
something? I was thinking tlbi=broadcast could be used to force enable
it or something.

Anyway, if that case don't exist, then yeah.

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

* Re: [PATCH] add tlbi=off to disable INVLPGB
  2026-07-31  8:46           ` Peter Zijlstra
@ 2026-07-31  9:14             ` David Laight
  2026-07-31 11:47             ` Rik van Riel
  1 sibling, 0 replies; 9+ messages in thread
From: David Laight @ 2026-07-31  9:14 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Borislav Petkov, Rik van Riel, Dave Hansen, Andy Lutomirski,
	Thomas Gleixner, Ingo Molnar, x86, linux-kernel, kernel-team

On Fri, 31 Jul 2026 10:46:56 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> On Thu, Jul 30, 2026 at 11:24:39AM -0700, Borislav Petkov wrote:
> > On Thu, Jul 30, 2026 at 07:31:04PM +0200, Peter Zijlstra wrote:  
> > > But also, nah:
> > > 
> > >   https://support.arm.com/documentation/dui0802/b/A64-General-Instructions/TLBI
> > > 
> > > "TLBI - TLB invalidate operation."  
> > 
> > Yap, that's what I meant.
> >   
> > >   tlbi={ipi,broadcast}
> > > 
> > > Anyway, INVLPGB stands for INVaLidate PaGe Broadcast, ain'ted that hard
> > > :-) Also, you know who to complain to for that instruction :-)  
> > 
> > Too late for that. :)
> > 
> > "tlbi=broadcast" is a bit much to type: imagine you're hunched over some box
> > in the server room, like Spiderman, crouching between racks and balancing the
> > keyboard on some old pile of cables... :-P  
> 
> There is IPMI and other fancy remote management stuff these days. There
> is no reason to suffer hearing loss for entering server rooms anymore
> :-)

The real problem is typing while wearing ski gloves...

	David

> 
> > So how about shorter:
> > 
> > "tlbi=bcast"
> > "tlbi=ipi"
> > 
> > ?
> > 
> > We probably won't need to write "bcast" at all, actually, because that would
> > be the default. So "tlbi=ipi" only. Yeah, that's good.  
> 
> Didn't we have a case where INVLPGB was disabled due to firmware or
> something? I was thinking tlbi=broadcast could be used to force enable
> it or something.
> 
> Anyway, if that case don't exist, then yeah.
> 


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

* Re: [PATCH] add tlbi=off to disable INVLPGB
  2026-07-31  8:46           ` Peter Zijlstra
  2026-07-31  9:14             ` David Laight
@ 2026-07-31 11:47             ` Rik van Riel
  1 sibling, 0 replies; 9+ messages in thread
From: Rik van Riel @ 2026-07-31 11:47 UTC (permalink / raw)
  To: Peter Zijlstra, Borislav Petkov
  Cc: Dave Hansen, Andy Lutomirski, Thomas Gleixner, Ingo Molnar, x86,
	linux-kernel, kernel-team

On Fri, 2026-07-31 at 10:46 +0200, Peter Zijlstra wrote:
> On Thu, Jul 30, 2026 at 11:24:39AM -0700, Borislav Petkov wrote:
> 
> > 
> > We probably won't need to write "bcast" at all, actually, because
> > that would
> > be the default. So "tlbi=ipi" only. Yeah, that's good.
> 
> Didn't we have a case where INVLPGB was disabled due to firmware or
> something? I was thinking tlbi=broadcast could be used to force
> enable
> it or something.

I have a mini PC here that does just that.

lspcu says:
      AMD Ryzen 9 7940HS w/ Radeon 780M Graphics

That suggests the core should have INVLPGB built-in,
but it shows up as disabled in cpuid.

$ cpuid -1 | grep INVLPGB
      INVLPGB instruction                      = false
      INVLPGB supports TLB flush guest nested  = false
      max page count for INVLPGB instruction = 0x0 (0)
      INVLPGB/TLBSYNC hyperv interc enable    = false

I have not been able to find a BIOS option that
results in it being enabled.

-- 
All Rights Reversed.

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

end of thread, other threads:[~2026-07-31 11:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-30  0:43 [PATCH] add tlbi=off to disable INVLPGB Rik van Riel
2026-07-30  1:44 ` Borislav Petkov
2026-07-30 10:32   ` Peter Zijlstra
2026-07-30 16:23     ` Borislav Petkov
2026-07-30 17:31       ` Peter Zijlstra
2026-07-30 18:24         ` Borislav Petkov
2026-07-31  8:46           ` Peter Zijlstra
2026-07-31  9:14             ` David Laight
2026-07-31 11:47             ` Rik van Riel

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.