diff mbox series

[8/8] parisc: Reduce size of __bug_table[] on 64-bit kernel by half

Message ID 20231124144158.158993-16-deller@kernel.org (mailing list archive)
State Accepted, archived
Headers show
Series parisc patch queue | expand

Commit Message

Helge Deller Nov. 24, 2023, 2:41 p.m. UTC
From: Helge Deller <deller@gmx.de>

Enable GENERIC_BUG_RELATIVE_POINTERS which will store 32-bit relative
offsets to the bug address and the source file name instead of 64-bit
absolute addresses. This effectively reduces the size of the
__bug_table[] array by half on 64-bit kernels.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/Kconfig           |  7 +++++--
 arch/parisc/include/asm/bug.h | 34 +++++++++++++++++-----------------
 2 files changed, 22 insertions(+), 19 deletions(-)

Comments

Guenter Roeck Nov. 30, 2023, 5:30 p.m. UTC | #1
On Fri, Nov 24, 2023 at 03:41:13PM +0100, deller@kernel.org wrote:
> From: Helge Deller <deller@gmx.de>
> 
> Enable GENERIC_BUG_RELATIVE_POINTERS which will store 32-bit relative
> offsets to the bug address and the source file name instead of 64-bit
> absolute addresses. This effectively reduces the size of the
> __bug_table[] array by half on 64-bit kernels.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>

With this patch in mainline, parisc:tinyconfig fails to build.

