Commit 80fdba2a authored by Borislav Petkov (AMD)'s avatar Borislav Petkov (AMD) Committed by sanglipeng
Browse files

x86/srso: Explain the untraining sequences a bit more

stable inclusion
from stable-v5.10.192
commit d2be58f9215a480c1aed3e47e1b2b889d83a8fed
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I933RF

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d2be58f9215a480c1aed3e47e1b2b889d83a8fed



--------------------------------

commit 9dbd23e4 upstream.

The goal is to eventually have a proper documentation about all this.

Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20230814164447.GFZNpZ/64H4lENIe94@fat_crate.local


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent a64b00f0
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -127,6 +127,25 @@ SYM_CODE_START(srso_alias_return_thunk)
	ud2
SYM_CODE_END(srso_alias_return_thunk)

/*
 * Some generic notes on the untraining sequences:
 *
 * They are interchangeable when it comes to flushing potentially wrong
 * RET predictions from the BTB.
 *
 * The SRSO Zen1/2 (MOVABS) untraining sequence is longer than the
 * Retbleed sequence because the return sequence done there
 * (srso_safe_ret()) is longer and the return sequence must fully nest
 * (end before) the untraining sequence. Therefore, the untraining
 * sequence must fully overlap the return sequence.
 *
 * Regarding alignment - the instructions which need to be untrained,
 * must all start at a cacheline boundary for Zen1/2 generations. That
 * is, instruction sequences starting at srso_safe_ret() and
 * the respective instruction sequences at retbleed_return_thunk()
 * must start at a cacheline boundary.
 */

/*
 * Safety details here pertain to the AMD Zen{1,2} microarchitecture:
 * 1) The RET at retbleed_return_thunk must be on a 64 byte boundary, for