x86: entry_64.S: fold test_in_nmi macro into its only user
PATCH v2 4/6 x86: entry_64.S: fold test_in_nmi macro into its only user
No code changes.
Changes since v1: added comments as requested by Steven Rostedt
Signed-off-by Denys Vlasenko <[email protected]>
CC Linus Torvalds <[email protected]>
CC Oleg Nesterov <[email protected]>
CC Borislav Petkov <[email protected]>
CC "H. Peter Anvin" <[email protected]>
CC Andy Lutomirski <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC X86 ML <[email protected]>
CC Alexei Starovoitov <[email protected]>
CC Will Drewry <[email protected]>
CC Kees Cook <[email protected]>
CC Steven Rostedt <[email protected]>
--- arch/x86/kernel/entry_64.S | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
arch/x86/kernel/entry_64.S +14 -16
@@ -1378,19 +1378,7 @@ ENTRY(error_exit) CFI_ENDPROC END(error_exit) -/* - * Test if a given stack is an NMI stack or not. - */ - .macro test_in_nmi reg stack nmi_ret normal_ret - cmpq %\reg, \stack - ja \normal_ret - subq $EXCEPTION_STKSZ, %\reg - cmpq %\reg, \stack - jb \normal_ret - jmp \nmi_ret - .endm - - /* runs on exception stack */ +/* Runs on exception stack */ ENTRY(nmi) INTR_FRAME PARAVIRT_ADJUST_EXCEPTION_FRAME
@@ -1426,7 +1414,7 @@ ENTRY(nmi) * NMI. */ - /* Use %rdx as out temp variable throughout */ + /* Use %rdx as our temp variable throughout */ pushq_cfi %rdx CFI_REL_OFFSET rdx, 0
@@ -1451,8 +1439,18 @@ ENTRY(nmi) * We check the variable because the first NMI could be in a * breakpoint routine using a breakpoint stack. */ - lea 6*8(%rsp), %rdx - test_in_nmi rdx, 4*8(%rsp), nested_nmi, first_nmi + lea 6*8(%rsp), %rdx + /* Compare the NMI stack (rdx) with the stack we came from (4*8(%rsp)) */ + cmpq %rdx, 4*8(%rsp) + /* If the stack pointer is above the NMI stack, this is a normal NMI */ + ja first_nmi + subq $EXCEPTION_STKSZ, %rdx + cmpq %rdx, 4*8(%rsp) + /* If it is below the NMI stack, it is a normal NMI */ + jb first_nmi + /* Ah, it is within the NMI stack, treat it as nested */ + jmp nested_nmi + CFI_REMEMBER_STATE nested_nmi:
Signature · 1 line
1.8.1.4
Quoted 17 lines · Denys Vlasenko
No code changes.
Changes since v1: added comments as requested by Steven Rostedt
Signed-off-by Denys Vlasenko <[email protected]>CC Linus Torvalds <[email protected]>CC Oleg Nesterov <[email protected]>CC Borislav Petkov <[email protected]>CC "H. Peter Anvin" <[email protected]>CC Andy Lutomirski <[email protected]>CC Frederic Weisbecker <[email protected]>CC X86 ML <[email protected]>CC Alexei Starovoitov <[email protected]>CC Will Drewry <[email protected]>CC Kees Cook <[email protected]>CC Steven Rostedt <[email protected]>
Quoted 3 lines
--- arch/x86/kernel/entry_64.S | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
Looks ok to me.
Acked-by Borislav Petkov <[email protected]>
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--