Skip to content

Commit

Permalink
x86/headers: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-UAPI headers
Browse files Browse the repository at this point in the history
While the GCC and Clang compilers already define __ASSEMBLER__
automatically when compiling assembly code, __ASSEMBLY__ is a
macro that only gets defined by the Makefiles in the kernel.

This can be very confusing when switching between userspace
and kernelspace coding, or when dealing with UAPI headers that
rather should use __ASSEMBLER__ instead. So let's standardize on
the __ASSEMBLER__ macro that is provided by the compilers now.

This is mostly a mechanical patch (done with a simple "sed -i"
statement), with some manual tweaks in <asm/frame.h>, <asm/hw_irq.h>
and <asm/setup.h> that mentioned this macro in comments with some
missing underscores.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250314071013.1575167-38-thuth@redhat.com
  • Loading branch information
Thomas Huth authored and Ingo Molnar committed Mar 19, 2025
1 parent 8a141be commit 24a295e
Show file tree
Hide file tree
Showing 81 changed files with 201 additions and 201 deletions.
4 changes: 2 additions & 2 deletions arch/x86/boot/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#define STACK_SIZE 1024 /* Minimum number of bytes for stack */

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__

#include <linux/stdarg.h>
#include <linux/types.h>
Expand Down Expand Up @@ -327,6 +327,6 @@ void probe_cards(int unsafe);
/* video-vesa.c */
void vesa_store_edid(void);

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#endif /* BOOT_BOOT_H */
2 changes: 1 addition & 1 deletion arch/x86/entry/vdso/extable.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* vDSO uses a dedicated handler the addresses are relative to the overall
* exception table, not each individual entry.
*/
#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__
#define _ASM_VDSO_EXTABLE_HANDLE(from, to) \
ASM_VDSO_EXTABLE_HANDLE from to

Expand Down
6 changes: 3 additions & 3 deletions arch/x86/include/asm/alternative.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define ALT_DIRECT_CALL(feature) ((ALT_FLAG_DIRECT_CALL << ALT_FLAGS_SHIFT) | (feature))
#define ALT_CALL_ALWAYS ALT_DIRECT_CALL(X86_FEATURE_ALWAYS)

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__

#include <linux/stddef.h>

Expand Down Expand Up @@ -277,7 +277,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
void BUG_func(void);
void nop_func(void);

#else /* __ASSEMBLY__ */
#else /* __ASSEMBLER__ */

#ifdef CONFIG_SMP
.macro LOCK_PREFIX
Expand Down Expand Up @@ -360,6 +360,6 @@ void nop_func(void);
ALTERNATIVE_2 oldinstr, newinstr_no, X86_FEATURE_ALWAYS, \
newinstr_yes, ft_flags

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#endif /* _ASM_X86_ALTERNATIVE_H */
10 changes: 5 additions & 5 deletions arch/x86/include/asm/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef _ASM_X86_ASM_H
#define _ASM_X86_ASM_H

#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__
# define __ASM_FORM(x, ...) x,## __VA_ARGS__
# define __ASM_FORM_RAW(x, ...) x,## __VA_ARGS__
# define __ASM_FORM_COMMA(x, ...) x,## __VA_ARGS__,
Expand Down Expand Up @@ -113,7 +113,7 @@

