From patchwork Tue Mar 12 17:02:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590403 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 6ED96C54E68 for ; Tue, 12 Mar 2024 17:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6WHv9dHLDU7uiGPuCXpqRh+MEH1aVFnMTQtShhNIp+k=; b=yFldo35wuIFHSf f9AifuddVz/MbjDzNFokCIl0kLjinLw41AtSXdc4rpVdHrEpArMjGPixNAHmuLzxFTtDGAtqDLZCW 9aEN2wwzCz27CkodYgdatHbLQr7wRwq8D5VrWGSdR/+zgRWNGQK9QzspJLtdpHAZVS0smFMdeLwNY b7PwD+wBiMPxsNL+4vRF3iygrtJQS+D4vf2tl9o3vlf907wxYwUJQ5Tf9ZnCbLDx1eQFsxDDJgsQB 2KGF5nZbdZk5sSfjJCS3dUlio0nk25UzemBF/wIGiUX1q/L+0t2mi6gr6nKpvz10epj4tty1/8sfC P/O47djl6293JZQ5Yxvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XM-00000006ioa-0jqY; Tue, 12 Mar 2024 17:03:37 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5X5-00000006iZr-33zB; Tue, 12 Mar 2024 17:03:22 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1dd611d5645so283485ad.1; Tue, 12 Mar 2024 10:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710262996; x=1710867796; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Of8hHWisNxYysvbPB0I6Y4GqENZSkz1n2sIkdEVr+kQ=; b=KsBkN23OLJluKeE51bBh6sUQeqlPLQXaAB4K6in+KynE7afrPrzZGjVNKOcv3NYkfB PBmG/97rn6+FOlLpbST2MSToVvuKEwSJG1DxqBrF8LYTvhutvz/TVVJ0ok1RY5JJA45P BSeTtVUCC1rW4Idux9rCBbT0cwBuHyy0piF3aDgmUk6gOfv7Yi0HIFy1fmavxoMOM7s+ hualoc7bHy5LfzhzDu2Z98B4uz7WrhdznQhdXTQFqlGLBbpFitA1HLJlmT78DkXPWT1b MegleMov964xYN5pHm5VXZC4rVFjfVaERFG285o4xc7eqSuKHQIjA/2gvlS8r3hTK0xU QVWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710262996; x=1710867796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Of8hHWisNxYysvbPB0I6Y4GqENZSkz1n2sIkdEVr+kQ=; b=uD3ex/SZw8JWWZ9UXwBLaqOzEnKp802OnQ3h6UAtDeMZ02kOmF9NxyfSixWDdYSmZC 72vnIwAvROjUqVmtiYNu29u9/gACM3t0ykU+PuliENzoJXMWx3EHvtvhe6/bUp6sLzGi FWFG9ueI7z6xqeLqnbHQcoxQFH5Q3XXFHR6Ci/pAAH3vnEvJ+A8dzKAQn+U7rMiEj2xq 7d+2w1IAbCOrIlyS7LOsMgncaDIL6lLoecJ3/82mh0m+QpasDcdrJduF9uxf+wXQolT/ 15eNPBpEhyCjW+KrijnaOZzwtik5FUimo905JGWjbfRN506NVehKugCGh0bgVN76Cmds XcCw== X-Forwarded-Encrypted: i=1; AJvYcCVv9Z4Ld3CL3CcybL7surgkQRUeOVxupkqWZc8HDNWoI0hQqzJJ7Rr5fAMORfepFnw+d3b9+IzcXa6GOfRhn/QMSqvmkzMD8UGYRl4+VNF0rLpWXVphufSGcsjRg6JgHgtaDvBDfAATentwhpQ9668uEhaptiw= X-Gm-Message-State: AOJu0YxGBf2WGoSGMlE753+1jdotNqzfrr6kr78a1U/mN/Ds80q3tFoy qn4mB81r8d4CEUToK91Q2S7oxNkctcUppkS093v+8GkBEUaUdlTh X-Google-Smtp-Source: AGHT+IE/Isr4cUsadh0SsOhn7mx4Gox6shabBQwnzVwQlzBf1DTIw8GWGf1C7I1mI94rK1/gQQW32g== X-Received: by 2002:a17:903:947:b0:1dd:a616:8205 with SMTP id ma7-20020a170903094700b001dda6168205mr110005plb.34.1710262996297; Tue, 12 Mar 2024 10:03:16 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id s5-20020a170902ea0500b001dcfc8a5fafsm6970018plg.96.2024.03.12.10.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:15 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 01/14] bug/kunit: Core support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:02:56 -0700 Message-Id: <20240312170309.2546362-2-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_100319_835828_3E27D65B X-CRM114-Status: GOOD ( 34.35 ) 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 Some unit tests intentionally trigger warning backtraces by passing bad parameters to API functions. Such unit tests typically check the return value from those calls, not the existence of the warning backtrace. Such intentionally generated warning backtraces are neither desirable nor useful for a number of reasons. - They can result in overlooked real problems. - A warning that suddenly starts to show up in unit tests needs to be investigated and has to be marked to be ignored, for example by adjusting filter scripts. Such filters are ad-hoc because there is no real standard format for warnings. On top of that, such filter scripts would require constant maintenance. One option to address problem would be to add messages such as "expected warning backtraces start / end here" to the kernel log. However, that would again require filter scripts, it might result in missing real problematic warning backtraces triggered while the test is running, and the irrelevant backtrace(s) would still clog the kernel log. Solve the problem by providing a means to identify and suppress specific warning backtraces while executing test code. Cc: Dan Carpenter Cc: Daniel Diaz Cc: Naresh Kamboju Cc: Kees Cook Signed-off-by: Guenter Roeck Reviewed-by: Kees Cook --- include/asm-generic/bug.h | 16 +++++++++--- include/kunit/bug.h | 51 +++++++++++++++++++++++++++++++++++++++ include/kunit/test.h | 1 + include/linux/bug.h | 13 ++++++++++ lib/bug.c | 51 ++++++++++++++++++++++++++++++++++++--- lib/kunit/Makefile | 6 +++-- lib/kunit/bug.c | 40 ++++++++++++++++++++++++++++++ 7 files changed, 169 insertions(+), 9 deletions(-) create mode 100644 include/kunit/bug.h create mode 100644 lib/kunit/bug.c diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 6e794420bd39..c170b6477689 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -18,6 +18,7 @@ #endif #ifndef __ASSEMBLY__ +#include #include #include @@ -39,8 +40,14 @@ struct bug_entry { #ifdef CONFIG_DEBUG_BUGVERBOSE #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS const char *file; +#ifdef HAVE_BUG_FUNCTION + const char *function; +#endif #else signed int file_disp; +#ifdef HAVE_BUG_FUNCTION + signed int function_disp; +#endif #endif unsigned short line; #endif @@ -96,15 +103,18 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...); #define __WARN() __WARN_printf(TAINT_WARN, NULL) #define __WARN_printf(taint, arg...) do { \ instrumentation_begin(); \ - warn_slowpath_fmt(__FILE__, __LINE__, taint, arg); \ + if (!IS_SUPPRESSED_WARNING(__func__)) \ + warn_slowpath_fmt(__FILE__, __LINE__, taint, arg);\ instrumentation_end(); \ } while (0) #else #define __WARN() __WARN_FLAGS(BUGFLAG_TAINT(TAINT_WARN)) #define __WARN_printf(taint, arg...) do { \ instrumentation_begin(); \ - __warn_printk(arg); \ - __WARN_FLAGS(BUGFLAG_NO_CUT_HERE | BUGFLAG_TAINT(taint));\ + if (!IS_SUPPRESSED_WARNING(__func__)) { \ + __warn_printk(arg); \ + __WARN_FLAGS(BUGFLAG_NO_CUT_HERE | BUGFLAG_TAINT(taint));\ + } \ instrumentation_end(); \ } while (0) #define WARN_ON_ONCE(condition) ({ \ diff --git a/include/kunit/bug.h b/include/kunit/bug.h new file mode 100644 index 000000000000..1e34da961599 --- /dev/null +++ b/include/kunit/bug.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * KUnit helpers for backtrace suppression + * + * Copyright (c) 2024 Guenter Roeck + */ + +#ifndef _KUNIT_BUG_H +#define _KUNIT_BUG_H + +#ifndef __ASSEMBLY__ + +#include + +#if IS_ENABLED(CONFIG_KUNIT) + +#include +#include + +struct __suppressed_warning { + struct list_head node; + const char *function; +}; + +void __start_suppress_warning(struct __suppressed_warning *warning); +void __end_suppress_warning(struct __suppressed_warning *warning); +bool __is_suppressed_warning(const char *function); + +#define DEFINE_SUPPRESSED_WARNING(func) \ + struct __suppressed_warning __kunit_suppress_##func = \ + { .function = __stringify(func) } + +#define START_SUPPRESSED_WARNING(func) \ + __start_suppress_warning(&__kunit_suppress_##func) + +#define END_SUPPRESSED_WARNING(func) \ + __end_suppress_warning(&__kunit_suppress_##func) + +#define IS_SUPPRESSED_WARNING(func) \ + __is_suppressed_warning(func) + +#else /* CONFIG_KUNIT */ + +#define DEFINE_SUPPRESSED_WARNING(func) +#define START_SUPPRESSED_WARNING(func) +#define END_SUPPRESSED_WARNING(func) +#define IS_SUPPRESSED_WARNING(func) (false) + +#endif /* CONFIG_KUNIT */ +#endif /* __ASSEMBLY__ */ +#endif /* _KUNIT_BUG_H */ diff --git a/include/kunit/test.h b/include/kunit/test.h index fcb4a4940ace..894c9fd1495d 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -10,6 +10,7 @@ #define _KUNIT_TEST_H #include +#include #include #include diff --git a/include/linux/bug.h b/include/linux/bug.h index 348acf2558f3..c668762dc76a 100644 --- a/include/linux/bug.h +++ b/include/linux/bug.h @@ -36,6 +36,9 @@ static inline int is_warning_bug(const struct bug_entry *bug) return bug->flags & BUGFLAG_WARNING; } +void bug_get_file_function_line(struct bug_entry *bug, const char **file, + const char **function, unsigned int *line); + void bug_get_file_line(struct bug_entry *bug, const char **file, unsigned int *line); @@ -62,6 +65,16 @@ static inline enum bug_trap_type report_bug(unsigned long bug_addr, } struct bug_entry; +static inline void bug_get_file_function_line(struct bug_entry *bug, + const char **file, + const char **function, + unsigned int *line) +{ + *file = NULL; + *function = NULL; + *line = 0; +} + static inline void bug_get_file_line(struct bug_entry *bug, const char **file, unsigned int *line) { diff --git a/lib/bug.c b/lib/bug.c index e0ff21989990..6b85d4042e07 100644 --- a/lib/bug.c +++ b/lib/bug.c @@ -26,6 +26,14 @@ when CONFIG_DEBUG_BUGVERBOSE is not enabled, so you must generate the values accordingly. + 2a.Optionally implement support for the "function" entry in struct + bug_entry. This entry must point to the name of the function triggering + the warning or bug trap (normally __func__). This is only needed if + both CONFIG_DEBUG_BUGVERBOSE and CONFIG_KUNIT are enabled and if + the architecture wants to implement support for suppressing warning + backtraces. The architecture must define HAVE_BUG_FUNCTION if it adds + pointers to function names to struct bug_entry. + 3. Implement the trap - In the illegal instruction trap handler (typically), verify that the fault was in kernel mode, and call report_bug() @@ -127,14 +135,21 @@ static inline struct bug_entry *module_find_bug(unsigned long bugaddr) } #endif -void bug_get_file_line(struct bug_entry *bug, const char **file, - unsigned int *line) +void bug_get_file_function_line(struct bug_entry *bug, const char **file, + const char **function, unsigned int *line) { + *function = NULL; #ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS *file = (const char *)&bug->file_disp + bug->file_disp; +#ifdef HAVE_BUG_FUNCTION + *function = (const char *)&bug->function_disp + bug->function_disp; +#endif #else *file = bug->file; +#ifdef HAVE_BUG_FUNCTION + *function = bug->function; +#endif #endif *line = bug->line; #else @@ -143,6 +158,13 @@ void bug_get_file_line(struct bug_entry *bug, const char **file, #endif } +void bug_get_file_line(struct bug_entry *bug, const char **file, unsigned int *line) +{ + const char *function; + + bug_get_file_function_line(bug, file, &function, line); +} + struct bug_entry *find_bug(unsigned long bugaddr) { struct bug_entry *bug; @@ -157,8 +179,9 @@ struct bug_entry *find_bug(unsigned long bugaddr) static enum bug_trap_type __report_bug(unsigned long bugaddr, struct pt_regs *regs) { struct bug_entry *bug; - const char *file; + const char *file, *function; unsigned line, warning, once, done; + char __maybe_unused sym[KSYM_SYMBOL_LEN]; if (!is_valid_bugaddr(bugaddr)) return BUG_TRAP_TYPE_NONE; @@ -169,12 +192,32 @@ static enum bug_trap_type __report_bug(unsigned long bugaddr, struct pt_regs *re disable_trace_on_warning(); - bug_get_file_line(bug, &file, &line); + bug_get_file_function_line(bug, &file, &function, &line); +#if IS_ENABLED(CONFIG_KUNIT) && defined(CONFIG_KALLSYMS) + if (!function) { + /* + * This will be seen if report_bug is called on an architecture + * with no architecture-specific support for suppressing warning + * backtraces, if CONFIG_DEBUG_BUGVERBOSE is not enabled, or if + * the calling code is from assembler which does not record a + * function name. Extracting the function name from the bug + * address is less than perfect since compiler optimization may + * result in 'bugaddr' pointing to a function which does not + * actually trigger the warning, but it is better than no + * suppression at all. + */ + sprint_symbol_no_offset(sym, bugaddr); + function = sym; + } +#endif /* IS_ENABLED(CONFIG_KUNIT) && defined(CONFIG_KALLSYMS) */ warning = (bug->flags & BUGFLAG_WARNING) != 0; once = (bug->flags & BUGFLAG_ONCE) != 0; done = (bug->flags & BUGFLAG_DONE) != 0; + if (warning && IS_SUPPRESSED_WARNING(function)) + return BUG_TRAP_TYPE_WARN; + if (warning && once) { if (done) return BUG_TRAP_TYPE_WARN; diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile index 309659a32a78..545b57c3be48 100644 --- a/lib/kunit/Makefile +++ b/lib/kunit/Makefile @@ -14,8 +14,10 @@ ifeq ($(CONFIG_KUNIT_DEBUGFS),y) kunit-objs += debugfs.o endif -# KUnit 'hooks' are built-in even when KUnit is built as a module. -obj-y += hooks.o +# KUnit 'hooks' and bug handling are built-in even when KUnit is built +# as a module. +obj-y += hooks.o \ + bug.o obj-$(CONFIG_KUNIT_TEST) += kunit-test.o diff --git a/lib/kunit/bug.c b/lib/kunit/bug.c new file mode 100644 index 000000000000..f93544d7a9d1 --- /dev/null +++ b/lib/kunit/bug.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * KUnit helpers for backtrace suppression + * + * Copyright (c) 2024 Guenter Roeck + */ + +#include +#include +#include +#include + +static LIST_HEAD(suppressed_warnings); + +void __start_suppress_warning(struct __suppressed_warning *warning) +{ + list_add(&warning->node, &suppressed_warnings); +} +EXPORT_SYMBOL_GPL(__start_suppress_warning); + +void __end_suppress_warning(struct __suppressed_warning *warning) +{ + list_del(&warning->node); +} +EXPORT_SYMBOL_GPL(__end_suppress_warning); + +bool __is_suppressed_warning(const char *function) +{ + struct __suppressed_warning *warning; + + if (!function) + return false; + + list_for_each_entry(warning, &suppressed_warnings, node) { + if (!strcmp(function, warning->function)) + return true; + } + return false; +} +EXPORT_SYMBOL_GPL(__is_suppressed_warning); From patchwork Tue Mar 12 17:02:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590402 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 2C1B4C54E69 for ; Tue, 12 Mar 2024 17:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N3FXq3nWX1iu2j8V+uJhL3hRzjQ26eC/+tqhyaJHG8E=; b=ThJKrD2FKdYmPT IZAJgYhNctRSvIuuY4QaN28QPf6vX6erV8Z+TkWtHekK+PfAMYlB7w7ZuRotiGD8IuyIfrenXQMPz bwJz/lURm3cWH1wWHM1LDTzF5qUw95gmPNGFSCLPDBhlbxU54KtcfKGFIDoe29kfVvgX7BMxaqaMx TF/4Vg8O9naSK306k4GwRAJPI/YQLN2r7w66iWwfRcEwXVVBtj2iwj/uiSUKUZOMPeioGGvYInQU3 pqUIe10l09xM2DtlQ0RSQW/S/bFKlGB3SWLAxNZEGMJ2NOxTO8QHUL48/K0uX0ho4Onrd66F8DLlG TcMFXaEjYYgCuRLn9w5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XJ-00000006im6-3nZq; Tue, 12 Mar 2024 17:03:33 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5X5-00000006iac-3WsT; Tue, 12 Mar 2024 17:03:21 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1dc49b00bdbso34336775ad.3; Tue, 12 Mar 2024 10:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710262999; x=1710867799; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=R3Kc+Yh+XQ4llosDDGAwX/2k1FGi6g14GWlRJRORANM=; b=mUkelREQqLvN8BVawZEUf7EbtBBW3ePLGSKJVVNjP2ez66BiL/hHHZYuy2Jq/f9gKU Dgp2+yYWlRnqpLdOhEhu0qOYD7lLywaA3HavUmVK1aj/nUuFaE9txaRvpCKfQX1DbxXP ymvYsqMm1oPn6jolsEMZKUKqr82GPpPaXDdyGCeix02gB5b3Zxa4j3ZAaxjasz3rgzfJ rD85Xb8jjP67Mcuzhxeu6qqdGzIf6RwiUvuUOBT9HFsjeh2vTmU4q39RxVo+2y4cYQXh Ty++hhw2VvuL+wi+CqkmvSRIzRC/VQhZe90YuG6+ssayX7+xcmPO5a5O37Hukg11iRHX 3yRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710262999; x=1710867799; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=R3Kc+Yh+XQ4llosDDGAwX/2k1FGi6g14GWlRJRORANM=; b=IAphAlI4ejzgUQ/iuJRaoQ0NB4zipi7h25IQUUuuGdGEdmfdPXr5EUg5w+MNfazIAd 6jkszv57piAnUNRH6usGZhORv7qeLfgXmp9nWhGlnuER2Q96iB5DHr8p8LbSJMs8JD11 A3yH9WwMwQBgV5v83/ZFRJCGFCyuexeD7emx8uqLj7j6OccGhpP5V8tVTbnSSZ16z8IX +L+u8dT260n/PNxGCclE0305zfNYUeCuVZvIdxLnzNuLWfk8AtwzfbqE024vktb7dqOY Ilyeukd+oUwriYGQqCfPuB5ebA4nn++t2yZdJrrVQzToxBmxlYwGru8r+Cz2ta0+b4bw i4Lg== X-Forwarded-Encrypted: i=1; AJvYcCVGd6sAiGe3qZ4SnaszWqY9VqmD4K5IV3m5o9E0ElhS9A4X8J+rvUWm6jtiP/zkHRPkGDz95ib34xbELv9/ZLN22yzpThtsxYy2mL0YDD9jdzOiXvveuUNfS+B6Snw1qa1xLa2l34ApIPIj0/V3U/4FbZwY4eA= X-Gm-Message-State: AOJu0Yx15JSY3NjqKYdC05C4fqwR+p5F8f1s5Qacpim0NFFRZY7pa2E5 TmJkPR9Nl2btuyu2Ci4/yizX2YEH5nvkpvvqvJgsZRVjBrL4vss4 X-Google-Smtp-Source: AGHT+IEtMqO0igDV/OJPl9l/q0X7vf8EgJ9VbKv7ARIuPeUFcb0gEvMyJN5DQCEgr2SoDMnFKNIL1A== X-Received: by 2002:a17:902:7b95:b0:1dc:418f:890b with SMTP id w21-20020a1709027b9500b001dc418f890bmr8936395pll.40.1710262998624; Tue, 12 Mar 2024 10:03:18 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e4-20020a170902b78400b001dcc3a46a6bsm6883069pls.262.2024.03.12.10.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:18 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 02/14] kunit: bug: Count suppressed warning backtraces Date: Tue, 12 Mar 2024 10:02:57 -0700 Message-Id: <20240312170309.2546362-3-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_100319_918818_0F4C550B X-CRM114-Status: GOOD ( 13.82 ) 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 Count suppressed warning backtraces to enable code which suppresses warning backtraces to check if the expected backtrace(s) have been observed. Using atomics for the backtrace count resulted in build errors on some architectures due to include file recursion, so use a plain integer for now. Signed-off-by: Guenter Roeck Reviewed-by: Kees Cook --- include/kunit/bug.h | 7 ++++++- lib/kunit/bug.c | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/kunit/bug.h b/include/kunit/bug.h index 1e34da961599..2097a854ac8c 100644 --- a/include/kunit/bug.h +++ b/include/kunit/bug.h @@ -20,6 +20,7 @@ struct __suppressed_warning { struct list_head node; const char *function; + int counter; }; void __start_suppress_warning(struct __suppressed_warning *warning); @@ -28,7 +29,7 @@ bool __is_suppressed_warning(const char *function); #define DEFINE_SUPPRESSED_WARNING(func) \ struct __suppressed_warning __kunit_suppress_##func = \ - { .function = __stringify(func) } + { .function = __stringify(func), .counter = 0 } #define START_SUPPRESSED_WARNING(func) \ __start_suppress_warning(&__kunit_suppress_##func) @@ -39,12 +40,16 @@ bool __is_suppressed_warning(const char *function); #define IS_SUPPRESSED_WARNING(func) \ __is_suppressed_warning(func) +#define SUPPRESSED_WARNING_COUNT(func) \ + (__kunit_suppress_##func.counter) + #else /* CONFIG_KUNIT */ #define DEFINE_SUPPRESSED_WARNING(func) #define START_SUPPRESSED_WARNING(func) #define END_SUPPRESSED_WARNING(func) #define IS_SUPPRESSED_WARNING(func) (false) +#define SUPPRESSED_WARNING_COUNT(func) (0) #endif /* CONFIG_KUNIT */ #endif /* __ASSEMBLY__ */ diff --git a/lib/kunit/bug.c b/lib/kunit/bug.c index f93544d7a9d1..13b3d896c114 100644 --- a/lib/kunit/bug.c +++ b/lib/kunit/bug.c @@ -32,8 +32,10 @@ bool __is_suppressed_warning(const char *function) return false; list_for_each_entry(warning, &suppressed_warnings, node) { - if (!strcmp(function, warning->function)) + if (!strcmp(function, warning->function)) { + warning->counter++; return true; + } } return false; } From patchwork Tue Mar 12 17:02:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590404 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 EA672C54E5D for ; Tue, 12 Mar 2024 17:04:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1Q/CmHw7+dpLzndNONCBHc5FGTMbZuuSFzXh61pn6mk=; b=Y9C3P8LcaD1Txh wVMphDQCiOKB67KOtXvkTk0Dhb3+RdMcg/ksTLUH26Jt7xBlY78b5dKQvkyMDcS2ZxcyMR+ttW6Pc yprp+McrmpmEVQ1WB9diTcO8FvMUKB/HBVJGt+L7I+R1nj0idE4PCOOMRBC4UxrEcGUXwA/hRf0nY XONdAW30P2gctmHDyGfZlAolYGwRTToMcxjtRLzp73/zJk5QspT4LXrA+LSglBGC/mMJBCNy/d3I8 YZk6+4pdb5i1RCWvYlyYBE+6dvhJ+sYqYvyqR0s34Hfrj2DAwNZ/x/jY3OM/yAaJkOFwYBIEQWOKH AC8JTwzjpo1oPQp1K/aQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5Xq-00000006jDo-1TTj; Tue, 12 Mar 2024 17:04:06 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5X7-00000006ibc-3eD5; Tue, 12 Mar 2024 17:03:23 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6e622b46f45so3449426b3a.1; Tue, 12 Mar 2024 10:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263000; x=1710867800; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=0g4hKhLnYWz4PyvpNTr/SgCP1vJlAe2ABRcfc3yqje8=; b=eP1xHH5EDt+i8EKnj2RRwFTIkWwNG6om7zjXp83JrI9LDsYQ1vRPiFJ5lDnQzasFsV dL1qg2xteTMXy1QqEXqmwYAhzn1iRb7X1+mQYAsaxTebZn5kjJDEVrK9EMqRWoOAMFj0 UE95i5bVX6Sh2BB4ZN24dvZLCIRrM17F59c/pUFQYIwJ813nSjd3YiFfnBiLlv/L2cYa Mz9p362kBd6+3XJ1rdrwNHBv+w0eTm9PNbsLe67BFjRmF/rt2nP5oseyACrc2ZdFlH09 dKD9ZuJnTxuMFyBw3GZ4t132bM0KkhdYE3hGbzLFMnh7hye/d7p8LgTjROWJIxzJc7+k iN+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263000; x=1710867800; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0g4hKhLnYWz4PyvpNTr/SgCP1vJlAe2ABRcfc3yqje8=; b=IVnCiMi6+txuxliRSgaehA091K5TOnd7umB04yXo76L9cVyU5yxRdFcWyv4x1yHN1K aICzrLNCyPipgush/roDnSJ0FFD+q0Ug++hKqezgkAutFpCLvzXSZM1P8ytOwehPmNJU x0PKbbva4vwWgI2GEqvd1koGYnroC3VAyFraRBmrGMKk8HRcn0eturxwORhMR5uQyIJ/ xKFNczzRp1d7i7NpJVzdkxhKImS1Yte6P9Zo2RiKL33gy4b9w7elGM15Mzou9NcIRF2X xhrpIvHdS9XkHdsQagA0HA03bKkqNOEOsqe6LtpxezWHfcoI+L4wRe0fkRz7cemUKoC1 iczg== X-Forwarded-Encrypted: i=1; AJvYcCULAK1EohWOmHCoN2myCB/ju5KPMAKhZOMJNPGMwWCwAmfrmSk8nxz85u5ovB2ThCYi0upVBJPjtBAJN4c8wBHAYfG1NzCZveQat+xMKkH9MwCEHZCKRgEE8BeCUhYDuvwu/S3W/546Nb2G4gHlHhSONKjU/3A= X-Gm-Message-State: AOJu0YyMGBL/6qxT2lfehQhRuT0t5BoTlnGoaghvoe9P0n9m+lyIKzz0 Hpmzq+v5tp/99u5EJPVqjP9GZTfiHNInmfI6xD65aYtWVNT+36x6 X-Google-Smtp-Source: AGHT+IHT6d6QUcxkAobup5YpfcRZi4Aa/waxUmdzBZbBKsk0+4WZBzbaK7WYGFQOB9v1r7/VMSutWg== X-Received: by 2002:a05:6a00:10d2:b0:6e5:ad7d:d031 with SMTP id d18-20020a056a0010d200b006e5ad7dd031mr32842pfu.32.1710263000113; Tue, 12 Mar 2024 10:03:20 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id r2-20020aa79ec2000000b006e31f615af6sm6552880pfq.17.2024.03.12.10.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:19 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 03/14] kunit: Add test cases for backtrace warning suppression Date: Tue, 12 Mar 2024 10:02:58 -0700 Message-Id: <20240312170309.2546362-4-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_100322_261916_F1F907BC X-CRM114-Status: GOOD ( 15.78 ) 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 Add unit tests to verify that warning backtrace suppression works. If backtrace suppression does _not_ work, the unit tests will likely trigger unsuppressed backtraces, which should actually help to get the affected architectures / platforms fixed. Signed-off-by: Guenter Roeck Reviewed-by: Kees Cook --- lib/kunit/Makefile | 3 +- lib/kunit/backtrace-suppression-test.c | 104 +++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 lib/kunit/backtrace-suppression-test.c diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile index 545b57c3be48..6a44d2b54ea9 100644 --- a/lib/kunit/Makefile +++ b/lib/kunit/Makefile @@ -19,7 +19,8 @@ endif obj-y += hooks.o \ bug.o -obj-$(CONFIG_KUNIT_TEST) += kunit-test.o +obj-$(CONFIG_KUNIT_TEST) += kunit-test.o \ + backtrace-suppression-test.o # string-stream-test compiles built-in only. ifeq ($(CONFIG_KUNIT_TEST),y) diff --git a/lib/kunit/backtrace-suppression-test.c b/lib/kunit/backtrace-suppression-test.c new file mode 100644 index 000000000000..47c619283802 --- /dev/null +++ b/lib/kunit/backtrace-suppression-test.c @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * KUnit test for suppressing warning tracebacks + * + * Copyright (C) 2024, Guenter Roeck + * Author: Guenter Roeck + */ + +#include +#include + +static void backtrace_suppression_test_warn_direct(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(backtrace_suppression_test_warn_direct); + + START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_direct); + WARN(1, "This backtrace should be suppressed"); + END_SUPPRESSED_WARNING(backtrace_suppression_test_warn_direct); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(backtrace_suppression_test_warn_direct), 1); +} + +static void trigger_backtrace_warn(void) +{ + WARN(1, "This backtrace should be suppressed"); +} + +static void backtrace_suppression_test_warn_indirect(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(trigger_backtrace_warn); + + START_SUPPRESSED_WARNING(trigger_backtrace_warn); + trigger_backtrace_warn(); + END_SUPPRESSED_WARNING(trigger_backtrace_warn); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(trigger_backtrace_warn), 1); +} + +static void backtrace_suppression_test_warn_multi(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(trigger_backtrace_warn); + DEFINE_SUPPRESSED_WARNING(backtrace_suppression_test_warn_multi); + + START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_multi); + START_SUPPRESSED_WARNING(trigger_backtrace_warn); + WARN(1, "This backtrace should be suppressed"); + trigger_backtrace_warn(); + END_SUPPRESSED_WARNING(trigger_backtrace_warn); + END_SUPPRESSED_WARNING(backtrace_suppression_test_warn_multi); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(backtrace_suppression_test_warn_multi), 1); + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(trigger_backtrace_warn), 1); +} + +static void backtrace_suppression_test_warn_on_direct(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(backtrace_suppression_test_warn_on_direct); + + if (!IS_ENABLED(CONFIG_DEBUG_BUGVERBOSE) && !IS_ENABLED(CONFIG_KALLSYMS)) + kunit_skip(test, "requires CONFIG_DEBUG_BUGVERBOSE or CONFIG_KALLSYMS"); + + START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_on_direct); + WARN_ON(1); + END_SUPPRESSED_WARNING(backtrace_suppression_test_warn_on_direct); + + KUNIT_EXPECT_EQ(test, + SUPPRESSED_WARNING_COUNT(backtrace_suppression_test_warn_on_direct), 1); +} + +static void trigger_backtrace_warn_on(void) +{ + WARN_ON(1); +} + +static void backtrace_suppression_test_warn_on_indirect(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(trigger_backtrace_warn_on); + + if (!IS_ENABLED(CONFIG_DEBUG_BUGVERBOSE)) + kunit_skip(test, "requires CONFIG_DEBUG_BUGVERBOSE"); + + START_SUPPRESSED_WARNING(trigger_backtrace_warn_on); + trigger_backtrace_warn_on(); + END_SUPPRESSED_WARNING(trigger_backtrace_warn_on); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(trigger_backtrace_warn_on), 1); +} + +static struct kunit_case backtrace_suppression_test_cases[] = { + KUNIT_CASE(backtrace_suppression_test_warn_direct), + KUNIT_CASE(backtrace_suppression_test_warn_indirect), + KUNIT_CASE(backtrace_suppression_test_warn_multi), + KUNIT_CASE(backtrace_suppression_test_warn_on_direct), + KUNIT_CASE(backtrace_suppression_test_warn_on_indirect), + {} +}; + +static struct kunit_suite backtrace_suppression_test_suite = { + .name = "backtrace-suppression-test", + .test_cases = backtrace_suppression_test_cases, +}; +kunit_test_suites(&backtrace_suppression_test_suite); + +MODULE_LICENSE("GPL"); From patchwork Tue Mar 12 17:02:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590405 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 68B1FC54E58 for ; Tue, 12 Mar 2024 17:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=X/Rs5v3YFNpwhvHgkRcosz/Z7wCR9APvj7UQyxjxeYs=; b=ZqiixmPqwCm5PN JK2LpOGvTWiVnPNZOB9Pm24CdRb1Hr1zFbMmYIjTIZ73SCjS63UDTlOdnqdoigROWeNGVqu8RVjrv rSn/mMCl3W1+SCeyRty2k/sWvj2ho6MI0KRw9+YfEMkCv5SYDH3aRE9Fb83yfTEDaF3nW1g7b1gHF Ql+Aw0mXMi9wKakfMU9blxFd+IfGuVnQSeA8XAG3gkp03SK0Hf+p0OYp22xOnfLYoCjXDLz+9WGhA 8oCvz513A+VthtLl4tMiGTfKc6C1dvYeM5JSikLNRDsDYPTljIitXlB28O06FB5jvP/fmHKsQYN36 jmXSOebsBH3Yirc0i0MA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5Xt-00000006jGm-3xAC; Tue, 12 Mar 2024 17:04:09 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XB-00000006icT-0Q0r; Tue, 12 Mar 2024 17:03:27 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dca3951ad9so47285635ad.3; Tue, 12 Mar 2024 10:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263002; x=1710867802; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=36BrykVX1YEJvDrrNJGSTLQfgxZ1lgqGPC6PgqTTbEw=; b=GbMSCdmYmzTeoAE1M2oKR1Kw62noH7EBXDmdZs1Un8RRDnzoDunyyYjc+U7NNUtVF0 p0WqvZGNRXOJ+NSrwTvg8o0Y2aR/Ohz6GDuD6htd+R7Lioy/UqXFNB8l9jXTaXL5e250 sTsMKdDnkBiWAJZwXsyc8gY5u5CW91xGal7VRD7WhA1vCFd6495sGk5rRsLqXUjqFwLz E7jDAausmV8Sg1mP3o824ynm870oMrrbD4BmNJqAl4DHt2h7wo/7T616SMKbhIbcoQMI q/PBg9rQ2LwWSzP4WSyAYBFbQWV8/qXuhpIzRCgjn3xeWhggYw1HzS5bPDoYlLz4fV56 2OIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263002; x=1710867802; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=36BrykVX1YEJvDrrNJGSTLQfgxZ1lgqGPC6PgqTTbEw=; b=GElk2twe191iq2ec2DphmbTFST5IINdcNfPq68hP9bnYq+k2mqC8OOmb1Dpy8lk5oW 9jnYMwi/kR/gtydGRBzo7796fQgoMUGM0SK8bSEq5r6YY8lJaTHs/HP2tn71YPDl/rjP /iiMQkIQ131LnrCBTjAgE7ZoSdkkeSIswYMlxnkU/8tZgpYcbW2OPx0VE47pfh2jXWh7 zPWWtuQ1YWMq/Onpjf45u91ysZNGZbtYXLEhGiNhIUblnkk2+aGqb/shzjd1MyuNYzj4 QtZSLtOInFvHV5qN/GuqY+sy1F1y6uyuTo6+TMWSG1ibbYlKFwyXsuqFsbg7YXWKDIYj GMgA== X-Forwarded-Encrypted: i=1; AJvYcCX1EaWAWbOAwkUwEZ6pKCGxQWcgSt7hgaz3XvP/LICF9Y+EB/r2tEYaD6h8rQUsxAOG1BjTCxjEC3dBbksLdxKVa+gFv5m4L2odxzN28+lAbCm9Xb1VtxqpNf6v0VnAUxtYN9hHlEvhLKATZ4ogwgYqCfs/J94= X-Gm-Message-State: AOJu0Yy/aYYgNXT81NGJljcK9gKtBds+SMP2tdD1f7R5SikWEHMqsiob rp20MXvi8E4VL1ryZAL0knjoSR/VWn13RrdBClPwyDyRYb3tjZky X-Google-Smtp-Source: AGHT+IHYAZUPDqsFw7GWyh1RSbVI2Qwrh9Mdl1wKcQdsH3Ao31Ql441CQm7bvVJxkQ6v+AiS/8LElw== X-Received: by 2002:a17:902:b198:b0:1dc:d8de:5664 with SMTP id s24-20020a170902b19800b001dcd8de5664mr9227736plr.33.1710263002517; Tue, 12 Mar 2024 10:03:22 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id q1-20020a170902a3c100b001dbb6fef41fsm7095813plb.257.2024.03.12.10.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:21 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 04/14] kunit: Add documentation for warning backtrace suppression API Date: Tue, 12 Mar 2024 10:02:59 -0700 Message-Id: <20240312170309.2546362-5-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_100325_453138_0929894E X-CRM114-Status: GOOD ( 14.19 ) 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 Document API functions for suppressing warning backtraces. Signed-off-by: Guenter Roeck Reviewed-by: Kees Cook --- Documentation/dev-tools/kunit/usage.rst | 30 ++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst index 22955d56b379..8d3d36d4103d 100644 --- a/Documentation/dev-tools/kunit/usage.rst +++ b/Documentation/dev-tools/kunit/usage.rst @@ -157,6 +157,34 @@ Alternatively, one can take full control over the error message by using if (some_setup_function()) KUNIT_FAIL(test, "Failed to setup thing for testing"); +Suppressing warning backtraces +------------------------------ + +Some unit tests trigger warning backtraces either intentionally or as side +effect. Such backtraces are normally undesirable since they distract from +the actual test and may result in the impression that there is a problem. + +Such backtraces can be suppressed. To suppress a backtrace in some_function(), +use the following code. + +.. code-block:: c + + static void some_test(struct kunit *test) + { + DEFINE_SUPPRESSED_WARNING(some_function); + + START_SUPPRESSED_WARNING(some_function); + trigger_backtrace(); + END_SUPPRESSED_WARNING(some_function); + } + +SUPPRESSED_WARNING_COUNT() returns the number of suppressed backtraces. If the +suppressed backtrace was triggered on purpose, this can be used to check if +the backtrace was actually triggered. + +.. code-block:: c + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(some_function), 1); Test Suites ~~~~~~~~~~~ @@ -857,4 +885,4 @@ For example: dev_managed_string = devm_kstrdup(fake_device, "Hello, World!"); // Everything is cleaned up automatically when the test ends. - } \ No newline at end of file + } From patchwork Tue Mar 12 17:03:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590545 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 992F8C54E6A for ; Tue, 12 Mar 2024 19:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5mnqyLif6/Zt3KKdq6tOKbc8kTgg1X1dQKGPUl1gxa0=; b=s0khIRNf6PVz9u eD5ICZET3XdapFUzQHwCjT1TPsCe0x6rxFEMfNe9PfN0aFGcuLTpGSHK2Raz9S+JEtRC9FMzTaFnC +4O8wv1+kllgleGud7rDzJtZ/8jKlYmeuj63lxWy/94N7Epc2KlwoDZU7D2cDFoqpFBNYN6HH5FlJ AcuFtmkaLK+R/edJ160p5Tno59sqizzmRb2N/6pEZ3JiVSlzXQMZ5UyiWJITauwFa3ZwOEM2bKv7e k+afQH7qQju69iZD4zzslwqHces2QcMuqbgh9FkkIP/H0fAs3mNnlTrP1DE0eTRB/4h16AmPYBZTw EjXDZuKH89KibGR3DoEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk7qR-00000007IBt-3M02; Tue, 12 Mar 2024 19:31:27 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XF-00000006idb-0xJ5; Tue, 12 Mar 2024 17:03:33 +0000 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6e6adc557f3so577032b3a.1; Tue, 12 Mar 2024 10:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263005; x=1710867805; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=NGQg+0HBD/PmNnv+fI5fQqG3IGlyLsIaZmNJE7ZYwjo=; b=FuGLyEshx6ZssHealmxyS3HK48hr+IPl4R8AdPiMXnNftnOsZHDcXGhDcJmocEozQ4 n3+MMN2vucsx8qQY2pkIaggcJY0M5M8cEYpZ6IRzSxt0xu9Nap/4hHHHcCy+9T8zsPKd NerMH408j8nEK2eU0LjwL7PEn1totwMN/JXGWp+ruKF+LyeHp3Fw1LjVVz6nv0csdZt5 kYaiZK512+5vrRErf3Z2IP/EgFwCaAUBqVvx4oHKMNrGzQVlbWLVE7tjpPFWhzeviu4f G7Vw75Yjh/I2i0pqHc1HBWduKEXe/tgC+kfeg5/xXMrd3jcFNShkTy8NvwMe7G056VqF C3XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263005; x=1710867805; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=NGQg+0HBD/PmNnv+fI5fQqG3IGlyLsIaZmNJE7ZYwjo=; b=FjVjOzq0VUGsr6gVWJM4SYB0NhJcEJJkCOFOEF9Jdbd6QA0oAYJJ334BrvaSD+kqhb LeCpZMAoPQrg7cMKpnTpKtDqjcY07hIkG3dvfK0Z+gYYH7PuxWgQPasJmZ8suBQ/eKue g1mRLY4HhP/vuXjXmYBVYcIm3ZWaLYvJmCD/cs98Ae8J1vsa0XWfiVzpF4Z4hHWyEjHf xITUm6rEAPVy3HyrvQcdQG7y5DGSWUA2nYb9xw4jTaSn3MbEmaeGK8Ln2sr6ahol0LPN oKXCm3jYh+CrMIOisgj4Gh98Vx4AA/W6RYMhYsDyliDNo/2FXPFXXyCuL6rQkHDE9sYH LNSQ== X-Forwarded-Encrypted: i=1; AJvYcCWQCizT3GDOTwlEixcP52kmJZjK4RNr9vI7SjQgDmeG79URP9eXs9unzStj1NlxxjpAwEpUDT/gIFoGlksCCjZxYvZYm2D1RkN5A/4kEMjkb5wNDRVFUgsvNSCu3IW1ZB500BuhXjvApnPzlYbUButPxRnBkTA= X-Gm-Message-State: AOJu0Yw/CKOHVdvS5NTXByhsjZroHITTTpwAC24LnrWflS6wfxP8mRYu ny4h1kJWZY+bpYDWIncs3p02pjpgX7tOOe4sm8zqJDYfGrsSQ1+m X-Google-Smtp-Source: AGHT+IGxFzq6cbK7MrvIXcZlkGCehcjfwe014BGxyN94I+kP8/p7v7PJMJz1gy7c7O8kch/y3R6C8g== X-Received: by 2002:a05:6a20:1a8f:b0:1a1:4ea8:1844 with SMTP id ci15-20020a056a201a8f00b001a14ea81844mr8418900pzb.26.1710263004751; Tue, 12 Mar 2024 10:03:24 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id t123-20020a628181000000b006e657c72cf8sm6830699pfd.148.2024.03.12.10.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:23 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 05/14] drm: Suppress intentional warning backtraces in scaling unit tests Date: Tue, 12 Mar 2024 10:03:00 -0700 Message-Id: <20240312170309.2546362-6-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_100330_502353_A6DB281E X-CRM114-Status: UNSURE ( 9.52 ) X-CRM114-Notice: Please train this message. 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 The drm_test_rect_calc_hscale and drm_test_rect_calc_vscale unit tests intentionally trigger warning backtraces by providing bad parameters to the tested functions. What is tested is the return value, not the existence of a warning backtrace. Suppress the backtraces to avoid clogging the kernel log. Signed-off-by: Guenter Roeck --- drivers/gpu/drm/tests/drm_rect_test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c index 76332cd2ead8..75614cb4deb5 100644 --- a/drivers/gpu/drm/tests/drm_rect_test.c +++ b/drivers/gpu/drm/tests/drm_rect_test.c @@ -406,22 +406,28 @@ KUNIT_ARRAY_PARAM(drm_rect_scale, drm_rect_scale_cases, drm_rect_scale_case_desc static void drm_test_rect_calc_hscale(struct kunit *test) { + DEFINE_SUPPRESSED_WARNING(drm_calc_scale); const struct drm_rect_scale_case *params = test->param_value; int scaling_factor; + START_SUPPRESSED_WARNING(drm_calc_scale); scaling_factor = drm_rect_calc_hscale(¶ms->src, ¶ms->dst, params->min_range, params->max_range); + END_SUPPRESSED_WARNING(drm_calc_scale); KUNIT_EXPECT_EQ(test, scaling_factor, params->expected_scaling_factor); } static void drm_test_rect_calc_vscale(struct kunit *test) { + DEFINE_SUPPRESSED_WARNING(drm_calc_scale); const struct drm_rect_scale_case *params = test->param_value; int scaling_factor; + START_SUPPRESSED_WARNING(drm_calc_scale); scaling_factor = drm_rect_calc_vscale(¶ms->src, ¶ms->dst, params->min_range, params->max_range); + END_SUPPRESSED_WARNING(drm_calc_scale); KUNIT_EXPECT_EQ(test, scaling_factor, params->expected_scaling_factor); } From patchwork Tue Mar 12 17:03:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590406 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 3AEA6C54E5D for ; Tue, 12 Mar 2024 17:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yrUAoDccVzKOKP9JQJnXd7YBrsVlpo7HUhTcyHQEqSE=; b=1ep2LoIDKyNpZT HT/fEuFEKVsL2x4HwMBIS73v2usPOOpaZXVyzC7aO0boznhUavPEBmj3aNTnharptK2wU9jeJ1O0j SirhNRKWWgNYryBCMRjmCziktAQXOLyo7hTK5HZPqgWF80dtCnWx614pQtfHXlSxz5K0/Ec6+ht16 ru8M1VoYZFoLYhp2hyC0iT7zI9aGP8JoOpvUYPwW7wpMEBI231iC+17aMO6N2pNDVS29xigCrFGyn GVjjPgvvDHTwRjR18Z8Q48dZOityg+bKLdBOKzmsnsyA5/NyQjL9v9p2ocmBSInQEgmyhRnCP3ROk E9V5i7/qEWbBpclcRbcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5Xw-00000006jIL-06Jz; Tue, 12 Mar 2024 17:04:12 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XI-00000006ijt-1ogq; Tue, 12 Mar 2024 17:03:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=mFp+F6/qbMDKwppN9CX4ZWrh/15b9XKC6E4V4vAKNpU=; b=UJ90j4X8rUu6lFtsW1Bptts8Mq 97X11bK7Tq96V0+GzAmod/S8D8F959Tzrs78QOzmfMHEoovvYq0E9k30tQWiIirzGBYt/wLntVZDM 0K80PnjER6YXXxPdDy8qM3BDjvDlxmNlzsjrSUWGhAvIyckRsHLVFh9XGUeZ+sJVlBU9VxbBB9FlQ p8DWufeRTrrECEZhyF+vOU8Uq6vDsW1QU9MHqnNqyhxCxZq6LILhcbgxWe3JqySsv8aWuiK2Cbgzd vg6Y3D/v17iCdyedSLYvH8m5GzFSKUaUdF5aQ7JQJ0FmGaYViBZ3Bx9u71dBCPCdO/vLaxiurW4F3 m1tV6Phw==; Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XF-00000009YdE-1PZv; Tue, 12 Mar 2024 17:03:31 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1dd5df90170so518565ad.0; Tue, 12 Mar 2024 10:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263006; x=1710867806; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=mFp+F6/qbMDKwppN9CX4ZWrh/15b9XKC6E4V4vAKNpU=; b=jAoPIwbxWrHtMtAAhH6U4842hxKWFVdXZcO5CSoRr8TXcx53cWAOW5gH0ybqpYcY83 ET5gm1uZ1XyWxqwvKbdBcqViCejRx1fcOGtQ9s3NPUQVitzPwyMNhTlBUFukIT8S/mVe PjahDe5/ODmXkRI8g/XHJdkEFK6r4hJHD64VxB/uUdIOwW9gaEC2q23V+U2TTlFX0M1s KI8k03HX3mttP4sqJX/KF3hnmWSa24fDSvztAEb/Pt8K8YZw95XrR3/TS7pdal1i6Slq GxukoN7Q7X7KXhNUj0s+j5RFsh5zq4jrvkaqjLpzGcHmcb+TvrSdR4ECtdlGbaakMK9L SIEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263006; x=1710867806; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mFp+F6/qbMDKwppN9CX4ZWrh/15b9XKC6E4V4vAKNpU=; b=S5JSks6/UKnXFMv6yosi8LSuhQz1c4V9Nb3pEJ/K36isKaN4e6x81oBogTVSBW0QDf eBPXXPNgh6zcE6rC5dfR8/jfZyFMSqjDoVnsYZ3SDSCoPJvgOZj5k5sYonCbim2SWLG4 ktVwT5uKLi3yj9C+UjzJX6eVpJqsIQL3vse5fC0lJKvoGU6qMhf/nZRcyxD4buSg8Hv+ c7t5fPnOXos5ItPg34PfP5MGG/gp/hLSmMLiPAj7p5QCH9wJbmnRgzUn5Bg3thSLqE3H /ln7JO08qC9TN6UwQ/JYzs3TthIHXdGPvR6ZraD1Qb7U3lFP6A/xuMApDQ6NGEPFfGW1 r9IQ== X-Forwarded-Encrypted: i=1; AJvYcCXpoSeSbHz7ytItbmjo/spoEhSnsfFY1YJ6vV1pofN4dTgfKzvb7jnU/5tywyEQUgOVTd3hnQxVxgxUf7Ijs7KItRVnehuJUudG6vT31S9g3PpYIXtpLgDRhCu3Ku3IhVhvtqkNqL5eHnDhRPgTE1ZI1QdkEvY= X-Gm-Message-State: AOJu0YxDb1UdyWiz4Yp82K3X2DfHen7mVeK7o1kIAuNGe2x9wJgKhZKR EOWqD7+o1seyC5B/3uQC00SRazSS1NV29OLdrwmvX3M9sPTKYdlY X-Google-Smtp-Source: AGHT+IFHgAu4TIvnFI5COGYb5tswxOQ5AvbfbseYntF0tu2SzSXjMyu1g4BetZFgaKzrp5WqY1rOuQ== X-Received: by 2002:a17:902:db10:b0:1dd:8ed0:59d0 with SMTP id m16-20020a170902db1000b001dd8ed059d0mr179469plx.17.1710263006272; Tue, 12 Mar 2024 10:03:26 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b21-20020a170902ed1500b001d9a42f6183sm6958740pld.45.2024.03.12.10.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:25 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck , Jakub Kicinski Subject: [PATCH 06/14] net: kunit: Suppress lock warning noise at end of dev_addr_lists tests Date: Tue, 12 Mar 2024 10:03:01 -0700 Message-Id: <20240312170309.2546362-7-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_170329_506225_645B3421 X-CRM114-Status: GOOD ( 13.74 ) 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 dev_addr_lists_test generates lock warning noise at the end of tests if lock debugging is enabled. There are two sets of warnings. WARNING: CPU: 0 PID: 689 at kernel/locking/mutex.c:923 __mutex_unlock_slowpath.constprop.0+0x13c/0x368 DEBUG_LOCKS_WARN_ON(__owner_task(owner) != __get_current()) WARNING: kunit_try_catch/1336 still has locks held! KUnit test cleanup is not guaranteed to run in the same thread as the test itself. For this test, this means that rtnl_lock() and rtnl_unlock() may be called from different threads. This triggers the warnings. Suppress the warnings because they are irrelevant for the test and just confusing. The first warning can be suppressed by using START_SUPPRESSED_WARNING() and END_SUPPRESSED_WARNING() around the call to rtnl_unlock(). To suppress the second warning, it is necessary to set debug_locks_silent while the rtnl lock is held. Cc: David Gow Cc: Jakub Kicinski Signed-off-by: Guenter Roeck --- net/core/dev_addr_lists_test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/core/dev_addr_lists_test.c b/net/core/dev_addr_lists_test.c index 4dbd0dc6aea2..b427dd1a3c93 100644 --- a/net/core/dev_addr_lists_test.c +++ b/net/core/dev_addr_lists_test.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include #include #include @@ -49,6 +50,7 @@ static int dev_addr_test_init(struct kunit *test) KUNIT_FAIL(test, "Can't register netdev %d", err); } + debug_locks_silent = 1; rtnl_lock(); return 0; } @@ -56,8 +58,12 @@ static int dev_addr_test_init(struct kunit *test) static void dev_addr_test_exit(struct kunit *test) { struct net_device *netdev = test->priv; + DEFINE_SUPPRESSED_WARNING(__mutex_unlock_slowpath); + START_SUPPRESSED_WARNING(__mutex_unlock_slowpath); rtnl_unlock(); + END_SUPPRESSED_WARNING(__mutex_unlock_slowpath); + debug_locks_silent = 0; unregister_netdev(netdev); free_netdev(netdev); } From patchwork Tue Mar 12 17:03:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590547 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 80312C54E5D for ; Tue, 12 Mar 2024 19:31: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0NXcaIOiB2YZT32S4bQ6f9kowjOuNH+kfHqHdM+qLeA=; b=zdAAUeXqZvBE61 17bCEMCuvyG7l3mKphVU+ny8sswy+ioTwarShxKNNy1vYvvEWnMDWJsJDRaUQrkhfe0gztBxnrrBg Zmo7HvX0qhrfeqDfUQMJF/Y8eWmRTGzPaWLD8NBckYzBxRUaBknROAOqK/91cdbF2zvSKlLWOlY8o xEcuPz6Y42H/+DpzX//fbxEqDOH9bx6u2lhvFYc4Ejahx2ktYR/37QK7mf7VvDgUo1zn3nMiRnzfn nsC17C476Dfh6TdrIlHnSs3vvy+CKkBHDBcMT1tO+bHPv0hLoouUNoj0+DOCRSl/V5QrVfebIq5X5 nfQ7c5Y+n3hVYzSwUF8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk7qT-00000007ICr-2ZAE; Tue, 12 Mar 2024 19:31:29 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XG-00000006ihj-3n9R; Tue, 12 Mar 2024 17:03:35 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5cdbc4334edso2900494a12.3; Tue, 12 Mar 2024 10:03:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263009; x=1710867809; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=5e/E6ddr2rv0O0qI6ESGYNVGq97JQ/YRs1mbYMxZhW0=; b=PX2QEuckrC/MwVZaKse7o/G7QNWSLqRIJw8rGWfcPkxmit6uDdHOKOtgRL6JIoXgSe h1vJHOsV688o0wYU2oF4uhxsy/P0LY9QPnr+jkSHvSIAnCstAaliG9nUIfLUUYO9Le1c ARYDduNS1/oxVTfLG2+tde7eeoF/A+B30Vps+CNR99LCilcZzFFDULxuqS6MDO7LUpCt ykbixU4Ua0kxsDJYwwMoveikgyFA0H6gO/EXDFH2pzNwrAiWGBGoe0ubK9nFZ6SXYS8q AUc6sffSHos1kL++PNds68/domQHc1tmxPTXIp+Pot9jotToHpNwR74+OCS/MijSuxW8 bQgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263009; x=1710867809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5e/E6ddr2rv0O0qI6ESGYNVGq97JQ/YRs1mbYMxZhW0=; b=ckAiFQx8RT4GSr0IFZdQlREIIoDdNH5+jg0BIEXrPC7cOY0cLdhE+DL15/6dXJOHk4 PdeGZZyK/rURgbZg8AISrwFRGNt1PaOxaXHHEKDNbRGR3tZlHYywxoeX6onjA+SMI9B+ laCer/Y9ceJOGqQXO69qScE0p2wGLzmv/w4jQ1ZGiMbniaMqNYy7Rs14QfA0RAmZIR7Y THQ80Xv8YhPBlNM/DWPf3oLGyBrPYEBVkfToVy8eJHlcSCJd5WH7OWudUt7cZWxo22iQ ++hWlCX56oSBXYpJ+Ul/jDGkLiR6nXHlbV9Ha4enIO3VW1ajcr5rsUfbN2RlA3TC1XWI adiQ== X-Forwarded-Encrypted: i=1; AJvYcCXw99rVvy6eLaw3Mn4q05M7kU2UaYxIj0rB4yUR8H3suVnDTdmV7k17YWp7fk/uKs5HhMLdx7XZKRNCLfxaqIPZMa/rHT7Uv1WtuMZXyp0bsgxggRx8wePsN0yvmvWhA4G4DSlSZg0ZNlAPi9Tfzbps5XLY9c4= X-Gm-Message-State: AOJu0YzNrLCNL5B+0ZgcuMxrJyPDRdomoVGeYhl5sxSlqjJ5I4CGy+3a k5juexR3Ex/Ctwbf2/fABzL1y80NTwMAcp37LY10fWfViPTzYG8N X-Google-Smtp-Source: AGHT+IHnpV6pQ4sbhTQFUz6ATEKXpUTcdarefNsnZ32RzB7TxwrdDKUDIv3vmdM+PJbrepqm0Atu1Q== X-Received: by 2002:a17:90a:ba93:b0:29c:844:a91 with SMTP id t19-20020a17090aba9300b0029c08440a91mr5600961pjr.48.1710263008670; Tue, 12 Mar 2024 10:03:28 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id bf20-20020a17090b0b1400b0029bc2b845c4sm5986405pjb.11.2024.03.12.10.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:28 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 07/14] x86: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:02 -0700 Message-Id: <20240312170309.2546362-8-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_100331_255779_62037F8B X-CRM114-Status: GOOD ( 12.47 ) 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 Add name of functions triggering warning backtraces to the __bug_table object section to enable support for suppressing WARNING backtraces. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Signed-off-by: Guenter Roeck --- arch/x86/include/asm/bug.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index a3ec87d198ac..d87bf8bab238 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -23,18 +23,28 @@ #ifdef CONFIG_DEBUG_BUGVERBOSE +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%c1) +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC_PTR +# define __BUG_FUNC NULL +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define _BUG_FLAGS(ins, flags, extra) \ do { \ asm_inline volatile("1:\t" ins "\n" \ ".pushsection __bug_table,\"aw\"\n" \ "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \ - "\t.word %c1" "\t# bug_entry::line\n" \ - "\t.word %c2" "\t# bug_entry::flags\n" \ - "\t.org 2b+%c3\n" \ + "\t" __BUG_FUNC_PTR "\t# bug_entry::function\n" \ + "\t.word %c2" "\t# bug_entry::line\n" \ + "\t.word %c3" "\t# bug_entry::flags\n" \ + "\t.org 2b+%c4\n" \ ".popsection\n" \ extra \ - : : "i" (__FILE__), "i" (__LINE__), \ + : : "i" (__FILE__), "i" (__BUG_FUNC), "i" (__LINE__),\ "i" (flags), \ "i" (sizeof(struct bug_entry))); \ } while (0) @@ -80,7 +90,8 @@ do { \ do { \ __auto_type __flags = BUGFLAG_WARNING|(flags); \ instrumentation_begin(); \ - _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ + if (!IS_SUPPRESSED_WARNING(__func__)) \ + _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ instrumentation_end(); \ } while (0) From patchwork Tue Mar 12 17:03:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590548 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 E74A4C54E58 for ; Tue, 12 Mar 2024 19:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aLYvn2RV7TNrNEF9LkDxYUeUVsvapsA/qzJYLRd4qh8=; b=X3wQl5icullRXv hFfiM2UpkDgecZ/Vq45B3RMJryuPbzgqpd+1kOHYVg1HdILNX3kTtXHqOflnrYXbZ+Q9AUcZBcCU1 6az3acTWNGuF5qNSEvZEGfFaauaJMltZeFUJsKxma3RRSaMHbD40j5OWDUEzTj118Zj5eBsA7gUK7 ZLvuvoamD2OdGOrGnyGeDccLoUy8iTJYGNf3ooayII3bp7TD73VWThKiQm8T9OOXw/+PLdLq0P5Ze ZyUnNaFfcXP/DAknidjS5DFXOuflyaZWVSDCuLoPvRYN+NqcOn/+TEP5KNEz3pKfIZ6iv/YkCNuzE IwwCkeVKeu6uBoNRcTAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk7qV-00000007IDh-03hB; Tue, 12 Mar 2024 19:31:31 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XN-00000006iot-1B35; Tue, 12 Mar 2024 17:03:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=mgfFEM0oJIh4ATTR993DWw0sPyKQH24EY/4/QOUPczo=; b=L2yDXwezvXsa7i/RJTCOhhmJcW 7g+dt2Ct745cD+C7ibdYRA06tWMqRpmQO2iSfrI8oPBY67u+6lfgWZPoOL2796qMyWifKbAxTETaj OVo88WdBsHmoaNHk4Ux+lemxVuo3zrWHJt08XmdtJgUe4SxaD2ka0qsMg+dOZVUl5XuHfJWpAocrF pXRWdNx7GvZJuBu0mZGA+EM/rLRClRfo2WFbrQUuZ/lTIhv3313hPXN2zwKYFUkud5au3kv+VWsUo ZLDXuGdj//HXC+SlVOuRTlVhS8His0eRShphMAIvUwZHClupNj6NrLTr99VOCOh2Kswp+SWdSFOSz aOgiFleA==; Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XJ-00000009YeB-35AV; Tue, 12 Mar 2024 17:03:35 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6e5dddd3b95so31874b3a.1; Tue, 12 Mar 2024 10:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263012; x=1710867812; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=mgfFEM0oJIh4ATTR993DWw0sPyKQH24EY/4/QOUPczo=; b=gqoW2xs7xdgcOIJSq5iqOPUdHx8T/wyxjZ+VKCDff+iScnq9MmqrMhfl8bl8G3YWb2 aLL6bKTP95f3bt2Ui0NxjaWufL7j/7gDMY/LtmCvBp0zbIqQbzJxaqSqvevJ+/tvtZMv Fo3PMoeci1Q0sKlJUjh3W0GzyNx5ciYCzcH8wLNbV3xgEku2cxWKjAYP/1uzjA556u6n 1trd14TAV6XA7VE2iA6KHpffe6Z8cAE16jN0bnyPgSg73IxGKNGM5MpRxBohfIdf3/2E Th3Cl4KaFRCVvu7ZakYQRiFlBLZRVZWmHyO/xZLHpcDRzfuk3wK1GizO+a6WbPWMg/Mn +W9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263012; x=1710867812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mgfFEM0oJIh4ATTR993DWw0sPyKQH24EY/4/QOUPczo=; b=r5wGCp9wnsmTtVhWid8Qczkpq15I0eUmiCiAEjwVxwe+qgpnhfBP36HLsqt5My05cm B+3TGv6J18MQQGk4U36HmqDLsYsF6f/RmUKQcHt/ZJ6SxJdpiYsOoQQ8QWeTM/dkEZSr ravuykOusJaM/IgkpVf2Y6YcWQWIPa+/a2s39FYt7FEfp4sYBGwjn9wxZ4Gcv79bZoCH rLQzYaMEAarLbYRfbuhir9EZrMgWsimiSOHj1nb3Ffi4RFy0RSzJgzyciuzXBKGqW01/ Q+QCDGCLHb6X8wDexT1ptq7qTjN6ePUJ8cblzUeNQyvVvpBPURuCxG1Np7Zw4Dl3hQiV 2zAA== X-Forwarded-Encrypted: i=1; AJvYcCWmvEMwielpnNkjFFmpd7cEp5jEB3yaiwy5TL8eJ/8CZGxzAKSiUcuQX3Qan+83sWDjd6XWzHvHm/zAQNnj5VgekNVwiaRFOIdKquy6xZT6T4ZpD9RR+rdJvXvFf27Ixb7F/ziqHu7rUfhcRNOO4xT2a+VqRXM= X-Gm-Message-State: AOJu0YwJPI8buH1zmynaq+ptKFL+sifWnzIna8syrjNUe8JWU5LbPli9 XNbLSg5kPa/ZPtaDCetmhoVphDVpQWr+dqtUfWK+1jdupTPuf7xf X-Google-Smtp-Source: AGHT+IFq2CL0ds18qlKLUiBCru+tEydVmq2O3jl6A2X5cUl3NOOBJhsozkjJ4JcvCmlm7vgxw0hJ7g== X-Received: by 2002:a05:6a00:3a0c:b0:6e6:96cb:3ab8 with SMTP id fj12-20020a056a003a0c00b006e696cb3ab8mr29726pfb.10.1710263011492; Tue, 12 Mar 2024 10:03:31 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 29-20020a63125d000000b005dc98d9114bsm6228742pgs.43.2024.03.12.10.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:30 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 08/14] arm64: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:03 -0700 Message-Id: <20240312170309.2546362-9-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_170333_904706_1AFA1BB2 X-CRM114-Status: GOOD ( 13.64 ) 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 Add name of functions triggering warning backtraces to the __bug_table object section to enable support for suppressing WARNING backtraces. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Signed-off-by: Guenter Roeck --- arch/arm64/include/asm/asm-bug.h | 29 +++++++++++++++++++---------- arch/arm64/include/asm/bug.h | 8 +++++++- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/asm-bug.h b/arch/arm64/include/asm/asm-bug.h index c762038ba400..6884089a7191 100644 --- a/arch/arm64/include/asm/asm-bug.h +++ b/arch/arm64/include/asm/asm-bug.h @@ -8,36 +8,45 @@ #include #ifdef CONFIG_DEBUG_BUGVERBOSE -#define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line) -#define __BUGVERBOSE_LOCATION(file, line) \ + +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR(func) .long func - .; +#else +# define __BUG_FUNC_PTR(func) +#endif + +#define _BUGVERBOSE_LOCATION(file, func, line) __BUGVERBOSE_LOCATION(file, func, line) +#define __BUGVERBOSE_LOCATION(file, func, line) \ .pushsection .rodata.str,"aMS",@progbits,1; \ 14472: .string file; \ .popsection; \ \ .long 14472b - .; \ + __BUG_FUNC_PTR(func) \ .short line; #else -#define _BUGVERBOSE_LOCATION(file, line) +#define _BUGVERBOSE_LOCATION(file, func, line) #endif #ifdef CONFIG_GENERIC_BUG -#define __BUG_ENTRY(flags) \ +#define __BUG_ENTRY(flags, func) \ .pushsection __bug_table,"aw"; \ .align 2; \ 14470: .long 14471f - .; \ -_BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ - .short flags; \ +_BUGVERBOSE_LOCATION(__FILE__, func, __LINE__) \ + .short flags; \ .popsection; \ 14471: #else -#define __BUG_ENTRY(flags) +#define __BUG_ENTRY(flags, func) #endif -#define ASM_BUG_FLAGS(flags) \ - __BUG_ENTRY(flags) \ +#define ASM_BUG_FLAGS(flags, func) \ + __BUG_ENTRY(flags, func) \ brk BUG_BRK_IMM -#define ASM_BUG() ASM_BUG_FLAGS(0) +#define ASM_BUG() ASM_BUG_FLAGS(0, .) #endif /* __ASM_ASM_BUG_H */ diff --git a/arch/arm64/include/asm/bug.h b/arch/arm64/include/asm/bug.h index 28be048db3f6..044c5e24a17d 100644 --- a/arch/arm64/include/asm/bug.h +++ b/arch/arm64/include/asm/bug.h @@ -11,8 +11,14 @@ #include +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif + #define __BUG_FLAGS(flags) \ - asm volatile (__stringify(ASM_BUG_FLAGS(flags))); + asm volatile (__stringify(ASM_BUG_FLAGS(flags, %c0)) : : "i" (__BUG_FUNC)); #define BUG() do { \ __BUG_FLAGS(0); \ From patchwork Tue Mar 12 17:03:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590407 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 44FC8C54E5D for ; Tue, 12 Mar 2024 17:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4Rm2lxgrU5alPs1H/2lZqqCLncZEPXWeSYtCKXUk4PA=; b=0aze8jhfFGP3Ee VoLQtdPp2bQ7tPfI/+KPq24KzoIzCPASx0lVnOv/aShSbVnt5ZrAd3UX7K4L3O3RQ5CzJqUNZnS3V G8P+9J1QmH3dGhiRrREPHKEui9of0XEb5Mosms7g7KAxC69f6VgDiGl+UfANI7eiinPzCGHDlgdEJ lEe2qfSwCbgP4exZ4e1CWn15Izc5Xh/A2amL7bISdFb6e18V/whkwCR+UbqB3HLI6/BJKnFeCRBrU d1QS7cJa5vVe2gMA9+uGJCKldTbW1MWaclmOX80y4Skjnj5w/yP3M934CDOn8ZHY65V1aUp82Q74w kc+SOpGXODKN39LStO+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5Y5-00000006jPj-2ys2; Tue, 12 Mar 2024 17:04:21 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XP-00000006iqi-0rl2; Tue, 12 Mar 2024 17:03:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=QaoPploMqkrEWkpIzUU4wfevhj/fOj8xGNuIym5RM4g=; b=a7RG6WvFH9bB152C9gr8eZpnwf tJBVrJUUxkLWwnSqmj3+Y6EfvGsgnnHBLA5Ynx8FFJShqTnbdays7rg0KfeT41amauaCk6jwAtD+P 9B+whHq8ogwfKCXikLcq6PzQJeHzW73fjMbOoCvl3wvJB1QcB88D8/az+NKqRiaCsSTU0r2PD1lND R4bc5iUeqXbTdNaWnjEVvcbeJfcGczKpQPOTbcMtL43wp00UjRQMcPbjrCMN1OdumjRMefUmXPmDB FvZAdmrFELFWkeY93BvOix2O/MjroTfvPg1BytBS2gyhdfAnmzz3yr5B9Dvsp7UxxzH3pO6YxdGhN 65EElhtQ==; Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XL-00000009YeW-492L; Tue, 12 Mar 2024 17:03:37 +0000 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-29c52a90417so23563a91.1; Tue, 12 Mar 2024 10:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263014; x=1710867814; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=QaoPploMqkrEWkpIzUU4wfevhj/fOj8xGNuIym5RM4g=; b=BXcNxl3gYXKtKWClxdMgOqP6v86ZL8Es1En6eDzUq8Ifi0c7G4JtJRn2g+yh8OfrWH r7ThDKWxiXffy6qdOZzQRVRCndZKzL1UpQITGG4muhx5raJGDINEYXJSfCwWCpJvixX+ y80l84QUGOVs5Mm1GjD9zFwAIcA/oldq/nRqx4dehb39LUj8+lU2GqAROZUZgGhmXvX2 oepy2MaNlBxaVo/Nc30UyfHYtwL1pEeEx67ghAMbYSt3raS6/CYX1whBG2uWl70UWYQO Br4ieaIdnhGp0TuDT6G/a5nva0nCGZwib3SeGK/8u4LWYA8WZ3aoa6d8Eg34qOLDQ7YF Twyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263014; x=1710867814; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=QaoPploMqkrEWkpIzUU4wfevhj/fOj8xGNuIym5RM4g=; b=xD7lJ6olTIc48GEE5YYZG/BiNc+JDZgL7L9vk1568/QDtTyxvfIz/WpcO3O+v49/NQ 6Oz//X2T0+hQYS8FaJlFxekdIzVBhurIy9+2CWNVpf++YE1+5QdTwKfSxrjnTAE95Kxh 67xxDjTQWy7DIqPa3Lcrxc/k0J7D/9Ja415oV2wssdi1GOAyJbC1KsHmqr7wqAIt8Wri cq/5wb5vRZKuH4FSQirBsbxlbdPZh7d0ajrsdz/q2kmC6xja73CpJK3xkYNsdDhfQYx+ LvanI+35MPNmwI4JscWGbSZhZfOvAIRIgxyQ43XTHQUDjL/LCY+bbTVMCYs4ua2mqQxS n0rg== X-Forwarded-Encrypted: i=1; AJvYcCUbTScrpjZIaSWjdBHxxdnfnw20r6e/GFgDhlHPHpApEC1AuL3d9nEuSnz/k/37XFvTseLvwTXoH6GMWCuEsowjyXNSkZ/GBlG0pP8oK2ip4FnnjYhF0dPUtz/aKR/lZELTiPRKEijvB1PY93e6ejnWoh0FTTQ= X-Gm-Message-State: AOJu0YwASymgdM09gUIY0PrAE3eVHhs7nu7O/Zuyp2s5W8EtKbAzaREG FQBAO9PMa4v++a2hQuAm1Evyy/ubSi64QemUw+fqltsMc/gIy0vO X-Google-Smtp-Source: AGHT+IGp1mJ0KTZ+LQYMSXPX4xCWLkAXoeTNJUTBRzyrNk3iCGaW03oMbFoz7IlCFWta+THFx92xXA== X-Received: by 2002:a17:90a:e514:b0:29a:9dd1:d45b with SMTP id t20-20020a17090ae51400b0029a9dd1d45bmr194372pjy.3.1710263013769; Tue, 12 Mar 2024 10:03:33 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e11-20020a17090a77cb00b0029bf32b524esm4052208pjs.13.2024.03.12.10.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:32 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 09/14] loongarch: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:04 -0700 Message-Id: <20240312170309.2546362-10-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_170336_155982_6E6FFCC4 X-CRM114-Status: GOOD ( 13.39 ) 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 Add name of functions triggering warning backtraces to the __bug_table object section to enable support for suppressing WARNING backtraces. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Signed-off-by: Guenter Roeck --- arch/loongarch/include/asm/bug.h | 38 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/arch/loongarch/include/asm/bug.h b/arch/loongarch/include/asm/bug.h index d4ca3ba25418..25f2b5ae7702 100644 --- a/arch/loongarch/include/asm/bug.h +++ b/arch/loongarch/include/asm/bug.h @@ -3,47 +3,63 @@ #define __ASM_BUG_H #include +#include #include #ifndef CONFIG_DEBUG_BUGVERBOSE -#define _BUGVERBOSE_LOCATION(file, line) +#define _BUGVERBOSE_LOCATION(file, func, line) #else -#define __BUGVERBOSE_LOCATION(file, line) \ +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR(func) .long func - .; +#else +# define __BUG_FUNC_PTR(func) +#endif + +#define __BUGVERBOSE_LOCATION(file, func, line) \ .pushsection .rodata.str, "aMS", @progbits, 1; \ 10002: .string file; \ .popsection; \ \ .long 10002b - .; \ + __BUG_FUNC_PTR(func) \ .short line; -#define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line) +#define _BUGVERBOSE_LOCATION(file, func, line) __BUGVERBOSE_LOCATION(file, func, line) #endif #ifndef CONFIG_GENERIC_BUG -#define __BUG_ENTRY(flags) +#define __BUG_ENTRY(flags, func) #else -#define __BUG_ENTRY(flags) \ +#define __BUG_ENTRY(flags, func) \ .pushsection __bug_table, "aw"; \ .align 2; \ 10000: .long 10001f - .; \ - _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ + _BUGVERBOSE_LOCATION(__FILE__, func, __LINE__) \ .short flags; \ .popsection; \ 10001: #endif -#define ASM_BUG_FLAGS(flags) \ - __BUG_ENTRY(flags) \ +#define ASM_BUG_FLAGS(flags, func) \ + __BUG_ENTRY(flags, func) \ break BRK_BUG -#define ASM_BUG() ASM_BUG_FLAGS(0) +#define ASM_BUG() ASM_BUG_FLAGS(0, .) + +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif #define __BUG_FLAGS(flags) \ - asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags))); + asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags, %0)) : : "i" (__BUG_FUNC)); #define __WARN_FLAGS(flags) \ do { \ instrumentation_begin(); \ - __BUG_FLAGS(BUGFLAG_WARNING|(flags)); \ + if (!IS_SUPPRESSED_WARNING(__func__)) \ + __BUG_FLAGS(BUGFLAG_WARNING|(flags)); \ instrumentation_end(); \ } while (0) From patchwork Tue Mar 12 17:03:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590408 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 2C920C54E5D for ; Tue, 12 Mar 2024 17:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YbJQxQonmiYywcgqEM/SeYMu0tJVPu8Fvjtc3YTt6y0=; b=WSQvDgFbWAkxUU Io5D+LdSb/hebSC6JC+LQblnVdEybKAJmgOZGWzg2e5oajpCkdyglfPQEbOGH/ZxpewJG16yvrEAi H1CfcD93Ak6GYqNbrhWFqKc05ZLSJd5GHk2UvbF5GRjy//y03UVKFBEjoMa1eFQyYQQTbYmlZFHCp nYHl0IO2wAfMCRn+rpCXvC9weYxQX6uIgauA8oZoMlvSvvImB5oAxUUcoPDqIB0DPjfSMZqzTXmDz hfgJ6KlyEZZG/66++jVIAalged7a1YD/NiouEbi1NJaAxelo7mo8h4TZvcEp9Nf+RuIxvoAab2ecL 43FjXTJWwgp5XvgaAzxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5YF-00000006jYO-2yfX; Tue, 12 Mar 2024 17:04:31 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XT-00000006iuR-0QUm; Tue, 12 Mar 2024 17:03:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=8yPqiFdiMaUo8CT/x9a2ZlbShLK74ZzL6qnaxWOIrD0=; b=Pz3eZG19Kg5XQ7JRC8YEnCSHrq BGmuC7ff+NrBhdKoI2KPVr6SqnvUauJChtY2yd5hHayafYLgSWAeyyfFLJYnhBWmDViIsNCEz6f17 R+0gbDOkPYqB40gAn+ebAHN/UMx4Q/EtGDkhv8ixG+nyqmHSvNlMh2dD1Quz8WP/FWVaUE5E4h/1S jfDKpuJWKJabQaVf4snJueZHbeGxwrARxphuaT38/Yr5byNOTMrddFP2tUH2xvKuwXEe1xj9GRf5G 5xKxrYlCblFqe50uSMQnJ9kJQWKagnHLibg0nvC0usH8u+44yoQf9+gN9SNjcu0OYnWNUdxnq4n6J eq/zvrug==; Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XP-00000009Yf2-1HWd; Tue, 12 Mar 2024 17:03:41 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1dd68d4cff1so32065325ad.2; Tue, 12 Mar 2024 10:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263016; x=1710867816; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=8yPqiFdiMaUo8CT/x9a2ZlbShLK74ZzL6qnaxWOIrD0=; b=azDUqEIJmsd02QTbqAxWbDkAm+ZZqXvhg5+6G7XLKfe2Kck93sA04cyQlQur0rrjLu VgbriKSxcrULDQvBzuX973E54UVM4/93MzQemJW5eHIPpyw9x73IiB9T+bhTU5Yw5M3z 9fcB9QiSK+DKIXzsAG0Gu26UU2/1TFNv3TxDys/ul4QmY30VRYkuk118M1DYsiWqYf6R 4s1BW2qINL2R7jGDtbU260EQUgpqwKK9bZC7yY4AFE8OepKPDnSdA9stsaU19m8tWyxt iQjC9Zk4P1ab9HBSxxgCg3APotrxOCA7GQqAxChzqr1T++EDsFAX6JYbTWSjJ//Ee1Vr xp1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263016; x=1710867816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8yPqiFdiMaUo8CT/x9a2ZlbShLK74ZzL6qnaxWOIrD0=; b=KWPNDyTYIBYRG+m/VCzbrrFYhxbMrhme9P2rhBpGnC3z3/KKLgNLAByMKBW8bS/8+5 4QfFNNnZL/IJD4ySTvP05mE3U5ZGTfRlX/hL6Tgh2svDQZCZzciieu/6Nuow/f6qGxLU EBawpx2TyYWft3wUbXYG8/zdxNEdnoy/OosuSMuim8uU7WkAPeQGNy0hJmErMpbYPgOe u3ksCzekcOcL7A9yTehnGdtNpzLBm0Oa3x3x1+iykrKdlvgcmUi5+EIRaDDAJrMc2+m2 cSg3Z1g++q8oPUrd+tVlidI/ADpdIphoMzC+tu2ZQlEH92kc8VMXWOWVTYzUZBj/Ykni uPqQ== X-Forwarded-Encrypted: i=1; AJvYcCW04s8b5cOs+GvC3iIo9GGiNgaVrQiKejycD1jkQeK44CbNrG2i/5qZn6fH89NK1H2gGZzaUdt4BCFDFPUL9Wdz9shLiusFxJYfFLePX3OBGVgudqzfjNC+tG1Va5e2+OeJkKoD2wKgCI8ZRi/uRXf+qlzGg8w= X-Gm-Message-State: AOJu0YzhUD3Q/P+FPBbNm8KfBO/v0B1vuB2Mo/tEu6hLiyCcHekVyPNJ Pz5GLX/Kq35wS935uHbP1DP7hfJzMniFJFWA6E5MdHCbxBntdSpo X-Google-Smtp-Source: AGHT+IFoEsNPPrMLHPvnKMDpnnejQqa8I+dYMyPxL8EBJ4sDwkePMFxEwmxbDBpOVTaOpj6jJj/c1w== X-Received: by 2002:a17:903:2349:b0:1dd:afc9:a34f with SMTP id c9-20020a170903234900b001ddafc9a34fmr4471610plh.50.1710263016146; Tue, 12 Mar 2024 10:03:36 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b21-20020a170902ed1500b001d9a42f6183sm6958877pld.45.2024.03.12.10.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:35 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 10/14] parisc: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:05 -0700 Message-Id: <20240312170309.2546362-11-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_170339_806047_523C7299 X-CRM114-Status: GOOD ( 11.63 ) 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 Add name of functions triggering warning backtraces to the __bug_table object section to enable support for suppressing WARNING backtraces. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). While at it, declare assembler parameters as constants where possible. Refine .blockz instructions to calculate the necessary padding instead of using fixed values. Signed-off-by: Guenter Roeck Acked-by: Helge Deller --- arch/parisc/include/asm/bug.h | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/arch/parisc/include/asm/bug.h b/arch/parisc/include/asm/bug.h index 833555f74ffa..792dacc2a653 100644 --- a/arch/parisc/include/asm/bug.h +++ b/arch/parisc/include/asm/bug.h @@ -23,8 +23,17 @@ # define __BUG_REL(val) ".word " __stringify(val) #endif - #ifdef CONFIG_DEBUG_BUGVERBOSE + +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%c1) +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC_PTR +# define __BUG_FUNC NULL +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define BUG() \ do { \ asm volatile("\n" \ @@ -33,10 +42,12 @@ "\t.align 4\n" \ "2:\t" __BUG_REL(1b) "\n" \ "\t" __BUG_REL(%c0) "\n" \ - "\t.short %1, %2\n" \ - "\t.blockz %3-2*4-2*2\n" \ + "\t" __BUG_FUNC_PTR "\n" \ + "\t.short %c2, %c3\n" \ + "\t.blockz %c4-(.-2b)\n" \ "\t.popsection" \ - : : "i" (__FILE__), "i" (__LINE__), \ + : : "i" (__FILE__), "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (0), "i" (sizeof(struct bug_entry)) ); \ unreachable(); \ } while(0) @@ -58,10 +69,12 @@ "\t.align 4\n" \ "2:\t" __BUG_REL(1b) "\n" \ "\t" __BUG_REL(%c0) "\n" \ - "\t.short %1, %2\n" \ - "\t.blockz %3-2*4-2*2\n" \ + "\t" __BUG_FUNC_PTR "\n" \ + "\t.short %c2, %3\n" \ + "\t.blockz %c4-(.-2b)\n" \ "\t.popsection" \ - : : "i" (__FILE__), "i" (__LINE__), \ + : : "i" (__FILE__), "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (BUGFLAG_WARNING|(flags)), \ "i" (sizeof(struct bug_entry)) ); \ } while(0) @@ -74,7 +87,7 @@ "\t.align 4\n" \ "2:\t" __BUG_REL(1b) "\n" \ "\t.short %0\n" \ - "\t.blockz %1-4-2\n" \ + "\t.blockz %c1-(.-2b)\n" \ "\t.popsection" \ : : "i" (BUGFLAG_WARNING|(flags)), \ "i" (sizeof(struct bug_entry)) ); \ From patchwork Tue Mar 12 17:03:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590549 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 4AF95C54E66 for ; Tue, 12 Mar 2024 19:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YbvJ8zVltlWlsC1AkGSbR3Of1kIF3ETtsZXCCTuAX3k=; b=zFPO5o328ylTxL kn99TfhfUhZ2KlrdWjihmxBMYqN8v4Z9xbQe+W2fdWCkWbTuMg5dSTP19eFGGHu1HI3IzjIEBjFcP m+kNZ2PTXnrjiaDuWWXYz3NSQk/GaqNo3en0UX858GAlshgWFm2BBBGx+3vO3Ad8NRPRTyI+c73qR 1OvweigE592or/PFM2WeXEGtrHuv3F8fT86TzdVFzTaiVcy+jciEWvdL+NJDbxC9sUnFcAOqHhKZF x54fHQgWsd9bx9l5jQ6E52jDb0ffc6xnmp4/eBfgnB3lY8NMUDJ9u/hrTXUyaaGYuIkpL3xO61Feq 78ln76WBDjlH8nQUZ4qg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk7qV-00000007IE7-2kEW; Tue, 12 Mar 2024 19:31:31 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XU-00000006iwc-3C7E; Tue, 12 Mar 2024 17:03:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=UNfBGF7ZRB5gRY5ju3ZTnVyluuI6d4pIMWMvwwDFCuc=; b=JgKRMqWIw32269Y6KBgK4ZpUpJ C2Z0P3CnOfKqVBHS6nRkx9IOuskpQkVHTm4+pHhw8eGlkPdidM2F0Vm26bxNxqs7Y2qKQJUaW4W65 EhH2AoQY3oCcIBhxHhOxbOpP9Gz53TTjbs1TY+HDQ6rmq6lxPZgCMIu3bg88QENRVA0r6x7bISFc9 MyFhnHUlTSHvdmIBJaQuTkIOLu6fuaaIhyJ6/6TElnVWVi4XhPxrfDdX073vPa1goYPOAgU02Z0Ls 7KukknjLwXRVT9LWholUmJ/lSdtLPfS+PgIc/KdMfriehovDFW0TWCzSz+hSc1Ks2cfdtIJQ+TiKp 7zmTrWEQ==; Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XQ-00000009Yfh-3UU9; Tue, 12 Mar 2024 17:03:43 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1dc1ff3ba1aso958285ad.3; Tue, 12 Mar 2024 10:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263019; x=1710867819; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=UNfBGF7ZRB5gRY5ju3ZTnVyluuI6d4pIMWMvwwDFCuc=; b=FC3fMRgreRmeb1TrfxZMEVWrYqiqmZ9lFg2GhZuoGnMJSYIUayW9MjVgARsD+witAv FC8PDooH10P4AY2B6d8FVMhgXZ8Jwxb0+qdfQtOHEMAi4riNxnUWX4XKlIJ9WO1g8rdr Bf+Kqx7trYLyPrwCZm2/YhErAwolT72ACMRRVGPsPBwBhVottq85LU+6ormAG7xDy7Ht hJABVPso4qS32Ga/VubAcgVxhNxkExnLvbZVNdjuDwupRSkd/Lgx1/JtLjJQXIorXH1w VWrUU4ftmuMaCoPphFHs+8bkXeimVkzO37pHNWQPhyToSEzeWC/RyXQaOtcQx9YBE3Vh 5uPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263019; x=1710867819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UNfBGF7ZRB5gRY5ju3ZTnVyluuI6d4pIMWMvwwDFCuc=; b=XO0Q5y77RnG3G7aJTGTNMV/DMYWuxEBsUVt/CQDab62dA0FMvieEKjzL/BpZ5mTUum qmo7JmJBBlhLgTn06wUcRS8COBFkiVk/zGdPcWB5244TXXOXMzylj8HV6jDwI8DTvCJl C3hQeR6d9nnD4wqvx88a2rRNxrCaOLs8VEtiWnOSjRdVXU/rbETX3MT4CcN4RGn6e8Lf p059926YM9zYpYn9N70YrNOhI1/W8cw2OlXeM82zhwUuAxLtlhP26PtZ02mqy72LOfxq h+Vtz899BByVnljwz8ZzLe6aYc8GHch8FH12LSn62KngN6UtYXpuHTECTN0H5zr7WIsV u9bA== X-Forwarded-Encrypted: i=1; AJvYcCUfoj3rG261+hF5ZwkVXn7HRZFeOfB78v7viDlXwTdYr5vh2FGmGj1YZn1DVlEs0siOd9Mz3Y3aWzJOzpjhl3bYqx5D7Q6kraRtzlqqQh6C09DzzF0ijv6FER5qyo1k0rPeMZ13o4h8sxh1mCeADMbw1ScQOhU= X-Gm-Message-State: AOJu0YxASoKOHDAgbVTb2Evk8KlzxIrXNbsCeSSbI9wn3pXQ0Rdd5FJj 1VGjVigsLv+/o4G36C2v6JbtBWueWETk1JOObvWJEHylcakuR5sk X-Google-Smtp-Source: AGHT+IGjcPO5G+GnCGVDj4Jcw0R4zzS4LNLUn52exaX20Pa+MrIRq7GoxtzdXir/jkag847FtE7VIQ== X-Received: by 2002:a17:902:cec8:b0:1dd:7d6a:de4f with SMTP id d8-20020a170902cec800b001dd7d6ade4fmr939106plg.2.1710263018703; Tue, 12 Mar 2024 10:03:38 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k17-20020a170902c41100b001d9edac54b1sm6398555plk.171.2024.03.12.10.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:38 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 11/14] s390: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:06 -0700 Message-Id: <20240312170309.2546362-12-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_170341_000691_03BF65CC X-CRM114-Status: GOOD ( 11.36 ) 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 Add name of functions triggering warning backtraces to the __bug_table object section to enable support for suppressing WARNING backtraces. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Signed-off-by: Guenter Roeck --- arch/s390/include/asm/bug.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h index aebe1e22c7be..01e2aa4069d7 100644 --- a/arch/s390/include/asm/bug.h +++ b/arch/s390/include/asm/bug.h @@ -8,19 +8,30 @@ #ifdef CONFIG_DEBUG_BUGVERBOSE +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR " .long %0-.\n" +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC_PTR +# define __BUG_FUNC NULL +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define __EMIT_BUG(x) do { \ asm_inline volatile( \ "0: mc 0,0\n" \ ".section .rodata.str,\"aMS\",@progbits,1\n" \ "1: .asciz \""__FILE__"\"\n" \ ".previous\n" \ - ".section __bug_table,\"awM\",@progbits,%2\n" \ + ".section __bug_table,\"awM\",@progbits,%3\n" \ "2: .long 0b-.\n" \ " .long 1b-.\n" \ - " .short %0,%1\n" \ - " .org 2b+%2\n" \ + __BUG_FUNC_PTR \ + " .short %1,%2\n" \ + " .org 2b+%3\n" \ ".previous\n" \ - : : "i" (__LINE__), \ + : : "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (x), \ "i" (sizeof(struct bug_entry))); \ } while (0) From patchwork Tue Mar 12 17:03:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590551 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 3B7BCC54E58 for ; Tue, 12 Mar 2024 19:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l8IYJXCu3rZJI6pUSlkE0cQdw6EaA+uu61LiEhjNgNU=; b=Ayzf3DpA7C4Lz4 06SduZ0Ao6j8fSrQT4xUbvDRur0ZTBugtuEjRZfGpdNBHQiYz/IKiUzEG2p5RXf3Hr3TEAmfuUNjQ nSeJJ1wPVcX4Wi9MNg4dw3LkvQrTfJ9PLZW3C1V9+KgfULYqQOx7zT+A0wPvtHwDgcrhQZ0fm4q3G w/lj6AZ8mT4DbgdiN1Sn8AsT/R/lX/ZP+BGAsr03GihQII2/O9xVLV6GJustWPAOFXJjWGJJvfFNu Xg+1Uv1NbdZeIheKtB69DyEep7q2ENAACXKDZalKaJvpei/nM7fizwj1AC3L34omMVn0oITZr6wxZ 3zsXc90SDpda65ID8dow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk7qY-00000007IGm-3tmZ; Tue, 12 Mar 2024 19:31:34 +0000 Received: from mail-pf1-f175.google.com ([209.85.210.175]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XT-00000006itp-1Pl4; Tue, 12 Mar 2024 17:03:56 +0000 Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6e62c65865cso4818350b3a.2; Tue, 12 Mar 2024 10:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263021; x=1710867821; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=bXPfnReuSHXGXOVrQxZxvKsOYxRmb4ItarTkuVBwfPs=; b=YnqqgK3MmA4VJ0RTwNwQsYg0L52NRFyNie69JlCW9INqOckwo95AmBGGgUl6GGrDu3 Hgm9K83/Ct5kgLc7+aqzozT8X6FDhsnL8Lll5Qc9GvGI3WOFKVBtVo6mpriNYpehizRv mtQ4irU5/1nmKYhDSr7T3ZNoq3pwOQMEZw+K7OwiOZXfuuI5Po/yhIFBO8vzU9ldP1UR O0cKy3tDmdDHu65pt1qpIR4xb1XAafKki2SAGmG1Y+F5U7vHUwWDREQ0ZfYJdgWnzRzC NNMZgF4HMLHcRAKISQvL3N1v9bUV06C6sJ1oOncVhglvUZ/qnSyLarZGbpisa6tGSCG0 uESA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263021; x=1710867821; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bXPfnReuSHXGXOVrQxZxvKsOYxRmb4ItarTkuVBwfPs=; b=GrY7xfc9GfisARM51noGpxPbkid8cJCnScgdVRHJ22KGPD74AaDWbWehXym4PdfHVo Y6rlBNdVFLqhSul+cFN/n9YR7ERK6bUoyB6g+hr59jpnvO6XHETxhj/cS7c4+jjDnfZO N11SewGvCPtqy1KN8dOxWLObZvBBqLR024ZVEIOylL1Kjdkd7lujfA8R9VZ8OgKUKxhp f3gMZuWv88s+eqMrGON36l2oZP1+06hC166yUP9HBdpwFr+35TFjyRw3KFSEFHKnER0j 9HkG91Pc4E2bzScImmcOGRZ8celwQ3pg8UGNy+ZlCivMbxwQ9NRSMd9Q2WA7HZL6G2DM WDDQ== X-Forwarded-Encrypted: i=1; AJvYcCWPBF6zb+lS4nI4hz4bdUXOaRrZiVPz/Gsrsx1rkb3NYAMiJLfRylg+nDffTZe5Cl+1+xIAF+OTZ+2Lmdm8LzKTCCkUlMm41IV3O4L7wR6xT5Otn3/c+09F+xf9DvBb4aRJvD0BvQ3fD5i5gACrJGpbrJwIO00= X-Gm-Message-State: AOJu0YxYddm+kt7fuD3bSZ+S6iXQMrl152mqe8XaYrUySJhoxwcoHt6S HxLmuvIcwMpGKf70um0qHYq7YmiNBEk2rPSq7tw58nZm0hsbYNKH X-Google-Smtp-Source: AGHT+IE4fVqqJ6hNP2W9YJrC0c7a73CCPEj82DwWsP9/bD/wztKwzROAlQDxzJc7BU6W2bM1RSgz/A== X-Received: by 2002:a05:6a20:9f06:b0:1a2:ba3f:e530 with SMTP id mk6-20020a056a209f0600b001a2ba3fe530mr11544554pzb.50.1710263020818; Tue, 12 Mar 2024 10:03:40 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id g1-20020a056a000b8100b006e674ef94b2sm1453577pfj.159.2024.03.12.10.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:40 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 12/14] sh: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:07 -0700 Message-Id: <20240312170309.2546362-13-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_100343_670769_D1AF6782 X-CRM114-Status: GOOD ( 12.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 Add name of functions triggering warning backtraces to the __bug_table object section to enable support for suppressing WARNING backtraces. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Signed-off-by: Guenter Roeck --- arch/sh/include/asm/bug.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/arch/sh/include/asm/bug.h b/arch/sh/include/asm/bug.h index 05a485c4fabc..cadc335eb759 100644 --- a/arch/sh/include/asm/bug.h +++ b/arch/sh/include/asm/bug.h @@ -24,21 +24,36 @@ * The offending file and line are encoded in the __bug_table section. */ #ifdef CONFIG_DEBUG_BUGVERBOSE + +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR "\t.long %O2\n" +#else +# define __BUG_FUNC_PTR +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define _EMIT_BUG_ENTRY \ "\t.pushsection __bug_table,\"aw\"\n" \ "2:\t.long 1b, %O1\n" \ - "\t.short %O2, %O3\n" \ - "\t.org 2b+%O4\n" \ + __BUG_FUNC_PTR \ + "\t.short %O3, %O4\n" \ + "\t.org 2b+%O5\n" \ "\t.popsection\n" #else #define _EMIT_BUG_ENTRY \ "\t.pushsection __bug_table,\"aw\"\n" \ "2:\t.long 1b\n" \ - "\t.short %O3\n" \ - "\t.org 2b+%O4\n" \ + "\t.short %O4\n" \ + "\t.org 2b+%O5\n" \ "\t.popsection\n" #endif +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif + #define BUG() \ do { \ __asm__ __volatile__ ( \ @@ -47,6 +62,7 @@ do { \ : \ : "n" (TRAPA_BUG_OPCODE), \ "i" (__FILE__), \ + "i" (__BUG_FUNC), \ "i" (__LINE__), "i" (0), \ "i" (sizeof(struct bug_entry))); \ unreachable(); \ @@ -60,6 +76,7 @@ do { \ : \ : "n" (TRAPA_BUG_OPCODE), \ "i" (__FILE__), \ + "i" (__BUG_FUNC), \ "i" (__LINE__), \ "i" (BUGFLAG_WARNING|(flags)), \ "i" (sizeof(struct bug_entry))); \ @@ -85,6 +102,7 @@ do { \ : \ : "n" (TRAPA_BUG_OPCODE), \ "i" (__FILE__), \ + "i" (__BUG_FUNC), \ "i" (__LINE__), \ "i" (BUGFLAG_UNWINDER), \ "i" (sizeof(struct bug_entry))); \ From patchwork Tue Mar 12 17:03:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590550 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 AE598C54E68 for ; Tue, 12 Mar 2024 19:31: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pGzM9AtNPlVIe15LnzTkpwhS3ba5Xe4itrwj9I7kQ8A=; b=D9eDsd0+Y6CQFB RY6EyTISd5eSTfWkEMpb6IfAHRkzsqVmIXeAerhke/eipS+SCqnOMywH6MoW3T6qRBBMtRAc/1KGq SGsKX+au6AilOhqYu162g2mO8uwlQ4oCVA84rABOm/HygbK9HDBsBwcfdYDjp1X+kM6RqMR9bDq9P fvDYwcT7N9r80T03Mp2NBiKU7Jg6oetTDZvBFDK77/rE3wpL0aTzLCEClE5R+8afITE9z8atdJmGX 7+6K/kMDhYpQ1BrFlcg2k+LE6/I4H7sH2DshMqMDTiiTLxQt33c3xz667qifCSBdzLcvSZ4bSeLhN LVQWyD3YXnpNahczlgtQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk7qW-00000007IF0-2ide; Tue, 12 Mar 2024 19:31:32 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XY-00000006izZ-3nmA; Tue, 12 Mar 2024 17:03:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Mb4FmIopiSO+/3QwXjaWJkazatuyJXVbnhhdOwFBf/s=; b=C1C9BSPxYKeWLvPZNE4RXj9sxo sP5t8BUKZAIlDmxLvtGtKGprfGtEXS/brvRIsh8KXYACKL0091BXQ/HGL8ZW5ZJT6oj2tfVajRoU/ d5Xn6tvNxS+FBLAswvYPoICOZhyxCstWrI6XZtZn2HmOlBabBARQ/O35pf9sYb8DSjgFADirfdc9k oPVXE7Hqg+OnEWrpnmweON5yMNM0QKolG4osTM1anRSKvyY4VOS9vyL0DQtP5eTR2YBGQgdMOVLe3 buFqPRLMF+JUMV8fF3cFgVr8hKHrJj+WwTjrhGGIYvBUnEapUk3GhCuLfsYv3MR7DP6LqfTeoIMNe 3Yb6YjHg==; Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XV-00000009YiT-3w8X; Tue, 12 Mar 2024 17:03:47 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1ddbad11823so7183545ad.0; Tue, 12 Mar 2024 10:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263023; x=1710867823; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Mb4FmIopiSO+/3QwXjaWJkazatuyJXVbnhhdOwFBf/s=; b=daMLGT0W93Dr1nG0HbF0X5z4xyEa1++bVHEAN5ajFgOu7VcvXhpTRcA51xQkT4Mhtc YHQcVG3Rp08B+2bFpo5SVkNQCZt9wr4fHURQ4bSAQtaeyxn9omfYw/oVzAJOs0OQzgY6 TA4lDwgt81lhGzxhJ65Q2Ht30gwuSToGOg3YkEHQaMbegh4vLrA7XUGlA0yMpv2K5Pkf 3Cs8Av0O8jkZ+uG7/viIY0QKrgO3aXKPloO1kIgdYemr1XpLYfUjsiTMte+jOt4Rllhg ohCFJ/T+D5DLCGJSfqZ4da+Jfmy8VhOQomFvcxpzoZwqf5NJfBt4MG8+18g5WLsMmue/ 7qpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263024; x=1710867824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Mb4FmIopiSO+/3QwXjaWJkazatuyJXVbnhhdOwFBf/s=; b=TxW68i2CRJei6HP0tNFpffRddw4k3cFlTAzV/KIKv1CGl4VBgDsURXsAEUF+xum3wd fMmB2DCv2gzJGRJsz3flP484VrZNL0CFSk5rWVQmIDliVLeqyVhVxe0vJ6WEsnXSJnTa zf1JzRS4pkpJUFUOrPnJrrPNpktHxLPshwYbF1mJQ6pl7Wj2cRhSPVxvFx/bav16QTAL uboCSNE2ovAhTatHaELWJBmHeA0Q9krjGHHxf1tw0blriTPIDq0leaDsJiHfMo1DGdQP 5Xe39TGwUG1O6p7LhTfx34C4s7TCE2+DMi0GgF2iTiBz+M+1t4rNKoO0wJGdHDyNRWlp Fqsw== X-Forwarded-Encrypted: i=1; AJvYcCWZhLIQyqVRCn7mSBBGBrvzL+Y62WX524gUztQJx40LtQzuB5yXjCeZJ+kmrPYB5M0U3q/izulFyzuP5V3IdR4PveXQ/0qbAeo/7c6/wf1XoEFkp5/Eb/elYFsiWw4S+RXjcc+KPJrk3MiHNpc9rNO1MJo5QtA= X-Gm-Message-State: AOJu0Yz3U2yjIjNIX4eofJB5tCelwIiDxLeOA6oAVKHOI0XC4oM+SxVy EsmOw3r1z92vyNyZSgV+N/N0BSOAg2jGhkEtamFtmyzWdPqv6EdF X-Google-Smtp-Source: AGHT+IESK+W76sbv32507e8vr+AETbi9zHy7dM6LrGga9gr4qnmj+9kyX8nY1a/g+A7cAY64N5ru0w== X-Received: by 2002:a17:902:edd0:b0:1dc:a8aa:3c86 with SMTP id q16-20020a170902edd000b001dca8aa3c86mr9530991plk.5.1710263023689; Tue, 12 Mar 2024 10:03:43 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id w17-20020a170902d11100b001dca68b97d3sm6991774plw.44.2024.03.12.10.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:43 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 13/14] riscv: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:08 -0700 Message-Id: <20240312170309.2546362-14-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_170346_126473_21843BDC X-CRM114-Status: GOOD ( 13.09 ) 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 Add name of functions triggering warning backtraces to the __bug_table object section to enable support for suppressing WARNING backtraces. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). To simplify the implementation, unify the __BUG_ENTRY_ADDR and __BUG_ENTRY_FILE macros into a single macro named __BUG_REL() which takes the address, file, or function reference as parameter. Signed-off-by: Guenter Roeck --- arch/riscv/include/asm/bug.h | 38 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h index 1aaea81fb141..8955ee5c1c27 100644 --- a/arch/riscv/include/asm/bug.h +++ b/arch/riscv/include/asm/bug.h @@ -30,26 +30,39 @@ typedef u32 bug_insn_t; #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS -#define __BUG_ENTRY_ADDR RISCV_INT " 1b - ." -#define __BUG_ENTRY_FILE RISCV_INT " %0 - ." +#define __BUG_REL(val) RISCV_INT " " __stringify(val) " - ." #else -#define __BUG_ENTRY_ADDR RISCV_PTR " 1b" -#define __BUG_ENTRY_FILE RISCV_PTR " %0" +#define __BUG_REL(val) RISCV_PTR " " __stringify(val) #endif #ifdef CONFIG_DEBUG_BUGVERBOSE + +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%1) +#else +# define __BUG_FUNC_PTR +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define __BUG_ENTRY \ - __BUG_ENTRY_ADDR "\n\t" \ - __BUG_ENTRY_FILE "\n\t" \ - RISCV_SHORT " %1\n\t" \ - RISCV_SHORT " %2" + __BUG_REL(1b) "\n\t" \ + __BUG_REL(%0) "\n\t" \ + __BUG_FUNC_PTR "\n\t" \ + RISCV_SHORT " %2\n\t" \ + RISCV_SHORT " %3" #else #define __BUG_ENTRY \ - __BUG_ENTRY_ADDR "\n\t" \ - RISCV_SHORT " %2" + __BUG_REL(1b) "\n\t" \ + RISCV_SHORT " %3" #endif #ifdef CONFIG_GENERIC_BUG +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif + #define __BUG_FLAGS(flags) \ do { \ __asm__ __volatile__ ( \ @@ -58,10 +71,11 @@ do { \ ".pushsection __bug_table,\"aw\"\n\t" \ "2:\n\t" \ __BUG_ENTRY "\n\t" \ - ".org 2b + %3\n\t" \ + ".org 2b + %4\n\t" \ ".popsection" \ : \ - : "i" (__FILE__), "i" (__LINE__), \ + : "i" (__FILE__), "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (flags), \ "i" (sizeof(struct bug_entry))); \ } while (0) From patchwork Tue Mar 12 17:03:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13590546 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 265A7C54E69 for ; Tue, 12 Mar 2024 19:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=d9xN2lNukN9+WOZtaHveUUhIgw7cmOG1A/rtEgby7nI=; b=AIzpWU543l9INU zgOaWisZKLqAv+9yiRnYDO7ixhcFI8owOFOa/EzALSENDeoJ6GArkbYAiymYLjJBXK27MKAdio90E QJz74ucDGnMouL69d29aZVadw1qQG/CCfnmsmCZ0L6ZxgGVgPdO5RZwlmPGAWJzQUgVe0lDcVMSGR xCPn9m9NYCAL+AsZBV8H8UenE4sAsGL5KqSf/+1wJ6uLeKhbeXKUBAnWaCMAYevLuJlvvOLOItqFM 0gUfP310k/AloEtBzLwoEg6sUYth8I+K2xqU/VkCpY2RmjbbMJojM+3AJCw0Q4OiNK+LCEj7p0UAM 4KEda+bdlP44vlvAneOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk7qb-00000007IJW-3fK5; Tue, 12 Mar 2024 19:31:37 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk5XY-00000006iyk-1QZO; Tue, 12 Mar 2024 17:03:59 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1dd9568fc51so22813505ad.2; Tue, 12 Mar 2024 10:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263026; x=1710867826; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=f6JeHPuNf2fPfe8/IgMEBFCbi+8s7x8ZP+Ypz6wTBFE=; b=X4CdKql5kCwSqcXSiksaOH0kTonaB+/SdZE35RxxYkzz2vnZMBCZ9xpWP9SUPCcCc/ SvHCHJOFL34CQfDSd+tMd5L80tdHDVyOxNMyFD2TsYp6+nIO1a3DEHijL8QRcBdBLu8M h5qHJkZ9Ik/dD67ry/RvKZdNYKBqcQvJHgENet8J/aqrR8QMTgA2IryCCn0DAkSLAHqW 1PkqKAwQdaUuRf6sqv/it338RWMUxLIZClg+ndwh8hAurNJnpXjxP4aHnVFi+FgVTaLU PNuI6HKM83dV/JdL2a1MVs3a0VqrQzUR/41Iq30Om2pVRuF/cBP5E56uqWlAmeC366ws 4vrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263026; x=1710867826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=f6JeHPuNf2fPfe8/IgMEBFCbi+8s7x8ZP+Ypz6wTBFE=; b=SkYddvKkinUWc9Ud5+1koNVezBs74Hvpm4GgPu/nfgpnHzRvtqF1Y18wmHExsz2Ns+ pjcF29oEFmvfzecKeE/vVueZmlJdYlHD2R68uqw6iWWJVIzpVdFwydDCrGFoQH7EU4GF /M+qZ9vv7KSuUMOjkmE48Za+AqlJdTPnqaTtTLeoND9vhs0wtwvBaLUdFjgvLLo7Bmai 3jCj3MrO7hnEKdqR2nnSIxfrFnvMr8dyyS8nt5/WAYs5AXzmlfGxPn/8oAnSPcoEQX/j bPPGlUKbHXWPJapXZLha7NJ9etzqxrLYKqFlQcm1FKdlnyeqrx/vwK/onPHVjK7vuMrz Z96Q== X-Forwarded-Encrypted: i=1; AJvYcCUPkNtAWnMzYZ5oFNoDyHzKePwmD+tPelRY60VjSvWfa0L7ccB5CprQ1o/ujwMwwJIUgmG/GnS8H6f+RAgWrWOoptUhBsn4MK1meiTIP+XCA92rnNM1v/+hXe1keArgvS9F0/kKZDIcg8P5MRtNjkqLdxY3o6Q= X-Gm-Message-State: AOJu0Yxd1Ql7UI4I5W9MVfftWdwfqc96FHLSTGC49w97wBdalSd/TtpB WD9LvJDqN55ugI7BpPjZmhcdVa64jpw9uLNOPa23wb6+HMUvULXg X-Google-Smtp-Source: AGHT+IFeKRBmX0VW7sv5rUHfZ0tynia7OwMdWO6tHkvskc+E+k+IhaoGejd1DMN70lLMBnMgohEXxQ== X-Received: by 2002:a17:903:483:b0:1dc:fba1:1522 with SMTP id jj3-20020a170903048300b001dcfba11522mr6685263plb.41.1710263026027; Tue, 12 Mar 2024 10:03:46 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e10-20020a170902f1ca00b001dd75d4c78csm7006194plc.221.2024.03.12.10.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:44 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@lists.linux.dev, Guenter Roeck Subject: [PATCH 14/14] powerpc: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:09 -0700 Message-Id: <20240312170309.2546362-15-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_100348_666779_B6F56D5D X-CRM114-Status: GOOD ( 12.78 ) 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 Add name of functions triggering warning backtraces to the __bug_table object section to enable support for suppressing WARNING backtraces. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Signed-off-by: Guenter Roeck --- arch/powerpc/include/asm/bug.h | 37 +++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h index 1db485aacbd9..330d4983f90e 100644 --- a/arch/powerpc/include/asm/bug.h +++ b/arch/powerpc/include/asm/bug.h @@ -14,6 +14,9 @@ .section __bug_table,"aw" 5001: .4byte \addr - . .4byte 5002f - . +#if IS_ENABLED(CONFIG_KUNIT) + .4byte 0 +#endif .short \line, \flags .org 5001b+BUG_ENTRY_SIZE .previous @@ -32,30 +35,46 @@ #endif /* verbose */ #else /* !__ASSEMBLY__ */ -/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and - sizeof(struct bug_entry), respectively */ +/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3,%4 to be FILE, __func__, LINE, flags + and sizeof(struct bug_entry), respectively */ #ifdef CONFIG_DEBUG_BUGVERBOSE + +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR " .4byte %1 - .\n" +#else +# define __BUG_FUNC_PTR +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define _EMIT_BUG_ENTRY \ ".section __bug_table,\"aw\"\n" \ "2: .4byte 1b - .\n" \ " .4byte %0 - .\n" \ - " .short %1, %2\n" \ - ".org 2b+%3\n" \ + __BUG_FUNC_PTR \ + " .short %2, %3\n" \ + ".org 2b+%4\n" \ ".previous\n" #else #define _EMIT_BUG_ENTRY \ ".section __bug_table,\"aw\"\n" \ "2: .4byte 1b - .\n" \ - " .short %2\n" \ - ".org 2b+%3\n" \ + " .short %3\n" \ + ".org 2b+%4\n" \ ".previous\n" #endif +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif + #define BUG_ENTRY(insn, flags, ...) \ __asm__ __volatile__( \ "1: " insn "\n" \ _EMIT_BUG_ENTRY \ - : : "i" (__FILE__), "i" (__LINE__), \ + : : "i" (__FILE__), "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (flags), \ "i" (sizeof(struct bug_entry)), \ ##__VA_ARGS__) @@ -80,7 +99,7 @@ if (x) \ BUG(); \ } else { \ - BUG_ENTRY(PPC_TLNEI " %4, 0", 0, "r" ((__force long)(x))); \ + BUG_ENTRY(PPC_TLNEI " %5, 0", 0, "r" ((__force long)(x))); \ } \ } while (0) @@ -90,7 +109,7 @@ if (__ret_warn_on) \ __WARN(); \ } else { \ - BUG_ENTRY(PPC_TLNEI " %4, 0", \ + BUG_ENTRY(PPC_TLNEI " %5, 0", \ BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \ "r" (__ret_warn_on)); \ } \