ecurity/commoncap.c: In function 'cap_capset':
arch/parisc/include/asm/bug.h:71:17: error: invalid 'asm': operand number out of range
   71 |                 asm volatile("\n"                                       \
      |                 ^~~

and many similar errors. Bisect log attached.

Guenter

---
# bad: [3b47bc037bd44f142ac09848e8d3ecccc726be99] Merge tag 'pinctrl-v6.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl
# good: [98b1cc82c4affc16f5598d4fa14b1858671b2263] Linux 6.7-rc2
git bisect start 'HEAD' 'v6.7-rc2'
# good: [f1a09972a45ae63efbd1587337c4be13b1893330] Merge tag 'ata-6.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata
git bisect good f1a09972a45ae63efbd1587337c4be13b1893330
# good: [090472ed9c922e699dc61dd601a9b376a64f4390] Merge tag 'usb-6.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
git bisect good 090472ed9c922e699dc61dd601a9b376a64f4390
# bad: [2cc14f52aeb78ce3f29677c2de1f06c0e91471ab] Linux 6.7-rc3
git bisect bad 2cc14f52aeb78ce3f29677c2de1f06c0e91471ab
# good: [4892711acee0915a8a4ae02e1af3dc70ce000024] Merge tag 'x86-urgent-2023-11-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
git bisect good 4892711acee0915a8a4ae02e1af3dc70ce000024
# bad: [43266838515d30dc0c45d5c7e6e7edacee6cce92] parisc: Reduce size of the bug_table on 64-bit kernel by half
git bisect bad 43266838515d30dc0c45d5c7e6e7edacee6cce92
# good: [07eecff8ae78df7f28800484d31337e1f9bfca3a] parisc: Mark jump_table naturally aligned
git bisect good 07eecff8ae78df7f28800484d31337e1f9bfca3a
# good: [c9fcb2b65c2849e8ff3be23fd8828312fb68dc19] parisc: Ensure 32-bit alignment on parisc unwind section
git bisect good c9fcb2b65c2849e8ff3be23fd8828312fb68dc19
# good: [e5f3e299a2b1e9c3ece24a38adfc089aef307e8a] parisc: Drop the HP-UX ENOSYM and EREMOTERELEASE error codes
git bisect good e5f3e299a2b1e9c3ece24a38adfc089aef307e8a
# first bad commit: [43266838515d30dc0c45d5c7e6e7edacee6cce92] parisc: Reduce size of the bug_table on 64-bit kernel by half
Helge Deller Nov. 30, 2023, 7 p.m. UTC | #2
On 11/30/23 18:30, Guenter Roeck wrote:
> On Fri, Nov 24, 2023 at 03:41:13PM +0100, deller@kernel.org wrote:
>> From: Helge Deller <deller@gmx.de>
>>
>> Enable GENERIC_BUG_RELATIVE_POINTERS which will store 32-bit relative
>> offsets to the bug address and the source file name instead of 64-bit
>> absolute addresses. This effectively reduces the size of the
>> __bug_table[] array by half on 64-bit kernels.
>>
>> Signed-off-by: Helge Deller <deller@gmx.de>
>
> With this patch in mainline, parisc:tinyconfig fails to build.
>
> ecurity/commoncap.c: In function 'cap_capset':
> arch/parisc/include/asm/bug.h:71:17: error: invalid 'asm': operand number out of range
>     71 |                 asm volatile("\n"                                       \
>        |                 ^~~
>
> and many similar errors. Bisect log attached.

Yes, problem was reported already and fix is in my for-next git tree:

https://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux.git/commit/?h=for-next&id=487635756198cad563feb47539c6a37ea57f1dae

Thanks!
Helge
diff mbox series

Patch

diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index a7c9c0e69e5a..d14ccc948a29 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -115,9 +115,12 @@  config ARCH_HAS_ILOG2_U64
 	default n
 
 config GENERIC_BUG
-	bool
-	default y
+	def_bool y
 	depends on BUG
+	select GENERIC_BUG_RELATIVE_POINTERS if 64BIT
+
+config GENERIC_BUG_RELATIVE_POINTERS
+	bool
 
 config GENERIC_HWEIGHT
 	bool
diff --git a/arch/parisc/include/asm/bug.h b/arch/parisc/include/asm/bug.h
index b9cad0bb4461..1641ff9a8b83 100644
--- a/arch/parisc/include/asm/bug.h
+++ b/arch/parisc/include/asm/bug.h
@@ -17,26 +17,27 @@ 
 #define	PARISC_BUG_BREAK_ASM	"break 0x1f, 0x1fff"
 #define	PARISC_BUG_BREAK_INSN	0x03ffe01f  /* PARISC_BUG_BREAK_ASM */
 
-#if defined(CONFIG_64BIT)
-#define ASM_WORD_INSN		".dword\t"
+#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
+# define __BUG_REL(val) ".word " __stringify(val) " - ."
 #else
-#define ASM_WORD_INSN		".word\t"
+# define __BUG_REL(val) ".word " __stringify(val)
 #endif
 
+
 #ifdef CONFIG_DEBUG_BUGVERBOSE
 #define BUG()								\
 	do {								\
 		asm volatile("\n"					\
 			     "1:\t" PARISC_BUG_BREAK_ASM "\n"		\
 			     "\t.pushsection __bug_table,\"a\"\n"	\
-			     "\t.align %4\n"				\
-			     "2:\t" ASM_WORD_INSN "1b, %c0\n"		\
+			     "\t.align 4\n"				\
+			     "2:\t" __BUG_REL(1b) "\n"			\
+			     "\t" __BUG_REL(%c0)  "\n"			\
 			     "\t.short %1, %2\n"			\
-			     "\t.blockz %3-2*%4-2*2\n"			\
+			     "\t.blockz %3-2*4-2*2\n"			\
 			     "\t.popsection"				\
 			     : : "i" (__FILE__), "i" (__LINE__),	\
-			     "i" (0), "i" (sizeof(struct bug_entry)),	\
-			     "i" (sizeof(long)) );			\
+			     "i" (0), "i" (sizeof(struct bug_entry)) );	\
 		unreachable();						\
 	} while(0)
 
@@ -54,15 +55,15 @@ 
 		asm volatile("\n"					\
 			     "1:\t" PARISC_BUG_BREAK_ASM "\n"		\
 			     "\t.pushsection __bug_table,\"a\"\n"	\
-			     "\t.align %4\n"				\
-			     "2:\t" ASM_WORD_INSN "1b, %c0\n"		\
+			     "\t.align 4\n"				\
+			     "2:\t" __BUG_REL(1b) "\n"			\
+			     "\t" __BUG_REL(%c0)  "\n"			\
 			     "\t.short %1, %2\n"			\
-			     "\t.blockz %3-2*%4-2*2\n"			\
+			     "\t.blockz %3-2*4-2*2\n"			\
 			     "\t.popsection"				\
 			     : : "i" (__FILE__), "i" (__LINE__),	\
 			     "i" (BUGFLAG_WARNING|(flags)),		\
-			     "i" (sizeof(struct bug_entry)),		\
-			     "i" (sizeof(long)) );			\
+			     "i" (sizeof(struct bug_entry)) );		\
 	} while(0)
 #else
 #define __WARN_FLAGS(flags)						\
@@ -71,13 +72,12 @@ 
 			     "1:\t" PARISC_BUG_BREAK_ASM "\n"		\
 			     "\t.pushsection __bug_table,\"a\"\n"	\
 			     "\t.align %2\n"				\
-			     "2:\t" ASM_WORD_INSN "1b\n"		\
+			     "2:\t" __BUG_REL(1b) "\n"			\
 			     "\t.short %0\n"				\
-			     "\t.blockz %1-%2-2\n"			\
+			     "\t.blockz %1-4-2\n"			\
 			     "\t.popsection"				\
 			     : : "i" (BUGFLAG_WARNING|(flags)),		\
-			     "i" (sizeof(struct bug_entry)),		\
-			     "i" (sizeof(long)) );			\
+			     "i" (sizeof(struct bug_entry)) );		\
 	} while(0)
 #endif