#endif

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__
#ifndef __pic__
static __always_inline __pure void *rip_rel_ptr(void *p)
{
Expand Down Expand Up @@ -144,7 +144,7 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
# include <asm/extable_fixup_types.h>

/* Exception table entry */
#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__

# define _ASM_EXTABLE_TYPE(from, to, type) \
.pushsection "__ex_table","a" ; \
Expand All @@ -164,7 +164,7 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
# define _ASM_NOKPROBE(entry)
# endif

#else /* ! __ASSEMBLY__ */
#else /* ! __ASSEMBLER__ */

# define DEFINE_EXTABLE_TYPE_REG \
".macro extable_type_reg type:req reg:req\n" \
Expand Down Expand Up @@ -232,7 +232,7 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
*/
register unsigned long current_stack_pointer asm(_ASM_SP);
#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)
#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#define _ASM_EXTABLE(from, to) \
_ASM_EXTABLE_TYPE(from, to, EX_TYPE_DEFAULT)
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/include/asm/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
# define BOOT_STACK_SIZE 0x1000
#endif

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__
extern unsigned int output_len;
extern const unsigned long kernel_text_size;
extern const unsigned long kernel_total_size;
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/include/asm/cpufeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <asm/processor.h>

#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
#if defined(__KERNEL__) && !defined(__ASSEMBLER__)

#include <asm/asm.h>
#include <linux/bitops.h>
Expand Down Expand Up @@ -137,5 +137,5 @@ static __always_inline bool _static_cpu_has(u16 bit)
#define CPU_FEATURE_TYPEVAL boot_cpu_data.x86_vendor, boot_cpu_data.x86, \
boot_cpu_data.x86_model

#endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */
#endif /* defined(__KERNEL__) && !defined(__ASSEMBLER__) */
#endif /* _ASM_X86_CPUFEATURE_H */
4 changes: 2 additions & 2 deletions arch/x86/include/asm/cpumask.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_X86_CPUMASK_H
#define _ASM_X86_CPUMASK_H
#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__
#include <linux/cpumask.h>

extern void setup_cpu_local_masks(void);
Expand Down Expand Up @@ -34,5 +34,5 @@ static __always_inline void arch_cpumask_clear_cpu(int cpu, struct cpumask *dstp

#define arch_cpu_is_offline(cpu) unlikely(!arch_cpu_online(cpu))

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */
#endif /* _ASM_X86_CPUMASK_H */
4 changes: 2 additions & 2 deletions arch/x86/include/asm/current.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <linux/build_bug.h>
#include <linux/compiler.h>

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__

#include <linux/cache.h>
#include <asm/percpu.h>
Expand All @@ -27,6 +27,6 @@ static __always_inline struct task_struct *get_current(void)

#define current get_current()

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#endif /* _ASM_X86_CURRENT_H */
4 changes: 2 additions & 2 deletions arch/x86/include/asm/desc_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

#define DESC_USER (_DESC_DPL(3))

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__

#include <linux/types.h>

Expand Down Expand Up @@ -166,7 +166,7 @@ struct desc_ptr {
unsigned long address;
} __attribute__((packed)) ;

#endif /* !__ASSEMBLY__ */
#endif /* !__ASSEMBLER__ */

/* Boot IDT definitions */
#define BOOT_IDT_ENTRIES 32
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/include/asm/dwarf2.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef _ASM_X86_DWARF2_H
#define _ASM_X86_DWARF2_H

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__
#warning "asm/dwarf2.h should be only included in pure assembly files"
#endif

Expand Down
4 changes: 2 additions & 2 deletions arch/x86/include/asm/fixmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/* fixmap starts downwards from the 507th entry in level2_fixmap_pgt */
#define FIXMAP_PMD_TOP 507

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__
#include <linux/kernel.h>
#include <asm/apicdef.h>
#include <asm/page.h>
Expand Down Expand Up @@ -196,5 +196,5 @@ void __init *early_memremap_decrypted_wp(resource_size_t phys_addr,
void __early_set_fixmap(enum fixed_addresses idx,
phys_addr_t phys, pgprot_t flags);

#endif /* !__ASSEMBLY__ */
#endif /* !__ASSEMBLER__ */
#endif /* _ASM_X86_FIXMAP_H */
10 changes: 5 additions & 5 deletions arch/x86/include/asm/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#ifdef CONFIG_FRAME_POINTER

#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__

.macro FRAME_BEGIN
push %_ASM_BP
Expand Down Expand Up @@ -51,7 +51,7 @@
.endm
#endif /* CONFIG_X86_64 */

#else /* !__ASSEMBLY__ */
#else /* !__ASSEMBLER__ */

#define FRAME_BEGIN \
"push %" _ASM_BP "\n" \
Expand Down Expand Up @@ -82,18 +82,18 @@ static inline unsigned long encode_frame_pointer(struct pt_regs *regs)

#endif /* CONFIG_X86_64 */

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#define FRAME_OFFSET __ASM_SEL(4, 8)

#else /* !CONFIG_FRAME_POINTER */

#ifdef __ASSEMBLY__
#ifdef __ASSEMBLER__

.macro ENCODE_FRAME_POINTER ptregs_offset=0
.endm

#else /* !__ASSEMBLY */
#else /* !__ASSEMBLER__ */

#define ENCODE_FRAME_POINTER

Expand Down
4 changes: 2 additions & 2 deletions arch/x86/include/asm/fred.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define FRED_CONFIG_INT_STKLVL(l) (_AT(unsigned long, l) << 9)
#define FRED_CONFIG_ENTRYPOINT(p) _AT(unsigned long, (p))

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__

#ifdef CONFIG_X86_FRED
#include <linux/kernel.h>
Expand Down Expand Up @@ -113,6 +113,6 @@ static inline void fred_entry_from_kvm(unsigned int type, unsigned int vector) {
static inline void fred_sync_rsp0(unsigned long rsp0) { }
static inline void fred_update_rsp0(void) { }
#endif /* CONFIG_X86_FRED */
#endif /* !__ASSEMBLY__ */
#endif /* !__ASSEMBLER__ */

#endif /* ASM_X86_FRED_H */
4 changes: 2 additions & 2 deletions arch/x86/include/asm/fsgsbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef _ASM_FSGSBASE_H
#define _ASM_FSGSBASE_H

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__

#ifdef CONFIG_X86_64

Expand Down Expand Up @@ -80,6 +80,6 @@ extern unsigned long x86_fsgsbase_read_task(struct task_struct *task,

#endif /* CONFIG_X86_64 */

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#endif /* _ASM_FSGSBASE_H */
8 changes: 4 additions & 4 deletions arch/x86/include/asm/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define ARCH_SUPPORTS_FTRACE_OPS 1
#endif

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__
extern void __fentry__(void);

static inline unsigned long ftrace_call_adjust(unsigned long addr)
Expand Down Expand Up @@ -106,11 +106,11 @@ struct dyn_arch_ftrace {
};

#endif /* CONFIG_DYNAMIC_FTRACE */
#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */
#endif /* CONFIG_FUNCTION_TRACER */


#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__

void prepare_ftrace_return(unsigned long ip, unsigned long *parent,
unsigned long frame_pointer);
Expand Down Expand Up @@ -154,6 +154,6 @@ static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
}
#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_IA32_EMULATION */
#endif /* !COMPILE_OFFSETS */
#endif /* !__ASSEMBLY__ */
#endif /* !__ASSEMBLER__ */

#endif /* _ASM_X86_FTRACE_H */
4 changes: 2 additions & 2 deletions arch/x86/include/asm/hw_irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <asm/irq_vectors.h>

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__

#include <linux/percpu.h>
#include <linux/profile.h>
Expand Down Expand Up @@ -128,6 +128,6 @@ extern char spurious_entries_start[];
typedef struct irq_desc* vector_irq_t[NR_VECTORS];
DECLARE_PER_CPU(vector_irq_t, vector_irq);

#endif /* !ASSEMBLY_ */
#endif /* !__ASSEMBLER__ */

#endif /* _ASM_X86_HW_IRQ_H */
12 changes: 6 additions & 6 deletions arch/x86/include/asm/ibt.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#define HAS_KERNEL_IBT 1

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__

#ifdef CONFIG_X86_64
#define ASM_ENDBR "endbr64\n\t"
Expand Down Expand Up @@ -82,21 +82,21 @@ extern __noendbr bool is_endbr(u32 *val);
extern __noendbr u64 ibt_save(bool disable);
extern __noendbr void ibt_restore(u64 save);

#else /* __ASSEMBLY__ */
#else /* __ASSEMBLER__ */

#ifdef CONFIG_X86_64
#define ENDBR endbr64
#else
#define ENDBR endbr32
#endif

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#else /* !IBT */

#define HAS_KERNEL_IBT 0

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__

#define ASM_ENDBR
#define IBT_NOSEAL(name)
Expand All @@ -108,11 +108,11 @@ static inline bool is_endbr(u32 *val) { return false; }
static inline u64 ibt_save(bool disable) { return 0; }
static inline void ibt_restore(u64 save) { }

#else /* __ASSEMBLY__ */
#else /* __ASSEMBLER__ */

#define ENDBR

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

#endif /* CONFIG_X86_KERNEL_IBT */

Expand Down
6 changes: 3 additions & 3 deletions arch/x86/include/asm/idtentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#define IDT_ALIGN (8 * (1 + HAS_KERNEL_IBT))

#ifndef __ASSEMBLY__
#ifndef __ASSEMBLER__
#include <linux/entry-common.h>
#include <linux/hardirq.h>

Expand Down Expand Up @@ -474,7 +474,7 @@ static inline void fred_install_sysvec(unsigned int vector, const idtentry_t fun
idt_install_sysvec(vector, asm_##function); \
}

#else /* !__ASSEMBLY__ */
#else /* !__ASSEMBLER__ */

/*
* The ASM variants for DECLARE_IDTENTRY*() which emit the ASM entry stubs.
Expand Down Expand Up @@ -579,7 +579,7 @@ SYM_CODE_START(spurious_entries_start)
SYM_CODE_END(spurious_entries_start)
#endif

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLER__ */

/*
* The actual entry points. Note that DECLARE_IDTENTRY*() serves two
Expand Down
Loading

0 comments on commit 24a295e

Please sign in to comment.