]> www.infradead.org Git - users/hch/misc.git/commit
x86/its: Use dynamic thunks for indirect branches
authorPeter Zijlstra <peterz@infradead.org>
Mon, 14 Oct 2024 17:05:48 +0000 (10:05 -0700)
committerDave Hansen <dave.hansen@linux.intel.com>
Fri, 9 May 2025 20:36:58 +0000 (13:36 -0700)
commit872df34d7c51a79523820ea6a14860398c639b87
tree879a171d40e26b5c2258dea65914eb18b00aeb55
parentebebe30794d38c51f71fe4951ba6af4159d9837d
x86/its: Use dynamic thunks for indirect branches

ITS mitigation moves the unsafe indirect branches to a safe thunk. This
could degrade the prediction accuracy as the source address of indirect
branches becomes same for different execution paths.

To improve the predictions, and hence the performance, assign a separate
thunk for each indirect callsite. This is also a defense-in-depth measure
to avoid indirect branches aliasing with each other.

As an example, 5000 dynamic thunks would utilize around 16 bits of the
address space, thereby gaining entropy. For a BTB that uses
32 bits for indexing, dynamic thunks could provide better prediction
accuracy over fixed thunks.

Have ITS thunks be variable sized and use EXECMEM_MODULE_TEXT such that
they are both more flexible (got to extend them later) and live in 2M TLBs,
just like kernel code, avoiding undue TLB pressure.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
arch/x86/Kconfig
arch/x86/include/asm/alternative.h
arch/x86/kernel/alternative.c
arch/x86/kernel/module.c
include/linux/execmem.h
include/linux/module.h