riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in header files
Subsystems (7)
v2 cover riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in header files
The kernel Makefiles define the __ASSEMBLY__ macro to provide a way to use headers in both, assembly and C source code. However, all the supported versions of the GCC and Clang compilers also define the macro __ASSEMBLER__ automatically already when compiling assembly code, so some kernel headers are using __ASSEMBLER__ instead. With regards to userspace code, this seems also to be constant source of confusion, see for example these links here:
https://lore.kernel.org/kvm/[email protected]/
https://stackoverflow.com/questions/28924355/gcc-assembler-preprocessor-not-compatible-with-standard-headers
https://forums.raspberrypi.com/viewtopic.php?p=1652944#p1653834
https://github.com/riscv-software-src/opensbi/issues/199
To avoid confusion in the future, it would make sense to standardize on the macro that gets defined by the compiler, so this patch series changes all occurances of __ASSEMBLY__ into __ASSEMBLER__.
I split the patches per architecture to ease the review, and I also split the uapi headers from the normal ones in case we decide that uapi needs to be treated differently from the normal headers here.
The x86 and parisc patches already got merged via their specific architecture tree:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=24a295e4ef1ca8
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8a141be3233af7
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cccaea1d66e94b
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e2b6a188625a2b
So I assume the riscv patches should also go via the riscv tree.
v2:
- Split the riscv patches from the global series
(see https://lore.kernel.org/all/[email protected]/)
- Rebased the patches on linux-next and fixed the conflicts
and new occurances of __ASSEMBLY__
Thomas Huth (2):
riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers
riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers
arch/riscv/include/asm/alternative-macros.h | 12 ++++++------ arch/riscv/include/asm/alternative.h | 2 +- arch/riscv/include/asm/asm-extable.h | 6 +++--- arch/riscv/include/asm/asm.h | 10 +++++----- arch/riscv/include/asm/assembler.h | 2 +- arch/riscv/include/asm/barrier.h | 4 ++-- arch/riscv/include/asm/cache.h | 4 ++-- arch/riscv/include/asm/cpu_ops_sbi.h | 2 +- arch/riscv/include/asm/csr.h | 4 ++-- arch/riscv/include/asm/current.h | 4 ++-- arch/riscv/include/asm/errata_list.h | 6 +++--- arch/riscv/include/asm/ftrace.h | 6 +++--- arch/riscv/include/asm/gpr-num.h | 6 +++--- arch/riscv/include/asm/image.h | 4 ++-- arch/riscv/include/asm/insn-def.h | 8 ++++---- arch/riscv/include/asm/jump_label.h | 4 ++-- arch/riscv/include/asm/kasan.h | 2 +- arch/riscv/include/asm/kgdb.h | 4 ++-- arch/riscv/include/asm/mmu.h | 4 ++-- arch/riscv/include/asm/page.h | 4 ++-- arch/riscv/include/asm/pgtable.h | 4 ++-- arch/riscv/include/asm/processor.h | 4 ++-- arch/riscv/include/asm/ptrace.h | 4 ++-- arch/riscv/include/asm/scs.h | 4 ++-- arch/riscv/include/asm/set_memory.h | 4 ++-- arch/riscv/include/asm/thread_info.h | 4 ++-- arch/riscv/include/asm/vdso.h | 4 ++-- arch/riscv/include/asm/vdso/getrandom.h | 4 ++-- arch/riscv/include/asm/vdso/gettimeofday.h | 4 ++-- arch/riscv/include/asm/vdso/processor.h | 4 ++-- arch/riscv/include/asm/vdso/vsyscall.h | 4 ++-- arch/riscv/include/uapi/asm/kvm.h | 2 +- arch/riscv/include/uapi/asm/ptrace.h | 4 ++-- arch/riscv/include/uapi/asm/sigcontext.h | 4 ++-- tools/arch/riscv/include/asm/csr.h | 6 +++--- tools/arch/riscv/include/asm/vdso/processor.h | 4 ++-- 36 files changed, 81 insertions(+), 81 deletions(-)
Signature · 1 line
2.49.0
PATCH v2 1/2 riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers
From: Thomas Huth <[email protected]>
__ASSEMBLY__ is only defined by the Makefile of the kernel, so this is not really useful for uapi headers (unless the userspace Makefile defines it, too). Let's switch to __ASSEMBLER__ which gets set automatically by the compiler when compiling assembly code.
This is a completely mechanical patch (done with a simple "sed -i" statement).
--- arch/riscv/include/uapi/asm/kvm.h | 2 +- arch/riscv/include/uapi/asm/ptrace.h | 4 ++-- arch/riscv/include/uapi/asm/sigcontext.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
arch/riscv/include/uapi/asm/kvm.h +1 -1
@@ -9,7 +9,7 @@#ifndef __LINUX_KVM_RISCV_H#define __LINUX_KVM_RISCV_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <linux/types.h> #include <asm/bitsperlong.h>
arch/riscv/include/uapi/asm/ptrace.h +2 -2
@@ -6,7 +6,7 @@#ifndef _UAPI_ASM_RISCV_PTRACE_H#define _UAPI_ASM_RISCV_PTRACE_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <linux/types.h>
@@ -127,6 +127,6 @@ struct __riscv_v_regset_state {*/ #define RISCV_MAX_VLENB (8192) -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _UAPI_ASM_RISCV_PTRACE_H */
arch/riscv/include/uapi/asm/sigcontext.h +2 -2
@@ -15,7 +15,7 @@/* The size of END signal context header. */ #define END_HDR_SIZE 0x0 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ struct __sc_riscv_v_state { struct __riscv_v_ext_state v_state;
@@ -35,6 +35,6 @@ struct sigcontext { }; }; -#endif /*!__ASSEMBLY__*/ +#endif /*!__ASSEMBLER__*/ #endif /* _UAPI_ASM_RISCV_SIGCONTEXT_H */
Signature · 1 line
2.49.0
PATCH v2 2/2 riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers
In reply to Thomas HuthFrom: Thomas Huth <[email protected]>
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 originally was a completely mechanical patch (done with a simple "sed -i" statement), with some manual fixups during rebasing of the patch later.
--- arch/riscv/include/asm/alternative-macros.h | 12 ++++++------ arch/riscv/include/asm/alternative.h | 2 +- arch/riscv/include/asm/asm-extable.h | 6 +++--- arch/riscv/include/asm/asm.h | 10 +++++----- arch/riscv/include/asm/assembler.h | 2 +- arch/riscv/include/asm/barrier.h | 4 ++-- arch/riscv/include/asm/cache.h | 4 ++-- arch/riscv/include/asm/cpu_ops_sbi.h | 2 +- arch/riscv/include/asm/csr.h | 4 ++-- arch/riscv/include/asm/current.h | 4 ++-- arch/riscv/include/asm/errata_list.h | 6 +++--- arch/riscv/include/asm/ftrace.h | 6 +++--- arch/riscv/include/asm/gpr-num.h | 6 +++--- arch/riscv/include/asm/image.h | 4 ++-- arch/riscv/include/asm/insn-def.h | 8 ++++---- arch/riscv/include/asm/jump_label.h | 4 ++-- arch/riscv/include/asm/kasan.h | 2 +- arch/riscv/include/asm/kgdb.h | 4 ++-- arch/riscv/include/asm/mmu.h | 4 ++-- arch/riscv/include/asm/page.h | 4 ++-- arch/riscv/include/asm/pgtable.h | 4 ++-- arch/riscv/include/asm/processor.h | 4 ++-- arch/riscv/include/asm/ptrace.h | 4 ++-- arch/riscv/include/asm/scs.h | 4 ++-- arch/riscv/include/asm/set_memory.h | 4 ++-- arch/riscv/include/asm/thread_info.h | 4 ++-- arch/riscv/include/asm/vdso.h | 4 ++-- arch/riscv/include/asm/vdso/getrandom.h | 4 ++-- arch/riscv/include/asm/vdso/gettimeofday.h | 4 ++-- arch/riscv/include/asm/vdso/processor.h | 4 ++-- arch/riscv/include/asm/vdso/vsyscall.h | 4 ++-- tools/arch/riscv/include/asm/csr.h | 6 +++--- tools/arch/riscv/include/asm/vdso/processor.h | 4 ++-- 33 files changed, 76 insertions(+), 76 deletions(-)
arch/riscv/include/asm/alternative-macros.h +6 -6
@@ -4,7 +4,7 @@#ifdef CONFIG_RISCV_ALTERNATIVE -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__ .macro ALT_ENTRY oldptr newptr vendor_id patch_id new_len .4byte \oldptr - .
@@ -53,7 +53,7 @@#define __ALTERNATIVE_CFG (...) ALTERNATIVE_CFG __VA_ARGS__#define __ALTERNATIVE_CFG_2 (...) ALTERNATIVE_CFG_2 __VA_ARGS__ -#else /* !__ASSEMBLY__ */ +#else /* !__ASSEMBLER__ */ #include <asm/asm.h> #include <linux/stringify.h>
@@ -98,7 +98,7 @@ __ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, patch_id_1, enable_1) \ ALT_NEW_CONTENT(vendor_id_2, patch_id_2, enable_2, new_c_2) -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #define _ALTERNATIVE_CFG (old_c, new_c, vendor_id, patch_id, CONFIG_k) \ __ALTERNATIVE_CFG(old_c, new_c, vendor_id, patch_id, IS_ENABLED(CONFIG_k))
@@ -109,7 +109,7 @@ new_c_2, vendor_id_2, patch_id_2, IS_ENABLED(CONFIG_k_2))#else /* CONFIG_RISCV_ALTERNATIVE */ -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__ .macro ALTERNATIVE_CFG old_c \old_c
@@ -118,12 +118,12 @@#define __ALTERNATIVE_CFG (old_c, ...) ALTERNATIVE_CFG old_c#define __ALTERNATIVE_CFG_2 (old_c, ...) ALTERNATIVE_CFG old_c -#else /* !__ASSEMBLY__ */ +#else /* !__ASSEMBLER__ */ #define __ALTERNATIVE_CFG (old_c, ...) old_c "\n"#define __ALTERNATIVE_CFG_2 (old_c, ...) old_c "\n" -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #define _ALTERNATIVE_CFG (old_c, ...) __ALTERNATIVE_CFG(old_c)#define _ALTERNATIVE_CFG_2 (old_c, ...) __ALTERNATIVE_CFG_2(old_c)
arch/riscv/include/asm/alternative.h +1 -1
@@ -8,7 +8,7 @@#include <asm/alternative-macros.h> -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#ifdef CONFIG_RISCV_ALTERNATIVE
arch/riscv/include/asm/asm-extable.h +3 -3
@@ -10,7 +10,7 @@#ifdef CONFIG_MMU -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__#define __ASM_EXTABLE_RAW (insn, fixup, type, data) \ .pushsection __ex_table, "a"; \
@@ -25,7 +25,7 @@ __ASM_EXTABLE_RAW(\insn, \fixup, EX_TYPE_FIXUP, 0) .endm -#else /* __ASSEMBLY__ */ +#else /* __ASSEMBLER__ */ #include <linux/bits.h> #include <linux/stringify.h>
@@ -77,7 +77,7 @@ EX_DATA_REG(ADDR, addr) \ ")") -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #else /* CONFIG_MMU */ #define _ASM_EXTABLE_UACCESS_ERR (insn, fixup, err)
arch/riscv/include/asm/asm.h +5 -5
@@ -6,7 +6,7 @@#ifndef _ASM_RISCV_ASM_H#define _ASM_RISCV_ASM_H -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__#define __ASM_STR (x) x#else #define __ASM_STR (x) #x
@@ -30,7 +30,7 @@#define SRLI __REG_SEL(srliw, srli)#if __SIZEOF_POINTER__ ==8 -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__#define RISCV_PTR .dword#define RISCV_SZPTR 8#define RISCV_LGPTR 3
@@ -40,7 +40,7 @@#define RISCV_LGPTR "3"#endif #elif __SIZEOF_POINTER__ == 4 -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__#define RISCV_PTR .word#define RISCV_SZPTR 4#define RISCV_LGPTR 2
@@ -69,7 +69,7 @@#error "Unexpected __SIZEOF_SHORT__"#endif -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__#include <asm/asm-offsets.h> /* Common assembly source macros */
@@ -194,6 +194,6 @@#define ASM_NOKPROBE (name)#endif -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _ASM_RISCV_ASM_H */
arch/riscv/include/asm/assembler.h +1 -1
@@ -5,7 +5,7 @@* Author: Jee Heng Sia <[email protected]> */ -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#error "Only include this from assembly code"#endif
arch/riscv/include/asm/barrier.h +2 -2
@@ -10,7 +10,7 @@#ifndef _ASM_RISCV_BARRIER_H#define _ASM_RISCV_BARRIER_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <asm/cmpxchg.h> #include <asm/fence.h>
@@ -82,6 +82,6 @@ do { \#include <asm-generic/barrier.h> -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _ASM_RISCV_BARRIER_H */
arch/riscv/include/asm/cache.h +2 -2
@@ -24,7 +24,7 @@#define ARCH_SLAB_MINALIGN 16#endif -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__extern int dma_cache_alignment;#ifdef CONFIG_RISCV_DMA_NONCOHERENT
@@ -35,6 +35,6 @@ static inline int dma_get_cache_alignment(void) }#endif -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _ASM_RISCV_CACHE_H */
arch/riscv/include/asm/cpu_ops_sbi.h +1 -1
@@ -5,7 +5,7 @@#ifndef __ASM_CPU_OPS_SBI_H#define __ASM_CPU_OPS_SBI_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <linux/init.h> #include <linux/sched.h> #include <linux/threads.h>
arch/riscv/include/asm/csr.h +2 -2
@@ -513,7 +513,7 @@#define IE_TIE (_AC(0x1, UL) << RV_IRQ_TIMER)#define IE_EIE (_AC(0x1, UL) << RV_IRQ_EXT) -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#define csr_swap (csr, val) \ ({ \
@@ -575,6 +575,6 @@ : "memory"); \ }) -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _ASM_RISCV_CSR_H */
arch/riscv/include/asm/current.h +2 -2
@@ -13,7 +13,7 @@#include <linux/bug.h> #include <linux/compiler.h> -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__struct task_struct ;
@@ -35,6 +35,6 @@ static __always_inline struct task_struct *get_current(void) registerunsigned long current_stack_pointer __asm__("sp" ); -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _ASM_RISCV_CURRENT_H */
arch/riscv/include/asm/errata_list.h +3 -3
@@ -29,7 +29,7 @@#define ERRATA_THEAD_NUMBER 3#endif -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__#define ALT_INSN_FAULT (x) \ ALTERNATIVE(__stringify(RISCV_PTR do_trap_insn_fault), \
@@ -42,7 +42,7 @@ ALTERNATIVE(__stringify(RISCV_PTR do_page_fault), \ __stringify(RISCV_PTR sifive_cip_453_page_fault_trp), \SIFIVE_VENDOR_ID ,ERRATA_SIFIVE_CIP_453 , \ CONFIG_ERRATA_SIFIVE_CIP_453) -#else /* !__ASSEMBLY__ */ +#else /* !__ASSEMBLER__ */ #define ALT_SFENCE_VMA_ASID(asid) \ asm(ALTERNATIVE("sfence.vma x0, %0", "sfence.vma", SIFIVE_VENDOR_ID, \
@@ -123,6 +123,6 @@ asm volatile(ALTERNATIVE( \#define THEAD_C9XX_RV_IRQ_PMU 17#define THEAD_C9XX_CSR_SCOUNTEROF 0x5c5 -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif
arch/riscv/include/asm/ftrace.h +3 -3
@@ -13,7 +13,7 @@#endif #define ARCH_SUPPORTS_FTRACE_OPS 1 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__extern void *return_address (unsigned int level);
@@ -112,7 +112,7 @@ do { \#define MCOUNT_JALR_SIZE 4#define MCOUNT_NOP4_SIZE 4 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__struct dyn_ftrace ;int ftrace_init_nop (struct module *mod,struct dyn_ftrace *rec);#define ftrace_init_nop ftrace_init_nop
@@ -235,7 +235,7 @@ static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, unsi#endif /* CONFIG_DYNAMIC_FTRACE_WITH_ARGS */ -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* CONFIG_DYNAMIC_FTRACE */
arch/riscv/include/asm/gpr-num.h +3 -3
@@ -2,7 +2,7 @@#ifndef __ASM_GPR_NUM_H#define __ASM_GPR_NUM_H -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__ .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 .equ .L__gpr_num_x\num, \num
@@ -41,7 +41,7 @@ .equ .L__gpr_num_t5, 30 .equ .L__gpr_num_t6, 31 -#else /* __ASSEMBLY__ */ +#else /* __ASSEMBLER__ */ #define __DEFINE_ASM_GPR_NUMS \ " .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31\n" \
@@ -80,6 +80,6 @@" .equ .L__gpr_num_t5, 30\n" \ " .equ .L__gpr_num_t6, 31\n" -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* __ASM_GPR_NUM_H */
arch/riscv/include/asm/image.h +2 -2
@@ -29,7 +29,7 @@#define RISCV_HEADER_VERSION (RISCV_HEADER_VERSION_MAJOR << 16 | \ RISCV_HEADER_VERSION_MINOR) -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#define riscv_image_flag_field (flags, field)\ (((flags) >> field##_SHIFT) & field##_MASK)/**
@@ -63,5 +63,5 @@ struct riscv_image_header {u32 magic2;u32 res3; }; -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _ASM_RISCV_IMAGE_H */
arch/riscv/include/asm/insn-def.h +4 -4
@@ -25,7 +25,7 @@#define INSN_S_SIMM5_SHIFT 7#define INSN_S_OPCODE_SHIFT 0 -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__#ifdef CONFIG_AS_HAS_INSN
@@ -77,7 +77,7 @@#define __INSN_I (...) insn_i __VA_ARGS__#define __INSN_S (...) insn_s __VA_ARGS__ -#else /* ! __ASSEMBLY__ */ +#else /* ! __ASSEMBLER__ */ #ifdef CONFIG_AS_HAS_INSN
@@ -153,7 +153,7 @@#endif -#endif /* ! __ASSEMBLY__ */ +#endif /* ! __ASSEMBLER__ */ #define INSN_R (opcode, func3, func7, rd, rs1, rs2) \ __INSN_R(RV_##opcode, RV_##func3, RV_##func7, \
@@ -263,7 +263,7 @@#define RISCV_INSN_NOP4 _AC(0x00000013, U) -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#define nop () __asm__ __volatile__ ("nop")#define __nops (n) ".rept " #n "\nnop\n.endr\n"#define nops (n) __asm__ __volatile__ (__nops(n))
arch/riscv/include/asm/jump_label.h +2 -2
@@ -7,7 +7,7 @@#ifndef __ASM_JUMP_LABEL_H#define __ASM_JUMP_LABEL_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <linux/types.h> #include <asm/asm.h>
@@ -66,5 +66,5 @@ static __always_inline bool arch_static_branch_jump(struct static_key * const kereturn true; } -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* __ASM_JUMP_LABEL_H */
arch/riscv/include/asm/kasan.h +1 -1
@@ -4,7 +4,7 @@#ifndef __ASM_KASAN_H#define __ASM_KASAN_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__/* * The following comment was copied from arm64:
arch/riscv/include/asm/kgdb.h +2 -2
@@ -17,12 +17,12 @@#define BREAK_INSTR_SIZE 4#endif -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__void arch_kgdb_breakpoint (void );extern unsigned long kgdb_compiled_break; -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ #define DBG_REG_ZERO "zero"#define DBG_REG_RA "ra"
arch/riscv/include/asm/mmu.h +2 -2
@@ -7,7 +7,7 @@ #ifndef _ASM_RISCV_MMU_H #define _ASM_RISCV_MMU_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ typedef struct { #ifndef CONFIG_MMU
@@ -40,6 +40,6 @@ typedef struct {void __meminit create_pgd_mapping (pgd_t *pgdp,uintptr_t va,phys_addr_t pa,phys_addr_t sz,pgprot_t prot); -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _ASM_RISCV_MMU_H */
arch/riscv/include/asm/page.h +2 -2
@@ -41,7 +41,7 @@#define PAGE_OFFSET ((unsigned long)phys_ram_base)#endif /* CONFIG_MMU */ -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#ifdef CONFIG_RISCV_ISA_ZICBOZ void clear_page (void *page);
@@ -199,7 +199,7 @@ static __always_inline void *pfn_to_kaddr(unsigned long pfn)return __va (pfn <<PAGE_SHIFT ); } -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #define virt_addr_valid (vaddr) ({ \ unsigned long _addr = (unsigned long)vaddr; \
arch/riscv/include/asm/pgtable.h +2 -2
@@ -111,7 +111,7 @@#endif -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <asm/page.h> #include <asm/tlbflush.h>
@@ -1141,6 +1141,6 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];WARN_ON_ONCE (pgd_present (*pgdp) && !pgd_same (*pgdp, pgd)); \set_pgd (pgdp, pgd); \ }) -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ #endif /* _ASM_RISCV_PGTABLE_H */
arch/riscv/include/asm/processor.h +2 -2
@@ -54,7 +54,7 @@#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)#endif -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__struct task_struct ;struct pt_regs ;
@@ -215,6 +215,6 @@ long get_tagged_addr_ctrl(struct task_struct *task);#define GET_TAGGED_ADDR_CTRL () get_tagged_addr_ctrl(current)#endif -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _ASM_RISCV_PROCESSOR_H */
arch/riscv/include/asm/ptrace.h +2 -2
@@ -10,7 +10,7 @@#include <asm/csr.h> #include <linux/compiler.h> -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ struct pt_regs { unsigned long epc;
@@ -180,6 +180,6 @@ static __always_inline bool regs_irqs_disabled(struct pt_regs *regs)return !(regs->status &SR_PIE ); } -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _ASM_RISCV_PTRACE_H */
arch/riscv/include/asm/scs.h +2 -2
@@ -2,7 +2,7 @@#ifndef _ASM_SCS_H#define _ASM_SCS_H -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__#include <asm/asm-offsets.h> #ifdef CONFIG_SHADOW_CALL_STACK
@@ -49,6 +49,6 @@ .endm#endif /* CONFIG_SHADOW_CALL_STACK */ -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _ASM_SCS_H */
arch/riscv/include/asm/set_memory.h +2 -2
@@ -6,7 +6,7 @@#ifndef _ASM_RISCV_SET_MEMORY_H#define _ASM_RISCV_SET_MEMORY_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__/* * Functions to change memory attributes. */
@@ -45,7 +45,7 @@ int set_direct_map_default_noflush(struct page *page);int set_direct_map_valid_noflush (struct page *page,unsigned nr,bool valid);bool kernel_page_present (struct page *page); -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #if defined(CONFIG_STRICT_KERNEL_RWX ) || defined(CONFIG_XIP_KERNEL )#ifdef CONFIG_64BIT
arch/riscv/include/asm/thread_info.h +2 -2
@@ -37,7 +37,7 @@#define IRQ_STACK_SIZE THREAD_SIZE -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <asm/processor.h> #include <asm/csr.h>
@@ -98,7 +98,7 @@ struct thread_info {void arch_release_task_struct (struct task_struct *tsk);int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src); -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ /* * thread information flags
arch/riscv/include/asm/vdso.h +2 -2
@@ -16,7 +16,7 @@#define __VDSO_PAGES 4 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <generated/vdso-offsets.h> #define VDSO_SYMBOL (base, name) \
@@ -34,7 +34,7 @@ extern char compat_vdso_start[], compat_vdso_end[];extern char vdso_start[], vdso_end[]; -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ #endif /* CONFIG_MMU */
arch/riscv/include/asm/vdso/getrandom.h +2 -2
@@ -5,7 +5,7 @@#ifndef __ASM_VDSO_GETRANDOM_H#define __ASM_VDSO_GETRANDOM_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <asm/unistd.h>
@@ -25,6 +25,6 @@ static __always_inline ssize_t getrandom_syscall(void *_buffer, size_t _len, unsreturn ret; } -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ #endif /* __ASM_VDSO_GETRANDOM_H */
arch/riscv/include/asm/vdso/gettimeofday.h +2 -2
@@ -2,7 +2,7 @@#ifndef __ASM_VDSO_GETTIMEOFDAY_H#define __ASM_VDSO_GETTIMEOFDAY_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <asm/barrier.h> #include <asm/unistd.h>
@@ -79,6 +79,6 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,return csr_read (CSR_TIME ); } -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ #endif /* __ASM_VDSO_GETTIMEOFDAY_H */
arch/riscv/include/asm/vdso/processor.h +2 -2
@@ -2,7 +2,7 @@#ifndef __ASM_VDSO_PROCESSOR_H#define __ASM_VDSO_PROCESSOR_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <asm/barrier.h> #include <asm/insn-def.h>
@@ -23,6 +23,6 @@ static inline void cpu_relax(void)barrier (); } -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* __ASM_VDSO_PROCESSOR_H */
arch/riscv/include/asm/vdso/vsyscall.h +2 -2
@@ -2,13 +2,13 @@#ifndef __ASM_VDSO_VSYSCALL_H#define __ASM_VDSO_VSYSCALL_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <vdso/datapage.h> /* The asm-generic header needs to be included after the definitions above */ #include <asm-generic/vdso/vsyscall.h> -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ #endif /* __ASM_VDSO_VSYSCALL_H */
tools/arch/riscv/include/asm/csr.h +3 -3
@@ -468,13 +468,13 @@#define IE_TIE (_AC(0x1, UL) << RV_IRQ_TIMER)#define IE_EIE (_AC(0x1, UL) << RV_IRQ_EXT) -#ifdef __ASSEMBLY__ +#ifdef __ASSEMBLER__#define __ASM_STR (x) x#else #define __ASM_STR (x) #x#endif -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#define csr_swap (csr, val) \ ({ \
@@ -536,6 +536,6 @@ : "memory"); \ }) -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* _ASM_RISCV_CSR_H */
tools/arch/riscv/include/asm/vdso/processor.h +2 -2
@@ -2,7 +2,7 @@#ifndef __ASM_VDSO_PROCESSOR_H#define __ASM_VDSO_PROCESSOR_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <asm-generic/barrier.h>
@@ -27,6 +27,6 @@ static inline void cpu_relax(void)barrier (); } -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* __ASM_VDSO_PROCESSOR_H */
Signature · 1 line
2.49.0
Alexandre Ghiti
reviewerHi Thomas,
Quoted 70 lines · Thomas Huth
The kernel Makefiles define the
__ASSEMBLY__macro to provide a way to use headers in both, assembly and C source code. However, all the supported versions of the GCC and Clang compilers also define the macro__ASSEMBLER__automatically already when compiling assembly code, so some kernel headers are using__ASSEMBLER__instead. With regards to userspace code, this seems also to be constant source of confusion, see for example these links here:https://lore.kernel.org/kvm/[email protected]/
https://stackoverflow.com/questions/28924355/gcc-assembler-preprocessor-not-compatible-with-standard-headers
https://forums.raspberrypi.com/viewtopic.php?p=1652944#p1653834
https://github.com/riscv-software-src/opensbi/issues/199To avoid confusion in the future, it would make sense to standardize on the macro that gets defined by the compiler, so this patch series changes all occurances of
__ASSEMBLY__into__ASSEMBLER__.I split the patches per architecture to ease the review, and I also split the uapi headers from the normal ones in case we decide that uapi needs to be treated differently from the normal headers here.
The x86 and parisc patches already got merged via their specific architecture tree:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=24a295e4ef1ca8
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8a141be3233af7
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cccaea1d66e94b
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e2b6a188625a2bSo I assume the riscv patches should also go via the riscv tree.
v2:
- Split the riscv patches from the global series
(see https://lore.kernel.org/all/[email protected]/)
- Rebased the patches on linux-next and fixed the conflicts
and new occurances of__ASSEMBLY__Thomas Huth (2):
riscv: Replace__ASSEMBLY__with__ASSEMBLER__in uapi headers
riscv: Replace__ASSEMBLY__with__ASSEMBLER__in non-uapi headersarch/riscv/include/asm/alternative-macros.h | 12 ++++++------ arch/riscv/include/asm/alternative.h | 2 +- arch/riscv/include/asm/asm-extable.h | 6 +++--- arch/riscv/include/asm/asm.h | 10 +++++----- arch/riscv/include/asm/assembler.h | 2 +- arch/riscv/include/asm/barrier.h | 4 ++-- arch/riscv/include/asm/cache.h | 4 ++-- arch/riscv/include/asm/cpu_ops_sbi.h | 2 +- arch/riscv/include/asm/csr.h | 4 ++-- arch/riscv/include/asm/current.h | 4 ++-- arch/riscv/include/asm/errata_list.h | 6 +++--- arch/riscv/include/asm/ftrace.h | 6 +++--- arch/riscv/include/asm/gpr-num.h | 6 +++--- arch/riscv/include/asm/image.h | 4 ++-- arch/riscv/include/asm/insn-def.h | 8 ++++---- arch/riscv/include/asm/jump_label.h | 4 ++-- arch/riscv/include/asm/kasan.h | 2 +- arch/riscv/include/asm/kgdb.h | 4 ++-- arch/riscv/include/asm/mmu.h | 4 ++-- arch/riscv/include/asm/page.h | 4 ++-- arch/riscv/include/asm/pgtable.h | 4 ++-- arch/riscv/include/asm/processor.h | 4 ++-- arch/riscv/include/asm/ptrace.h | 4 ++-- arch/riscv/include/asm/scs.h | 4 ++-- arch/riscv/include/asm/set_memory.h | 4 ++-- arch/riscv/include/asm/thread_info.h | 4 ++-- arch/riscv/include/asm/vdso.h | 4 ++-- arch/riscv/include/asm/vdso/getrandom.h | 4 ++-- arch/riscv/include/asm/vdso/gettimeofday.h | 4 ++--
Quoted 8 lines
arch/riscv/include/asm/vdso/processor.h | 4 ++-- arch/riscv/include/asm/vdso/vsyscall.h | 4 ++-- arch/riscv/include/uapi/asm/kvm.h | 2 +- arch/riscv/include/uapi/asm/ptrace.h | 4 ++-- arch/riscv/include/uapi/asm/sigcontext.h | 4 ++-- tools/arch/riscv/include/asm/csr.h | 6 +++--- tools/arch/riscv/include/asm/vdso/processor.h | 4 ++-- 36 files changed, 81 insertions(+), 81 deletions(-)
Applied for 6.17,
Thanks,
Alex
This series was applied to riscv/linux.git (for-next) by Alexandre Ghiti <[email protected]>:
Hello:
This series was applied to riscv/linux.git (for-next) by Alexandre Ghiti <[email protected]>:
Quoted 9 lines · On Fri, 6 Jun 2025 09:09:50 +0200 you wrote:
The kernel Makefiles define the
__ASSEMBLY__macro to provide a way to use headers in both, assembly and C source code. However, all the supported versions of the GCC and Clang compilers also define the macro__ASSEMBLER__automatically already when compiling assembly code, so some kernel headers are using__ASSEMBLER__instead. With regards to userspace code, this seems also to be constant source of confusion, see for example these links here:[...]
Here is the summary with links:
- [v2,1/2] riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in uapi headers
https://git.kernel.org/riscv/c/c47963980ba6 - [v2,2/2] riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers https://git.kernel.org/riscv/c/b5eb1f12a416
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 4 lines · On 06/08/2025 19.15, [email protected] wrote:
Hello:
This series was applied to riscv/linux.git (for-next) by Alexandre Ghiti <[email protected]>:
Hi Alexandre,
I can't see the patches in the for-next branch ... have they been dropped again? Was there an issue with the patches?
Thanks,
Thomas
Quoted 18 lines · On Fri, 6 Jun 2025 09:09:50 +0200 you wrote:
Quoted 9 lines
The kernel Makefiles define the
__ASSEMBLY__macro to provide a way to use headers in both, assembly and C source code. However, all the supported versions of the GCC and Clang compilers also define the macro__ASSEMBLER__automatically already when compiling assembly code, so some kernel headers are using__ASSEMBLER__instead. With regards to userspace code, this seems also to be constant source of confusion, see for example these links here:[...]
Here is the summary with links:
- [v2,1/2] riscv: Replace__ASSEMBLY__with__ASSEMBLER__in uapi headershttps://git.kernel.org/riscv/c/c47963980ba6 - [v2,2/2] riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers https://git.kernel.org/riscv/c/b5eb1f12a416You are awesome, thank you!
Alexandre Ghiti
reviewerHi Thomas,
Quoted 9 lines · Thomas Huth
Quoted 4 lines · On 06/08/2025 19.15, [email protected] wrote:
Hello:
This series was applied to riscv/linux.git (for-next) by Alexandre Ghiti <[email protected]>:
Hi Alexandre,
I can't see the patches in the for-next branch ... have they been dropped again? Was there an issue with the patches?
No issues with the patches, Linus rejected the riscv PR. I'll send them again for 6.18.
Sorry about that,
Alex
Quoted 24 lines
Thanks,
ThomasQuoted 18 lines · On Fri, 6 Jun 2025 09:09:50 +0200 you wrote:
Quoted 9 lines
The kernel Makefiles define the
__ASSEMBLY__macro to provide a way to use headers in both, assembly and C source code. However, all the supported versions of the GCC and Clang compilers also define the macro__ASSEMBLER__automatically already when compiling assembly code, so some kernel headers are using__ASSEMBLER__instead. With regards to userspace code, this seems also to be constant source of confusion, see for example these links here:[...]
Here is the summary with links:
- [v2,1/2] riscv: Replace__ASSEMBLY__with__ASSEMBLER__in uapi headers
https://git.kernel.org/riscv/c/c47963980ba6
- [v2,2/2] riscv: Replace__ASSEMBLY__with__ASSEMBLER__in non-uapi headers
https://git.kernel.org/riscv/c/b5eb1f12a416You are awesome, thank you!
Paul Walmsley
maintainerHi Thomas,
Quoted 10 lines · Thomas Huth
Quoted 4 lines · On 06/08/2025 19.15, [email protected] wrote:
Hello:
This series was applied to riscv/linux.git (for-next) by Alexandre Ghiti <[email protected]>:
Hi Alexandre,
I can't see the patches in the for-next branch ... have they been dropped again? Was there an issue with the patches?
No issues with your patches; we just had some trouble getting the arch/riscv PR merged during the last merge window. I've queued both of your patches for v6.18. They should show up in for-next in a few days. Thanks,
- Paul