Commit 29e97589 authored by H. Peter Anvin (Intel)'s avatar H. Peter Anvin (Intel) Committed by Ingo Molnar

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: default avatarH. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210510185316.3307264-6-hpa@zytor.com
parent 6de4ac1d
...@@ -63,7 +63,7 @@ For 32-bit we have the following conventions - kernel is built with ...@@ -63,7 +63,7 @@ For 32-bit we have the following conventions - kernel is built with
* for assembly code: * for assembly code:
*/ */
.macro PUSH_AND_CLEAR_REGS rdx=%rdx rax=%rax save_ret=0 .macro PUSH_REGS rdx=%rdx rax=%rax save_ret=0
.if \save_ret .if \save_ret
pushq %rsi /* pt_regs->si */ pushq %rsi /* pt_regs->si */
movq 8(%rsp), %rsi /* temporarily store the return address in %rsi */ 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 ...@@ -90,7 +90,9 @@ For 32-bit we have the following conventions - kernel is built with
.if \save_ret .if \save_ret
pushq %rsi /* return address on top of stack */ pushq %rsi /* return address on top of stack */
.endif .endif
.endm
.macro CLEAR_REGS
/* /*
* Sanitize registers of values that a speculation attack might * Sanitize registers of values that a speculation attack might
* otherwise want to exploit. The lower registers are likely clobbered * 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 ...@@ -112,6 +114,11 @@ For 32-bit we have the following conventions - kernel is built with
.endm .endm
.macro PUSH_AND_CLEAR_REGS rdx=%rdx rax=%rax save_ret=0
PUSH_REGS rdx=\rdx, rax=\rax, save_ret=\save_ret
CLEAR_REGS
.endm
.macro POP_REGS pop_rdi=1 skip_r11rcx=0 .macro POP_REGS pop_rdi=1 skip_r11rcx=0
popq %r15 popq %r15
popq %r14 popq %r14
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment