From nobody Tue Feb 10 02:55:04 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B95F03612C6 for ; Wed, 14 Jan 2026 07:28:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768375708; cv=none; b=ini03cvPTCO2sED+AQf9UPmMjs4oEpz3bFUOtjJZGMLgikadvFxQyeqTu00oYlsKFb/50Db82AiRnB9ZK2JQLuR/YdVtA/GSykBdU1GCP1JRWV+TE8FRvUN4I1RGUKljgHDHMCu4zg//JVGC6Q/GBwdKAQJIOw7ApplXCsu0La0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768375708; c=relaxed/simple; bh=ZkCW0y1qBYlQUwt7ET0wm5t9Ac/g46X+vbejvWmozno=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HCK/+0Zf+WrIbYDvNFhirMROg9w1XpMeH8eEEFkm5rlJIGLZURtRf67jNEvuaTWJGLQogYaNiQnaDT92TJrrmFgHhrIVIzucP+kOpreS2yPY5tCWBkDK72GcwQbRwD0SfiRD8G9nAvP/4ruNIqcnQc/4awsdCNBJhcACxjevQgQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=lVXaiMQV; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2HtSlf6u; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="lVXaiMQV"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2HtSlf6u" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1768375701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oZLC1OcX/4X/172DOOta5GPxHR7S1+1EA8wRTIuT8Os=; b=lVXaiMQVJdv+PLdbhiWcS6321TuD3FaklqUcveKiVC6oEuEyJS1l/UFGojFx8VQXh8MtvO 0IcXHEXGMXLDRXGG6pheay/blpmXvIwcFS4zvEGzFLEbgMhVZbT5qtzj4DYKcctMWkxjiD B4Q4FBBvihx84YI5kyZ8fXMl8aMqNR/uiWpQTYTWz8ynfubBf7xoPvdXEDSfClFE8ia6mc U9YZpCoKumJGEKYEvJq+YWk8q0DXmNhIz32gmj6lASoU0+EpOLNhy+yypSs5Qx03aUBGyr eyJVsOy7yXJgEx2PtMo3ZVH/gMr5ynyLELxYi6myykuj3INxyE4n4XuJ6aMDoA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1768375701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oZLC1OcX/4X/172DOOta5GPxHR7S1+1EA8wRTIuT8Os=; b=2HtSlf6uMwJwxNTkRZHj5p0Xc6SIrnGv/15OPCbc4geYRpmVvEz5rej/ZfvRhkuGz3EDyn IUoBivPpzN8aHfCg== Date: Wed, 14 Jan 2026 08:28:13 +0100 Subject: [PATCH v3 1/5] ARC: Always use SWAPE instructions for __arch_swab32() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260114-headers_install-config-leak-v3-1-c14cde735a79@linutronix.de> References: <20260114-headers_install-config-leak-v3-0-c14cde735a79@linutronix.de> In-Reply-To: <20260114-headers_install-config-leak-v3-0-c14cde735a79@linutronix.de> To: Vineet Gupta , Russell King , Dinh Nguyen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Arnd Bergmann , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1768375700; l=5361; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=ZkCW0y1qBYlQUwt7ET0wm5t9Ac/g46X+vbejvWmozno=; b=zna2F7uRhB71MyLnmHI5GDtU7owNIO4QC4K/Uj4j+HFbF5p4uH8gQYMJYvRLgD5u84t49BB48 ukxcz+nCTP3Ad2NStdUDxlfZL/qHPqWJ3avcy8B0088w88C/Zs5i+bV X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Since commit 67a697e7576 ("ARC: retire ARC750 support") all supported CPUs have the 'swape' instruction. Always use the implementation of __arch_swabe() which uses 'swape'. ARCH_USE_BUILTIN_BSWAP can not be used as that results on libcalls on -mcpu=3Darc700. As as side-effect, remove a leak of an internal kconfig symbol through the UAPI headers. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/lkml/0ae2688a-5a22-405b-adaf-9b5ad712b245@app= .fastmail.com/ Suggested-by: Vineet Gupta Link: https://lore.kernel.org/lkml/a033a402-e3c5-4982-9fff-b6a4c55817ae@ker= nel.org/ Signed-off-by: Thomas Wei=C3=9Fschuh --- arch/arc/Kconfig | 5 ---- arch/arc/Makefile | 3 +- arch/arc/include/uapi/asm/swab.h | 63 ------------------------------------= ---- scripts/headers_install.sh | 1 - 4 files changed, 1 insertion(+), 71 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index f27e6b90428e..2ed7186c81c5 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -121,7 +121,6 @@ choice config ARC_CPU_770 bool "ARC770" depends on ISA_ARCOMPACT - select ARC_HAS_SWAPE help Support for ARC770 core introduced with Rel 4.10 (Summer 2011) This core has a bunch of cool new features: @@ -340,10 +339,6 @@ config ARC_HAS_LLSC default y depends on !ARC_CANT_LLSC =20 -config ARC_HAS_SWAPE - bool "Insn: SWAPE (endian-swap)" - default y - if ISA_ARCV2 =20 config ARC_USE_UNALIGNED_MEM_ACCESS diff --git a/arch/arc/Makefile b/arch/arc/Makefile index 0c5e6e6314f2..868805ffcfea 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -9,7 +9,7 @@ ifeq ($(CROSS_COMPILE),) CROSS_COMPILE :=3D $(call cc-cross-prefix, arc-linux- arceb-linux- arc-lin= ux-gnu-) endif =20 -cflags-y +=3D -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__ +cflags-y +=3D -fno-common -pipe -fno-builtin -mmedium-calls -mswape -D__li= nux__ =20 tune-mcpu-def-$(CONFIG_ISA_ARCOMPACT) :=3D -mcpu=3Darc700 tune-mcpu-def-$(CONFIG_ISA_ARCV2) :=3D -mcpu=3Dhs38 @@ -41,7 +41,6 @@ endif cflags-y +=3D -fsection-anchors =20 cflags-$(CONFIG_ARC_HAS_LLSC) +=3D -mlock -cflags-$(CONFIG_ARC_HAS_SWAPE) +=3D -mswape =20 ifdef CONFIG_ISA_ARCV2 =20 diff --git a/arch/arc/include/uapi/asm/swab.h b/arch/arc/include/uapi/asm/s= wab.h index 8d1f1ef44ba7..417ea30f29f5 100644 --- a/arch/arc/include/uapi/asm/swab.h +++ b/arch/arc/include/uapi/asm/swab.h @@ -19,9 +19,6 @@ =20 #include =20 -/* Native single cycle endian swap insn */ -#ifdef CONFIG_ARC_HAS_SWAPE - #define __arch_swab32(x) \ ({ \ unsigned int tmp =3D x; \ @@ -32,66 +29,6 @@ tmp; \ }) =20 -#else - -/* Several ways of Endian-Swap Emulation for ARC - * 0: kernel generic - * 1: ARC optimised "C" - * 2: ARC Custom instruction - */ -#define ARC_BSWAP_TYPE 1 - -#if (ARC_BSWAP_TYPE =3D=3D 1) /******* Software only ********/ - -/* The kernel default implementation of htonl is - * return x<<24 | x>>24 | - * (x & (__u32)0x0000ff00UL)<<8 | (x & (__u32)0x00ff0000UL)>>8; - * - * This generates 9 instructions on ARC (excluding the ld/st) - * - * 8051fd8c: ld r3,[r7,20] ; Mem op : Get the value to be swapped - * 8051fd98: asl r5,r3,24 ; get 3rd Byte - * 8051fd9c: lsr r2,r3,24 ; get 0th Byte - * 8051fda0: and r4,r3,0xff00 - * 8051fda8: asl r4,r4,8 ; get 1st Byte - * 8051fdac: and r3,r3,0x00ff0000 - * 8051fdb4: or r2,r2,r5 ; combine 0th and 3rd Bytes - * 8051fdb8: lsr r3,r3,8 ; 2nd Byte at correct place in Dst Reg - * 8051fdbc: or r2,r2,r4 ; combine 0,3 Bytes with 1st Byte - * 8051fdc0: or r2,r2,r3 ; combine 0,3,1 Bytes with 2nd Byte - * 8051fdc4: st r2,[r1,20] ; Mem op : save result back to mem - * - * Joern suggested a better "C" algorithm which is great since - * (1) It is portable to any architecture - * (2) At the same time it takes advantage of ARC ISA (rotate intrns) - */ - -#define __arch_swab32(x) \ -({ unsigned long __in =3D (x), __tmp; \ - __tmp =3D __in << 8 | __in >> 24; /* ror tmp,in,24 */ \ - __in =3D __in << 24 | __in >> 8; /* ror in,in,8 */ \ - __tmp ^=3D __in; \ - __tmp &=3D 0xff00ff; \ - __tmp ^ __in; \ -}) - -#elif (ARC_BSWAP_TYPE =3D=3D 2) /* Custom single cycle bswap instruction */ - -#define __arch_swab32(x) \ -({ \ - unsigned int tmp =3D x; \ - __asm__( \ - " .extInstruction bswap, 7, 0x00, SUFFIX_NONE, SYNTAX_2OP \n"\ - " bswap %0, %1 \n"\ - : "=3Dr" (tmp) \ - : "r" (tmp)); \ - tmp; \ -}) - -#endif /* ARC_BSWAP_TYPE=3Dzzz */ - -#endif /* CONFIG_ARC_HAS_SWAPE */ - #if !defined(__STRICT_ANSI__) || defined(__KERNEL__) #define __SWAB_64_THRU_32__ #endif diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh index 0e4e939efc94..727f7f82c2c7 100755 --- a/scripts/headers_install.sh +++ b/scripts/headers_install.sh @@ -70,7 +70,6 @@ configs=3D$(sed -e ' # # The format is : in each line. config_leak_ignores=3D" -arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8 arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT --=20 2.52.0