Skip to content

Commit

Permalink
x86/entry/32: Clarify register saving in __switch_to_asm()
Browse files Browse the repository at this point in the history
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 <torvalds@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Thomas Gleixner committed Nov 16, 2019
1 parent e638ad0 commit a3ba966
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion arch/x86/entry/entry_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,11 @@ ENTRY(__switch_to_asm)
pushl %ebx
pushl %edi
pushl %esi
/*
* Flags are saved to prevent AC leakage. This could go
* away if objtool would have 32bit support to verify
* the STAC/CLAC correctness.
*/
pushfl

/* switch stack */
Expand All @@ -740,8 +745,9 @@ ENTRY(__switch_to_asm)
FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
#endif

/* restore callee-saved registers */
/* Restore flags or the incoming task to restore AC state. */
popfl
/* restore callee-saved registers */
popl %esi
popl %edi
popl %ebx
Expand Down

0 comments on commit a3ba966

Please sign in to comment.