mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 17:30:02 +00:00
![Josh Poimboeuf](/assets/img/avatar_default.png)
Apparently the binutils 2.20 assembler can't handle the '&&' operator in
the UNWIND_HINT_REGS macro. Rearrange the macro to do without it.
This fixes the following error:
arch/x86/entry/entry_64.S: Assembler messages:
arch/x86/entry/entry_64.S:521: Error: non-constant expression in ".if" statement
arch/x86/entry/entry_64.S:521: Error: non-constant expression in ".if" statement
arch/x86/entry/entry_64.S:521: Error: non-constant expression in ".if" statement
arch/x86/entry/entry_64.S:521: Error: non-constant expression in ".if" statement
arch/x86/entry/entry_64.S:521: Error: non-constant expression in ".if" statement
arch/x86/entry/entry_64.S:521: Error: non-constant expression in ".if" statement
arch/x86/entry/entry_64.S:521: Error: non-constant expression in ".if" statement
arch/x86/entry/entry_64.S:521: Error: non-constant expression in ".if" statement
arch/x86/entry/entry_64.S:521: Error: non-constant expression in ".if" statement
Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 39358a033b
("objtool, x86: Add facility for asm code to provide unwind hints")
Link: http://lkml.kernel.org/r/e2ad97c1ae49a484644b4aaa4dd3faa4d6d969b2.1502116651.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
105 lines
3 KiB
C
105 lines
3 KiB
C
#ifndef _ASM_X86_UNWIND_HINTS_H
|
|
#define _ASM_X86_UNWIND_HINTS_H
|
|
|
|
#include "orc_types.h"
|
|
|
|
#ifdef __ASSEMBLY__
|
|
|
|
/*
|
|
* In asm, there are two kinds of code: normal C-type callable functions and
|
|
* the rest. The normal callable functions can be called by other code, and
|
|
* don't do anything unusual with the stack. Such normal callable functions
|
|
* are annotated with the ENTRY/ENDPROC macros. Most asm code falls in this
|
|
* category. In this case, no special debugging annotations are needed because
|
|
* objtool can automatically generate the ORC data for the ORC unwinder to read
|
|
* at runtime.
|
|
*
|
|
* Anything which doesn't fall into the above category, such as syscall and
|
|
* interrupt handlers, tends to not be called directly by other functions, and
|
|
* often does unusual non-C-function-type things with the stack pointer. Such
|
|
* code needs to be annotated such that objtool can understand it. The
|
|
* following CFI hint macros are for this type of code.
|
|
*
|
|
* These macros provide hints to objtool about the state of the stack at each
|
|
* instruction. Objtool starts from the hints and follows the code flow,
|
|
* making automatic CFI adjustments when it sees pushes and pops, filling out
|
|
* the debuginfo as necessary. It will also warn if it sees any
|
|
* inconsistencies.
|
|
*/
|
|
.macro UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=0 type=ORC_TYPE_CALL
|
|
#ifdef CONFIG_STACK_VALIDATION
|
|
.Lunwind_hint_ip_\@:
|
|
.pushsection .discard.unwind_hints
|
|
/* struct unwind_hint */
|
|
.long .Lunwind_hint_ip_\@ - .
|
|
.short \sp_offset
|
|
.byte \sp_reg
|
|
.byte \type
|
|
.popsection
|
|
#endif
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_EMPTY
|
|
UNWIND_HINT sp_reg=ORC_REG_UNDEFINED
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_REGS base=%rsp offset=0 indirect=0 extra=1 iret=0
|
|
.if \base == %rsp
|
|
.if \indirect
|
|
.set sp_reg, ORC_REG_SP_INDIRECT
|
|
.else
|
|
.set sp_reg, ORC_REG_SP
|
|
.endif
|
|
.elseif \base == %rbp
|
|
.set sp_reg, ORC_REG_BP
|
|
.elseif \base == %rdi
|
|
.set sp_reg, ORC_REG_DI
|
|
.elseif \base == %rdx
|
|
.set sp_reg, ORC_REG_DX
|
|
.elseif \base == %r10
|
|
.set sp_reg, ORC_REG_R10
|
|
.else
|
|
.error "UNWIND_HINT_REGS: bad base register"
|
|
.endif
|
|
|
|
.set sp_offset, \offset
|
|
|
|
.if \iret
|
|
.set type, ORC_TYPE_REGS_IRET
|
|
.elseif \extra == 0
|
|
.set type, ORC_TYPE_REGS_IRET
|
|
.set sp_offset, \offset + (16*8)
|
|
.else
|
|
.set type, ORC_TYPE_REGS
|
|
.endif
|
|
|
|
UNWIND_HINT sp_reg=sp_reg sp_offset=sp_offset type=type
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_IRET_REGS base=%rsp offset=0
|
|
UNWIND_HINT_REGS base=\base offset=\offset iret=1
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_FUNC sp_offset=8
|
|
UNWIND_HINT sp_offset=\sp_offset
|
|
.endm
|
|
|
|
#else /* !__ASSEMBLY__ */
|
|
|
|
#define UNWIND_HINT(sp_reg, sp_offset, type) \
|
|
"987: \n\t" \
|
|
".pushsection .discard.unwind_hints\n\t" \
|
|
/* struct unwind_hint */ \
|
|
".long 987b - .\n\t" \
|
|
".short " __stringify(sp_offset) "\n\t" \
|
|
".byte " __stringify(sp_reg) "\n\t" \
|
|
".byte " __stringify(type) "\n\t" \
|
|
".popsection\n\t"
|
|
|
|
#define UNWIND_HINT_SAVE UNWIND_HINT(0, 0, UNWIND_HINT_TYPE_SAVE)
|
|
|
|
#define UNWIND_HINT_RESTORE UNWIND_HINT(0, 0, UNWIND_HINT_TYPE_RESTORE)
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_X86_UNWIND_HINTS_H */
|