Skip to content

Commit 29e9758

Browse files
H. Peter Anvin (Intel)ingomolnar
authored andcommitted
x86/entry: Split PUSH_AND_CLEAR_REGS into two submacros
PUSH_AND_CLEAR_REGS, as the name implies, performs two functions: pushing registers and clearing registers. They don't necessarily have to be performed in immediate sequence, although all current users do. Split it into two macros for the case where that isn't desired; the FRED enabling patchset will eventually make use of this. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20210510185316.3307264-6-hpa@zytor.com
1 parent 6de4ac1 commit 29e9758

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

arch/x86/entry/calling.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ For 32-bit we have the following conventions - kernel is built with
6363
* for assembly code:
6464
*/
6565

66-
.macro PUSH_AND_CLEAR_REGS rdx=%rdx rax=%rax save_ret=0
66+
.macro PUSH_REGS rdx=%rdx rax=%rax save_ret=0
6767
.if \save_ret
6868
pushq %rsi /* pt_regs->si */
6969
movq 8(%rsp), %rsi /* temporarily store the return address in %rsi */
@@ -90,7 +90,9 @@ For 32-bit we have the following conventions - kernel is built with
9090
.if \save_ret
9191
pushq %rsi /* return address on top of stack */
9292
.endif
93+
.endm
9394

95+
.macro CLEAR_REGS
9496
/*
9597
* Sanitize registers of values that a speculation attack might
9698
* otherwise want to exploit. The lower registers are likely clobbered
@@ -112,6 +114,11 @@ For 32-bit we have the following conventions - kernel is built with
112114

113115
.endm
114116

117+
.macro PUSH_AND_CLEAR_REGS rdx=%rdx rax=%rax save_ret=0
118+
PUSH_REGS rdx=\rdx, rax=\rax, save_ret=\save_ret
119+
CLEAR_REGS
120+
.endm
121+
115122
.macro POP_REGS pop_rdi=1 skip_r11rcx=0
116123
popq %r15
117124
popq %r14

0 commit comments

Comments
 (0)