Skip to content

Commit 9dbd23e

Browse files
committed
x86/srso: Explain the untraining sequences a bit more
The goal is to eventually have a proper documentation about all this. Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20230814164447.GFZNpZ/64H4lENIe94@fat_crate.local
1 parent 864bcaa commit 9dbd23e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

arch/x86/lib/retpoline.S

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,25 @@ SYM_CODE_START(srso_alias_return_thunk)
186186
ud2
187187
SYM_CODE_END(srso_alias_return_thunk)
188188

189+
/*
190+
* Some generic notes on the untraining sequences:
191+
*
192+
* They are interchangeable when it comes to flushing potentially wrong
193+
* RET predictions from the BTB.
194+
*
195+
* The SRSO Zen1/2 (MOVABS) untraining sequence is longer than the
196+
* Retbleed sequence because the return sequence done there
197+
* (srso_safe_ret()) is longer and the return sequence must fully nest
198+
* (end before) the untraining sequence. Therefore, the untraining
199+
* sequence must fully overlap the return sequence.
200+
*
201+
* Regarding alignment - the instructions which need to be untrained,
202+
* must all start at a cacheline boundary for Zen1/2 generations. That
203+
* is, instruction sequences starting at srso_safe_ret() and
204+
* the respective instruction sequences at retbleed_return_thunk()
205+
* must start at a cacheline boundary.
206+
*/
207+
189208
/*
190209
* Safety details here pertain to the AMD Zen{1,2} microarchitecture:
191210
* 1) The RET at retbleed_return_thunk must be on a 64 byte boundary, for

0 commit comments

Comments
 (0)