Skip to content

Commit

Permalink
x86/asm: Make <asm/asm.h> valid on cross-builds as well
Browse files Browse the repository at this point in the history
Stephen Rothwell reported that the objtool cross-build breaks on
non-x86 hosts:

  > tools/arch/x86/include/asm/asm.h:185:24: error: invalid register name for 'current_stack_pointer'
  >   185 | register unsigned long current_stack_pointer asm(_ASM_SP);
  >       |                        ^~~~~~~~~~~~~~~~~~~~~

The PowerPC host obviously doesn't know much about x86 register names.

Protect the kernel-specific bits of <asm/asm.h>, so that it can be
included by tooling and cross-built.

Reported-by: Stephen Rothwell <[email protected]>
Reviewed-by: H. Peter Anvin <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Ingo Molnar committed May 14, 2021
1 parent 9ddcb87 commit 41f45fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/x86/include/asm/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
# define CC_OUT(c) [_cc_ ## c] "=qm"
#endif

#ifdef __KERNEL__

/* Exception table entry */
#ifdef __ASSEMBLY__
# define _ASM_EXTABLE_HANDLE(from, to, handler) \
Expand Down Expand Up @@ -186,4 +188,6 @@ register unsigned long current_stack_pointer asm(_ASM_SP);
#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)
#endif /* __ASSEMBLY__ */

#endif /* __KERNEL__ */

#endif /* _ASM_X86_ASM_H */
4 changes: 4 additions & 0 deletions tools/arch/x86/include/asm/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
# define CC_OUT(c) [_cc_ ## c] "=qm"
#endif

#ifdef __KERNEL__

/* Exception table entry */
#ifdef __ASSEMBLY__
# define _ASM_EXTABLE_HANDLE(from, to, handler) \
Expand Down Expand Up @@ -186,4 +188,6 @@ register unsigned long current_stack_pointer asm(_ASM_SP);
#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)
#endif /* __ASSEMBLY__ */

#endif /* __KERNEL__ */

#endif /* _ASM_X86_ASM_H */

0 comments on commit 41f45fb

Please sign in to comment.