From: Sven Schnelle <svens@linux.ibm.com>
To: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org,
linux-s390@vger.kernel.org
Subject: Re: [PATCH] bug: Use normal relative pointers in 'struct bug_entry'
Date: Fri, 06 May 2022 11:17:35 +0200 [thread overview]
Message-ID: <yt9d35hnj9zk.fsf@linux.ibm.com> (raw)
In-Reply-To: <afddb4548e93f6458ec1d9ec185a834c348eda33.1651798983.git.jpoimboe@kernel.org> (Josh Poimboeuf's message of "Thu, 5 May 2022 18:09:45 -0700")
Josh Poimboeuf <jpoimboe@kernel.org> writes:
> With CONFIG_GENERIC_BUG_RELATIVE_POINTERS, the addr/file relative
> pointers are calculated weirdly: based on the beginning of the bug_entry
> struct address, rather than their respective pointer addresses.
>
> Make the relative pointers less surprising to both humans and tools by
> calculating them the normal way.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Acked-by: Sven Schnelle <svens@linux.ibm.com> # s390
> ---
> arch/arm64/include/asm/asm-bug.h | 4 ++--
> arch/powerpc/include/asm/bug.h | 5 +++--
> arch/riscv/include/asm/bug.h | 4 ++--
> arch/s390/include/asm/bug.h | 5 +++--
> arch/x86/include/asm/bug.h | 2 +-
> lib/bug.c | 15 +++++++--------
> 6 files changed, 18 insertions(+), 17 deletions(-)
>
> diff --git a/arch/arm64/include/asm/asm-bug.h b/arch/arm64/include/asm/asm-bug.h
> index 03f52f84a4f3..c762038ba400 100644
> --- a/arch/arm64/include/asm/asm-bug.h
> +++ b/arch/arm64/include/asm/asm-bug.h
> @@ -14,7 +14,7 @@
> 14472: .string file; \
> .popsection; \
> \
> - .long 14472b - 14470b; \
> + .long 14472b - .; \
> .short line;
> #else
> #define _BUGVERBOSE_LOCATION(file, line)
> @@ -25,7 +25,7 @@
> #define __BUG_ENTRY(flags) \
> .pushsection __bug_table,"aw"; \
> .align 2; \
> - 14470: .long 14471f - 14470b; \
> + 14470: .long 14471f - .; \
> _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \
> .short flags; \
> .popsection; \
> diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
> index ecbae1832de3..76252576d889 100644
> --- a/arch/powerpc/include/asm/bug.h
> +++ b/arch/powerpc/include/asm/bug.h
> @@ -13,7 +13,8 @@
> #ifdef CONFIG_DEBUG_BUGVERBOSE
> .macro __EMIT_BUG_ENTRY addr,file,line,flags
> .section __bug_table,"aw"
> -5001: .4byte \addr - 5001b, 5002f - 5001b
> +5001: .4byte \addr - .
> + .4byte 5002f - .
> .short \line, \flags
> .org 5001b+BUG_ENTRY_SIZE
> .previous
> @@ -24,7 +25,7 @@
> #else
> .macro __EMIT_BUG_ENTRY addr,file,line,flags
> .section __bug_table,"aw"
> -5001: .4byte \addr - 5001b
> +5001: .4byte \addr - .
> .short \flags
> .org 5001b+BUG_ENTRY_SIZE
> .previous
> diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h
> index d3804a2f9aad..1aaea81fb141 100644
> --- a/arch/riscv/include/asm/bug.h
> +++ b/arch/riscv/include/asm/bug.h
> @@ -30,8 +30,8 @@
> typedef u32 bug_insn_t;
>
> #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
> -#define __BUG_ENTRY_ADDR RISCV_INT " 1b - 2b"
> -#define __BUG_ENTRY_FILE RISCV_INT " %0 - 2b"
> +#define __BUG_ENTRY_ADDR RISCV_INT " 1b - ."
> +#define __BUG_ENTRY_FILE RISCV_INT " %0 - ."
> #else
> #define __BUG_ENTRY_ADDR RISCV_PTR " 1b"
> #define __BUG_ENTRY_FILE RISCV_PTR " %0"
> diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h
> index 0b25f28351ed..aebe1e22c7be 100644
> --- a/arch/s390/include/asm/bug.h
> +++ b/arch/s390/include/asm/bug.h
> @@ -15,7 +15,8 @@
> "1: .asciz \""__FILE__"\"\n" \
> ".previous\n" \
> ".section __bug_table,\"awM\",@progbits,%2\n" \
> - "2: .long 0b-2b,1b-2b\n" \
> + "2: .long 0b-.\n" \
> + " .long 1b-.\n" \
> " .short %0,%1\n" \
> " .org 2b+%2\n" \
> ".previous\n" \
> @@ -30,7 +31,7 @@
> asm_inline volatile( \
> "0: mc 0,0\n" \
> ".section __bug_table,\"awM\",@progbits,%1\n" \
> - "1: .long 0b-1b\n" \
> + "1: .long 0b-.\n" \
> " .short %0\n" \
> " .org 1b+%1\n" \
> ".previous\n" \
> diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
> index aaf0cb0db4ae..a3ec87d198ac 100644
> --- a/arch/x86/include/asm/bug.h
> +++ b/arch/x86/include/asm/bug.h
> @@ -18,7 +18,7 @@
> #ifdef CONFIG_X86_32
> # define __BUG_REL(val) ".long " __stringify(val)
> #else
> -# define __BUG_REL(val) ".long " __stringify(val) " - 2b"
> +# define __BUG_REL(val) ".long " __stringify(val) " - ."
> #endif
>
> #ifdef CONFIG_DEBUG_BUGVERBOSE
> diff --git a/lib/bug.c b/lib/bug.c
> index 45a0584f6541..c223a2575b72 100644
> --- a/lib/bug.c
> +++ b/lib/bug.c
> @@ -6,8 +6,7 @@
>
> CONFIG_BUG - emit BUG traps. Nothing happens without this.
> CONFIG_GENERIC_BUG - enable this code.
> - CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit pointers relative to
> - the containing struct bug_entry for bug_addr and file.
> + CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit relative pointers for bug_addr and file
> CONFIG_DEBUG_BUGVERBOSE - emit full file+line information for each BUG
>
> CONFIG_BUG and CONFIG_DEBUG_BUGVERBOSE are potentially user-settable
> @@ -53,10 +52,10 @@ extern struct bug_entry __start___bug_table[], __stop___bug_table[];
>
> static inline unsigned long bug_addr(const struct bug_entry *bug)
> {
> -#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
> - return bug->bug_addr;
> +#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
> + return (unsigned long)&bug->bug_addr_disp + bug->bug_addr_disp;
> #else
> - return (unsigned long)bug + bug->bug_addr_disp;
> + return bug->bug_addr;
> #endif
> }
>
> @@ -131,10 +130,10 @@ void bug_get_file_line(struct bug_entry *bug, const char **file,
> unsigned int *line)
> {
> #ifdef CONFIG_DEBUG_BUGVERBOSE
> -#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
> - *file = bug->file;
> +#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
> + *file = (const char *)&bug->file_disp + bug->file_disp;
> #else
> - *file = (const char *)bug + bug->file_disp;
> + *file = bug->file;
> #endif
> *line = bug->line;
> #else
next prev parent reply other threads:[~2022-05-06 9:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-06 1:09 [PATCH] bug: Use normal relative pointers in 'struct bug_entry' Josh Poimboeuf
2022-05-06 7:45 ` Peter Zijlstra
2022-05-06 9:17 ` Sven Schnelle [this message]
2022-05-06 10:40 ` Mark Rutland
2022-05-09 12:31 ` Michael Ellerman
2022-05-09 19:20 ` Josh Poimboeuf
2022-05-10 10:38 ` Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yt9d35hnj9zk.fsf@linux.ibm.com \
--to=svens@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=aou@eecs.berkeley.edu \
--cc=benh@kernel.crashing.org \
--cc=borntraeger@linux.ibm.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=jpoimboe@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).