From patchwork Wed Apr 3 13:19:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 891FBCD1299 for ; Wed, 3 Apr 2024 13:19:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qP3fkJWsPQJZ0m/w8kUSDYmZLSS9yF2nfQg+aSpNndk=; b=4MWnnmD55JycmM 6/11FnY+QFg8oWycNmT51SHBx3mLUmiQU8InCJpar5ngdvUeRmZ9KKTceRJ3d2JxFE103Cr6UlkYI WsPgh/rLhB2I57MfsbFMz29MKbEBZ3eB0blqilcGCHgwtdHajwFzwD4wMcpv8oKjDysrCc+/N4gg+ OvffpZOMUJQ1ZURWhQDwKMGA9/8Cx9Hbgxx191v474r88VDJGhCxrILpb4T9UsTlfogtLiShtaBTg wiz/RIRmwW7oPsgovuAjr/Qz0DVzv3KhOOnblnh1pnaQG4UpDGu5cIqOFaTHe9KCLNOt0lMRLgh3N CC7ae++259uKDjeHqIjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0Wt-0000000G8WI-3iBA; Wed, 03 Apr 2024 13:19:52 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0Wn-0000000G8RH-2u1F; Wed, 03 Apr 2024 13:19:48 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5ce2aada130so4236400a12.1; Wed, 03 Apr 2024 06:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150384; x=1712755184; darn=lists.infradead.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=QLppDGinW0QyvnpiYq8klDjFNvdzQ2Nr+inin7jIp4I=; b=N7cbcoJT2P+6DA3nUlOyFsSOkIHAUkHxFy2be+GqxiWVVVZGUxQO+mtPVK5rNmh/8j KXJA5/BEm09sBhWspm8rKPUxV50BDKPOr44RLoR6r7cEzTo1TMzol0ppUYqciZBxJaKS O+z5tK3tlTRkbUn7mKCiqAHDJX1w4G+e2yBU1F5OdlTCUyfDReKukjM2xUBadnHqF80E D7B1KRqkHJgR+XVMZG9yeCudVagXqtbEsRGmUjKnF+JaNXE+OtR2PUKjr0NvTOAAGg66 SxkJaGPxHvQvLv+YnTg4Rz5ba7fKuP2K5ey/yxfKV04nJ/QM4hRtFF+3KUq9xw2G/vR+ 7Vrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150384; x=1712755184; 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=QLppDGinW0QyvnpiYq8klDjFNvdzQ2Nr+inin7jIp4I=; b=MZYTCY3PFhUeeYBTUWkOFxdSd5MTHhkBNMFYVIIFqYqYqG9e602NXHNtm8awMoWGmQ OQZtoObmmKYy6DgtmwKU3nfTvdv+lYwdB7+MDE95r9drG88u/NChIK5q0RZXH7p6qWO+ +u/9dSM57cXvTAGxdO9P2vYnnNG9XAPIip5GlJURyaYbsQn5h4pq0I1c7cpWRkJzI8V/ YGRJxOl5H8egZ8CR8ELyKajJt6fh5PmWuF16iyAM6Vfn6XU/MhzY5iL76v71SfFjhYtu 9HdZdUbmdVDwyZSnAidWzC2eZsr2Iycww0QFYNZRNfjE0TxqCVHJyx5claOOIu+AwmUj 5Fuw== X-Forwarded-Encrypted: i=1; AJvYcCVyHVcz0RBcmf9dE07MJovwVqbMWMjmH3JLQ4yhaFSdmDo1M5Af4W7y99bR6OXF1ICNK9KNwnzhB6fGg5cJbzX1xGLz+rQPHQSSIHcWXn/gT52lggKQrwZN1g6AsQGwjivOBG7UEgm8WBfD6aIe0o1tuvryk/Y= X-Gm-Message-State: AOJu0YxeIw/gvNiMQBbOsQhiuOudVn7TNMLoql3IkfdwlKNiRFSPgsAF iEoU8UkvkcLx2y75zOHhaK8IjgGgeYbuXWbgcpkmXXo4yTP7wI0h X-Google-Smtp-Source: AGHT+IHLZzwj8QjdIOumZZwMTdNJboOCUuRmYTlmuXcu4rWvyLRFqzzHLCDPQsEEK1PiSQ2OkIhUJQ== X-Received: by 2002:a17:90a:e691:b0:29c:7544:54df with SMTP id s17-20020a17090ae69100b0029c754454dfmr13682150pjy.23.1712150383662; Wed, 03 Apr 2024 06:19:43 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k6-20020a17090a658600b0029bc1c931d9sm13588667pjj.51.2024.04.03.06.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:19:42 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v3 01/15] bug/kunit: Core support for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:22 -0700 Message-Id: <20240403131936.787234-2-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_061945_821265_197BF2B6 X-CRM114-Status: GOOD ( 36.26 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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. Since the new functionality results in an image size increase of about 1% if CONFIG_KUNIT is enabled, provide configuration option KUNIT_SUPPRESS_BACKTRACE to be able to disable the new functionality. This option is by default enabled since almost all systems with CONFIG_KUNIT enabled will want to benefit from it. Cc: Dan Carpenter Cc: Daniel Diaz Cc: Naresh Kamboju Cc: Kees Cook Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Reviewed-by: Kees Cook Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Added CONFIG_KUNIT_SUPPRESS_BACKTRACE configuration option, enabled by default v3: - Rebased to v6.9-rc2 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/Kconfig | 9 +++++++ lib/kunit/Makefile | 6 +++-- lib/kunit/bug.c | 40 ++++++++++++++++++++++++++++++ 8 files changed, 178 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..bd0fe047572b --- /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 + +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE + +#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_SUPPRESS_BACKTRACE */ + +#define DEFINE_SUPPRESSED_WARNING(func) +#define START_SUPPRESSED_WARNING(func) +#define END_SUPPRESSED_WARNING(func) +#define IS_SUPPRESSED_WARNING(func) (false) + +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ +#endif /* __ASSEMBLY__ */ +#endif /* _KUNIT_BUG_H */ diff --git a/include/kunit/test.h b/include/kunit/test.h index 61637ef32302..d0c44594d34c 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..aa8bb12b9809 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_SUPPRESS_BACKTRACE 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 defined(CONFIG_KUNIT_SUPPRESS_BACKTRACE) && 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 /* defined(CONFIG_KUNIT_SUPPRESS_BACKTRACE) && 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/Kconfig b/lib/kunit/Kconfig index 68a6daec0aef..b1b899265acc 100644 --- a/lib/kunit/Kconfig +++ b/lib/kunit/Kconfig @@ -15,6 +15,15 @@ menuconfig KUNIT if KUNIT +config KUNIT_SUPPRESS_BACKTRACE + bool "KUnit - Enable backtrace suppression" + default y + help + Enable backtrace suppression for KUnit. If enabled, backtraces + generated intentionally by KUnit tests are suppressed. Disable + to reduce kernel image size if image size is more important than + suppression of backtraces generated by KUnit tests. + config KUNIT_DEBUGFS bool "KUnit - Enable /sys/kernel/debug/kunit debugfs representation" if !KUNIT_ALL_TESTS default KUNIT_ALL_TESTS 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 Wed Apr 3 13:19:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616278 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B292BCD1288 for ; Wed, 3 Apr 2024 14:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=K7ElIdN8Tm75nauDLK0wU3sFvaaT8mBf1Qm+G0NdbIc=; b=iMo35j7kmn2M6m jMoc91bRn1xmAZhwG64RkVn/j3dlW9thLn4KSbEiqU0WW+pKIwL+Dq7tW5A0tZj9KDWdz5pKhjOl/ Pg76v2+pyWWjqu3g4DhgJe3s0Wa7tZ0ug/qgbLj0ZHfZsR23qG7UHQDEt2tbDcPH+0Nr22/JSVKW7 KJetgTvYB9r6VjrjjxFhtvbE1kti1/5ImBxxJBQakXFenTARxI5ab7aGzmt3vlBdmGCEI8hnXYeX3 J7LROFJgntnpJcJEas74BkHHPZCbrFVRjeSfiRbcr1od8cR1lG/X3p7CC8deENB+HRnbh/n/aosKN jzuTwVCU12BAd8LN92NA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs1gw-0000000GUg2-1cqn; Wed, 03 Apr 2024 14:34:18 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0Wr-0000000G8S3-1WhO; Wed, 03 Apr 2024 13:19:53 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1e27e174ccbso10904895ad.2; Wed, 03 Apr 2024 06:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150385; x=1712755185; darn=lists.infradead.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=vPi3jXYhV/VW7gVgCzBi2KBL1/Xcj6OVJJpN8P4Laxs=; b=Hdis1yKYxs7UzPBOWDK/7whrRx3Ma3wLxyJ46fWep9HEnnphkb7aqX1uRqaFBY3ZfS 6GhceUUZexFSQh9vzC1wHbEQhiMowqoJkHwgFQc09ibnDKXsK7/OHHJ5ogut/K/T54Wu Apek/yef/Wf1v9N3hjWWV4gR5QN8bWrEFAIDoFZ40rwzhXLiEMPYqqHZz5QZqcWE3P3c hd32tBCXxp6zV1EbIMHJlgbJSPU5lxMWUslPTXYiF1Hey+dVMuFLGPbMufG8/W6EMNd2 qNSWqruZNqgFfmU2HL44LMPBuoAtxMSlCJnLE6DVS1iATuhQC1N+cOIeC6L/gOBlbemb bDXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150385; x=1712755185; 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=vPi3jXYhV/VW7gVgCzBi2KBL1/Xcj6OVJJpN8P4Laxs=; b=vaePumFxZrOPYH5q0wWg6ifZlxWNnIRpxzjzRed89Ubxhn/hKJJ9r6mEiPUtKweFRq 0cFixv5F3mnxSUM3wALHRdt+ZwRRuIHPrOanK7PwLooIhMyr2H93Qmf+Ec3LLWYiYr3f bl8a4/oTMyg0tGreoGFpduN1tKtLK4fxWntzecbrn7QKpWTWP1/ShBZSpu39zk/FWKD2 XnNT+seeKg+GC0VpxYwlzDYwWbqbXrSriTphiXsV9CjpTfzoTRbWcCzz0KCcmCe+KxnI 3D58UXfp+ObcGSAbANeXf9D/8Z/zuffk08HgFn9jaCnrmV0IaaiXZpv7ehpCkKAX2Vw/ g25A== X-Forwarded-Encrypted: i=1; AJvYcCXbKJuBzRS8hC9OF1GPo2Q3IyCMSSM+Bme8rq8/xgAtGBUfmIgE7LLDwBFI5VVFGR40pG6Wcr/UPb7lHNyMlYi52FMcpbDF5mTvuv3gaGq3NQpoOirComxJS0kIuzbIlaT2wbePfHSsmqlOyj8CJckU812eHw4= X-Gm-Message-State: AOJu0YyvyvrU6dijouWaYWWeAIRY71wDQDneOPTMv8B745FeXYBt43Dd UM8RAyTpVtgJmfMHQrgGR/dPlOABNbjjXfYbOXMgJC4+0BgrlaD2 X-Google-Smtp-Source: AGHT+IEBdntNuCJK1g1Qd+nUbBCHvT+g3ANfVkijVSktnMtYlUtgHLeuVpmPgg+o1C+TJMJB0A4+8w== X-Received: by 2002:a17:902:9004:b0:1e2:5e2f:682 with SMTP id a4-20020a170902900400b001e25e2f0682mr6996194plp.2.1712150385380; Wed, 03 Apr 2024 06:19:45 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id u2-20020a170902e5c200b001d8f81ecea1sm13305095plf.172.2024.04.03.06.19.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:19:44 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v3 02/15] kunit: bug: Count suppressed warning backtraces Date: Wed, 3 Apr 2024 06:19:23 -0700 Message-Id: <20240403131936.787234-3-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_061949_619981_ADB72F43 X-CRM114-Status: GOOD ( 13.98 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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. Acked-by: Dan Carpenter Reviewed-by: Kees Cook Tested-by: Linux Kernel Functional Testing Signed-off-by: Guenter Roeck Reviewed-by: David Gow --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2 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 bd0fe047572b..72e9fb23bbd5 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_SUPPRESS_BACKTRACE */ #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_SUPPRESS_BACKTRACE */ #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 Wed Apr 3 13:19:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AAFB5CD1292 for ; Wed, 3 Apr 2024 13:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+Trm5YAiPSFn9NrpDZw5+2YvayWCfWja0cuHW7yGVsA=; b=JO2FQh3iv0Noqn vxkMs/VbDSvF+EDeQmuxxJupr/pBtb/+ztR0hijhBG6pGafdNMLj3DQpqcNA+RHQqEQnrCcgx7XgR 4RAQSDNlGvZhKCd3NesKik8k0eUodnCX+f327p516A14Gc09xtz83m/T5SWR5+Zx6NxiS0b8iJbD9 HtfKiTeabqVbV+moyG/U6oLbsSa/kF+D+Kg8vhlYw5jNU+z2qiRkhbk+FVyzsDtC67aiWRNoDO/jk UhKpgVedxpAuT9bGUH4COVT02V8kreIyghPxZJ73+mpEa2LU9bCd4DaqsoTI0HXfwlGBosUdVFqsC 1JGkajwYgZZxebA3rQqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XV-0000000G8tX-2OQR; Wed, 03 Apr 2024 13:20:30 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0Ws-0000000G8TM-1v8Z; Wed, 03 Apr 2024 13:19:58 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2a2474f2595so2124707a91.1; Wed, 03 Apr 2024 06:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150388; x=1712755188; darn=lists.infradead.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=Pjv7Xp9MV0DSDQU0m3fWBF7u8xCRPonxB88RSacFUiY=; b=BJIl23c7WZaF/ce4XX4zE96gWAH+Va0E5riU2pWjqnmgrmc+0Zga7pKNKa8tjBXSWm ivpkGFAHI1BnEzJDxo6xhCtXhS0J6B/fx0UFQJg5q2WhW4/rMu6CWrU5J6NDVYcFLcq7 1kg+UCDGyhQMK435CYiF85FhRIGC8R3msUxD2G3xPJSPr4cWAPJh07NnqF5JI2kJ3xFb XvIzLU0k60vCoCMe7CBEqGcbgyOxRLzDavNKsSMXLIgDVAPmQR4etPdecN96wJW9Jaq9 F/HoVImGjflJGGNpDQvVKU7LUEmfz4FlxFoPgr7aOVdN5ETkPQ9R+082Ct1hG1MTj3AB WnhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150388; x=1712755188; 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=Pjv7Xp9MV0DSDQU0m3fWBF7u8xCRPonxB88RSacFUiY=; b=R1oNhcEpW1qh2r62bPb5skxWboZRydHtmo6PrwJewUZd8z5XkbgvevaX7L6M9Bk3YL IGI894mSIvrnFqHYMZIpesmy+ABDc7zoj85O1Jbp76CX+MIExOEyOTwLhszhiFJ0NVKQ eB/LNrS6gybARIjm/i4YF1Szf4qSPlpZXWAN4kbIUDDWOrMjRkebxmwP9YWgYjgEBMT0 O3cY0aALfKZeot5Oh4hYVjVC3wBcFll6Ny5vxl1AjH+Zwll93JNAqbVI6ihYadOjKDW5 Lm1Pks3QutteOB2LXVUGO7T7wyNOeKJQ8F8TIqmLizUyHPLStz9oI1LBTdxLriUbwYr2 Bw6Q== X-Forwarded-Encrypted: i=1; AJvYcCWlcGzetVYWlheMZ/2tUVPbjsJSkTXFG4z+OO+g/tfB87pxCizWHmgi0PasthPNNrfi/tmfOqyIYG4GRYqxv/V0PAkQyzC3r80eZywQHxaFl6GCyoS45aaljvdc3J29Sgp/hD76830eEI2GuQGoFvTu6jP57bI= X-Gm-Message-State: AOJu0YwL+UUssjSH4KiWMPc4pqwfu6oVt7LTEom1N4PyYSGUpg2GRC4r /geinoaIczk7gNeKTEWnuqikLkhjcZfvbiU7tGnSjxi1IVk6/i3A X-Google-Smtp-Source: AGHT+IH9i3q5NLbj3L3SRhLxC/yUkLElgfzecWcrFNyAnqHWTVhzS/ed731TWMk8XQGzPC81E+r2yQ== X-Received: by 2002:a17:90a:fd8b:b0:2a2:b2bd:e1b1 with SMTP id cx11-20020a17090afd8b00b002a2b2bde1b1mr551165pjb.22.1712150388063; Wed, 03 Apr 2024 06:19:48 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id on4-20020a17090b1d0400b002a0777a2b1asm11473160pjb.10.2024.04.03.06.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:19:46 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v3 03/15] kunit: Add test cases for backtrace warning suppression Date: Wed, 3 Apr 2024 06:19:24 -0700 Message-Id: <20240403131936.787234-4-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_061950_665774_8E78E2D3 X-CRM114-Status: GOOD ( 16.22 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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. Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Reviewed-by: Kees Cook Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2 lib/kunit/Makefile | 7 +- lib/kunit/backtrace-suppression-test.c | 104 +++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 lib/kunit/backtrace-suppression-test.c diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile index 545b57c3be48..3eee1bd0ce5e 100644 --- a/lib/kunit/Makefile +++ b/lib/kunit/Makefile @@ -16,10 +16,13 @@ endif # KUnit 'hooks' and bug handling are built-in even when KUnit is built # as a module. -obj-y += hooks.o \ - bug.o +obj-y += hooks.o +obj-$(CONFIG_KUNIT_SUPPRESS_BACKTRACE) += bug.o obj-$(CONFIG_KUNIT_TEST) += kunit-test.o +ifeq ($(CCONFIG_KUNIT_SUPPRESS_BACKTRACE),y) +obj-$(CONFIG_KUNIT_TEST) += backtrace-suppression-test.o +endif # 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 Wed Apr 3 13:19:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C405CD128A for ; Wed, 3 Apr 2024 13:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=soimj1aURj9HauCMCOx2Z8lFnQC1ivQFAOBsD+eTdgk=; b=q2prQZXmd+5ZJJ ENyvYb9c0VqdQ4I3KI0cqdiKJITwWJ/POuYhLPaUX5OT633AwL9Pdmk+7g8gfBTuvLhA0ktg96UOD 1+SCYd2P2VJ+rG3G1a9LbFpBEC0fOXE+YFPMbgtZRVIjgKHPn7ZXiLCV4u9Ea7IR6xp5FVytj4a9j tRgvG+rwT4Bftgs6ZglezK7u4x2nXMKrFSV7k968VNUsNtpY9MkWI9WsOi/SGja07kEuyld0ssd5E zFxqudL72j5ozQEk+RRDbsAATLEOqcrvkpH1ReTF/jmDHxdA7sWwNClrv4YvDTUZGVQJxf6t5IDWn XVUbYQA4J8ZmKufazI+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XY-0000000G8vp-3E59; Wed, 03 Apr 2024 13:20:32 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0Wu-0000000G8VQ-1mWc; Wed, 03 Apr 2024 13:19:58 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e0f0398553so56799295ad.3; Wed, 03 Apr 2024 06:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150390; x=1712755190; darn=lists.infradead.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=KUpuwFkhA/ZZkaJrm+5DUMvKoRunaI4/ZlB0ejZmZW4=; b=RIJC9ec7pfE/DMp+PXsR+50UbpFdJYIjJ65n6lPB3Dim7p8MTiP9tg82N1CzBhI8/X qy51pJSK3Ph8kR7GrOsdvxtm+AZzZ/9ThWOy43gnTNsN7gcWT4I9LIIxc1naW/sRkBzC E2keNWMIEtjbpgCvsgn/pB7cOOCrm5fUqnoIsJxtIvwZ2EEaqfwQtoDk8hwrKQ7nVexi 6iskNr2SAOEC9hojkvUvEsohZJM1dFVgUb2wdpR4Hd3W9+5ZJFczQ9joFfCWZThB9X3K AKkO6L0v6JV/Qe/G/bEYp0rLlcYkiCcHhwjuor9wbWk5CrffjKSocgAEyfCL9jRHUR5x uNvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150390; x=1712755190; 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=KUpuwFkhA/ZZkaJrm+5DUMvKoRunaI4/ZlB0ejZmZW4=; b=SvG5ZD5XjxCzLpCUIs2GzVg07IKMGrRy/JzNotwuYUvhkZdtME+pHSl6LJWkkJ6L/8 y+yhWTvpkLOMzX14aa8Z1raNrxh4CzLnu1VKSw4zdvXpDLNV5Pzgwy5HqwWT8RPqCw9Z NYHKVObwD6DZ+/SwQQY8T2kgGLzyHu9tWi1Smtzkmrrk0c/gK4YM80d2I9UrQ/iMMSDt QIonady6uguiK8Y4+AjydRO7DZqlIijQ169UNZp8zzIyVEBopAlvCvt+G1cQik1IeBo3 01/h53Y2RG45NFyIp44dhLH+ravY9wUKN/G+JTbN3ljLeLf+Og8UpXXjENBl1RxbRGfz oJWg== X-Forwarded-Encrypted: i=1; AJvYcCXDGNxf3KDwjxlAauYlGQXZnytOO9MI57piOJLtEJJ1wyXqnrsZ/QQjaayFjcvMAntVDDj67pu4qXRHnZCVWZoRDq1ivWL86UJMzeUvoSMIqov6e2RYgHPxtsnDj37lNKlKmRkGIIua1rberWzIKQB+qXcnbm4= X-Gm-Message-State: AOJu0Yx9tDxamNDSffmY6b3nLpxM0mC91OnK96oQMvTY9PPaPXgGfd+4 JdVXvwMONrnCXu1HQ4K8UBlymFQ95u0/vFEgCDS99xDvPJq92cq0 X-Google-Smtp-Source: AGHT+IE/2OacMp/2cfvaRksBgAjGZgKxyI++pmI4VDvZRW0+d8012wJeFPX8kGKifNbdvVT4SH77dg== X-Received: by 2002:a17:902:f68a:b0:1e2:9205:5254 with SMTP id l10-20020a170902f68a00b001e292055254mr1881147plg.7.1712150389795; Wed, 03 Apr 2024 06:19:49 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k10-20020a170902694a00b001e088a9e2bcsm13158796plt.292.2024.04.03.06.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:19:49 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v3 04/15] kunit: Add documentation for warning backtrace suppression API Date: Wed, 3 Apr 2024 06:19:25 -0700 Message-Id: <20240403131936.787234-5-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_061952_670781_9471E740 X-CRM114-Status: GOOD ( 14.51 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Document API functions for suppressing warning backtraces. Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Reviewed-by: Kees Cook Signed-off-by: Guenter Roeck Reviewed-by: David Gow --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags v3: - Rebased to v6.9-rc2 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 Wed Apr 3 13:19:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616280 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0ABACCD1299 for ; Wed, 3 Apr 2024 14:34:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Y+xeKkT5WO1cYK64blBToKvZ24ASQQrZ5aWjfJWIerg=; b=HECLk9DmBcb303 Jh6T6QHjK2SngBbMHyAczs4gDrC7QE5q6zKDFucB1xbCvAo97KumQuXz20UJ4dvzlIb+Ti4tKIFgi BNQDigZjzstwCXwVO0WMhREYQb87qVbv5o0XcVmzhVKxA2St6VY1kcZYRWAJxONcHkjQZG4MQE1Fr oQlm502V9pxUgTdZEGa3jgI7L2t8VDoQu1WJ21s4YyccMoharJ/N3EHV+YIozbByvyFXqvV2vnq/Q TQRF/z4FbYi5iZz3JosPRfDA4Ly6dF23MX6pN8H0S2t/xeSzcHIljCEWnNNo/oGv4IL2i/ZGmbQ6Y Y7JGyMnV5/gQq0LPGevQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs1gz-0000000GUho-2C9i; Wed, 03 Apr 2024 14:34:21 +0000 Received: from mail-pl1-f172.google.com ([209.85.214.172]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0Wv-0000000G8We-2kVy; Wed, 03 Apr 2024 13:20:08 +0000 Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1e2987e9d06so3697335ad.2; Wed, 03 Apr 2024 06:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150391; x=1712755191; darn=lists.infradead.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=0HH3He2M5JGBbpn1IyUzwQbFpqNeS8i3zDjnB0NO5L0=; b=AJE3WnbGUhAwDJcB3ZG5ldW6A4tQjOwrz/14AwYD6oKv4BTvX+mBBX8gmkNVzPM1HN snn3T61q8V31n+X1fwriUtSqcC7Nmq61XwCzVcpuh3D2SGGqCUsO0gWmpEH4BcLn3lLv K+cJTNXD50Qnd42ruEVuasnXD7C6cx7EH4aDibvLQJNAiYDE7phyDBNBNj51JIkTSZzV cqlzRTYEjdI6azjYzMeCkf+AqUYTaaD02cGujF3HYXuS3YAvLNXy+DxVEoDj/7xs3uHu 3BbtiqBGVIJ0kQaFmIsvXcfnftml8GLxl30JtA76Cco9AAYygell20bMdIgOyhQ3T30h 2hzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150391; x=1712755191; 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=0HH3He2M5JGBbpn1IyUzwQbFpqNeS8i3zDjnB0NO5L0=; b=YpLPLWHeJk8wA7uYYxg1KVyxRdToE0vxTUlaaKTpeLZzhCz6j+3gSrUB/tJyNEplDI tyY88lVFltB0XzAHRxXB7HBkkK36ZnPb1CxJA+X/DyxH9rJ0aMWs9DlTIV2ZbwfAktJS gksVvRSufDHmREmBpnJeZJur/O+B78EOarOed0HjQ1JCWRp8cFcvhbG5VpRnaSxTC5Ku +YEvIx5ebdYXIwW3T4dV1E5Eca0SWjueAK/Cfbnm3vC/VE9bE4tT8scsofTf5GXoUmc1 OOAY9OKK5Pb5H7rfh830VmezSoQJ94sc2gbsFDku6n/4rTluNESpOHv329G8EGCi8Eu/ vsRw== X-Forwarded-Encrypted: i=1; AJvYcCXWzw7PKqADoWuDxJWkO2+HpxgIQ7nKPi7ZwfSR20nbPE5lZase92c29i9UUQuwUgDsbT30HQdN4H4IyFdpyHy3awvHDV9Y6ons6SpIwSVLejisEXziaEggtuLhULczG6bATB2lyTFwfye026MvhPQCMeTFQQM= X-Gm-Message-State: AOJu0YzPMss+MbtZjhDglvLgHIvktVRArmK+4noeJs2gmSisdM0SO2LB d3THAhmBxL43j3R68Suftj3kMzeg1CIq0WalVbwnYeoIm7DudtVs X-Google-Smtp-Source: AGHT+IGzp4oN8GRSo/9EyN0xy1NOVYsP3l70Car4fBvR2s7g6gbB9/O+yleAACI5/eSTY78txokLLg== X-Received: by 2002:a17:903:d1:b0:1e2:a177:d6b with SMTP id x17-20020a17090300d100b001e2a1770d6bmr229571plc.19.1712150391428; Wed, 03 Apr 2024 06:19:51 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h1-20020a170902b94100b001dd0c5d5227sm13149194pls.193.2024.04.03.06.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:19:50 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v3 05/15] drm: Suppress intentional warning backtraces in scaling unit tests Date: Wed, 3 Apr 2024 06:19:26 -0700 Message-Id: <20240403131936.787234-6-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_061954_154525_372BC30F X-CRM114-Status: GOOD ( 12.21 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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 and distraction from real problems. Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Acked-by: MaĆ­ra Canal Cc: Maarten Lankhorst Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags v3: - Rebased to v6.9-rc2 drivers/gpu/drm/tests/drm_rect_test.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c index 76332cd2ead8..66851769ee32 100644 --- a/drivers/gpu/drm/tests/drm_rect_test.c +++ b/drivers/gpu/drm/tests/drm_rect_test.c @@ -406,22 +406,38 @@ 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; + /* + * drm_rect_calc_hscale() generates a warning backtrace whenever bad + * parameters are passed to it. This affects all unit tests with an + * error code in expected_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; + /* + * drm_rect_calc_vscale() generates a warning backtrace whenever bad + * parameters are passed to it. This affects all unit tests with an + * error code in expected_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 Wed Apr 3 13:19:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616164 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20010CD128A for ; Wed, 3 Apr 2024 13:21:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iEynWLlYuKun9t0HGgrfFVr2zH7NKF+0DwXKVgggHpI=; b=h7lB2Z37aFxjbn bT8D6j0tsFPGvikQREzI5PIDIak6t3J04Lof3aFS8hHtzHAL+2O1bYzg9XPyIC+byXAkZGoKTfPhq YoIizqdFvSlahFAOOdvrnvbMSYTJNpgit2NbhMF0cAswRMQd6S0XWyI4+SnScimGkBUKm2ussv1EF mJKqJvAdAIFxXXSdOp+nOO0EW+Lo1nnyMqJVravFu5y3fmjk9X0QjrqP5/LIzc4JxDITHsONpgS4N KbsHKOv2t+0hF3VQ3eytoWNjxO9ZQDf5mOy/2tINC2QUwo1K7a4cDDSIZcIQeLppnideqJBCzPdGf KDcrjgf6567zAGUS3J4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0Xt-0000000G99g-17fZ; Wed, 03 Apr 2024 13:20:53 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XD-0000000G8kT-1QeH; Wed, 03 Apr 2024 13:20:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=MvARuQ+3VmnrmzgmqFSmVu3cd4NVfa8l1fZDGFIcUBg=; b=fzQ3Jy/5381FJy5Iy1LnGOhH8c I3jVPiozccnhl9J72qw/o7NDQxN3snuoE6RFH10H/Ip8jPaDYHECkOmdflzRqCZpUM7F6RdbSMQGm Mfx6kkUYf+47fdTc5GT0toqlxJvgPFZfnuP6sQcIqNjEhBWCqDBblCdYWXrRDGMkJH72xIpdTc+cV Ap0sYE/UD2PDXZHaVGdazk58vNcqTiaTf484zup3bRaTmJVWkj+Y5J+RC+k09pwK9XtnTXI4GtPE/ 42HvXstE0kibQrgZqTvkMacQDr4GZ8lh8AFeDE5j2ZAYd3sCHgtMdS2ARDdkp9+rIQwg57j23vTnJ AFEI0RPw==; Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XA-00000004EPd-0NO1; Wed, 03 Apr 2024 13:20:10 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6ecc9f0bdaaso1190513b3a.1; Wed, 03 Apr 2024 06:19:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150393; x=1712755193; darn=lists.infradead.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=MvARuQ+3VmnrmzgmqFSmVu3cd4NVfa8l1fZDGFIcUBg=; b=ANZNULJLj9jRuUlGDRpeuRH8WhvVhcSY5Vbr44M9wkDsT4p5gTR7+Ad7MR0qYYGw2k au5mGC0W1ydopBXq7d3bOE9AqFlB3+ertd3/hbfh5fVqrBJNnjZqK2CBeYC9XKAZZYNc Oi6Eikoihs3itel2psUyoUKSIkoEJyaKgrrTlmvulDxHKo1aaslod9xIQq7nMdzyi1pW ZC/2IOeBqYbtGBuRgSzHHBe0kXL34N5CPmujh1GAQ5dcHZrIob9CnN3UG1+FaPQMu2m0 40+QYnKqr5IlMtV823XKJHaCyIX1yAyJhPBPOTJ/rLQ1vwC3mXqPE66UVQsDsX+a7yfO DkwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150393; x=1712755193; 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=MvARuQ+3VmnrmzgmqFSmVu3cd4NVfa8l1fZDGFIcUBg=; b=KOFdxtZRkZY+bqr70Wq7fwimV56/xOb9pKEd7ShHvXKuzQnVreR68sAmYzYy8m+ZBi ms8t5exWHMx+vqLBJEFY0UZpQZfYZZQml2DBcSQi4DHP4nI/mHxEQxkeORe0q8ipq2rv kRSlt54DrdOfBxH5HFJhCcAT02KgTS9yNjZciTp3a8DNaheu9HazFtvbwrYfBxxHt5rB mKehTOxlhKgJsL5xXzxYLXW9m1x4s3ePuzKf6YFp248q/dDSJgSvgXLPQRIwMnyt5xb+ rq8ea92Urx4AtmrY5S+FG5YQDzBdBJQIZdSDxt1TxZiX3waoEfdc5oO2fJliTKMFYrpg ohug== X-Forwarded-Encrypted: i=1; AJvYcCVTClEwQpi8Ky5NZlBDjs0lqMVgkMlcw2bf3/xRmh0hGkZlX3qa7551ZolgM3sNOwDCbaRAJuolf7KF4IPGgKePkI8o5A9THw8u1Tvaw7ScqzEXB8H6domi5M/VFqHpqaAVicDjBiUu+DxB9Qh0dOTzMGKnRXs= X-Gm-Message-State: AOJu0Yx+aXKep8x9p6i2rCZTRoRBfJ646w2oKi5/fIu8tMR9OYfd5epV oVaJLx83morYb3/KkH1EoDqdxOGFdwNg1c/WcPoqwNtgVVJoANDS X-Google-Smtp-Source: AGHT+IFzkfgfwanXAd82f8i8ef5Fjpgbc/yneRFMHGOwV59qDNS3Awm153uRnJZYSeIbwOl4zm4JYA== X-Received: by 2002:a05:6a00:190b:b0:6ea:73d3:d3a with SMTP id y11-20020a056a00190b00b006ea73d30d3amr17312402pfi.22.1712150393007; Wed, 03 Apr 2024 06:19:53 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id j3-20020a62b603000000b006e56bf07483sm11720837pff.77.2024.04.03.06.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:19:52 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing , Jakub Kicinski , Eric Dumazet Subject: [PATCH v3 06/15] net: kunit: Suppress lock warning noise at end of dev_addr_lists tests Date: Wed, 3 Apr 2024 06:19:27 -0700 Message-Id: <20240403131936.787234-7-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_142008_289613_94C2C9D9 X-CRM114-Status: GOOD ( 13.88 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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 and distracting. 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. Tested-by: Linux Kernel Functional Testing Cc: David Gow Cc: Jakub Kicinski Cc: Eric Dumazet Acked-by: Dan Carpenter Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags v3: - Rebased to v6.9-rc2 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 Wed Apr 3 13:19:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616166 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3DBDCCD128A for ; Wed, 3 Apr 2024 13:21:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/NK4gc4WJJ8sGuMTZSd7AqUq63vA2juCx44Xgwv1zRs=; b=aIQHMMMrkF6eMs NonUgIpuXv3zsDkJh9vWad9IUhSiN4ItAjB7XeWDgpq99jJ4LmtcZHBfpyOLA05yYPVJsqj90xasP UCv/oWMVFRvrENYQKTD33qKbau11jRd1S0xeNjPP2UIQwisGP12I09X28vlpjVEefqaHGimtl1Ju4 wkeEQ/CqbWa0O6NIA+w+oQ1L+n8COmK6b+i9JNHeIkg+gxwcIjTo5OOvKa+9gPDgz3mL1PhBVRlcx au1zcp1IMOIrlhw3uvbAhZ3gHHWcS4bVwm+KbCEXTc2LfTj5uEEg6m60Agq7vT6dxqS2YT6OV6TFC FuqRUr9ABvY0w8tdhThQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0YM-0000000G9Xt-2Goo; Wed, 03 Apr 2024 13:21:22 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XE-0000000G8mE-3rAO; Wed, 03 Apr 2024 13:20:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=kz48OxP3NhYfgMKsflTw0/QUK/EsEKDn2LToBTsPHNQ=; b=mbPDIBX60VhJa1bfojsF8lI/21 Z/xE9JyRiEUiXnGb8Kxes9/BE/GzeuFPmQSgP8vbRuL82xaatkK0tTM7qe/Zphpz+k+dlbDRKjkzc oSIw8F5bn7BgtzdGJKkXMz/r80RflyuP/t7g5snLo7bkRKezbm9VDXe6DYnft/mkAN1kRjN7VGFXx 9HdbBReZf0M1c6EAgwpuMVy//u40hFTLGQKbqCYbrIQO7gyyrtsbp1oqH2JtXRYui2pjwItQLj3qc bfGt2OW1pFvKER06WWI47Ro3AO8cFUXivBduFeg8d+VZO0u5w2kFo+K3qGeds7/NPHQZdXcYA5vHP LKE3bTxw==; Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XA-00000004EPg-0UFX; Wed, 03 Apr 2024 13:20:11 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1e0d8403257so49723495ad.1; Wed, 03 Apr 2024 06:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150394; x=1712755194; darn=lists.infradead.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=kz48OxP3NhYfgMKsflTw0/QUK/EsEKDn2LToBTsPHNQ=; b=Rc1mVtCjqASFRDIQ5Bm6QFRB/z/v8RtA9Uth6yr5AuX9bAo/hOgN2/nlWC8iOWCsHG cArIS+P9WtgLXLKrLUfgBIziLnIb/s01h2MNAi6iULWQyYw92387HgNaKgdOI9vN7wai FK2fgHP/2Z4888G+0YkyfJPMNsiVQ73mp4futS8/iel1w82309CbsHj6t8Kw/+9zCLkA vVJ4FkOJp5CtDUXuWhfzsiW68Ci0vOsGvSHtTtEuIKNPzV6ylACcTStyfZTxImTRIudI lv4jRg4AQA66hM1QltJi5muqlOpVk9Eg34yUi2JtWwSQbrQcbg9OJQ/nM77y75RdPZVp bFRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150394; x=1712755194; 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=kz48OxP3NhYfgMKsflTw0/QUK/EsEKDn2LToBTsPHNQ=; b=iSdTG4AnhdJShZn/OAydfh0nLAMBoUKzFYGxCVAkGS+SKEaszUlbiNhBzQ9j94qQkz kbiZfJOijZ9+Pk87uPpMbzf9j158l2g7pWN24Y+BQRfLwG7axFJJ+k8q+LIEFMDtJ8no szFS+mHHsFVhaersTPu2FsE33PpO6kcXdPXyb0fjw7xrQJ+jqVuqT4HaMIA9dZj0QSnd vGTziANWpbVzYlEAQt3BLmKZYRtLfBUO8FYb/7xxZbBgp6Z3nZM0oyhZ5JMBimN6Ppjq c0usL6eAJ3OwDj5KDvZZC7ut6hC+DbaUnmvoJcpFvJtqQGzEel1hX+zowASnK6OGWwsx R+Xw== X-Forwarded-Encrypted: i=1; AJvYcCUta5ufmt63MIr3ElRXcQXXo/94BwRKNj5xarAHeuKQCWkUhwyOwcNJZte9bE643j5iDX8ckspd5JSwFwbvRM6kVuHlSXJ0ottn399dGgPxKAyJ9RsreRgakX0QVESKxV2YmbCA3fcwEYoKl0Bl0B/9TfLvuIw= X-Gm-Message-State: AOJu0YwQsnzdbYZolmtUk4iK32FOrK+r22w5ifKP1Th2bRRUxP2BV0dH /zmwfiKYng4LNFt7d63Imx13+bHoH/4madvutbo1tOZwz6l8gCox X-Google-Smtp-Source: AGHT+IFNgcjVYp4BARBLtJXFan7xr/0CnX1zHuDDo3GwnVh2w9uqbZMBPA/s2jR8/t1K3n7W3FEYHw== X-Received: by 2002:a17:902:ec8b:b0:1e2:2e93:10ef with SMTP id x11-20020a170902ec8b00b001e22e9310efmr15831594plg.52.1712150394590; Wed, 03 Apr 2024 06:19:54 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h4-20020a170902704400b001e26e1e62f9sm3840318plt.176.2024.04.03.06.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:19:54 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Subject: [PATCH v3 07/15] x86: Add support for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:28 -0700 Message-Id: <20240403131936.787234-8-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_142008_291680_79F0EFCB X-CRM114-Status: GOOD ( 13.30 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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_SUPPRESS_BACKTRACE 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). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2 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..7698dfa74c98 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -23,18 +23,28 @@ #ifdef CONFIG_DEBUG_BUGVERBOSE +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# 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 /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + #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 Wed Apr 3 13:19:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB2C2CD1292 for ; Wed, 3 Apr 2024 14:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3fDXUBJa+Jp+bcrqxSwP4xHA7+OYfr7LRBL+90jMnE0=; b=tPwUiFc1w1ql9J ELXX6BFhMd/pKMqf2kCiWLHPKX0iAwI+OC7fx1QzWs+UtiwXBs8dve5b349u9pRdsDhcQZX+nXx20 0mofzCzq6JoUWgOcPsQza+MMpTzLvA7yYkUAo8KGHIRPtl130hFInj1KeSabOCrfA9AVgeCCEin5g mzOZlPhZMWmWzhYUnzHG9vAbSjIr9+QsrXBzBxUzhNQRPt34Sc9/Jeg4yP4xnhxqnhMdlm4kipTK0 dXIaS0CG2/XmRVlUQJThZIIvcJ1iIy/InLbZaxTNdEnaBpt3TeTBZCw/5oZr8cxMwSIvovKLdV8az KSg3sa/ySv1KQDoJKIjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs1gy-0000000GUh9-2KPF; Wed, 03 Apr 2024 14:34:20 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0Wz-0000000G8ah-2HWx; Wed, 03 Apr 2024 13:20:08 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1e0ae065d24so53957225ad.1; Wed, 03 Apr 2024 06:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150396; x=1712755196; darn=lists.infradead.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=xkb1tQP+RY53Yd+dTVS3E48OfxPMmEiIEhGf0kaureE=; b=Yw9wSpv6d7JBRz1dPwCmXO1nSxUOo36wcucsMqTOfV2Xvf7M2rsG1XwS6xCdiES55L ivkujMg+AE+BeHedm5yWz3cdNoTyIlRJQ/PAUos4E+TjDjel4sbz9AW0JDHtpq9YYyVX OqZyfCvvXluKyAwHajKj1c9sot9ptaICVD3zuUJCc7VF2T84dZrGv8cWdUOjx6HW7G9s yZWwN8kBcM9BdhThZALPUzWLzthsmwm/yQ8vxm0Lwb6HiGvksMgtIi05wNpzcR/X1sIe JL6eq4fQOhPNySTpEfC48PGnFi+SgoN2AgK1WdBMv4H9Yho3H16XST6Y/zz4ussXpa4R u2UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150396; x=1712755196; 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=xkb1tQP+RY53Yd+dTVS3E48OfxPMmEiIEhGf0kaureE=; b=JVpDtEAQrzU0oevquGRTOJ1NwLjIPSzJaxgIGB4xLiQcUu5sRxFCgoXwWxdFfPzdao HWptXXsOMHIv97mMRhMxeM/xOINzLmQuhC8Z6p7Gjel0a+8AnwI9I0eBH+L57ZoQbgYo ApWALjMKHYg5PxlahCa8mN6bNlpxPkMtI2BKzbXwar/ecaApujK0bz3tZIL9os1PbY/i SG5Fe5u8atFEcxVmLKOPUzQJERZfpkcVqCtke1Ae7k2MYTpfVjR++0CwSJ/beYH7wBDW Fpeh1suDsDU9NryDBhVp9QceUhntpWqF2f/L7iWH/ku7TisBlZQH32IRrHTiNH8+uAiW JDMw== X-Forwarded-Encrypted: i=1; AJvYcCXzvgdhc2wR3oFKR/lO5W28Mmhimb/aYDWcCNIBvnxOwqrTcyS+Z0Krwc1xTf7CJbNOp+v3zDsAJsbA/3tIrmJNfwD4WenIj+A/a/CPIqxgcd5dG4sTjTBSzwa9/bdGoP16kvOphsPjeG3OXFyo+BS2kNMwiZQ= X-Gm-Message-State: AOJu0Yw7cWwr7Yq4StJgzppPNdNIzbHu0NcFpKjANgA2Le38N/5NlyyH TZ3WrF87rSS49oLMmVPQtZ2KlY8UPFUq0H+VI4Ca4+fiD4J6E5/By0k7SHuS X-Google-Smtp-Source: AGHT+IEFIYqOYVWwVKGxmRZLqxD45VjqdbvtvChfTBAzSn1B79yxhWl03nHs5HLMNlC5fEEyMMkQQQ== X-Received: by 2002:a17:903:249:b0:1e0:1486:e808 with SMTP id j9-20020a170903024900b001e01486e808mr16191679plh.13.1712150396344; Wed, 03 Apr 2024 06:19:56 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001e02875930asm13195748plh.25.2024.04.03.06.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:19:55 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing , Catalin Marinas , Will Deacon Subject: [PATCH v3 08/15] arm64: Add support for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:29 -0700 Message-Id: <20240403131936.787234-9-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_061958_062060_674033DC X-CRM114-Status: GOOD ( 13.93 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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_SUPPRESS_BACKTRACE 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). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Cc: Catalin Marinas Cc: Will Deacon Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2 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..c6d22e3cd840 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) \ + +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# 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 Wed Apr 3 13:19:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616282 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 71173CD1288 for ; Wed, 3 Apr 2024 14:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iF71KwmCcHsn7sJ2JB2DuORFFzmgTjHdnvterkJZ3wg=; b=mplcMLEb4iBgdX VVPIHqWYzmPucBfMWtBymrMAsOuuiyWPVXMXQ35dnlU2ccdzaDJOoDV8sdzyBrKZtEIy1XWxAARGR Zk/7vtVsYSU7K8YIrHuMQWwZQmnrajvZxmmYVKpUCdLGs3tq9rbp2BmuF38JIWosBxwc68oc9xk7y kuFymHngdyuDnpJ8WqYoZveU/4UM/YaI6AnYSPUnDodoCv0WaEd9OrQWamRLaAiX9lw7YpNRjx73O Xdbibqf6dYlzEivSsVkdIOWMSsjtBrzcMuyckzHiv3g2kGSj/qeH0LUW3fiE6/C1UkzdJpx9WoHTh PFoDuV4eQ3wylXqcBd2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs1h3-0000000GUki-1M25; Wed, 03 Apr 2024 14:34:25 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XG-0000000G8nA-2HdT; Wed, 03 Apr 2024 13:20:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=W4Cw0LtOjrrGR/zeu8wuFTPQ/EpLq4I/3itsXmN/APU=; b=aIJKuzkx3FnUC8PlPLx+HibinQ S33j/uCrXl/jLqYanw33iaSMGpLR4JQyplkNB67H7rQtgptXljCiwR8l77k5AYKFt5cR/9lnN8Wsu YJjuq3PfvpTtLIBhcN9zVa9l5R3LV7LrP2lnr/nGC0sUSWJI15/HBdUUjkorOv+w92KzvQJ9TJsGR 9KFBdgQ97kSNMH5tPNgxbMrZaJcC7U7v+cmVv/fXv24DMaW+i2v2krMLb338+WQPZFyOwLlD89LT+ q4F0QesKkLj7BJczq/gt0LBjmodSuTj7EOSCXTuCxgbldXHSTQTbkAuhkZ+0tXQTgtPDlkQ38MLVI fZRl/uPQ==; Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XB-00000005eVi-0JIC; Wed, 03 Apr 2024 13:20:13 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1e2235c630aso29583505ad.2; Wed, 03 Apr 2024 06:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150398; x=1712755198; darn=lists.infradead.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=W4Cw0LtOjrrGR/zeu8wuFTPQ/EpLq4I/3itsXmN/APU=; b=XQIf6wdHLOuc6Cnm4OfYlnkIaeoNdkTm+mrj1wTGG2SWVa69Gj+a7BTMhPNYoTLa3G e2iHDcANgzxsRNy3h3BOLOdZowuy0pL8UfWrv6VSs0X39RJDjENS4L4GR1Mu38P+93Kt I3YxaTxohYHk2zf9NmWj5l8sy0B5+IBNIWqDqefzVw7qhkv7vHAwAdu7k1JwrCKQXpGY /fOwKVCwLxvpjfRtPWdj+OpHcHQ7XTPlbFw6Lt5C2oa0vpA/Wbzc+bRI4ImJbiVZTL26 OfLcDbJn/J+0HbH00n0FGu1crMQ+awM/mQ9ff9pVfpu+voAjTLaZNzdXiz0SmAIhCJqP ryZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150398; x=1712755198; 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=W4Cw0LtOjrrGR/zeu8wuFTPQ/EpLq4I/3itsXmN/APU=; b=Sz5gfHMdW+pp3tH9jFbCfgeBCMjkX8HqiA9Hbt+9xJjoHzghghML9V+TwbHFUMYzlI zgdvJq2Je8F4QUK8vGNZOEVtZM5exTOZkH2TWUC3h7yXQYLQraRLAnQEb45bQYWwwHAZ aPoXfn/gDyUNyMW5HxNozRxtP40kbe1yd11Q9+Ht1wlHfxq4QNsQu+9yGQibhT41l4PB Ag7kqtke2D6ahqg8KNcFwadPymAIkIo2ItFCbKAXhA7qH4b2lWYvKhyQx+KGqGSssrAv ZxVd7oHdlSGjICYyJLITI4VApay3mpgqNAV1mUQDd4uYq9DKvj1CmV52d2tl+J0wC71q Usfg== X-Forwarded-Encrypted: i=1; AJvYcCV+6YScKDpm8uyWFVGXmE/9aIC/rqksHFrBeqyDrLggLviJ3qSHzQ79Eqp8ykOyS/eXlvegSJa0MUd88bXpm2Vsxo8M9H9H98k2h47pJBN95SxzgZE82PKIWxAkeiZUoWDo4doxgcTd8WxLkiqXWUhofPAWmIc= X-Gm-Message-State: AOJu0YxHKpaaiigv8MOFLo4AVIfB/TPOzb5czienHtGNr6YqcFNttTsp FefdpqhSh4z31C+o6Jhq2kn5MFeNfk2mcI1JtgOIBcRTKkErxbuc X-Google-Smtp-Source: AGHT+IFWFkTPmr0egylKtq40e/om3PfbjESX8Y3agDhfM9FAMg7tTYjJ0Fk7T/XrXLnOhqzCRkHQ4g== X-Received: by 2002:a17:903:41c4:b0:1e0:a0d5:1d23 with SMTP id u4-20020a17090341c400b001e0a0d51d23mr17965782ple.29.1712150397884; Wed, 03 Apr 2024 06:19:57 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id i10-20020a17090332ca00b001e0f504a74csm13199577plr.269.2024.04.03.06.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:19:57 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing , Huacai Chen Subject: [PATCH v3 09/15] loongarch: Add support for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:30 -0700 Message-Id: <20240403131936.787234-10-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_142009_161515_37E3F51B X-CRM114-Status: GOOD ( 13.39 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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_SUPPRESS_BACKTRACE 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). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Cc: Huacai Chen Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1; resolved context conflict - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2; resolved context conflict 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 08388876ade4..193f396d81a0 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) \ +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR(func) .long func - .; +#else +# define __BUG_FUNC_PTR(func) +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + +#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)); \ annotate_reachable(); \ instrumentation_end(); \ } while (0) From patchwork Wed Apr 3 13:19:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBD94CD1292 for ; Wed, 3 Apr 2024 13:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fVp4zkEps1P0+fuWCDeOBC1Q74OBc1AOtQXmdK5YVU8=; b=q+a1z417ffvm89 xUWmMrctS9RuRVMatrUFuDQzi+yAwzuP1IeVK1dAim6UMI2IsmCJYBIoclQ3ZEhusMcAyFli/Pd9z vKzhgFAaVAhdFG68iCuyZEzHGDrbpGgHU56N7ovXwkVRTCiok4q7Biqa4LkJrU40We7i8E96rTAXO fq6UJWyP/VKPANzPBEsyWwFjECngFciefvw2XTmBKt3GY2ajOjRxoAFXYjR+iSzZ8Jcfbtk6CjCae UNh8DdaHLyg6Y+Gb6HHQXHtNIyODf2HsVTuHuTdYh8Gww1mHgVBCm8u2w+VPq4R4ZQ8jJ2RBd863j 2pW+rfAU+SQzIBzpJYfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0YG-0000000G9TK-2vg4; Wed, 03 Apr 2024 13:21:16 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XE-0000000G8mF-3w7H; Wed, 03 Apr 2024 13:20:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=9dfx4BAIsIiEeZYorwHVQiaeI+Aj0IBngtjLPvcVHyE=; b=et5/SWhTtjRtFkgEM+Xi5XaquY lEh2uEOQ1+/kPO7BHbtrih+2rnUsGpMh1kNzLKQPj9+jmdjSaNxaSXmPFZ23ZPlPHHH+giLZ9ExpM SkX5o2gb0ciKSNr8j2sVCKEa8F0+y3feQda6uu3crk12tpvSuW++OdoL2eHk52ePBIhlcIFmkP8Z8 H3Tcxz6XWTMJhTm4gOXnnLJs9NkF6l43VBUzGK/KrfKr1SKa5BuUIfm9wdyR3ez+289iKkD/jvHX7 pBm39e8HcLjHbHu7GK4EqAs9inFLXGSss9nNLyDAgOAnKAt4TJlRvuVGG2VGx0hvaPyjbX0pTCyht G07yGMcw==; Received: from mail-pl1-f173.google.com ([209.85.214.173]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XA-00000004ERK-0NQt; Wed, 03 Apr 2024 13:20:11 +0000 Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1e28be94d32so8110655ad.0; Wed, 03 Apr 2024 06:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150399; x=1712755199; darn=lists.infradead.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=9dfx4BAIsIiEeZYorwHVQiaeI+Aj0IBngtjLPvcVHyE=; b=HGbhRvyo7y68rs5nwbuWExAYODQ4Se1Gw11PxAwwp0cJCImB3LdOaknIa9x81XoE33 tVq7qNjelQ8WZMLwP1rkmRqaKkUS9Bj+B7VR0BL90GI+bBcnQk2MFrjH7zxWLRfos0lO ZMVK4IIvNOW4iyR3WFYQ8skamgaW4Pbcf4bSVVc29g94fiXegapRzZ5OCWSii7mNp4Ft Cvp9uQ1YQDALbfnMnoDOUPCr1AojiXaJcYPSpkb3x2REwukK6mDrHjHy1JWwiASfScJ8 KYPGWTv01B1gtW641SV4IPKJm2vHQpcVbv9Tum8bXO+i5+xN0NCaqT5YoV0HLx14XL0/ 9kNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150399; x=1712755199; 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=9dfx4BAIsIiEeZYorwHVQiaeI+Aj0IBngtjLPvcVHyE=; b=s7O9Lxx5zOAocyDjP42+sW3vrQfD6hRt2m5fLr8IuPbEvD8Y6Kfgi3oBaJ8l27KST1 8NNIiSontWwFpyEnkNXyrpZ6FAsPmXNEAXk/NQWRBkFjrJrv2r2TIVDQima6bn3JJxv7 6tIY5yEx8hnvkODn6fMKl/LOitxkvhMYXIa5a+/bAYp9Z1rSmgQIEvLII+BAT70poI05 bpxmFTjbpLBXTlnKb8Pbsy2pTgMX7OHLXUOkq3a2gSR7pu5Zkr39ijAymFKO5vyRLCky cz0UMHAvvMu3fo+lrJP+y9LABH5bKCr3pv4VtowNpkoLkDyzeb/dLZ2qpgCb4qVi61hL O3+Q== X-Forwarded-Encrypted: i=1; AJvYcCWCDLjAJKzFWPfDZwLNit6LZef8WLKZSj/LPZMYnEXHljR5lnpq9kjiiW93q89+Xfb84ulPgpyWYy8UL2c48Gb+Te1CD6XhjuUCwrM33LmAgBg8zXnVUiUIstTu9YjljgMti6EWoxEDfGAyQdbI933Ea6370UI= X-Gm-Message-State: AOJu0YwuqlBS9NyODlv189tI5rYN6xsXUJQyX9RVOpQVCERv2Vcboupc zlq3G7JuZ8xtle4Uyhn85w0k7UeGbzSdtVTzqWTkOZG4NCVOlurP X-Google-Smtp-Source: AGHT+IGbWkjRTcooZ5OE5cFx+wdKtwDNdTLrjwriJaWh51uLS/GGpEV8fzA7vGhwR64nNp+19Aq+wg== X-Received: by 2002:a17:902:d4c4:b0:1e2:a0cf:c3dd with SMTP id o4-20020a170902d4c400b001e2a0cfc3ddmr376556plg.7.1712150399532; Wed, 03 Apr 2024 06:19:59 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id l11-20020a170903120b00b001dddaa7d046sm13268622plh.29.2024.04.03.06.19.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:19:58 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing , Helge Deller Subject: [PATCH v3 10/15] parisc: Add support for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:31 -0700 Message-Id: <20240403131936.787234-11-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_142008_318595_808085BD X-CRM114-Status: GOOD ( 11.35 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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_SUPPRESS_BACKTRACE 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. Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Acked-by: Helge Deller Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2 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..b59c3f7380bf 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 + +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# 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 /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + #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 Wed Apr 3 13:19:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6C3FCD1299 for ; Wed, 3 Apr 2024 14:34:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hk9Pd6OlrptQsWDIIQkGneLZHwPp7drNtmqIEMvwkVU=; b=yJaKh35uhHxP2+ hbsGuF10oHG5z0qyeSgoInwTb/8SnR059ItchRRv32r4rgi9TV3qGynyjSUKJqfOAoGMXrqaXZzPG kFNbSRmFSFQYv3O+1ENAFnSaWyg+dl5GFLK4UOxUhqFDzbUePyL/8y5TSmx00Ct7G/xyO59By6hQZ 4FWs8YkJJnM9yyYojBKXZyyHnppWpaBbexmGzCXMULsBH9wVaaHBh/l/fJLMt6F2Wf5c4Fej62GKH JpUFqdRX7aIb9I88pPbKRYMhml1jEFy6ogkjTA3g4p/pBeYE7k1wFtRRlzT8h/M7L9+/domKeTTYh DZWiOnI3BAtjGuhmWXfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs1h2-0000000GUjx-13Cy; Wed, 03 Apr 2024 14:34:24 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XL-0000000G8oR-2k9O; Wed, 03 Apr 2024 13:20:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=klYg8xMT6MjrhYgIxkpLnDg0Lyaa6cQfR4UsA0LeN2U=; b=KtW5y69+iG8tbxhN4I5ZXswFex OZzS7WKoma5JOcfY/OU0Qj7g/RRRX56keB5IPzIkt6fsCb48MKWMmnwokXpIdMolX7FQlGCTJnB2d X1EPn00DpddxDLTeCEDyKhayfPHnG+UwUhHDyhG1ytKBnmpU57L48fUBQFfHHwoj3LdG8JdnvrcBC s1HKA090wDmU22H439UukEdMRVhrP3tNx6XOEZAJS1GNZFIVGyohRjPeLgibTGcKu2OoAtGNNiijs RaiwFo5wp2JdmPPl94NTJtdN+vC/idO/jSV/0zm2Zv4gBch8x8D+CxamtMBWCDtZ0qwHYqOLYFNU2 nnVvRhNA==; Received: from mail-pl1-f176.google.com ([209.85.214.176]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XH-00000004ESF-180Y; Wed, 03 Apr 2024 13:20:18 +0000 Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1e0ae065d24so53957995ad.1; Wed, 03 Apr 2024 06:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150401; x=1712755201; darn=lists.infradead.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=klYg8xMT6MjrhYgIxkpLnDg0Lyaa6cQfR4UsA0LeN2U=; b=kM9SkMmG24nJVJUaWNKfsesXQN4RCAwzv1Ng1kYzuQXKaqPJjXNE55J9bl+84P8gRB me5HVjBwa8xR3+MaXzQO5Zgos5D66kjDEJYrk/e4MLXKW2toO1Vp8lTjH5SBzCjvw9+F vN7xOCmO4wxU7wB03tJLPO1kGOwLimkQE1z3eyG72RZc+ZD4KkM8bQeFcydRmsr8QeDd rM/b2gtCIt6O5JD3ufQjyRh4fCiHEs/q1Ln6xXjMhSuojfNI2/gcmsE0A6BihjunwPzv +Pa+RpthUC26qC6LAizzthbdlBiWze61mkm5ieTWLn1XG0mYMCeIzO/8+IV3/8IkUJ3G 27VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150401; x=1712755201; 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=klYg8xMT6MjrhYgIxkpLnDg0Lyaa6cQfR4UsA0LeN2U=; b=fvO2hDHD8bcrxTYchO9Q+QPp3tlqSfO+/BrewfwJTp4Q3O6O4+CjImdVhdnuSxEV7g o5fVnDmFn2VDbGcEfVBEk+LYc4BclTfTXhra6Rp2731aeNblwXJ6+5TwS4ZV9o5x5LO1 DES1KCzHkzOz85IBNWbyxMe9WjAuGD6sLJ5SBc0nCIc7L7OXr49G/vQUtgCaPRA/gk1p +yCPrXIjbPCjsmwja0HDIeHOTfZHDXn4lvYK0eAi0NnIDcEajviNpBCnyknAbaNRhQP3 14UN97CjFcFg42hn3HBngbLw32hRf8gigh0WbG6amTsmIjtXVm4cepEOikIbrJEQij+G 2LYg== X-Forwarded-Encrypted: i=1; AJvYcCU9dnok916t6pL6tQzrIccIsUm35bkG7tr+5LEomvAj1ZI/mFEkH5vZJwQ1uhhZJCNhNf9C4STyK9AXtL5FyakABuw7VfU8GtATsz2i3Yyc7qUmS5tka38GsymSabp4EavCKJ+egS8oiSwrkccNbPr33Jja5A8= X-Gm-Message-State: AOJu0YzJnJXvQx4M0jCH/Vjh7hrIMDZdxQSyCCt1vubfjF5TW5ynDWZD 9IU+TQSd4vsPKM0uL/CgbWQ0dgiwg6/SKjizYVW0cEebwrEQ2uru X-Google-Smtp-Source: AGHT+IEMqe589WW9yt5k/lfzrxxoDYVpXeSOxtyZyHF9LDTCjhOnJNt1j89G1vs1iICWdJ7uWy226Q== X-Received: by 2002:a17:902:bb16:b0:1e0:b871:53f1 with SMTP id im22-20020a170902bb1600b001e0b87153f1mr12301982plb.31.1712150401114; Wed, 03 Apr 2024 06:20:01 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id x3-20020a170902a38300b001e2461c52c6sm9309915pla.149.2024.04.03.06.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:20:00 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing , Heiko Carstens , Vasily Gorbik , Alexander Gordeev Subject: [PATCH v3 11/15] s390: Add support for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:32 -0700 Message-Id: <20240403131936.787234-12-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_142015_602328_0362D4F6 X-CRM114-Status: GOOD ( 12.27 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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_SUPPRESS_BACKTRACE 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). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1 (simplified assembler changes after upstream commit 3938490e78f4 ("s390/bug: remove entry size from __bug_table section") - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2 arch/s390/include/asm/bug.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h index c500d45fb465..44d4e9f24ae0 100644 --- a/arch/s390/include/asm/bug.h +++ b/arch/s390/include/asm/bug.h @@ -8,6 +8,15 @@ #ifdef CONFIG_DEBUG_BUGVERBOSE +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# 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 /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + #define __EMIT_BUG(x) do { \ asm_inline volatile( \ "0: mc 0,0\n" \ @@ -17,10 +26,12 @@ ".section __bug_table,\"aw\"\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 Wed Apr 3 13:19:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28B5BCD128A for ; Wed, 3 Apr 2024 13:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jcjBrCHKEJp1m+DMER0m9trfSEylWJub97IdAqz/jow=; b=KyNmqSg/rfpYvu AzwyEbVykp1jxDE48uEqrXmslTW6FlCafsOuLzha0ZwNjEbc8r4O/ci+/cmgZYVgoU/cD5v6URwzZ 9+KJEpahbK9uSAfENGD8wORZVEng3xbPht8FNYanGYEZTtSaxDNrqAJyQqxbtfE/trkeDpGdR5Jh2 ivsqIuSc9BUzuMk2otWN/drs7r6JelXhyldCjmTHh3b1b6i+eIHjqR52kjaReKU7wUzj8TACtrXOa jL1fy2jcBFYpE3dvoBQESGCstHKcbr0deXN67Zi4QBxNtJ9ISDsnOiO+800E0QZa7DcINKh8rggJB l8g6+JrTSAbzQoC2gjHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0YX-0000000G9hQ-05Ul; Wed, 03 Apr 2024 13:21:33 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XI-0000000G8nb-1Wxe; Wed, 03 Apr 2024 13:20:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=acDD7oYfD3QQ420QQJRR06Qs6MsGb4dTYH+kiSwK7vU=; b=IAPInJyOb5j8f6gBTcqim8FtOk NnG3uqTM3Frj7r7G4OmGakQrbYo5Jkko1y4QAZPEFu8obAz321M+spMMvomIV91Q4h+eCIRXabqC1 2jJe/WquDFqQ8eqoFs54M4LGQdmSlJho2KUSdWOFNbaUCV8kfs0S83u0cFW+Nf/VJf0p9CQb1V+w7 qLc7/RkmmKQFDRVHduJZuike93PIkhBZRP1tZIc6M+ilJtpTn6yD/vWZ4NSTfDvs51VOAcZ6DfKz+ eNPDGJCv7IkECH475UJbJs27eF7/bK7OO1hujsmgvkEg1OuteREdHeNWWCc76vn7H37n3loHy/x3I 6WQ2Wbpw==; Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XB-00000005eWQ-0QNs; Wed, 03 Apr 2024 13:20:15 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6e6bee809b8so5980729b3a.1; Wed, 03 Apr 2024 06:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150403; x=1712755203; darn=lists.infradead.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=acDD7oYfD3QQ420QQJRR06Qs6MsGb4dTYH+kiSwK7vU=; b=DbPmfoLYc/SUogg2TMO+vdJegvOdTRm2qyDpr0EtuwHaB5BSNIf8SIxZlYEwR33SPs hH7RkVubc4pjBg+pRLjgxdIfBEc0ETMdfEibOTeFWpDzeH5YsR4U3TX/eyF+AdDhoofz nrUiEUxF+eKmMdV9uSKszTlAl14Jekgxp2XeUVz0Bgi1rS2o9fLk38ThfpfDvgqD+7A4 DM6Be+slwXE7Orsqz92V+QXgxRr0IqN8GkVD07/VXUbSmgancdaB9qgpe/eVRec2NNt8 b8QNvK2aWo/rC8GoDHxgc5DDnXgL1VxSkNvOR+nvN6mcwejAM1s337O1KbaEkIewvCXM a8cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150403; x=1712755203; 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=acDD7oYfD3QQ420QQJRR06Qs6MsGb4dTYH+kiSwK7vU=; b=Pry9kjywV1aYxxu9D/L8dlFQzzpntIn+vxFQHH2OkgKQ/7ktgjLE2jZKclJNL365jD fuq07MrcRS0Jk/69BTDJ4PcS4LwsH2b+kFJ+spjkWZB4xn5dMnm+oQot4BfCDicphaCU djQd85sxadl2+aBqNE+TKGr1fTjhGwt6xqreXM/rNnnoUaBYtjekdLF+YEwRvWq/UsBV eqaXlzn7COk1VkLZgCtidp3Gg42z+JelqdBEHPEwB7JakUeDBCvo96OEq+BY3EifMBFb A/HQI0GM5sEhtjFrumUoOXLbUHRBS8t+p6bnrZUCBwBcXhOYM3ENVR8HdXuiLQgWAtaf PCfA== X-Forwarded-Encrypted: i=1; AJvYcCV1lXBZkceeJXCH4dsZQAVJx0mFTuUR7RBDxyhsb/IGdrewYa6NaV6qMSbvvV57Tdm3aEQHR6/zRbk+7w/adSCKUPstQKhhdtQNiM+Bi4ZZBst6LitPDXbfeXv5ftWZOyX1TSdQaqbR+TmOv7nsL18d3uA0mcU= X-Gm-Message-State: AOJu0YzzXYDPXkGjD89tAPKFpiasRtgKVnwznTtAUITUxITsGUXDwAdt MskeKwZvzFr/JClIA8EZdKs/WlXNrhbp4cAEfYvs+jaFdgwZ5pQk X-Google-Smtp-Source: AGHT+IH8rm/3VYkllAG+Ph/J3KijfrTneW29i0jWUjHAEJZozpI7yZ7ux/mQaa8T08FdPB1wOfWR4w== X-Received: by 2002:a05:6a00:21cf:b0:6ea:c9c3:94a5 with SMTP id t15-20020a056a0021cf00b006eac9c394a5mr19496685pfj.0.1712150402646; Wed, 03 Apr 2024 06:20:02 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id u32-20020a634720000000b005e838955bc4sm11440044pga.58.2024.04.03.06.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:20:02 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz Subject: [PATCH v3 12/15] sh: Add support for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:33 -0700 Message-Id: <20240403131936.787234-13-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_142009_209201_5EE88428 X-CRM114-Status: GOOD ( 13.13 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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_SUPPRESS_BACKTRACE 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). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Cc: Yoshinori Sato Cc: Rich Felker Cc: John Paul Adrian Glaubitz Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2 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..470ce6567d20 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 + +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR "\t.long %O2\n" +#else +# define __BUG_FUNC_PTR +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + #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 Wed Apr 3 13:19:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616168 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2898CD1288 for ; Wed, 3 Apr 2024 13:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OqCywzCmnJJw2KoYjd8bxGnSu9qAeh+IZLME3qG1iYQ=; b=Sx4I+9iTMFSPvQ l4mU0Z0cTd8XbqgKI4hSxiI/O6Ri9EfNDh8dHWHakMcds64fB30LhUseRI1rcuAYKmJc/NwufiPqW DDtkFtiUQ2T3nBOnTvkp13cRDQsrycx2FCWeJR071otItBD6Xu7VLIxW193FdNJy2ly7tgsmWkP8p mWT07rsXrAaTKZ15uGXKemv7LKJ+iw+bCsX7o+RUA+gG37lpWxsjmoamVERm0cU1j5ivgS61VWDZZ Yjz2ovqLr2gbsPWcoBm5OVmtm+76vQwZjonfuxPmHeOmTLiN0Wcez6pW7HjUkE2fSQyTMoGQG98zw tvNJ2HFZXN3h+RelDp8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0Yf-0000000G9oK-2jee; Wed, 03 Apr 2024 13:21:41 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XF-0000000G8mI-2u0r; Wed, 03 Apr 2024 13:20:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=cRPOdz6AnxublM7n3KmjYybYhLan42asyWOmMDzsw+o=; b=GBDcDp+ly3uACKwmnqVq3Pzc2W xfxq5cGJuEBeqpq9BJHsRQXrbg9RmYySh543zoUhBmjmjgwL+IW9a6PYZdHQ7lBN2n8/rpXqBTbpE 3iK0kHBC2pbz4MkOmSf8odtJe3ewTaJ1HB0bi1DKDW94XJhbH9kyHneVlXBSwDRhrvHJm9Lh/Mwgx LI5sZR1XXBNm4F+Zzo6MTxCJnEVIAvo+4e2irov0uoQMJuKb78xPEeOyT5i5Ty6S8/2+4Mg/dgPoN f6A/X3DDTo9yw0/Q0E/ZRORE7e43Fx4phxwHBJ9MdMGOQfmbLB4AhoSM+TQd4hOP8YwVbZLMFozdN ey/vWfxw==; Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0XA-00000005eWX-43p7; Wed, 03 Apr 2024 13:20:12 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1e27c303573so13522905ad.3; Wed, 03 Apr 2024 06:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150404; x=1712755204; darn=lists.infradead.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=cRPOdz6AnxublM7n3KmjYybYhLan42asyWOmMDzsw+o=; b=cLhb9uJ20UEOCu3HqctWjUf3+2ggpQ5sH5ZuYbdG4QFQ2PAdcevvW1411OmbPK5OtP T68js+3z/NHi23lZDP+CxI4q/lGbVPl9WckEsiEEMZUOt7KMZo4g1I/JXJHdvv+bGh8Q ZzVu5xM4W+xL1nOS0IwH8e9FbFY8I916+wmwy0WHSGTNtIdUTI+WN9wr2wubH8/v58P6 995z5WNPVust45zVSOJi+5pnH826eHP8+V6VCbJZCYGj4taNkQa0zmFCRoOpVMcJ7+qC Wismnug2KxOhjbkh+aAXnK6NqkIdOpjx7qX/8iUH68oSatKdfMucFHALE5EYjUpfs1Fs 9cww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150404; x=1712755204; 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=cRPOdz6AnxublM7n3KmjYybYhLan42asyWOmMDzsw+o=; b=mJPNWK0LHHtYJO6ajvYvRlihqR6CJNfQ/JucaBhZnwCbCjtKhsjArqPQFvtuXRmZZH nbSft14Wpjav63Q9KRQ2qMFAoHrn5J78zZVGTxhOBGWGWwrs5x0fJzNdE6Q5tO+QoIKa dBOU1NZEsBBg/WMmCvXkix14P/X3RATeCJMWL9tlEtf3t3KlHaCnV2frsh0lGzCUIZmN QZnLoRqaiaJUYjPt9OAy/blkaRvVGSqxLPoI+5A4HWQcdCjq2hMAwfVqYWf3teHKtUe+ YgEuyQ/rsK70fJrXSoO/B1zi2YRAPPTWKfZtX+JjfAjAaY7jeNDj9pvYgA1gnloqsS7M rPPw== X-Forwarded-Encrypted: i=1; AJvYcCVMgtesJ4r7eJ9Ksb/KfsBmXjTOAhwtY7bO2iFt2sINUp7bd4xtih64KFfwE0xYf94ImMQ9wkfZoDulupr8J6eHo1cf6lC3LcXKE1VeuuTuNSFMr9vA68hFWN3KmwsW2taI0psajW/pxSkPZW7cwIM/UhhodOM= X-Gm-Message-State: AOJu0YwY1zCQoZ1MayW1E8Dxx9Ih7d9djRsohQH5EzRWNb4JSJxabqpI gcJwUSc/i7dooRMjKdGJv1M18U7QXZVVg6kAG57OtSOT7NnxVCG3 X-Google-Smtp-Source: AGHT+IGx8oRVikcJmoZrmV6I1PpggSRavr/G5SNCkYR+IkJlaqrk2wHgg+ZazQ8Nymmw82Dh4v/u5A== X-Received: by 2002:a17:903:32cc:b0:1e2:2d0c:fef0 with SMTP id i12-20020a17090332cc00b001e22d0cfef0mr17310539plr.48.1712150404272; Wed, 03 Apr 2024 06:20:04 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d5-20020a170903230500b001dd4d0082c8sm3855527plh.216.2024.04.03.06.20.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:20:03 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Simon Horman , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz Subject: [PATCH v3 13/15] sh: Move defines needed for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:34 -0700 Message-Id: <20240403131936.787234-14-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_142009_018342_D65191C4 X-CRM114-Status: GOOD ( 10.45 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Declaring the defines needed for suppressing warning inside '#ifdef CONFIG_DEBUG_BUGVERBOSE' results in a kerneldoc warning. .../bug.h:29: warning: expecting prototype for _EMIT_BUG_ENTRY(). Prototype was for HAVE_BUG_FUNCTION() instead Move the defines above the kerneldoc entry for _EMIT_BUG_ENTRY to make kerneldoc happy. Reported-by: Simon Horman Cc: Simon Horman Cc: Yoshinori Sato Cc: Rich Felker Cc: John Paul Adrian Glaubitz Signed-off-by: Guenter Roeck --- v3: Added patch. Possibly squash into previous patch. arch/sh/include/asm/bug.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/sh/include/asm/bug.h b/arch/sh/include/asm/bug.h index 470ce6567d20..bf4947d51d69 100644 --- a/arch/sh/include/asm/bug.h +++ b/arch/sh/include/asm/bug.h @@ -11,6 +11,15 @@ #define HAVE_ARCH_BUG #define HAVE_ARCH_WARN_ON +#ifdef CONFIG_DEBUG_BUGVERBOSE +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR "\t.long %O2\n" +#else +# define __BUG_FUNC_PTR +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ +#endif /* CONFIG_DEBUG_BUGVERBOSE */ + /** * _EMIT_BUG_ENTRY * %1 - __FILE__ @@ -25,13 +34,6 @@ */ #ifdef CONFIG_DEBUG_BUGVERBOSE -#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE -# define HAVE_BUG_FUNCTION -# define __BUG_FUNC_PTR "\t.long %O2\n" -#else -# define __BUG_FUNC_PTR -#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ - #define _EMIT_BUG_ENTRY \ "\t.pushsection __bug_table,\"aw\"\n" \ "2:\t.long 1b, %O1\n" \ From patchwork Wed Apr 3 13:19:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616176 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14A2CCD128A for ; Wed, 3 Apr 2024 13:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eTw+OcUDx0KVULds1zCQFyxcDrPr7ysrBrdNTJWNC+M=; b=YSO2oKEUgK4yvO UtlCwAfHS9TDJe1+DtD8f98Fxv/0yynglO57UeH4sBdlpGKbIJnoHy5XGtkFo3P+mkUAX2Ideokdj ieQy+q1FPUybZREyKkaB/71Xum5ErfEh4D/T2+0O5QawkrxLwL4MAT8VaGza0Hmiwp5ICKCmYVpY2 2ax8NBt/I8wjBPvs/8LAkUqHglPUUnG6axylCoQCKR0oHskVIusb103uZAQ3+b1JLR5BJgjjxP9B2 ZzT0AGTSgYVGmHIAz7AGwwNBOciRoBE5qTlG5XuG/TQxnWIHPMDxPx0M5JBreb5aa2ljuc8SgrRIQ bxPRmVN25g0eJ/xBqxlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0d3-0000000GBx4-0cZE; Wed, 03 Apr 2024 13:26:13 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0cz-0000000GBva-3pyP; Wed, 03 Apr 2024 13:26:11 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6eae2b57ff2so5160041b3a.2; Wed, 03 Apr 2024 06:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150769; x=1712755569; darn=lists.infradead.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=ODnUVSnKJhDEm1BurB+AUz+TF6tuatLZNT+jGpCl49o=; b=YXu5Y9be4GvcrBSmmW7G4iXHop14vH1phhi83Dt14YABHJr+ZD1Vs8NQJNfEsAGO2d 8z1MWJrhxh8JV5IIBqUUkSwwUX82ehBSt3ENwkRZwvK1fdPWZbtBbE07KM3wPWdcATkd SYdlQBVZwyMo2ayYis5ITYlb0S2+S4oyO4hF6p97TpFP7qb03ksQ5Cyg7wsUQ/OWQkWV Kf6btE20fMKI2GI/LxGU9jeX7gJgvgMPMD06nOqLmgso2ojyIVkPSklfLRSDIu7RZP2T sPAOBs6Sg8l9Jkyewtw9ewWbSfN1jLLZ7ofV9bCBiOnISN2O6+2VzpxCEtf09fwglJmP UsCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150769; x=1712755569; 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=ODnUVSnKJhDEm1BurB+AUz+TF6tuatLZNT+jGpCl49o=; b=edvSamErpwdEq2Ze7YBh6D2bYQVBzJsJA4tRAJz/MrWnPxxdG/tMEn+1er8yiEidGk cnwkZr8JkeoNZ6ze3kWOAF3mViVNocGYZXmFU0gqBCagT7JPdy2jxuJp848FzfWTkiVG 2+exGP77vzOaQzhhLro9Y38mh6JDf7x9FQW46P19xxa3XO3P4VPPBnI7zd4Ps/MUpvQt gQ85sOPrl0Npo2BEHNNVSEqVO7MwDrFpRJ9+36u7pYH5ZjAvF4UaT+pNJPpBCJf9POVY T6qvheH3J7owZ45WML6MRD6Jif5JVXS+1WMg6XiZKUOjBnDK0UTbGSA0yM7PoX0h6HXM 5FDw== X-Forwarded-Encrypted: i=1; AJvYcCW8qidbKFSXV/J84bbL0qFcWusr6Iu7+69K8iyjNiFAc8/X7HGLTd4Mo33hFHzB7OQmkLzAzwdWwgC/j5nnbdWf7VvGHVmWdk00upG6aAxDDxHy6W3FC0Gkr/h9PbMjBuqw9qUOlELqv66yr6CQERdaPu1HnwE= X-Gm-Message-State: AOJu0YxgAKPavYJvRZc/klOopHc9bfdLZMCII/a9UdQnX0LREApuXhqa T76ZiKGN5ZkN5s+u9/6efR8FZgUaq2af9fgxCzdfC64DZmJO3LmEERqpz1y6 X-Google-Smtp-Source: AGHT+IFJ9xVFhcxKPjkQ9awCqlJIsW3wvRmyEJkLnkWMs/f98CPvZeN33nEjiQcGmSbiBbYrqVdc1g== X-Received: by 2002:a17:902:ccc1:b0:1e2:3d61:e266 with SMTP id z1-20020a170902ccc100b001e23d61e266mr18724864ple.49.1712150405920; Wed, 03 Apr 2024 06:20:05 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b1-20020a170903228100b001db717d2dbbsm13207508plh.210.2024.04.03.06.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:20:05 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing , Paul Walmsley , Palmer Dabbelt , Albert Ou Subject: [PATCH v3 14/15] riscv: Add support for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:35 -0700 Message-Id: <20240403131936.787234-15-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_062609_960299_44E83BF8 X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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_SUPPRESS_BACKTRACE 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. Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Cc: Paul Walmsley Cc: Palmer Dabbelt Cc: Albert Ou Signed-off-by: Guenter Roeck Reviewed-by: Charlie Jenkins --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2 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..79f360af4ad8 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 + +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%1) +#else +# define __BUG_FUNC_PTR +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + #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 Wed Apr 3 13:19:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13616175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57ECBCD128A for ; Wed, 3 Apr 2024 13:25:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IyYYxMH3b63+wtaeEjZ1FULm/yAMCBpqurBi1DqPxGw=; b=uAula1qY4oFG8D cS6901BQ0D0WMaWM1tv4OnQh1egtIlcdtzJbhrioHM2tHWl9XwSO5TwJNJHwgysbgDKYJIazjz69N 4kNtDlAR4lbW9H+T7T69E4K1YnY1al45BFPUKVLHSTJzCqnqsaWpLUPmEyakEDy+iogQQQY3C9CZ0 pNi3Lo9MykFkt3P7jtl/0/tkq6WNoQoTA0NhGGcRXMwRU02/X+HheAHdz+Ut8KeDliaWm7M9r3IyA rk/awXG8jZAhmQSlSIQfqT36rIRXJOvSeNTaWUhyMxY/EzvTxMKDRK1h6MRWITb1tg6fDs9sW1TM5 jYzwQo08aLKda6zR1ibg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0cL-0000000GBfF-0Fia; Wed, 03 Apr 2024 13:25:29 +0000 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs0cG-0000000GBcb-40o6; Wed, 03 Apr 2024 13:25:27 +0000 Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-78a26803f1aso444310885a.3; Wed, 03 Apr 2024 06:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150722; x=1712755522; darn=lists.infradead.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=Wn5Y6haDMX+KFeDZiuG3bLreTNkdvF0hb2IVOihuo/Q=; b=HXrnnkFHvIVMEuIwHumbgDiKi+mBErk4dMv+c9BSlkHwKVyB1hNEeyGKCmAmrP4Q3O kbMMXEpOyzuFiog6IHk2EzAOc3GOWj/v/8dAKIpNeCATOim3egjWn+NZ4b1uJnJ6Efg/ P96s5D2XFlS3r0JvDDLHolfSufEkxeoZvQOuFa96t+KklxkLCYRUQOGTK6d52KQHUsRt 4KY1zw//3WwLf03j71D0d+Vvkx7VMWKYVnN5VnAOJh5p4jWUOTOSABlR9F7YnEOTijqD BfyAyqWsgLogA7zx0QBN0sbe1ftSNLhO5MuM1q/9yXuhiJAjCE3jyjOXm0L/x6NqG8nS qI7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150722; x=1712755522; 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=Wn5Y6haDMX+KFeDZiuG3bLreTNkdvF0hb2IVOihuo/Q=; b=r+p97SnX9M+jTPI8ed0knhSqBFsgbpe3gKKFRq2/3tnh3+seHdmRD8vBu0O5vOPVdP bvzKH++OLobxG6oyfWZ3EmxXjHNMxNDz/l7lBxK6JkxmrgfNZ6zpaoUA83V3JeYDQynX 9gus8+O/ZM/oYBOscwbMABLyY941/8s9MYkriQ19dFWs5iu5aAsyDGr7D5RJBLJd9RZ0 FXe9Z0fwfqCiLA7cC3V8HeystnYyINyXuQzcimj9PQZNfagGQHN0G3C/I5UVVZXdQYZR zmPdDTBqCfVFCieiTU7PqvlJmop4qjnzAFoHVfVeTnKg/Sk8u1o36I37KbnDxs6JY8a+ CDqg== X-Forwarded-Encrypted: i=1; AJvYcCVtTLozcFtXDcO8pgLDYbFTdnlxXbZBcTnuEowYk+w5qIpgqb5dtyjPD3PFu6z3Zv0gjq3IckP82jFBRFbjybqnxb+v0puZY06/HKHCBbAelgFykBXPeYojEwPogDnhmPkZFkXVkjWtxR/IdvMPFDwK2jYkNbI= X-Gm-Message-State: AOJu0Yyhpxu42cgfeDtudC+Z6uDMPXgBoPWf/+5RXUwUdsLFiXaiLbah 2KNZwiUhT+/b6iZE38hAmY/5PJhg3lRHtCjwcPgtxLcMo43hOGS5V8R7UkuG X-Google-Smtp-Source: AGHT+IHWmvXbtJ9fAm6MAldmvpyAC7gyMYuUNuumU3VUQ5OUfg6iZFWTqXY0l/Y7ponpfkrN4lhaag== X-Received: by 2002:a17:902:e74f:b0:1e0:d630:f054 with SMTP id p15-20020a170902e74f00b001e0d630f054mr18958233plf.7.1712150407580; Wed, 03 Apr 2024 06:20:07 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k12-20020a170902c40c00b001e0b3a87dbbsm1705074plk.177.2024.04.03.06.20.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:20:07 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing , Michael Ellerman Subject: [PATCH v3 15/15] powerpc: Add support for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:36 -0700 Message-Id: <20240403131936.787234-16-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_062525_015542_3F3855B6 X-CRM114-Status: GOOD ( 13.26 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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_SUPPRESS_BACKTRACE 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). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Cc: Michael Ellerman Signed-off-by: Guenter Roeck Acked-by: Michael Ellerman (powerpc) --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2 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..5b06745d20aa 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 - . +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE + .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 + +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR " .4byte %1 - .\n" +#else +# define __BUG_FUNC_PTR +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + #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)); \ } \