From patchwork Thu Mar 13 11:43:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014777 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BCEC267B84 for ; Thu, 13 Mar 2025 11:44:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866277; cv=none; b=iPUbTszIi9lZrFYZT4q0LQ5nozgswefQ8ixjm5M1hRfi382LSQdO/4r4O+mKh/dkq/JGbge1XWk+Jelypva/y8/mVBo+lUMGrbA4+3xo/QQDthm+ZQIVi6Wf+9n5bnwdK1/JV/E3u5BBV4334O7hwNimqb9zqLtFFaz5JjrVxhY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866277; c=relaxed/simple; bh=s4N55xMPdXd8kYsnuYY0WP523AnPM+PQ4w7NaziEdRM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=hhcmRss9DVtB5MORQ0hfZCUAljz+DP1mlapwR60bUz6T0JDuhNBTSBWqaN7Qyt3fO+7tyXDSxc7NHYl2YRybHa7mHMA3voMC/kOYcDTe7LyrcXaT+N3bucRYT7qFxWMsDuTT7E+QcA6eEHU1d+06sJCyV3U6KurHKA/QqVf3Z8c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=FsnZF3Ni; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FsnZF3Ni" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c9whUtdSVycPepKkB48hTehRX04VaeLWlAoVnLwkI/o=; b=FsnZF3Nis6aNMTP0KXdHWbSTN5jUAjx6NWDL4Y9JbtXBcqQpPqm9n/6LJPzQxPyq47Z6Tk yj3RVjF1Ibb3rgNSUyzIh15JNQQZsaulXmmVLKsKO8jbSJ6NM9ltwW8UJ220NwMGkYjKjk 5ylnShGM3UpmNlB8KvrrGJ6LW5kkuEA= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-457-JbAd8CIsNG-hmXqypyBHjA-1; Thu, 13 Mar 2025 07:44:33 -0400 X-MC-Unique: JbAd8CIsNG-hmXqypyBHjA-1 X-Mimecast-MFC-AGG-ID: JbAd8CIsNG-hmXqypyBHjA_1741866272 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43ceeaf1524so4584855e9.1 for ; Thu, 13 Mar 2025 04:44:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866271; x=1742471071; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c9whUtdSVycPepKkB48hTehRX04VaeLWlAoVnLwkI/o=; b=D1tDGPPia7lhHdDMqkb9OChHB3ODs12GCn8vgSv/5OAgcqUI/E5a/2o9RJB9o4k9vl s1aQe+9VXXB8uTBfLsq/nZaRYyjg+vLsoBfr3lU1RVKS+fdYRS/AKcd17rIco0mwkyD5 /VoBXzX3Xs/y7PZDlXVgnDSZOE/RwCTIQPA0q41KgHFIqc0bxkgqrdelLVYPWpjri6Li T1durcblOiMaaR0+axflUgnlhAL+WzkBV6sVFQ67pN7QpxU8LAw93rKXP4GUtSPJwBvn bI3CWc6a+CTi8kX9irycUvcBYV1f77+/9mhBABjMvcsbUU7RJw4SWq/07u2dQmRsPH7/ 8Rzw== X-Gm-Message-State: AOJu0YxZaTXvTRoE4cv93Qv8o5YvCcxcI5nXo8YGUVZHxxH5Yu/V0rjv OzjgbpVlw/QHhoSnCqvM2t/ZoRhgzrc0zwbcR/nmWQH3ScDmHE81yq1RlF8OatkIvSALpTAiGjV DVEQmS0iCx2F5+raZYLMEjklxA26LECCr4dWJvsGkBGRFXKSPHtRlbDIFoz10PjxltqMuaPkb6x Ek5WZbC8pld0jgg0qvl7zrJ+ml4aoqy3zJY08fISx1NGDGvxhAh7bZ X-Gm-Gg: ASbGncsKTcpxP3hZyL12xs+WuAkOaDzpg6LI7w13AQCNrpT3uJ5QXKZuoXzISpUvjYn Vtv3Tlp7A8ZD9HTx0waiwaOdLN/p0nb/d+X8SnFmoFgJXwYSeSJdkGqmW7hm+9xStmq22FBD2Ud QbMhSoRM1KypQQWGzA6CZNYYj4PA2mQScZ6vKlUvLOujHTETUsjCQjt0XI/rJAiKIb9hPC9Mjyf ra7x+6u1rKW+ITvRJSDM0kow718nlVKbHOSUSE9goX3ZQLG0SzVf72KLUp/OdcjG8BZr0IkVFGS j0SxPQm37RrNeicnfZYv X-Received: by 2002:a05:600c:46d2:b0:439:8e95:796a with SMTP id 5b1f17b1804b1-43d180a4435mr17959625e9.13.1741866271324; Thu, 13 Mar 2025 04:44:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwbP4l4FVtrSDnlyy+D6/JgQ5XIs1l5aoFtF0Hno/5cr8h07s4+r9vz3ImSRA+QwHoshLsPA== X-Received: by 2002:a05:600c:46d2:b0:439:8e95:796a with SMTP id 5b1f17b1804b1-43d180a4435mr17959115e9.13.1741866270833; Thu, 13 Mar 2025 04:44:30 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:30 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Alessandro Carminati Subject: [PATCH v4 01/14] bug/kunit: Core support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:16 +0000 Message-Id: <20250313114329.284104-2-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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 387720933973..9194cf743ec3 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 (!KUNIT_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 (!KUNIT_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..0a8e62c1fcaf --- /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 __kunit_start_suppress_warning(struct __suppressed_warning *warning); +void __kunit_end_suppress_warning(struct __suppressed_warning *warning); +bool __kunit_is_suppressed_warning(const char *function); + +#define DEFINE_SUPPRESSED_WARNING(func) \ + struct __suppressed_warning __kunit_suppress_##func = \ + { .function = __stringify(func) } + +#define KUNIT_START_SUPPRESSED_WARNING(func) \ + __kunit_start_suppress_warning(&__kunit_suppress_##func) + +#define KUNIT_END_SUPPRESSED_WARNING(func) \ + __kunit_end_suppress_warning(&__kunit_suppress_##func) + +#define KUNIT_IS_SUPPRESSED_WARNING(func) \ + __kunit_is_suppressed_warning(func) + +#else /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + +#define DEFINE_SUPPRESSED_WARNING(func) +#define KUNIT_START_SUPPRESSED_WARNING(func) +#define KUNIT_END_SUPPRESSED_WARNING(func) +#define KUNIT_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 58dbab60f853..cad32d174872 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 a9948a9f1093..e42f20cf8830 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..5eb2ee66916f 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 && KUNIT_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 a97897edd964..201402f0ab49 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 5aa51978e456..3195e861d63c 100644 --- a/lib/kunit/Makefile +++ b/lib/kunit/Makefile @@ -16,8 +16,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 obj-$(CONFIG_KUNIT_TEST) += platform-test.o diff --git a/lib/kunit/bug.c b/lib/kunit/bug.c new file mode 100644 index 000000000000..351f9a595a71 --- /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 __kunit_start_suppress_warning(struct __suppressed_warning *warning) +{ + list_add(&warning->node, &suppressed_warnings); +} +EXPORT_SYMBOL_GPL(__kunit_start_suppress_warning); + +void __kunit_end_suppress_warning(struct __suppressed_warning *warning) +{ + list_del(&warning->node); +} +EXPORT_SYMBOL_GPL(__kunit_end_suppress_warning); + +bool __kunit_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(__kunit_is_suppressed_warning); From patchwork Thu Mar 13 11:43:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014778 X-Patchwork-Delegate: brendanhiggins@google.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4529267F48 for ; Thu, 13 Mar 2025 11:44:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866280; cv=none; b=c9vcWdE14iSIzX8D8XiWCMj942k4kEyRtmtcu4ySVAKlLEKaBd/OIRsN3+DzkNYKe+72BRSzbs5gtZSajV2vMvi9X+/54fFvnjVguO0cKyTQP8wkPvanJj+G2lTGAp//AEWi3Ay8gqQ5FzTFhrmuWh1Dr2TswBH5TRpbZXqE0jk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866280; c=relaxed/simple; bh=JbNbHCb0M8H+Mi/VSJ+AkQrazCf6qqGs/PR+WCt/JcI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=vCk1IaFdDVTCkVENyqZ6DNn5EoZ3uXQ8u81PQMIQ0RlVqhgdKpCHeCEay4H9UA7H/zpufPN3Us0m/khZQXisdjpRMrT764ffPH2UvoUO9TFSBlh8jjlFvcmHslP/kQUjJLdp1re0HsXbFOQCVC+shny/ymEgCWhDznGtKzcALGc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=i1XiBCrS; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i1XiBCrS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866276; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UxCl1osfLw2v3G3W+1kfNU8xiBvtJTPCZorcBEjeG40=; b=i1XiBCrSF+9v2m6bPObCTrnvcNAnDgO5kEE1zMt1utiI0LpgrASITr7jbg9qG5sUCUHbgv 40mtgZ/l3Kn37w+k5FntsbwoPAbLS778n0o3XZTL6fbH+0rb66j++/9sNOfxNM2ZoYRPti Px/yE3PrYMCXiUgZS76rONl/IlieYbg= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-412-dNC2t_zjMtGpX1gkyismbg-1; Thu, 13 Mar 2025 07:44:35 -0400 X-MC-Unique: dNC2t_zjMtGpX1gkyismbg-1 X-Mimecast-MFC-AGG-ID: dNC2t_zjMtGpX1gkyismbg_1741866274 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43cf44b66f7so4302265e9.1 for ; Thu, 13 Mar 2025 04:44:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866273; x=1742471073; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UxCl1osfLw2v3G3W+1kfNU8xiBvtJTPCZorcBEjeG40=; b=JclgnBfj35STftrjQCfqIpqSJ9SpzVSohpj3lzVincUAAuA4g1596Pm3pztFNauCK+ P/QK/sQPKtb/AdVBtcoauFZxJ6mtjq4k9wzFHkbI3aJYP3FN0xXSufVNmGq7+efcK5m4 TqW7Xy+HhwmUTgPrsyk6E60elF9vQyRr0B6+BTMgf4qMVZ8RMOOtjdPKMP+01NqsmZRd PAOJ0CeWyO8xFXme9thk4wVi88okx2Jhd90bWWisrVOh0bQfhryrtcdjnrXMj/60qwon nVZa269QbmaM1gzkr9EmYZ3Rk6qSYmVZyBxMoAdlY5wxqT2ihJnEpvgy0FKvfpvvvkL9 LriA== X-Gm-Message-State: AOJu0YzCU/ecvzhNtxVYWxhOKQokwOUX3+fQ9ZdMaJ8WTE176gvgb2X1 jnSaHWkpA1LihAqNfYL7ksJ1cw9Jwco5aoyBFKmTjYTG2xl/OggZTlNaHV2z3nBwzhDVsLyQ2AA YPo7ALYs8SJFMcg0j0hcTVRGpxEOkTcCbU05U5WDil5n75pe5E7kckJa661SfuxPWF51ErVWTyp YsLuQ1u0QEUdowEe6alpj5iMnFgc+eW6n70jr5uZtsocgt8RVciqEg X-Gm-Gg: ASbGncvxtyfSxPpgM5zuvm5mMTJJvi8UAzaizgVXsQl+Bf1oUXK3PmzZK+vSENIuUUY JAcS8R/6Ny3ylm1fsSr+dkAGX6dbsU5Aqj3jv8JKAlqkOnXOHQUOxh7mXzcRlSSf1Fzen31FEgZ w1CrEJ6HMrnpKlI9GQlQHYV1/s1fxf5Pe4Kw/0QZbXBac5+bWWknEqw3ZuNQdMfje7tW2xpJNDk BaEzD1EQZabmsRYqCH9khEXzZNugObfydoCQp7X0mLpydMn7ZI3bTtH/TQG4qzsuJu5RKzqNVSa vvNUD2lN9o3BUPFYpKzy X-Received: by 2002:a05:600c:190c:b0:43c:ea40:ae4a with SMTP id 5b1f17b1804b1-43cea40af7amr174500905e9.31.1741866273536; Thu, 13 Mar 2025 04:44:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGs6EAEForVjkecQAM8kbehVzhKfM/0tK/SxXfrbXe4b06Gjm7InnzRnhjTKgVzk9sVgzkBAA== X-Received: by 2002:a05:600c:190c:b0:43c:ea40:ae4a with SMTP id 5b1f17b1804b1-43cea40af7amr174500265e9.31.1741866273039; Thu, 13 Mar 2025 04:44:33 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:32 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Alessandro Carminati Subject: [PATCH v4 02/14] kunit: bug: Count suppressed warning backtraces Date: Thu, 13 Mar 2025 11:43:17 +0000 Message-Id: <20250313114329.284104-3-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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 0a8e62c1fcaf..44efa7d5c902 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 __kunit_start_suppress_warning(struct __suppressed_warning *warning); @@ -28,7 +29,7 @@ bool __kunit_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 KUNIT_START_SUPPRESSED_WARNING(func) \ __kunit_start_suppress_warning(&__kunit_suppress_##func) @@ -39,12 +40,16 @@ bool __kunit_is_suppressed_warning(const char *function); #define KUNIT_IS_SUPPRESSED_WARNING(func) \ __kunit_is_suppressed_warning(func) +#define SUPPRESSED_WARNING_COUNT(func) \ + (__kunit_suppress_##func.counter) + #else /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ #define DEFINE_SUPPRESSED_WARNING(func) #define KUNIT_START_SUPPRESSED_WARNING(func) #define KUNIT_END_SUPPRESSED_WARNING(func) #define KUNIT_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 351f9a595a71..84c05b1a9e8b 100644 --- a/lib/kunit/bug.c +++ b/lib/kunit/bug.c @@ -32,8 +32,10 @@ bool __kunit_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 Thu Mar 13 11:43:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014779 X-Patchwork-Delegate: brendanhiggins@google.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7377267F5F for ; Thu, 13 Mar 2025 11:44:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866282; cv=none; b=nNsG/TwEd3og1X6Efg3/QSyUOJXwvoqAihVSe6VRAi++k5db7yR//KOH+kIjh14ke+K0b3KE8KN63LRjrOvhTH4fW8Zu6+Dyt4Asa0Uv3v43EEbl3xQ1Oo9rQxM/8co8Ifxk636tVgkdG4jPbJhzh9I8BeLt4uFUYTg80DkvnU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866282; c=relaxed/simple; bh=u6Rwk0svFtWeF4hFVzbd7zjAA4nknN3Gap2PdMh7Y8s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=syNtElrxJOhgEr+zIuD6XkC43RbYCV1jWOtWRAbLSit25uAt7kOxSVWMvlrlgLC/PZ554im5kvvQ0neKAZonKT4KYX5VrnwqTpjC+UTMXhmPYa6p1Y9tibU9NXiACfOfWtjNjfoVTMYxnhBzus7lJS3vTMdrDimCuxFqkHQV7EA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UbdDNbAK; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UbdDNbAK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8XY7u+VGe4o3zwipniM3kgRblYBzOD2SlUABTxKMSlI=; b=UbdDNbAKrVZHuFb+UAFgZOTMTUG/ThnAik3kirE8rbXsTY1rFOYCrlmEpru9uk2i301qlm ePInHf22mEU2pOw8aDZD1TLDD1oAQH+RW0gsZfLs0AaAlAl4m0PZHyf2Apd9GvYcIq9VmN C+ZykA1El4LjEtSTVeUvfcZ/9jDYWC0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-xkQK7Vn2Nua_eQXvyhkElQ-1; Thu, 13 Mar 2025 07:44:37 -0400 X-MC-Unique: xkQK7Vn2Nua_eQXvyhkElQ-1 X-Mimecast-MFC-AGG-ID: xkQK7Vn2Nua_eQXvyhkElQ_1741866276 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3912b54611dso565560f8f.1 for ; Thu, 13 Mar 2025 04:44:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866276; x=1742471076; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8XY7u+VGe4o3zwipniM3kgRblYBzOD2SlUABTxKMSlI=; b=TIh4ag0hxkbc6+t40tVgczm94lnL0iXxNfhPCXKOut2Zd3qlJ/cf5fQ8D6SNpmzHY6 TDCJ47+yYL0PNkrEdMuFicwY+z0sUenWkKc9/AT7xsyIljv3e689WwtCtsYBGY0BpeTU O0nE3tBLczJDN+h4WNvLJfbGp0g6uRpe8wDTHh8GdjU713D08LqXzlNsx9Ra40uwI4L0 RNOLQwBzzEjRwCSZSMbOfGjxivj5h/zdaYafFDxfdUtqGZscjyZ+Bf6ujs8EXn2UsVeV HUHDLCCzbzJ1N2jdkrqqcnrcQn99k5gYQvw5yFKuF0oMwdEwzJJdRRAu1Hs37grkh/4I US6w== X-Gm-Message-State: AOJu0Yxw7ts4berUs9xysdw8aDmwC/OFzhbeDMjOiKPpFoGbOGx8qeK5 aFHESeLDiOCeeM4xWhsic45r0uVim5W2S274gQp5GbvZbHVZlMq9ndPZyAPYJJVSm9ylew2k/Pn h96kpuT1hsqMo347iOUur2d8c214KXw6pV/7h9BcamlDwKhH+4XrHzBMEXVqvt5DT+kByZYggNO BmpIhAc7FAwRZrlZmae7REkIroepM0jTrZZLiXjb/Z9x/owyoW2Ky5 X-Gm-Gg: ASbGnctMFWrVw4OVV0Uc5MJ8ibxsw1Eq/3tUqFLW0UnccE4eVoB0911Z8SzwQnC/Seo lwUF0VGbEiUhpRtmbwOdqRMX/a/57rbRkr6zmp8LEU/y7SX5Mi4FUFMf1K4sS6PGTpRdt2NPWuU HpQjZ9L86McoOoCZJD+26hSwYT6gPSqvtlyyOGWG564Nun1ru8RVdi+E8HB86EOFoUtjPWWCCpk WF3BqsN/5qzdWUjuUD/hppKTsFyVSJDyqjbLzEhWN4yJenjgDgNn1GWnQ/+ISLozkdhF0pPLXue sBB394vhst/ySYp43glV X-Received: by 2002:a05:6000:402a:b0:38f:2efb:b829 with SMTP id ffacd0b85a97d-39132db8f39mr21017132f8f.50.1741866275720; Thu, 13 Mar 2025 04:44:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+VRMNblZ6UVVkAdfbP7euIJRbGF3K1/IwYQbvGRJNcsyt3iuZtEZMCMltjGjHXgTrURlOvQ== X-Received: by 2002:a05:6000:402a:b0:38f:2efb:b829 with SMTP id ffacd0b85a97d-39132db8f39mr21017073f8f.50.1741866275187; Thu, 13 Mar 2025 04:44:35 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:34 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Alessandro Carminati Subject: [PATCH v4 03/14] kunit: Add test cases for backtrace warning suppression Date: Thu, 13 Mar 2025 11:43:18 +0000 Message-Id: <20250313114329.284104-4-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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 3195e861d63c..539a044a9f12 100644 --- a/lib/kunit/Makefile +++ b/lib/kunit/Makefile @@ -18,11 +18,14 @@ 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 obj-$(CONFIG_KUNIT_TEST) += platform-test.o +ifeq ($(CONFIG_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..8b4125af2481 --- /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); + + KUNIT_START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_direct); + WARN(1, "This backtrace should be suppressed"); + KUNIT_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); + + KUNIT_START_SUPPRESSED_WARNING(trigger_backtrace_warn); + trigger_backtrace_warn(); + KUNIT_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); + + KUNIT_START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_multi); + KUNIT_START_SUPPRESSED_WARNING(trigger_backtrace_warn); + WARN(1, "This backtrace should be suppressed"); + trigger_backtrace_warn(); + KUNIT_END_SUPPRESSED_WARNING(trigger_backtrace_warn); + KUNIT_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"); + + KUNIT_START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_on_direct); + WARN_ON(1); + KUNIT_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"); + + KUNIT_START_SUPPRESSED_WARNING(trigger_backtrace_warn_on); + trigger_backtrace_warn_on(); + KUNIT_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 Thu Mar 13 11:43:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014780 X-Patchwork-Delegate: brendanhiggins@google.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4136326983B for ; Thu, 13 Mar 2025 11:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866283; cv=none; b=IBsbd8cvIFgjh35RN4EqKcFj61AxHtvHlct2OeXkRv47cOwgUO0BLCnVx08rjMZqcI5JHpaghv72Npk5ax+IGsJFnZRImzNzHsJOcjMl6kDYHDSTxvjlGsNZiydOnqtf8cvr8Z84UYREOh8t4D7msWmUf0+MbijU8OfhxWIJAP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866283; c=relaxed/simple; bh=k/QW8yyThWQYD06PZzn8avBbFa43Ro0Rb4YCVVYWNuQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=n7umEiwgBPaw0OaXymapvniREZwx3dsh+Inu7Ewo6PlQ7VRIHQfeoL41xMA5DVdqkz07CbrmcBfR4rYXdWVcUNrc+T6COMw8lePrp8M6XRWvjw28MFfSCNVL6KRPC2c5GznKaboQzVxmXGWcjKxWjDA2uw6kXD6l4QwjFx9CCMw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PlOvZ7wM; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PlOvZ7wM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=piebsVU5QZFL/FeYXj8vMs1AI4HP2ZYK+Wi3o0pUrOA=; b=PlOvZ7wMpeHapZ2nPBdSZQCYukvOZXsLjTzwui9dctd7I/xg8Txh01hOiIKHLGtDgPJSae IcfF+xiP8Qk1Q0iR3cxycybW1Ih7/901TW9cYtxxBBbqnTYD9Exut0PLbWTG7EDAIon0SM MM2FbVmRQyRZ8QiCKYqSq2DmWE7DvHE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-AQIVcgJ4NvOf9AJitmFh4A-1; Thu, 13 Mar 2025 07:44:40 -0400 X-MC-Unique: AQIVcgJ4NvOf9AJitmFh4A-1 X-Mimecast-MFC-AGG-ID: AQIVcgJ4NvOf9AJitmFh4A_1741866279 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4388eee7073so8945455e9.0 for ; Thu, 13 Mar 2025 04:44:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866278; x=1742471078; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=piebsVU5QZFL/FeYXj8vMs1AI4HP2ZYK+Wi3o0pUrOA=; b=PJOI70ghA8Q+2n1zTEP2APuNfgfV/m2BUn8F0nmFywYVtWFCoJs751InxwVNQ1U3P8 /CTVQnIKK3s7kIkgkiPRg6CpxesOsMAk59FPMALe8yOY/X6aKKACjZXFXFTWYTpGcqfp 8hkhHLVeXNhC325Dcx8KGDYNVi1gFDjpe1LBrSJPe0BN52AD4CzHgxJXOw4gjTJKFJkO du4+Smg2jmkDouzn8T6+Ld57KstJmZ/MXxROEoaCN9qG21IU4bkQBG5dS9VgMrk1YXh9 jGhiNFOTVJnKnwE5e1AhNfGZ8wzOqyUYCqB9aeXPj8ZbK2kCKc3ziC91XyQ14nWCMJ3u VnVw== X-Gm-Message-State: AOJu0YwFVfFIcQTK0WDrlwSdmJxd4V3/DFi6dEUuo5Ybd2lCnliCpQDM dEwasJ+nD17a6PBcgcwUv8Z9q5IjVSW8lGlGYBURYfivZh1CUIW7zqARuJ22fr/l7G7TlQnFV9z 7UbbEUui5TLenOswFGOalToRU2eyjma7rW82/CTgPpNq1IsB3bdNkplTenz7xWzilKkHUQYramB 4Y9Rn7v419ynHQPzrQqiXlO1Q25A/bku+rxY31d0aNjUZl4NcbbZPY X-Gm-Gg: ASbGncv6i0lSu5MXPg+qREeHBG8kk85kjp3q76x09/yTdgVCiauEEGi1LlFbbBn5jR4 7MVmyRDafGTKsAoI3Xhs7GHRps7JibuavKs3bxPaFi9hCcmEFiUL2WLG7LqJ/xzg/7ZygOjJiMG eblVMSGPT9aMZD1qHcxl0YZ+wZWrItisiNALas6qV94DMkmnZ9rLSeCj8dKtROzjaLrPAFzNhWj MBLejeYEzQQMD+kj+P3c3/TmcNf5izyT1WohhrUsMV9TMsk1cxzijrSqSGgKMt/Sw3946gbNDrF Sg6ukIPCGN22/cp4CUX+ X-Received: by 2002:a05:6000:1fa9:b0:390:f025:9e85 with SMTP id ffacd0b85a97d-395b954eeeamr1447656f8f.21.1741866277889; Thu, 13 Mar 2025 04:44:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPsIsJrLJpu/wcDWacnMw+4SNJEtb8GetI5Mzi5kv4VuMQGkXurfVfuA8bqNlB7JY189Yj3A== X-Received: by 2002:a05:6000:1fa9:b0:390:f025:9e85 with SMTP id ffacd0b85a97d-395b954eeeamr1447604f8f.21.1741866277398; Thu, 13 Mar 2025 04:44:37 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:36 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Alessandro Carminati Subject: [PATCH v4 04/14] kunit: Add documentation for warning backtrace suppression API Date: Thu, 13 Mar 2025 11:43:19 +0000 Message-Id: <20250313114329.284104-5-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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..b2f1e56d53b4 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); + + KUNIT_START_SUPPRESSED_WARNING(some_function); + trigger_backtrace(); + KUNIT_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 Thu Mar 13 11:43:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014781 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 807382698BC for ; Thu, 13 Mar 2025 11:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866287; cv=none; b=pcjxkcnZYT3xKipCkq+7OfA4v9oopIIUfxaapMWdbTcjVUL2sfCFptNBk3TzqS55ChPVW7DLb9P8fKFuvoo8cuqDIRL0tkQENyQoBSn7733Jc/qfwcOOZuwuOESUi4+tChuotGAUhxmFvQLXmeRTlbfiudEgcabgdZABmFziusQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866287; c=relaxed/simple; bh=0zAXw8Fu4pWyrls3J/qZaqJC0Q8LMMCdN0t5bJavxBw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type:Content-type; b=iZTc1WpTOyg2k87ZzvJjqfftGVHrc2IRfAWUsU+RZ5zylfbUrXbY8BBiEzArYKubQ2WxfcMtqwoQE5If4HSGG4gObatgFdUgZC+HToGvG6zoAb6jyW4lCF5YzMQf/+gMfcrg4+SrmTk+AWjtUlTI8Q05WR2s8+jceu6Per0wtm8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RW83EQv0; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RW83EQv0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a3r2g39Wllme+8/IppJMHdqpnHPlgxpExHUFAvvaA/g=; b=RW83EQv0m9U7Kt8rGIWcei1mellTDeoY0OvNnJ8UuLylvv6Y/wONcmAxbU8Ts92tFm2UH/ HFnc/wfX8XlKyzwIeWSrlTqXQ4UBHXEwB5bWHdjzckQwRIkXlCMEkT6jEdmH8yhm4Nc9X4 bzsDv0rthTzSRzMLl+V8UEEV6YXHFiQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-79-6zr0niXZOmOakG_5XyAK-Q-1; Thu, 13 Mar 2025 07:44:42 -0400 X-MC-Unique: 6zr0niXZOmOakG_5XyAK-Q-1 X-Mimecast-MFC-AGG-ID: 6zr0niXZOmOakG_5XyAK-Q_1741866281 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43bd0586a73so5903115e9.2 for ; Thu, 13 Mar 2025 04:44:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866280; x=1742471080; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a3r2g39Wllme+8/IppJMHdqpnHPlgxpExHUFAvvaA/g=; b=bHDnLgurltbnQ5tK3dOm481NCkPXELigo9rOfUHjdjWqvGmQ/r4AGlf2TP/f/pT1HT i43a7OaKJQ+sMVVdJVzVD5TGE9sPLJ/7wN72oQ9Gkx12IAE8PVa8rsddq68IXqHxdrDc rVj4HvmXc6Bb74tHhO9IaO/rV2V8DIlRx6w2HyfbWyhR1666UlXGIKm6kMYlNi0nqvZp t1UBLTJhQDiNXvdNTM6YNpg/Q6XYSosRWj5KAWhBna2kKsObY3DsUnixBw8wD+RK6hZ/ GZy9k8nIUZRCsjzmCJRrJbOLhdwFFELMY32R+uQWTtus8OXq3likt7TNeY4OGErxxYlm 5LLg== X-Gm-Message-State: AOJu0YyMfw7F7WgbrehQO8Jc9uZ7dxPAOCcoO0SaP66JLoLdrDt+Wr7S jJ/EZfNR3e3pPzKsjvLwyVKOWucSQmJ4ZXrd2KaVBgldUdLMFqSwqBVRnVbgEN3KbBY2iemu8jR Rjutf8QtUjywE4g51FtJ947wa7dz+BBX9WQkuQVoRaqMAbxYVrDglXVWw97yEB49hWYCYTQQg9q 3t3317oq6Vx0fWIsRSjDxFg77Q7eYZ1XD22TpO/6kouCAsHXM8SDFK X-Gm-Gg: ASbGnctVrR+BAYI9srEIa3oeNH4UbaYfwlA4aJ6mkQYu9fczztMp+afYt6tAynT+EA7 khj7tt8t0zCIWZ0xpGoIhLhSs7fwi75ySKc5kgV0xEb0L5RjNR+Kw8eCqzi/Pxd+50/MkS9blMf GfXNwQU4fyzmijwo9fClStvx71bW8zK74uDDLQi+eQiIw6NHB8SMTVONaRqqhDD+uHmr8mG/6AM ATbXtGWhDbomLnCC/EEeJnNMtR15FmhW8wXuIFcBV2fC0itYdfWB0/ZR6WO2bmlqxGQtOCVAZae tG4vfWn/z80xhISX5wwj X-Received: by 2002:a05:6000:402a:b0:390:d73a:4848 with SMTP id ffacd0b85a97d-39132db1bdcmr22489012f8f.47.1741866280432; Thu, 13 Mar 2025 04:44:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGX54DwhuuXuiX517uvSUEgVEhgO3UBbgNo/IaPOPi6DbNC92jX9q/7SC3qQwivycyOtbvIkA== X-Received: by 2002:a05:6000:402a:b0:390:d73a:4848 with SMTP id ffacd0b85a97d-39132db1bdcmr22488963f8f.47.1741866280013; Thu, 13 Mar 2025 04:44:40 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:38 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Alessandro Carminati Subject: [PATCH v4 05/14] drm: Suppress intentional warning backtraces in scaling unit tests Date: Thu, 13 Mar 2025 11:43:20 +0000 Message-Id: <20250313114329.284104-6-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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 17e1f34b7610..e8d707b4a101 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. + */ + KUNIT_START_SUPPRESSED_WARNING(drm_calc_scale); scaling_factor = drm_rect_calc_hscale(¶ms->src, ¶ms->dst, params->min_range, params->max_range); + KUNIT_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. + */ + KUNIT_START_SUPPRESSED_WARNING(drm_calc_scale); scaling_factor = drm_rect_calc_vscale(¶ms->src, ¶ms->dst, params->min_range, params->max_range); + KUNIT_END_SUPPRESSED_WARNING(drm_calc_scale); KUNIT_EXPECT_EQ(test, scaling_factor, params->expected_scaling_factor); } From patchwork Thu Mar 13 11:43:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014782 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDCD7269CE4 for ; Thu, 13 Mar 2025 11:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866288; cv=none; b=X+iBYeTwTaEck+oJUPmV+/YrpDJJRACGffGYWG9WgA546BXCWAb7UMi02yYyHQ0LPVRmwEgEF2EBrps4e60ZraOko2xFDQPXZKaMp2XOuylnfvAGowbGmMfyQWUHCd7JFGOUXfqXJDfmZDNTI2IFoTm6zUwMfVFeR5UFglvE/PA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866288; c=relaxed/simple; bh=wb4K6eThBhnG7QUcN+gX/b7GoXZu0I9IHZjPqusvMic=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=f4KvGcSpJUDYml89TyECX5bRs9yIjhVqtwH+jyo419V00Nzd1P+sdaTCO6qE5LzV9wlqRPAf+ra7L93q81080jv4mhmstVnCgbK/PloTi5XlRvHUMKZrhh5dgv+UfigAlQvmd/HecFfuo0hB0sLaC/D25uMboZXlGkOCkKZE6ps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ct+v0wxr; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ct+v0wxr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8P6wNaO+XIHVOsaMiUxPKzcQyyRjSmyu7hy/Ke33WeI=; b=Ct+v0wxrtzPDPcLlSLMppeB2ZEGv4dNYYH7JLP03rCjmRQTZNltcZIBykPIo560Zmpa8z7 sd18hWvDmBZ6L+k7o0g9lGGetHk5BFuw5sdAGIE/I54d8U48Z/q+cmLAb0jlnCsuKosJlf 5V8PGJjqmxresde02Qn/AOfrmJIkAps= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-18-1vx4js7QNsmEpay-9DwWDw-1; Thu, 13 Mar 2025 07:44:44 -0400 X-MC-Unique: 1vx4js7QNsmEpay-9DwWDw-1 X-Mimecast-MFC-AGG-ID: 1vx4js7QNsmEpay-9DwWDw_1741866283 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43cf172ffe1so5891365e9.3 for ; Thu, 13 Mar 2025 04:44:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866283; x=1742471083; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8P6wNaO+XIHVOsaMiUxPKzcQyyRjSmyu7hy/Ke33WeI=; b=w5ayJvBS3XaH9bXFZJLzj1cUs7XIRVZvjvKrkKtlEo2WU1ye2fwIDYFO38AuDdH7ux Ct9XjJ+HrqZqLktJ2swWNbbwE0s8tVDi1UlCiJtsTNQMSsqvm4RXXMsoGH8MOlOll8uW j26BLh+r8/0+75Hz9RtsN9tKNqoeiLFWREp76KMebwajh+RuzOF06hbQC2Mf3fC1/1BQ Vtp1b8O8OCmbJvDkZYLdGKa+sZys3y/BYh6AlYCveZNdTIuacM2hsIc25dUkYqgJ+Xgk pxn4p3giBO1QejX8k1NqwRCfZshJm1YSDqou+R3viSW5eFGg3JKthryzo5kf0fRFGkYW l3Zw== X-Gm-Message-State: AOJu0YyJUaAVHvuA9Qj0+RC4X+mcRtoJriA3EL1DpeTPUXhmgSjXLBXE aQ0j0dMuNpoXewB3QzZx+pf1TY87EKTzJlFkgqsikUzwGTvkc4TUeE5r9aPG3vp6NOO2jqjclXZ fOpSdVkc036NlWdYwLk7+1ZQGQMPaAvnnNUmGAe+L1jVXJegZzl2XXjFn1Np1R0Kz+lNvdS0O6z JorANCXGsZfUEWm6TpkppMRZR2K1qw6NRa4pJzQJnsob5fOpJz3EfK X-Gm-Gg: ASbGncvVQ2+4D6aGVd6SSGq4AasOvYUVjxbxuhQBeaxgbcxgAtQ5JhE0ibrJR5pQrvK ae8ymalSFvZgc36ptwVYydCYVQKeSwT+tUJnDIlcqGiF3Qtsi2iSOIrU4NzxihRqql8aOeQjEbu d7WN4TNMeJVBK5UwzGM3FPsjyWq2vqqvndVGauCPXmwpNpcQolp92mjfxSzlD6Wcx/R9wXQ8Iwb 3N5KUifJEsldvNxP70m81Ksymrd8xwGw3KihBRjFS4m28UUpQqIo2x4bOAktLTNruU5sfkgWlej toYoIBzMfw4fNTvYpZd8 X-Received: by 2002:a05:600c:46d3:b0:439:9424:1b70 with SMTP id 5b1f17b1804b1-43c602223f0mr255847295e9.30.1741866282692; Thu, 13 Mar 2025 04:44:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXX+a12CkpViQK6U7ArlV7I00zmbs9phG5wa1a6gevfoSJzXsUnRwbzS8Xh3mqpEsYOihpsg== X-Received: by 2002:a05:600c:46d3:b0:439:9424:1b70 with SMTP id 5b1f17b1804b1-43c602223f0mr255846615e9.30.1741866282213; Thu, 13 Mar 2025 04:44:42 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:41 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Alessandro Carminati Subject: [PATCH v4 06/14] x86: Add support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:21 +0000 Message-Id: <20250313114329.284104-7-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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 e85ac0c7c039..f6e13fc675ab 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -35,18 +35,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) @@ -92,7 +102,8 @@ do { \ do { \ __auto_type __flags = BUGFLAG_WARNING|(flags); \ instrumentation_begin(); \ - _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE(1b)); \ + if (!KUNIT_IS_SUPPRESSED_WARNING(__func__)) \ + _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE(1b)); \ instrumentation_end(); \ } while (0) From patchwork Thu Mar 13 11:43:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014783 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64DD9269CF4 for ; Thu, 13 Mar 2025 11:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866291; cv=none; b=g6l6EBaFoBNacAfVuYK3zzGMqlkT9eeL4csXLSl39EYPwboF18X1xZhRodKyxyyBwgGqqnKZMr6b1SC67lGcALPwKGzBAw6oXP3KsZSR37q06RCVdfHyuLBWJchBSgxxDL0zySTr2c/tvBgkMQxpDIvGL2GKyxDIDCURg+zF1QE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866291; c=relaxed/simple; bh=liO3eLVl1wJXmy8vDx1YCNgXVebD8YdGrdwAIJcfcmo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=GRE7Oj5a7oL1W69mr0qmzsZ70p/lw+I0cHygs3Ls8AMFRrkbOotPByCxt4UM0ENT0MGGj9DXF6vADR3EpXDDZJVzdZZiatrPE3yKFMkkjpNNQzxMviv+sVUYonqdntVFh10tGXk+aC85sbbtXcDMftWxptMoHZMYgDa5Jk8eIdU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MBMjRLJM; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MBMjRLJM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866288; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GROr3WSjkuWJZb5whyX7QQnwj0kVrCWo4LNK5GIabXk=; b=MBMjRLJMcZ+DCEiNGj1YfE/yoE6+agjY2mKud910Koo5f1pBeIuPWMLZcFhdg6RWzmFRkE ++rQfYURHDyZxmtqZrnzsgJIwXPD1Ppng0BS+R08EYwg8+kFi/oMvsUvJGLHWghOqAZhbS ZDeSDA+SUFSOKqM26VMDIEvZ1RVBDGo= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-gRN1YkdRMdOqHiPy9zyIDg-1; Thu, 13 Mar 2025 07:44:47 -0400 X-MC-Unique: gRN1YkdRMdOqHiPy9zyIDg-1 X-Mimecast-MFC-AGG-ID: gRN1YkdRMdOqHiPy9zyIDg_1741866286 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43cf327e9a2so5858755e9.3 for ; Thu, 13 Mar 2025 04:44:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866285; x=1742471085; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GROr3WSjkuWJZb5whyX7QQnwj0kVrCWo4LNK5GIabXk=; b=oH+U59WwSf4GBleGWPSPnY8T9R/oscf7ap9+GIRUyy7x5L51NFy510Na+Q9RJdETRe BZcHLUzSOenKaIFuJ8mva0/cPxLeNujOYYQt+I+OUSh1worMA8hP1X2LCjfm85RIC1ri 12NlH1IwyJPAax9W9BJbErJwrMq6Fg7Az5lBqit1bYhUGkOIZ86rTvieOfhL/SH1ItqC ZvN6Ht1c6F5hH/YB1pw0js284E8ctorMY09WbuAgmM0Bm+aDZFzUAHe2XZfLh+9z2xqs 5xqtzvxY+H29ssJSKVdXtJtnj4SBZhAlWEfCp0YFpfmlkVHMT9XlnrWphULbllcgpu0T ucZw== X-Gm-Message-State: AOJu0Yx6+se6PlbK5e0Xc/lW5bx1VY+YvhzUt67hmMBBcE9fIvq3p0Xr bKAlKmrvb434FNRfrIai8ZKFsISxH35vIcszho+LjcDIrqvsMj6YRatEZfFUonJ++8Y2GynGDc6 vWm+Vd/tXOanoD1DMcD4mkeHGnR2JZ2Kzm5ORarT3/4NMASKh0nRohSQz8yQMHC685oniBkgHMG rhMq0Yi6NrirwquHJTIKWobm9lPZmkVbWkuAkcR45FPAyJtkI+qr0C X-Gm-Gg: ASbGncvibxmdQtd57vUmtXVmdWdQv4s8hwK19jkXRpRXnkS+oQNDtv5qiP2aj4hXPai T4o+NJhSYPuTK5jor//afRPVGQQ9Soszwq/yzz0cFxm2E8on9G9ZFEyruAp6zS9jizpX0Q7n3GN 8ClrhFPgM88ceCpOH3NpoP3Ny+fHx/fe0GfDk/VrPScxSkDaPt4/cZlsCPDtq+DNrymyh4+qsAG eVKY0TIdUaNxovrhGMfmDqn0T1zeWE62WHGkvbWsSj/7ae7nH4aPy9odOkgkGyYoA12WJZYqIUo bj50cH6QA6k62/BfxdMe X-Received: by 2002:a05:600c:5493:b0:43c:fb8e:aec0 with SMTP id 5b1f17b1804b1-43d01bd21e2mr95038955e9.1.1741866284942; Thu, 13 Mar 2025 04:44:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmAbVJJ3Axf7J+/aQFhSVgbztnHuV0D3aaCUWl74kfxPn81ZspK5wVSFqWrESjIWmYzw2aJw== X-Received: by 2002:a05:600c:5493:b0:43c:fb8e:aec0 with SMTP id 5b1f17b1804b1-43d01bd21e2mr95038375e9.1.1741866284399; Thu, 13 Mar 2025 04:44:44 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:43 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Catalin Marinas , Will Deacon , Alessandro Carminati Subject: [PATCH v4 07/14] arm64: Add support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:22 +0000 Message-Id: <20250313114329.284104-8-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- arch/arm64/include/asm/asm-bug.h | 27 ++++++++++++++++++--------- arch/arm64/include/asm/bug.h | 8 +++++++- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/asm-bug.h b/arch/arm64/include/asm/asm-bug.h index 6e73809f6492..bf0a5ba81611 100644 --- a/arch/arm64/include/asm/asm-bug.h +++ b/arch/arm64/include/asm/asm-bug.h @@ -8,37 +8,46 @@ #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__) \ +_BUGVERBOSE_LOCATION(__FILE__, func, __LINE__) \ .short flags; \ .align 2; \ .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 Thu Mar 13 11:43:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014784 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4963926869B for ; Thu, 13 Mar 2025 11:44:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866293; cv=none; b=UvoZW6qXlRsn+TyljfntrIVqCpuHt3gfTnKdqjC034SMZQMXDwyD7oxpiKEDg5V0ju7bHm1dsTyc6GSYFU9eAfE5vWt/8+V1PO29dP8anvlX1s8hVNnuQfcrg/C9+edrickTJXNrTrkzgLSOwE3BDXhUstwlcJvC0fRkPZAmWRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866293; c=relaxed/simple; bh=5fLDKvq7QfjMD1rpic/O5Jy44W9yZO5UGhmiIAM5Nww=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=JDQKQXhQGWD7zCArRctRioa9z/Gql3Adb9s42JVOkAVHl1wKuHxZaXXdARU+cTE21abhgNhxvaHbpa0YkFGKERgPzUpnKi1K0wW8CoC+re3Nqtlx/Q0yGTn6sDftnscgqpsIaN7VIn90iinDBJpWeMppdhc/HwN7I+9m47uHLjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bWZa8nBH; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bWZa8nBH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PbqX7vwCNjEpHKJ2wPiix10XVQC29l2r3Yj9fEcNr2k=; b=bWZa8nBHoXG3GREn2Bx7JrXtcNxzSkst9p0mvZfAAUdEEhYpgyxd0+104qxKLRCjK7EdHp LvHyV4ao/PPHTDZEqaAWFJOVfMRXZpbWTY5fU8OKGcx44tW3N5db537HoF605uQ9p6PZ7Y 7rcbv0SistoNF1StwFbi9en/bsg7fyc= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-MkMQl6stM_2N_4svBd2gCQ-1; Thu, 13 Mar 2025 07:44:49 -0400 X-MC-Unique: MkMQl6stM_2N_4svBd2gCQ-1 X-Mimecast-MFC-AGG-ID: MkMQl6stM_2N_4svBd2gCQ_1741866288 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43935e09897so6482325e9.1 for ; Thu, 13 Mar 2025 04:44:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866287; x=1742471087; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PbqX7vwCNjEpHKJ2wPiix10XVQC29l2r3Yj9fEcNr2k=; b=OM6TS4KB/8TULT/3vSrQPpxCgo9mdYl5PXqhScGalZso+YHi1mb+bRsk0n+uwIHw/C 7pT1JMch053jU1A0Iz11+ShuikHk6jUmb+SYA5GPVtCrRE0s9MSQAUc9hoza4e/bY1sC pSSiwXsLRHPpJTOdFDkd0h6z01GoDT1zFIsIUBnENRnItVaXayEYmuEW4XrHVh3xP6Wj YNhZzDYfqCE+9kDPkeaeBwEUd6mI/S0IWOgQygCf2VqYGDOEBRkHjQK4WxiY4/oSO0fW b7xS8c0VaXkVyHkPRKUbNoehEP7qlNu8R++picdWuf2JoTCIlQ6jESV62ZdmCCvoR4Fx chcQ== X-Gm-Message-State: AOJu0YxcDLoi+YZHdrpCfJl1yBfi2nwDzflzTvfgxlkn6k9+GQ8E5wBK 3tQM0D0kZTalxDwDLr2deo01uxPiLrWPZSpqeBfJABna9jgkITHRtACGrM2t32BvpiwTg3rJVI2 luiJJXAWU2BW3zwwwLPeY9X6TOccFRDlLNi/uhLY4cdVvfz2VAggUt5QfC8DMzKgaHNb/uSvosW WoffSDsUTF6W6XUA6wQxUaSCGcy10Qlzeq7dt208r3ONNR8wN/bcLS X-Gm-Gg: ASbGncusBJyBLS+0KaH6ZYpJ1w3od/CsE978c3Uy8VHEe2ymzMVadI9w9/VX3OUfIIc c5om0xU1SUKWAdjsKXSp6iLvIWTPS7pbe1jC50bK4k1wlgftFxIpk7bbTZ9iquwz67DmZJQeY89 1asnxEwBh+sQGRFE0vkMWbQoaW5SoPhhnFivW9fDfSEF3rTBAHjXweZGoN/Wk/2daEO9bL38uGU yUuFp2lNEnCPwcxmaFANoJBiGUfaOMjcjguVWgvrR4lHbXwchocK+LQBq2ukzys0Cdklr6BwIop t7RNcUD/v8/88FeMk4ud X-Received: by 2002:a05:600c:3512:b0:43c:fe15:41c9 with SMTP id 5b1f17b1804b1-43cfe154338mr111255455e9.9.1741866287362; Thu, 13 Mar 2025 04:44:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDgHdaZ1G01z8VuKBQ3BfPMVXgqQ5rvdTXEZ7bpTSjr+Dr16GZrLUPpD2KPNpGCET/hDHX7g== X-Received: by 2002:a05:600c:3512:b0:43c:fe15:41c9 with SMTP id 5b1f17b1804b1-43cfe154338mr111254865e9.9.1741866286869; Thu, 13 Mar 2025 04:44:46 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:45 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Huacai Chen , Alessandro Carminati Subject: [PATCH v4 08/14] loongarch: Add support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:23 +0000 Message-Id: <20250313114329.284104-9-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- arch/loongarch/include/asm/bug.h | 42 ++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/arch/loongarch/include/asm/bug.h b/arch/loongarch/include/asm/bug.h index f6f254f2c5db..b79ff6696ce6 100644 --- a/arch/loongarch/include/asm/bug.h +++ b/arch/loongarch/include/asm/bug.h @@ -3,49 +3,65 @@ #define __ASM_BUG_H #include +#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, extra) \ - asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)) \ - extra); +#define __BUG_FLAGS(flags, extra) \ + asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags, %0)) \ + extra : : "i" (__BUG_FUNC) ); #define __WARN_FLAGS(flags) \ do { \ instrumentation_begin(); \ - __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\ + if (!KUNIT_IS_SUPPRESSED_WARNING(__func__)) \ + __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\ instrumentation_end(); \ } while (0) From patchwork Thu Mar 13 11:43:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014785 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 693D926A0C1 for ; Thu, 13 Mar 2025 11:44:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866295; cv=none; b=BkNF7FDzuuEfR6W5V0gfyosr50UEdE1TAgkgl8kzZ5nvPzt6KCxry0UwHU/ZjXELj/IYMMNQ5e2LDr1qwUZWIwA3NcoWCAZSSliv/VlPwye7fIuJNxtVqjqPtHS5SDidt6UhiCKs9/mp8RcvgKbIFdnSzRIU4ZDssAwBdZLf0HU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866295; c=relaxed/simple; bh=0aizeDhwWkFKZsPeHlQzOAxiwKdPV8X3HwIBD/FO6ic=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=CRtZN9fs9gPgMUz8BDp5PAqSuIynkjs4HRYlJmNQcaawRdOCOI8nDahDhwhmmPLy8u4h6p4tGd62iSC8Mh8Mhm5tD2nV1TNRELh6+/0NtforQpaTEVeQu2lXbCU8FKH+qyhmwOUV5LmtfMCQGl7KRIKHfAhxKsFQyqqbOHD8sjk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AlxoX2DI; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AlxoX2DI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oNDdusV5kHSN69Wnsdcb+ESaCAhVWZZ95i0rdnVfZIo=; b=AlxoX2DI8jfL8OdV/Mj9lXXImOquR9Y7d96KgUA5r2p5KooxwGK6jULtE/qbvMjQubtV+T wmAJGrItqXp/hY71RfwhddqxcEFkWJIcezbVv5iAWjRnge35IkbPtryGuob42nNremPJJA TFPvpfnkI+ksnd2bvt7BDTbLIQsO9+o= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-nKhu8EJlNXuMNXRTB9Nklg-1; Thu, 13 Mar 2025 07:44:51 -0400 X-MC-Unique: nKhu8EJlNXuMNXRTB9Nklg-1 X-Mimecast-MFC-AGG-ID: nKhu8EJlNXuMNXRTB9Nklg_1741866290 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3913b2d355fso345415f8f.1 for ; Thu, 13 Mar 2025 04:44:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866289; x=1742471089; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oNDdusV5kHSN69Wnsdcb+ESaCAhVWZZ95i0rdnVfZIo=; b=TP17NUEYzG6E//vDVwhx/guNs7KBBazwtUuDyEgJlGSOWsjfdxKOo9WrsC+qFdPsbs aQ9dE7U6s2eAHWDz1HT7fltIppPiENDwF8N9XG2jCeyY2UWTX27SihLvPYJsu6oH+SSG ilnrUBom2C5famAH+zyEfTRPpuF0cjyyB972awtnOIzzNhMjOEH3HbMqOc0eHdWIUBMZ g46IxGUDZv7NFVRKNRpIMOkK6GaNatTYH/C+idDVFaQMuAT24GqWmUZNeE3JjAAKxgcs MCh7QbvRy92thUsu1h/1hCN9TiYH3M+WUsSaLhwq5/2/Jex/nqRCorM1ktXnDLdWzNKs UneQ== X-Gm-Message-State: AOJu0Yza59vifowbeOVsqU3dBlFGcKyXoyOX5sGeRPRIf5w/869ZFb3B jD3Hg3iUtG/rm1ofo5TsiGZ9tICxR23lysRSfkY1veYKp/nost+1Jkydzn1EGCkaygFQ7mBoWoh kCm1k7Yrfo5zEGgSUpsLtmqPn/menBCs1XunrkVB8xmw6gp7/kTbGICFd6ogq/ZKN/Gjie08cwG 1dm0gyGeOF/JTIP3KnGou0VzDu/3VIXqGtLuJimuNNzlhizCRa6X4b X-Gm-Gg: ASbGncsUHqorWfhAOpeKZ0HNwHW0gLcYxDqZpqVNanLfGfs9O8QeWf8GN65WLSnER4e v95oD4NigeDZd2vXtnoGCMzBGEk3j83BCAhin+9GkU7N4csnIN4wFSI+l6Uyui7vj8Xv+V3WGkR wipWOWePcP96RWYPf/zFAPH2FKqmMbR61mmrmAWSZnMk73Vr0LmdIypk4ZPUHnEqkMYxZiTIsIw 0Sg7rkg+BNC03bnfoEOEDNgCYy+Ed3Bh1l+yabU5IYwxKnSkJcqhbMMDCt+vRyCTLGDaypzHJxQ B7zctVXEQ4Hu2Nn78hpQ X-Received: by 2002:a5d:6daa:0:b0:390:fbba:e64b with SMTP id ffacd0b85a97d-39132d8afb7mr18596847f8f.31.1741866289526; Thu, 13 Mar 2025 04:44:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYwocEA7kYpHNOe02FWF9uxS8M3FuzRDEqfu4GtiOXX78+oDlT7RdxLzaiu9BpsPlw7lldzQ== X-Received: by 2002:a5d:6daa:0:b0:390:fbba:e64b with SMTP id ffacd0b85a97d-39132d8afb7mr18596786f8f.31.1741866289052; Thu, 13 Mar 2025 04:44:49 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:48 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Helge Deller , Alessandro Carminati Subject: [PATCH v4 09/14] parisc: Add support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:24 +0000 Message-Id: <20250313114329.284104-10-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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 Thu Mar 13 11:43:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014786 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F00126A0D6 for ; Thu, 13 Mar 2025 11:44:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866297; cv=none; b=GvL3dknSjTc6mE0kTjZUrYXFjOMwO7iGvxU+4WZ7DXdAHN317N72GFZh6TFqkVb/k8Jhv7RowG9CcjEoOTGANNhgyTnFC8ioskVaY3PhA8bASDEJgzet4W3wOFlgnY+i3+2OGojAIDpsC8a6b1D4qTkR8gQb+6SfbcDKp7P/Uks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866297; c=relaxed/simple; bh=J4X8YZO4x00QVWpFsvAbnTlhyYgUvXZEkg17s47TCi0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=iFT5hsfzHmOVPSgG3fKbnFOEsfhyf0mpLTGYs2m9gHM+3ONIlltF/OVb/NQ+zLzVs5WnIpJeUVrFZubHYTX7xRQTBCGRk1tLBLr7WbRETkJQQ7I1xUkvZvrhfBZrRyiAJl0qoiBMCyJwEqKdL8jLgsSAwCSaJUS1+6u6kC2xlLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JhFfb65d; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JhFfb65d" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EdALik7flTFVSWTVblU8JKKGGV2JCoENkhxrfjNtUxw=; b=JhFfb65dbLIFuTOsmZM5CyAKYRE/nYHwuuMUhfMFJXL71ecgONeVT5sCU0JRbnXWD4mjRw lvGo4rzE2KKAHaAR6Sjbaw7cgLxcwbzmlOQn3InlGswLBFVfjH5CFHvADo36gSWlI307hK tLxIwCyVHTjMXtBBhaYy7bzTtx3Zz7w= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-ak8MDxy-Pd6CPWyVqCNVcw-1; Thu, 13 Mar 2025 07:44:53 -0400 X-MC-Unique: ak8MDxy-Pd6CPWyVqCNVcw-1 X-Mimecast-MFC-AGG-ID: ak8MDxy-Pd6CPWyVqCNVcw_1741866292 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-391425471d6so306827f8f.3 for ; Thu, 13 Mar 2025 04:44:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866291; x=1742471091; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EdALik7flTFVSWTVblU8JKKGGV2JCoENkhxrfjNtUxw=; b=LK2wXz+sh67y/89JiZqxc4j8bibLbWx/0vQYom/7QmI/Bo5XFq8XM6D2lGxC0rFyNt QHWcHavfKsEIm5/ZsijfZqnaaLaOG/pzjTPMQA4upi5JAzViRQ8U0FQR6EFIaf2j1DgH /L1IdeAqafag/J48buTq7EUzQ2a6puoGZklBYz/kK8nxx5VQV99dFuwZXIm/ZYwncouq iLmt0PNoKkIFYyLu4A4T+7ovVblv6W0jZnNYgnt5JlfSVFcoaNYtDrG/w3H6EVSZeB7i KO1PK/1gPyWZs9M16XUdAP8fTlE92aQ/usJbIhOGeokMWmSSeFBtO5JWbSEgc/bdKQ9s sjfQ== X-Gm-Message-State: AOJu0YzbJgie/cR4QRLiXPUDIBqwgiX70IlbV7EB8/b0ulbRlLqW2mf/ 2vidS6HiY/f8nEbaYJLMT9gZKfxiLCMOqXbP+orvUaz2oL4o4O2kYbG+PBc3Tv6bpYu76jtViv5 8jLwMTwN3UuTLT0I0m2DLPQWOUdJ8BDvLarMLMCb3tRnbu3HSl2Bihb4vQd57Or8J05SBHBEL7N rxBo1Rz2R0lurRmndgk86Adfzbw+AVnkiPqpBx4txDDIueZP04C+kM X-Gm-Gg: ASbGnct8PpdRxY0hSpWGTnH5pSGZpfmOKcP6tmJgPPRgzOJED7/o2KREMeaX6dfAN8E YxSLZFQ12fBtRhSCqXI1KG3i6L4zDuPjO+rOKYDuoUBRMFXI/ZiZrEUXQT0rAJ7s7aM0V7Z4EHa bh+dwoGkJZhKo8BG92+GVtt2xmyII4xKtsmMmv4A3uqIZtjosNpZ9/V4PWtyzc091ZY/7r0e1eb UFRtyAyke1WIAriTqQmpb2UKbV6lOZDnADzsHiHNLmPvQOzvDZVWQ+yBWt7Lz0K6GljBaYtX50C eWczWTKIYOp1fDHN+mY5 X-Received: by 2002:a5d:64a4:0:b0:391:a74:d7dc with SMTP id ffacd0b85a97d-39132db7543mr19148462f8f.50.1741866291607; Thu, 13 Mar 2025 04:44:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFc68icOs2UFLsGvYM02K+KaAXrxdUkEYYl5CYIXnV4BsTbvYwzMB6bzWlvY18H1nYSqaV5qQ== X-Received: by 2002:a5d:64a4:0:b0:391:a74:d7dc with SMTP id ffacd0b85a97d-39132db7543mr19148405f8f.50.1741866291178; Thu, 13 Mar 2025 04:44:51 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:50 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Alessandro Carminati Subject: [PATCH v4 10/14] s390: Add support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:25 +0000 Message-Id: <20250313114329.284104-11-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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 Thu Mar 13 11:43:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014790 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39D8E26BD83 for ; Thu, 13 Mar 2025 11:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866316; cv=none; b=pctWqbu93Had6rb6oLdA5mUctLSpIZHTDRvm8+NzBOUmyuQ1qnPcffUjcT5rmj6dYI2ubi5CdRKyvO+n86dMNwGQ5v7TTVfk7K4/bNb4wfp7S1ny1s2tf4GmKxMyZ9oqrpHPl3DPV1Uvr/UwIHofIOZY6dfOMhiCOszuZ52b4yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866316; c=relaxed/simple; bh=NbfqpVn1osOn99nDNr/w9uuM1r2DWHYwWsVBZu8K+4o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=juU2eXEWgtls7aTj889oU4b8QI77oFiUyPNbYkkm69p+W3lGX7ZYVpxZCzkl7w1ljdQC+J0+AYYh1NScDj3/bq6tsrD8EXGxyzYJeD9c0llZTsuOWnAf1G7NBSl8ti176EcY/uRHnkvrmAuP0Gvdwrhrv9diJt8iH3booMuonO8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GK6XdmD/; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GK6XdmD/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866314; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fuCFF39iXwBMHtdVpJheMeZKmjdk+AFM9NbRaPloTHM=; b=GK6XdmD/9dhM8+h2f8Te+duVkmSCh0xq7o1zP2w48TCbJCl1fP3hCWha3guLXARL8WFJX2 ZchUy2/yY9+pyp/pUgQ5OJVkF8HJ7EHIouw0QW5Rqw5VV13v4PaC99KG6yVP9x8AE7TyD5 WvmPdtmAl1eASa28CcosQhI2R7cpKVU= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-440-aFNC0IEQNEyiYOWnt4MxVw-1; Thu, 13 Mar 2025 07:44:55 -0400 X-MC-Unique: aFNC0IEQNEyiYOWnt4MxVw-1 X-Mimecast-MFC-AGG-ID: aFNC0IEQNEyiYOWnt4MxVw_1741866294 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43cf44b66f7so4303935e9.1 for ; Thu, 13 Mar 2025 04:44:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866294; x=1742471094; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fuCFF39iXwBMHtdVpJheMeZKmjdk+AFM9NbRaPloTHM=; b=rph/AQ9WrOAUqZbkudsxdtkNxZlEhTZ8HJYHNqxrF4QgLrk4r85GIllYzwDdYT5gCN e0DrVR0ME9r9VhwK+uWOS8VfJhsAFlZjf1VwHMYyhK6QZSr6ousVU8uIQzoxw9HV3m0O eiYqF59gHaZlYK9uaJBULZqg/gRx82pGbPbu2dh51gmMoVLhZNEJImjWP3imf5Uf8No3 OCwHhTtHBVqNOAqKacCA50/71zQFSLU4NA38/MceeZRwVAHubCfRf+Gjd/Qhh+1yc+JA JbfVFa1VZOX2fngA6vqMP3NgPnfSJqKq+5JwbTvSZJHMRUFDhYZe5kX1FGx11+E21aOI G+qQ== X-Gm-Message-State: AOJu0YwI5Pe7uAwDMymdeiJSguSoaFP2csxo01VO8+flAAfgGfWzCXsh q28WXaJ8oYfFk5G0eTtWKlUW9DA0nEa5k7RM9WEoI1PAhzuCDerdRqfdedwPatvvHggMqFBDo7v RWLpcgmxFV/YQa0XQuxExMEikG+d/NcgIrDtgkIoZzplfEnIAV9e0m0AiPkQBxLFJb25wtTPdeX SgM/ZLHwQpY7pWUsG2ctG4bckge/212aH0e2bATHk9P4oG63yiSyZW X-Gm-Gg: ASbGncsvJmn7VgmEX5SU5nwCntFXGvUDm7Yo+3AmnUPYnjcv5r4z2FgVy3/5fakUR5S oDFJESP9HfdFx/XVqqRVmMongCbhw9OctnpBiaV/hXZ15unHtwDSklxuWx8DXWvNfnpRLCWF4rg leis/JTebs7GTat5mZsyrzYsS7WECxfwV51O21oQ/sQbyG0UrRWzYjga5DVHQLTqRkuJP2IFi4I j6JMC2wtnVXCglC9+KCXKWThhur3ZX2GQFZ5RdtaNSpZAWLJ25YmuUU8AOlpzH73YZo6Qtykytg dxNfHXXBGa/dA1Rf8Lw/ X-Received: by 2002:a05:600c:448a:b0:43c:ee62:33f5 with SMTP id 5b1f17b1804b1-43cee6235b7mr136023595e9.27.1741866293922; Thu, 13 Mar 2025 04:44:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0wHJ2zwJ8yj3cYw/s9VH9lfhVlHVsfQsMYeCFjOVxBPaF+5L2/VWS3+5UdzriUt/uCnhyuw== X-Received: by 2002:a05:600c:448a:b0:43c:ee62:33f5 with SMTP id 5b1f17b1804b1-43cee6235b7mr136023005e9.27.1741866293519; Thu, 13 Mar 2025 04:44:53 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:52 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Alessandro Carminati Subject: [PATCH v4 11/14] sh: Add support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:26 +0000 Message-Id: <20250313114329.284104-12-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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 Thu Mar 13 11:43:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014787 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9979726A1D9 for ; Thu, 13 Mar 2025 11:45:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866302; cv=none; b=mkiel+K464+sBKyi4yN4OgK0Zl7/bSoEkqgpkPtr2GnuR1BV9cRThWIXga9xHqHP1hbWCo02Q1TDc3huRJ2spJsXtZkSoE/6KYYAs39/FzBIkCXrvYvj+rlkVWG1qEoV6G5wF4humFubGtPtHdGD2OF/7mWs77sT88A6LT2WXms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866302; c=relaxed/simple; bh=LkqKUNYGs/ePGkjxR4/GakhMBC+dOQkDGsyg7Jru2eY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=u5elRDUPXyOavbAjjdY5CmW6J1SGPSDFZCtqk8I2oQBH+sztD/j76cpqoIZLbOOfUZg3Zm0KdQ/+wSREb3bAt3QCEe3zNl+SWy/xkguz3Ivgex7+EGKiG82rzgS4eIs+ksnkBu723qG69r88019B20VnkZ9harCqWexumtBfAik= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XHapybat; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XHapybat" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866299; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Td98jnkcLGUCy3vrjbMOv35ZA5bivtUA493Q3YOVPt4=; b=XHapybat4/xBhr9chJgwWGv1+sqJgQmRaaI4h42Hfvagggh8fcnrDoEh/l9TaGr+d1tt4Y diQxWc726WHIifX16OquWAye8RL81p75VK3Et4ahOITZdsuwZ+C6WPQub/UmhkZMmWxEHg Dtg/IjpPi5JfCirirFe0yN43xPUKwFI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-26-qZnji8VwMB-jmD9RY952Iw-1; Thu, 13 Mar 2025 07:44:58 -0400 X-MC-Unique: qZnji8VwMB-jmD9RY952Iw-1 X-Mimecast-MFC-AGG-ID: qZnji8VwMB-jmD9RY952Iw_1741866297 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3913b2d355fso345483f8f.1 for ; Thu, 13 Mar 2025 04:44:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866296; x=1742471096; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Td98jnkcLGUCy3vrjbMOv35ZA5bivtUA493Q3YOVPt4=; b=eTnfgpd7tVklX1GQvK1HHH2YHt0rz/8Ve7OxB8rLY9xwH4mC8Gg0Xrs5r/9oWtTQ4K bzaT5U+Wkqs4cCVflJYayHN0OP8oR+iGXK7CwV43tUV2yHKDtGoTu3WNOr8fQA+I0FoC JRJD4Ol5DeK19qztS13wc6q2ESRj1/s9+Fs3mriWljlOexYi4lQs56VslJMzxt5uOXWv Qpn/Nsmmp71+H8PUvkl/2OVuV4FknkXFBUkXF8iLzN7a1TuJsatP8qaUhCFrCZdkmA00 Wa31ND0oan9RmHLtBp9NIrNlQV8BjuJ5oO5aBRSYqsCYW6OQ3Ql8biYUjBdcXulC3WRD p0ZQ== X-Gm-Message-State: AOJu0YzegDx28TL6e55aQ1gkVDGukdFbKHMDU6SrTIS3og7AkN0pVQkH +YbvfUSWhZi4HFdWWgX64h1V7d3g0NPiuJz5955haFRGwJ4VU7V+rhiam+tyilfPBVdinKb6KGE i5CR0Ji/gMOV3N0FcyGg/TIEU2pqfRaiHehfxl4oluFMXHlNOMbCcAhAH4SSPJLR722PgG9+ksk FQaUgFrVrTdODVSXs3Q/L0Mx7hVjLh+o+wc0mWdgNaDHCzHRP7JKFx X-Gm-Gg: ASbGncs5e9uiTKr41psuEGBPN8Wydj5vhaDx94E+Z3VflNv1jmOnrWYzfqBh5tWOk5g LyuN6E0XhHATcZLtttHbvTgWTKERKj9J+JxnLwFt0qRgfLsNhXbYUlG84aHu2/19jjoDPwebZux Qb5OEO3GKs8zjh895Ss1Nrqz8OxolzkD14OUKlX98e3EUQh+oSOl428Plqmb0TcMCP8FzsujzRJ 6nw+A1n8IF63qqmb7FOHCNt+GipErKNs1Dd2L8XcNdpzjIFRrMDADPZtHYEagA+HTSa9NgFrhfo ko0j/ZItEnkxP1R2Owre X-Received: by 2002:a5d:64a8:0:b0:391:23e7:968d with SMTP id ffacd0b85a97d-39132db703cmr17836151f8f.47.1741866296182; Thu, 13 Mar 2025 04:44:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyU2ePtAFWyqCZMakOsiK4/iIhrDziNVQawXJEAak4gPJli8tipIq38M0q9zksW0XKC08fAA== X-Received: by 2002:a5d:64a8:0:b0:391:23e7:968d with SMTP id ffacd0b85a97d-39132db703cmr17836093f8f.47.1741866295677; Thu, 13 Mar 2025 04:44:55 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:54 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Simon Horman , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Alessandro Carminati Subject: [PATCH v4 12/14] sh: Move defines needed for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:27 +0000 Message-Id: <20250313114329.284104-13-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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 Thu Mar 13 11:43:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014788 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70D6526AAA9 for ; Thu, 13 Mar 2025 11:45:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866304; cv=none; b=uL2jC5nIcOTW5Aiucq39tlWicOQtN3n6dVWGoSRQK9oZOoj04cUFmm/8ouKmnP5DAah5VeCtMzf1RjfKxzZe6HmqhOCeN24+Z9Ro2n7nz3o/fi0QT9cSgCK4AZ5Izk6arKnDxEDLRLMnvsDWQPGmaArtsMaHLyd4YJZCsMRJfyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866304; c=relaxed/simple; bh=IBY1cNO3qDPo2x35DSNukBNEFYKja79GMNoThS6fomc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=WzKCw3qeMkHJKGa4LvjpZoCkZOIXPmtJO61cTrGurSGHibOqLzBzcmJdqiv/C1D0EXbit+kjAZrKXxO+lo6BsYAOn3St/8OQVt3q4ZyGRCCEycXPM+rZR2b/atgxj2KY5h7nYZJxaVTdyGkxLrXWBrmkYrnZeptLajhNenU6/wI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=V0TqN5Ng; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="V0TqN5Ng" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gL6tEDolxd3AJJcGJnpcVh0p0Gir2o2MhbQax2LwBfI=; b=V0TqN5Ng4Zzu/ImLu7mN+jZKmhJbD9drlIK3nzhvhL4pDlHO5W3u9VY4kr51B6hGvJCU+8 k2ALvxkM5jTTX95J0CzkLtMeom3+p+GARnQvNgz04Mpqe+Qpcetj2CSANe2EJ447aaoJi3 72d4ncC3sJtbLjFKwwrJXmEG5p2XsuQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-416-ydKr9BTuOoWTFpXXonMRMw-1; Thu, 13 Mar 2025 07:45:00 -0400 X-MC-Unique: ydKr9BTuOoWTFpXXonMRMw-1 X-Mimecast-MFC-AGG-ID: ydKr9BTuOoWTFpXXonMRMw_1741866299 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43bd0586a73so5906085e9.2 for ; Thu, 13 Mar 2025 04:45:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866298; x=1742471098; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gL6tEDolxd3AJJcGJnpcVh0p0Gir2o2MhbQax2LwBfI=; b=ei+OrVE/7uLJeJlTDbVKCG/ZvABTL5MkUdbBTrxDi3ERu2zm6sm+4FwSr7DxEz51jH zm4q94GqkNgdwpoXURaBDKoKjhSPV4+XXZdl8mPo+si2q3h1310NMIR8ASsqL14aHhsE NuByYGclW8HTkvRR7MqXOx8AEh5PaF9ia+pgWTmX2x0zJylrXVINLBnfQB7u7bpBGc5M n3PYVz/F4MNfSZwSleL1pGKvoUl4Jf4Pm9qu0ogeziAiWwO/H7to7y2my/W+P5i+SE4L 1pXyu96Sn3cmmlPK0DQLP92omjqJ5BvNFtrvVJscrxd8t3QHvSznCC2ZnaMrr3kvzMIJ 90qQ== X-Gm-Message-State: AOJu0YwvXFyKDTKilwPE9yoQ4/Z2XAzoDa7DcV8UWVODvb3voPxK8JEm ZN5FEUPcFAQpghBRJM6pByfqyicJSw3RyfqfPe6eS3C1wGmxQ8OUtaGFkI16SSwvYyu5UwYAJK4 HGbj+l4/987fDLGbN6HUalpqRedxJi1L3Z6/k5NKktO1pu6UBkDrbrAocInlmbGHpcq/6q9s7ks yzODHxwdqlnK6oz84Kr0AR/mLKg773aDednUMAblBdDmWFOML20U8n X-Gm-Gg: ASbGncuLv/lAFuUx4fSSrGFSig3atXFQ12WWekfmmaq7+wnEb8hOYzqhlTOxezX0jl/ 7NzGSh6twWdxlZwOZcwzmMe6ivoWFZvNevxWqSh8tetH7FeUg/XlndMlNSwDBMbwSWI7Gvg/NuV 0/wFJsj8PGVCxGdSgLDgQtl1kwXc4XTQ528b7Syx1Ge/ptYyzCbr3OR7G59Q0gTyc34K84CfhdB 1yx84rpbgO4n9nct80l68FzL7JRTLMaskMM3PS0dvZDYyg6KjmL2K9LFiLM6/RJYlCUOyfeXJ72 EY3RMLwFGikfkO8PFQ5y X-Received: by 2002:a05:600c:1908:b0:43c:ec28:d31b with SMTP id 5b1f17b1804b1-43cec28d58fmr198762645e9.10.1741866298414; Thu, 13 Mar 2025 04:44:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3R3Nh+MesHXp5r1AiRFiydlKhpsUv7CB4RneKkaatJviaz79nmlaZTG/mhvpsulZ3LqTgOQ== X-Received: by 2002:a05:600c:1908:b0:43c:ec28:d31b with SMTP id 5b1f17b1804b1-43cec28d58fmr198761995e9.10.1741866297943; Thu, 13 Mar 2025 04:44:57 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:57 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Alessandro Carminati Subject: [PATCH v4 13/14] riscv: Add support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:28 +0000 Message-Id: <20250313114329.284104-14-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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 Thu Mar 13 11:43:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014789 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F263268C50 for ; Thu, 13 Mar 2025 11:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866316; cv=none; b=eetX6I/HZYsgjHMTF0PTkFK2oGqSz5it5/Ac+uprygs+iwmPs9vknI4/xhzdQeXs3/SKZUqBHhDXrmZz15qKAB+DLqCjltgNhnwoTskIXsCjFNbH3gLTPbhpWWwUcnxscb9k0F0j7a6SNVr9WTapBZHp0SAMoLFAEtjl+s3etNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866316; c=relaxed/simple; bh=xetTM7NbHTpP54GNd2evXkwpRCX6m2HaBd9Qo2PRDeA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=Nfs5tZiBSk9+oD9Vcobz3NCpH9e+sYiTv8o0mysZAiuCG1nMVo5m1Pb0E6yQobzpOvb8SmEnEIU9OYRPKrdPVVONqawAxkn5WSXgp7L8ELqg9drjg6kY2puM25o3fHYmseKJjIBtVdBZUgry6UCDtBQOFhKX/lxlztZv2SjSKgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ffFI9KB1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ffFI9KB1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866314; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BMlGspdrpbJ31u0fCjYvjyAZlqg7W4BaKawB7P7nRsE=; b=ffFI9KB1MoknlgN/YaPXeQF5V9K879W8sTP0/pNncTGHIxQKNo7RThXUS/I5vDSeRr0sjo fuirh5Ikmfxfpzfx+6g3fbEThTnubLhR1hQp7aTc/AEA2KJ8yXezep2Qq6hB9geBRrwUuA NwKmkHdNlo/8hCXzKSjP/mpN94QvssM= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-154-W8V_AIXXMu2ILA-IG7LuaQ-1; Thu, 13 Mar 2025 07:45:02 -0400 X-MC-Unique: W8V_AIXXMu2ILA-IG7LuaQ-1 X-Mimecast-MFC-AGG-ID: W8V_AIXXMu2ILA-IG7LuaQ_1741866301 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43ab5baf62cso6562855e9.0 for ; Thu, 13 Mar 2025 04:45:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866300; x=1742471100; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BMlGspdrpbJ31u0fCjYvjyAZlqg7W4BaKawB7P7nRsE=; b=lovQTfzIHgmKM4KXcyCq+heWFCCiDw4qv2pMJUsOUuGXzOXMaetMVwac5nEL4SbGWq VhTJT5aaAffUrvu7MVrBwUjIovxFEUYHY/ZH9+4X7Me+iUTOfZr8heCbWNTpVD1QSi0w VuPa5z5nR+2dk3S3JxhLQ53UfCbRw7N6V9583uNGwNTvdNa41Hc4a4gNYFt5ulfqaC47 7hDv0yS7ZpXL/BnRq+6zXr/8zdoD7SIkSpGaSMqkG6CQhW9enxH2zsqsv1tK5KKnrBJi ee/5iEjgkQwKs3ac3WJI/InlwPjzRGcwWIzGCNP1WwMQrRHjVcDSHZbKpwmaah5/57f5 xd9w== X-Gm-Message-State: AOJu0YzhJTXdKFH48TMno9YG+ibSp5qaZYwGNAkgKI2vc96M1vfl8r+n Hfx1QOCzoNE58wt9u58RnXYsloaHt6bKxLmS6WkNY1Tq7+QhvFdyda/rkFsIH7/9pqfvbVD5sZP jxIwCG4hfzzcSx3991DFbYOISeg9Qs/uS4uUYcIF3kVGhn6MNGevQidaH+Y10+66uQSCC/Qfv3N pNZCpb4aRG7b46JWpbiyFWrUekqRYasyYihu5cEkLXUb0pKbU/f548 X-Gm-Gg: ASbGncvVQWhtYWkiqbVenzfnvDfompWaIcnPUCkN7EOLzZxFeyK21GXKrRf+Soh+G8V ORT9jk/4P0H/lF5KxObYSmPCtjrV1mwr8wd4y670e8j/sFNWh3SPFNNWXw2iAC0UFCcmhO77QJy pu66gMW6W5CFBcu6CA/80Ut4dbeQdHe7k2JAGUjqU+NqX5EgrFtKVtc7bgrScf3k3x96TsP4G/i AUitV1g6V9peCTa4jMKVWqQZUKdZbB1KLeDSDK2ZwcnjPF9pKf1bxfEqqMfxFdMHFoZ3TmEBhf0 +MoaZa+jem3f2EidJ+qz X-Received: by 2002:a05:600c:470a:b0:43c:f44c:72a6 with SMTP id 5b1f17b1804b1-43cf44c76ccmr144327275e9.2.1741866300593; Thu, 13 Mar 2025 04:45:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERxTxm4YW1Ezaow82Z48NXt1aSx6Vv01Gh0iy7KljuVnLSLjwCs9KSAjTKcqnBX6jh4hKEWQ== X-Received: by 2002:a05:600c:470a:b0:43c:f44c:72a6 with SMTP id 5b1f17b1804b1-43cf44c76ccmr144326735e9.2.1741866300120; Thu, 13 Mar 2025 04:45:00 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:59 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Michael Ellerman , Alessandro Carminati Subject: [PATCH v4 14/14] powerpc: Add support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:29 +0000 Message-Id: <20250313114329.284104-15-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Signed-off-by: Alessandro Carminati --- 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)); \ } \