]> git.ipfire.org Git - thirdparty/linux.git/commit
x86/mm: Enable AMD translation cache extensions
authorRik van Riel <riel@surriel.com>
Wed, 26 Feb 2025 03:00:47 +0000 (22:00 -0500)
committerIngo Molnar <mingo@kernel.org>
Wed, 19 Mar 2025 10:12:29 +0000 (11:12 +0100)
commit440a65b7d25fb06f85ee5d99c5ac492d49a15370
tree7c8384bba7d7a77bf3991ad5c812ddbcbf38ff56
parent4afeb0ed1753ebcad93ee3b45427ce85e9c8ec40
x86/mm: Enable AMD translation cache extensions

With AMD TCE (translation cache extensions) only the intermediate mappings
that cover the address range zapped by INVLPG / INVLPGB get invalidated,
rather than all intermediate mappings getting zapped at every TLB invalidation.

This can help reduce the TLB miss rate, by keeping more intermediate mappings
in the cache.

From the AMD manual:

Translation Cache Extension (TCE) Bit. Bit 15, read/write. Setting this bit to
1 changes how the INVLPG, INVLPGB, and INVPCID instructions operate on TLB
entries. When this bit is 0, these instructions remove the target PTE from the
TLB as well as all upper-level table entries that are cached in the TLB,
whether or not they are associated with the target PTE.  When this bit is set,
these instructions will remove the target PTE and only those upper-level
entries that lead to the target PTE in the page table hierarchy, leaving
unrelated upper-level entries intact.

  [ bp: use cpu_has()... I know, it is a mess. ]

Signed-off-by: Rik van Riel <riel@surriel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250226030129.530345-13-riel@surriel.com
arch/x86/include/asm/msr-index.h
arch/x86/kernel/cpu/amd.c
tools/arch/x86/include/asm/msr-index.h