From patchwork Tue Mar 12 17:02:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911239 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=N6U6uQWf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKk93qf9z23qn for ; Wed, 13 Mar 2024 04:04:17 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=N6U6uQWf; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKk92kRhz3vX8 for ; Wed, 13 Mar 2024 04:04:17 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=N6U6uQWf; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::62e; helo=mail-pl1-x62e.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKj46MNbz3d2m for ; Wed, 13 Mar 2024 04:03:19 +1100 (AEDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1dd5df90170so515995ad.0 for ; Tue, 12 Mar 2024 10:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710262996; x=1710867796; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Of8hHWisNxYysvbPB0I6Y4GqENZSkz1n2sIkdEVr+kQ=; b=N6U6uQWflIzVlIR8bMwcGU9ptj9UxxgCXeQGsOsv2WwF5c012qYU+F/cxYkDO5/MiK RS18PXOSdL3lWfFGnNObOFLIyjogDAGiy9iXO1Rsf4K07WboukgzbXv/v+gdf2iFOjd0 GmaVh+FGw6j8E3tsMZ/JzX4sNGMrosqIYUpFuKoptiDba5e5QS/ywk27Geqcny+aV6bq dR4+nXmoDrItWo5ylcmOphrj4aZg159N22o9D6nkfDFwata6w0DujMp+hQjSjLNzMpzS 2r1fGhcZqA69k+d1U+iIa6O1Oru10bXiFqqhN/LCjEjgfyrkygBpu0Ub6ml4RiGglKdE KSNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710262996; x=1710867796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Of8hHWisNxYysvbPB0I6Y4GqENZSkz1n2sIkdEVr+kQ=; b=R11+jK9Q1Kcwh50pJ9jire44DT0h2jIy1dECdGjst/UBGKvqe9GI5TCa6w4ha91kse vOUKcU683BKd0Olxh9i/uuf64Gk63xASVEQOAjSm2xj7PVIUuza4EkxxUujIMdeN8JBI 5PatuuNmH1LSXDtDxrVwORq1+JiKZXtVQKfSEQ1IEWLvb5DB2X2MieIc2uuGQJQjFXk2 WzH1UFGJZmglqHpWGdQ+9GsUnclwKkS7LTupZEoK5zPN+Y9/K4yRdJTl42asdMf9iBOf jhni8yyL996zlbI26PAbg1C645228OAZCcY6FzjWCtWLwI8QsmB23Vj7P1jHUHfqSP9n idYw== X-Forwarded-Encrypted: i=1; AJvYcCV6V+v/LuB0YhhYj4S8ZmYrHPhxloXBMbxapW9NeVuUIGoGjOCk9Mk3j0pJrO1cuLnfeM6mRWiIHxb5eb6qFXor2y171rCyVtJfbjl97Q== X-Gm-Message-State: AOJu0YylGR/IdQiX2kI1pqOhEEHjK+ka1IXtidprdl1Spzzmkbd8w05a Me0imtKPoIACpJ0ml9s3CT2xuvjaR+AzAdLQjnOSznQQWZqAbAVWnGzXRTre X-Google-Smtp-Source: AGHT+IE/Isr4cUsadh0SsOhn7mx4Gox6shabBQwnzVwQlzBf1DTIw8GWGf1C7I1mI94rK1/gQQW32g== X-Received: by 2002:a17:903:947:b0:1dd:a616:8205 with SMTP id ma7-20020a170903094700b001dda6168205mr110005plb.34.1710262996297; Tue, 12 Mar 2024 10:03:16 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id s5-20020a170902ea0500b001dcfc8a5fafsm6970018plg.96.2024.03.12.10.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:15 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 01/14] bug/kunit: Core support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:02:56 -0700 Message-Id: <20240312170309.2546362-2-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Some unit tests intentionally trigger warning backtraces by passing bad parameters to API functions. Such unit tests typically check the return value from those calls, not the existence of the warning backtrace. Such intentionally generated warning backtraces are neither desirable nor useful for a number of reasons. - They can result in overlooked real problems. - A warning that suddenly starts to show up in unit tests needs to be investigated and has to be marked to be ignored, for example by adjusting filter scripts. Such filters are ad-hoc because there is no real standard format for warnings. On top of that, such filter scripts would require constant maintenance. One option to address problem would be to add messages such as "expected warning backtraces start / end here" to the kernel log. However, that would again require filter scripts, it might result in missing real problematic warning backtraces triggered while the test is running, and the irrelevant backtrace(s) would still clog the kernel log. Solve the problem by providing a means to identify and suppress specific warning backtraces while executing test code. Cc: Dan Carpenter Cc: Daniel Diaz Cc: Naresh Kamboju Cc: Kees Cook Signed-off-by: Guenter Roeck Reviewed-by: Kees Cook --- include/asm-generic/bug.h | 16 +++++++++--- include/kunit/bug.h | 51 +++++++++++++++++++++++++++++++++++++++ include/kunit/test.h | 1 + include/linux/bug.h | 13 ++++++++++ lib/bug.c | 51 ++++++++++++++++++++++++++++++++++++--- lib/kunit/Makefile | 6 +++-- lib/kunit/bug.c | 40 ++++++++++++++++++++++++++++++ 7 files changed, 169 insertions(+), 9 deletions(-) create mode 100644 include/kunit/bug.h create mode 100644 lib/kunit/bug.c diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 6e794420bd39..c170b6477689 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -18,6 +18,7 @@ #endif #ifndef __ASSEMBLY__ +#include #include #include @@ -39,8 +40,14 @@ struct bug_entry { #ifdef CONFIG_DEBUG_BUGVERBOSE #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS const char *file; +#ifdef HAVE_BUG_FUNCTION + const char *function; +#endif #else signed int file_disp; +#ifdef HAVE_BUG_FUNCTION + signed int function_disp; +#endif #endif unsigned short line; #endif @@ -96,15 +103,18 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...); #define __WARN() __WARN_printf(TAINT_WARN, NULL) #define __WARN_printf(taint, arg...) do { \ instrumentation_begin(); \ - warn_slowpath_fmt(__FILE__, __LINE__, taint, arg); \ + if (!IS_SUPPRESSED_WARNING(__func__)) \ + warn_slowpath_fmt(__FILE__, __LINE__, taint, arg);\ instrumentation_end(); \ } while (0) #else #define __WARN() __WARN_FLAGS(BUGFLAG_TAINT(TAINT_WARN)) #define __WARN_printf(taint, arg...) do { \ instrumentation_begin(); \ - __warn_printk(arg); \ - __WARN_FLAGS(BUGFLAG_NO_CUT_HERE | BUGFLAG_TAINT(taint));\ + if (!IS_SUPPRESSED_WARNING(__func__)) { \ + __warn_printk(arg); \ + __WARN_FLAGS(BUGFLAG_NO_CUT_HERE | BUGFLAG_TAINT(taint));\ + } \ instrumentation_end(); \ } while (0) #define WARN_ON_ONCE(condition) ({ \ diff --git a/include/kunit/bug.h b/include/kunit/bug.h new file mode 100644 index 000000000000..1e34da961599 --- /dev/null +++ b/include/kunit/bug.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * KUnit helpers for backtrace suppression + * + * Copyright (c) 2024 Guenter Roeck + */ + +#ifndef _KUNIT_BUG_H +#define _KUNIT_BUG_H + +#ifndef __ASSEMBLY__ + +#include + +#if IS_ENABLED(CONFIG_KUNIT) + +#include +#include + +struct __suppressed_warning { + struct list_head node; + const char *function; +}; + +void __start_suppress_warning(struct __suppressed_warning *warning); +void __end_suppress_warning(struct __suppressed_warning *warning); +bool __is_suppressed_warning(const char *function); + +#define DEFINE_SUPPRESSED_WARNING(func) \ + struct __suppressed_warning __kunit_suppress_##func = \ + { .function = __stringify(func) } + +#define START_SUPPRESSED_WARNING(func) \ + __start_suppress_warning(&__kunit_suppress_##func) + +#define END_SUPPRESSED_WARNING(func) \ + __end_suppress_warning(&__kunit_suppress_##func) + +#define IS_SUPPRESSED_WARNING(func) \ + __is_suppressed_warning(func) + +#else /* CONFIG_KUNIT */ + +#define DEFINE_SUPPRESSED_WARNING(func) +#define START_SUPPRESSED_WARNING(func) +#define END_SUPPRESSED_WARNING(func) +#define IS_SUPPRESSED_WARNING(func) (false) + +#endif /* CONFIG_KUNIT */ +#endif /* __ASSEMBLY__ */ +#endif /* _KUNIT_BUG_H */ diff --git a/include/kunit/test.h b/include/kunit/test.h index fcb4a4940ace..894c9fd1495d 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -10,6 +10,7 @@ #define _KUNIT_TEST_H #include +#include #include #include diff --git a/include/linux/bug.h b/include/linux/bug.h index 348acf2558f3..c668762dc76a 100644 --- a/include/linux/bug.h +++ b/include/linux/bug.h @@ -36,6 +36,9 @@ static inline int is_warning_bug(const struct bug_entry *bug) return bug->flags & BUGFLAG_WARNING; } +void bug_get_file_function_line(struct bug_entry *bug, const char **file, + const char **function, unsigned int *line); + void bug_get_file_line(struct bug_entry *bug, const char **file, unsigned int *line); @@ -62,6 +65,16 @@ static inline enum bug_trap_type report_bug(unsigned long bug_addr, } struct bug_entry; +static inline void bug_get_file_function_line(struct bug_entry *bug, + const char **file, + const char **function, + unsigned int *line) +{ + *file = NULL; + *function = NULL; + *line = 0; +} + static inline void bug_get_file_line(struct bug_entry *bug, const char **file, unsigned int *line) { diff --git a/lib/bug.c b/lib/bug.c index e0ff21989990..6b85d4042e07 100644 --- a/lib/bug.c +++ b/lib/bug.c @@ -26,6 +26,14 @@ when CONFIG_DEBUG_BUGVERBOSE is not enabled, so you must generate the values accordingly. + 2a.Optionally implement support for the "function" entry in struct + bug_entry. This entry must point to the name of the function triggering + the warning or bug trap (normally __func__). This is only needed if + both CONFIG_DEBUG_BUGVERBOSE and CONFIG_KUNIT are enabled and if + the architecture wants to implement support for suppressing warning + backtraces. The architecture must define HAVE_BUG_FUNCTION if it adds + pointers to function names to struct bug_entry. + 3. Implement the trap - In the illegal instruction trap handler (typically), verify that the fault was in kernel mode, and call report_bug() @@ -127,14 +135,21 @@ static inline struct bug_entry *module_find_bug(unsigned long bugaddr) } #endif -void bug_get_file_line(struct bug_entry *bug, const char **file, - unsigned int *line) +void bug_get_file_function_line(struct bug_entry *bug, const char **file, + const char **function, unsigned int *line) { + *function = NULL; #ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS *file = (const char *)&bug->file_disp + bug->file_disp; +#ifdef HAVE_BUG_FUNCTION + *function = (const char *)&bug->function_disp + bug->function_disp; +#endif #else *file = bug->file; +#ifdef HAVE_BUG_FUNCTION + *function = bug->function; +#endif #endif *line = bug->line; #else @@ -143,6 +158,13 @@ void bug_get_file_line(struct bug_entry *bug, const char **file, #endif } +void bug_get_file_line(struct bug_entry *bug, const char **file, unsigned int *line) +{ + const char *function; + + bug_get_file_function_line(bug, file, &function, line); +} + struct bug_entry *find_bug(unsigned long bugaddr) { struct bug_entry *bug; @@ -157,8 +179,9 @@ struct bug_entry *find_bug(unsigned long bugaddr) static enum bug_trap_type __report_bug(unsigned long bugaddr, struct pt_regs *regs) { struct bug_entry *bug; - const char *file; + const char *file, *function; unsigned line, warning, once, done; + char __maybe_unused sym[KSYM_SYMBOL_LEN]; if (!is_valid_bugaddr(bugaddr)) return BUG_TRAP_TYPE_NONE; @@ -169,12 +192,32 @@ static enum bug_trap_type __report_bug(unsigned long bugaddr, struct pt_regs *re disable_trace_on_warning(); - bug_get_file_line(bug, &file, &line); + bug_get_file_function_line(bug, &file, &function, &line); +#if IS_ENABLED(CONFIG_KUNIT) && defined(CONFIG_KALLSYMS) + if (!function) { + /* + * This will be seen if report_bug is called on an architecture + * with no architecture-specific support for suppressing warning + * backtraces, if CONFIG_DEBUG_BUGVERBOSE is not enabled, or if + * the calling code is from assembler which does not record a + * function name. Extracting the function name from the bug + * address is less than perfect since compiler optimization may + * result in 'bugaddr' pointing to a function which does not + * actually trigger the warning, but it is better than no + * suppression at all. + */ + sprint_symbol_no_offset(sym, bugaddr); + function = sym; + } +#endif /* IS_ENABLED(CONFIG_KUNIT) && defined(CONFIG_KALLSYMS) */ warning = (bug->flags & BUGFLAG_WARNING) != 0; once = (bug->flags & BUGFLAG_ONCE) != 0; done = (bug->flags & BUGFLAG_DONE) != 0; + if (warning && IS_SUPPRESSED_WARNING(function)) + return BUG_TRAP_TYPE_WARN; + if (warning && once) { if (done) return BUG_TRAP_TYPE_WARN; diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile index 309659a32a78..545b57c3be48 100644 --- a/lib/kunit/Makefile +++ b/lib/kunit/Makefile @@ -14,8 +14,10 @@ ifeq ($(CONFIG_KUNIT_DEBUGFS),y) kunit-objs += debugfs.o endif -# KUnit 'hooks' are built-in even when KUnit is built as a module. -obj-y += hooks.o +# KUnit 'hooks' and bug handling are built-in even when KUnit is built +# as a module. +obj-y += hooks.o \ + bug.o obj-$(CONFIG_KUNIT_TEST) += kunit-test.o diff --git a/lib/kunit/bug.c b/lib/kunit/bug.c new file mode 100644 index 000000000000..f93544d7a9d1 --- /dev/null +++ b/lib/kunit/bug.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * KUnit helpers for backtrace suppression + * + * Copyright (c) 2024 Guenter Roeck + */ + +#include +#include +#include +#include + +static LIST_HEAD(suppressed_warnings); + +void __start_suppress_warning(struct __suppressed_warning *warning) +{ + list_add(&warning->node, &suppressed_warnings); +} +EXPORT_SYMBOL_GPL(__start_suppress_warning); + +void __end_suppress_warning(struct __suppressed_warning *warning) +{ + list_del(&warning->node); +} +EXPORT_SYMBOL_GPL(__end_suppress_warning); + +bool __is_suppressed_warning(const char *function) +{ + struct __suppressed_warning *warning; + + if (!function) + return false; + + list_for_each_entry(warning, &suppressed_warnings, node) { + if (!strcmp(function, warning->function)) + return true; + } + return false; +} +EXPORT_SYMBOL_GPL(__is_suppressed_warning); From patchwork Tue Mar 12 17:02:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911245 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=K5hlEGxY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKky2kLXz1yWt for ; Wed, 13 Mar 2024 04:04:58 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=K5hlEGxY; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKky1D8Bz3vbw for ; Wed, 13 Mar 2024 04:04:58 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=K5hlEGxY; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::62d; helo=mail-pl1-x62d.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKj53bhVz3d2n for ; Wed, 13 Mar 2024 04:03:21 +1100 (AEDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1dd955753edso23090325ad.1 for ; Tue, 12 Mar 2024 10:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710262999; x=1710867799; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=R3Kc+Yh+XQ4llosDDGAwX/2k1FGi6g14GWlRJRORANM=; b=K5hlEGxYciy+RkT+/23XTGL8AwNlsA38+nOdBMJIQFnqhJ0tTAqwvWLkE2m+CAgtc2 GXCA3J3H1to7zrJ1Sih8asqCKvV7dP+k6if/NtMHEBNhZSkAg5bQr2klSakJ8YEy5NIM 0uzzfS/jQEhUUdx0PuoBOL1OqGUiiNiQccABAmqk/mBKU0TOjSIPBym8rNyKX2xBp+y9 JzuAcSukhYKnybIUGklfBTlcc9QHl6uaFj11uK3w7Dumasc3KOt4GP7+cHRV8TUUGUWW ixNwKg2DLcat3udVFJqMVgEStKBXjdA8GvZrjwVKCNghaYVKyldC6pbhpXX65TEm5on3 tIKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710262999; x=1710867799; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=R3Kc+Yh+XQ4llosDDGAwX/2k1FGi6g14GWlRJRORANM=; b=A+Ry64RxPPb6GxV2W0yt7zStkf9WgXZva/My9Cn4j0e89LtT4FD0dR0McA6h1T/CM9 JNfKWtUMTxUEtYQzr0xp7V+r1OWLqzDAltCOFXHbkG6cwES0sG6JzZJyRXP6XQ+zia9/ MgJc6NY9PbcyUEIl/mma0VCY4wXLxfOXTUjP58gdqrUX2sqdpCEtpr6OLqNsRByNDKC3 sVlZqm2m+4hRZYXDUSPgqiZ3H+ddtFh3+/mYlu8FTcKv15smqVP6855me7w8TdN2bRes 3uc8kyd4wl/28PA6IOEGjkme63ywKgZzUJVq2V7ISlimROjOgtadWgzgPySRcAfG8wuI Iyaw== X-Forwarded-Encrypted: i=1; AJvYcCXhn9Bsjv6hKWAWifVH1lTMnRa95bL2hHR/x7bE46rTo05qKGu6u+yQT9qTGuQgHOhyR6A24H8wdL+iNz49u8L1en5xxpx5ryod7MKu+A== X-Gm-Message-State: AOJu0YxmOApQgXQI2PSyUZU0fAbGhicTVQH6NlX2pj4nwhA9+7n81HCf G6iqWPhZvKwIEW/WEBvJxlsc2HWLYkc8FlQfH3xwR9k6ca9qIZsB X-Google-Smtp-Source: AGHT+IEtMqO0igDV/OJPl9l/q0X7vf8EgJ9VbKv7ARIuPeUFcb0gEvMyJN5DQCEgr2SoDMnFKNIL1A== X-Received: by 2002:a17:902:7b95:b0:1dc:418f:890b with SMTP id w21-20020a1709027b9500b001dc418f890bmr8936395pll.40.1710262998624; Tue, 12 Mar 2024 10:03:18 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e4-20020a170902b78400b001dcc3a46a6bsm6883069pls.262.2024.03.12.10.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:18 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 02/14] kunit: bug: Count suppressed warning backtraces Date: Tue, 12 Mar 2024 10:02:57 -0700 Message-Id: <20240312170309.2546362-3-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Count suppressed warning backtraces to enable code which suppresses warning backtraces to check if the expected backtrace(s) have been observed. Using atomics for the backtrace count resulted in build errors on some architectures due to include file recursion, so use a plain integer for now. Signed-off-by: Guenter Roeck Reviewed-by: Kees Cook --- include/kunit/bug.h | 7 ++++++- lib/kunit/bug.c | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/kunit/bug.h b/include/kunit/bug.h index 1e34da961599..2097a854ac8c 100644 --- a/include/kunit/bug.h +++ b/include/kunit/bug.h @@ -20,6 +20,7 @@ struct __suppressed_warning { struct list_head node; const char *function; + int counter; }; void __start_suppress_warning(struct __suppressed_warning *warning); @@ -28,7 +29,7 @@ bool __is_suppressed_warning(const char *function); #define DEFINE_SUPPRESSED_WARNING(func) \ struct __suppressed_warning __kunit_suppress_##func = \ - { .function = __stringify(func) } + { .function = __stringify(func), .counter = 0 } #define START_SUPPRESSED_WARNING(func) \ __start_suppress_warning(&__kunit_suppress_##func) @@ -39,12 +40,16 @@ bool __is_suppressed_warning(const char *function); #define IS_SUPPRESSED_WARNING(func) \ __is_suppressed_warning(func) +#define SUPPRESSED_WARNING_COUNT(func) \ + (__kunit_suppress_##func.counter) + #else /* CONFIG_KUNIT */ #define DEFINE_SUPPRESSED_WARNING(func) #define START_SUPPRESSED_WARNING(func) #define END_SUPPRESSED_WARNING(func) #define IS_SUPPRESSED_WARNING(func) (false) +#define SUPPRESSED_WARNING_COUNT(func) (0) #endif /* CONFIG_KUNIT */ #endif /* __ASSEMBLY__ */ diff --git a/lib/kunit/bug.c b/lib/kunit/bug.c index f93544d7a9d1..13b3d896c114 100644 --- a/lib/kunit/bug.c +++ b/lib/kunit/bug.c @@ -32,8 +32,10 @@ bool __is_suppressed_warning(const char *function) return false; list_for_each_entry(warning, &suppressed_warnings, node) { - if (!strcmp(function, warning->function)) + if (!strcmp(function, warning->function)) { + warning->counter++; return true; + } } return false; } From patchwork Tue Mar 12 17:02:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=D5Wo7RoG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKlv12hCz1yWn for ; Wed, 13 Mar 2024 04:05:47 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=D5Wo7RoG; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKlt1XDVz3vfY for ; Wed, 13 Mar 2024 04:05:46 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=D5Wo7RoG; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::430; helo=mail-pf1-x430.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKj72qSSz3ckj for ; Wed, 13 Mar 2024 04:03:23 +1100 (AEDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6e6afd8da93so500621b3a.3 for ; Tue, 12 Mar 2024 10:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263000; x=1710867800; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=0g4hKhLnYWz4PyvpNTr/SgCP1vJlAe2ABRcfc3yqje8=; b=D5Wo7RoGxcmUVNtz/IMuG8+zXb/HKS24tdEgRT3hGXFtDLKheU8Ue5ABVs1WIxOHR4 8Ac3PLczSifZWzdwAY3b3FHsynK7bC1thRbNU07O2ZTCSTQMo/AeVpRvLHWZyzhq3REp dyfzMbpP6YnX2vHahU2fPgDbS01eTnfVZupYLe2JCmCAFLH+e8OgAG6zrEqVOvOMATEq ad4Znxqkz/rBtkN/hr6OvP8sdfWK/YiNiNzk1Uu1Fs8dYOFCP1XwJDzTSZGFJ53ti2/9 a5hFHK+hjmQayf3Jo0/GVgzFu6pj1BaAi+mGZewRm9yfCmDGjN4O31UJhK50stM+kTFv ZJpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263000; x=1710867800; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0g4hKhLnYWz4PyvpNTr/SgCP1vJlAe2ABRcfc3yqje8=; b=S/t7bk4vejRJNxDCheHrwbJyxM0TAKjxFmMIJJCQfosKMcXPB6G3w4E3bGZikF4loM wbpb0oSXECCUoTDOkNA6KcYlqU6mZavNLyaJllJs/YXk2QzV4j3XAwM0fDOoWXUd7RhK UH1C3hkA/g5WIenerB6jTgVXQKxeT8DB8QoduxZ3Q2ft92XPRXkR1FDvpKvtxdccQLYS /MEprXScm5ymtQ+0glNUfQX6ZR/Vkhg/hX2dS8o5NApVH31Pc63LmzSz9oEYYyWx162A jRJReXOZYJmGnlkx3DTWIArQbn/P9zruJefNiLcnvXIR+gdUUcq9r4pBjbG4V8J66eJx HERw== X-Forwarded-Encrypted: i=1; AJvYcCXWtaip1EoeSelCzKo/+eXQ/pvU6XTWIK+FrWTuNPBZwMTWd1myxLU7OmfBScJLJVkzjDgUfL/polpg+KGfXMrelX6ksCLQP0Z7LWlv6A== X-Gm-Message-State: AOJu0Yyd+iQmdxBWHIOPSIcg92bOLqpYIbkpJBWe3+fCdxe5Waq1DIhJ +zXr+h0NnghdCK4JnxoWBpwKwSB46DAaCuF1+9ACnYf68mh4nqys X-Google-Smtp-Source: AGHT+IHT6d6QUcxkAobup5YpfcRZi4Aa/waxUmdzBZbBKsk0+4WZBzbaK7WYGFQOB9v1r7/VMSutWg== X-Received: by 2002:a05:6a00:10d2:b0:6e5:ad7d:d031 with SMTP id d18-20020a056a0010d200b006e5ad7dd031mr32842pfu.32.1710263000113; Tue, 12 Mar 2024 10:03:20 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id r2-20020aa79ec2000000b006e31f615af6sm6552880pfq.17.2024.03.12.10.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:19 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 03/14] kunit: Add test cases for backtrace warning suppression Date: Tue, 12 Mar 2024 10:02:58 -0700 Message-Id: <20240312170309.2546362-4-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Add unit tests to verify that warning backtrace suppression works. If backtrace suppression does _not_ work, the unit tests will likely trigger unsuppressed backtraces, which should actually help to get the affected architectures / platforms fixed. Signed-off-by: Guenter Roeck Reviewed-by: Kees Cook --- lib/kunit/Makefile | 3 +- lib/kunit/backtrace-suppression-test.c | 104 +++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 lib/kunit/backtrace-suppression-test.c diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile index 545b57c3be48..6a44d2b54ea9 100644 --- a/lib/kunit/Makefile +++ b/lib/kunit/Makefile @@ -19,7 +19,8 @@ endif obj-y += hooks.o \ bug.o -obj-$(CONFIG_KUNIT_TEST) += kunit-test.o +obj-$(CONFIG_KUNIT_TEST) += kunit-test.o \ + backtrace-suppression-test.o # string-stream-test compiles built-in only. ifeq ($(CONFIG_KUNIT_TEST),y) diff --git a/lib/kunit/backtrace-suppression-test.c b/lib/kunit/backtrace-suppression-test.c new file mode 100644 index 000000000000..47c619283802 --- /dev/null +++ b/lib/kunit/backtrace-suppression-test.c @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * KUnit test for suppressing warning tracebacks + * + * Copyright (C) 2024, Guenter Roeck + * Author: Guenter Roeck + */ + +#include +#include + +static void backtrace_suppression_test_warn_direct(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(backtrace_suppression_test_warn_direct); + + START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_direct); + WARN(1, "This backtrace should be suppressed"); + END_SUPPRESSED_WARNING(backtrace_suppression_test_warn_direct); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(backtrace_suppression_test_warn_direct), 1); +} + +static void trigger_backtrace_warn(void) +{ + WARN(1, "This backtrace should be suppressed"); +} + +static void backtrace_suppression_test_warn_indirect(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(trigger_backtrace_warn); + + START_SUPPRESSED_WARNING(trigger_backtrace_warn); + trigger_backtrace_warn(); + END_SUPPRESSED_WARNING(trigger_backtrace_warn); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(trigger_backtrace_warn), 1); +} + +static void backtrace_suppression_test_warn_multi(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(trigger_backtrace_warn); + DEFINE_SUPPRESSED_WARNING(backtrace_suppression_test_warn_multi); + + START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_multi); + START_SUPPRESSED_WARNING(trigger_backtrace_warn); + WARN(1, "This backtrace should be suppressed"); + trigger_backtrace_warn(); + END_SUPPRESSED_WARNING(trigger_backtrace_warn); + END_SUPPRESSED_WARNING(backtrace_suppression_test_warn_multi); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(backtrace_suppression_test_warn_multi), 1); + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(trigger_backtrace_warn), 1); +} + +static void backtrace_suppression_test_warn_on_direct(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(backtrace_suppression_test_warn_on_direct); + + if (!IS_ENABLED(CONFIG_DEBUG_BUGVERBOSE) && !IS_ENABLED(CONFIG_KALLSYMS)) + kunit_skip(test, "requires CONFIG_DEBUG_BUGVERBOSE or CONFIG_KALLSYMS"); + + START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_on_direct); + WARN_ON(1); + END_SUPPRESSED_WARNING(backtrace_suppression_test_warn_on_direct); + + KUNIT_EXPECT_EQ(test, + SUPPRESSED_WARNING_COUNT(backtrace_suppression_test_warn_on_direct), 1); +} + +static void trigger_backtrace_warn_on(void) +{ + WARN_ON(1); +} + +static void backtrace_suppression_test_warn_on_indirect(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(trigger_backtrace_warn_on); + + if (!IS_ENABLED(CONFIG_DEBUG_BUGVERBOSE)) + kunit_skip(test, "requires CONFIG_DEBUG_BUGVERBOSE"); + + START_SUPPRESSED_WARNING(trigger_backtrace_warn_on); + trigger_backtrace_warn_on(); + END_SUPPRESSED_WARNING(trigger_backtrace_warn_on); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(trigger_backtrace_warn_on), 1); +} + +static struct kunit_case backtrace_suppression_test_cases[] = { + KUNIT_CASE(backtrace_suppression_test_warn_direct), + KUNIT_CASE(backtrace_suppression_test_warn_indirect), + KUNIT_CASE(backtrace_suppression_test_warn_multi), + KUNIT_CASE(backtrace_suppression_test_warn_on_direct), + KUNIT_CASE(backtrace_suppression_test_warn_on_indirect), + {} +}; + +static struct kunit_suite backtrace_suppression_test_suite = { + .name = "backtrace-suppression-test", + .test_cases = backtrace_suppression_test_cases, +}; +kunit_test_suites(&backtrace_suppression_test_suite); + +MODULE_LICENSE("GPL"); From patchwork Tue Mar 12 17:02:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=bKubvVE9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKmg3gZtz1yWn for ; Wed, 13 Mar 2024 04:06:27 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=bKubvVE9; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKmg1JLlz3vZr for ; Wed, 13 Mar 2024 04:06:27 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=bKubvVE9; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::631; helo=mail-pl1-x631.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKj92P07z3dTr for ; Wed, 13 Mar 2024 04:03:25 +1100 (AEDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1dd97fd66cdso19992665ad.1 for ; Tue, 12 Mar 2024 10:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263002; x=1710867802; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=36BrykVX1YEJvDrrNJGSTLQfgxZ1lgqGPC6PgqTTbEw=; b=bKubvVE9OAe4cTL3M3sDioTEGj0rd8uN/TkoG/qWwi0i7SB7NHAQNEg3pl7z5CyMaE 8T/pNVbfHDN+eWh9N5lTAb7/sx4DWvDWt0HfIXA47V8PGvpmlj8VadBGheaO/QHQnCxq VUUirb+5U4Vzknv5DA7/gf4ViJ97HqnyWYXV62BRmxCQ/u9Rpc6jRoBO3R5WyavJ4Hw2 VB8iJFnPRHs/atNimMV0WWB9anyUtwFHwn3hNBPPBzTAolXUvS9W1FO813pKcyiOmfu4 P7qJjl4bBCA5pGCHYQV7b0N1GPOn+jfq8Rh1Hm+23DKZWB7pZyIoscwHxC8dWgGNbPBv g/iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263002; x=1710867802; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=36BrykVX1YEJvDrrNJGSTLQfgxZ1lgqGPC6PgqTTbEw=; b=m/9UYbHDgE9rjTLi6w02WktQYIljwEQkBPcai2N+oPNN/eIIGdevHOlx23WRGUIzky oVJWa++j+lbNq4rnrfRtdaSQHINipgt37cQmhLT6NvsLJt2zRySesWdp66XjpKMeUyjR p97mzMvYZBCjekSGQM9yvCroIAoYmgcHunCxh2EPpAcAfKa9a5mRnUf9hX2vhU6lozg5 q/aNyP3M8qy+s27swdyjev6oIeMJB/Jd1T+WKtQeDWwkDrYxbNulofTzsuvpULqbBFEI Fu3pr8zYzRM5bi6QMPlTLKTIbcfEWVAaTWMhi1j5e2+tQGgKehdCLuyEhey1glu5mW9q VtRQ== X-Forwarded-Encrypted: i=1; AJvYcCVGpFKDJrJIuhVXpR2rp30OkFruhJHaPrUtb5jpozoWGvJTWwSbG3B8bmLyia6En+tHMDfas+FMVne9UR6K+tKriy24XOtqxWOynoxV9w== X-Gm-Message-State: AOJu0YwtzoQJYjGX08qRacFxR5K3j715CL7xTN/Ff1pPeIuzB7iQbXjU LWlfLW4Loag3DNWl1II0zKaJz7gI7a9aYPiu+1QaPB8Zf/gMi1td X-Google-Smtp-Source: AGHT+IHYAZUPDqsFw7GWyh1RSbVI2Qwrh9Mdl1wKcQdsH3Ao31Ql441CQm7bvVJxkQ6v+AiS/8LElw== X-Received: by 2002:a17:902:b198:b0:1dc:d8de:5664 with SMTP id s24-20020a170902b19800b001dcd8de5664mr9227736plr.33.1710263002517; Tue, 12 Mar 2024 10:03:22 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id q1-20020a170902a3c100b001dbb6fef41fsm7095813plb.257.2024.03.12.10.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:21 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 04/14] kunit: Add documentation for warning backtrace suppression API Date: Tue, 12 Mar 2024 10:02:59 -0700 Message-Id: <20240312170309.2546362-5-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Document API functions for suppressing warning backtraces. Signed-off-by: Guenter Roeck Reviewed-by: Kees Cook --- Documentation/dev-tools/kunit/usage.rst | 30 ++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst index 22955d56b379..8d3d36d4103d 100644 --- a/Documentation/dev-tools/kunit/usage.rst +++ b/Documentation/dev-tools/kunit/usage.rst @@ -157,6 +157,34 @@ Alternatively, one can take full control over the error message by using if (some_setup_function()) KUNIT_FAIL(test, "Failed to setup thing for testing"); +Suppressing warning backtraces +------------------------------ + +Some unit tests trigger warning backtraces either intentionally or as side +effect. Such backtraces are normally undesirable since they distract from +the actual test and may result in the impression that there is a problem. + +Such backtraces can be suppressed. To suppress a backtrace in some_function(), +use the following code. + +.. code-block:: c + + static void some_test(struct kunit *test) + { + DEFINE_SUPPRESSED_WARNING(some_function); + + START_SUPPRESSED_WARNING(some_function); + trigger_backtrace(); + END_SUPPRESSED_WARNING(some_function); + } + +SUPPRESSED_WARNING_COUNT() returns the number of suppressed backtraces. If the +suppressed backtrace was triggered on purpose, this can be used to check if +the backtrace was actually triggered. + +.. code-block:: c + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(some_function), 1); Test Suites ~~~~~~~~~~~ @@ -857,4 +885,4 @@ For example: dev_managed_string = devm_kstrdup(fake_device, "Hello, World!"); // Everything is cleaned up automatically when the test ends. - } \ No newline at end of file + } From patchwork Tue Mar 12 17:03:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=CXiiMbPx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKnT0gRTz1yWn for ; Wed, 13 Mar 2024 04:07:09 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=CXiiMbPx; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKnS6jS0z3vm0 for ; Wed, 13 Mar 2024 04:07:08 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=CXiiMbPx; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::431; helo=mail-pf1-x431.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKjC6Dq2z3dWF for ; Wed, 13 Mar 2024 04:03:27 +1100 (AEDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6e68bab3e4cso2357726b3a.0 for ; Tue, 12 Mar 2024 10:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263005; x=1710867805; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=NGQg+0HBD/PmNnv+fI5fQqG3IGlyLsIaZmNJE7ZYwjo=; b=CXiiMbPxeamhk54LU656VgVLK9bPUP3Z5SIjDi6HA5ujEF0Zs4F7z/s7WKNdmAYTYt DmKqJqZth+aFxum3yi4u8yEigugywJYV1FVkzH16S6i2nTgTMqWhgPmDdXfmZkhxzf7l bJLvmD9h9+jo/dp9Iw178elXV4Gc6qkXN7SK0Al0B/7DbIl6p1b0xVOZ2V/Se2kE3HJG knH0450hC1Kmfas7YIjG2Wx2UhsNHLXYWI5dh5lA/MUAKXe4G3TTA3PFUusvWTDKXOkc M+Bcz6DHuOdGKQ/G/RY1IMOMlUIuG766txxEwk1A4xUwr9/GhtAsBVHX1KeNv4WgR0Bx Z/fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263005; x=1710867805; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=NGQg+0HBD/PmNnv+fI5fQqG3IGlyLsIaZmNJE7ZYwjo=; b=BVZHrpyLKDlrsgv3GU16rhN4NIRjAMuTpLdxGGFCgZUm51snTc54NHUYsyT3odn4QS GO0OXFrkdECmKIl9SO9hcVnZMHARksXmkW0kS/Q+JJ2Ba4mqYOhL0YwokTeShoFZko7L OTFq2OQgWm3iNem2RkBqwZX5F8hzYs1bMsjxjbJIpJ7JnjXROufbJgouzu4EUYH6Rmvn R3xhGssF/e7GulyzvTrQCmRKFprOVkugd9PCFumrm0qL/j8i0xq6coxljK51h61yNCrd w9oW6gji9kEwcRfgHxVJZMXPTG3vzU4JnFwXT2gevRwvYf/Sy8UMvMiQOzeo/bb1L0+E Hj+A== X-Forwarded-Encrypted: i=1; AJvYcCXV/QP+WE60qYMr4vFmI8IWlJ50sWSrkItb00LpxyT6CEXVFngaX6WuIKPhoXZYHf4hijSiNPwA4TYL2gT49QbY1GegTmQ/Csuv4o5G3w== X-Gm-Message-State: AOJu0YwiLnlGTNi6aqe4uPL0jnnNALrPnOADDZBSzgjpeVJ3tPGXmhYq uYR8hL2KH+4EzZUrX/9qMx36V8+sYABkkXMOZ6Agjr3/k7kBj94t X-Google-Smtp-Source: AGHT+IGxFzq6cbK7MrvIXcZlkGCehcjfwe014BGxyN94I+kP8/p7v7PJMJz1gy7c7O8kch/y3R6C8g== X-Received: by 2002:a05:6a20:1a8f:b0:1a1:4ea8:1844 with SMTP id ci15-20020a056a201a8f00b001a14ea81844mr8418900pzb.26.1710263004751; Tue, 12 Mar 2024 10:03:24 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id t123-20020a628181000000b006e657c72cf8sm6830699pfd.148.2024.03.12.10.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:23 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 05/14] drm: Suppress intentional warning backtraces in scaling unit tests Date: Tue, 12 Mar 2024 10:03:00 -0700 Message-Id: <20240312170309.2546362-6-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The drm_test_rect_calc_hscale and drm_test_rect_calc_vscale unit tests intentionally trigger warning backtraces by providing bad parameters to the tested functions. What is tested is the return value, not the existence of a warning backtrace. Suppress the backtraces to avoid clogging the kernel log. Signed-off-by: Guenter Roeck --- drivers/gpu/drm/tests/drm_rect_test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c index 76332cd2ead8..75614cb4deb5 100644 --- a/drivers/gpu/drm/tests/drm_rect_test.c +++ b/drivers/gpu/drm/tests/drm_rect_test.c @@ -406,22 +406,28 @@ KUNIT_ARRAY_PARAM(drm_rect_scale, drm_rect_scale_cases, drm_rect_scale_case_desc static void drm_test_rect_calc_hscale(struct kunit *test) { + DEFINE_SUPPRESSED_WARNING(drm_calc_scale); const struct drm_rect_scale_case *params = test->param_value; int scaling_factor; + START_SUPPRESSED_WARNING(drm_calc_scale); scaling_factor = drm_rect_calc_hscale(¶ms->src, ¶ms->dst, params->min_range, params->max_range); + END_SUPPRESSED_WARNING(drm_calc_scale); KUNIT_EXPECT_EQ(test, scaling_factor, params->expected_scaling_factor); } static void drm_test_rect_calc_vscale(struct kunit *test) { + DEFINE_SUPPRESSED_WARNING(drm_calc_scale); const struct drm_rect_scale_case *params = test->param_value; int scaling_factor; + START_SUPPRESSED_WARNING(drm_calc_scale); scaling_factor = drm_rect_calc_vscale(¶ms->src, ¶ms->dst, params->min_range, params->max_range); + END_SUPPRESSED_WARNING(drm_calc_scale); KUNIT_EXPECT_EQ(test, scaling_factor, params->expected_scaling_factor); } From patchwork Tue Mar 12 17:03:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911266 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=EMCYn8vP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKpG0cF6z1yWn for ; Wed, 13 Mar 2024 04:07:49 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=EMCYn8vP; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKpF4jmHz3vgg for ; Wed, 13 Mar 2024 04:07:49 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=EMCYn8vP; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::62a; helo=mail-pl1-x62a.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKjD6J7Dz3dWF for ; Wed, 13 Mar 2024 04:03:28 +1100 (AEDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1dd8f7d50c6so475345ad.0 for ; Tue, 12 Mar 2024 10:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263006; x=1710867806; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=mFp+F6/qbMDKwppN9CX4ZWrh/15b9XKC6E4V4vAKNpU=; b=EMCYn8vP/ZAED4ebXobFg8tx52sznGr/9Zs+DPOX3iSiFvkQ5tBuhXhEJMlQpwbm1k a3XHDYQc9DsddFGCYk7OsdfeItfFVB7WhZ9ps11SOIHB70VoV4y732X+3KGH4gaC3Bfo 3A600dz7mTl+sgMMI4npIoGme59s5MV1/41lMgUuGYHdGODpTQ3Q2m5RTR+UmNg0yvzy /wZeG3d8niiUklX1d6+7iin7rbPjptIOQRVPG6WxSpjswkebJ3meLfqHJ6iuQRttAEdF +9+Hx/VzUDq8YlMUVuRVy2El9qWtZnKIo0l6wpm0QgpAvrJNhF95Ake6bmI1V6LTxL2D f7tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263006; x=1710867806; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mFp+F6/qbMDKwppN9CX4ZWrh/15b9XKC6E4V4vAKNpU=; b=rXqcdzDkq3dA34yMMAvSo3C0fhgXhDaaoKSrOJ9M/yoUPFjkeJ+sGPwwdBzIM/KdXr TiZTUSMBMo7GWoxoC9joC/enJ8ocPG5NNhdAbd8yVqxcwBXm6kq6g7L/+1oM3YisI2mT +KGFZ8H/KJzWE86Egk7aLa6UNk01xqmIXdfCSjTQ+9wd1Y4jaq4GsF10SeyXldenFDtG pBLqrafZVr6QzzokCWHG+qNIauBZDh2merKuB0tkWW4FZNHymgSqExxSuQYab6lbYLKY axobmrrCSHIAYrSCyR+s7OWptO9CqIdv/zfuDTSRtw6a/Q/4n2j7tSGCcZFGrbEweQxX LiQg== X-Forwarded-Encrypted: i=1; AJvYcCWJCmZVZjh2oqZkWOBnSWboXtlqpyb3o8bChifjWgovVCyJfNcq5A4kqS2HlcjU/ZVWgrWRhkq1jahPrcXJMZqFHLTSXg/uR4Kl45AwyQ== X-Gm-Message-State: AOJu0YzqFpkzIvDIg4xeCylYeJb4PxfBMsCOJhlUc25zaV+u3ShCvW9N kkvdmhYn9JrzErKN8Or3QjcuY6anArzS4TZG6xCqoxprlSU3uhaR X-Google-Smtp-Source: AGHT+IFHgAu4TIvnFI5COGYb5tswxOQ5AvbfbseYntF0tu2SzSXjMyu1g4BetZFgaKzrp5WqY1rOuQ== X-Received: by 2002:a17:902:db10:b0:1dd:8ed0:59d0 with SMTP id m16-20020a170902db1000b001dd8ed059d0mr179469plx.17.1710263006272; Tue, 12 Mar 2024 10:03:26 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b21-20020a170902ed1500b001d9a42f6183sm6958740pld.45.2024.03.12.10.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:25 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 06/14] net: kunit: Suppress lock warning noise at end of dev_addr_lists tests Date: Tue, 12 Mar 2024 10:03:01 -0700 Message-Id: <20240312170309.2546362-7-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Jakub Kicinski , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel @vger.kernel.org, Thomas Zimmermann , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" dev_addr_lists_test generates lock warning noise at the end of tests if lock debugging is enabled. There are two sets of warnings. WARNING: CPU: 0 PID: 689 at kernel/locking/mutex.c:923 __mutex_unlock_slowpath.constprop.0+0x13c/0x368 DEBUG_LOCKS_WARN_ON(__owner_task(owner) != __get_current()) WARNING: kunit_try_catch/1336 still has locks held! KUnit test cleanup is not guaranteed to run in the same thread as the test itself. For this test, this means that rtnl_lock() and rtnl_unlock() may be called from different threads. This triggers the warnings. Suppress the warnings because they are irrelevant for the test and just confusing. The first warning can be suppressed by using START_SUPPRESSED_WARNING() and END_SUPPRESSED_WARNING() around the call to rtnl_unlock(). To suppress the second warning, it is necessary to set debug_locks_silent while the rtnl lock is held. Cc: David Gow Cc: Jakub Kicinski Signed-off-by: Guenter Roeck --- net/core/dev_addr_lists_test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/core/dev_addr_lists_test.c b/net/core/dev_addr_lists_test.c index 4dbd0dc6aea2..b427dd1a3c93 100644 --- a/net/core/dev_addr_lists_test.c +++ b/net/core/dev_addr_lists_test.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include #include #include @@ -49,6 +50,7 @@ static int dev_addr_test_init(struct kunit *test) KUNIT_FAIL(test, "Can't register netdev %d", err); } + debug_locks_silent = 1; rtnl_lock(); return 0; } @@ -56,8 +58,12 @@ static int dev_addr_test_init(struct kunit *test) static void dev_addr_test_exit(struct kunit *test) { struct net_device *netdev = test->priv; + DEFINE_SUPPRESSED_WARNING(__mutex_unlock_slowpath); + START_SUPPRESSED_WARNING(__mutex_unlock_slowpath); rtnl_unlock(); + END_SUPPRESSED_WARNING(__mutex_unlock_slowpath); + debug_locks_silent = 0; unregister_netdev(netdev); free_netdev(netdev); } From patchwork Tue Mar 12 17:03:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911272 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Ws/dp5Bh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKq93qt0z1yWn for ; Wed, 13 Mar 2024 04:08:37 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Ws/dp5Bh; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKq92kSVz3vsN for ; Wed, 13 Mar 2024 04:08:37 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Ws/dp5Bh; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1034; helo=mail-pj1-x1034.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKjH4Kg8z3dVw for ; Wed, 13 Mar 2024 04:03:31 +1100 (AEDT) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-29c585b259aso118685a91.3 for ; Tue, 12 Mar 2024 10:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263009; x=1710867809; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=5e/E6ddr2rv0O0qI6ESGYNVGq97JQ/YRs1mbYMxZhW0=; b=Ws/dp5BhiwbgOHSPLCe/AAZcZGwRB9Zm42+oP4ZWi7JZ5pM3ur7BjHB3SSVQ72jRes 94CnltDFwvWCJ1gF/7X7alZ0Vz24e89uScB96oOe9bGe0t9FcWZwAzgjYCEQ+CT03gj1 UFSokgn1PYWLaIzv/KHmdiX2LiN8UY3iQYLcPTty5I78p9cyOMSh8TL2TG1LB6LP7uSL gJ6KOXwMWmQLPBmD+JBeL+jRXuKQFEVKmNEFUt64jcHegPyz4KQaLdJ5XE7Obij2ENg2 UxEDGEOp61mEX6v+n/7Fi63dWvn14vhIVRUjSFmlHbTtt6yjpoEiA+2Z0Ug9MtVMPajp Sbhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263009; x=1710867809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5e/E6ddr2rv0O0qI6ESGYNVGq97JQ/YRs1mbYMxZhW0=; b=gZmLPUsETOjWMwwwrSA9MRyvL3WUGJ0NyvcCqWfcsCumIbUQ3YA87X8UYZn+mLkT3E EzvVEEfl8ZcVWFs65UhZeLK28NGGXom1Epl2xcj6HOXJXKoGNEihbLwL8EahS6orFjhO PrzDJz5S/acUNneibL0Ea4FGWIssujcqSAwlvngQX468RDdYQwW4O3Qw9tXYIMiaENmJ ABBvAP6Qn+3K+7xdle5qeUl7JhcHuMVnBGWUrYX0JoXz4ChyQfw/sVDE/p7QNpm99pfE 6ISBPzzB9onKnatEaAMRh7IzzNvRwUGqIyBUjwnwt5E4gU/w2NfZelb/9ofjpPRnPBU+ ZfDQ== X-Forwarded-Encrypted: i=1; AJvYcCULIZ3Haysqmvhq5kFA90Pold49L17yZtXYNCkaBJfAWCdoSraE8Srf//SFwT5gp+YWQrI9xqCTI47iOKOs7s/7fOEZJS/mueqK/7w87w== X-Gm-Message-State: AOJu0YzmpKKF8oqOBTmNFNIG/wMY5c1zFfcKcL+ZgGk0K0RYtSz8jMbY ypgzlfF2JmAvhDgPMgy8F+8q7jJH7HgHNAPzv+f4YOuWWN99NG9f X-Google-Smtp-Source: AGHT+IHnpV6pQ4sbhTQFUz6ATEKXpUTcdarefNsnZ32RzB7TxwrdDKUDIv3vmdM+PJbrepqm0Atu1Q== X-Received: by 2002:a17:90a:ba93:b0:29c:844:a91 with SMTP id t19-20020a17090aba9300b0029c08440a91mr5600961pjr.48.1710263008670; Tue, 12 Mar 2024 10:03:28 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id bf20-20020a17090b0b1400b0029bc2b845c4sm5986405pjb.11.2024.03.12.10.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:28 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 07/14] x86: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:02 -0700 Message-Id: <20240312170309.2546362-8-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- arch/x86/include/asm/bug.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index a3ec87d198ac..d87bf8bab238 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -23,18 +23,28 @@ #ifdef CONFIG_DEBUG_BUGVERBOSE +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%c1) +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC_PTR +# define __BUG_FUNC NULL +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define _BUG_FLAGS(ins, flags, extra) \ do { \ asm_inline volatile("1:\t" ins "\n" \ ".pushsection __bug_table,\"aw\"\n" \ "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \ - "\t.word %c1" "\t# bug_entry::line\n" \ - "\t.word %c2" "\t# bug_entry::flags\n" \ - "\t.org 2b+%c3\n" \ + "\t" __BUG_FUNC_PTR "\t# bug_entry::function\n" \ + "\t.word %c2" "\t# bug_entry::line\n" \ + "\t.word %c3" "\t# bug_entry::flags\n" \ + "\t.org 2b+%c4\n" \ ".popsection\n" \ extra \ - : : "i" (__FILE__), "i" (__LINE__), \ + : : "i" (__FILE__), "i" (__BUG_FUNC), "i" (__LINE__),\ "i" (flags), \ "i" (sizeof(struct bug_entry))); \ } while (0) @@ -80,7 +90,8 @@ do { \ do { \ __auto_type __flags = BUGFLAG_WARNING|(flags); \ instrumentation_begin(); \ - _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ + if (!IS_SUPPRESSED_WARNING(__func__)) \ + _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ instrumentation_end(); \ } while (0) From patchwork Tue Mar 12 17:03:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=EmGR0Hx5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKr54C8wz1yWn for ; Wed, 13 Mar 2024 04:09:25 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=EmGR0Hx5; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKr51kTMz3vfD for ; Wed, 13 Mar 2024 04:09:25 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=EmGR0Hx5; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::42c; helo=mail-pf1-x42c.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKjL3PwWz3dSn for ; Wed, 13 Mar 2024 04:03:34 +1100 (AEDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6e5dddd3b95so31878b3a.1 for ; Tue, 12 Mar 2024 10:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263012; x=1710867812; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=mgfFEM0oJIh4ATTR993DWw0sPyKQH24EY/4/QOUPczo=; b=EmGR0Hx5oSurg2DzylsSk+2+b9ptjVvmDfvW93nnr7UeDbyEFbg+ww7m070nUY698f 9rPoyfWKKniSbarReVgJN+rj1WIdq6P6NaVV8KNVJy5lQCSr/y0ZChFQjzj+LoWh9zg3 ncrfZ208qMN5I3YhkHqoILY0aZ80N78RDjgKe02fcmfdUsojv11deHPw01EXIsnxBruq xuMygnFsgAQOILw3xNt5/PxmS74DGMSIcYqy5u93gu1v60acIGGaL7WHRKg+lg/IdUK7 rKhkXAjjm+4BgA85wBcF4HnLemaOZ+/cJiUIPciG51fpPZgqm+7DioUWuqUaBPHqd9ad dvYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263012; x=1710867812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mgfFEM0oJIh4ATTR993DWw0sPyKQH24EY/4/QOUPczo=; b=WgPB2PkpFuCzLGOIQQYzCaffphTbOpjyO/7O3y8cTmAEIrRH3rRbgMSRowwdrlL+Pi 0sq1NGtupidQwVXtsn6mBes9vq/xQf+Wps7eDA+BO89JlLn6x4yOUtp6Jf9Kruy2lPtb uP8j6E9urTyiNpojETZhztE+yRbFec40XU99DmccnQccd8yoWeZKXvP5lgaWQV+MMPFo tQuwv2jMHE9yWcWSAKceUA9t8OFV0S2UVYiDEfZ+3UJuqLiSw3CadlfPwbge2AwU867U lhGFpwsEgyDdpt+t+S9DnmI/qVYo8lxxT/pJV1TVznlYQtvuH2R/IQx4cUqwl9NViBEu 6T2w== X-Forwarded-Encrypted: i=1; AJvYcCWygydFd9G1aQHeUix866nvO78OTMNxNuhPqgwy9OiT09AQUJwXixogSHWtt/+/1g5Xr210ybPr+zoAySjKCZkUG7+ONaTQkciV+qvZiA== X-Gm-Message-State: AOJu0YwxK0BQr7lTYNPBbI2GPUqk+zRkIS/h9ikF/w4K6nJNUGu7s379 YnPoest9cKUtnVPbMAXbubeuOyeLdvG4c/GQeL4EBaYyzTtwjSA4 X-Google-Smtp-Source: AGHT+IFq2CL0ds18qlKLUiBCru+tEydVmq2O3jl6A2X5cUl3NOOBJhsozkjJ4JcvCmlm7vgxw0hJ7g== X-Received: by 2002:a05:6a00:3a0c:b0:6e6:96cb:3ab8 with SMTP id fj12-20020a056a003a0c00b006e696cb3ab8mr29726pfb.10.1710263011492; Tue, 12 Mar 2024 10:03:31 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 29-20020a63125d000000b005dc98d9114bsm6228742pgs.43.2024.03.12.10.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:30 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 08/14] arm64: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:03 -0700 Message-Id: <20240312170309.2546362-9-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- arch/arm64/include/asm/asm-bug.h | 29 +++++++++++++++++++---------- arch/arm64/include/asm/bug.h | 8 +++++++- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/asm-bug.h b/arch/arm64/include/asm/asm-bug.h index c762038ba400..6884089a7191 100644 --- a/arch/arm64/include/asm/asm-bug.h +++ b/arch/arm64/include/asm/asm-bug.h @@ -8,36 +8,45 @@ #include #ifdef CONFIG_DEBUG_BUGVERBOSE -#define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line) -#define __BUGVERBOSE_LOCATION(file, line) \ + +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR(func) .long func - .; +#else +# define __BUG_FUNC_PTR(func) +#endif + +#define _BUGVERBOSE_LOCATION(file, func, line) __BUGVERBOSE_LOCATION(file, func, line) +#define __BUGVERBOSE_LOCATION(file, func, line) \ .pushsection .rodata.str,"aMS",@progbits,1; \ 14472: .string file; \ .popsection; \ \ .long 14472b - .; \ + __BUG_FUNC_PTR(func) \ .short line; #else -#define _BUGVERBOSE_LOCATION(file, line) +#define _BUGVERBOSE_LOCATION(file, func, line) #endif #ifdef CONFIG_GENERIC_BUG -#define __BUG_ENTRY(flags) \ +#define __BUG_ENTRY(flags, func) \ .pushsection __bug_table,"aw"; \ .align 2; \ 14470: .long 14471f - .; \ -_BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ - .short flags; \ +_BUGVERBOSE_LOCATION(__FILE__, func, __LINE__) \ + .short flags; \ .popsection; \ 14471: #else -#define __BUG_ENTRY(flags) +#define __BUG_ENTRY(flags, func) #endif -#define ASM_BUG_FLAGS(flags) \ - __BUG_ENTRY(flags) \ +#define ASM_BUG_FLAGS(flags, func) \ + __BUG_ENTRY(flags, func) \ brk BUG_BRK_IMM -#define ASM_BUG() ASM_BUG_FLAGS(0) +#define ASM_BUG() ASM_BUG_FLAGS(0, .) #endif /* __ASM_ASM_BUG_H */ diff --git a/arch/arm64/include/asm/bug.h b/arch/arm64/include/asm/bug.h index 28be048db3f6..044c5e24a17d 100644 --- a/arch/arm64/include/asm/bug.h +++ b/arch/arm64/include/asm/bug.h @@ -11,8 +11,14 @@ #include +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif + #define __BUG_FLAGS(flags) \ - asm volatile (__stringify(ASM_BUG_FLAGS(flags))); + asm volatile (__stringify(ASM_BUG_FLAGS(flags, %c0)) : : "i" (__BUG_FUNC)); #define BUG() do { \ __BUG_FLAGS(0); \ From patchwork Tue Mar 12 17:03:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=c2IOYvDq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKrt2Fjcz1yWt for ; Wed, 13 Mar 2024 04:10:06 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=c2IOYvDq; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKrt17PJz3vYW for ; Wed, 13 Mar 2024 04:10:06 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=c2IOYvDq; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1033; helo=mail-pj1-x1033.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKjP0KtTz3dVj for ; Wed, 13 Mar 2024 04:03:36 +1100 (AEDT) Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-29c52a90417so23561a91.1 for ; Tue, 12 Mar 2024 10:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263014; x=1710867814; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=QaoPploMqkrEWkpIzUU4wfevhj/fOj8xGNuIym5RM4g=; b=c2IOYvDqMAtdpeSwJZ30kW3Z7Gayy0KYx2xfvnsGbvUAko5dAxJ/hSMn9YEFUYNTBx 9uK5eA4s21qd/KqokOI030H9zsUvTwhXqXx/Y7YjM5mRlZ4SL6v/fS9u4yNzM765n9pP OMMYRjaszsi1w5AIFPw9sWqjyvTXF0yWSIGiCC3lHlYsnqWvpqY7hkInJdUcTbKRjEcy 4jxGahwn9F0r5jvZhJ6wn96Sz5bE5VpzsJsPPFMtruoqy5GtJ9eb26YJm6T8QQyc/Ybu 5ARoebNZ/DdvM/hFH2pFw1FzpL3w40Z2+sXR/g6Pr4lVM3UT+BbE8H5N46qeM7npRFia CqAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263014; x=1710867814; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=QaoPploMqkrEWkpIzUU4wfevhj/fOj8xGNuIym5RM4g=; b=fcYvCHDcSP2fSY48disuCpvjdmwD13vkYbL9Veya+ufAj53tUEVcwUeQtrjIYAs2uH 9b7cxQOlmGXLNfgoOG+1iIu39gGsAJtbzWeNBg2sfLdvmjPDJsGPKYXg9e+1cT4rOUzP 4QryskMnq5oeQBwoPukNd8MCZgfjkFVuk9LKcAEYIn+yYyI2XdVj011X1g5ma8nLDnqW 9ZccQqmBo74zYI8kbCQ9hKCMNadRq7OK/gBXdSEyMa4XvvFiOmjHr5RqnrZckMdJUl5g uGjl7iw+ehNjBuippKsKwaTK+B7vo+aNGCGZZNGcXHVteHwO7JYLSQcSRmvnqlo4GQMr dNcg== X-Forwarded-Encrypted: i=1; AJvYcCXrkbbwPMM6gDVXsnoVcqXilPyhG3kyWvYmOaSrnzCVv/OHx8yiXQq3UTHibK5s9+8wQ1JJKmyFOWxi8biTn68piHWKv4iR7Dj2emahPw== X-Gm-Message-State: AOJu0YwnMkFlNzAcU4l3F/nVvtkmxgk0nbgKgffIPeFYj+VfANCXr1p4 QIaR1C5F8eCwSwe+gZPu6oXEI0VpqrkUoiElqTvW6qzwHMuhHmtz X-Google-Smtp-Source: AGHT+IGp1mJ0KTZ+LQYMSXPX4xCWLkAXoeTNJUTBRzyrNk3iCGaW03oMbFoz7IlCFWta+THFx92xXA== X-Received: by 2002:a17:90a:e514:b0:29a:9dd1:d45b with SMTP id t20-20020a17090ae51400b0029a9dd1d45bmr194372pjy.3.1710263013769; Tue, 12 Mar 2024 10:03:33 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e11-20020a17090a77cb00b0029bf32b524esm4052208pjs.13.2024.03.12.10.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:32 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 09/14] loongarch: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:04 -0700 Message-Id: <20240312170309.2546362-10-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- arch/loongarch/include/asm/bug.h | 38 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/arch/loongarch/include/asm/bug.h b/arch/loongarch/include/asm/bug.h index d4ca3ba25418..25f2b5ae7702 100644 --- a/arch/loongarch/include/asm/bug.h +++ b/arch/loongarch/include/asm/bug.h @@ -3,47 +3,63 @@ #define __ASM_BUG_H #include +#include #include #ifndef CONFIG_DEBUG_BUGVERBOSE -#define _BUGVERBOSE_LOCATION(file, line) +#define _BUGVERBOSE_LOCATION(file, func, line) #else -#define __BUGVERBOSE_LOCATION(file, line) \ +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR(func) .long func - .; +#else +# define __BUG_FUNC_PTR(func) +#endif + +#define __BUGVERBOSE_LOCATION(file, func, line) \ .pushsection .rodata.str, "aMS", @progbits, 1; \ 10002: .string file; \ .popsection; \ \ .long 10002b - .; \ + __BUG_FUNC_PTR(func) \ .short line; -#define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line) +#define _BUGVERBOSE_LOCATION(file, func, line) __BUGVERBOSE_LOCATION(file, func, line) #endif #ifndef CONFIG_GENERIC_BUG -#define __BUG_ENTRY(flags) +#define __BUG_ENTRY(flags, func) #else -#define __BUG_ENTRY(flags) \ +#define __BUG_ENTRY(flags, func) \ .pushsection __bug_table, "aw"; \ .align 2; \ 10000: .long 10001f - .; \ - _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ + _BUGVERBOSE_LOCATION(__FILE__, func, __LINE__) \ .short flags; \ .popsection; \ 10001: #endif -#define ASM_BUG_FLAGS(flags) \ - __BUG_ENTRY(flags) \ +#define ASM_BUG_FLAGS(flags, func) \ + __BUG_ENTRY(flags, func) \ break BRK_BUG -#define ASM_BUG() ASM_BUG_FLAGS(0) +#define ASM_BUG() ASM_BUG_FLAGS(0, .) + +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif #define __BUG_FLAGS(flags) \ - asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags))); + asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags, %0)) : : "i" (__BUG_FUNC)); #define __WARN_FLAGS(flags) \ do { \ instrumentation_begin(); \ - __BUG_FLAGS(BUGFLAG_WARNING|(flags)); \ + if (!IS_SUPPRESSED_WARNING(__func__)) \ + __BUG_FLAGS(BUGFLAG_WARNING|(flags)); \ instrumentation_end(); \ } while (0) From patchwork Tue Mar 12 17:03:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=RQZLlj3T; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKsg1rhcz1yWt for ; Wed, 13 Mar 2024 04:10:47 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=RQZLlj3T; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKsg0m6fz3vjS for ; Wed, 13 Mar 2024 04:10:47 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=RQZLlj3T; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::633; helo=mail-pl1-x633.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKjQ6Gg4z3dVv for ; Wed, 13 Mar 2024 04:03:38 +1100 (AEDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1dc5d0162bcso33494275ad.0 for ; Tue, 12 Mar 2024 10:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263016; x=1710867816; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=8yPqiFdiMaUo8CT/x9a2ZlbShLK74ZzL6qnaxWOIrD0=; b=RQZLlj3T59sjrFg/DieAJgXhF5t0Tq8mDUc7kVyNzHpba0kNwe0PXF7yiHa2lqlvH7 s2aJP00TqDA3c9Pg5rRsWNPAoDPIxoHSOJTCj+CW0KdwrU5N5AlhpHq9/B+mlZcJ73SO hsgOan917vCuhgdvQQe/wRx5ek1C3VI4y5z13VmEKruTTEovGz0Uk3nn/thpqnkiaszr jgMKISHx633rVE6oPFhVq69zcZVyLxBj1r88dQYvejNWO/BNKS31aOB2ugE+tDefAgj1 /ffdpAblZccg7SWGNyMyf9+7zBGH+YlvvEDtFvx/FY9ehJkgZ2/1u4bTjpHCF7vufkkm sFEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263016; x=1710867816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8yPqiFdiMaUo8CT/x9a2ZlbShLK74ZzL6qnaxWOIrD0=; b=wH19XawJdulKwQG2fhwby460ehmJ/q3Lmi19Vcs6cti+royTVK8e4nhE0R7uKXY2bD NvSdGRIp9Dgmow0C9cvwPBu3207rzPBVGX/gjladP4raExXe4AsnWeEVoZzvz1LJB+CM 7RfYnPvpRxhF3Lzex3LV/W0HPrNtLA49Ol2T+YL1DbUflJCR4VfSXyN5HR06axo4zvQ+ 24S4xSc4ZQZwSR7wafyolOJiCEEWHFt+wW8QpWSlcg5KYJwOLmgH7G4hNyWIhSlS8lNH yxNOL/Vx5AhI4PH+sQ5PVxxw+/Q4QNtGFeGW8X60wdr0M7FWNqpAUGf907fB8dx+RrO0 UpHQ== X-Forwarded-Encrypted: i=1; AJvYcCX8BsRe7cVof5LB1XeZVYEOIUiTUQ/WS5xQCTdnJdXKxQs3/kjcYBguOObP/P17r2rtni28XnFCYeHMfB09h53jve5epUsZShSymSmpqA== X-Gm-Message-State: AOJu0YzKgqXejQ0UP5wsYtLZF72ixF6NlmPit8x0BbgvmYZiv0PaJkC1 J7KGw41PzGKyfVF9koE/vyAuHVr0hCINnGJRpX8nu82hsvzVQs8U X-Google-Smtp-Source: AGHT+IFoEsNPPrMLHPvnKMDpnnejQqa8I+dYMyPxL8EBJ4sDwkePMFxEwmxbDBpOVTaOpj6jJj/c1w== X-Received: by 2002:a17:903:2349:b0:1dd:afc9:a34f with SMTP id c9-20020a170903234900b001ddafc9a34fmr4471610plh.50.1710263016146; Tue, 12 Mar 2024 10:03:36 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b21-20020a170902ed1500b001d9a42f6183sm6958877pld.45.2024.03.12.10.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:35 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 10/14] parisc: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:05 -0700 Message-Id: <20240312170309.2546362-11-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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). While at it, declare assembler parameters as constants where possible. Refine .blockz instructions to calculate the necessary padding instead of using fixed values. Signed-off-by: Guenter Roeck Acked-by: Helge Deller --- arch/parisc/include/asm/bug.h | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/arch/parisc/include/asm/bug.h b/arch/parisc/include/asm/bug.h index 833555f74ffa..792dacc2a653 100644 --- a/arch/parisc/include/asm/bug.h +++ b/arch/parisc/include/asm/bug.h @@ -23,8 +23,17 @@ # define __BUG_REL(val) ".word " __stringify(val) #endif - #ifdef CONFIG_DEBUG_BUGVERBOSE + +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%c1) +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC_PTR +# define __BUG_FUNC NULL +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define BUG() \ do { \ asm volatile("\n" \ @@ -33,10 +42,12 @@ "\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" __BUG_FUNC_PTR "\n" \ + "\t.short %c2, %c3\n" \ + "\t.blockz %c4-(.-2b)\n" \ "\t.popsection" \ - : : "i" (__FILE__), "i" (__LINE__), \ + : : "i" (__FILE__), "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (0), "i" (sizeof(struct bug_entry)) ); \ unreachable(); \ } while(0) @@ -58,10 +69,12 @@ "\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" __BUG_FUNC_PTR "\n" \ + "\t.short %c2, %3\n" \ + "\t.blockz %c4-(.-2b)\n" \ "\t.popsection" \ - : : "i" (__FILE__), "i" (__LINE__), \ + : : "i" (__FILE__), "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (BUGFLAG_WARNING|(flags)), \ "i" (sizeof(struct bug_entry)) ); \ } while(0) @@ -74,7 +87,7 @@ "\t.align 4\n" \ "2:\t" __BUG_REL(1b) "\n" \ "\t.short %0\n" \ - "\t.blockz %1-4-2\n" \ + "\t.blockz %c1-(.-2b)\n" \ "\t.popsection" \ : : "i" (BUGFLAG_WARNING|(flags)), \ "i" (sizeof(struct bug_entry)) ); \ From patchwork Tue Mar 12 17:03:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911288 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=AM9m552C; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKtR6sSTz23qn for ; Wed, 13 Mar 2024 04:11:27 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=AM9m552C; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKtR5qbFz3vht for ; Wed, 13 Mar 2024 04:11:27 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=AM9m552C; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::62a; helo=mail-pl1-x62a.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKjS31cjz3dVw for ; Wed, 13 Mar 2024 04:03:40 +1100 (AEDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1dc1ff3ba1aso958295ad.3 for ; Tue, 12 Mar 2024 10:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263019; x=1710867819; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=UNfBGF7ZRB5gRY5ju3ZTnVyluuI6d4pIMWMvwwDFCuc=; b=AM9m552CHC/VBh17g4rO0tFL5aB39px/dbWyTwf8KBJT26b7LekI9nd/wQfzk1n8hO yO7CtvvmGA+anIh7SCnd1VxHsh+Y78BHZVYT4+FHTaXEgf5PR3NANrKnk5MtaQNb0tg/ e0CeBUEZSQ4Cg/gWEO78W286021LPUfzB2/pcxeSZwToT4JCzpICiyiQtGYGY3J+E6Gd 0njvmGQeQkVAinZWNZV5jC89dBvqarXYsXjXQ75JcqArceOT8+HYTf5ixqNH02xC5sf4 QlfRvzQEW4Lc44gXmrSx9BNtcFQ2aI45B45W9qz41ZHAny9qGLisf1VErAQfr5XbNK9O GeIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263019; x=1710867819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UNfBGF7ZRB5gRY5ju3ZTnVyluuI6d4pIMWMvwwDFCuc=; b=OdunmqxspR1lRmSuUZ3UZUYAyWp0l+FBQjf+R8rxGWdYw+WZdl340HR9Uu6l6k42uW vcomTY8v38y4y6+LddaPECj9BA0L4PKm4EEJG0aur9nxBFlv29nGX4eMF31Q2YcVu7Lf RWxxnAQTk1bFhEQmKEC50QR+Y7CsdFmaV8iKgmNQlrnczMv+lX2rWleICq4IgMze8zyJ WhG/VNYtpP3I15U00U7W06OmrK5IfIXZd8ObqY/ABwRRAXH4QJUuoW4szufHJFjesIC2 VvpPLSnIu3WtSoYT3UzW9ABgSqe9BlWEeGuVN79wGOs+WHKl4Mbq6pVJsOaoMShxn/TH g+2Q== X-Forwarded-Encrypted: i=1; AJvYcCWuHRFcjSBJzx1GfntVsz09upIo9P14+SKNxwRZJ9Xv92KudraY8XmRmUqW+bCGAfVLdUbIjzn9xHsYLawzGWbAfFnMYvnkQ+JtYUc/oQ== X-Gm-Message-State: AOJu0Yz+7PHoP6MpnoNcqGTcRVM34g/xY1w4kG/c4kvwwc9u4KXLIB+v saKfYcy1EfVN/ypqpKMmxvJ17rJKbAr6j2CW1SW/IS7aQLT6RwES X-Google-Smtp-Source: AGHT+IGjcPO5G+GnCGVDj4Jcw0R4zzS4LNLUn52exaX20Pa+MrIRq7GoxtzdXir/jkag847FtE7VIQ== X-Received: by 2002:a17:902:cec8:b0:1dd:7d6a:de4f with SMTP id d8-20020a170902cec800b001dd7d6ade4fmr939106plg.2.1710263018703; Tue, 12 Mar 2024 10:03:38 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k17-20020a170902c41100b001d9edac54b1sm6398555plk.171.2024.03.12.10.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:38 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 11/14] s390: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:06 -0700 Message-Id: <20240312170309.2546362-12-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- arch/s390/include/asm/bug.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h index aebe1e22c7be..01e2aa4069d7 100644 --- a/arch/s390/include/asm/bug.h +++ b/arch/s390/include/asm/bug.h @@ -8,19 +8,30 @@ #ifdef CONFIG_DEBUG_BUGVERBOSE +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR " .long %0-.\n" +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC_PTR +# define __BUG_FUNC NULL +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define __EMIT_BUG(x) do { \ asm_inline volatile( \ "0: mc 0,0\n" \ ".section .rodata.str,\"aMS\",@progbits,1\n" \ "1: .asciz \""__FILE__"\"\n" \ ".previous\n" \ - ".section __bug_table,\"awM\",@progbits,%2\n" \ + ".section __bug_table,\"awM\",@progbits,%3\n" \ "2: .long 0b-.\n" \ " .long 1b-.\n" \ - " .short %0,%1\n" \ - " .org 2b+%2\n" \ + __BUG_FUNC_PTR \ + " .short %1,%2\n" \ + " .org 2b+%3\n" \ ".previous\n" \ - : : "i" (__LINE__), \ + : : "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (x), \ "i" (sizeof(struct bug_entry))); \ } while (0) From patchwork Tue Mar 12 17:03:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911292 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=M09eGzTj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKvN0bqQz1yWt for ; Wed, 13 Mar 2024 04:12:15 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=M09eGzTj; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKvM5KJzz3vjK for ; Wed, 13 Mar 2024 04:12:15 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=M09eGzTj; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::432; helo=mail-pf1-x432.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKjW501Yz3dW1 for ; Wed, 13 Mar 2024 04:03:43 +1100 (AEDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6e6adf257fdso573974b3a.0 for ; Tue, 12 Mar 2024 10:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263021; x=1710867821; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=bXPfnReuSHXGXOVrQxZxvKsOYxRmb4ItarTkuVBwfPs=; b=M09eGzTjd7aLdmjoVTsW6uW46zJ4r/OJa+VoljirTbvz8/VHSgvcEkBOh3GuI9tu2c q/1DriJJ4Qn9T3CYJaF1T4JBughNtoLP3Fj9wEcjttre8bnNjivlvFLbs7d2K8sLy7rr 6t4MHl9lZ+CZl0hC/RGQMHNc7hhZfm+7hqdxg5Or2EeOhUQEWvWUrbd/08vvgwO3RDcM nGoz7ymIBDQx7SfXnN4Tx0aX8KpS7FQFsC5W2746b9n5+2jsmjH/jxGlz7nHK8xxLv0X hn9HMlnrdJves0GXkjXgP9JTSxRkrJVmWVaKTJrTe0y/5wR70oPOoVkcxf6t6DhU2yTP rQsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263021; x=1710867821; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bXPfnReuSHXGXOVrQxZxvKsOYxRmb4ItarTkuVBwfPs=; b=GsvBuSOzVBk0+z+J+BgYl9N37qOr3lxH5kPfNySk4YksPJurjMnhtJiEBC6vfI6S+W BrQyaFaO8b5s5E74MDDztvAq3ygXTmOAECizVDzNrdnxoO4/Q3HJB/5BKVZHLi04mIPa ld/8mP0G+GqHdpf4usU5nCbnA+vNGz1wpu76o7nwZaQ3Es76xD/S5r0DhQNrhfcMmMis gPdC4YC/MW5qXgF0usy3hI31C8yVMAgmxZLPF4OS3+VjSvzaQAn3yZBv5E1gXg4gKM2W 9iF/zWWgG2OXSiA5TUYi6/QOuQaZdUs0KGw7PCJ32tXNu/N6u1WEpBbKU2dv9NcCU8Oo P4jg== X-Forwarded-Encrypted: i=1; AJvYcCUCIOilztc71EvOWVtXvNwFMaPuRGQaT6STqLBAZ1BJEg6PPDfdrCau6Hyq7qBsailQi2jIk8OfHsWU8C61yOE3vPBpEgHTmpv3efVd3Q== X-Gm-Message-State: AOJu0YygQObMn/0sm0NKG+i9B8UhkDarJFUKhkn5YWv/cUHXMzehuUix 1Wjuje9izSMorp1JpZTNaYoW3hV2f4obQ3M7hF/yfAdXkT/OdIC8 X-Google-Smtp-Source: AGHT+IE4fVqqJ6hNP2W9YJrC0c7a73CCPEj82DwWsP9/bD/wztKwzROAlQDxzJc7BU6W2bM1RSgz/A== X-Received: by 2002:a05:6a20:9f06:b0:1a2:ba3f:e530 with SMTP id mk6-20020a056a209f0600b001a2ba3fe530mr11544554pzb.50.1710263020818; Tue, 12 Mar 2024 10:03:40 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id g1-20020a056a000b8100b006e674ef94b2sm1453577pfj.159.2024.03.12.10.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:40 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 12/14] sh: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:07 -0700 Message-Id: <20240312170309.2546362-13-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- arch/sh/include/asm/bug.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/arch/sh/include/asm/bug.h b/arch/sh/include/asm/bug.h index 05a485c4fabc..cadc335eb759 100644 --- a/arch/sh/include/asm/bug.h +++ b/arch/sh/include/asm/bug.h @@ -24,21 +24,36 @@ * The offending file and line are encoded in the __bug_table section. */ #ifdef CONFIG_DEBUG_BUGVERBOSE + +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR "\t.long %O2\n" +#else +# define __BUG_FUNC_PTR +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define _EMIT_BUG_ENTRY \ "\t.pushsection __bug_table,\"aw\"\n" \ "2:\t.long 1b, %O1\n" \ - "\t.short %O2, %O3\n" \ - "\t.org 2b+%O4\n" \ + __BUG_FUNC_PTR \ + "\t.short %O3, %O4\n" \ + "\t.org 2b+%O5\n" \ "\t.popsection\n" #else #define _EMIT_BUG_ENTRY \ "\t.pushsection __bug_table,\"aw\"\n" \ "2:\t.long 1b\n" \ - "\t.short %O3\n" \ - "\t.org 2b+%O4\n" \ + "\t.short %O4\n" \ + "\t.org 2b+%O5\n" \ "\t.popsection\n" #endif +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif + #define BUG() \ do { \ __asm__ __volatile__ ( \ @@ -47,6 +62,7 @@ do { \ : \ : "n" (TRAPA_BUG_OPCODE), \ "i" (__FILE__), \ + "i" (__BUG_FUNC), \ "i" (__LINE__), "i" (0), \ "i" (sizeof(struct bug_entry))); \ unreachable(); \ @@ -60,6 +76,7 @@ do { \ : \ : "n" (TRAPA_BUG_OPCODE), \ "i" (__FILE__), \ + "i" (__BUG_FUNC), \ "i" (__LINE__), \ "i" (BUGFLAG_WARNING|(flags)), \ "i" (sizeof(struct bug_entry))); \ @@ -85,6 +102,7 @@ do { \ : \ : "n" (TRAPA_BUG_OPCODE), \ "i" (__FILE__), \ + "i" (__BUG_FUNC), \ "i" (__LINE__), \ "i" (BUGFLAG_UNWINDER), \ "i" (sizeof(struct bug_entry))); \ From patchwork Tue Mar 12 17:03:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BbmNIYdG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKw84mBwz1yWt for ; Wed, 13 Mar 2024 04:12:56 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BbmNIYdG; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKw83hYCz3w2P for ; Wed, 13 Mar 2024 04:12:56 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BbmNIYdG; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::62d; helo=mail-pl1-x62d.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKjY2LTSz3dfb for ; Wed, 13 Mar 2024 04:03:45 +1100 (AEDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1ddbad11823so7183535ad.0 for ; Tue, 12 Mar 2024 10:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263023; x=1710867823; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Mb4FmIopiSO+/3QwXjaWJkazatuyJXVbnhhdOwFBf/s=; b=BbmNIYdGACNsjNz6YGqqqYHy6ghPKZtpW9KFck4og30Z8yByXTNL822YtttVv7YtKr RuIK7IqW/+wQquTwefgzMi/2F95U0RINpImbXQz+FEymV7e//WjRWhrnRfZAxULlDtA0 Lb8Bo+Xx+b3w9n7UXLoEZCDJhXInr39+CNNPY7ugEEuzQZ88Su0BSXLycVY2AthPuaaL /OZwJx+0jN+QHT3xZJ7mKQgTIoR76C2B3Ukz2FNdt261yuj9AV72ENFkf4w+/htJq2Mb S6P/8HkrvHR6LuhEPzuRbmpVPqsXTO5t59p/brvrtt/drseW+oJkRDPFUoeCHjzmAHeb zi7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263024; x=1710867824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Mb4FmIopiSO+/3QwXjaWJkazatuyJXVbnhhdOwFBf/s=; b=vLdVfqyqaTacGhvGArvKDcdWS9+919EAw3hxyb4bOmKeLvgKnG3XNqkXo9IfM7hdpc 0rw99Yx8+AGPyIsF4UKtqWFVPHbqGU+rgJWjVLhHgTKhBxxbAICw0OkCRh/W2i4Vybew aYv7lg2+ZNxLIZscwCxHh5gJ6iDv9k500X3GfUC1+JVAo0tpGKBF+ddF3zb8wxZGKU4S 2ImHxQlOQCuxTiHVQ2rQwk0vu+sXpstm/VJ6MWjy5EgbRdzpleUNPPTiu56ug49W2AHM 7yBiRfAP3LBDjRanNPfHOQx1rr192sffo8SaiJcEPARr+80/wD9nuvn4yWEGlhZD5d7+ G5ZA== X-Forwarded-Encrypted: i=1; AJvYcCXwYEbHr+FHhjAaAAyddmvLWRSderIOxVuH9pKi7tB+bqRdE2I4865Jdf3+v2IxOn/QlnLeiIRsPU4kwLP2tS03ZoIxgvf1s5CrlP1bKg== X-Gm-Message-State: AOJu0YyFSUKrx4TOB5u6oCAGbdCQAQFer/qRhhCwDwajbkEFWeWRBQV5 dLkZEJh0eIVgQiFHGZ+j5ptH5NvOi1KxU0BcJ6Gvpo0heucFd4TM X-Google-Smtp-Source: AGHT+IESK+W76sbv32507e8vr+AETbi9zHy7dM6LrGga9gr4qnmj+9kyX8nY1a/g+A7cAY64N5ru0w== X-Received: by 2002:a17:902:edd0:b0:1dc:a8aa:3c86 with SMTP id q16-20020a170902edd000b001dca8aa3c86mr9530991plk.5.1710263023689; Tue, 12 Mar 2024 10:03:43 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id w17-20020a170902d11100b001dca68b97d3sm6991774plw.44.2024.03.12.10.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:43 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 13/14] riscv: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:08 -0700 Message-Id: <20240312170309.2546362-14-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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). To simplify the implementation, unify the __BUG_ENTRY_ADDR and __BUG_ENTRY_FILE macros into a single macro named __BUG_REL() which takes the address, file, or function reference as parameter. Signed-off-by: Guenter Roeck --- arch/riscv/include/asm/bug.h | 38 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h index 1aaea81fb141..8955ee5c1c27 100644 --- a/arch/riscv/include/asm/bug.h +++ b/arch/riscv/include/asm/bug.h @@ -30,26 +30,39 @@ typedef u32 bug_insn_t; #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS -#define __BUG_ENTRY_ADDR RISCV_INT " 1b - ." -#define __BUG_ENTRY_FILE RISCV_INT " %0 - ." +#define __BUG_REL(val) RISCV_INT " " __stringify(val) " - ." #else -#define __BUG_ENTRY_ADDR RISCV_PTR " 1b" -#define __BUG_ENTRY_FILE RISCV_PTR " %0" +#define __BUG_REL(val) RISCV_PTR " " __stringify(val) #endif #ifdef CONFIG_DEBUG_BUGVERBOSE + +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%1) +#else +# define __BUG_FUNC_PTR +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define __BUG_ENTRY \ - __BUG_ENTRY_ADDR "\n\t" \ - __BUG_ENTRY_FILE "\n\t" \ - RISCV_SHORT " %1\n\t" \ - RISCV_SHORT " %2" + __BUG_REL(1b) "\n\t" \ + __BUG_REL(%0) "\n\t" \ + __BUG_FUNC_PTR "\n\t" \ + RISCV_SHORT " %2\n\t" \ + RISCV_SHORT " %3" #else #define __BUG_ENTRY \ - __BUG_ENTRY_ADDR "\n\t" \ - RISCV_SHORT " %2" + __BUG_REL(1b) "\n\t" \ + RISCV_SHORT " %3" #endif #ifdef CONFIG_GENERIC_BUG +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif + #define __BUG_FLAGS(flags) \ do { \ __asm__ __volatile__ ( \ @@ -58,10 +71,11 @@ do { \ ".pushsection __bug_table,\"aw\"\n\t" \ "2:\n\t" \ __BUG_ENTRY "\n\t" \ - ".org 2b + %3\n\t" \ + ".org 2b + %4\n\t" \ ".popsection" \ : \ - : "i" (__FILE__), "i" (__LINE__), \ + : "i" (__FILE__), "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (flags), \ "i" (sizeof(struct bug_entry))); \ } while (0) From patchwork Tue Mar 12 17:03:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1911296 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=JzjQFRKJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TvKwx4MjLz1yWt for ; Wed, 13 Mar 2024 04:13:37 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=JzjQFRKJ; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKwx1yKXz3vm3 for ; Wed, 13 Mar 2024 04:13:37 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=JzjQFRKJ; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::632; helo=mail-pl1-x632.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKjc3Xbyz3dy3 for ; Wed, 13 Mar 2024 04:03:48 +1100 (AEDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dd9568fc51so22813495ad.2 for ; Tue, 12 Mar 2024 10:03:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263026; x=1710867826; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=f6JeHPuNf2fPfe8/IgMEBFCbi+8s7x8ZP+Ypz6wTBFE=; b=JzjQFRKJAz6Qzc8unCBt3UG9wfu2i7qiKQH7v8yze0tZL5I3iskZ4m0lFeNIO+VCRf hD+o/7jz+nakbRYsTgzC5bjroa0DF2L/K+3lc5mjSDcvgfcDCd++9NllMT3nZxAIt7gh 2rooXW6j3W2bNjSVZ9KtsvyUxmPLakSYWxUyPJRYgBW7SZ4D/7cGY/vt+ASW+vlnfAWJ 9JJp82rt+TTNjsmVZaiYSqEHffcORH7eHv9NwsUO0hL0SoOBr1hcEyniN0mFkBGly2HA DvAwXMSaJcsSDTy9amAZtuGPF5kukDzOl6n7WZ2drVZlxhBseQB4taYKJPIlFtnM6cF9 IAjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263026; x=1710867826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=f6JeHPuNf2fPfe8/IgMEBFCbi+8s7x8ZP+Ypz6wTBFE=; b=tjmnkorIzkHzlpBhTRZhdX1Eor4a/qNsOmjty5hD4BV00oTeN6zKt3La/IRgrDpXn6 nD0lK1iOh8AjnLa1HSwfr26s8RzIpHwPbLCw9xt/V5xdPEu4gJ9jlDiPAEnOTA9sveO3 ykr4oS3oKMsgRvxt5U3DNFFODrO6wHw7JYKkdaR9M/LlpfSNG1CEe6CqhT5WP3rrcp8G NkqEERVQnI051mW7mujJWovPjzRZWJQbEPNjiinB48CimpSkAcCaGCVut0ifeKFbXoqL O24XrC+D2DlAUsMjXUvlhZoHba33OgpvRd2QRVh7SjsUK2Y3L4MLqvKt8NE8KDN78pZn I/KQ== X-Forwarded-Encrypted: i=1; AJvYcCXMArLRBFmI934o2PU51RxTh3hjdi+dWzixnzCWXsKpDa9ulQLMvDfkE5ieoEghyb3O5FFnzX2pBM79klZDZ5UOcpu/4EjAo3dbhGjXaQ== X-Gm-Message-State: AOJu0Yyxr9tfBhFO/NsM1XzNSmOMVkAVFWB7MHod19f+D97Hp8z7+4Qd jq2dYLIZ5Ry3y/du9P3NNlw5zAmJCNmTkcr74YhufVjeqpSdvfDZ X-Google-Smtp-Source: AGHT+IFeKRBmX0VW7sv5rUHfZ0tynia7OwMdWO6tHkvskc+E+k+IhaoGejd1DMN70lLMBnMgohEXxQ== X-Received: by 2002:a17:903:483:b0:1dc:fba1:1522 with SMTP id jj3-20020a170903048300b001dcfba11522mr6685263plb.41.1710263026027; Tue, 12 Mar 2024 10:03:46 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e10-20020a170902f1ca00b001dd75d4c78csm7006194plc.221.2024.03.12.10.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:44 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 14/14] powerpc: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:09 -0700 Message-Id: <20240312170309.2546362-15-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- 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)); \ } \