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: 13590387 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9A4B137937; Tue, 12 Mar 2024 17:03:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263000; cv=none; b=OWV+BNdrZoR+DrdVJAnZyPSma01vC4+5/0/b2TP/x7gXlLwFJ5Lqd8mcbe3MZhbKL6WK9TKEV6WOrRlOMPGKsEgkh+Qz4zH4WJzqoGzzvOuHssvQ4VdIf/chHH/edGPCBQzXx4h93dgSNUJtlog/PF2OKZIvsGtxW9nSVRQsR4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263000; c=relaxed/simple; bh=/F8eGdrcYtvsHguRnDycepsU2JMIeyRyZpaWMtKZD5A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EmOk8y8BgTMCntw7lT3TJvgYwDiNqqjsQg8QASy+iIDW1Lbf6j3KvxZi7Wu86yrxTv9WxfiBsb8RlhEPwS235gIvgpHJAuXztD65xF4DtVkpfIJVfzs2AxU0wE3SCQ8mHKkgsIpkw6Z62pdNjBX28lnNf+YzWrdSuAoq2E+BB8w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=U6iIXiVO; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U6iIXiVO" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1dd8f7d50c6so474075ad.0; 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=vger.kernel.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=U6iIXiVOLp8W1O1fUFMxQMZknDKEDCDMhBvsGNe8FZilXDE7hGHNgMKJ9DsuhYb9xt FjDUrxxvfv9iKZaaHqXCiy1dcMZ+CMf2PlNcT25HoEexNdEudviqI2X35m1Tuvg40ehy yC91lr8/6XSsmKImSCquoUBZUhhubUTFZ3UKSxC6lKgUD5ttIgfsQzqmV1V1rvEtnvjN Aso01VU+liOw44DPQE57AVKAQJZVpDJjsq2cVMQ8YtJSJRAx4pPJpBAIXaq2FWJvw/w1 5iqa2uya1oT3XRguJK0FqrSAC5lXUmRY3R18tMo7S47wkOxAh3nmblQl9TWHmkcNbU0u jhsA== 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=BLNnXT6/lMFPKxpeQhXlo81CxjPrY1TgHMJI6h2W4hfVrsiBRN4+QDFxiFmgZuJjzg 7iNgMtxFu3yGYRZipjvrN9rWWi+wjKhqpxiAFQ3Ikll938a97iXvACNp/AQMwNuDB5pS zwD07eSbIGWWVXY3kc+VME9pNTaI8ZyCtYzg2Da+TOzLBHo4P4qdBnYHcZQtHoZE/1vk aT4piwrtj73tSt5GeToJw/oURyZxt3hiJz+40jg5l4a1J+TfVSP9x+iWIyHAd+kOn3MU +tjigrL9Lc4JaBtIQ7B6vzb3kFmgCDoad/+evWXkoq60MI465wlFlUfAlyX9YhKZJLah +Teg== X-Forwarded-Encrypted: i=1; AJvYcCWLpnnfZZY+JEntdG8O09p1W3QEZW3mLq9Tpe1mFUxgw1c/vRvcZZWKmYDwdVIhQ67Kmk4xaifAyNGjkUR5o1wFvmHGQbR+yQDIjsk0XJkf1MNg7soMbRCmqkS9sb+4IUcHdJqsewXKFna9brMx79CeRPKycY/gL6LdyB+0Szzwf0ZUchVGUMx0tF7sMKRYml0kC8mqcIcIzLxrRUaediUkHzmzMSgcl4AILfLee1trMK4Nmj4/IbIqsuNKkXsYbSgywUZseezoVWz6sGN6qw2Rv8GivpRyUQ== X-Gm-Message-State: AOJu0YyGKWG7JGK7/IFwUvFvVKMbLDOXl9cejbsSbQErzVVsgVa8YqpM IHdap44PBJB7puacXwAG6klFseMzRZSJkLZhfUrJKpvGA9OWwoWtA76LaymG 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590388 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC1CE1384AC; Tue, 12 Mar 2024 17:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263001; cv=none; b=EqjzEHlAY2ynA/h+8qUQGDTN2XgJUjnsZNvsGoHulAmgVARm+Wd1xDhO5PL+yRC4i4KBjVtI/71yI+FBp1ON69+5yEprx1nVfu2xo+ieyOmKF5psKpZ7clULXe5ggdpMTwfoZDgcw6khDIo1vtzOiPli/L8EakG8JbNQTCfeEdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263001; c=relaxed/simple; bh=Xkzz7frE9nvSTNzSTAYavYlAajmFMh+XRJNWZiXH5+4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NNhQmGWo89gMWNj/QUs2aauGIvcmyQiLADRQ4tdv7Z9m18VYTtxPJcX1BsdIghafgZQFhZyf/pK9TE5jXVoDdVK/XqzMq1HKZrT42u+Iihy8oOIe31Ks5iy6InowoAo0FVHNY3+nPYqMWXwzCzZVjUQ3xi/irBwPh+WQUS3PLwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GA/0s7SR; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GA/0s7SR" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1dc5d0162bcso33490385ad.0; 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=vger.kernel.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=GA/0s7SRT36z2jQRgwBg2/AKRMucGj4NPaEITfEX9DpHpZQqkK57TpbQ3I1bd7jcbL biEMUXVpdMdzOy7KvzvRLRP4dxAbzb5dMjV9X8oiyxfGnX1zKH0lRkOdgfG1cicmGTnE GrRRIuLWWWoRgSlGp+B0P2tCNSWoxUM9M3fn/xbpZMKuiblHkHZMbPuxppUq7tv8LuW/ 6o+e7ert3ZI/7AQPvxg3fkm4bAzie3uEL7YUIxaKBNhe/Tl+gi6RQcZ8P+1iA6wTkjrU BymQNohWv8XnPNISncitpiZUmAlbJtYexeP9UCYwxTJyW7bhXGpCHMW6PFvLnHtXfcbG NaVw== 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=Df3LZsYmn9N75di3xgLXmatD0OcyP4ATqUYhImgYfi4t1VBDK6wjoFj3faInSgoXbQ sKwf6hG1R+3/cPtFPcC7O4/fYIIEwKRpbI2MzukwN56QUBr7YcriKy/ulwaihIPOKcA6 pNnYpotZLy8UrPhhfJKcIWHowxrxz1RIf+bzWYB1WG/wFiRpOEfFl7vhmJLD2x03fgqK C619oajhCl5KIN9+5XLfesVVvXYYZIhvioxaZPK/zys6tGqHqYvn507fdSAKgAGcCUD1 tf92t8WuvDadVa0eh6RS6AVTC7b7fHNpWFu2xqN6aDkaHlTItdMv9kpcd5LaYQ1oHd3h sn1A== X-Forwarded-Encrypted: i=1; AJvYcCUH+KC8RvdLRv+TeUVIIaJ1bIwZOevo5jbWONGntdL7LycleS2UnAcn1uE7cypkiVr38gyba7eJ+R9yr0RxTPd/Zhisuo03bIJ7HKxxhGNdjHw+WWFe+MkSN35jmOsGcJ/LsCtgqa4TrESai7VJGxorMLONH++vQanALZUbV5I41AaDieMpt5ZeDdArxqSOkUw+VIYrAMmQF2YHsPvn3/wnUuw70vfec9bmbWw62zm6NJXI/LK8CUy1mnGU3u0YIbjdttKf/T2dkmb+ByPsK8Ify7yvcOtzgQ== X-Gm-Message-State: AOJu0YxbwBfSC6Enj6+1h1T7/Tx9TwckrroP3l74gO+Z7YzmifVab0rG s0tDR+bz7ltbbzQBlaXXPkD7LbPk7y305PVolCgGtkVeP+LEQabfs/mCXPta 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590389 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09D4B137C28; Tue, 12 Mar 2024 17:03:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263003; cv=none; b=ndDSQFW3dxmDN5FRmM2tGRN2gOD0Ki2BT4iTnsgeiFuMGh7BcDbEPY9GUPEjzv714AaWGtYGiFE5jH32Cy+uIfaqy5rYZF2lsIZpODx7EJt2JfwU1oXurTyGMiFi/U+xQpx/RDFDDIj/+Sp3LfNbWodvKvwyLlkva9tWLL7sJY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263003; c=relaxed/simple; bh=6sNYSIeWjeJasEWjPkKmJrJOPHHuw7n+sDWqcd32API=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VoPnidiaUPmkT0BE2zFYpx2wrX6UOITT4/vEgOv8HhsFf0fyrZmkdq4JFB2im9LYVej5koHKjQQ6+S+lGVP8IEfF4OE/l4cOJKwsqFHrxoIaRfMjZIIMpDSQKXFpV4Xcl3W7aXmiZ+gP+t48IWidWdBr/17UJ8n6SEnNZsH7QSQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hIxEPtvV; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hIxEPtvV" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6e622b46f45so3449441b3a.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=vger.kernel.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=hIxEPtvVCrxqUlyuA3CHzu8qlTZn1/iRuh+92+0gCYs2kwxBXc3ojGWjbmYql6QM2+ Yzt2zsIVE1pn4z3XxfdDTaSVju75fniSexX/65FAeqJul/CHhyRMTFACezGmsytY5zju H5lK3tDXwwOacy3w4nIX1GZMK234mVeONb41UCo6D4GyqA6tilLYeSr2g8eFgwFIu0cm 5RD9GvMYercy2Z2iuF/8b0veGXd0XqV2FqivCv9yze1jpX3Vw5Ih3jDbvTVyyEMfroxW wIXjzncNg6srpBbhUBFY/JV7ALcbkdbF91gCcRLhH8WfmcpoqHD+8vn0zsJyRHSYLL8w MjCg== 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=LFR/3SaShVlVQwrxv44DZ5GXEiLyHwIezA0irO1RVzf3UhDOMfHE99nJQb2WPcdoKS cboSgKh5DiLhaTECsHpuaejQkVCrU2lof0mSEjJcKHoVfKcVHqVOiQTYPjPObvxskSZU qTDL4EgNWYIk20+/DygKte5KhNAbH+akIq6Aw1hGpZn7lW7N9+bHEdi6r9g1NG3dCYbW p764biW6tuyyAvTqzEC7/egc2EN0SWplM/rGRKpU+96S5M2ZRHgreFlqZG3OEAWeR2/8 jsyxr2/TvzAMkUZ7Lg/6ttYCKlQRZWJ3P/TFBa8zQvl9EeoZBqe4kUbkpa7Ar1KbIPJY UQ6A== X-Forwarded-Encrypted: i=1; AJvYcCXuV8XUyqSwTY/7nboMA5kXR5IZXieWuQLYDFqjTtuFREIpfIoAStiWPoBARwQKXD/G002aD3mssrOxBJIz1XuC1iLeIQ14C+ZK/b9VamlFnh9zCaNljkETLxNNjOf6vNpF+OUzlPsnDteY6qoi3HMMuk/raOd8h/9obTiJ3+1ZzAlX6cey62GedgztK3qqMZpSZIyt8X8mG1Riyu0XAMcxdwt6sTVRcTpdT8f4pLT4t5gmCrTD1Ia5tFVr1+iHCyWJk1e1ysyoWzyJ7KE0veCZK0FLRgK4Mg== X-Gm-Message-State: AOJu0YwrmI7R5JFAVLf6UP/ktgIcP5qOSFn102u4iauyf3e4UbqP5wkn 5GfGC46AIYPqi+41RgtzxDm+Hxx+KY/4kgGb8WAlIdLuH3DBDCp57gVvOGW7 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590390 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85546139590; Tue, 12 Mar 2024 17:03:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263006; cv=none; b=a7N1I60+JrUbUO384zaVgqU61hmvu6PNGXouYlik8Kr/Siwwq+a6yv18iSgM5zoqrO0PYDXS5ZuhpxSTRBn+yxZzc+jJNXvrIrJBzFsYCRQ7aKG9zD5gDLOfsXV2KD5U/qNaG/+8gFo4oBadhmKqXWKN3/n5lYlfuVWB0W6u3qo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263006; c=relaxed/simple; bh=yHteoDhfKPGcsj1rp+n2EnxWC6nzc7OGPJZKXcy8Y4U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kKCn6zSL9pzMgmps0n0riMaRGz5KdWPZrJfVrGJ7X+FLKn2XcR8B+uT8ZQCeC6Q0yYcf3fjZTJgMdsPYkU+n+gsNXAUC+Lstw1U3F1RvdKoo5ZrKz6K1UCDO0RuUX06+Eegk/dYZn56o6DmLObLqVMd7+QKkOQnwcmWbbLMX69E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=A1Afs6sh; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A1Afs6sh" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6e5760eeb7aso4201516b3a.1; Tue, 12 Mar 2024 10:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263002; x=1710867802; darn=vger.kernel.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=A1Afs6shx26k3sneKBVaM+JdA60O55y8zlBV/iZFoaRWakMn3D5Iw5ArItT/7Koub+ owEC9j5sx9x0iLCI7c+MUahVD6X8uxAPbDcdUWektCVsh8HyxSfjh2oZXfKkOJ/vcG2d cdVBo0Huw/+49pI8ejflIkrGvmj8yOi9YCC151eMyZJ3wc4hc3MPuXaarGiiP0Yb+uUX Cjm83uOXN38cBfw2wmL6R4/yCEASwgyE2bgJzIWbedOxTHr1y09yDxC+7cIUEspRbf/V AYSrx7+g11BqBTgWungDl3BY4ya4rIbu8Ao70BA8P8oR80GAzqq8NMI/RRtfs/PTcTnX +TFw== 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=wf7fNR0htm9T6o3YJMI1sZasrNlL8mBiNZ3Oo79sHYa2KPaWaLc3Iivtm6lET3H+0j YNsj7SzWmhku9+TzvR5z0plC3W7SrDhd3ujSefHWdarxJOaaMsorma8+v0Rk2Y92YDfB dibWJW67+MhgcC66+vvtcu6d+R/dQbK8ukyElLkdGlTXEwrkr+3vLVdEQEaQPk4NWpoi CqbZWSCVxFa6erJ8EUX0a9C4bxtqZfPNLUS+IrXJ51zQYkeWRiiruZXmnu7iuk6x3DtQ Qh7wp7mu8clIyzGPIxtjQoLldiLLJP00kbj4tddZIqrBfT6JHZ4kuTj/hm/6PQpn+0+g m2Uw== X-Forwarded-Encrypted: i=1; AJvYcCW85UqGqzBsKn3x4WEmXRjkK4/cC5bqwKKsEfUoYgBb54HzcZ2e6s6jDTafNRGKzqQ6WyjcWZwJSYcpCSQE820fbF2xLucDfMKWYU1q9VKBarzE/iJkv2XbGpFPS+OZhV0EmrjBP3NTWwQwjaq1XQccwsz1TxxTJ0aj9oZCN9iFkbHNchE0Ip6EbFnUfxRNsJeEKnJMpGi3YqKxOH0AIH8X3Vk5vBiLsgZH1xNrXB2Hfhx9Cy7IlT0z9QHhOe49qaaIKfMBfdhaUp43X8VBtpHR995SFId5mQ== X-Gm-Message-State: AOJu0YwQEFIXoj0u8NnnycALMM8JEmObK8YKYs5y+BnXO9ddIcPAxqlN Fd1BwsFb3wryBTMIkyqxXk/rwbpRwJ5BSpXKCWO90yhtPE3wKTZrJn4Kz4ya 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590391 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A98113A25E; Tue, 12 Mar 2024 17:03:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263007; cv=none; b=IOpn2OxFz106P3mS/NrDtFHWwscrbMtMzSfDf8RDL7BfVjriILsS0gRD9MxBVb8OFF+a18YiPXaOh+R5+KtedO0nOepcnFvjp+HL8Kk9WdXryIBRXi5YU6Dxb1AMzV8BHQD0KK+2VzpsWF9QATAJU8KKiC6jAENWULIyUJhDI8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263007; c=relaxed/simple; bh=N5o0HnSZW5WhDNiR5nZH4ujEcqRXW+pWgts1zMrovCA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MPpwH+xd7wYIeGydE5iC3pswQblm9f6+qgfmRih1JwmMRsG5eA1EazSOGM61kewMhLpMxjvJ1ZRaCx4+slFXCVoys0PrZs5OJDHCoZGx1nxErqA15bRxTaKzDG33EizsP51nKD/3hEaVPoaqKeFLdZphJukghXYLvglPp7pePRg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nWfI6JO4; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nWfI6JO4" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6e6adc557f3so577066b3a.1; Tue, 12 Mar 2024 10:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263005; x=1710867805; darn=vger.kernel.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=nWfI6JO4W7MiLv4L0R5Tw0WRue65H5zlpc5F9gitpB39cQ9emdVl1WqGaCwBK/wTiM Gk4WXOsaqalAB+dghTbQacA7mYyQPCsIQWWJ7Wb7INrSYkmBJu/2KeLoJ7oUV/II+qz0 Z/KDSoNap7r2txpGMJTfkx2kRilrhc5HQaX+ApCSznBpU9djakgh83sPJI0BZKaevTd0 vgJ1i9WSiDop0fy5y/2Q0EarWK2sa5OfPr8AAEo9WbtQNjifYAC2Kys2M3mGGtvZfQpl AvX12tA2/gE7w55IQP5A5IxuNZjahXjbN2h1OAP87/HwenKh/yUzQ0wn0mPYiWtBbl0J kcuQ== 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=E0vKxbWfGLyteHR5SAJub61pEkriZTF/qzuuuEMc6KbQ6AgjGS3aZkmfKUGkJhszMi 9our+ADotnLuK1ppa+IvC5x1/nhSXlVV+qzUdhg0eUnmXwKzOhcpOeyGgw+wy64tHt9B rZ82qbPNcMHMRiE6/KzxMipq06UAY8UiSaCSxH58EL/Y/MO2RKpVwYoP+5ZstzYovGD2 9pUQvPvRLFMp0BAMF2lpAUqoEACpwzEHrh2oFl+YrcDzMXle3FqiXqPOoFtkbjx/1oOC HX+5p8c8zZm6z5PEkZrut8n4tNq8UwpPHERi9JpJz7vG+iHCutfiDoJiLoVBGjcbl0XM Ez8w== X-Forwarded-Encrypted: i=1; AJvYcCWNHG3z7pdxcC5WBIX4lT6J+RcJp11+gpz3QmN2YEl9EBcbMqJ4d49NIUGo2vyGS6aCYe/T1HQeCl3qBe9EYNxhHScGeDjhVl/3FhC8OuY99cAN2zs4HZzZYHeD7QRpnqS+0t/UXfuoJXwCFiHodc6COm/O1kW3vh/uOeJTHk/NIIJqF2qNkApBKwUZx0Ci6QvrQPjuprp/XLIPYhKYdugGee1lnaVCMGIyBTMz6m/tgY3tETTZSst6NVgkebs5g5iiGiTgWGNa3eRYGd8WrIouM389ENlJFw== X-Gm-Message-State: AOJu0YzTnD9i9Aw8roFv2oFOW1F+mOXc24FA/p3WQyBqdj64vSy9+6U6 Tiv0wPriBu2I8TvRFvUCnp0A2BSpIUaxg9rBomc6ezgNaL17g7Gj7Ds0Uehx 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590392 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA16113A877; Tue, 12 Mar 2024 17:03:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263009; cv=none; b=ia2ZhYc6zO737w4LHz+oUHfop16SEr39wKyqzeVX7Q03/2daxSxXEiFBKordF8sKeHiFofeqJ+Mf9iqroI6h/dblwbEREOxL8JKuKZ/CQV+54bsZi079QdZ8Qw3H/7vtvzRw4Vfhl3+Om5c2KUUxVDGJDilOip1ypbP9cm0EkHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263009; c=relaxed/simple; bh=knS+qppVrCuENhoPuTL59QYimH+PsuApCzIRiQQv0SM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C0nRMmUntkNqQFBvIu2dmk3PctnHjcYQr7fpcgLFtNZiZCnf7kHO3Y3c3V/feH6C8OhAhDHVfXSajfyGuZeuFYnnLZVNdldFwXhjswUvD/ewJ9mJr/tRy5ELSQMuB1uV4lr/k/171VcWbYex/cojDhwOwfN1U+NpzJC0cmPykDk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HvJNnX0A; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HvJNnX0A" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1dd611d5645so285015ad.1; Tue, 12 Mar 2024 10:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263006; x=1710867806; darn=vger.kernel.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=HvJNnX0An1/a+qhgTMfDvZQxoVK/L/dv4oLBdteu6CYZuaRoowarKOiFKXD7v7zySR BUOjj3dIYmat3PyLZG6lltN/Cw07431yC+1LVP9TxshLsLqInkLPzt0Sxpz9G9MCBOa1 9UuOj5JUi7MnQ5j8qY9uBs2JjpzZPEM61S4dC6UfAWMme9XUOJ/MTYIUjjFXlw8XB0N8 bZA9K+gKDqBcBiwx2UeTeEPctuhuCuKrVViisZORt/9fqqPci7A2kz22KnmKtqX1prx5 +QLUUWfCBhxVeARG61JMeD3OLkomYQQnr5ORO7XhJqMpVYvKXWhNVKOxc7O2q7QC+C3l p4QA== 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=X/CsjMAlXoI+yGlx+sLUlGgU+8U6TPWMqanZ2da/jHFWAz+/t7eFfAe9J5L5JfIpsz Jt2YqEq/nUy3A1eLCkEMeUMC5jXTvfmwx2s5BusanMTZd1dyomu71h7IvFKPWO8RrNOg 4ZEk+BvrsBpwZBAt45rTXZJIX6wobFPOUHLMfkLkxBoWhCx3515CFx8GUfwtjFDko95Y bxakCXjgzIKCxxYt7C/OTjKmmZvPyvrUmWvZ319imcgizh0aINcSUhVPr7hj8+eQ2wXh WEIMstssmGdLM5NtatFe7pADyPMwZc4v8bNa/MGmnJDMrer41VoMNFcaHyVOT329eha6 C66A== X-Forwarded-Encrypted: i=1; AJvYcCXW7Xf1IeOZqAuxfvkbk0gGcgFK/dVdHeZW0RoDv9aDPnINtAq4ICuc6X7yoSw4ib6KK/ZScFaY/Z14V/4MjTDHD55IJmS0Kz5MlAxxL9zoWxv7BDI97Q3w3pRNClG4UXdCWsYzvX5fGjThbs7SY7S4m5q0jj1a8JWiHW88CAkOW/HotpNsRM9nmJBgpXBEws+Y/9/mf8adagfN97o8KT+qUeywEDeKi3xjfQOXe9FzoQMyAM84O8AJqzDexv0LveljieUa3GajDLFiOdKiEB7Rn34zK2pYFA== X-Gm-Message-State: AOJu0Yx3zHqOcmsWapTc14rt4uU5hk02DiH96LU9RGdwG74qVH2ptMmI hQJUd79NdC7jDv80iQ42MbL8aQjKDAIJgicpJr2eF8nsW2RswyLFWXwuPDbm 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590393 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6121113AA4C; Tue, 12 Mar 2024 17:03:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263011; cv=none; b=Kms+KaQ+ZhDpY6ZqxWYw3wdzceo10aTLV+jDR7aFSIXDzIFLq0FBpxBAgJ0kmMMGC01D6rXtXNYhHEfilEPkjG6Lr1a0TqppmU7tBVaY3V2NHj0jhUL827zSH70pcS9gNxWznhcbq69iAGDUc45V3gkhU7NYDQpKDikeHzQDers= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263011; c=relaxed/simple; bh=2NHIPSEeh5V+X5+GdK5eLhFVjFh0D1jEmjx7oDfzWbY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SR2e4hAFVRoGFHZpA2W35FrRkzd/iu02nUwDFV2i39qnhG47qYv+iBOumC+VMVBP2xMhAr8bJTcz9qDF/9L8eP7Jx6uIPKlS62DKF8VdPFdnLp9bhi79d27yKUTGRSnG1DX/pCLR38XpEFOkWhtMn0FDfjutVpnOgk2GHfe9NWg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KaeG/q4k; arc=none smtp.client-ip=209.85.215.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KaeG/q4k" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-5e152c757a5so3350307a12.2; Tue, 12 Mar 2024 10:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263009; x=1710867809; darn=vger.kernel.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=KaeG/q4k2oTvKthueq3In95ouKsGzvDChhRbSwKB9rGceH2ZIqnow3ELZSd4ldzY3I 3qmwFcc9fZRV+5zf9Ep5sL5ZNnYfGFFeb/5/pUBRwn2a3f4GDo7z1SXiXUlmmjRUTSNW 2FrmB/13kuQaDgj/QBoofnCtB9jhgkm2VAtJ5MU+z67tiYA/ZqJDWajhEazgxVKTqpkq 9OIE+X1oyMPNn8Xg8N1mzYulx7l1l3Juf+w+q0lhj5hbmZoWMgKSE0V1UleSyHzQHAJW wJM9veOocS84V6wIiiKuGBP6FtCbodMQH5C+ueHEK4Br9lxJMzJFvEaYbaIuqk5+peeZ QuQg== 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=OrjWVB9Bu4SPimeMsvt3qj4OPCsMXAhS8x0fYnS3o15l2JcTuC1QfmGxLJidvUdc8/ Erl0iBCbRxNomSruhg9YfdqaRBoq6eTSz+qKQmrtrrhzNqiyZLVIvOSwcOvkF0UqFm0T 6TuN50UGJRh19QnlqwzfW+tic/N4WSgz9i04tQxqkxpaB0sCFAIWcPN/XyrdKCMSjyJY Z1GlFcBW4fqGgYAw272ZYE5H2OBRAvfd+0ukw46NB4X1tVRXuJIlg3PNkUmkjB3orW4x HFbsHrymyLmBQdUC+sNMOdULWqIf8Y+9Ep1Xfc/1v9QpC8b6qaGEuDNAXQJ+W7BrbGuQ FhsA== X-Forwarded-Encrypted: i=1; AJvYcCXukJ9LeUdG6MAKwldh41kRcHw+AU1/+kDVAiBHuAbdlIzxSJ3rqQrNQoSnp2jPkr4DzYJISIpcTdGYJXaJmU7iTHNZv8keXwplnFIs9wqNPG9piaTb7yIoorxyC3gaGquRJ8bJMrUdz0ZYUoyGz1XWgjxbKyiG6abqkTXMtS/fgFKOT61+8FdQD6XldNEg8ckaag0xky3qAKFDEGl58F/3tG6B5Jhbu4dVyNwAJG1rmQLxgPvLO0yhY5BNDMp4z0hl6HU+L1IWoRMrWHnVb/dIDrJNxduj+w== X-Gm-Message-State: AOJu0Yw+wNuYZXHZB05Qhkd3UXL2pVG/d3RozlOpkmh/QlJYax1tekRw 2MjQ2NpaMDyp9OoZFeKf9KfT0IFJhg1+6anJOvf/7FcUQNoNWQWaUU6uJMwd 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590394 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3838613B2B0; Tue, 12 Mar 2024 17:03:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263014; cv=none; b=ZDM0+dqOlp3/OVnF2aztlRxUDfE4B8ks35IYlPISoQMoKRTc4Nmicu1Lm6ygIFOvSUas1FshRI8rMNe4yLVwsgYhKAS1owMVzSt1zt2dmIDdu0YIkcO5UhcWKQiLniFOfKPT7V3MMrvnD45x7Tc8rHCI9B2H5We+HWwEf6k2uBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263014; c=relaxed/simple; bh=uZZ0pxvUudvGaQrFvHsY/MGGWPShLhBfmN2ecn70snU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qCb1qEtcTRVHk/H4tlbIbjuYWuBYIvjW+GLM+wpqwcao6tuip2RHkTpd+Sv1C7YOvcB/OmTCaXYG1yPMZpXpwTMgyNezJRxPcqq4yxOBZMDjH4wbpX3/xC78RsWkZwWW1klWcpOcnoctLR4ujuK0omQzGGxpUeN/0m3j12DpCGU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KxIw98IB; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KxIw98IB" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6e5a232fe80so45165b3a.0; 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=vger.kernel.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=KxIw98IBPFvBUKPyIUxvRBJuBcqQnpSZCDaCqY0kKSvifF1KQfRexk1sokOU1UOL35 N0QDSdk98/cHstpOxBuPyoKWHPTSyBjYE59EBh5MMdh6bOAttgtr44Ii7sgY2uVo/p5q RBIcSnO7AQzLArzoYL7OSM42XOT1XEpkKgzdn46l/wIba3JKXnvyiyIih/H/pnsDLXL6 godBC758E50dj6JGQ27Jvuo3zRxFMSQn0WLozGbfTs7mmSXoPYDr+4aI81Hssh5Os4RV LWNNG4mRlfZ3J/myQorPgkuO4/SYuDo7uJy598Q9ejOEUyjuOQgV4ccH33IkcS5LuTsR oBGw== 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=V1gjtWBPBSFYKMq/x+0X0AaZtBvPb2panayfnbOlgTjM6FvnmrS/5jGgQ/wSv0MEaj NYH5Rnzz1TVYT7EFDlWD3FjRD/0HIEZYNh124848NhUJlppwB0wkKQzMSKUKGk1YzHZi ATB91pO+fl5O8jLU0pyls2AeLB/R0NVjH2Z8N8F14c4YQ3b2ioFnR3DdkhwobKhRnEcc Llb8bcnzwTql+CI39S1pt2Yx0VLQWlRn7Eg/W9jWw8V8Pakd4Tjoy033V0K7L7Zxb5cT Zxv1IvTGOseYOKvm6fCW/5nlEFCrnALbx+jZ0rF3XV6V9ip29QPhEahKW655YS3iQgi1 uokQ== X-Forwarded-Encrypted: i=1; AJvYcCVLoXMH7hhNX8tBnlfvEIwENLg1cMgjpDCOlrp9KacVik7Nl9AjjH9UXmlbnmCiS32npGOlibQ6CYe5IBkaFqbnPiuhYQwBXnEwJyWOKRaYTmzXuYasSJ8l78HpecnHCmPQEZSIc2YF9NUEW7O+u31Yc3ldVz2a7LQo2DtLbfuSLVjL5ssU2YTGqJDZ9AwqWUJXlgqSAhrp0u/yx9DFmgAyJDZaU0LgxZUH/pd6nvZbVhv+f/KE23WjeLeD8LD3tZmS6kmSKE3gipXz9AmNfEzglYSyARVSkw== X-Gm-Message-State: AOJu0YyC/IlkFJ5f9H5agGfkPjvybNlOI7wKiLQLBmYA0I+z04PpIzAf RmwjpqciNQMCsJ7ovZA5ZLkZutzO7IVjDxiXMeO/npgsuRBeMqs6iHdRkHc/ 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590395 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2551013B7AC; Tue, 12 Mar 2024 17:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263016; cv=none; b=pkG008AzJ/eJeeCWAzcNlbsRmGygHvKUgvTPKJqaXDKOvOahEA6DifQCwwxXiYurLja/eU1OWaDZs+cfgUIa7iPfweFkL2yjfil/5o1HSWrBIwCSHC+vkGkQrvWSipcJo7YM5Gmd8/kGGrtXInVx6+ua4+RH8VgozJd/xhub4Mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263016; c=relaxed/simple; bh=g8p6Ru/ffP1jzehPrw/CRaeaF2IOojZZQLAZrCdrRdY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sN7OOfe+JLG0KKU0aJnM919UFfiRXeRqc8B4yQiTZV2bMEyKsEFgGmRmfdaWa1UT2dm2hkcQGve3asUCHAuoh6O4DHB033V6NKhpf23JLdfFpFyT8QTxW5xA4EMyzJSqB6N8NjY1rD1ps6ovYYYE5kd+yF3/ZduQnObcyvw2UFA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Np815lRI; arc=none smtp.client-ip=209.85.216.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Np815lRI" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-29c52a90417so23575a91.1; Tue, 12 Mar 2024 10:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263014; x=1710867814; darn=vger.kernel.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=Np815lRIv1esVZLfF7hP0nDH6Cwtd5VcAjgowzj5Jv30VHdAekxLSUIsXSMRfRFvKt gWVWDUwcS7UhA7mM9/ZvDlgooL6Kn5CmINGyeMfZ3/0T2u4NeNxmAD1mtFNN0VpGmPpc Xr07xfdSqx/1XqyxQfyO+5g77e3uzHVqWsuHp1JcuJluLPWkF9zWAlusYSQEq2JGXhyh IopLjqGxVbeVbOFAm3fLuuriP2Y2dcKCopMmLafpNM5Juh5OBz7+KGlesk2f1TT8SOVt iP+BhyHwm60728bW1zA+J/cWl28i+taJJIqGhdgsDKew8Jbo9B2o/t9ky1huyzvftbxQ zwnA== 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=XHgJujaC3uGnih7J8p3EcOgGjmwHhqOhqIgThJEIb/UDbOauZDtDDbcvVlj3qUDKFv GLFqysh1cHJwVBdgr3mBR+E7eFITHJWH+AC+3TSLWA5ahKiby0r8YKnZRt8MtNTy3Hgb Fk0unAjWWx2E5GTC7XtwZgInyGIMoxmYLrmm1k8tgiyQqzyStVH7EKriCWmb3z8J0qD3 OLZNnxUnX2bqMvGj68Vs1U4vHdjjp6yTwmbCvfrZdlDoYDcBr11PfUmFqsSlZf4rUU6c 2crlVG/g8ucoI2UJWQgrcFH25auPPx2B9BDt+cnUBgDio+fFdv2liQqPOu4NijWVCIE9 caeg== X-Forwarded-Encrypted: i=1; AJvYcCWPh/j2tekCpXybHW/stK4T8EJtk6113qrelBArYRUTyK+JG5sRwbzNh+lcFm5APeR7UgcEgtfMI0UMh2bvPpF+I/yvLPsCMQHbzpWjD+vD0HYR4bQLW5NN9xylM78OvVXtcLZy04ZCpPeBvQKm3zG8vpke6KJ1XHWKshgpoc1MoACns6fe2Q8/HFyKkdQtUA8Pg9rtTGzf+zo/ukS4kF2KJAIJEofppSho8QdnvTtvyglVa2CG6jnHEEZCSuq/fC1E+gSAO9FwNONEZK0XX61PobAoTtSjsA== X-Gm-Message-State: AOJu0YyMQ/8JxbcpceUDuj21EAaFJKIF0cNDsS6NEfn1um5Q55kK5mqz ISfutY3YWfBhNQ4lllcPm16hDOts6ovMgqtQZQyJlGa5biVWopA3zBFgx5Sm 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590396 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B97C413C9E5; Tue, 12 Mar 2024 17:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263019; cv=none; b=G3RmhYdHnT56VmbeMGLBufHUzf9CJ7kZsh2cxF+8MiK6LOFALaRUxbP9UnyuErz423BBAmp43RPeZ4fVe7Xtw/cxM18w0hZv+/dxZ0/REDIS/lEWWfenPpQs6VSGOzynnth+mQro4knnr2sjp0CXFT/rOnRyR3rOh/NAloxeZ9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263019; c=relaxed/simple; bh=f0M5fc11HYIWKzmWkt7Ao2+081OZJPK9Hnp8Pgby/bA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=arZx3lIwZ7LVdwzMjQSNfpKBNmpIoFggs47HAbwCVVthwP7KlHmO2Qae9F2hctz7zM/XJbE3QbdVdHd1JnQG7IGQs9dLomrxaYKXseDqkmVeY1fdBEZnJsFVpxTPsY4vtUaS+a2d+pvieqUsIGw1e3A8/6ukPjxmH0YMb5d64oQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NQqGip5L; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NQqGip5L" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1dc49b00bdbso34340115ad.3; 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=vger.kernel.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=NQqGip5L6qpSjIyg0i6WDde/VoNj+WxxxiOkcLyrfDb+s8hCN4nsR/CsKpwqykYHYQ rsN1xozkX0w5k47rNB4sd1im+Vay70TeOyHMJxH/0MUI8VANAP2wBPXDI6jc9irUDOx4 P/vNSeGvOIdodmRWlsuUrcXyAgIM7UK0JjWDnDQHbTE0jztCVrRP7tALnOnnm6cjoROK exHEobP8niTbWzS6fgAeVLhzJD0T09TggUUQj+wQZi7yt/XnRbqxAp5vFkn2rutqMJiO fOa2Gj4lqeKClr0manY2nir1RiKwjpSJS8LTX+ISx7Wzvtl32Zb1O44Mmls8snR4bNTs LG9w== 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=RkF1zJZTW5Upo17fYAlHjhEvvQSzSWH7TW3tkSt6ZiXy44AR3SIeLKujIHAv6acrv0 8+F1IvQwep/MfZ6Y+f3XoEk/QQHQfcUAbaC2va9PTBEMXvOLjrQj5GoW/MgX5QkAkRzA PZfN4cpby3HBtz+sO6eUORqMzReIIO0HWnKllJp+I/OlKuH3rrb97dttgCM9UGjFydvk uV6YGu9/+SX7dJtV2dWFZo3hMhAuZqEHwbzZnntVXu35IGkfqJkLbejpkSMggxzvRMvJ CwXrJYL3ba4vRexYMqcOAi2LgAH46am/6DB4a1u5zm+6wblSvVzZ+ecaANVgXdRSA00a kjfw== X-Forwarded-Encrypted: i=1; AJvYcCWVS45q/EAfBJVTRP0unz9GUcHkpvHY2N/4p0C2ejvABuFlLmNahm8Ct58fp1d0YCf+yKWpVaYEZvuhBvlrXkXuiLhBRlHzmcAPoF6SwTTVUpCSdvPabCYnfK2lExZTE5pRW/abry3YT/x5dJg8rC8qTAItVA3PBHaP/T61avxkzZVFLuDO0rMX/Ifsw7YlpqQS/OBpl7p0tXBctI7gfM9jVlY9psOazYzwXf13dvlujH+Rd9OKr43R5PHQpiuJvUE7IZzD2MtcgTAW7GhhPbpFegyUf0ntkw== X-Gm-Message-State: AOJu0YyznalQ/Zc+BT38jtjxb+OGC1hYHlIGMkrD0jLbFuKB6r4gYWHz vRsjgZxM1kRwVWTtIzsGRvNSC+oMiWg2db1MIjJQm347bqr4I9ElbAgUiXpQ 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590397 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A67B13C9EB; Tue, 12 Mar 2024 17:03:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263021; cv=none; b=SoemvvqO7D0S26mvmWpqdYheepaz6DK5nU3jfT1LTBjov1vuCft9m+K4Ht2Geo3Cp09mIGLz/0EMA1FkbgJM91idXM3mKPP6PblH/h1jbp1xUdYsMQdLuRBZXmro0U/WPitOvW67bKqHdp5ijNAMLcbKxp1yDCLU0/zj8xw4QMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263021; c=relaxed/simple; bh=/dkJjeYnC4xp3pBdcYmRMb6HiU3G4u98Gd+EGKHtNq4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BKWP9zHva+wOU+sq8PMsd0HJkYy0WPJ6B5nYSOr0bFNqmZl7UUBiAHLJHhLIfMvI/Yg8y6KavkO2ex3uX1fgMx1xoCaKdL22yZ4cU6EcVz5ma3fo8ZS8+BNb6kvCNV0rN4KLq3rnFAZeleFI1gs9etBgjttf5xEqzlhbmSv0RCg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NVYk1V59; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NVYk1V59" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1d944e8f367so1243445ad.0; 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=vger.kernel.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=NVYk1V59fcBZDVxiWT2IfmOoElqDPK97pxT/VCzo6wJgWudZjLl+Y1KEdnr60XWlSn T2c0xSlH6oHtntvN+R1tjFXZjmg7HIm48dNZhhyVQhTYdYuNoFgcnhCJPPfuCOHeJhXO wtMVxWvc/dL/HqB57oQwsxd+6VxpKB7VMSS3JPmg39AR1bKUm0IOoM6VfP8Glv1WqRRU arbCDUaZPfRipWq8FHJSRE/AaQTB/kVNXkP7ukz8MDFVvHshMkFsKbGCbcOC1SQonurJ Oggd42Fgw2oZzzqwd34VRvmmJb7tVo9yJnWlzZxhTroyopkN47eTcUtRmk5AstmuQNvd 06iA== 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=tAbKVjDzOI36qX32pNu8u7NOaaz4rBr4xg5TR401LRAVkjpWnYDdFxx4CBBMjNVAgP LNgSqY+7cej3Toqo156cB2C6cAUfyDVQF8R6ePRpu7PtrnYPwjC3O+c7pLg8fdevH2UQ 7AB9EyhWITAxagS8M7PBEhEA+2CR3ab25jEW0wJiYOH4ZmUIOWERt72lBbnJva3eomRt YvYYvgpV9BO0V9vNHdwmIVFPMfoqD8BrgSfTZfp8S+2rGgli7bKuiAvdJMabUnL73FY8 lIHmAHxlz9d/pkopWUTy+qkgozREAzu7iWiAhBxCGsyKI4pGTa6JMOr1m9SOrQLup8aF oIDw== X-Forwarded-Encrypted: i=1; AJvYcCWQaIkrMSvzLce0pzuf/i7GAggwx7WrLAGJsb8inkXWMNS8CDPmmkU5Jdze0oBLlMaSgRxRSdV2t4yocARg4IRKMhVcg6xiDc7z353sNDipfU5UA4Y3RoP6nzAptzIdjnsMXjRh0nY3KAOIY186fNhlkY2vsipAamXL2NpJ1nHrR88qoqTQoCinUhUGPI800DqMt9U90HWQcGCl3CX7qzB/vcLssqJWNsuVqxL/GCD0dn+/aT1Xoe5B5IrkL0p0a3cSxzmeZtHtxU+WTkSxKDttTnTa/vyzSQ== X-Gm-Message-State: AOJu0YxXANmm2aaKketi727qJ+6EWJQpSSzVvLcLLdMFRseB7Bo1Fv52 eaNwwkD89rrw9/m71x9QCYq+r3Mr2vxE10zHym8CulH5UuWjLLUP5QJJOdTF 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590398 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F4DE13D314; Tue, 12 Mar 2024 17:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263023; cv=none; b=bj+YRLVG90s0Vjw4wC8tmOR8trlMeW0p203vgyW/WYb9mJy5UyZCse/9hh3UrAcd8LLRISHMLrnKCnrs2J09uvYO2F/2O6kVkQHjoVJGT6FuBmOj1fOdJW9btOmty2fSOHA2xlnirBhfZcY4uw8ZC3BzqAvKmnlNaWogI69RKSs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263023; c=relaxed/simple; bh=jbZMWCS3DByK5SjjQJp5r57w18nrJ58+23RdL2gWKoc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=m3JLULH/vLf/1LPXhjr08DdhLlHqQCQKbOPbsbF+vPCS3Nu/rOFNOnEMWU9BHa4q9aLYNIoq7Rzr9PXLZYi5co7pPbuJ71o/ram7yGD1xIwQtoPD6P4n2uJZXHdyz5QmOkIN4zhdvesaHos86x+vHCWaN1EOB5DB4lez7RTT0Zk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PcI0Nb9P; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PcI0Nb9P" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6e6adf257fdso573999b3a.0; Tue, 12 Mar 2024 10:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263021; x=1710867821; darn=vger.kernel.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=PcI0Nb9P0NLswssNCZXz6UBWmFBIKgU+jsUizQXLs7At8lm45obiqPNmkpN3k9n+Ik R0QcawcdhDEI2/dvOfFJeBB2dDNgegT1P5nfr9NeeAdebsUjzPPzW7vyXrrw57XnsC2l 4ED3dzwC3stgQiL5xdK+lfPXxNAxr4EZpTzpwc7jyL5RXeUlK/3sl9/IH1ixAEPm4yh/ fXT8Nb7b1bUfi85HzbD5ihW9aJbwSOufWB8H1TZr/7SvEOYHIr08abmuvtauBGhP8aAE hVAdFpjochGg8C0jHWXhZSoiKJpAzfelJpF91YyOUGj3y6JCZch0jogdj9IJ7kyGdYIV gnIg== 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=JhdMtVDlsaCMLP9AG06B6qxaCNU9V3esow6H4gcSIo1iG4GXr62KN23+sCDQYypfTW 5gKg9HB7PmCsYHoNz8WWAriH/0aYxpxqt0R8NS2KqFs/qhs74H4Gq8BGcbH3Lny4iYjU YWSf53DG54uIwFzUlvMApA/bbDiscGe3KrMfrB1r1VPex8mE7sxv0i/1Pt/zjiWRLOg7 7kU1WazhozieQHpAlzKTAD8X0/9ByPiiXp7GoNW+EKXT8Qm3nuP042whiybMt4dDDXxL NhzuMff2OZSrqrFs0ttABY2nyLgYCdiTe3BEDZ3GtK7Nys1KLZbTlIIWrvLkFLJNah9t eTYg== X-Forwarded-Encrypted: i=1; AJvYcCU2I3MWKBnFWVMdKJjivkO+EWg8K+OmWmiIblU24THQUtosnzBjlTp2HjKXbjB2Co0CU8RBN1WCzRTTnxHOCvCR3qdKYvGelOP8vYqyWaAJsCnKa9CWF6glPJ0UoXfVQZ8wF3nxIRfLWIOaTaASl9bEohvzOW2jPHYJ5FvwI4nfLBV3FplKe7qgEo4YTDP/yl60jWytUEwq0PkriUMn0+cW+2gdVDMPq5OfWR06yUt6TG9/k2osJ0F0vwCTpiLgafPmB/g/vRu82+zqGLeYV5Pgttuk8jzT2g== X-Gm-Message-State: AOJu0YysKPK3NZ9g5j7gZMYkBWfykql7X2usVBwKXUOqzg7sV0ecXwcA s+h2bfAfSRY9tbNb5V4JTM7vV2xMGyr0LRxCKUnSBV2E/2tnc9tkEHeKIiPo 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590399 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 387D513F00A; Tue, 12 Mar 2024 17:03:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263026; cv=none; b=RgfAkFOgn5bgaCJyxHET3XRbOAD2cdjEbAmqXu1IkCpeVh1l0oEWeQt3yL6E9axB9NLL/uczFRg80dhTzUAO2LxNnYYQwhahLaJFzDGvmFsmX8c2gmDQHRgKHHI9BR+aawDK4GI9AybDmOaklmjxaNgEgOhVl8jWOPWSay8B6i0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263026; c=relaxed/simple; bh=M3fGFgI9yuthQJkxiEtVWLMsbx99o2Y7sxqWKVQ8z74=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F1bn0m3Th8BoChBjbxty+VA1hOenEwIlD6aAkadhYc3r9oOoEYD600MSsmtFrDdW9rB86MqLj+JaCt/1038xVNehHDiI89+cfgKpwRRnnw+etvX/QvsZNVyG7Hm3KIX8d2KcBeCkG8DvScIsRzXjBvh2hgWVxjVS3+9k7f/5zxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VVGfBPsp; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VVGfBPsp" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1dd97fd66cdso19995905ad.1; 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=1710263024; x=1710867824; darn=vger.kernel.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=VVGfBPsp3BEGYJsCa5NCbgQBQDFd5jatjIgVlWqkD6ZWIV7w58STxRohrPLcnLYbSZ nSh7CU/4CJ2h/SofVs0yZg/G6tu8mCSw6b72sIKndtCJZCzZ2bcL/UqkRXKON2GOj/aI y42cETY2mlMtDvTOw81GyogwABtpNg/UepvHN17FrlHTEBtMr/Gx5K5qSX+NqG2UPN1v 4iWPq1neaYmoNrCsw0oMNo0DOVkokbqjE7L0AjMGiK1XdeaN91HZSPBRisF57/iRpAJ6 +puMXHE1vOzYOKdOIlIHUf3w9s9pDskN/wgI7C++ahkI1RConDeagXgHIn+40rFtwFUQ Cd0Q== 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=C9VgUDJSjKMWaYc7dqpeKe6VMBBm3RskavMnF2KMo2/+bYiw484uAjtgDjDCTjo3f8 0dgIbPN7zbUjOnMK6rb/W32dOu4PUuqDdbdg55ZuU4TEOVZ/yqvbGKmqCCP2MhtEOyM1 peF2L18HgaJyRjgJSTgKJp2Zc3Fx6Ig0V8q67Id8keTbLOP2xcQnyJyOxDaeQlxHtF8P 8Q0G7y/cblbg61d1PvLgoVwP6FNKo+lepfOfThDfofoWYjqwHKwvzb3sJ+3rNNt0rKN0 X5b+NxBiObp6asyRJ6E7ImTn9OLydF0jFZ2TAc/H4kfzjAO+podt3+b0p6RgWGb0XGh0 e8RA== X-Forwarded-Encrypted: i=1; AJvYcCWMCvrBsxZbmet6Krq6XU/AUry238XQ6RQRiBZVAM6um3zCpaZyEPNiql+Q+nLV+nJezi7zf3CVV1l/HiVQI2qg0o97DREJnd3fzyYGb8aXUkANHFyLu9QAEfustfnVyeHhDAcruUW+esPWBjap94GECLlCVO79veZfqDjZJdRNCpvl5U28USBT/StH/4Q8jN20R9QfaXI9RF5cQrZ/WaipPD+F+RxzABc/5yNHMfpK07dlyXu2f1UXoE7B7CMZTm3IwH1m5bjucNZD3kz9jKUrcx4L1qS1/g== X-Gm-Message-State: AOJu0YzpTMqqZ4Zl8c0rUMt5LyA35HdHzJZSTAgZ4D2tP+8u8NwQT2Ui 3d+Yn0J8oZrhJH1wzCDFB8WkJdn/u+cngp6F+SYwGbyHC8IEjSkeVZJMd79J 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13590400 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7398213F43C; Tue, 12 Mar 2024 17:03:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263028; cv=none; b=RQVxQtIrYHe/94jAEevfS8qEPgqRterFStoJfr/rxyB4ah0xYdRE9z7GWSeRwM152vAOnuAqGLZRZqXdQlmzbeOoE9zA+LryIqXAaLpf5roHVIdDL7rzD6uBI04DK2fBrcqwOxpXy+U7k0yVSzvOqrtlYDVJ63bfyTB8Jl2emlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710263028; c=relaxed/simple; bh=aXK16bg6wFU939Q5hQXiPa2mmiaErST3M/uq0N+/d0M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aRyHv/mEPt/KonPt1qER8oQNO85l9v0dnw8Sxx/aKDi/nTnv4XdqG7S7fAXJBHQwuVi8Ix6fyb6LBMk3YXTPb/S/UIYdMYGfvHmIMeDoaUGMeCzaODNXzt/YYaEj2fA2XM4Z9kcH1og0NE2MiinHuFlTlHas/eT3SrWLO9rxmHE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AkJDfD8d; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AkJDfD8d" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1dd9568fc51so22813665ad.2; Tue, 12 Mar 2024 10:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263026; x=1710867826; darn=vger.kernel.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=AkJDfD8dIT0XkorCvtWCXld9660bxGyCxgYYHwK1dP6jTMwBiOoImKTxegP9eY/L2+ ULyXUByH35/epJtHBmGHffmyV5gVlYDKXQl3zSiH7N/n2uY4qgpW2K4nM5xaOmx4xCiV IyiTqC5vYksM8XUli0sn2bU0b8+MvK3MtElZ8JP7hh/CiphchxYrBiMe5rSwsL1IIBXX h/9TngYVo9PGMPkoRF+ccYZ3wwqF1CoK3CEk2CO/+fO1CmZAk40KNzV8qJYNimkMs76r jalEiGaSMZ8XZqtiHc0VBcVCabby5+RVTNIC7DHd/Vgt352lf/UrPVWUSkzuvGlP74XX 1IhQ== 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=W003Q3DEGIw2ie+YE8i7XBizeG7QTiuW59A77BFB7NioJEFXNldOGEa9eYMlyC+stQ QYbRvQrkb5K2btceiEjTfClIC6CQETJhONclkI7P8/0DGZbaIvAuYEy/1fBvYP/YR3S0 ZIAT99edEXzJeFlPfL0irAWGYnT7Cs3ONNC+S9ieH8ynzcw6PPfdQGBd+NnpNFeGm3JL h6VSI4rkKh0z5kb1epuFO+9/2UEm52zxyRrrfwU5B0T0YcmsQ4Uy/BfzgkmHhQTDmZEL EjLKEEnrZ1MJY2HtPsH/q5AG9rls4Jf5nRLf8lrb9/J8dO15hhT7ekOLa9zYIiHCqQ0u bxhQ== X-Forwarded-Encrypted: i=1; AJvYcCWEp2okZOCa7sqE9hFnA8U04gwIbWULiO1u/KHQ6OOu+Q/BnSoBeiwXQbxJI5gsLkkKGVJlXFAuxpI4CPQl/ZmJTSyb3oBhkbApMIiTwO6M/YsPTljVZ8KV8GxdOL42DqlFbv/CO1unf82hE66ZBmtL0vwEGnKUzxxPqLjEimfZjDLbWIX4nkNc8r/akDUYySIL+X5sftOJb8qAKdi7jXgWHXB75fe5b2/GerQd7uo6WNA7yT2Ypr8RHW3XZ28LuGdElryYZp6+CuTy3DH2yh/lrsmdamCMbg== X-Gm-Message-State: AOJu0YxAODUmli+DmE7cbfn9j6kpRL4tq78vRNEqkIe/OmBuOXFP6Egx SnyEc1Dm74cn9pHVB2ipaLH8F4vHSo6f74Ay+s2ppDf8xZMl0sFWeI/PGI8w 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) Sender: Guenter Roeck 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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)); \ } \