[PATCH v8 16/29] arm64: Share arm64 headers with s390

Catalin Marinas catalin.marinas at arm.com
Mon Sep 28 09:07:52 PDT 2026


On Fri, Sep 18, 2026 at 03:30:53PM +0200, Steffen Eiden wrote:
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 6b005c8fef70..12cbad460258 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -45,6 +45,11 @@ KBUILD_CFLAGS	+= $(CC_FLAGS_NO_FPU) \
>  KBUILD_CFLAGS	+= $(call cc-disable-warning, psabi)
>  KBUILD_AFLAGS	+= $(compat_vdso)
>  
> +# Enable all code shared to s390
> +KBUILD_CFLAGS	+= -DARM64_S390_COMMON
> +KBUILD_AFLAGS	+= -DARM64_S390_COMMON
> +KBUILD_CPPFLAGS	+= -DARM64_S390_COMMON

Do we actually need these defines? They seem only to be used as markers
for the awk scripts to extract the definitions. Why do we need the C
preprocessor involved at all? Could we not just have comment markers:

/* ARM64_S390_COMMON_BEGIN */
...
/* ARM64_S390_COMMON_END */

(also the CPPFLAGS definition was enough, it gets copied into the others
automatically)

> diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
> index ab205f9db94a..1c5c4df260be 100644
> --- a/arch/arm64/include/asm/sysreg.h
> +++ b/arch/arm64/include/asm/sysreg.h
> @@ -16,6 +16,8 @@
>  
>  #include <asm/gpr-num.h>
>  
> +#ifdef ARM64_S390_COMMON
> +
>  /*
>   * ARMv8 ARM reserves the following encoding for system registers:
>   * (Ref: ARMv8 ARM, Section: "System instruction class encoding overview",
> @@ -50,6 +52,8 @@
>  #define sys_reg_CRm(id)	(((id) >> CRm_shift) & CRm_mask)
>  #define sys_reg_Op2(id)	(((id) >> Op2_shift) & Op2_mask)
>  
> +#endif /* ARM64_S390_COMMON */
> +
>  #ifndef CONFIG_BROKEN_GAS_INST
>  
>  #ifdef __ASSEMBLER__
> @@ -123,6 +127,8 @@
>  #define GSB_SYS_BARRIER_INSN		__SYS_BARRIER_INSN(1, 0, 12, 0, 0, 31)
>  #define GSB_ACK_BARRIER_INSN		__SYS_BARRIER_INSN(1, 0, 12, 0, 1, 31)
>  
> +#ifdef ARM64_S390_COMMON
> +
>  /* Data cache zero operations */
>  #define SYS_DC_ISW			sys_insn(1, 0, 7, 6, 2)
>  #define SYS_DC_IGSW			sys_insn(1, 0, 7, 6, 4)
> @@ -832,6 +838,8 @@
>  #define SCTLR_ELx_A	 (BIT(1))
>  #define SCTLR_ELx_M	 (BIT(0))
>  
> +#endif /* ARM64_S390_COMMON */
> +
>  #ifdef CONFIG_CPU_BIG_ENDIAN
>  #define ENDIAN_SET_EL2		SCTLR_ELx_EE
>  #else
> @@ -866,6 +874,7 @@
>  	 SCTLR_EL1_LSMAOE | SCTLR_EL1_nTLSMD | SCTLR_EL1_EIS   | \
>  	 SCTLR_EL1_TSCXT  | SCTLR_EL1_EOS)
>  
> +#ifdef ARM64_S390_COMMON
>  /* MAIR_ELx memory attributes (used by Linux) */
>  #define MAIR_ATTR_DEVICE_nGnRnE		UL(0x00)
>  #define MAIR_ATTR_DEVICE_nGnRE		UL(0x04)
> @@ -1102,6 +1111,8 @@
>  #define GICV5_GICR_CDNMIA_TYPE_MASK	GENMASK_ULL(31, 29)
>  #define GICV5_GICR_CDNMIA_ID_MASK	GENMASK_ULL(23, 0)
>  
> +#endif /* ARM64_S390_COMMON */

I haven't checked them all but there are a few definitions in here that
depend on arm64-specific configs: e.g. GCR depends on KASAN, TGRAN
macros depend on page size, PA_BITS_52 influences some other values.

I think they should be outside the common definitions shared with s390.
In addition, the awk scripts should reject any CONFIG_ (or at least
CONFIG_ARM64_) lines in the copied files. Ideally report an error rather
than silently masking them out.

-- 
Catalin



More information about the linux-arm-kernel mailing list