arm64: Remove unused big-endian support
Subsystems (14)
Will Deacon
maintainerv2 cover arm64: Remove unused big-endian support
Hi folks,
This is version two of the arm64 big-endian removal series previously posted here:
https://lore.kernel.org/linux-arm-kernel/[email protected]/
Changes since v1 include:
* Rebased onto v7.3-rc1
* Removed some now-redundant driver Kconfig entries
* Force little-endian during boot
* Minor stylistic cleanups
Arnd, I wasn't quite as aggressive with the drivers Kconfigs as your suggestion at [1], since I didn't want to prevent COMPILE_TEST from a big-endian architecture in cases where it is currently supported.
Cheers,
Will
[1] https://lore.kernel.org/linux-arm-kernel/[email protected]/
--->8
Will Deacon (14):
selftests/arm64: Remove big-endian support
arm64: bpf: Remove big-endian support from the JIT compiler
arm64: crypto: Assume a little-endian kernel
arm64: lib: Assume a little-endian kernel in custom library routines
arm64: lib: Assume a little-endian kernel in optimised string routines
arm64: assembler: Remove endianness helper macros
arm64: head: Force little-endian early during boot
arm64: vdso32: Always build compat vDSO object as little-endian
KVM: arm64: Remove support for a big-endian hypervisor object
arm64: Remove all usage of CONFIG_CPU_BIG_ENDIAN
arm64: Remove all usage of __AARCH64EB__
arm64: image: Remove endianness handling for generating image header
arm64: Kbuild: Remove vestigial big-endian support
drivers: Kconfig: Simplify dependencies on ARM64 && !CPU_BIG_ENDIAN
arch/arm64/Kconfig | 35 +------- arch/arm64/Makefile | 12 +-- arch/arm64/crypto/aes-ce-ccm-core.S | 4 +- arch/arm64/crypto/aes-neonbs-core.S | 4 +- arch/arm64/crypto/ghash-ce-core.S | 6 +- arch/arm64/crypto/sm4-ce-cipher-core.S | 4 +- arch/arm64/include/asm/assembler.h | 42 --------- arch/arm64/include/asm/compat.h | 14 --- arch/arm64/include/asm/elf.h | 12 --- arch/arm64/include/asm/processor.h | 2 - arch/arm64/include/asm/ptrace.h | 6 -- arch/arm64/include/asm/sysreg.h | 50 +++-------- arch/arm64/include/asm/thread_info.h | 5 -- arch/arm64/include/asm/word-at-a-time.h | 6 -- arch/arm64/include/uapi/asm/byteorder.h | 4 - arch/arm64/kernel/fpsimd.c | 21 +---- arch/arm64/kernel/head.S | 25 +----- arch/arm64/kernel/image.h | 38 +------- arch/arm64/kernel/kexec_image.c | 5 +- arch/arm64/kernel/kgdb.c | 6 +- arch/arm64/kernel/ptrace.c | 8 +- arch/arm64/kernel/signal32.c | 13 --- arch/arm64/kernel/sys32.c | 5 -- arch/arm64/kernel/vdso32/Makefile | 4 - arch/arm64/kvm/hyp/include/nvhe/spinlock.h | 4 - arch/arm64/kvm/hyp/nvhe/gen-hyprel.c | 16 ---- arch/arm64/lib/csum.c | 17 ---- arch/arm64/lib/memchr.S | 2 +- arch/arm64/lib/memcmp.S | 2 - arch/arm64/lib/strcmp.S | 34 +------ arch/arm64/lib/strlen.S | 26 ------ arch/arm64/lib/strncmp.S | 93 ++------------------ arch/arm64/lib/strnlen.S | 16 +--- arch/arm64/mm/extable.c | 5 -- arch/arm64/net/bpf_jit_comp.c | 11 --- drivers/hv/Kconfig | 3 +- drivers/misc/vmw_vmci/Kconfig | 2 +- drivers/net/ethernet/microsoft/Kconfig | 2 +- drivers/soc/tegra/Kconfig | 5 -- tools/testing/selftests/arm64/fp/fp-ptrace.c | 19 +--- tools/testing/selftests/rseq/rseq-arm64.h | 5 -- 41 files changed, 54 insertions(+), 539 deletions(-)
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerPATCH v2 1/14 selftests/arm64: Remove big-endian support
Big-endian support on arm64 depends on BROKEN, so the arm64 selftests do not need to worry about testing this configuration any more.
Remove the 128-bit byte-swapping helper from the fp-ptrace test and the big-endian definition of RSEQ_SIG_DATA from the rseq test.
--- tools/testing/selftests/arm64/fp/fp-ptrace.c | 19 +------------------ tools/testing/selftests/rseq/rseq-arm64.h | 5 ----- 2 files changed, 1 insertion(+), 23 deletions(-)
tools/testing/selftests/arm64/fp/fp-ptrace.c +1 -18
@@ -115,23 +115,6 @@ static void handle_alarm(int sig, siginfo_t *info, void *context) got_alarm = true; } -#ifdef CONFIG_CPU_BIG_ENDIAN -static __uint128_t arm64_cpu_to_le128 (__uint128_t x) -{ -u64 a =swab64 (x); -u64 b =swab64 (x >>64 ); - -return ((__uint128_t )a <<64 ) | b; -} -#else -static __uint128_t arm64_cpu_to_le128 (__uint128_t x) -{ -return x; -} -#endif - -#define arm64_le128_to_cpu (x) arm64_cpu_to_le128(x) -static bool sve_supported (void ) {return getauxval (AT_HWCAP ) &HWCAP_SVE ;
@@ -932,7 +915,7 @@ static void fpsimd_to_sve(__uint128_t *v, char *z, int vl)for (i =0 ; i < __SVE_NUM_ZREGS; i++) { p = (__uint128_t *)&z[__SVE_ZREG_OFFSET (vq, i)]; - *p =arm64_cpu_to_le128 (v[i]); + *p = v[i]; } }
tools/testing/selftests/rseq/rseq-arm64.h +0 -5
@@ -12,12 +12,7 @@* matches code endianness. */ #define RSEQ_SIG_CODE 0xd428bc00/* BRK #0x45E0. */ - -#ifdef __AARCH64EB__ -#define RSEQ_SIG_DATA 0x00bc28d4/* BRK #0x45E0. */ -#else #define RSEQ_SIG_DATA RSEQ_SIG_CODE -#endif #define RSEQ_SIG RSEQ_SIG_DATA
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerPATCH v2 2/14 arm64: bpf: Remove big-endian support from the JIT compiler
In reply to Will DeaconBig-endian support on arm64 depends on BROKEN. In preparation for removing the dead code altogether, remove the big-endian-specific support from the arm64 BPF JIT backend.
--- arch/arm64/net/bpf_jit_comp.c | 11 ----------- 1 file changed, 11 deletions(-)
arch/arm64/net/bpf_jit_comp.c +0 -11
@@ -1439,13 +1439,8 @@ static int build_insn(const struct bpf_verifier_env *env, const struct bpf_insncase BPF_ALU |BPF_END |BPF_FROM_LE :case BPF_ALU |BPF_END |BPF_FROM_BE :case BPF_ALU64 |BPF_END |BPF_FROM_LE : -#ifdef CONFIG_CPU_BIG_ENDIAN -if (BPF_CLASS (code) ==BPF_ALU &&BPF_SRC (code) ==BPF_FROM_BE ) - goto emit_bswap_uxt; -#else /* !CONFIG_CPU_BIG_ENDIAN */ if (BPF_CLASS (code) ==BPF_ALU &&BPF_SRC (code) ==BPF_FROM_LE ) goto emit_bswap_uxt; -#endif switch (imm) {case 16 :emit (A64_REV16 (is64, dst, dst), ctx);
@@ -2559,15 +2554,9 @@ static void clear_garbage(struct jit_ctx *ctx, int reg, int effective_bytes) {if (effective_bytes) {int garbage_bits =64 -8 * effective_bytes; -#ifdef CONFIG_CPU_BIG_ENDIAN -/* garbage bits are at the right end */ -emit (A64_LSR (1 , reg, reg, garbage_bits), ctx); -emit (A64_LSL (1 , reg, reg, garbage_bits), ctx); -#else /* garbage bits are at the left end */ emit (A64_LSL (1 , reg, reg, garbage_bits), ctx);emit (A64_LSR (1 , reg, reg, garbage_bits), ctx); -#endif } }
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Re: [PATCH v2 02/14] arm64: bpf: Remove big-endian support from the JIT compiler
Quoted 10 lines · Will Deacon
Big-endian support on arm64 depends on BROKEN. In preparation for removing the dead code altogether, remove the big-endian-specific support from the arm64 BPF JIT backend.
Acked-by Catalin Marinas <[email protected]>Acked-by Arnd Bergmann <[email protected]>Acked-by Marc Zyngier <[email protected]>Acked-by Eric Biggers <[email protected]>Signed-off-by Will Deacon <[email protected]>
Will Deacon
maintainerPATCH v2 3/14 arm64: crypto: Assume a little-endian kernel
In reply to Will DeaconCommit 5276ea17a23c ("lib/crc: arm64: Assume a little-endian kernel") removed all usage of the CPU_LE()/CPU_BE() macros from the arm64 CRC assembly now that big-endian support depends on BROKEN.
Do the same for the crypto assembly code.
--- arch/arm64/crypto/aes-ce-ccm-core.S | 4 ++-- arch/arm64/crypto/aes-neonbs-core.S | 4 ++-- arch/arm64/crypto/ghash-ce-core.S | 6 +++--- arch/arm64/crypto/sm4-ce-cipher-core.S | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-)
arch/arm64/crypto/aes-ce-ccm-core.S +2 -2
@@ -50,7 +50,7 @@ ld1 {v0.16b}, [x5] /* load mac */ cbz x2, ce_aes_ccm_final ldr x8, [x6, #8] /* load lower ctr */ -CPU_LE( rev x8, x8 ) /* keep swabbed ctr in reg */ + rev x8, x8 /* keep swabbed ctr in reg */ 0: /* outer loop */ ld1 {v1.8b}, [x6] /* load upper ctr */ prfm pldl1strm, [x1]
@@ -73,7 +73,7 @@ CPU_LE( rev x8, x8 ) /* keep swabbed ctr in reg */ eor v0.16b, v0.16b, v2.16b /* xor mac with pt ^ rk[last] */ st1 {v6.16b}, [x0], #16 /* write output block */ bne 0b -CPU_LE( rev x8, x8 ) + rev x8, x8 str x8, [x6, #8] /* store lsb end of ctr (BE) */ cbnz x7, ce_aes_ccm_final st1 {v0.16b}, [x5] /* store mac */
arch/arm64/crypto/aes-neonbs-core.S +2 -2
@@ -824,8 +824,8 @@ SYM_FUNC_START(aesbs_ctr_encrypt) frame_push 0 ldp x7, x8, [x5] ld1 {v0.16b}, [x5] -CPU_LE( rev x7, x7 ) -CPU_LE( rev x8, x8 ) + rev x7, x7 + rev x8, x8 adds x8, x8, #1 adc x7, x7, xzr
arch/arm64/crypto/ghash-ce-core.S +3 -3
@@ -148,7 +148,7 @@ SYM_FUNC_START(pmull_ghash_update_p64) sub w0, w0, #1 3: /* multiply XL by SHASH in GF(2^128) */ -CPU_LE( rev64 T1.16b, T1.16b ) + rev64 T1.16b, T1.16b ext T2.16b, XL.16b, XL.16b, #8 ext IN1.16b, T1.16b, T1.16b, #8
@@ -272,7 +272,7 @@ SYM_FUNC_END(pmull_ghash_update_p64) cbz x0, 3f // tag only? ldr w8, [x5, #12] // load lower counter -CPU_LE( rev w8, w8 ) + rev w8, w8 0: mov w9, #4 // max blocks per round add x10, x0, #0xf
@@ -380,7 +380,7 @@ CPU_LE( rev w8, w8 ) ret 5: -CPU_LE( rev w8, w8 ) + rev w8, w8 str w8, [x5, #12] // store lower counter st1 {XL.2d}, [x4] b 4b
arch/arm64/crypto/sm4-ce-cipher-core.S +2 -2
@@ -18,7 +18,7 @@ SYM_FUNC_START(sm4_ce_do_crypt) ld1 {v8.4s}, [x2] ld1 {v0.4s-v3.4s}, [x0], #64 -CPU_LE( rev32 v8.16b, v8.16b ) + rev32 v8.16b, v8.16b ld1 {v4.4s-v7.4s}, [x0] sm4e v8.4s, v0.4s sm4e v8.4s, v1.4s
@@ -30,7 +30,7 @@ CPU_LE( rev32 v8.16b, v8.16b ) sm4e v8.4s, v7.4s rev64 v8.4s, v8.4s ext v8.16b, v8.16b, v8.16b, #8 -CPU_LE( rev32 v8.16b, v8.16b ) + rev32 v8.16b, v8.16b st1 {v8.4s}, [x1] ret SYM_FUNC_END(sm4_ce_do_crypt)
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerPATCH v2 4/14 arm64: lib: Assume a little-endian kernel in custom library routines
In reply to Will DeaconCommit 5276ea17a23c ("lib/crc: arm64: Assume a little-endian kernel") removed all usage of the CPU_LE()/CPU_BE() macros from the arm64 CRC assembly now that big-endian support depends on BROKEN.
Do the same for the rest of the custom arm64 library code, as well as removing all usage of the '__LITTLE_ENDIAN' macro.
--- arch/arm64/lib/csum.c | 17 ----------------- arch/arm64/lib/memchr.S | 2 +- 2 files changed, 1 insertion(+), 18 deletions(-)
arch/arm64/lib/csum.c +0 -17
@@ -47,11 +47,7 @@ unsigned int __no_sanitize_address do_csum(const unsigned char *buff, int len)*/ shift = offset *8 ; data = *ptr++; -#ifdef __LITTLE_ENDIAN data = (data >> shift) << shift; -#else - data = (data << shift) >> shift; -#endif /* * Body: straightforward aligned loads from here on (the paired loads
@@ -94,13 +90,8 @@ unsigned int __no_sanitize_address do_csum(const unsigned char *buff, int len) len -=16 ; ptr +=2 ; -#ifdef __LITTLE_ENDIAN data = tmp >>64 ; sum64 =accumulate (sum64, tmp); -#else - data = tmp; - sum64 =accumulate (sum64, tmp >>64 ); -#endif }if (len >0 ) { sum64 =accumulate (sum64, data);
@@ -112,11 +103,7 @@ unsigned int __no_sanitize_address do_csum(const unsigned char *buff, int len)* preserving odd/even alignment. */ shift = len *-8 ; -#ifdef __LITTLE_ENDIAN data = (data << shift) >> shift; -#else - data = (data >> shift) << shift; -#endif sum64 =accumulate (sum64, data);/* Finally, folding */
@@ -140,11 +127,7 @@ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, dst = *(const __uint128_t *)daddr->s6_addr; sum += (__force u32 )htonl (len); -#ifdef __LITTLE_ENDIAN sum += (u32 )proto <<24 ; -#else - sum += proto; -#endif src += (src >>64 ) | (src <<64 ); dst += (dst >>64 ) | (dst <<64 );
arch/arm64/lib/memchr.S +1 -1
@@ -63,7 +63,7 @@ L(byte_loop): sub srcin, srcin, #1 ret L(found_word): -CPU_LE( rev tmp, tmp) + rev tmp, tmp clz tmp, tmp sub tmp, tmp, #64 add result, srcin, tmp, asr #3
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerPATCH v2 5/14 arm64: lib: Assume a little-endian kernel in optimised string routines
In reply to Will DeaconBig-endian support on arm64 depends on BROKEN. In preparation for removing the dead code altogether, remove the big-endian-specific support from the arm64 optimised string routines. Although these started life as a fork of Arm's "cortex strings" library and later got updated with the "optimized-routines" code, the in-kernel implementation has always been different enough that removing the unused big-endian portion still makes sense.
--- arch/arm64/lib/memcmp.S | 2 - arch/arm64/lib/strcmp.S | 34 +-------------- arch/arm64/lib/strlen.S | 26 ----------- arch/arm64/lib/strncmp.S | 93 +++------------------------------------- arch/arm64/lib/strnlen.S | 16 +------ 5 files changed, 8 insertions(+), 163 deletions(-)
arch/arm64/lib/memcmp.S +0 -2
@@ -103,10 +103,8 @@ L(last_bytes): /* Compare data bytes and set return value to 0, -1 or 1. */ L(return): -#ifndef __AARCH64EB__ rev data1, data1 rev data2, data2 -#endif cmp data1, data2 L(ret_eq): cset result, ne
arch/arm64/lib/strcmp.S +1 -33
@@ -38,14 +38,6 @@ #define shift x9 #define off2 x10 -/* On big-endian early bytes are at MSB and on little-endian LSB. - LS_FW means shifting towards early bytes. */ -#ifdef __AARCH64EB__ -# define LS_FW lsl -#else -# define LS_FW lsr -#endif - /* NUL detection works on the principle that (X - 1) & (~X) & 0x80 (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and can be done in parallel across the entire word.
@@ -67,28 +59,17 @@ L(loop_aligned): ldr data2, [src1, off2] ldr data1, [src1], 8 L(start_realigned): -#ifdef __AARCH64EB__ - rev tmp, data1 - sub has_nul, tmp, zeroones - orr tmp, tmp, REP8_7f -#else sub has_nul, data1, zeroones orr tmp, data1, REP8_7f -#endif bics has_nul, has_nul, tmp /* Non-zero if NUL terminator. */ ccmp data1, data2, 0, eq b.eq L(loop_aligned) -#ifdef __AARCH64EB__ - rev has_nul, has_nul -#endif eor diff, data1, data2 orr syndrome, diff, has_nul L(end): -#ifndef __AARCH64EB__ rev syndrome, syndrome rev data1, data1 rev data2, data2 -#endif clz shift, syndrome /* The most-significant-non-zero bit of the syndrome marks either the first bit that is different, or the top bit of the first zero byte.
@@ -113,7 +94,7 @@ L(mutual_align): ldr data1, [src1], 8 neg shift, src2, lsl 3 /* Bits to alignment -64. */ mov tmp, -1 - LS_FW tmp, tmp, shift + lsr tmp, tmp, shift orr data1, data1, tmp orr data2, data2, tmp b L(start_realigned)
@@ -135,9 +116,6 @@ L(src1_aligned): neg shift, src2, lsl 3 bic src2, src2, 7 ldr data3, [src2], 8 -#ifdef __AARCH64EB__ - rev data3, data3 -#endif lsr tmp, zeroones, shift orr data3, data3, tmp sub has_nul, data3, zeroones
@@ -152,9 +130,6 @@ L(src1_aligned): L(loop_unaligned): ldr data3, [src1, off1] ldr data2, [src1, off2] -#ifdef __AARCH64EB__ - rev data3, data3 -#endif sub has_nul, data3, zeroones orr tmp, data3, REP8_7f ldr data1, [src1], 8
@@ -163,9 +138,6 @@ L(loop_unaligned): b.eq L(loop_unaligned) lsl tmp, has_nul, shift -#ifdef __AARCH64EB__ - rev tmp, tmp -#endif eor diff, data1, data2 orr syndrome, diff, tmp cbnz syndrome, L(end)
@@ -174,10 +146,6 @@ L(tail): neg shift, shift lsr data2, data3, shift lsr has_nul, has_nul, shift -#ifdef __AARCH64EB__ - rev data2, data2 - rev has_nul, has_nul -#endif eor diff, data1, data2 orr syndrome, diff, has_nul b L(end)
arch/arm64/lib/strlen.S +0 -26
@@ -85,14 +85,6 @@ SYM_FUNC_START(__pi_strlen) cmp tmp1, MIN_PAGE_SIZE - 16 b.gt L(page_cross) ldp data1, data2, [srcin] -#ifdef __AARCH64EB__ - /* For big-endian, carry propagation (if the final byte in the - string is 0x01) means we cannot use has_nul1/2 directly. - Since we expect strings to be small and early-exit, - byte-swap the data now so has_null1/2 will be correct. */ - rev data1, data1 - rev data2, data2 -#endif sub tmp1, data1, zeroones orr tmp2, data1, REP8_7f sub tmp3, data2, zeroones
@@ -144,19 +136,7 @@ L(page_cross_entry): /* Enter with C = has_nul1 == 0. */ L(tail): -#ifdef __AARCH64EB__ - /* For big-endian, carry propagation (if the final byte in the - string is 0x01) means we cannot use has_nul1/2 directly. The - easiest way to get the correct byte is to byte-swap the data - and calculate the syndrome a second time. */ - csel data1, data1, data2, cc - rev data1, data1 - sub tmp1, data1, zeroones - orr tmp2, data1, REP8_7f - bic has_nul1, tmp1, tmp2 -#else csel has_nul1, has_nul1, has_nul2, cc -#endif sub len, src, srcin rev has_nul1, has_nul1 add tmp2, len, 8
@@ -194,13 +174,7 @@ L(page_cross): ldp data1, data2, [src] lsl tmp1, srcin, 3 mov tmp4, -1 -#ifdef __AARCH64EB__ - /* Big-endian. Early bytes are at MSB. */ - lsr tmp1, tmp4, tmp1 /* Shift (tmp1 & 63). */ -#else - /* Little-endian. Early bytes are at LSB. */ lsl tmp1, tmp4, tmp1 /* Shift (tmp1 & 63). */ -#endif orr tmp1, tmp1, REP8_80 orn data1, data1, tmp1 orn tmp2, data2, tmp1
arch/arm64/lib/strncmp.S +6 -87
152 lines not on this page · raw message
arch/arm64/lib/strnlen.S +1 -15
@@ -91,22 +91,10 @@ SYM_FUNC_START(__pi_strnlen) */ sub len, src, srcin cbz has_nul1, .Lnul_in_data2 -CPU_BE( mov data2, data1 ) /*perpare data to re-calculate the syndrome*/ sub len, len, #8 mov has_nul2, has_nul1 .Lnul_in_data2: - /* - * For big-endian, carry propagation (if the final byte in the - * string is 0x01) means we cannot use has_nul directly. The - * easiest way to get the correct byte is to byte-swap the data - * and calculate the syndrome a second time. - */ -CPU_BE( rev data2, data2 ) -CPU_BE( sub tmp1, data2, zeroones ) -CPU_BE( orr tmp2, data2, #REP8_7f ) -CPU_BE( bic has_nul2, tmp1, tmp2 ) - sub len, len, #8 rev has_nul2, has_nul2 clz pos, has_nul2
@@ -139,10 +127,8 @@ CPU_BE( bic has_nul2, tmp1, tmp2 ) lsl tmp4, tmp4, #3 /* Bytes beyond alignment -> bits. */ mov tmp2, #~0 - /* Big-endian. Early bytes are at MSB. */ -CPU_BE( lsl tmp2, tmp2, tmp4 ) /* Shift (tmp1 & 63). */ /* Little-endian. Early bytes are at LSB. */ -CPU_LE( lsr tmp2, tmp2, tmp4 ) /* Shift (tmp1 & 63). */ + lsr tmp2, tmp2, tmp4 /* Shift (tmp1 & 63). */ cmp tmp1, #8
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerPATCH v2 6/14 arm64: assembler: Remove endianness helper macros
In reply to Will DeaconThe CPU_LE()/CPU_BE() helper macros are only used by head.S. Since big-endian support depends on BROKEN, remove the last users along with the macro definitions. The unused regs_to_64() assembly macro, which somewhat bizarrely behaves differently depend on the endianness, is also removed.
--- arch/arm64/include/asm/assembler.h | 31 ------------------------------ arch/arm64/kernel/head.S | 3 +-- 2 files changed, 1 insertion(+), 33 deletions(-)
arch/arm64/include/asm/assembler.h +0 -31
@@ -129,37 +129,6 @@ lr .req x30 // link register b \label .endm -/* -* Select code when configured for BE. - */ -#ifdef CONFIG_CPU_BIG_ENDIAN -#define CPU_BE(code...) code -#else -#define CPU_BE(code...) -#endif - -/* -* Select code when configured for LE. -*/ -#ifdef CONFIG_CPU_BIG_ENDIAN -#define CPU_LE(code...) -#else -#define CPU_LE(code...) code -#endif - -/* -* Define a macro that constructs a 64-bit value by concatenating two -* 32-bit registers. Note that on big endian systems the order of the -* registers is swapped. -*/ -#ifndef CONFIG_CPU_BIG_ENDIAN - .macro regs_to_64, rd, lbits, hbits -#else - .macro regs_to_64, rd, hbits, lbits -#endif - orr \rd, \lbits, \hbits, lsl #32 - .endm -/* * Pseudo-ops for PC-relative adr/ldr/str <reg>, <symbol> where * <symbol> is within the range +/- 4 GB of the PC.
arch/arm64/kernel/head.S +1 -2
@@ -138,8 +138,7 @@ SYM_CODE_START_LOCAL(record_mmu_state) b.ne 0f mrs x19, sctlr_el2 0: -CPU_LE( tbnz x19, #SCTLR_ELx_EE_SHIFT, 1f ) -CPU_BE( tbz x19, #SCTLR_ELx_EE_SHIFT, 1f ) + tbnz x19, #SCTLR_ELx_EE_SHIFT, 1f tst x19, #SCTLR_ELx_C // Z := (C == 0) and x19, x19, #SCTLR_ELx_M // isolate M bit csel x19, xzr, x19, eq // clear x19 if Z
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerPATCH v2 7/14 arm64: head: Force little-endian early during boot
In reply to Will DeaconCommit 2ced0f30a426 ("arm64: head: Switch endianness before populating the ID map") configured SCTLR_ELx.EE at boot according to the endianness of the kernel in case the bootloader had entered the image in the wrong endianness. Additionally, if the MMU was enabled in such a case, logic was added to turn it back off to prevent the hardware walker from misinterpreting the idmap page-table.
Given that the MMU is only expected to be enabled when booting EFI, EFI only supports little-endian and arm64 kernels cannot be built as big-endian images, we can rip out this handling and simply force SCTLR_ELx.EE to 0 (little-endian).
--- arch/arm64/kernel/head.S | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
arch/arm64/kernel/head.S +1 -19
@@ -138,29 +138,11 @@ SYM_CODE_START_LOCAL(record_mmu_state) b.ne 0f mrs x19, sctlr_el2 0: - tbnz x19, #SCTLR_ELx_EE_SHIFT, 1f + bic x19, x19, #SCTLR_ELx_EE // Force little-endian tst x19, #SCTLR_ELx_C // Z := (C == 0) and x19, x19, #SCTLR_ELx_M // isolate M bit csel x19, xzr, x19, eq // clear x19 if Z ret - - /* - * Set the correct endianness early so all memory accesses issued - * before init_kernel_el() occur in the correct byte order. Note that - * this means the MMU must be disabled, or the active ID map will end - * up getting interpreted with the wrong byte order. - */ -1: eor x19, x19, #SCTLR_ELx_EE - bic x19, x19, #SCTLR_ELx_M - b.ne 2f - pre_disable_mmu_workaround - msr sctlr_el2, x19 - b 3f -2: pre_disable_mmu_workaround - msr sctlr_el1, x19 -3: isb - mov x19, xzr - ret SYM_CODE_END(record_mmu_state) /*
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Re: [PATCH v2 07/14] arm64: head: Force little-endian early during boot
Hi Will,
Quoted 23 lines · Will Deacon
Commit
2ced0f30a426("arm64: head: Switch endianness before populating the ID map") configured SCTLR_ELx.EE at boot according to the endianness of the kernel in case the bootloader had entered the image in the wrong endianness. Additionally, if the MMU was enabled in such a case, logic was added to turn it back off to prevent the hardware walker from misinterpreting the idmap page-table.Given that the MMU is only expected to be enabled when booting EFI, EFI only supports little-endian and arm64 kernels cannot be built as big-endian images, we can rip out this handling and simply force SCTLR_ELx.EE to 0 (little-endian).
Suggested-by Ard Biesheuvel <[email protected]>Signed-off-by Will Deacon <[email protected]>--- arch/arm64/kernel/head.S | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)arch/arm64/kernel/head.S +0
-0
arch/arm64/kernel/head.S SYM_CODE_START_LOCAL(record_mmu_state) · line 141
Quoted 5 lines
arch/arm64/kernel/head.S +1
-1@@ -138,29 +138,11 @@ SYM_CODE_START_LOCAL(record_mmu_state) b.ne 0f mrs x19, sctlr_el2 0: - tbnz x19, #SCTLR_ELx_EE_SHIFT, 1f + bic x19, x19, #SCTLR_ELx_EE // Force little-endian
This bic has no effect here: the 'and' below clears it anyway, but x19 is not written back to SCTLR.
When I suggested this, I missed that SCTLR.EE still needs to be cleared before populating the ID map, regardless of whether we enter with the MMU and caches enabled.
IOW, we need to retain the SCTLR writeback logic below. The only thing we can drop is the clearing of the M bit and the invocations of pre_disable_mmu_workaround. But we might as well keep that.
Apologies for the bad suggestion.
Quoted 27 lines
arch/arm64/kernel/head.S +0
-18tst x19, #SCTLR_ELx_C // Z := (C == 0) and x19, x19, #SCTLR_ELx_M // isolate M bit csel x19, xzr, x19, eq // clear x19 if Z ret - - /* - * Set the correct endianness early so all memory accesses issued - * before init_kernel_el() occur in the correct byte order. Note that - * this means the MMU must be disabled, or the active ID map will end - * up getting interpreted with the wrong byte order. - */ -1: eor x19, x19, #SCTLR_ELx_EE - bic x19, x19, #SCTLR_ELx_M - b.ne 2f - pre_disable_mmu_workaround - msr sctlr_el2, x19 - b 3f -2: pre_disable_mmu_workaround - msr sctlr_el1, x19 -3: isb - mov x19, xzr - ret SYM_CODE_END(record_mmu_state) /*Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerRe: [PATCH v2 07/14] arm64: head: Force little-endian early during boot
Quoted 19 lines · Ard Biesheuvel
Quoted 18 lines · Will Deacon
Commit
2ced0f30a426("arm64: head: Switch endianness before populating the ID map") configured SCTLR_ELx.EE at boot according to the endianness of the kernel in case the bootloader had entered the image in the wrong endianness. Additionally, if the MMU was enabled in such a case, logic was added to turn it back off to prevent the hardware walker from misinterpreting the idmap page-table.Given that the MMU is only expected to be enabled when booting EFI, EFI only supports little-endian and arm64 kernels cannot be built as big-endian images, we can rip out this handling and simply force SCTLR_ELx.EE to 0 (little-endian).
Suggested-by Ard Biesheuvel <[email protected]>Signed-off-by Will Deacon <[email protected]>--- arch/arm64/kernel/head.S | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
Quoted 13 lines
arch/arm64/kernel/head.S SYM_CODE_START_LOCAL(record_mmu_state) · line 141
Quoted 10 lines
arch/arm64/kernel/head.S +1
-1@@ -138,29 +138,11 @@ SYM_CODE_START_LOCAL(record_mmu_state) b.ne 0f mrs x19, sctlr_el2 0: - tbnz x19, #SCTLR_ELx_EE_SHIFT, 1f + bic x19, x19, #SCTLR_ELx_EE // Force little-endianThis bic has no effect here: the 'and' below clears it anyway, but x19 is not written back to SCTLR.
Oh yes, this is only used to drive the flag to say whether or not the MMU was enabled on entry and then the other part of the patch removes the sctlr write.
Quoted 9 lines
When I suggested this, I missed that SCTLR.EE still needs to be cleared before populating the ID map, regardless of whether we enter with the MMU and caches enabled.
IOW, we need to retain the SCTLR writeback logic below. The only thing we can drop is the clearing of the M bit and the invocations of
pre_disable_mmu_workaround. But we might as well keep that.Apologies for the bad suggestion.
Not to worry, I made an absolutely dog's dinner of implementing it anyway! I'll just drop this patch for now.
Cheers,
Will
Will Deacon
maintainerPATCH v2 8/14 arm64: vdso32: Always build compat vDSO object as little-endian
In reply to Will DeaconBig-endian support on arm64 depends on BROKEN. In preparation for removing the dead code altogether, remove support for building a big-endian 32-bit vDSO.
--- arch/arm64/kernel/vdso32/Makefile | 4 ---- 1 file changed, 4 deletions(-)
arch/arm64/kernel/vdso32/Makefile +0 -4
@@ -45,11 +45,7 @@ endif # From arm Makefile VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2-cfi-asm) VDSO_CAFLAGS += -mabi=aapcs-linux -mfloat-abi=soft -ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) -VDSO_CAFLAGS += -mbig-endian -else VDSO_CAFLAGS += -mlittle-endian -endif # From arm vDSO Makefile VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerPATCH v2 9/14 KVM: arm64: Remove support for a big-endian hypervisor object
In reply to Will DeaconBig-endian support on arm64 depends on BROKEN. In preparation for removing the dead code altogether, remove the support for generating ELF relocations for a big-endian hypervisor object and drop the unused big-endian spinlock definition from nVHE.
--- arch/arm64/kvm/hyp/include/nvhe/spinlock.h | 4 ---- arch/arm64/kvm/hyp/nvhe/gen-hyprel.c | 16 ---------------- 2 files changed, 20 deletions(-)
arch/arm64/kvm/hyp/include/nvhe/spinlock.h +0 -4
@@ -20,11 +20,7 @@typedef union hyp_spinlock {u32 __val;struct { -#ifdef __AARCH64EB__ -u16 next, owner; -#else u16 owner, next; -#endif }; }hyp_spinlock_t ;
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c +0 -16
@@ -139,28 +139,12 @@ static struct {const char *sh_string; } elf; -#if defined(CONFIG_CPU_LITTLE_ENDIAN ) -#define elf16toh (x) le16toh(x)#define elf32toh (x) le32toh(x)#define elf64toh (x) le64toh(x)#define ELFENDIAN ELFDATA2LSB -#elif defined(CONFIG_CPU_BIG_ENDIAN ) - -#define elf16toh (x) be16toh(x) -#define elf32toh (x) be32toh(x) -#define elf64toh (x) be64toh(x) - -#define ELFENDIAN ELFDATA2MSB - -#else - -#error PDP-endian sadly unsupported... - -#endif -#define fatal_error (fmt, ...) \ ({ \ fprintf(stderr, "error: %s: " fmt "\n", \
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerPATCH v2 10/14 arm64: Remove all usage of CONFIG_CPU_BIG_ENDIAN
In reply to Will DeaconBig-endian support on arm64 depends on BROKEN. In preparation for removing the dead code altogether, remove all usage of CONFIG_CPU_BIG_ENDIAN from the arm64 kernel port.
--- arch/arm64/include/asm/processor.h | 2 -- arch/arm64/include/asm/ptrace.h | 6 ---- arch/arm64/include/asm/sysreg.h | 50 ++++++++-------------------- arch/arm64/include/asm/thread_info.h | 5 --- arch/arm64/kernel/fpsimd.c | 21 ++---------- arch/arm64/kernel/image.h | 18 ++-------- arch/arm64/kernel/kexec_image.c | 5 ++- arch/arm64/kernel/kgdb.c | 6 +--- arch/arm64/kernel/ptrace.c | 8 ++--- arch/arm64/kernel/signal32.c | 3 -- arch/arm64/kernel/sys32.c | 5 --- 11 files changed, 23 insertions(+), 106 deletions(-)
arch/arm64/include/asm/processor.h +0 -2
@@ -351,8 +351,6 @@ static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc,unsigned long pstate =PSR_AA32_MODE_USR ;if (pc &1 ) pstate |=PSR_AA32_T_BIT ; -if (IS_ENABLED (CONFIG_CPU_BIG_ENDIAN )) - pstate |=PSR_AA32_E_BIT ;start_thread_common (regs, pc, pstate);spectre_v4_enable_task_mitigation (current);
arch/arm64/include/asm/ptrace.h +0 -6
@@ -66,12 +66,6 @@#define PSR_AA32_IT_MASK 0x0600fc00/* If-Then execution state mask */ #define PSR_AA32_GE_MASK 0x000f0000 -#ifdef CONFIG_CPU_BIG_ENDIAN -#define PSR_AA32_ENDSTATE PSR_AA32_E_BIT -#else -#define PSR_AA32_ENDSTATE 0 -#endif -/* AArch32 CPSR bits, as seen in AArch32 */ #define COMPAT_PSR_DIT_BIT 0x00200000
arch/arm64/include/asm/sysreg.h +14 -36
72 lines not on this page · raw message
arch/arm64/include/asm/thread_info.h +0 -5
@@ -29,13 +29,8 @@ struct thread_info {union {u64 preempt_count;/* 0 => preemptible, <0 => bug */ struct { -#ifdef CONFIG_CPU_BIG_ENDIAN -u32 need_resched; -u32 count; -#else u32 count;u32 need_resched; -#endif } preempt; };#ifdef CONFIG_SHADOW_CALL_STACK
arch/arm64/kernel/fpsimd.c +2 -19
@@ -621,23 +621,6 @@ static int __init sme_sysctl_init(void) { return 0; }#define ZREG (sve_state, vq, n) ((char *)(sve_state) + \ (SVE_SIG_ZREG_OFFSET(vq, n) - SVE_SIG_REGS_OFFSET)) -#ifdef CONFIG_CPU_BIG_ENDIAN -static __uint128_t arm64_cpu_to_le128 (__uint128_t x) -{ -u64 a =swab64 (x); -u64 b =swab64 (x >>64 ); - -return ((__uint128_t )a <<64 ) | b; -} -#else -static __uint128_t arm64_cpu_to_le128 (__uint128_t x) -{ -return x; -} -#endif - -#define arm64_le128_to_cpu (x) arm64_cpu_to_le128(x) -static void __fpsimd_to_sve (struct arm64_sve_state *sst,struct user_fpsimd_state const *fst,unsigned int vq)
@@ -647,7 +630,7 @@ static void __fpsimd_to_sve(struct arm64_sve_state *sst,for (i =0 ; i <SVE_NUM_ZREGS ; ++i) { p = (__uint128_t *)ZREG (sst, vq, i); - *p =arm64_cpu_to_le128 (fst->vregs[i]); + *p = fst->vregs[i]; } }
@@ -702,7 +685,7 @@ static inline void sve_to_fpsimd(struct task_struct *task) vq =sve_vq_from_vl (vl);for (i =0 ; i <SVE_NUM_ZREGS ; ++i) { p = (__uint128_t const *)ZREG (sst, vq, i); - fst->vregs[i] =arm64_le128_to_cpu (*p); + fst->vregs[i] = *p; } }
arch/arm64/kernel/image.h +2 -16
@@ -24,28 +24,14 @@* when PIE is in effect. So we need to split them up in 32-bit high and low * words. */ -#ifdef CONFIG_CPU_BIG_ENDIAN -#define DATA_LE32 (data) \ - ((((data) & 0x000000ff) << 24) | \ - (((data) & 0x0000ff00) << 8) | \ - (((data) & 0x00ff0000) >> 8) | \ - (((data) & 0xff000000) >> 24)) -#else -#define DATA_LE32 (data) ((data) & 0xffffffff) -#endif -#define DEFINE_IMAGE_LE64 (sym, data) \ - sym##_lo32 = DATA_LE32((data) & 0xffffffff); \ - sym##_hi32 = DATA_LE32((data) >> 32) + sym##_lo32 = (data) & 0xffffffff; \ + sym##_hi32 = (data) >> 32#define __HEAD_FLAG (field) (__HEAD_FLAG_##field << \ ARM64_IMAGE_FLAG_##field##_SHIFT) -#ifdef CONFIG_CPU_BIG_ENDIAN -#define __HEAD_FLAG_BE ARM64_IMAGE_FLAG_BE -#else #define __HEAD_FLAG_BE ARM64_IMAGE_FLAG_LE -#endif #define __HEAD_FLAG_PAGE_SIZE ((PAGE_SHIFT - 10) / 2)
arch/arm64/kernel/kexec_image.c +2 -3
@@ -40,7 +40,7 @@ static void *image_load(struct kimage *image, {struct arm64_image_header *h;u64 flags, value; -bool be_image, be_kernel; +bool be_image;struct kexec_buf kbuf = {};unsigned long text_offset, kernel_segment_number;struct kexec_segment *kernel_segment;
@@ -58,8 +58,7 @@ static void *image_load(struct kimage *image,/* Check cpu features */ flags =le64_to_cpu (h->flags); be_image =arm64_image_flag_field (flags,ARM64_IMAGE_FLAG_BE ); - be_kernel =IS_ENABLED (CONFIG_CPU_BIG_ENDIAN ); -if ((be_image != be_kernel) && !system_supports_mixed_endian ()) +if (be_image && !system_supports_mixed_endian ())return ERR_PTR (-EINVAL ); value =arm64_image_flag_field (flags,ARM64_IMAGE_FLAG_PAGE_SIZE );
arch/arm64/kernel/kgdb.c +1 -5
@@ -60,11 +60,7 @@ struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = {* 32-bits. Look for the big comment in asm/kgdb.h for more * detail. */ - { "pstate", 4, offsetof(struct pt_regs, pstate) -#ifdef CONFIG_CPU_BIG_ENDIAN - + 4 -#endif - }, + { "pstate", 4, offsetof(struct pt_regs, pstate)}, { "v0", 16, -1 }, { "v1", 16, -1 }, { "v2", 16, -1 },
arch/arm64/kernel/ptrace.c +2 -6
@@ -2517,12 +2517,8 @@ static int valid_compat_regs(struct user_pt_regs *regs) { regs->pstate &= ~SPSR_EL1_AARCH32_RES0_BITS ; -if (!system_supports_mixed_endian_el0 ()) { -if (IS_ENABLED (CONFIG_CPU_BIG_ENDIAN )) - regs->pstate |=PSR_AA32_E_BIT ; -else - regs->pstate &= ~PSR_AA32_E_BIT ; - } +if (!system_supports_mixed_endian_el0 ()) + regs->pstate &= ~PSR_AA32_E_BIT ; if (user_mode(regs) && (regs->pstate & PSR_MODE32_BIT) && (regs->pstate & PSR_AA32_A_BIT) == 0 &&
arch/arm64/kernel/signal32.c +0 -3
@@ -334,9 +334,6 @@ static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka,/* The IT state must be cleared for both ARM and Thumb-2 */ spsr &= ~PSR_AA32_IT_MASK ; -/* Restore the original endianness */ - spsr |=PSR_AA32_ENDSTATE ; -if (ka->sa.sa_flags &SA_RESTORER ) { retcode =ptr_to_compat (ka->sa.sa_restorer); }else {
arch/arm64/kernel/sys32.c +0 -5
@@ -59,12 +59,7 @@ COMPAT_SYSCALL_DEFINE6(aarch32_mmap2, unsigned long, addr, unsigned long, len,return ksys_mmap_pgoff (addr, len, prot, flags, fd, off_4k); } -#ifdef CONFIG_CPU_BIG_ENDIAN -#define arg_u32p (name) u32, name##_hi, u32, name##_lo -#else #define arg_u32p (name) u32, name##_lo, u32, name##_hi -#endif -#define arg_u64 (name) (((u64)name##_hi << 32) | name##_lo) COMPAT_SYSCALL_DEFINE6(aarch32_pread64, unsigned int, fd, char __user *, buf,
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerPATCH v2 11/14 arm64: Remove all usage of __AARCH64EB__
In reply to Will DeaconBig-endian support on arm64 depends on BROKEN. In preparation for removing the dead code altogether, remove all usage of __AARCH64EB__ from the arm64 kernel port.
--- arch/arm64/include/asm/compat.h | 14 -------------- arch/arm64/include/asm/elf.h | 12 ------------ arch/arm64/include/asm/word-at-a-time.h | 6 ------ arch/arm64/include/uapi/asm/byteorder.h | 4 ---- arch/arm64/kernel/signal32.c | 10 ---------- arch/arm64/mm/extable.c | 5 ----- 6 files changed, 51 deletions(-)
arch/arm64/include/asm/compat.h +0 -14
@@ -28,34 +28,20 @@ typedef u16 compat_ipc_pid_t;#include <linux/sched.h> #include <linux/sched/task_stack.h> -#ifdef __AARCH64EB__ -#define COMPAT_UTS_MACHINE "armv8b\0\0" -#else #define COMPAT_UTS_MACHINE "armv8l\0\0" -#endif typedef u16 __compat_uid16_t ;typedef u16 __compat_gid16_t ;typedef s32 compat_nlink_t ;struct compat_stat { -#ifdef __AARCH64EB__ -short st_dev; -short __pad1; -#else compat_dev_t st_dev; -#endif compat_ino_t st_ino;compat_mode_t st_mode;compat_ushort_t st_nlink;__compat_uid16_t st_uid;__compat_gid16_t st_gid; -#ifdef __AARCH64EB__ -short st_rdev; -short __pad2; -#else compat_dev_t st_rdev; -#endif compat_off_t st_size;compat_off_t st_blksize;compat_off_t st_blocks;
arch/arm64/include/asm/elf.h +0 -12
@@ -72,11 +72,7 @@* These are used to set parameters in the core dumps. */ #define ELF_CLASS ELFCLASS64 -#ifdef __AARCH64EB__ -#define ELF_DATA ELFDATA2MSB -#else #define ELF_DATA ELFDATA2LSB -#endif #define ELF_ARCH EM_AARCH64/*
@@ -85,11 +81,7 @@* intent than poking at uname or /proc/cpuinfo. */ #define ELF_PLATFORM_SIZE 16 -#ifdef __AARCH64EB__ -#define ELF_PLATFORM ("aarch64_be") -#else #define ELF_PLATFORM ("aarch64") -#endif /* * This is used to ensure we don't load something for the wrong architecture.
@@ -195,11 +187,7 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,#define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12))#endif -#ifdef __AARCH64EB__ -#define COMPAT_ELF_PLATFORM ("v8b") -#else #define COMPAT_ELF_PLATFORM ("v8l") -#endif /* AArch32 registers. */ #define COMPAT_ELF_NGREG 18
arch/arm64/include/asm/word-at-a-time.h +0 -6
@@ -7,8 +7,6 @@#include <linux/uaccess.h> -#ifndef __AARCH64EB__ -#include <linux/bitops.h> #include <linux/wordpart.h>
@@ -36,10 +34,6 @@ static inline unsigned long zero_bytemask(unsigned long bits)return bits >>7 ; } -#else /* __AARCH64EB__ */ -#include <asm-generic/word-at-a-time.h> -#endif -/* * Load an unaligned word from kernel space. *
arch/arm64/include/uapi/asm/byteorder.h +0 -4
@@ -17,10 +17,6 @@#ifndef __ASM_BYTEORDER_H#define __ASM_BYTEORDER_H -#ifdef __AARCH64EB__ -#include <linux/byteorder/big_endian.h> -#else #include <linux/byteorder/little_endian.h> -#endif #endif /* __ASM_BYTEORDER_H */
arch/arm64/kernel/signal32.c +0 -10
@@ -70,22 +70,12 @@ static inline int get_sigset_t(sigset_t *set,/* * VFP save/restore code. -* -* We have to be careful with endianness, since the fpsimd context-switch -* code operates on 128-bit (Q) register values whereas the compat ABI -* uses an array of 64-bit (D) registers. Consequently, we need to swap -* the two halves of each Q register when running on a big-endian CPU. */ union __fpsimd_vreg {__uint128_t raw;struct { -#ifdef __AARCH64EB__ -u64 hi; -u64 lo; -#else u64 lo;u64 hi; -#endif }; };
arch/arm64/mm/extable.c +0 -5
@@ -79,12 +79,7 @@ ex_handler_load_unaligned_zeropad(const struct exception_table_entry *ex, addr &= ~0x7UL ; data = *(unsigned long *)addr; - -#ifndef __AARCH64EB__ data >>=8 * offset; -#else - data <<=8 * offset; -#endif pt_regs_write_reg (regs, reg_data, data);
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerPATCH v2 12/14 arm64: image: Remove endianness handling for generating image header
In reply to Will DeaconSince big-endian support for arm64 depends on BROKEN, we don't need to bother jumping through hoops to generate a little-endian kernel image header for a big-endian target. We can just ignore the possibility instead.
--- arch/arm64/include/asm/assembler.h | 11 ----------- arch/arm64/kernel/head.S | 4 ++-- arch/arm64/kernel/image.h | 24 ++---------------------- 3 files changed, 4 insertions(+), 35 deletions(-)
arch/arm64/include/asm/assembler.h +0 -11
@@ -521,17 +521,6 @@ alternative_else_nop_endif#define EXPORT_SYMBOL_NOKASAN (name) EXPORT_SYMBOL(name)#endif -/* -* Emit a 64-bit absolute little endian symbol reference in a way that -* ensures that it will be resolved at build time, even when building a -* PIE binary. This requires cooperation from the linker script, which -* must emit the lo32/hi32 halves individually. -*/ - .macro le64sym, sym - .long \sym\()_lo32 - .long \sym\()_hi32 - .endm -/* * mov_q - move an immediate constant into a 64-bit register using * between 2 and 4 movz/movk instructions (depending on the
arch/arm64/kernel/head.S +2 -2
@@ -61,8 +61,8 @@ efi_signature_nop // special NOP to identity as PE/COFF executable b primary_entry // branch to kernel start, magic .quad 0 // Image load offset from start of RAM, little-endian - le64sym _kernel_size_le // Effective size of kernel image, little-endian - le64sym _kernel_flags_le // Informative flags, little-endian + .quad _kernel_size_le // Effective size of kernel image, little-endian + .quad _kernel_flags_le // Informative flags, little-endian .quad 0 // reserved .quad 0 // reserved .quad 0 // reserved
arch/arm64/kernel/image.h +2 -22
@@ -13,21 +13,6 @@#include <asm/image.h> -/* -* There aren't any ELF relocations we can use to endian-swap values known only -* at link time (e.g. the subtraction of two symbol addresses), so we must get -* the linker to endian-swap certain values before emitting them. -* -* Note that, in order for this to work when building the ELF64 PIE executable -* (for KASLR), these values should not be referenced via R_AARCH64_ABS64 -* relocations, since these are fixed up at runtime rather than at build time -* when PIE is in effect. So we need to split them up in 32-bit high and low -* words. -*/ -#define DEFINE_IMAGE_LE64 (sym, data) \ - sym##_lo32 = (data) & 0xffffffff; \ - sym##_hi32 = (data) >> 32 -#define __HEAD_FLAG (field) (__HEAD_FLAG_##field << \ ARM64_IMAGE_FLAG_##field##_SHIFT)
@@ -41,13 +26,8 @@ __HEAD_FLAG(PAGE_SIZE) | \ __HEAD_FLAG(PHYS_BASE)) -/* -* These will output as part of the Image header, which should be little-endian -* regardless of the endianness of the kernel. While constant values could be -* endian swapped in head.S, all are done here for consistency. -*/ #define HEAD_SYMBOLS \ - DEFINE_IMAGE_LE64(_kernel_size_le, _end - _text); \ - DEFINE_IMAGE_LE64(_kernel_flags_le, __HEAD_FLAGS); + _kernel_size_le = _end - _text; \ + _kernel_flags_le = __HEAD_FLAGS;#endif /* __ARM64_KERNEL_IMAGE_H */
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerRe: [PATCH v2 12/14] arm64: image: Remove endianness handling for generating image header
Quoted 10 lines · Will Deacon
Since big-endian support for arm64 depends on BROKEN, we don't need to bother jumping through hoops to generate a little-endian kernel image header for a big-endian target. We can just ignore the possibility instead.
Acked-by Catalin Marinas <[email protected]>Acked-by Arnd Bergmann <[email protected]>Acked-by Marc Zyngier <[email protected]>Acked-by Eric Biggers <[email protected]>Signed-off-by Will Deacon <[email protected]>
Quoted 5 lines
--- arch/arm64/include/asm/assembler.h | 11 ----------- arch/arm64/kernel/head.S | 4 ++-- arch/arm64/kernel/image.h | 24 ++---------------------- 3 files changed, 4 insertions(+), 35 deletions(-)
I think this is another patch I should drop from the series.
I was under the wrong impression that we were using two 32-bit words for symbol addresses because of endianness quirks in the linker, but digging into the original rationale from Ard [1], this is more fundamental to the way in which the PIE toolchain handles ABS64 symbol relocations.
Will
[1] https://lore.kernel.org/all/CAKv+Gu8vdk-9N_VVG6XWYLp1SM9ynfcsbxwk2xx1mXYq7qN0Cg@mail.gmail.com/
Will Deacon
maintainerPATCH v2 13/14 arm64: Kbuild: Remove vestigial big-endian support
In reply to Will DeaconSince 1cf89b6bf660 ("arm64: Kconfig: Make CPU_BIG_ENDIAN depend on BROKEN"), CONFIG_CPU_BIG_ENDIAN has depended on BROKEN for arm64.
Remove the last traces of its existence and unconditionally force a little-endian kernel build.
--- arch/arm64/Kconfig | 35 ++++------------------------------- arch/arm64/Makefile | 12 ++---------- 2 files changed, 6 insertions(+), 41 deletions(-)
arch/arm64/Kconfig +4 -31
@@ -73,7 +73,7 @@ config ARM64 select ARCH_SUPPORTS_HUGETLBFS select ARCH_SUPPORTS_MEMORY_FAILURE select ARCH_SUPPORTS_SHADOW_CALL_STACK if CC_HAVE_SHADOW_CALL_STACK - select ARCH_SUPPORTS_LTO_CLANG if CPU_LITTLE_ENDIAN + select ARCH_SUPPORTS_LTO_CLANG select ARCH_SUPPORTS_LTO_CLANG_THIN select ARCH_SUPPORTS_CFI select ARCH_SUPPORTS_ATOMIC_RMW
@@ -224,7 +224,7 @@ config ARM64 select HAVE_FUNCTION_ARG_ACCESS_API select MMU_GATHER_RCU_TABLE_FREE select HAVE_RSEQ - select HAVE_RUST if RUSTC_SUPPORTS_ARM64 + select HAVE_RUST select HAVE_STACKPROTECTOR select HAVE_STATIC_CALL if CFI select HAVE_SYSCALL_TRACEPOINTS
@@ -263,10 +263,6 @@ config ARM64 help ARM 64-bit (AArch64) Linux support. -config RUSTC_SUPPORTS_ARM64 - def_bool y - depends on CPU_LITTLE_ENDIAN - config CLANG_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS def_bool CC_IS_CLANG # https://github.com/ClangBuiltLinux/linux/issues/1507
@@ -1596,28 +1592,6 @@ config ARM64_LPA2 def_bool y depends on ARM64_PA_BITS_52 && !ARM64_64K_PAGES -choice - prompt "Endianness" - default CPU_LITTLE_ENDIAN - help - Select the endianness of data accesses performed by the CPU. Userspace - applications will need to be compiled and linked for the endianness - that is selected here. - -config CPU_BIG_ENDIAN - bool "Build big-endian kernel" - depends on BROKEN - help - Say Y if you plan on running a kernel with a big-endian userspace. - -config CPU_LITTLE_ENDIAN - bool "Build little-endian kernel" - help - Say Y if you plan on running a kernel with a little-endian userspace. - This is usually the case for distributions targeting arm64. - -endchoice - config NR_CPUS int "Maximum number of CPUs (2-4096)" range 2 4096
@@ -1855,7 +1829,6 @@ config KUSER_HELPERS config COMPAT_VDSO bool "Enable vDSO for 32-bit applications" - depends on !CPU_BIG_ENDIAN depends on (CC_IS_CLANG && LD_IS_LLD) || "$(CROSS_COMPILE_COMPAT)" != "" default y help
@@ -2319,7 +2292,7 @@ menu "ARMv9.6 architectural features" config ARM64_LSUI bool "Support Unprivileged Load Store Instructions (LSUI)" default y - depends on AS_HAS_LSUI && !CPU_BIG_ENDIAN + depends on AS_HAS_LSUI help The Unprivileged Load Store Instructions (LSUI) provides variants load/store instructions that access user-space memory
@@ -2524,7 +2497,7 @@ config EFI_STUB config EFI bool "UEFI runtime support" - depends on OF && !CPU_BIG_ENDIAN + depends on OF depends on KERNEL_MODE_NEON select ARCH_SUPPORTS_ACPI select LIBFDT
arch/arm64/Makefile +2 -10
@@ -119,20 +119,12 @@ KBUILD_CFLAGS += -ffixed-x18 KBUILD_RUSTFLAGS += -Zfixed-x18 endif -ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) -KBUILD_CPPFLAGS += -mbig-endian -CHECKFLAGS += -D__AARCH64EB__ -# Prefer the baremetal ELF build target, but not all toolchains include -# it so fall back to the standard linux version if needed. -KBUILD_LDFLAGS += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb -z norelro) -UTS_MACHINE := aarch64_be -else KBUILD_CPPFLAGS += -mlittle-endian CHECKFLAGS += -D__AARCH64EL__ -# Same as above, prefer ELF but fall back to linux target if needed. +# Prefer the baremetal ELF build target, but not all toolchains include +# it so fall back to the standard linux version if needed. KBUILD_LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux -z norelro) UTS_MACHINE := aarch64 -endif ifeq ($(CONFIG_LD_IS_LLD), y) KBUILD_LDFLAGS += -z norelro
Signature · 1 line
2.55.0.979.g7e5102b832-goog
Will Deacon
maintainerPATCH v2 14/14 drivers: Kconfig: Simplify dependencies on ARM64 && !CPU_BIG_ENDIAN
In reply to Will DeaconNow that arm64 no longer supports a big-endian kernel, simplify some driver Kconfig entries so that the dependency on a little-endian kernel no longer needs to be called out explicitly.
--- drivers/hv/Kconfig | 3 +-- drivers/misc/vmw_vmci/Kconfig | 2 +- drivers/net/ethernet/microsoft/Kconfig | 2 +- drivers/soc/tegra/Kconfig | 5 ----- 4 files changed, 3 insertions(+), 9 deletions(-)
drivers/hv/Kconfig +1 -2
@@ -4,8 +4,7 @@ menu "Microsoft Hyper-V guest support" config HYPERV bool "Microsoft Hyper-V core hypervisor support" - depends on (X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \ - || (ARM64 && !CPU_BIG_ENDIAN) + depends on (X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) || ARM64 select PARAVIRT select X86_HV_CALLBACK_VECTOR if X86 select OF_EARLY_FLATTREE if OF
drivers/misc/vmw_vmci/Kconfig +1 -1
@@ -5,7 +5,7 @@ config VMWARE_VMCI tristate "VMware VMCI Driver" - depends on (X86 || ARM64) && !CPU_BIG_ENDIAN && PCI + depends on (X86 || ARM64) && PCI help This is VMware's Virtual Machine Communication Interface. It enables high-speed communication between host and guest in a virtual
drivers/net/ethernet/microsoft/Kconfig +1 -1
@@ -18,7 +18,7 @@ if NET_VENDOR_MICROSOFT config MICROSOFT_MANA tristate "Microsoft Azure Network Adapter (MANA) support" depends on PCI_MSI - depends on X86_64 || (ARM64 && !CPU_BIG_ENDIAN) + depends on X86_64 || ARM64 depends on PCI_HYPERV select AUXILIARY_BUS select DIMLIB
drivers/soc/tegra/Kconfig +0 -5
@@ -102,7 +102,6 @@ config ARCH_TEGRA_210_SOC config ARCH_TEGRA_186_SOC bool "NVIDIA Tegra186 SoC" default ARCH_TEGRA - depends on !CPU_BIG_ENDIAN select PINCTRL_TEGRA186 select MAILBOX select SOC_TEGRA_PMC
@@ -117,7 +116,6 @@ config ARCH_TEGRA_186_SOC config ARCH_TEGRA_194_SOC bool "NVIDIA Tegra194 SoC" default ARCH_TEGRA - depends on !CPU_BIG_ENDIAN select MAILBOX select PINCTRL_TEGRA194 select SOC_TEGRA_PMC
@@ -127,7 +125,6 @@ config ARCH_TEGRA_194_SOC config ARCH_TEGRA_234_SOC bool "NVIDIA Tegra234 SoC" default ARCH_TEGRA - depends on !CPU_BIG_ENDIAN select MAILBOX select PINCTRL_TEGRA234 select SOC_TEGRA_PMC
@@ -137,7 +134,6 @@ config ARCH_TEGRA_234_SOC config ARCH_TEGRA_238_SOC bool "NVIDIA Tegra238 SoC" default ARCH_TEGRA - depends on !CPU_BIG_ENDIAN select MAILBOX select SOC_TEGRA_PMC help
@@ -152,7 +148,6 @@ config ARCH_TEGRA_241_SOC config ARCH_TEGRA_264_SOC bool "NVIDIA Tegra264 SoC" default ARCH_TEGRA - depends on !CPU_BIG_ENDIAN select MAILBOX select SOC_TEGRA_PMC help
Signature · 1 line
2.55.0.979.g7e5102b832-goog
RE: [PATCH v2 14/14] drivers: Kconfig: Simplify dependencies on ARM64 && !CPU_BIG_ENDIAN
From: Will Deacon <[email protected]> Sent: Monday, September 7, 2026 9:37 AM
Quoted 19 lines
Now that arm64 no longer supports a big-endian kernel, simplify some driver
Kconfigentries so that the dependency on a little-endian kernel no longer needs to be called out explicitly.Suggested-by Arnd Bergmann <[email protected]>Signed-off-by Will Deacon <[email protected]>--- drivers/hv/Kconfig | 3 +-- drivers/misc/vmw_vmci/Kconfig | 2 +- drivers/net/ethernet/microsoft/Kconfig | 2 +- drivers/soc/tegra/Kconfig | 5 ----- 4 files changed, 3 insertions(+), 9 deletions(-)drivers/hv/Kconfig +0
-0
drivers/hv/Kconfig menu "Microsoft Hyper-V guest support" · line 10
Quoted 9 lines
drivers/hv/Kconfig +1
-2@@ -4,8 +4,7 @@ menu "Microsoft Hyper-V guest support" config HYPERV bool "Microsoft Hyper-V core hypervisor support" - depends on (X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \ - || (ARM64 && !CPU_BIG_ENDIAN) + depends on (X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) || ARM64 select PARAVIRT select X86_HV_CALLBACK_VECTOR if X86 select OF_EARLY_FLATTREE if OF
For this Hyper-V change,