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: 14014865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4FF63C282DE for ; Thu, 13 Mar 2025 11:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=c9whUtdSVycPepKkB48hTehRX04VaeLWlAoVnLwkI/o=; b=aRF85CWKSnX1VrsdpXC0eLRMMb O6MwwR8B86jb9f0mlGwKzqnSjQ7zgYJcsXfOc2HKyE7yFHr0HYcLIJSzN3HdJ16iIM73WZRm8b7go OxRZ8FR+stJZl9ASRkkpXTlVcnz/gJOnR2xrJ+MjPOA9X+uKcr5jcZ5RzTYkQOOVIino/0Typ7UmE y8XFQtVdsMmJw8RsCdDwgPGA+bUE2TRFmAUGPK0zFVwfWeY5Ua7O0YSoBlwH1SraH7Dx57cWgBCGE tA9cQaF/cAOwuFQMdXYJMFgYO08dHo7gN710RXoRWlnsgQ4yzMdO2ERTu6/7ADa3Y2Psu6/JMf9nR kLnEb7Ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsh5d-0000000B7eO-34G7; Thu, 13 Mar 2025 11:51:05 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh0k-0000000B5nF-2967 for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866360; 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=XAFy9Qszg1K4dV2YbkBDJ9YED0aSxG6B3K6HoidmVrdeimyPhFs2D8VxVySGkfUlOb6cis kdr87LslXZAIuG0w5Zgz2JAZB/5GvM02ghE8L98qukJXZmq1ascDia4Is92nlBtMTr3wuG 1mwV17ImCaGqCorjvVqWucHBLsHZsAw= 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-457-0X0cvSldPymITwqlIN9Iig-1; Thu, 13 Mar 2025 07:44:32 -0400 X-MC-Unique: 0X0cvSldPymITwqlIN9Iig-1 X-Mimecast-MFC-AGG-ID: 0X0cvSldPymITwqlIN9Iig_1741866271 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4394040fea1so4691765e9.0 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=hvxFHC7LXxaJGNDxQ4PtaMiJ7bDvXW3jEKj2uDjeqpTE8Wo80x+0koWHEt9NP4NEAn Wg32S31gWbcGTWMhgL5CvETFGfuJXrj1EpnrL8OYFx1kEhBR5caftbFgu/ElRIR/WCAo Y7+hhO1T4ILlIoYKA9ODWhKFKyv7M2Tk2ZtTEz6gCaew+Mj5R6QFVF4fUL4CEreOABX0 XJpmXJrp2l/g37UL7if3uyTkTJpXLK6i8nOjFpvDsObkI58DT7QMCPuoSDZWn4rr7FXR yyyCPvjwsgTQWMVP3b6nua811w8TZvJ/Vysh+H2XeWgvTxM0iecusYnIxBuRsgXVHqIr QHEg== X-Forwarded-Encrypted: i=1; AJvYcCVeE3Kf8Oze+Y036RWMTCpc5rRCg18EOP07qU9XI035RCwzNo89iV7oN/NauXcTcO6f6L4nMJoAqWLj7v5+XLHu@lists.infradead.org X-Gm-Message-State: AOJu0Yx9eYxUcU573u5wArfZtD+mJMxG8zNCcDJmBnMlXNlCYMHhBZzk y5NgV2h3kXGeDQKoMPh89O6nXOyF12x+OncmjcPMzEwCMcs2SC8oAoz7GXjwKz4oLgh8SS8OFgQ 1Qv//nacFKMCXMeK34hqRCX+3Dvsp9auBt2lzVTZgLeWS1kt42Rv0KlyaMxMQ/2hqzNXXRfTB X-Gm-Gg: ASbGncuLw8Ac2gcve7yrJd+DrvzUCVyeQ9zzPvwYjnSTjnUeZonSjRVpXdEJu5+hQ9q ZQHqn9FHs0888wkH7YPRzdR0wNz54f1GGDkbRch5lDd/cnPR9xhs6WcWw1D6NbGEzamrRgk4lsX 92vHixk22nk1W4jAC0FZo3vp7HngsctwZG6Gpsr+fg03O/MSq6v+N8Hi25Ti4ObhDCLjDkN09wq YMvYmZINhyFaQpNQp/1sUKaoq1/Bjl3cik/dCDrPi9Y0gOkaEQA8jdxEZAU3X41HACT5JVDlCD0 QfMBSy9B+hSa/caMH+GZ X-Received: by 2002:a05:600c:46d2:b0:439:8e95:796a with SMTP id 5b1f17b1804b1-43d180a4435mr17959585e9.13.1741866271298; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: C3RObYtyvOoUuXPxzSnT8m2OOtYQiZnMz-ajPdObpps_1741866271 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044602_704005_469BDAAE X-CRM114-Status: GOOD ( 35.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 41FE3C282DE for ; Thu, 13 Mar 2025 11:54:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UxCl1osfLw2v3G3W+1kfNU8xiBvtJTPCZorcBEjeG40=; b=DyhIDh1HtsG9dbKJAIZHwvYtOP aPlzFbHjIR1Guis3ATZbew2L4UzvVGR1sq6JKGcgjtfpbjiIG1ucc5FQvcnM24LCzA9iZf487IcSD WUDPuLk0xxebZ8fGfi3462X1XBEd9aBALt5S8nZOImkybpNFiVv/63Gd0jTejBwvHSmmVUb9AZqb0 pJyGkp6TTJL5h0AM5ynSLeQi1ki9FJRYZ+9D2azxmyEvtTn5JxegD7wlVOQGJvHXJ9zlrV2lxFDUq y/Qr1nBvFWG3KW3aR85knCmRIhonuOBxD9ENA9gfMSjipreLtS5PqnHy89gxAVPmteGvUZyn16i2n aiZx+7qA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsh8u-0000000B8aE-1yzM; Thu, 13 Mar 2025 11:54:28 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh0l-0000000B5nW-0YM9 for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866361; 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=VBzuhPk3Zq1Q+zhWOge7tnyE6q7mqA7np06T4FzfCrSSqY7CuX1Ga6xqOPdoMfU0wOO1Ii l5ZSKPghqkSaF34zAoBpWBwnPqFUlfC+dooSyKW4qINVQeuyETu7Cdfy7NbVUECdDLGPdC 8+YK+tk5idbahHDkpv1AkLE5wa50Oto= 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-221-1XGesYO4NpqcF7uLPnQsag-1; Thu, 13 Mar 2025 07:44:34 -0400 X-MC-Unique: 1XGesYO4NpqcF7uLPnQsag-1 X-Mimecast-MFC-AGG-ID: 1XGesYO4NpqcF7uLPnQsag_1741866273 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43cf44b66f7so4302205e9.1 for ; Thu, 13 Mar 2025 04:44:34 -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=L48xg7OKTN01Mjgrr37dg+MKOwuvGSmTOYD3oXB03+hSbMT4bbyR1HpkXipMyZS2yA oPlT+a9AIjt0Q+cqNqHtwYoq0D7Yv7f7IYxjeTTrdmqymi36jUq8P9xJ+7DT0nwmSVuL rC/gtphRZhHg26tIEePxobcCz5cr+gmA2lMpBbrXMCy7OH6814qIconaOkTOv7WHgOh4 H9nX0m0ZTmAzQpYkc9Z0i2F5DHTjAh/xvV8RdGlzxHxdJaSS2j1NrN7I3ylZyGjNZVm5 +sQsc+Q3a170i7iGtOVmWQoG6tOvp4JXcIEiz+7Ah+mX+l/khErncI9+FB9VZ4M8hnVK 1lww== X-Forwarded-Encrypted: i=1; AJvYcCW7lrAEfrrD5jtUx6fsYEsPYEQpTHVbegSq7t2yXIajNBWdH6eM2Zea3wJKM9n8QS0GhPVN0ZEmYbhwpTGKrN1j@lists.infradead.org X-Gm-Message-State: AOJu0Yw839DryogZ6fvVvNC1PWhkzG72hCra7yZfuI07SlqaN2IiIYYx +GwiGCQbupmwhnZtMUR1SF+ZKI7CBsrrtfO8gMgpjkzHwrA8o+YMS3ClTHKgEw6AUmI35r7QEuO lDyPXtWmzKVf+sP38eTqP09PLkuNT+1n6a7HYtrNBMeqqVggG3by1GHRs33IZVeButpoFlike X-Gm-Gg: ASbGncuCFNPEzjTE4wGylXcgVw6ddS3Z1ya7r/u9WNVmPjIcAxjD4pwW/40QbviUMdI 4Ok3liGk+3xwbX2Za1lZYWtgBaJnSY3QTQz3NF5xeWLxH8Z03c2Fgsm7mb/DvDIBo+I7uhHll+p E6uZoN9U2IvlUa0I/QXUSnQew9QC9GMVskcUrc9IAuhOUhhKE5t/f+2g29T6Wddqu/miEpcowt/ J2wPUU1TDIYHUugy7oWi0EUgQNfaPQ9HPp/h42WuzHu6DLVcJ4ynBUpp9HLGgdFGAhesuRJK/fv wNaek1CCBVNbH6iwgPq2 X-Received: by 2002:a05:600c:190c:b0:43c:ea40:ae4a with SMTP id 5b1f17b1804b1-43cea40af7amr174500555e9.31.1741866273482; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 4SKDdcVNi-kCwAYZkAya_UFTp8cp1FId5cMoRPxcRws_1741866273 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044603_241771_02614C80 X-CRM114-Status: GOOD ( 14.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45208C282DE for ; Thu, 13 Mar 2025 11:56:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8XY7u+VGe4o3zwipniM3kgRblYBzOD2SlUABTxKMSlI=; b=DbkGnzbTYQhvEShysocujKZ8zV 3J1+cKWHztxBfteh8kHtKfR+f+5n205eeC9t8qJO3c0LQWXo1eAKBweH2gBqomyFDJYEMk9yHuhhe kCpViqK3cUyKmG//Juab/JhPzG1nIky5VSI4e5gjGio42E6Ehs8CITzUlfKoXdzTk6yGi77qy5Kuq ffsYkiYD54VN7ua0vjA2jR1XibCtRmozYP1ph29QucsaS0VlFkMQIupLBllXueqWi+HK2dFpSI8Ob C+IQXwh0YqUj5bx6z3ID5CrDyJ/gvdQeeOatT6c2KsyhwoJ+IVOR/pjtE/MIuFWaXIrCXwkJsT+qZ uU2VnfEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshAY-0000000B9Cp-0icY; Thu, 13 Mar 2025 11:56:10 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh0m-0000000B5pY-2sSw for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866363; 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=MS//uN1S+3/H2lxtvjvZb5uu2CLer8hjWohToaYux58hTa6Bj0F/Q9FoqJsRIKfi8rmU2A aoCPskTmJ1SiMlac+SaHiCzE0rqn+m4q7o9+puQ8qNyRofZCKs7LEYWdn2pkRIpyFkhCZA nR0KfGiHZpiZ9MLCdiiz3kE/znevDio= 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-323-N8Oho7-jMViFFvxS6OSI7g-1; Thu, 13 Mar 2025 07:44:36 -0400 X-MC-Unique: N8Oho7-jMViFFvxS6OSI7g-1 X-Mimecast-MFC-AGG-ID: N8Oho7-jMViFFvxS6OSI7g_1741866276 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43935e09897so6480715e9.1 for ; Thu, 13 Mar 2025 04:44:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866275; x=1742471075; 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=IIcpE0PvGUAdpOdV2x5oMF4DEJdbkMk0GK2vdbYHZmsAu6mL11XsagfFbMdDbL10Ur San2X57amW9loIV5xB+5aLElFYfXJJuypm1EmjF1Sh+IeubGkSkQam0f42RHgjpRjXLw mcPK0SrTbS9NH0aIH1tYdmRPEMvsMD9SZHUBMMbkkzMEoyl66pvoLCUHrSXV59KJnZ9A A4opUtuhNs8vssKjXyPoDFfDpL+ngHfe3JAikC3XqMXxYf09D9eU/Npi/tECzDLjmnTV p3ec+0xguiEi8mSiUaXvbklXxk1zRrbqIDn/JrkKWBp1/AW8134NjGIxHabqxYj9J+gj eVYg== X-Forwarded-Encrypted: i=1; AJvYcCUgmeWJHBJtv0jtZ6F5EVZ0u2QymG2Ptj7D+lDxvZ1hmi2NMye5vbwppDsGCHgT/KZCi+aAIWKo/27AtGLUgzys@lists.infradead.org X-Gm-Message-State: AOJu0YypQfMibbzv/YOdHo6Y3rcS0J6jqA1n5ndjPyASYkF1z0mIevHK eFeGrSkQsmArsBP4z7FnvVbp08cxO7ZPVti4Z0OTaSkwYNI8v1loQ9saBeKjS9t76PQAR8e4P2O bfaOBMN2KzZ/Q3wkacjL/xhK7nJ7rNx8cy9nq7iSaCV8EsUolNV6o67Oq8I+oDe2Q6I0bJuPY X-Gm-Gg: ASbGnctCQ3sgfzxdHfMwpNvRhJQERdYt3buqUI4LCoXXB8FzHdGAYlrsd/wRxelheTo vMnXd2xlYyqNFHlye0GGAO6T+bvlPh1NearB604foheWNFy0YQLGD/E69ZQpaZzYm4UvTXLMOOg bSByE1vHuvN7aAEhIXlLhDT9sxZJBmi/5g8Otfc/A9vN9BOEeU4F6tmlcuZ8J7ldsszEyjWdC+S PsOkC2FMj+QeyKx/7ynCOyPf+lQPv7CEw+zCeQcCfrHz72I3SUK0rAoZ+rS9AqeLXDpuaQ1yMNg n70k16C2Fd30tE1c6kpv X-Received: by 2002:a05:6000:402a:b0:38f:2efb:b829 with SMTP id ffacd0b85a97d-39132db8f39mr21017104f8f.50.1741866275623; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3ZENH1SQw59vrVpZ3UZK2BfV-4Ht36-YMQn7ap6-59g_1741866276 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044604_824046_96597A1C X-CRM114-Status: GOOD ( 16.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2F74C282DE for ; Thu, 13 Mar 2025 11:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=piebsVU5QZFL/FeYXj8vMs1AI4HP2ZYK+Wi3o0pUrOA=; b=V8nR3Dpsc0/mvhHaHprBDRNxvm XOZzy/+qEZCU5J4O0Tu04s7kJ23AhSNpBL6hvYWPWaAHkWM6B2pHSp3JxAZSRt8qOvOlTcSpQ6Rol /su2zwO9br8tRC/lm3aUXcErp4ZPL0ydvmIRExA//H2UBahBooKMP6K9BfpIWz0yrJ7cAJFRHq+us xhlog5KgDj5fh9y01Lq9Ftgixgs4EAwcejOSXHqQN9xoTxPV875QqiiMDxD9k9gNw5RZp+s1XmOmu W+Xjxm5AxOed+Zmks3/pGbOT1BEoqvDa8syskWn3CdHJc2wDkuswA+0c0AcN16W+2gp0fYFq6Tmys l2uuLlBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshCC-0000000B9ZH-0CGN; Thu, 13 Mar 2025 11:57:52 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh0m-0000000B5pa-3Ym4 for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866364; 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=RTGQDTIUALBVYAFVrkocKVY2d+ieQ9Evt8yAZGdCqMmmg8GRoMg2tK/tLBH6aIJFEP8Isn wKKE29zjSK7DR2bPSrkkg6g77dxKXFW/TkHdEKPamwIP8Y/u0PgGSjVHQq1Se1f2zxE7gA PYT7/Zrc97qdn7NJNg1LPTBltxk41uw= 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-29-oJxthvXdNr2MC0HUJCkE9w-1; Thu, 13 Mar 2025 07:44:38 -0400 X-MC-Unique: oJxthvXdNr2MC0HUJCkE9w-1 X-Mimecast-MFC-AGG-ID: oJxthvXdNr2MC0HUJCkE9w_1741866278 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4388eee7073so8945345e9.0 for ; Thu, 13 Mar 2025 04:44:38 -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=PBJqkeRm9fOsZW0ZZVS9G9upkL+MZsix6k0XyxHf7Ii4lanl2pvxDY4iUZ9Er7tkkc ibwrZ+vSbtJUiBth3IwkxZsVPMSPB+oY2n3xjEnCscT51qHcvoXOjKZBkGkkXDdXfKgz ZVyi1lkXNvF4GGS1kpys1oZSfCOlg+Df9SetBhUSQTflodQGhBntucjUCfdpqpqtElmz 6I9l+2s2Q68IuUGnhHQ2kvMWqMd3LUmqXhp22jt2Wmg3Joj/PmkrzP69syu+pYYPkOwY ngZQZgEgLdNc4sOEfmj9nEmO10TvlriJsPSxVWMYgUyOWqX/fbw6p4ZHn6nw0X6k1yTq WS9w== X-Forwarded-Encrypted: i=1; AJvYcCWrJe2rak8KwyXp6Zd8V6lyHIErw0UzQNmq++CL+baT9DS8m1nJZT3u2rarmNoG4qAuEb/k5Zv9lIitnhsSUtG1@lists.infradead.org X-Gm-Message-State: AOJu0YzR7qiVOGnQw8Wwk5PHJ/GxchapQNcNFCy9J8YUOdr7Pqjs+gAX Bd91UJtyOYbB1azASLZhkGFIu3CBnUyqkFxLNYvM5zLi/MqTXCAuLp5Q5LIUC4bM2bUgSPKxFPV ecuy8cheDR8I0JU19ouJJryDPFjoqNqxbPFODi59+TxACuJtvIb4CPKtqeZ8OuElQmX3eab12 X-Gm-Gg: ASbGncsyHcrnts+oHzfIKXUa5fn7/dXAQXcPMfGWWIctB99W7UmMt+5ZGYWIIr6bv0Y Nz11wZcRYG6idfuOIGd/mvra7XGMNbgMBH4NwG8L9WjeBgPIh2EVv0S0sYStfJ+ftVYi7Q0nrRe 36OAVqSXM+g0OO2CBeBS5SbwxKn7Anm+oxMvNVcV7qsLJzXebpWDTarveXEP6AKyHpbnw8pcPFi rXQwtW/oFJD1FTgtCFv2TQuuTbOSi7TBZ6XOjljGXMQYmf2r9desvT80dEOol14ErGCGHK0YfqO rCW82ArTX5YtV4ESXMWT X-Received: by 2002:a05:6000:1fa9:b0:390:f025:9e85 with SMTP id ffacd0b85a97d-395b954eeeamr1447620f8f.21.1741866277738; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 7Uygiugez7sQM8C9-zaumlOzu1BrKScl8cHJvxeBzR4_1741866278 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044604_958155_F4F851CF X-CRM114-Status: GOOD ( 14.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2528DC282DE for ; Thu, 13 Mar 2025 12:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=a3r2g39Wllme+8/IppJMHdqpnHPlgxpExHUFAvvaA/g=; b=WajxfgznkMZJTIhVO6Q02Pj04e pdzshIIWNaMOXc2YTuNWSgGR3N1IuXkF+leURM2pqjcrDS/icTR4NjziMHtsO6NTqHiDZuRoBzw8i 9AgJt/Izq25kh4r3q4pzSW+b4qr1V80lhDMarY7KAEVoyJmECgxAvX9T7R7ZWp4NCdwWRgrlSv9b+ DZkXtXkY0p/Wh58oVIgUQfNplyQ3YRC+bxRD8OHvtejxceVz4+E9EMQRzQo7+JkxoeJMJ8MWFV4oH MMzg48mw/DuHTCTVfuJMQtIle7n8nflP0Gty+AE386+VUKM2nklORZoAR2HrRXTMIpMOVY1xQ5Kng 2mXPSQJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshFS-0000000BACm-0pxj; Thu, 13 Mar 2025 12:01:14 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh0s-0000000B5tH-2JYe for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866369; 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=a3r2g39Wllme+8/IppJMHdqpnHPlgxpExHUFAvvaA/g=; b=NDfmmwgQ4VWMNfl4yOtHFBZLoPJJQ843YxQB84iOE5Ols9x5+8NdIx+Tb8MjTngv3aKp5e gnc9/akJ8siYKePxlPwdJS933cuMO3GFd3fBFKtUqv/URfadYA+J5iYY/BS3eUr+P1pRo9 WsfWZtbQ1SWxvs5aq6Pjtp+dFzAanL4= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-73-Qu7UnMFdMCO5M4rxNPLbpw-1; Thu, 13 Mar 2025 07:44:41 -0400 X-MC-Unique: Qu7UnMFdMCO5M4rxNPLbpw-1 X-Mimecast-MFC-AGG-ID: Qu7UnMFdMCO5M4rxNPLbpw_1741866280 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3914608e90eso532341f8f.2 for ; Thu, 13 Mar 2025 04:44:41 -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=Iolhzg5n9W5Ji6CqMXQiv4lShX8Gc5T1VH82pz8idM83NkauIMALvXIy5OzNJRat7Y /yTFhLTvxXGS9vS5hVf2jBS6xGUkgnlZgjkkNiVSSYTlp+391gYei0aZ9rwQpiQyoSNM H3ryQz2s+VjMASnz757ScMFioSwz3bV2O/RHJChFxuZZO+6rxvWEObxEzQzIA9a2D7WW MK70N75cqtyIkkt2/reW5HpTf5l8HHWvpgNbxhFICK5JK1X/EeZ25W1DghWGJeRCobiD sbplnAe5bZduXK1fYZTEGxGj4fjccAkJI1JM7wV6e4lIl6t0aDQvDtuJpuSULJG/s4RY INQg== X-Forwarded-Encrypted: i=1; AJvYcCXLgvkRsCXTw3RT/4jUB0jN5RjZikWrWlRKpuPZY402e03c/dEZgWEhykGzIUN4nkCdhm5Or2PCKTBeOPkNIviS@lists.infradead.org X-Gm-Message-State: AOJu0YxUtGwQ0S9D5RRbrGvNNV5TU5PX8Sgd1ybKrjg24yfVIpR6cKee ZAyl5zF1Dnw7gPneC7/ZT88bzOndHbhoplvtBK51+x3Z61iDCLJl9SyNtDDEj68Vw6LHsONSDeq Oh5aQXu1U8QVYZycmpJ99Tjm3eFPx01UidQzkend4KQBcyTqCN/nXOFzldyed6fS2RXBCiyRs X-Gm-Gg: ASbGncvboqpCjJIfDK13XDdCShR1qHANlZT6/jlnHy4tC9D4TkIX/Ob0tUSOHuLdFM6 +WiH9stBSALoo/u+YRmMye4LrDtAYl4hN2HrDqqc/Oym1RdFfWDa6VjgpnfWGOPIf9Dh7GzZdSn QI9OJ4RinkWDSqsuYSlb2yx8BY2PtZAklTlupTp7ibuhVaqSUya9TNZSLSSd4iKmXeUP9dmy+HU csOTk9eqyu5MsK2vTFRnpdiTm8p1COd5l9oQimUkZKYG/qxRTlzDVHZpeUogTiSiZ6waIwVTjVD bQvCtzofh7Rb2hN9rcjf X-Received: by 2002:a05:6000:402a:b0:390:d73a:4848 with SMTP id ffacd0b85a97d-39132db1bdcmr22488988f8f.47.1741866280367; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: lCWeX_Njo9OBmbLEqeOrOz1eTXkMPkfjO06TmM-iFFQ_1741866280 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044610_702500_48647171 X-CRM114-Status: GOOD ( 12.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F28F2C282DE for ; Thu, 13 Mar 2025 11:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8P6wNaO+XIHVOsaMiUxPKzcQyyRjSmyu7hy/Ke33WeI=; b=CZAFV3GnJvmnmuWKeoyiKEYfM9 RCuohjSw1CgdFw/apBXjYzC/LowKVM3hxpFwNB43FlfontruD1wtBlK7idv88rtsJ7KDNAqyWcjPM 9eza2E7M2YexbUHo9ETXeisoVh4Cfnp0aL0pscDfom53jrI7LZzz/Wuw3g/UVZvU2tOoJOykT1kmO uBeHYDdg5f0ixW8AzmbZ9fRxtsnf+/vxsvrQjkJbYIFIE7LY8Wl53xOnOk9Fdsx8U7aPzJuHxYd2q DmrHmK+eyGOuMLJDbAH8fwKWNIREnGmRgROTm82R69NKzpbh0jz2KElF44pd99+AmrmPRmOLMnWXU G9MtIYUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshDp-0000000B9kz-1BhM; Thu, 13 Mar 2025 11:59:33 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh0s-0000000B5tI-2bHt for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866369; 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=MxDH+G8CfXDSQNP6WizN7KxNKH0G1D/S8F1GZ3sfpJl00C07A4Zca9ECgFg1iAGExumJjF 9yZKjSpk8WXNC3ULS5Jzl2lLpMnEIoFMEeSAqEMmdMN4gFflxdi0gdFh71ocW/WnVeciGD NPT1hu1KqfHo7QioMXhpSe5acv7nsb4= 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-348-9fmU8rq-PuOOZR3eBAq6BA-1; Thu, 13 Mar 2025 07:44:43 -0400 X-MC-Unique: 9fmU8rq-PuOOZR3eBAq6BA-1 X-Mimecast-MFC-AGG-ID: 9fmU8rq-PuOOZR3eBAq6BA_1741866283 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43947a0919aso6010995e9.0 for ; Thu, 13 Mar 2025 04:44:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866282; x=1742471082; 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=opUoJqx0mX6t+tZ93SnQv7fkrgUab5qO7r89prhW5+cJYdWnrmEIakiSy0IvkX94KS C6eKvW1lrHtwa9kl67V6EwVV1aTw+iMfhmNAqDR7dtWV9lK5eyWlBE+jYQK74XkyjLI3 +o1pS8i1pi1U/dPILTaIuIzOn1AQ6SdpNp/IYcgciC43pihaWTEewbhUkRxjvuF6S3ON Vxh/9T3BctHSNAU/btiWwu0+9vCkAmnyBXEHbH7G6bUE/iIDpNf8Jr8OpH3ttMgQWmPF ETjEnd6HB7n2AdhTrwFsRVvHC6+GBlq46qN1buTyibVeY14KWdJdgoUH+ECl4uydjzBD 1qdA== X-Forwarded-Encrypted: i=1; AJvYcCVG5ToNzbqyhQbuAtHxzvViXq7bxBHoXl+kMjJ7gXg8CLUtp0m8qhhGxcFNgCVA4Wgt9jwoq/pNJEJzC7FfPvWM@lists.infradead.org X-Gm-Message-State: AOJu0YyxkfRi++NYDAXLboSA905d/KOiMuZIejW2yGYtC7grrdwU7YP1 18on+2nVdYJ65d1OrMFKFiMU1OBJ2I1tMELUHpOPdyCypgxcQf3vR912X06jcc8wziDEn/FUZJl ErT9EWcr4KY3i89GHwnl2B0um9an5LPmUlHV4xJs3P8z5HCPKzm3IOPB8Mgn6axEvqNXRZMqS X-Gm-Gg: ASbGncvntvPTn/3mykupdvktfYu5k46UHuCluG4GSznKFpYXpmM2IZDSSIDWxWUsAjP 22RCnoy6eZ1axuKJHrb/aXMFxJHgucVIiBV47V7siNEsDPh3gS7wXIumchRYr8Yo+KgdWnhdD6n VioHHxW56806NV+7MRzO6YQCdJ+81HkofBze80c+P2l07XpfEdmcJDWLPQL/QgZ7m5hmCBXxWUd wCh+i0r0V7wj362LMAuysnhvt3IBDqWsNaoNcsMVaZlZT+cBDxPXO7mTAfFmvzXRr+eNvSVIjXH MzzkF+SBfhJ5nEelgeoI X-Received: by 2002:a05:600c:46d3:b0:439:9424:1b70 with SMTP id 5b1f17b1804b1-43c602223f0mr255847115e9.30.1741866282646; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: hvPftm8FMV5_8C8bydirlX5t8K-646NLdZHKMi1mK58_1741866283 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044610_731966_B504CC1A X-CRM114-Status: GOOD ( 14.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D59CC2BA1B for ; Thu, 13 Mar 2025 12:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GROr3WSjkuWJZb5whyX7QQnwj0kVrCWo4LNK5GIabXk=; b=SdjIBiV5UeTQ7x/16rdcTga6wh CuY+ClW70fqze8M3Cc+6M2OT7V6t1rYtvcwn2u2Vkw2zl/YYCuIBF6Aon9DlzKbq9WqY0GMSh5qRC MHyEA/sUhCsg0uIOTBG++AF2CuRNmaag44V2ra3Lp6MWmrkInhKITHGxN20tml6nsqZWg+08dEntD E8OOZPF3EZMaoJOIWzlVZO3hJX2TaTbKTwmTr1VE9DxA2wfUi+coNkUASO3cyFnmMutGFVR4qon32 OwgLsUmgde8eYxRyMmG/B+7K6ZDGnTNujwNbpxRt1GfXNis3gkbj/jTHP36yqR8NrZhYddyyEpbfK 75Xs4jaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshSW-0000000BCmu-2Z2J; Thu, 13 Mar 2025 12:14:44 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh1J-0000000B63m-2i9t for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866396; 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=cU0dokWj1srKD5fHQ4mcj10jud89raeAlP1sExA1G2/zRngfHK2ZPP/0N425cBnrwu3u1q eHyCESZjZFLOsdiIJQc4UCPam+eu+1PYBvRjtDL4vUkf38OD+pQCWHvBHHorLN6sGn2ok6 Q2CBmBDN9JhDnvXd3cdWwr90Doo7N78= 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-460-ajkEqp6nMQiIYCxDd7myKQ-1; Thu, 13 Mar 2025 07:44:46 -0400 X-MC-Unique: ajkEqp6nMQiIYCxDd7myKQ-1 X-Mimecast-MFC-AGG-ID: ajkEqp6nMQiIYCxDd7myKQ_1741866285 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-438e4e9a53fso5918155e9.1 for ; Thu, 13 Mar 2025 04:44:45 -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=H8nV1z/T75SAyLnAIWueH0D2zR6ObW4RC2Bd/6kSL00eqBrLty74SO85KUHhNDYswa tYvOpfEZP7JbfDurUOw3KcOHERIPj++kVM/X8OJlABstdJH2sK+A89WC6zKv7aYWzB0f a6NGs7RIAXQVQLKgIPTfanqTqrLO2IQLuM0HjAzuJbRgj4imqH710cdcd0EZ2KKgM0dI st38hR1cxxMpnpWRhj1sEdgkQNvI7HROgLdczCN14kKz2UjlW0qCdmYqrcJ3mNkQ5xP3 ojt5qM70pG3t/lPHeyQgKBjbMlwD+1uZkv2gXCIwN2K6QyZh6Hl3TzJNGHPShWtDLu2/ gHvg== X-Forwarded-Encrypted: i=1; AJvYcCWkc7pQmbKcVGPCUnNnvTSeWmh/LzovnJDvPe3IUBy+xaDH7Xx7i2uGcTIF003xhPmiL0UFOFOwQNzB3RB9qLCj@lists.infradead.org X-Gm-Message-State: AOJu0Yw85TLf+fxx55GqIgI6xNE8tJeMqyXDUs6Niiczq6wyF0odNo+O SDpjTgm7HAlgIMdD8yABvHycKo3tVbTa0f6dexc+QyqPuGiTdF72s0Cj/CiADNdFLu7RKob8jqT 6Fs8s7443tAoHQmUk9FMcaYg2DNrRqW+abRAT+4PQO6Oxc0zbgHfJw8bK+DHAnpbs5LB3xiDQ X-Gm-Gg: ASbGncu2ywXyOHvXbTmhs8/A6POvMu7valKx40GMwijxNDySuLg76yLhLpzoXp6y6sh c+/992KeZPWU8eFWWihcCibiz/j3G81WNH3wuCa8aV14pDXU/80tTEW09WDTDhaAlVRQ3pOG3CR C4LoAexZfuz732tISIipx4CLT+jFIl0nowrn5oKLY650uhTKv46krHxlJIfOVLFDKFE+wh+DxmO MgylL/XUotKeJmon41WNnI2bjQqvRbLzUQeW8zd7EVlTub1OS0DUSVfEN06cH6fwu573FRNQnlp wuMYvii6sG2WTOQzq+0q X-Received: by 2002:a05:600c:5493:b0:43c:fb8e:aec0 with SMTP id 5b1f17b1804b1-43d01bd21e2mr95038705e9.1.1741866284840; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ckz7At9DdMy7y17wOBePpodGW6hB6D4ztwMm5aC9qY0_1741866285 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044637_752633_FC67B770 X-CRM114-Status: GOOD ( 13.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014902 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68557C28B2E for ; Thu, 13 Mar 2025 12:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PbqX7vwCNjEpHKJ2wPiix10XVQC29l2r3Yj9fEcNr2k=; b=R8u1hykzVnlEBkxWxPj1TzmH4b ojtRsI+HGxjO9R49BXWYnujSkcXt5MHjIUsKXDVW30SYtcXmeZ4TVlE/tFtxgrYimd7hukLsXnALx uJzdyHDNhmdNnFApU6qX+jl+/CttiShbbzufVXvbNGJ8kIqHhfupCZNq+tPlRgWnqn/CQ38KJB1X1 ZSLFAKwCgeFYIapFdiOwtKEWmX7GES8TPDgIMuGigfaEUsJI0h56+q/Q32XKLiMWJfiLFbiM71Z57 I3DtWAnPyhhuw337lh8UZP/1EaEqHxGOwMHkfdFCqW7H0dTVZ2TQ0AlAfWHwcNUOAQIEDObImbpgy 629ePB+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshH6-0000000BAgs-0WkJ; Thu, 13 Mar 2025 12:02:56 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh0v-0000000B5uz-1Ien for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866372; 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=Ci9VJgM8lf8++v7H56AskHiBonueMkX1/yCkfFK2/s0zQA5vQhOZLEcNnfrNY6qvcU8oNx jdqmxIQdvHvkJjazpnHHsiSClDtQj3Kl3zXme1XMvT2fruFJ6xFSgeICpJji5hAkxw3Vr4 LLPmnOiHr8UVLBfIlWjllpMjXFHsTAk= 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-65-iYf1r3n3NXKKjwd8FS4FLQ-1; Thu, 13 Mar 2025 07:44:48 -0400 X-MC-Unique: iYf1r3n3NXKKjwd8FS4FLQ-1 X-Mimecast-MFC-AGG-ID: iYf1r3n3NXKKjwd8FS4FLQ_1741866287 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43ab5baf62cso6561345e9.0 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=vvqzMHI+7toTOLmqmLNvjiQNFe2wKweqJjCjAa9enaAyLBczEPzamwVqO0tCJji2rq V/1FSZIAyOXSVi0gq7atJJmMV99h/RqmUEJmDbGX5bLJHTQlkBww41lSIIgjNaxYvLA/ 7Xx+mTaO7h5UDOHLw6NjLoILe4ESKs2Ah+pNIcB9JOrWQzCuMxzb56jcVMSAl3pCxjTG fsM7UImVh1XRZT5+cAtmfV7R4KsBdgKRLSbVF5UdE3dP5aElhcyOlwxILRJySEM/Gsya 4a4O2iAc9Ck0AeGed+5idYudgSCIvEbXwMytkjTRmwRIhFB8maFZ0+lpIUuzOhwFLGm7 N4Kw== X-Forwarded-Encrypted: i=1; AJvYcCVgXkrnQYTdHERTGx63LIX0dKVNKFrpG67O8kLJPShh8N5wADgT5pP8RUIsyoYc03pSk4NIaLAmsNnyHqIxpwbn@lists.infradead.org X-Gm-Message-State: AOJu0YwyY78ov8giiyPYvjvd2X9IqoYMV74bKCmH7oVm96pRX/ZWAztx Z8Zn5fg11j/jjWlbNdhLIMJerMp1i17so+r+kev0u8gHFMHbbTu+Ca4x6Qtku0n4r89EVg0UK09 GXtXmQ7jvQ9QeSMUt7+OA7q3NKvUOulx3Bl9S1GXdWbRT9BR4bE+V7aTwalbTViKthKBr+sVW X-Gm-Gg: ASbGncva0xkdOk7fG9VjaSAkQeOga6pbrCb7BDyzxBZEmr8nKGGTEfK42OcBrPc0tFg m6y9aXar8cOP8WLv8wZ7bb7U0nTSINdUMSn3+H236LELqanplZJE/kHgeq0CSnS598AN+oY96aZ +mCFToWEo0ivUBcPxfo9wxYNIMQdYD62TEyjmv7oTZ8pQle3fSgPfqjCnAWZIXmbi15Y+cQsz3x ZXftD8iFR+SByAvfuoaGGPBRity0MZFVY85NhYr6EN2gdIJ0dt26JO4mzGyUhLLgq/wEcel78sL Zlts56oc6eXbKAwHWXX6 X-Received: by 2002:a05:600c:3512:b0:43c:fe15:41c9 with SMTP id 5b1f17b1804b1-43cfe154338mr111255215e9.9.1741866287296; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 1vjSz5TAVtTEunN2G91oekWeDXaTS8e6EnMcZW4sap8_1741866287 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044613_444850_E1178AFC X-CRM114-Status: GOOD ( 13.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73021C282DE for ; Thu, 13 Mar 2025 12:04:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=oNDdusV5kHSN69Wnsdcb+ESaCAhVWZZ95i0rdnVfZIo=; b=U2GqTn05Zf6dRD6WUudLZs7ItC Q/fdMq9SJYoy8/SNiOY75LQZJHG7rGYiLGOJpfaq3N40MZfuLbEngO7MK0QlzR8eW3RGDnkFMob6F IDMifjXUy9JDnZPoacj1VN6Pq4AZvqWRN1lOlym4WQ+w593lvmGyusXgzE8Pm4mByF7ym5jmX2UIt x7xw798qlIQXGE9wpL5F2FL3GcoS7gc0JXALDqXjNWwKmU1GhqFS7f9TPLRXNES2E4hBHK0HVFIxQ IZF21NhFDb1LSPdj45rxOaFnXdOCxxrsp2YyjIkjg34G1/1tG55uV+vr49+SBRZLaxZIlQNlo4bUQ m4FeA7MA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshIj-0000000BB38-1pq6; Thu, 13 Mar 2025 12:04:37 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh0y-0000000B5wg-1Jld for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866375; 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=WoCISQn8kl2cKuv1/th0VLOjyerfs2DJbOmJK5P/NBtkxUyGyAY5tcczh7ZltuPJ6K/Ny+ fTrrs4puGWcOKOB89h/QpEqdVSt+txLLKBcL5ZChF7JedvBeF4fxjjAoxMXHCJoCjig0OU YEUhePPj3jM63kg82tcCTik3LHvQqsE= 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-179-xlvZ6FdgNFqVRN5QmPx2bw-1; Thu, 13 Mar 2025 07:44:50 -0400 X-MC-Unique: xlvZ6FdgNFqVRN5QmPx2bw-1 X-Mimecast-MFC-AGG-ID: xlvZ6FdgNFqVRN5QmPx2bw_1741866289 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-391459c0395so372298f8f.2 for ; Thu, 13 Mar 2025 04:44:50 -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=STPmkvSD65wtF85s2qlezNU/Ki2gZECCw8j2bdGSm5QS7R9jj4VQcWIt9gFiROG7L+ jAKXet0/ou6xh1CSx0P36j0ubJ9y8E7Ap9u7p5At4g8RbfFvJEAxX9nyQZBOI9AjQWEJ lHNSMOIA8aekLExZkzVsJIX0Z0Fwn5IxiNPm2Rq37vdgPFtuUs5jKfDFgHtKZCrBjW1K //wNbFsxsvj0w/nrO4ICz3UDgtY72IQ/e/8pRjhSUWPF3DGKLN5VgMeYkUeweCtzSyKr aipMeWXbcqrK0Ex6/uxxgFdnLNs80yurBynnGXtAZemeav7r57m5ZFeC+iZhblbIpBTd F13w== X-Forwarded-Encrypted: i=1; AJvYcCVRQ4biZuUoH36NWNnWySWjmFkaogaIoussjB4qEUqZhaKufgL4mebV3TcIK4wilY3mJ1Tx1hj2No/j/JLEZMZA@lists.infradead.org X-Gm-Message-State: AOJu0YzO+mFvNjKjEUP2jVxHC5UWW5GN47ppeJsI21O9eOcUqGWMTvZe NCpIOJGdgCnxKhXb4UUzKvt5fgjaO9GnkX/xZC8/CW/jonUbDh6E2Fe/Sclid3lTtE3Kn00gtAJ 05meK7Ife88qMM+/tGxidR2LKJkr2eJ22npafJrrpQ+1qrKFjEXQS1Booy35LQdUz6Hr55ncB X-Gm-Gg: ASbGncuIV72YkNiWx/Q3+m0/F78e0B6FZIwopExzwYHXj+kOBOzwGFDOMq7pTbi2WXQ uhgigPLAcFJGX5rqi5PW2tXGcYXzNh36+9//aIEFyjApkUbwsqP4GfPp74fJOay+9AXTIY7sqDE DhiD2gL+9xy2QKbtYCD9qM1h5AJz5paXGL8A8qjGIZwLktUci7Adme2IRL0+KrSWG9DZjnmRUZ5 Jomy2iVcBuGwp1cS5tMu3+HeX1kJAJUlv/6ixBzh2BVOxFMKo8W9xHr6xxJ/d7TyWeynqGgF1NB ryYV4oY4svDkgnSbYwYg X-Received: by 2002:a5d:6daa:0:b0:390:fbba:e64b with SMTP id ffacd0b85a97d-39132d8afb7mr18596838f8f.31.1741866289404; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: SwHAS-ZsV-DMQRQONrkt6s53OenBr9BZxAjwUvUYqms_1741866289 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044616_422206_2DCBF623 X-CRM114-Status: GOOD ( 12.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7765CC282DE for ; Thu, 13 Mar 2025 12:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EdALik7flTFVSWTVblU8JKKGGV2JCoENkhxrfjNtUxw=; b=McYUrsGpVidSVRx/Zk4wQsdHwy cEFcrCCq2CVt0enWYic86e6drQtP3mNMq86/puzG3naNrIZZssVebsFQrl2Ed3peKT0Tzbr7zh10R /3Ep27IvouO1tNnM8hxKBLKEg74OK9hKKEIaUg3ZfhKz64siOJSVGyzDr+TF5f8t8FaRxhzJw2oWP S3485Rl02cRMWLnMWsK57mjbolcF7fI3Ms7gzblmQKK+GzOLHHvm9gAqJepCHnkBkjRw38s/bRFIH FLdQ6boTayjsPEKZg+6mnLFJLlRTk0Jk0+B4JI8AzN0T5A9ZQWt5n2RtspnJzIvgSYXryF3+/R28E v7jKh+Yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshKM-0000000BBKo-354N; Thu, 13 Mar 2025 12:06:18 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh0y-0000000B5wj-22fk for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866375; 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=TYj6APdLqRfHJjGa8AW9y7qyjO1zHZrjO0+o+NerkLP+toPaBP5Bl3RMTM/t92Jt85vLfv KjiupLqNL+RXa8BqYqB8W2kdWCeT9ySeSHtQ2lYBTVwfR9D/uUSJkp6tz07LN5+s+BPjWd kiNc+icZrFjZ0kBy6BJQHu2AuG+VqVA= 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-180-2ofHh8QrODqQsZK9xRl0wA-1; Thu, 13 Mar 2025 07:44:52 -0400 X-MC-Unique: 2ofHh8QrODqQsZK9xRl0wA-1 X-Mimecast-MFC-AGG-ID: 2ofHh8QrODqQsZK9xRl0wA_1741866291 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-391425471d6so306812f8f.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=HZeXl5eo/gowzPzjeHEvWK0d/B2599y/TkIo+gRHSZ95UZ5tqPff5W5/kPvZnqoPK6 wVB+kHvws6WUx77qVjOSjuL/oWzpzGge707lOqM+JkU8WFtYnhfMDsBTp5FyYNo82vuZ +pbCx4AAJYgkchZn5Gs/dbu3LOgg5wn0qz6i32gHJugA+IaJ4/TK5vgO+P0OrjyjUmgb A6Xgo0qv/4HGF3U5L7pHhsxcT7C7VguCJqXnw/W9mobR87cdRaZeVUN2ZOVY8a5+MFxq yyPDckk/tn0BJCpK0tY8x1GpmI+WaY1Qtvn+GTtRD6XXmmpsP52nsh5ujcyxmjMKDI4a /xpA== X-Forwarded-Encrypted: i=1; AJvYcCXjRXpA9kiKwLLM+JPQPiTngPWgunInc5GBaD4ySA/2dqIc3rdiGvpEbP6/gZtvWbYIA3XlcGeQztVgNCfuvwPR@lists.infradead.org X-Gm-Message-State: AOJu0Yx3eQ5+qv2/b/SKS7UpQo9zkauapy2CNfkud1LIfUsrQbEwr+x+ qMH5FSCObNI7NedZTJRkT0y49SrMq6NKmaBmpxFUbjSsLmhlmRnJ4FlNktQe5rn+BnyjT2hRqdC 94u/dUDHPoWR3+XzDTi1U4Jibun9GdALvv/RIibybJlukUO7kSevDKPI4jkL77bCng01A/yT/ X-Gm-Gg: ASbGnctgD+z/n5wau8HbcEuxisOMe+CPlqdZhvx1R4gJOhYG24lMZnsSvjbHSVodR7Z siqPdxheNzhI/zhNTys1ug+EgEYBS7rRq9DMbcG7jOn4IRDzmUMbv3d5XHrQnYWzoKRepq1i3x9 1HY0PslSPYU1MIC8RVl75ccUZyMpeJ8sMlWwB07lPK4rrf5XRp/UYSRgTtd39qhwmMoVyhpMvLr PvJHt8k9z/ezpGb0DPb1ggIweZfwX3a62mylhVxHoMi22328TLEOr2Td6r4dIWKXQvl8rwUfIbc +uphgY3SVw34L5JRw0Qr X-Received: by 2002:a5d:64a4:0:b0:391:a74:d7dc with SMTP id ffacd0b85a97d-39132db7543mr19148428f8f.50.1741866291552; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: bv1Dp9Bj9uhO1taswXJTjDyztcEYuL0U7LcC9warlGs_1741866291 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044616_604152_9EA18D12 X-CRM114-Status: GOOD ( 12.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14015170 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7E51DC35FF4 for ; Thu, 13 Mar 2025 14:21:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fuCFF39iXwBMHtdVpJheMeZKmjdk+AFM9NbRaPloTHM=; b=tbaIEHuhE9YsuXAkc0zhrQJVPJ Qfxb7TbPJ+29M2Neo41A1S+RAyZbJt/xolBnoeTPnmvQqwBmbCN224H/YT1sFfs865dUSJ1r3jdrP KJBNOZG0zKOKBZniRwjfXC9rFeon9AqzLmO8Sg4aSy+z6087CU6ExhlyG+zC9J4ZEb0+9fOiVoeLb 8UN2UDyIRqowlF8Asz1iZbM0ijxl2kITQ6Ub4azoyvnhvOCFVTAOkJnl3Ewk3jSweIlu9dcbHo0jQ mrL/jeoUwqJCBi+PuuXT0ARHnjQvogY+nfuw2NqTVMQ6MCBWN50UxRO0tvXphc6G37aGCmgoAolNZ DMdo6STA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsjQd-0000000BVb6-2FR2; Thu, 13 Mar 2025 14:20:55 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh11-0000000B5ys-1bXC for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866378; 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=IsknodAYvEWII0VKzxy/pdMgpRDYRZektZ9kFRQ1sQWYhSu2xoeUBUyyFwn8CKgPKSEdGS PHVq2ST8lZx0w4LnKoEARVPreiZXzD6fle53Du1VkA6jLibLT6NN80N+RQXHV2YNVJyeph vyxwgPaeDUOT2vsBpyHyFCGVFV2+awc= 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-695-hyt0A6qXNvmiaZZ4DVMHGw-1; Thu, 13 Mar 2025 07:44:55 -0400 X-MC-Unique: hyt0A6qXNvmiaZZ4DVMHGw-1 X-Mimecast-MFC-AGG-ID: hyt0A6qXNvmiaZZ4DVMHGw_1741866294 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43d00017e9dso4357205e9.0 for ; Thu, 13 Mar 2025 04:44:54 -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=HB49uq94hutNnFxljPSiNn5tVRk+RbC5cUkTyPSP5/BRKMSaaZ2AsvVtFZsiIW/WFU PzGDPq81DIcl+Y8EtUmZQnZmRgCBxWXTOV08mVBU9AHu3gD+OTjvpCY+70/xbKBzFHPj iaa+NjCip2VVoSHW6zkohQCElW/CsVhAqt5+kQbMV+bEVDopJNXUm6l1GK/RkDKKNmR5 20Y++lNgw3PH/Up/VySpQyFDmsbuSG1r7djsAIMjeZ+A2DTxHe6bRz1BhNK357pNfA7n p2fpNsd31ksnu50FabPwKKZYFigyQZkKZjH+eMN4ZC13e9P9YCF9GrujbplWn3kiRBBh k4fw== X-Forwarded-Encrypted: i=1; AJvYcCVdD6hNfT4WC2UxSDCADRcDr41WufAaLTlt+WC+FJc8UTI1akYCpKBZUURpoJw+TaAgag/PhDu/w+X/NUsi9gsJ@lists.infradead.org X-Gm-Message-State: AOJu0Yy5Bl2XQvfwCTSOjmqtJPaDtUp06Nmt9Wg1wzgXf0tCphNAcgVg WgVlJg/tK8c18OdLCFC439miYvylJ5rt0bwA5KW2T1AlD3KlCxlWEcxVTWrurVtDmUoiI6G1egu 5Obj1SQiBWb9glVfcmYa+/LdKDijV52L0Q8xg3hAahXotkplFkXS11w9WL9sZ4nMK5KoCIg/e X-Gm-Gg: ASbGnct/u8JXWr9XxBx5dwGhiqK2mRoZFm3USZ0RsxVFfYCAT7kRvtspy3TKTtEYxFD dcwwiQW1gLu5QvYkBIt/qs8g8Cms40ljvO8faCC4Y82OtLW0UvwNCXhbkn8uf4FBAO5+L7Q5XRe T+wR2pbl0A89rOufzj3MifusDP6BFtFDOrTTbIo5Ufh6eTZ7hDBl/ZytqxQRK8wp0QlMG/jWArJ 01dXEnR/PpwQzOnC443XhzTGl8u1oQKhGGZcsddw5SyAxgskQeEMp6sKx6vTYEIdhyTcIopRBYs Y1lft8Ocur+zPl8+Im4q X-Received: by 2002:a05:600c:448a:b0:43c:ee62:33f5 with SMTP id 5b1f17b1804b1-43cee6235b7mr136023455e9.27.1741866293869; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: QPVtLKRL44az91NwxD95r-U4V5Tyz4zFayhrLKj6L9s_1741866294 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044619_487212_2AB6090B X-CRM114-Status: GOOD ( 13.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3723AC282DE for ; Thu, 13 Mar 2025 12:09:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Td98jnkcLGUCy3vrjbMOv35ZA5bivtUA493Q3YOVPt4=; b=ngP0JxtNj2XUaOvkjAIJ/DkdqI meh6zQ9zf2YGKFFMRkf5tegoqGe2LRJXDSRSXfSTsIEYp5Eh6AKA+Gb6VGcVE0vAXMpS7gfR2HBod z/iNkVBu66uq18A/zSd/hcYjmGnOBXxk977Ob+EjO0QJ5KHqcfyQY7/VrDYUz+/TNF3P49aS3/4fa LBpABorXIKjgJgpQmuRZzX/hYpFCjYAORcXkDNqNcSPS85+IYgcUvHfGx8njLOuvmhmm7uDtIYpgR Wmbdv/tPSa5Q2FzvIbU/Hb/Hrc/aPXDMd1qVwRHXPVibgpt1+j+itjMO0NDiQ2JLK68QKlIkNJlpy FA0bIa5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshNc-0000000BBp0-2qLp; Thu, 13 Mar 2025 12:09:40 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh14-0000000B5zn-1nEt for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866381; 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=ZSY7akPf+IOl/qBGGI3qgIcpI5KQf3Dx30OSpmf2TBxCWL6NLKLf5GD6hRZiQ+uAkL7CDQ MqYSMiEAIRNa9w6429GQtuV2P7ykN3ne7xB95hBV82f72zdX6orj4VcYiaJX01jV6t+YV9 kuJLe00naYP5bMQq8ClaV0li0I/TdSc= 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-502-oKcpk7eLMR28tzNb2m2CaA-1; Thu, 13 Mar 2025 07:44:57 -0400 X-MC-Unique: oKcpk7eLMR28tzNb2m2CaA-1 X-Mimecast-MFC-AGG-ID: oKcpk7eLMR28tzNb2m2CaA_1741866296 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-391459c0395so372371f8f.2 for ; Thu, 13 Mar 2025 04:44:57 -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=cYWxc9QL1En+igqrPou9OKDgwdiFp6780L7WcBzFXlBC+MQ4uHx5sZAnjKq/38E4Js quFOY4OOLoRvA5aOhpmw4nCFC+9+ykw9X63oNBV7fn4ViYmwWHiOasx8p227WfdVpyuE GknvFef17iGWF3zEE0ya4p3UZZckRfzJOX9yLsgUgIw8V1nMrPj/8IbL8scJwu/L0vZK 14qDsy21MY4bCMCc5GNYC5Crx08myXysIgs33mgQFe/4uzlpcMfPXXxdaCoiHRyZXsf3 FOB1XmzraFjqMxD1T2EpbQtop4y6o4zwZDIP0L2NOIXYV1/l2CA0DSWJT1eDbQtdLFd6 /QGw== X-Forwarded-Encrypted: i=1; AJvYcCVkVLURGiHIoNJIn7WYirtpMh+zT8Lykkgo3Pb7odCMNYu8npcgcm/QTbtt32lyA/lQWT8ib/hXBuYqfGoAjdx2@lists.infradead.org X-Gm-Message-State: AOJu0Yy6aEPIQ5pRb2xYX6NTn/v+HS5lblesH9u2JIeuvuswK9lcuCWN kumZF31yGs4U/b5GTllXR5fy7j/o+yf8/hpWFH8XTX7+5hXpmbOlkvAxpqScvXD1VGGnMfru2/f jNnLDC6zXrGCTTmioZRS6paTO5ByCafebuWoAHQ/To4ENxfxuq1yBC/W+jLpPzFBYn5skopN9 X-Gm-Gg: ASbGncuYYFspy0PRubuV51jFkNKaM+f8pj1jL1rbbu3zVJhpbIFEOoqXT2vjk9+Wp0V yB8+CIf4C6Jt4E++wQVBcgJGnpCuxb6rx33JJo2HYzFQyNjjnp123tRvSFQryW1cVoLkyrrFPLh NM6qdE3sy4qeC4JphY/mB0ZdmPbP/zlzGmdHe/mrfgNQCirSAhWebgeKxQbsJhv7UcE7BDnxY0O NJQf4pgDQZmGFdCO82Z0kxSGDFTLSFOgkvJ9F9AfWuz5bnxDCZEpFg0bR6wJ/y+qQ2BKW2jwVGW H66/tr0Z4Sz/Sj2Me1Xf X-Received: by 2002:a5d:64a8:0:b0:391:23e7:968d with SMTP id ffacd0b85a97d-39132db703cmr17836141f8f.47.1741866296143; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: jhP7t5iKBM_XtoWgURuIlpbUJbCnKFJhPlnuz1F1cUY_1741866296 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044622_531109_1947A48C X-CRM114-Status: GOOD ( 10.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA311C28B2E for ; Thu, 13 Mar 2025 12:11:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gL6tEDolxd3AJJcGJnpcVh0p0Gir2o2MhbQax2LwBfI=; b=V77fMbHPPM03MIFfSe15MiyVD2 VU7fJ8Jbb/L+kkjFw4xIakn9BWGmoySSu7gY09UvPIFqRh+5rZWvcTvI1K2R2m2CYtG7tvg/EXxoV 7AupcWKwupGZrn0yNj/kWQfZqyzJzYOyKes9ApYRw9Pl+J3md7ouI1wmMJYY4kvgBjfrx6XLReGSi dwH/FPcLijgFVAhUEsVarE66igqOO1Xi+QHLg11l8qtewgdMfq+YsJ64bMLAc66l5q3xNfWr24JfM nCUSSyYREbymZC2v5Fgsw0bJZ9FdJ3Gw+Nj9RVVM/0e3pIRUlEw93bblxC4haO7RtH3ERD/KjW5v7 ELMppPLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshPF-0000000BCF6-3ulY; Thu, 13 Mar 2025 12:11:21 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh17-0000000B60V-2Ev3 for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866384; 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=dMuHn+mRm+CNZFyid06pRdGJ15JUfwAEdLIyovzT6eTCahNdZDgTI7YsQRhUVJ0Vs/xT+m OVzTEJ3VlH2sIRGJEvys2Hv40TVvH92ImzNafTExOGdv5qRlbFQ+naMQ9qVIKdGw8Zjdpb RYQ7MlPICX29XpIGACop8G9u4eLwkEk= 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-281-gD1ZpaNfN221Pezj48OVsQ-1; Thu, 13 Mar 2025 07:44:59 -0400 X-MC-Unique: gD1ZpaNfN221Pezj48OVsQ-1 X-Mimecast-MFC-AGG-ID: gD1ZpaNfN221Pezj48OVsQ_1741866298 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43d01024089so5948895e9.1 for ; Thu, 13 Mar 2025 04:44:59 -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=KetaEAuhy5kKfqhBbjN2aZsJlzTvJ27D0T/7/A1hcLhAqybQvwRn0/QZL5H6dG1ARp odXyBB2AkQsvoZRXKfWLtfX11irDqiigsEufzKsvgi/xoPLE/l46sAbMXxXeo4WwcZbZ YF05jvEqE2QryDy2mEsOIkpzI6iWnqQBXp33x8AM1lY8TU+Xx89w+YKL5z6w1nK06tDY dHRei7T2IOr/jDjSDMDUf9qUa6Lz2xozIU3gxltr9ww9hrUk4oQUh8FHpOqv7Xtl7Tfi YJtmBPxgX4pOII/YoZd7grvxuOaIUKOBqviLGzH5iqsTjKxx1/GeUVuc8+46fmKARYjL MVWw== X-Forwarded-Encrypted: i=1; AJvYcCVDyT4TTq+khwU+bYkc9TmZM6HAQhTTespeqb7bTCLC1pTHtY7bgPEVrwIYOihsnLV2NG/B5VMNFHCVp2grkyd/@lists.infradead.org X-Gm-Message-State: AOJu0YyR/Ps8HB+AzRwRGPBfoGr5bxd025j6AunZUwZ3O7vdR/YyJ8ZI OHEd1EF1JZSCVJU01m1kFz3euBNIGPZDzdz/Fu7yRv9J/P5P81m4b/C8Fo1hLgs9XXQvQanM114 ww73/dCTpSUhdcEUdb9TNeIIjunh4Z3J5xbg9phoudkECzHzFJw2CahES3fzRLYFNZLk93p59 X-Gm-Gg: ASbGncthn6/aYAXqZpBdw2hb0LbhyTW2GuxAFcCOTvlI3TE5H8u5hswHXqTRe48idNo W1QkLJjzkOUHiBZQl3xw6ABi8mr1w281PArswr3/y328wT1JkDwCMKfe6LuML62mqZkFJcrN+K1 s/+tOacxjsgxmgn1SxPbzGg0a+B/0I5PLVw2RyBRBSrvM+tOOjw2V7xkRNKFcbix39PKHsRvqdg vxET5y13W6hXMwQ9MHbb0nassVDI4c0sVQeZfKjLNQ/AB/6yWDdtKsK3Hq4RcN4IH9tO9lcUu73 sVXm6SapsEzZg6cMg43f X-Received: by 2002:a05:600c:1908:b0:43c:ec28:d31b with SMTP id 5b1f17b1804b1-43cec28d58fmr198762315e9.10.1741866298359; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: lJOwdNKNYxYe1lMTPisYIspsgs7E-v6kA3A4n6VgNCE_1741866298 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044625_657715_B4B9DCB9 X-CRM114-Status: GOOD ( 14.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 14014931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7542DC28B2E for ; Thu, 13 Mar 2025 12:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BMlGspdrpbJ31u0fCjYvjyAZlqg7W4BaKawB7P7nRsE=; b=kAzt+xShcd7XzpHz8B/L7sdi0q dZHqk8fOJolLvRQyG72cs6hTK5upyHCoZcbcgB/E1LVy/xWZU2lzyRScyb42cnY4ilSbsjb2LNgAw nPrxbzv7GiLpU6Scg5+mqQOmhfJlyNmwZ/hb1Ha4E+IkTauOSBE4iIhANRY3MpTiu+HwVq6SK+fOm ir0qcLzV9KLV8LxHBA006oTgC9H6F80MYvg7fpA2Gpd8qK9sR37dyOb1sDPJlqqqIbcZUz370cm7X Oh+lMhMVQ2u8aw+X6mIB4npwtOY0Q5TPt5F6UhWC6sXkywqBF6rNDyjCrzmOje2zWGJ4gMeRQmcIr ver2s0vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tshQt-0000000BCYr-0itA; Thu, 13 Mar 2025 12:13:03 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tsh1A-0000000B61z-1pMv for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2025 11:46:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866387; 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=AZkrlLAcmfUsD9FXNAw7UtDjTN8s7pXDRtE5Q+jpgmzaw1Y32P3YBQikL5TFYZZMEJHYzi aKG90JBs+IGO74WASufJ6PS5Lthn7P5lr0h91iq55Unf5fC88D8ijBEGVuAsY7Lb4qa50i wTdTsx94dq7fX17TV8z24IdoSCTBImY= 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-116-nvYqunrNOmWCu3fA0_XyYw-1; Thu, 13 Mar 2025 07:45:01 -0400 X-MC-Unique: nvYqunrNOmWCu3fA0_XyYw-1 X-Mimecast-MFC-AGG-ID: nvYqunrNOmWCu3fA0_XyYw_1741866301 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43ab5baf62cso6562715e9.0 for ; Thu, 13 Mar 2025 04:45:01 -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=CJCSQsz+c6wtgRJ6ToG6qak+ELMY7ET/Vs/+U0KZuM1GYzdl1IfUqtgrVBEBKEFoI+ R9RxQMN+7ojD1YYQmYoacULmAdZLTS+IYUiWDt6UhW71rOJZnO9Be9Wu09dULuRKGrqU 63SWGbd+tVfFdyvEUniRPY9QXwyeIhNNOPoum1jyOHxoRg/fYiMnuK74tfAFkf9B+aKU fXRbcE+sbsDaSIw0WtOjCP1GaOxImEzi18b97dFSyICEjRLRp67pjyOWy6vGICAPpbdv pmaN3JT1XALXQ29LsJJsdmWJbD+ea72OfMKt5eULxLWPSrLmAAR1VQ0k78zMgXW5/6zj PsFA== X-Forwarded-Encrypted: i=1; AJvYcCUnDG+z/4ubaOR8/OYMfTn9Cpcb4twVp+M+JMf8cW9ST35pP0FR1F3RlK3j6Gssejtnwk0xGfWsiIEUnpSrmLP6@lists.infradead.org X-Gm-Message-State: AOJu0YyZOSFr2ZsAga2nAjHKYYTEFDESardD8HbkKyjbb9CKpaHAe61v 3hwAT6Qp8UgyeVBYAan21kFxaXtXpHNKnKO4qlDBo9nIQ6q8a26eEcWRF+t+iyr6VWUwN4FVY4o Ut6e2LD/5OEqqESZCFSgm9qwK55k7Vy/lBu0n0SK4XfZGN6ng+LL/pXZHEoFd1cHv8GK/8u9C X-Gm-Gg: ASbGncvrhzYHAjRr77r2fvSiKOBdz3QZjo+WYeTGIKrIQNF7hmgHRPQVUhJT+mXoaez F7RlFh7bpzowkB5IBO+nmyl2QSZ8+KzK0icSKwryEc5Dx1EOeWu2OKWo1tC6cO8fMuTz9rwx6Uo PVY8nATygaS8DJUGSLqJ5IOomBKDYIjQ4BNYb/sdwYDLEX9OZuWlQYSDvDrQd2vhma6uLlpG7Uc CkX1YIZtMzUY/0txIzlYCvaJ7GyNvgC4zB9qyea4slPt/RqapVQ+UCbLOqWAX1foYVWX41v6Hip loid5C8dHHRLcHzx27xf X-Received: by 2002:a05:600c:470a:b0:43c:f44c:72a6 with SMTP id 5b1f17b1804b1-43cf44c76ccmr144327025e9.2.1741866300517; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zEeEna-G9WVne6yMA5a4a6cOldfa84RrJsGhxN9rtNg_1741866301 X-Mimecast-Originator: redhat.com Content-type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250313_044628_543110_EC52E161 X-CRM114-Status: GOOD ( 14.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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)); \ } \