From: Guenter Roeck <linux@roeck-us.net>
To: linux-kselftest@vger.kernel.org
Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org,
dri-devel@lists.freedesktop.org,
"Brendan Higgins" <brendan.higgins@linux.dev>,
linux-riscv@lists.infradead.org,
"David Airlie" <airlied@gmail.com>,
"Arthur Grillo" <arthurgrillo@riseup.net>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
"Daniel Diaz" <daniel.diaz@linaro.org>,
linux-sh@vger.kernel.org,
"Naresh Kamboju" <naresh.kamboju@linaro.org>,
"Maíra Canal" <mcanal@igalia.com>,
"Dan Carpenter" <dan.carpenter@linaro.org>,
"Guenter Roeck" <linux@roeck-us.net>,
netdev@lists.linux.dev, "Kees Cook" <keescook@chromium.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"David Gow" <davidgow@google.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com,
linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
"Thomas Zimmerman n" <tzimmermann@suse.de>,
"Andrew Morton" <akpm@linux-foundation.org>,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 14/14] powerpc: Add support for suppressing warning backtraces
Date: Tue, 12 Mar 2024 10:03:09 -0700 [thread overview]
Message-ID: <20240312170309.2546362-15-linux@roeck-us.net> (raw)
In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net>
Add name of functions triggering warning backtraces to the __bug_table
object section to enable support for suppressing WARNING backtraces.
To limit image size impact, the pointer to the function name is only added
to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE
are enabled. Otherwise, the __func__ assembly parameter is replaced with a
(dummy) NULL parameter to avoid an image size increase due to unused
__func__ entries (this is necessary because __func__ is not a define but a
virtual variable).
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
arch/powerpc/include/asm/bug.h | 37 +++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
index 1db485aacbd9..330d4983f90e 100644
--- a/arch/powerpc/include/asm/bug.h
+++ b/arch/powerpc/include/asm/bug.h
@@ -14,6 +14,9 @@
.section __bug_table,"aw"
5001: .4byte \addr - .
.4byte 5002f - .
+#if IS_ENABLED(CONFIG_KUNIT)
+ .4byte 0
+#endif
.short \line, \flags
.org 5001b+BUG_ENTRY_SIZE
.previous
@@ -32,30 +35,46 @@
#endif /* verbose */
#else /* !__ASSEMBLY__ */
-/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and
- sizeof(struct bug_entry), respectively */
+/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3,%4 to be FILE, __func__, LINE, flags
+ and sizeof(struct bug_entry), respectively */
#ifdef CONFIG_DEBUG_BUGVERBOSE
+
+#if IS_ENABLED(CONFIG_KUNIT)
+# define HAVE_BUG_FUNCTION
+# define __BUG_FUNC_PTR " .4byte %1 - .\n"
+#else
+# define __BUG_FUNC_PTR
+#endif /* IS_ENABLED(CONFIG_KUNIT) */
+
#define _EMIT_BUG_ENTRY \
".section __bug_table,\"aw\"\n" \
"2: .4byte 1b - .\n" \
" .4byte %0 - .\n" \
- " .short %1, %2\n" \
- ".org 2b+%3\n" \
+ __BUG_FUNC_PTR \
+ " .short %2, %3\n" \
+ ".org 2b+%4\n" \
".previous\n"
#else
#define _EMIT_BUG_ENTRY \
".section __bug_table,\"aw\"\n" \
"2: .4byte 1b - .\n" \
- " .short %2\n" \
- ".org 2b+%3\n" \
+ " .short %3\n" \
+ ".org 2b+%4\n" \
".previous\n"
#endif
+#ifdef HAVE_BUG_FUNCTION
+# define __BUG_FUNC __func__
+#else
+# define __BUG_FUNC NULL
+#endif
+
#define BUG_ENTRY(insn, flags, ...) \
__asm__ __volatile__( \
"1: " insn "\n" \
_EMIT_BUG_ENTRY \
- : : "i" (__FILE__), "i" (__LINE__), \
+ : : "i" (__FILE__), "i" (__BUG_FUNC), \
+ "i" (__LINE__), \
"i" (flags), \
"i" (sizeof(struct bug_entry)), \
##__VA_ARGS__)
@@ -80,7 +99,7 @@
if (x) \
BUG(); \
} else { \
- BUG_ENTRY(PPC_TLNEI " %4, 0", 0, "r" ((__force long)(x))); \
+ BUG_ENTRY(PPC_TLNEI " %5, 0", 0, "r" ((__force long)(x))); \
} \
} while (0)
@@ -90,7 +109,7 @@
if (__ret_warn_on) \
__WARN(); \
} else { \
- BUG_ENTRY(PPC_TLNEI " %4, 0", \
+ BUG_ENTRY(PPC_TLNEI " %5, 0", \
BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \
"r" (__ret_warn_on)); \
} \
--
2.39.2
next prev parent reply other threads:[~2024-03-12 17:14 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 17:02 [PATCH 00/14] Add support for suppressing warning backtraces Guenter Roeck
2024-03-12 17:02 ` [PATCH 01/14] bug/kunit: Core " Guenter Roeck
2024-03-12 22:00 ` Kees Cook
2024-03-12 17:02 ` [PATCH 02/14] kunit: bug: Count suppressed " Guenter Roeck
2024-03-12 22:02 ` Kees Cook
2024-03-12 17:02 ` [PATCH 03/14] kunit: Add test cases for backtrace warning suppression Guenter Roeck
2024-03-12 22:02 ` Kees Cook
2024-03-12 17:02 ` [PATCH 04/14] kunit: Add documentation for warning backtrace suppression API Guenter Roeck
2024-03-12 22:03 ` Kees Cook
2024-03-12 17:03 ` [PATCH 05/14] drm: Suppress intentional warning backtraces in scaling unit tests Guenter Roeck
2024-03-12 17:03 ` [PATCH 06/14] net: kunit: Suppress lock warning noise at end of dev_addr_lists tests Guenter Roeck
2024-03-12 17:03 ` [PATCH 07/14] x86: Add support for suppressing warning backtraces Guenter Roeck
2024-03-12 17:03 ` [PATCH 08/14] arm64: " Guenter Roeck
2024-03-12 17:03 ` [PATCH 09/14] loongarch: " Guenter Roeck
2024-03-12 17:03 ` [PATCH 10/14] parisc: " Guenter Roeck
2024-03-15 11:45 ` Helge Deller
2024-03-12 17:03 ` [PATCH 11/14] s390: " Guenter Roeck
2024-03-14 7:57 ` Geert Uytterhoeven
2024-03-14 13:54 ` Guenter Roeck
2024-03-12 17:03 ` [PATCH 12/14] sh: " Guenter Roeck
2024-03-12 17:03 ` [PATCH 13/14] riscv: " Guenter Roeck
2024-03-12 17:03 ` Guenter Roeck [this message]
2024-03-13 7:39 ` [PATCH 00/14] " Dan Carpenter
2024-03-14 7:19 ` Naresh Kamboju
2024-03-14 13:36 ` Geert Uytterhoeven
2024-03-14 14:37 ` Guenter Roeck
2024-03-14 15:02 ` Maxime Ripard
2024-03-14 15:29 ` Guenter Roeck
2024-03-16 16:16 ` Guenter Roeck
2024-03-18 3:24 ` Michael Ellerman
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=20240312170309.2546362-15-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=arthurgrillo@riseup.net \
--cc=brendan.higgins@linux.dev \
--cc=dan.carpenter@linaro.org \
--cc=daniel.diaz@linaro.org \
--cc=daniel@ffwll.ch \
--cc=davidgow@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=keescook@chromium.org \
--cc=kunit-dev@googlegroups.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=loongarch@lists.linux.dev \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mcanal@igalia.com \
--cc=mripard@kernel.org \
--cc=naresh.kamboju@linaro.org \
--cc=netdev@lists.linux.dev \
--cc=tzimmermann@suse.de \
--cc=ville.syrjala@linux.intel.com \
/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).