Skip to content

Commit a3ba966

Browse files
committed
x86/entry/32: Clarify register saving in __switch_to_asm()
commit 6690e86 ("sched/x86: Save [ER]FLAGS on context switch") re-introduced the flags saving on context switch to prevent AC leakage. The pushf/popf instructions are right among the callee saved register section, so the comment explaining the save/restore is not entirely correct. Add a seperate comment to pushf/popf explaining the reason. Reported-by: Linus Torvalds <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
1 parent e638ad0 commit a3ba966

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

arch/x86/entry/entry_32.S

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,11 @@ ENTRY(__switch_to_asm)
718718
pushl %ebx
719719
pushl %edi
720720
pushl %esi
721+
/*
722+
* Flags are saved to prevent AC leakage. This could go
723+
* away if objtool would have 32bit support to verify
724+
* the STAC/CLAC correctness.
725+
*/
721726
pushfl
722727

723728
/* switch stack */
@@ -740,8 +745,9 @@ ENTRY(__switch_to_asm)
740745
FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
741746
#endif
742747

743-
/* restore callee-saved registers */
748+
/* Restore flags or the incoming task to restore AC state. */
744749
popfl
750+
/* restore callee-saved registers */
745751
popl %esi
746752
popl %edi
747753
popl %ebx

0 commit comments

Comments
 (0)