This is a note to let you know that I've just added the patch titled x86/srso: Explain the untraining sequences a bit more to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: x86-srso-explain-the-untraining-sequences-a-bit-more.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 9dbd23e42ff0b10c9b02c9e649c76e5228241a8e Mon Sep 17 00:00:00 2001 From: "Borislav Petkov (AMD)" <bp@xxxxxxxxx> Date: Mon, 14 Aug 2023 21:29:50 +0200 Subject: x86/srso: Explain the untraining sequences a bit more From: Borislav Petkov (AMD) <bp@xxxxxxxxx> commit 9dbd23e42ff0b10c9b02c9e649c76e5228241a8e upstream. The goal is to eventually have a proper documentation about all this. Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx> Link: https://lore.kernel.org/r/20230814164447.GFZNpZ/64H4lENIe94@fat_crate.local Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- arch/x86/lib/retpoline.S | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) --- a/arch/x86/lib/retpoline.S +++ b/arch/x86/lib/retpoline.S @@ -128,6 +128,25 @@ SYM_CODE_START(srso_alias_return_thunk) 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 * alignment within the BTB. Patches currently in stable-queue which might be from bp@xxxxxxxxx are queue-5.10/x86-cpu-fix-up-srso_safe_ret-and-__x86_return_thunk.patch queue-5.10/x86-cpu-cleanup-the-untrain-mess.patch queue-5.10/objtool-x86-fixup-frame-pointer-vs-rethunk.patch queue-5.10/x86-srso-correct-the-mitigation-status-when-smt-is-disabled.patch queue-5.10/x86-retpoline-don-t-clobber-rflags-during-srso_safe_ret.patch queue-5.10/x86-retpoline-kprobes-fix-position-of-thunk-sections-with-config_lto_clang.patch queue-5.10/x86-cpu-amd-fix-the-div-0-initial-fix-attempt.patch queue-5.10/x86-cpu-rename-srso_-.-_alias-to-srso_alias_-1.patch queue-5.10/x86-srso-explain-the-untraining-sequences-a-bit-more.patch queue-5.10/x86-alternative-make-custom-return-thunk-unconditional.patch queue-5.10/x86-cpu-rename-original-retbleed-methods.patch queue-5.10/x86-cpu-clean-up-srso-return-thunk-mess.patch queue-5.10/x86-srso-disable-the-mitigation-on-unaffected-configurations.patch queue-5.10/x86-cpu-fix-__x86_return_thunk-symbol-type.patch