Skip to content

Commit 42be649

Browse files
Peter Zijlstrabp3tk0v
authored andcommitted
x86/cpu: Rename srso_(.*)_alias to srso_alias_\1
For a more consistent namespace. [ bp: Fixup names in the doc too. ] Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d025b7b commit 42be649

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

Documentation/admin-guide/hw-vuln/srso.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ sequence.
141141
To ensure the safety of this mitigation, the kernel must ensure that the
142142
safe return sequence is itself free from attacker interference. In Zen3
143143
and Zen4, this is accomplished by creating a BTB alias between the
144-
untraining function srso_untrain_ret_alias() and the safe return
145-
function srso_safe_ret_alias() which results in evicting a potentially
144+
untraining function srso_alias_untrain_ret() and the safe return
145+
function srso_alias_safe_ret() which results in evicting a potentially
146146
poisoned BTB entry and using that safe one for all function returns.
147147

148148
In older Zen1 and Zen2, this is accomplished using a reinterpretation

arch/x86/include/asm/nospec-branch.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@
300300

301301
#ifdef CONFIG_CPU_SRSO
302302
ALTERNATIVE_2 "", "call srso_untrain_ret", X86_FEATURE_SRSO, \
303-
"call srso_untrain_ret_alias", X86_FEATURE_SRSO_ALIAS
303+
"call srso_alias_untrain_ret", X86_FEATURE_SRSO_ALIAS
304304
#endif
305305
.endm
306306

@@ -316,7 +316,7 @@
316316

317317
#ifdef CONFIG_CPU_SRSO
318318
ALTERNATIVE_2 "", "call srso_untrain_ret", X86_FEATURE_SRSO, \
319-
"call srso_untrain_ret_alias", X86_FEATURE_SRSO_ALIAS
319+
"call srso_alias_untrain_ret", X86_FEATURE_SRSO_ALIAS
320320
#endif
321321
.endm
322322

@@ -353,7 +353,7 @@ extern void srso_alias_return_thunk(void);
353353

354354
extern void retbleed_untrain_ret(void);
355355
extern void srso_untrain_ret(void);
356-
extern void srso_untrain_ret_alias(void);
356+
extern void srso_alias_untrain_ret(void);
357357

358358
extern void entry_ibpb(void);
359359

arch/x86/kernel/vmlinux.lds.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ SECTIONS
147147

148148
#ifdef CONFIG_CPU_SRSO
149149
/*
150-
* See the comment above srso_untrain_ret_alias()'s
150+
* See the comment above srso_alias_untrain_ret()'s
151151
* definition.
152152
*/
153-
. = srso_untrain_ret_alias | (1 << 2) | (1 << 8) | (1 << 14) | (1 << 20);
153+
. = srso_alias_untrain_ret | (1 << 2) | (1 << 8) | (1 << 14) | (1 << 20);
154154
*(.text..__x86.rethunk_safe)
155155
#endif
156156
ALIGN_ENTRY_TEXT_END
@@ -536,8 +536,8 @@ INIT_PER_CPU(irq_stack_backing_store);
536536
* Instead do: (A | B) - (A & B) in order to compute the XOR
537537
* of the two function addresses:
538538
*/
539-
. = ASSERT(((ABSOLUTE(srso_untrain_ret_alias) | srso_safe_ret_alias) -
540-
(ABSOLUTE(srso_untrain_ret_alias) & srso_safe_ret_alias)) == ((1 << 2) | (1 << 8) | (1 << 14) | (1 << 20)),
539+
. = ASSERT(((ABSOLUTE(srso_alias_untrain_ret) | srso_alias_safe_ret) -
540+
(ABSOLUTE(srso_alias_untrain_ret) & srso_alias_safe_ret)) == ((1 << 2) | (1 << 8) | (1 << 14) | (1 << 20)),
541541
"SRSO function pair won't alias");
542542
#endif
543543

arch/x86/lib/retpoline.S

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,56 +133,56 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array)
133133
#ifdef CONFIG_RETHUNK
134134

135135
/*
136-
* srso_untrain_ret_alias() and srso_safe_ret_alias() are placed at
136+
* srso_alias_untrain_ret() and srso_alias_safe_ret() are placed at
137137
* special addresses:
138138
*
139-
* - srso_untrain_ret_alias() is 2M aligned
140-
* - srso_safe_ret_alias() is also in the same 2M page but bits 2, 8, 14
139+
* - srso_alias_untrain_ret() is 2M aligned
140+
* - srso_alias_safe_ret() is also in the same 2M page but bits 2, 8, 14
141141
* and 20 in its virtual address are set (while those bits in the
142-
* srso_untrain_ret_alias() function are cleared).
142+
* srso_alias_untrain_ret() function are cleared).
143143
*
144144
* This guarantees that those two addresses will alias in the branch
145145
* target buffer of Zen3/4 generations, leading to any potential
146146
* poisoned entries at that BTB slot to get evicted.
147147
*
148-
* As a result, srso_safe_ret_alias() becomes a safe return.
148+
* As a result, srso_alias_safe_ret() becomes a safe return.
149149
*/
150150
#ifdef CONFIG_CPU_SRSO
151151
.section .text..__x86.rethunk_untrain
152152

153-
SYM_START(srso_untrain_ret_alias, SYM_L_GLOBAL, SYM_A_NONE)
153+
SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE)
154154
UNWIND_HINT_FUNC
155155
ANNOTATE_NOENDBR
156156
ASM_NOP2
157157
lfence
158158
jmp srso_alias_return_thunk
159-
SYM_FUNC_END(srso_untrain_ret_alias)
160-
__EXPORT_THUNK(srso_untrain_ret_alias)
159+
SYM_FUNC_END(srso_alias_untrain_ret)
160+
__EXPORT_THUNK(srso_alias_untrain_ret)
161161

162162
.section .text..__x86.rethunk_safe
163163
#else
164164
/* dummy definition for alternatives */
165-
SYM_START(srso_untrain_ret_alias, SYM_L_GLOBAL, SYM_A_NONE)
165+
SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE)
166166
ANNOTATE_UNRET_SAFE
167167
ret
168168
int3
169-
SYM_FUNC_END(srso_untrain_ret_alias)
169+
SYM_FUNC_END(srso_alias_untrain_ret)
170170
#endif
171171

172-
SYM_START(srso_safe_ret_alias, SYM_L_GLOBAL, SYM_A_NONE)
172+
SYM_START(srso_alias_safe_ret, SYM_L_GLOBAL, SYM_A_NONE)
173173
lea 8(%_ASM_SP), %_ASM_SP
174174
UNWIND_HINT_FUNC
175175
ANNOTATE_UNRET_SAFE
176176
ret
177177
int3
178-
SYM_FUNC_END(srso_safe_ret_alias)
178+
SYM_FUNC_END(srso_alias_safe_ret)
179179

180180
.section .text..__x86.return_thunk
181181

182182
SYM_CODE_START(srso_alias_return_thunk)
183183
UNWIND_HINT_FUNC
184184
ANNOTATE_NOENDBR
185-
call srso_safe_ret_alias
185+
call srso_alias_safe_ret
186186
ud2
187187
SYM_CODE_END(srso_alias_return_thunk)
188188

0 commit comments

Comments
 (0)