From patchwork Mon Mar 25 17:52:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 782416 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 33DD775815; Mon, 25 Mar 2024 17:52:58 +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=1711389180; cv=none; b=kufa1+4tXra3SyiLMCuCyNvb+BbY/K2Lrus2xlaB9MonVCQKLaTDxgsizjRzSu0VnVM23DbjiRtnGI/Moeq9zCvA2Dz7MlglNciNqjaCC++xZqyS54EazY5EgEJSfun9QLgBK5710cl3V7yN+/KkXRdQckI8enzkx2/OQwYhqdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389180; c=relaxed/simple; bh=xSZ55v6UfTOTyTReQTKJ/rMwooPxvxAFhW6B8GTa7a4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZD3nJu7dfu+Ok1C6QFKoQ38j2spe/I7PkwIfHgiLVQAgtnfc7uYV3QjMNUK6/xwNmVFjfXgklGGYT8WNjs+jriw+FyxXfBMWSdb0zM8S0yGAjybAc6R8WyZb021GMOpDQwToQ80G0DtQDMBXAGDrM+oGl4xGg7X8cuzgGMG0wpk= 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=UXiJmKDR; 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="UXiJmKDR" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-29dee60302fso3834187a91.1; Mon, 25 Mar 2024 10:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711389177; x=1711993977; 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=VdgHihJKraUR/iBuD8NDeb6k16FVW4gr3RkZwUlYax0=; b=UXiJmKDRsoUHvdmXj25fZEZ2I0KaR3flBky46fi1rOmS8F64EzJyryXCQsLUShXff5 MfuXB/p+u8iDS5NYRnApPo+ZsprsCM1yai/cdVQ7YFMW/Fs/G3c+Fj9qACifxpgIPtAq Z5HTobKG97Qop3J0Iklt25HPIhNiZYYvmPiIau65spq+Fj/lH2jhEn3K5LhOOnbeOgsS Rw8PIMLN2hIZP+kxtVc9U3DLlYAyfsOzxo/h70ffngsd6zBMYjrhDE05yDr2tZsJpCsJ efxEO8C2IoqTSzyzN1DSi6DEnU+YBmZcu1ydUD4zO1iLEg+KFjV+cklRMKien2deyT2f hSnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711389177; x=1711993977; 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=VdgHihJKraUR/iBuD8NDeb6k16FVW4gr3RkZwUlYax0=; b=axI8RlgDvxve8F2ClaLRMOaXhfgTNH/F1y2u4rGMch4Z57IoMRpU5xAjU0Sdtr6eS+ umveEJ89QfOvRm1Zv9ZikGaM925ZFNWYm8AlEY4/7ZyfwY3ZXob3fhdnEAajHwkecwfk 3DN61VarHZbsB4jVb0sL19F7c/zkHbvHjusV3HKQr3qTedMf3pCuU/inwBWKDCV6Smc5 dqVaTLROaT34CKk1hTamP0+x5dJhZbo0GRg+HTpRdXNKVqnOBpLj/+1uM8RYcI2fvCqf LCdDs1ioJURB7y+vos1zT7z57tg5phIF7/kUfueBZ1hfkQTFit8VvaJMfn8eKUFyes36 SILA== X-Forwarded-Encrypted: i=1; AJvYcCWC0VuiY9Bk9ekMPOkIS5fd9E0V8RmldjuDU5LlsXP4UrqNllF2uk3bAA/lFAfiZQoRUOQBgw25Lp3wvF4tLhbAaJUZ/6uTfGdqfVY8FoLIGf0IFZesYNBs+KmjKKPSEqsq4Iuc4XkfyLJSc2ryW9QTktGvwq+vLYvxBVeq6/rgicvRdwZP7qXhE5fW/GuPV79RpX7oucXUjBTsFdwKuvTY9XZhMTIdIhjpOtpM6B+z/kmMUC0b2mRN4Qx1xVbolk/9zxJtuhso7yWplWT72fsjgC1k/EUQnLbQ2DMOgtM0/32WG/LFT1z0yIrjlMLfqw== X-Gm-Message-State: AOJu0Yx95xrSjkazXSOSvo1mIyz0gr7hb6B3iXhowME0Ci/g65dXMRbZ yCBTbJZALAHyVCvgBeaBs1yb46/Av+NqmMkULn5KyQAnQpB5WFHBTloFY1x4 X-Google-Smtp-Source: AGHT+IGDtRUvE+wB+Cm8/s7Iy4N5p+cGVP7velMgThaXg7aE5ZDLjn0z6N1uwWclcXueDp1Ww9/XQw== X-Received: by 2002:a17:90b:3b91:b0:2a0:7e08:ea49 with SMTP id pc17-20020a17090b3b9100b002a07e08ea49mr1818808pjb.5.1711389176978; Mon, 25 Mar 2024 10:52:56 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id li11-20020a17090b48cb00b002a0593432bbsm3625703pjb.52.2024.03.25.10.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:52:56 -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@vger.kernel.org, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v2 01/14] bug/kunit: Core support for suppressing warning backtraces Date: Mon, 25 Mar 2024 10:52:35 -0700 Message-Id: <20240325175248.1499046-2-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240325175248.1499046-1-linux@roeck-us.net> References: <20240325175248.1499046-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-kselftest@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. Since the new functionality results in an image size increase of about 1% if CONFIG_KUNIT is enabled, provide configuration option KUNIT_SUPPRESS_BACKTRACE to be able to disable the new functionality. This option is by default enabled since almost all systems with CONFIG_KUNIT enabled will want to benefit from it. Cc: Dan Carpenter Cc: Daniel Diaz Cc: Naresh Kamboju Cc: Kees Cook Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Reviewed-by: Kees Cook Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Added CONFIG_KUNIT_SUPPRESS_BACKTRACE configuration option, enabled by default include/asm-generic/bug.h | 16 +++++++++--- include/kunit/bug.h | 51 +++++++++++++++++++++++++++++++++++++++ include/kunit/test.h | 1 + include/linux/bug.h | 13 ++++++++++ lib/bug.c | 51 ++++++++++++++++++++++++++++++++++++--- lib/kunit/Kconfig | 9 +++++++ lib/kunit/Makefile | 6 +++-- lib/kunit/bug.c | 40 ++++++++++++++++++++++++++++++ 8 files changed, 178 insertions(+), 9 deletions(-) create mode 100644 include/kunit/bug.h create mode 100644 lib/kunit/bug.c diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 6e794420bd39..c170b6477689 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -18,6 +18,7 @@ #endif #ifndef __ASSEMBLY__ +#include #include #include @@ -39,8 +40,14 @@ struct bug_entry { #ifdef CONFIG_DEBUG_BUGVERBOSE #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS const char *file; +#ifdef HAVE_BUG_FUNCTION + const char *function; +#endif #else signed int file_disp; +#ifdef HAVE_BUG_FUNCTION + signed int function_disp; +#endif #endif unsigned short line; #endif @@ -96,15 +103,18 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...); #define __WARN() __WARN_printf(TAINT_WARN, NULL) #define __WARN_printf(taint, arg...) do { \ instrumentation_begin(); \ - warn_slowpath_fmt(__FILE__, __LINE__, taint, arg); \ + if (!IS_SUPPRESSED_WARNING(__func__)) \ + warn_slowpath_fmt(__FILE__, __LINE__, taint, arg);\ instrumentation_end(); \ } while (0) #else #define __WARN() __WARN_FLAGS(BUGFLAG_TAINT(TAINT_WARN)) #define __WARN_printf(taint, arg...) do { \ instrumentation_begin(); \ - __warn_printk(arg); \ - __WARN_FLAGS(BUGFLAG_NO_CUT_HERE | BUGFLAG_TAINT(taint));\ + if (!IS_SUPPRESSED_WARNING(__func__)) { \ + __warn_printk(arg); \ + __WARN_FLAGS(BUGFLAG_NO_CUT_HERE | BUGFLAG_TAINT(taint));\ + } \ instrumentation_end(); \ } while (0) #define WARN_ON_ONCE(condition) ({ \ diff --git a/include/kunit/bug.h b/include/kunit/bug.h new file mode 100644 index 000000000000..bd0fe047572b --- /dev/null +++ b/include/kunit/bug.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * KUnit helpers for backtrace suppression + * + * Copyright (c) 2024 Guenter Roeck + */ + +#ifndef _KUNIT_BUG_H +#define _KUNIT_BUG_H + +#ifndef __ASSEMBLY__ + +#include + +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE + +#include +#include + +struct __suppressed_warning { + struct list_head node; + const char *function; +}; + +void __start_suppress_warning(struct __suppressed_warning *warning); +void __end_suppress_warning(struct __suppressed_warning *warning); +bool __is_suppressed_warning(const char *function); + +#define DEFINE_SUPPRESSED_WARNING(func) \ + struct __suppressed_warning __kunit_suppress_##func = \ + { .function = __stringify(func) } + +#define START_SUPPRESSED_WARNING(func) \ + __start_suppress_warning(&__kunit_suppress_##func) + +#define END_SUPPRESSED_WARNING(func) \ + __end_suppress_warning(&__kunit_suppress_##func) + +#define IS_SUPPRESSED_WARNING(func) \ + __is_suppressed_warning(func) + +#else /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + +#define DEFINE_SUPPRESSED_WARNING(func) +#define START_SUPPRESSED_WARNING(func) +#define END_SUPPRESSED_WARNING(func) +#define IS_SUPPRESSED_WARNING(func) (false) + +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ +#endif /* __ASSEMBLY__ */ +#endif /* _KUNIT_BUG_H */ diff --git a/include/kunit/test.h b/include/kunit/test.h index 61637ef32302..d0c44594d34c 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -10,6 +10,7 @@ #define _KUNIT_TEST_H #include +#include #include #include diff --git a/include/linux/bug.h b/include/linux/bug.h index 348acf2558f3..c668762dc76a 100644 --- a/include/linux/bug.h +++ b/include/linux/bug.h @@ -36,6 +36,9 @@ static inline int is_warning_bug(const struct bug_entry *bug) return bug->flags & BUGFLAG_WARNING; } +void bug_get_file_function_line(struct bug_entry *bug, const char **file, + const char **function, unsigned int *line); + void bug_get_file_line(struct bug_entry *bug, const char **file, unsigned int *line); @@ -62,6 +65,16 @@ static inline enum bug_trap_type report_bug(unsigned long bug_addr, } struct bug_entry; +static inline void bug_get_file_function_line(struct bug_entry *bug, + const char **file, + const char **function, + unsigned int *line) +{ + *file = NULL; + *function = NULL; + *line = 0; +} + static inline void bug_get_file_line(struct bug_entry *bug, const char **file, unsigned int *line) { diff --git a/lib/bug.c b/lib/bug.c index e0ff21989990..aa8bb12b9809 100644 --- a/lib/bug.c +++ b/lib/bug.c @@ -26,6 +26,14 @@ when CONFIG_DEBUG_BUGVERBOSE is not enabled, so you must generate the values accordingly. + 2a.Optionally implement support for the "function" entry in struct + bug_entry. This entry must point to the name of the function triggering + the warning or bug trap (normally __func__). This is only needed if + both CONFIG_DEBUG_BUGVERBOSE and CONFIG_KUNIT_SUPPRESS_BACKTRACE are + enabled and if the architecture wants to implement support for suppressing + warning backtraces. The architecture must define HAVE_BUG_FUNCTION if it + adds pointers to function names to struct bug_entry. + 3. Implement the trap - In the illegal instruction trap handler (typically), verify that the fault was in kernel mode, and call report_bug() @@ -127,14 +135,21 @@ static inline struct bug_entry *module_find_bug(unsigned long bugaddr) } #endif -void bug_get_file_line(struct bug_entry *bug, const char **file, - unsigned int *line) +void bug_get_file_function_line(struct bug_entry *bug, const char **file, + const char **function, unsigned int *line) { + *function = NULL; #ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS *file = (const char *)&bug->file_disp + bug->file_disp; +#ifdef HAVE_BUG_FUNCTION + *function = (const char *)&bug->function_disp + bug->function_disp; +#endif #else *file = bug->file; +#ifdef HAVE_BUG_FUNCTION + *function = bug->function; +#endif #endif *line = bug->line; #else @@ -143,6 +158,13 @@ void bug_get_file_line(struct bug_entry *bug, const char **file, #endif } +void bug_get_file_line(struct bug_entry *bug, const char **file, unsigned int *line) +{ + const char *function; + + bug_get_file_function_line(bug, file, &function, line); +} + struct bug_entry *find_bug(unsigned long bugaddr) { struct bug_entry *bug; @@ -157,8 +179,9 @@ struct bug_entry *find_bug(unsigned long bugaddr) static enum bug_trap_type __report_bug(unsigned long bugaddr, struct pt_regs *regs) { struct bug_entry *bug; - const char *file; + const char *file, *function; unsigned line, warning, once, done; + char __maybe_unused sym[KSYM_SYMBOL_LEN]; if (!is_valid_bugaddr(bugaddr)) return BUG_TRAP_TYPE_NONE; @@ -169,12 +192,32 @@ static enum bug_trap_type __report_bug(unsigned long bugaddr, struct pt_regs *re disable_trace_on_warning(); - bug_get_file_line(bug, &file, &line); + bug_get_file_function_line(bug, &file, &function, &line); +#if defined(CONFIG_KUNIT_SUPPRESS_BACKTRACE) && defined(CONFIG_KALLSYMS) + if (!function) { + /* + * This will be seen if report_bug is called on an architecture + * with no architecture-specific support for suppressing warning + * backtraces, if CONFIG_DEBUG_BUGVERBOSE is not enabled, or if + * the calling code is from assembler which does not record a + * function name. Extracting the function name from the bug + * address is less than perfect since compiler optimization may + * result in 'bugaddr' pointing to a function which does not + * actually trigger the warning, but it is better than no + * suppression at all. + */ + sprint_symbol_no_offset(sym, bugaddr); + function = sym; + } +#endif /* defined(CONFIG_KUNIT_SUPPRESS_BACKTRACE) && defined(CONFIG_KALLSYMS) */ warning = (bug->flags & BUGFLAG_WARNING) != 0; once = (bug->flags & BUGFLAG_ONCE) != 0; done = (bug->flags & BUGFLAG_DONE) != 0; + if (warning && IS_SUPPRESSED_WARNING(function)) + return BUG_TRAP_TYPE_WARN; + if (warning && once) { if (done) return BUG_TRAP_TYPE_WARN; diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig index 68a6daec0aef..b1b899265acc 100644 --- a/lib/kunit/Kconfig +++ b/lib/kunit/Kconfig @@ -15,6 +15,15 @@ menuconfig KUNIT if KUNIT +config KUNIT_SUPPRESS_BACKTRACE + bool "KUnit - Enable backtrace suppression" + default y + help + Enable backtrace suppression for KUnit. If enabled, backtraces + generated intentionally by KUnit tests are suppressed. Disable + to reduce kernel image size if image size is more important than + suppression of backtraces generated by KUnit tests. + config KUNIT_DEBUGFS bool "KUnit - Enable /sys/kernel/debug/kunit debugfs representation" if !KUNIT_ALL_TESTS default KUNIT_ALL_TESTS diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile index 309659a32a78..545b57c3be48 100644 --- a/lib/kunit/Makefile +++ b/lib/kunit/Makefile @@ -14,8 +14,10 @@ ifeq ($(CONFIG_KUNIT_DEBUGFS),y) kunit-objs += debugfs.o endif -# KUnit 'hooks' are built-in even when KUnit is built as a module. -obj-y += hooks.o +# KUnit 'hooks' and bug handling are built-in even when KUnit is built +# as a module. +obj-y += hooks.o \ + bug.o obj-$(CONFIG_KUNIT_TEST) += kunit-test.o diff --git a/lib/kunit/bug.c b/lib/kunit/bug.c new file mode 100644 index 000000000000..f93544d7a9d1 --- /dev/null +++ b/lib/kunit/bug.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * KUnit helpers for backtrace suppression + * + * Copyright (c) 2024 Guenter Roeck + */ + +#include +#include +#include +#include + +static LIST_HEAD(suppressed_warnings); + +void __start_suppress_warning(struct __suppressed_warning *warning) +{ + list_add(&warning->node, &suppressed_warnings); +} +EXPORT_SYMBOL_GPL(__start_suppress_warning); + +void __end_suppress_warning(struct __suppressed_warning *warning) +{ + list_del(&warning->node); +} +EXPORT_SYMBOL_GPL(__end_suppress_warning); + +bool __is_suppressed_warning(const char *function) +{ + struct __suppressed_warning *warning; + + if (!function) + return false; + + list_for_each_entry(warning, &suppressed_warnings, node) { + if (!strcmp(function, warning->function)) + return true; + } + return false; +} +EXPORT_SYMBOL_GPL(__is_suppressed_warning); From patchwork Mon Mar 25 17:52:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 782415 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 9BD86839E1; Mon, 25 Mar 2024 17:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389183; cv=none; b=QnBpdFm0Q1wDgibq/GOTEN8YIKUIMEvSWSO9crVz4wZJSEpgqk7qqcCaiWzkjCatEztWTtHBOo/FAf93nYnIMrUCDxzV+OPuoLK4+kZKqQl5y97GONDFaDtn6PU+HMODW7ifnBsZnE9EiI7M/Mc4vb+Sm4fI0YnRHy/bk6FCZPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389183; c=relaxed/simple; bh=Q4GDe2OF/UogPfEQ1Rxv6tM7a2FMPTCpZuxl7c7+zL0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kh87/0peYYPRBeJqkwSqHcXVPIBZ7CzbHvIIdAJPYp0AOo3D/qzGgaG78gFnBEhuEVIxF14kryB4igYQhl+PQYtxinyrIaRTSTU7uxdfi1Bj0rr2hTSapWBchU9z6+SXPkU3GF1BfdVF9mxz8UyB+Xjv6WLdQp0i4S40IXVCZaQ= 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=bNiheVXE; arc=none smtp.client-ip=209.85.216.43 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="bNiheVXE" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-29ddfada0d0so2399366a91.3; Mon, 25 Mar 2024 10:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711389180; x=1711993980; 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=WAqubCL51IrVA5I7nNJRuv0X36LpccPRVheB6cZNZ0A=; b=bNiheVXEWDRl6+YRC8wg/Pu63FeLtgf9CATQH98Vt0Ia8oxdh8QjQB73vdHRikMw1N VzYOsA86f0LBZpM549L4kKVUH7The186WVcwq7ed2LJWEIdZvTBebI63kJBEukP2uNua FqE5F/ZR/VKK/LY7r7Vzi04kFkTYvsamQlpCJJx3xATzNsclNDGIsqzCP5UUUXBGwapl oyT8DcjV6pMcRI18SK2d+Nj2JwayoSanpu/R2bOce13D1ZEdN0ObF1/Iot5q+xJnVpNN ORq6r9cWx6FkqbWo0d6rAwLH8hhOa3u7OSvmklbt9THSCG/P1As9VBHveyGaazFAStmg PXYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711389180; x=1711993980; 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=WAqubCL51IrVA5I7nNJRuv0X36LpccPRVheB6cZNZ0A=; b=o2/mprYruip5ls/BUx7eXu3u8E9XdZeBHSiV6Ix55vup7uOB6rzNOjsZKdULCuq69v oh0oHItL+SXdSh2V7GWWJAxnQDk977M5yLGKq8SbZEqFCRtmyHcsf5o0dDtZzJjVS2n4 gdGq5B731CzrA+6FN5gXAcEaZOEdnSGClZ/e7eHcng5N2G7cSDkK47OFCoA2ViyphGil SnQ7XqlTb7IsbJY3YY/nJyu/AxfX/KoVfUQRdopVDo2/Fv96ss3qhtmA+wYkEBk4D8n9 uobAmGUscF3+Bhdk6pV6BX0AXpeQisxs37RHBSe0DgyK8u6lbxmfGzGvP7gxeVW2LZYx GAbg== X-Forwarded-Encrypted: i=1; AJvYcCWvhIcSDPNCUplkeoiOEHykpCnxeGns45x9LpDNk+hzW+Qyb5N6S/RgdnkfZ5qCmVQ+NHQNMtBfWkSAcng3iIo8jVeBfb39g8i5fzaOx++Cbq9oUVVFusZOcOfL9xgsIorPFoDW1FftwFufoTrQeqwvwGIYkI/e7jjfwEZaUr65qHF15I5ZlWKZfuJd48OsBxXalZkf9TsauAFd4lJWO3nEcwpfj1HFv0d7osqCbFfRsVTfTEnyge3WlkC1aQ4+KlaFH29QVj1/YWjXv+mMSjZcDQohC70pYyts4EJkqGb0b0gh89uzhGXiKqPl8RHuHw== X-Gm-Message-State: AOJu0YxW9DWJHerhp62Glealx5GA7BuDSaNOo8+qD/VjeRQhErc+d+KF pgjVmf25qPgVu6h8iCPgKoq9sKDzKXAYKx3EhnnkwbCaT4wK/mUhSJ21oHmV X-Google-Smtp-Source: AGHT+IEZGgr3SHHp7IQgBYCFkoLblCFSkGv9KaSvXEQxhqKmotSHNR4v/ZnArS+Gaiul6D7vvEZjeA== X-Received: by 2002:a17:90b:17c3:b0:2a0:84f8:3096 with SMTP id me3-20020a17090b17c300b002a084f83096mr202747pjb.5.1711389180022; Mon, 25 Mar 2024 10:53:00 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id fv9-20020a17090b0e8900b0029c7963a33fsm10424210pjb.10.2024.03.25.10.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:52:59 -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@vger.kernel.org, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v2 03/14] kunit: Add test cases for backtrace warning suppression Date: Mon, 25 Mar 2024 10:52:37 -0700 Message-Id: <20240325175248.1499046-4-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240325175248.1499046-1-linux@roeck-us.net> References: <20240325175248.1499046-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-kselftest@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. Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Reviewed-by: Kees Cook Signed-off-by: Guenter Roeck --- - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option lib/kunit/Makefile | 7 +- lib/kunit/backtrace-suppression-test.c | 104 +++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 lib/kunit/backtrace-suppression-test.c diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile index 545b57c3be48..3eee1bd0ce5e 100644 --- a/lib/kunit/Makefile +++ b/lib/kunit/Makefile @@ -16,10 +16,13 @@ endif # KUnit 'hooks' and bug handling are built-in even when KUnit is built # as a module. -obj-y += hooks.o \ - bug.o +obj-y += hooks.o +obj-$(CONFIG_KUNIT_SUPPRESS_BACKTRACE) += bug.o obj-$(CONFIG_KUNIT_TEST) += kunit-test.o +ifeq ($(CCONFIG_KUNIT_SUPPRESS_BACKTRACE),y) +obj-$(CONFIG_KUNIT_TEST) += backtrace-suppression-test.o +endif # string-stream-test compiles built-in only. ifeq ($(CONFIG_KUNIT_TEST),y) diff --git a/lib/kunit/backtrace-suppression-test.c b/lib/kunit/backtrace-suppression-test.c new file mode 100644 index 000000000000..47c619283802 --- /dev/null +++ b/lib/kunit/backtrace-suppression-test.c @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * KUnit test for suppressing warning tracebacks + * + * Copyright (C) 2024, Guenter Roeck + * Author: Guenter Roeck + */ + +#include +#include + +static void backtrace_suppression_test_warn_direct(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(backtrace_suppression_test_warn_direct); + + START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_direct); + WARN(1, "This backtrace should be suppressed"); + END_SUPPRESSED_WARNING(backtrace_suppression_test_warn_direct); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(backtrace_suppression_test_warn_direct), 1); +} + +static void trigger_backtrace_warn(void) +{ + WARN(1, "This backtrace should be suppressed"); +} + +static void backtrace_suppression_test_warn_indirect(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(trigger_backtrace_warn); + + START_SUPPRESSED_WARNING(trigger_backtrace_warn); + trigger_backtrace_warn(); + END_SUPPRESSED_WARNING(trigger_backtrace_warn); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(trigger_backtrace_warn), 1); +} + +static void backtrace_suppression_test_warn_multi(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(trigger_backtrace_warn); + DEFINE_SUPPRESSED_WARNING(backtrace_suppression_test_warn_multi); + + START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_multi); + START_SUPPRESSED_WARNING(trigger_backtrace_warn); + WARN(1, "This backtrace should be suppressed"); + trigger_backtrace_warn(); + END_SUPPRESSED_WARNING(trigger_backtrace_warn); + END_SUPPRESSED_WARNING(backtrace_suppression_test_warn_multi); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(backtrace_suppression_test_warn_multi), 1); + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(trigger_backtrace_warn), 1); +} + +static void backtrace_suppression_test_warn_on_direct(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(backtrace_suppression_test_warn_on_direct); + + if (!IS_ENABLED(CONFIG_DEBUG_BUGVERBOSE) && !IS_ENABLED(CONFIG_KALLSYMS)) + kunit_skip(test, "requires CONFIG_DEBUG_BUGVERBOSE or CONFIG_KALLSYMS"); + + START_SUPPRESSED_WARNING(backtrace_suppression_test_warn_on_direct); + WARN_ON(1); + END_SUPPRESSED_WARNING(backtrace_suppression_test_warn_on_direct); + + KUNIT_EXPECT_EQ(test, + SUPPRESSED_WARNING_COUNT(backtrace_suppression_test_warn_on_direct), 1); +} + +static void trigger_backtrace_warn_on(void) +{ + WARN_ON(1); +} + +static void backtrace_suppression_test_warn_on_indirect(struct kunit *test) +{ + DEFINE_SUPPRESSED_WARNING(trigger_backtrace_warn_on); + + if (!IS_ENABLED(CONFIG_DEBUG_BUGVERBOSE)) + kunit_skip(test, "requires CONFIG_DEBUG_BUGVERBOSE"); + + START_SUPPRESSED_WARNING(trigger_backtrace_warn_on); + trigger_backtrace_warn_on(); + END_SUPPRESSED_WARNING(trigger_backtrace_warn_on); + + KUNIT_EXPECT_EQ(test, SUPPRESSED_WARNING_COUNT(trigger_backtrace_warn_on), 1); +} + +static struct kunit_case backtrace_suppression_test_cases[] = { + KUNIT_CASE(backtrace_suppression_test_warn_direct), + KUNIT_CASE(backtrace_suppression_test_warn_indirect), + KUNIT_CASE(backtrace_suppression_test_warn_multi), + KUNIT_CASE(backtrace_suppression_test_warn_on_direct), + KUNIT_CASE(backtrace_suppression_test_warn_on_indirect), + {} +}; + +static struct kunit_suite backtrace_suppression_test_suite = { + .name = "backtrace-suppression-test", + .test_cases = backtrace_suppression_test_cases, +}; +kunit_test_suites(&backtrace_suppression_test_suite); + +MODULE_LICENSE("GPL"); From patchwork Mon Mar 25 17:52:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 782414 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 E9D29129E8C; Mon, 25 Mar 2024 17:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389186; cv=none; b=INDGjQC4mjq2Ba9+PM0vRd1msCbNUXqPAW8VOvMo3W9Kvk8tf5fb4NZJDb+WoJP3RPlL4Gq6EnDAv4xvZaff0fT4kwZa2/XrWp7BdbbeIrxnkt7s99POyfv2TsM0/6B2HyIexn0wpiKFG77FXAgNZiUjGVZhgYkwnRpyWubRtjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389186; c=relaxed/simple; bh=uf1EZIzeb5JONuf8FpS2iqxmJGsd3vztWjuaJxfsGis=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IGufsxNh8OT2H0yOD+33ndQ0c4v0RidhEVMlE6VkMCca4LomtXZzg+M9pJXpIXn65X6p7cRdtGuBjmIps2cupGop4mmf6HgzZvJU9s6UARk0PvXo6mg2IGISGdBdjv9Rxz+LIhFBJeeLC02oOVXWJRyVUN+asWdP90us0ThPFqA= 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=YJRVe2dg; arc=none smtp.client-ip=209.85.216.52 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="YJRVe2dg" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-29ddfada0d0so2399395a91.3; Mon, 25 Mar 2024 10:53:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711389183; x=1711993983; 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=TSmEsP2HwUjZ+Kmad7RzlLHqlu7fphsCj8c3+UcbJqs=; b=YJRVe2dgQrZ1XJ005FhecXb7dt9JHkwWj0D74mWRekhYluW2iOEXBi71w/NB2C8INs brVAcSLA4SbdNtPSz2Xry+4btjafdIKPkWbqAhqX+qxSXGpJA9lFneqqqiadfrE014gt kkCOhLVzCr2BYmyR80u7akYi3sLh/AXqGLwbW3QAt19S6BluQWZZ0nef93dN2FoTB1kA cP0T4xzKy1w1x+0uR8w7a2E3RE5MXNPHMqaNJEDtkXE3ktAjnaABpIiAT+uviyjwud41 MAbJniUZRHxXD605hzDfrJYmXGBWFBB4PFu4DgcpKHtY5cG0b4DkSBoeOBdFNoDQAj/f IQZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711389183; x=1711993983; 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=TSmEsP2HwUjZ+Kmad7RzlLHqlu7fphsCj8c3+UcbJqs=; b=pS6bHXExLKzBbxV76bEm5WQht82fks9W7gT+1uwqdXQ/t+EGKfnfX/waYiBHa4WPn1 fUEgKo97s3OOawYfPkbVZfN7OjPgGDFSbmnURVJghhSSTQIWzgU60/RBSGFX98OlUmcP 88MplRdfrLfqBOdXbPrlsHkgODIWkD+oGB9u5mBEGcaPTfniNY/YJfHoZ79oeLOrf0SV L499K/5ZrVEcqdETPecc6leGxlLg8e1qFMGk+hBAsUpGoOmW6bWttc7h6+gI3rQFRe5b UBwcdrJfUs+F0gKlRir46MOStoUgpzWv9l/5nhKbt1iXidqcfeOr+dVbwZrfPThmiFSL SIHw== X-Forwarded-Encrypted: i=1; AJvYcCVEvWLdgouQCGr58JjrndNswEShCyWmFbIkLtEtWngSNX9d4eL2E8NLJJ590cp3xFj+OcpL28dcMAh80uFacbmVLSJxGcYpVjz4p9kccy4nntC8wPWFtO2zTCutEtFCU/f4IEaXpN8GvTOGqcfEUMlu0slyS9LYMcbCa2eH2v+LL1pOqKQKb11dlke/EpkucXcW7dnDaLeRblekYc22hGNSubpyylJqqg2GOasDVf4zyorKV4qQ3hAKFMEOsp5KWVTqTOZs8XT44HipH8+4Rs0D6z/RXmVV0wSmWZNyANYE+a6v62T0J1NuF27v68RuvQ== X-Gm-Message-State: AOJu0YzE6+Ez8hD3yh0ZRirgfwNzEacnja6LNyw9hlzeeQb2BeqtKWvt hHLa6cPtkalXgPtINDIdmUB+hifhKMB3rcTAWoPTsaNprjSpBi6bHMzvBRIo X-Google-Smtp-Source: AGHT+IEVej1vJgDHyMhirxlQLl4uccA8YOz8D7GQmS3E1f+SiDCdIFMWODSUkw2joL6x2b4cQW8ruw== X-Received: by 2002:a17:90a:a88a:b0:2a0:486e:780a with SMTP id h10-20020a17090aa88a00b002a0486e780amr504319pjq.15.1711389183399; Mon, 25 Mar 2024 10:53:03 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id r12-20020a17090ad40c00b0029c68206e2bsm6603983pju.0.2024.03.25.10.53.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:53:02 -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@vger.kernel.org, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v2 05/14] drm: Suppress intentional warning backtraces in scaling unit tests Date: Mon, 25 Mar 2024 10:52:39 -0700 Message-Id: <20240325175248.1499046-6-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240325175248.1499046-1-linux@roeck-us.net> References: <20240325175248.1499046-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-kselftest@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. Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Signed-off-by: Guenter Roeck Acked-by: MaĆ­ra Canal --- - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags 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 Mon Mar 25 17:52:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 782413 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 359A312EBC4; Mon, 25 Mar 2024 17:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389189; cv=none; b=LXlG0mlgm6j4w96P6VtLNeSCwZUXINVAcvn9NTU7PuU1bkjN/0gDKtfjWUdvewbAadHeAZEDQfcCSWREI8heIKh6FnVY2GTT3vcKqZV/RzrxDGMlOHenDfbB3VQ7zYkngoqghquuFwJ2A16JvLjZvaBj7aJxVrLI1hev0BoBp5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389189; c=relaxed/simple; bh=ujryoIXyOtMv7CZgaU8c13DgnsRbrFmRRwvyIDKligc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rjVN9FsK4tIvftWNJHcqumGXZOV0nFVAp55qoi9J+wNN6/uQIv5qwzSX8DZlBxVaJYoRDIs2eIo+CTs4ZV77O6l/FM8K7kL5Xp0a5z3MNDGlZpujb96cOe4JE5aX5YHfyexWZ/WQ4940ipCRt35KP3WPkTDWk/1Hi+JcZUGi82U= 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=QUsU/fmX; arc=none smtp.client-ip=209.85.216.49 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="QUsU/fmX" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-29fa10274e5so3094472a91.3; Mon, 25 Mar 2024 10:53:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711389187; x=1711993987; 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=NkFivhI5ysBM/6se13ha6YOC4kb+BKpi8rjyyPjulPM=; b=QUsU/fmXqkeE48JmgN7bBk1mlaaOOgWTJFbKp7ddi9iTR/OJ0SAdgxctZFrNI3UThH wuymsClvLGzIZQXI91lU+mwFBTQy1fUuFt3QR2aio4l1cZIY5DALrpwPx2Y7xESC1a/g EdmV69CgtcRaxl79iBGpvoY0m0qj3GKshVAos9yUd+FD5FPv2X6wHPdBHpsjULYYK9C7 AhwRj7SjiBEnLk4imHWS8WTXTjTseKPLGExvo2Zt5/d7OiA0HnheQEB18ELgE7ySC3UA a2fsrBbWnChsyKNei8dYMytyG3ql1kbfOpDZg0tlOEjikuxEruxZzeAMnceuWGzCWJxJ RLcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711389187; x=1711993987; 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=NkFivhI5ysBM/6se13ha6YOC4kb+BKpi8rjyyPjulPM=; b=u2Lquax49rcZljD9dhz4RPXvMoaxD7ZFvjH9hQlTEwQJu3AKJGSls+DR+3B9qzoCaq ObY8Xp5NxWH0U9NWw3FL0Oq/amridwq/xdtT1r3EKP/uLw/lnWbBQ+ZNrkwnwlNFsYNh Iq0sakHp8Cl/Si2HsFocTUdaQ+5i+3Gf4vW1zzFnW0Ou9Tn7FZSJr2+a3tG0yIcqEoAN I9tYZxWwfa62hhGhItHn5hZuYVlVFvsSqZ8SAwKvz0JnoGwsDQ+spvN5ZFaZdJ6sVOOs zElX8UZ6JL/Bg6SI+WWQa5WNr3uzHtc0Kde6eFZosLXsMD1hgPKS0Wo62TSAYUXI3JdW pVkA== X-Forwarded-Encrypted: i=1; AJvYcCU9O3qzTRwfYPXh8qMJXZwI0gHFoUSifzdoC1QAEO2O9dlGPECucxsNHFxKLFkPmEv5E1P8tHpalP7vf4Bf+0LOGENmWI86toqxT1zXlgz4RMy+c1el+olAMY1X0tW/GFLKycSxaibBgytiZ7pPJjaWfTXOE9t7XhA+U0orp7yifNUU4KZpIsDQBFYzo+iSemVG4Dt1Ar0RK0mtPJIhhFXWqDqRlT8DdgZ8aVf4wboF4YLRR9CKmtpDbJCkVB+TuRdnlBRoI+IbUQOqsGlpwmRRPD4GjtYVyAXh6k6xxY3NSBnYnXuwjBjjvSxPSGoSoA== X-Gm-Message-State: AOJu0YxnS5QPk9BMLP0akjdnWKJJjRLPvhQ2fNgWMZkFui5oUKKW/E31 Mca24Lf+R5Z9BdytOyCoNolx0uTzFpp/FlJ+Kk6FefPyaMgibrB2jqGUEENK X-Google-Smtp-Source: AGHT+IGbs92c//BGiqmdUL4T55P2X9QmdN/SfOH2hxAjReRZ1Fd5UIZ7am79FuHHvN6tgafQ9jOuwg== X-Received: by 2002:a17:90b:3005:b0:29d:fe93:52ac with SMTP id hg5-20020a17090b300500b0029dfe9352acmr5131747pjb.13.1711389186749; Mon, 25 Mar 2024 10:53:06 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id u2-20020a17090ae00200b0029c693a1e6dsm6784603pjy.17.2024.03.25.10.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:53:06 -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@vger.kernel.org, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v2 07/14] x86: Add support for suppressing warning backtraces Date: Mon, 25 Mar 2024 10:52:41 -0700 Message-Id: <20240325175248.1499046-8-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240325175248.1499046-1-linux@roeck-us.net> References: <20240325175248.1499046-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-kselftest@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_SUPPRESS_BACKTRACE and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Signed-off-by: Guenter Roeck --- - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option arch/x86/include/asm/bug.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index a3ec87d198ac..7698dfa74c98 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -23,18 +23,28 @@ #ifdef CONFIG_DEBUG_BUGVERBOSE +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%c1) +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC_PTR +# define __BUG_FUNC NULL +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + #define _BUG_FLAGS(ins, flags, extra) \ do { \ asm_inline volatile("1:\t" ins "\n" \ ".pushsection __bug_table,\"aw\"\n" \ "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \ - "\t.word %c1" "\t# bug_entry::line\n" \ - "\t.word %c2" "\t# bug_entry::flags\n" \ - "\t.org 2b+%c3\n" \ + "\t" __BUG_FUNC_PTR "\t# bug_entry::function\n" \ + "\t.word %c2" "\t# bug_entry::line\n" \ + "\t.word %c3" "\t# bug_entry::flags\n" \ + "\t.org 2b+%c4\n" \ ".popsection\n" \ extra \ - : : "i" (__FILE__), "i" (__LINE__), \ + : : "i" (__FILE__), "i" (__BUG_FUNC), "i" (__LINE__),\ "i" (flags), \ "i" (sizeof(struct bug_entry))); \ } while (0) @@ -80,7 +90,8 @@ do { \ do { \ __auto_type __flags = BUGFLAG_WARNING|(flags); \ instrumentation_begin(); \ - _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ + if (!IS_SUPPRESSED_WARNING(__func__)) \ + _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ instrumentation_end(); \ } while (0) From patchwork Mon Mar 25 17:52:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 782412 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 754BB136E05; Mon, 25 Mar 2024 17:53:12 +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=1711389194; cv=none; b=EeRVRvbBuDrlDRxP7MxW3I6hUPh0oGZAIw0jvW/Zacz1QfIBl/5JtukdKGQwVFXQeN4NKWIcbNsHb/kvCVbbKK8Iaad0Vc2IYsU6mmNnsC9oVA72zohNjP/YBUYWsl/x1F7dAsAOyCs1DrswxZbD84fAZtJZ2o+ioCJYoGUndmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389194; c=relaxed/simple; bh=YAKHougynNfwqGMi4/MjS3GlrbEhqsqnDH26+cm5nFU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QNWWJFb4qFIImk0QI6WkhcOnUwXyfmmh9MgiY7zO5gBV0PvS+zsbK+chCABqt/PxZ72U7i3cD0LLp57RrCx1+yvkv+qvXGbrX1kOYPZy+G0UBRQ3oBMUi9xRgPCSCyNBdVM3KgWbl9nS+PtUdK1EeO4JmCq8lQtN5x00ovXa7oI= 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=V0JWh8VF; 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="V0JWh8VF" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1de0f92e649so32341225ad.0; Mon, 25 Mar 2024 10:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711389191; x=1711993991; 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=dtwUXE+IqNuorT54j0aaEA4aHeW6X4Zjm5IQoCcbGI8=; b=V0JWh8VF4gxuq2NuB7k6Uy1c4Aqts3f45IYMMURGaqfcNHAU+rSyokBOKcC1YZIRLK tuPklJLRe++uxpb0EHzumDE49yowK7Op6PLTuoJZu/g9701APIu8db2ZSGtIdEoy1AY2 5SZF//Q8WFu+szvAAgBR02/qM8MUDmI7yo59+l1W/Uk0DPVvIib+/uOQCQyJmJkj6RqJ K7UAYpMnX3Mu67VWw2K3hbfakFPzbbUC8Yoq58M0g/2tDO92G6Cp/AdfAdOQL7ZQgctI QJ1x0Oguz3LnH4C03d1M9CRuvj0gs2vvHW4uVkATWMqRFNZ9hdJ9lRAF1dgzUFPsmjRo nfiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711389191; x=1711993991; 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=dtwUXE+IqNuorT54j0aaEA4aHeW6X4Zjm5IQoCcbGI8=; b=DSep/drpZtHl9CXxwL4lqhZI1WzPjQuCHIJQBhS8jwGmnMspVifJEyPMeQZA+SXToF cuMASPLTrMFWYl8qakjKiCBQiemMiEQsAe/C4V8dmtrsUZU6NDmDG/2MajqMGfgg6Djb txY+F8UmQFYaYH/9+W/doVIuX7wER/wf7GYYHdnPhg+9iYsbbmsqnqMEdVI2+l7TMoVl llwPVZ6NDsrd7wPlP0hYE2rQiNxsDHBbbWNJqHmTZzfns58sMzy1WmSBD2vpEcvD9Dpv Zl3mIi8b7/YxTIq+97zIpbkkf9BD9ChWEin/ULPGi72ZfFbDnpUciKn23eqGYO+rvdDa Sr5g== X-Forwarded-Encrypted: i=1; AJvYcCUeHarzO0gHSIpUVW7T5LDO1d9w+Bfd5vAbZtvNi8RIuSixIUlZW6CardSu1VfZBZAritdOXnFxL8iqbdKFl6O00zGmdRTSNpCuZGmCfwMWCiddf6f9QUqJLGApfK2TKlBvhIVyHHvmAoFFWdR86gAUzHtF9xWifBHQwxWXaiDGLmqnQIVc81bFhUIw98HGsT4ETalQYUMur3rkX2BX5lU50hcQ0whqKXsm1gfZDL5wgWQtSIo7iMWJ6HSccmwNERqH3ixySbbEMNTr+vysimmr8Q+dVOlDszG/fo3HiYFm5Et3aAENht3Gw4me6crtzg== X-Gm-Message-State: AOJu0YxPh6UdToWy4TxAMJunYdpFgrMlHHHq1q0g7Uv1xhmIVSsLrV4B jltnSsYJsCqCqmX4KdcTwIGoO5g3hizdNrKzw6KarbvoBlI4E9dR4obQNMuA X-Google-Smtp-Source: AGHT+IFgb86jAL+eLx1VucoqIZk09YlvJLM+FeVnRGQ5UPNHQryATu5Oxjm2FFfuTD/AWoK6+BajtA== X-Received: by 2002:a17:902:f548:b0:1e0:94a1:95c1 with SMTP id h8-20020a170902f54800b001e094a195c1mr530124plf.29.1711389191372; Mon, 25 Mar 2024 10:53:11 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id l5-20020a170902f68500b001dda64281a9sm4953716plg.85.2024.03.25.10.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:53:10 -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@vger.kernel.org, Guenter Roeck , Linux Kernel Functional Testing , Helge Deller Subject: [PATCH v2 10/14] parisc: Add support for suppressing warning backtraces Date: Mon, 25 Mar 2024 10:52:44 -0700 Message-Id: <20240325175248.1499046-11-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240325175248.1499046-1-linux@roeck-us.net> References: <20240325175248.1499046-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-kselftest@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_SUPPRESS_BACKTRACE and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). While at it, declare assembler parameters as constants where possible. Refine .blockz instructions to calculate the necessary padding instead of using fixed values. Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Acked-by: Helge Deller Signed-off-by: Guenter Roeck --- - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option arch/parisc/include/asm/bug.h | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/arch/parisc/include/asm/bug.h b/arch/parisc/include/asm/bug.h index 833555f74ffa..b59c3f7380bf 100644 --- a/arch/parisc/include/asm/bug.h +++ b/arch/parisc/include/asm/bug.h @@ -23,8 +23,17 @@ # define __BUG_REL(val) ".word " __stringify(val) #endif - #ifdef CONFIG_DEBUG_BUGVERBOSE + +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%c1) +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC_PTR +# define __BUG_FUNC NULL +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + #define BUG() \ do { \ asm volatile("\n" \ @@ -33,10 +42,12 @@ "\t.align 4\n" \ "2:\t" __BUG_REL(1b) "\n" \ "\t" __BUG_REL(%c0) "\n" \ - "\t.short %1, %2\n" \ - "\t.blockz %3-2*4-2*2\n" \ + "\t" __BUG_FUNC_PTR "\n" \ + "\t.short %c2, %c3\n" \ + "\t.blockz %c4-(.-2b)\n" \ "\t.popsection" \ - : : "i" (__FILE__), "i" (__LINE__), \ + : : "i" (__FILE__), "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (0), "i" (sizeof(struct bug_entry)) ); \ unreachable(); \ } while(0) @@ -58,10 +69,12 @@ "\t.align 4\n" \ "2:\t" __BUG_REL(1b) "\n" \ "\t" __BUG_REL(%c0) "\n" \ - "\t.short %1, %2\n" \ - "\t.blockz %3-2*4-2*2\n" \ + "\t" __BUG_FUNC_PTR "\n" \ + "\t.short %c2, %3\n" \ + "\t.blockz %c4-(.-2b)\n" \ "\t.popsection" \ - : : "i" (__FILE__), "i" (__LINE__), \ + : : "i" (__FILE__), "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (BUGFLAG_WARNING|(flags)), \ "i" (sizeof(struct bug_entry)) ); \ } while(0) @@ -74,7 +87,7 @@ "\t.align 4\n" \ "2:\t" __BUG_REL(1b) "\n" \ "\t.short %0\n" \ - "\t.blockz %1-4-2\n" \ + "\t.blockz %c1-(.-2b)\n" \ "\t.popsection" \ : : "i" (BUGFLAG_WARNING|(flags)), \ "i" (sizeof(struct bug_entry)) ); \ From patchwork Mon Mar 25 17:52:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 782411 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.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 8558813AA3A; Mon, 25 Mar 2024 17:53:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389197; cv=none; b=bDo8KZlN1Khe5b2VpJMAqJNxSZgUIsjFJTbR4PmhRBvhpEsXcgom2ep+Cr38iqTVZTUAHX5QhO9r8Otv+zgfq9JfhexlLgK3UPawgln83mFgcDg8ay/qLov75GxW0I7x18ITZ7cezL6QRuGcgo0djIGR71syTp0xrNj/K3U7fr0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389197; c=relaxed/simple; bh=A5b2LvLAMqDa3tfzhsOvBq7xlErnTWSCJfRbwCKdC64=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=exm/lxBUEYzHhbt3VsX5/mjsLj1AGE3r+pQmcfh1BLeqI4qBg4tyHOqKWw+3pp8AwBG5NpPWpApdMTHQlfjykzIjgxyVseVplkmmJGop7O/n/1Pa+cRRx6YRNb7fyYwyfx044HekB4Mlaeds8mlOD20YdfDJO425Prt2rTNAnHg= 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=KO2ez7Sv; arc=none smtp.client-ip=209.85.161.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="KO2ez7Sv" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-5a51c063f99so1241683eaf.0; Mon, 25 Mar 2024 10:53:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711389193; x=1711993993; 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=ND8lqpveiFX6xmjgwVdwzXmzEkzcSSVNG8THPWMqf7Y=; b=KO2ez7SvA8oZa2/jMC0bYxgzzv0dDoH+jg254UpIDdTW1/Eqb4dhzi81TXicRbYVSQ QMv5qSlFfPCBtuer/crkXnPBw59RirHhMnCmU1FpnD/1la+KwqXBeYNThRB6JX6JIYuk EjxQnydwDZW4SGfsgjdeLSjTU48BLvot6A9xchoHoatEN2VpemY6ceIzYcTB/Py1yqrj 0aUwPkjS5bB8WbSq2kqWapsSpNT8itK33e7dmOcpy+wlS3fxYEtlt+2GcijByF0D0s0f Ss8o4NHqYBwUVZjvK62eXjrdIvzrS3XcFsNJIM1r9/JQ35Sp2XLNR14wgU2oKLVRnfG+ wX7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711389193; x=1711993993; 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=ND8lqpveiFX6xmjgwVdwzXmzEkzcSSVNG8THPWMqf7Y=; b=IAc5ca7gFSgQyH2Op1dhuj3Xt3Vle35fEEEQRHxvpDJ/lHtJeYBS1AcFXdS7LQKrxM 1wqQ39yNogLfs0o/MNURsKUuKEGJThCC+S2HgHX4OjmsQZDGS/MmWxMKGpBWfKhegH2g DZd3SCD5cA/TgcGpFnhzt3LgAFJhfMOLfel4KRYkw3puoA0bAEc1eSUIP6tuIfN1Qp6I Oi++y0AhVSGXzwkFRDb6Dt2e9MRjUyLdPWfvubPzE42xvtS2RIxQIeppV69xKAGRrVBL 8sq7KCnDBSGxCK5Uh7UuyIIAAq8HqTeSiOFCAwopE2ezEHhJHNTwRvw3WlJHHaNScJ+F hZ/w== X-Forwarded-Encrypted: i=1; AJvYcCWM73GPnshGsRF9bgb32IrfU27BoHit2IqPx4MDYhirjYCk3nmgXaQBExZ+jGdAY5C/vpqE0g3FdAKPWwPQosVC/wt3z1sNhR2Pj1RAxnroDkbg6QDhNtd7Zd6CSWe9arMtR5MaYlJtOVL4c8OOph+kjV1Z0SuHsaLge0JnojtssxA1mstWjkfnHNsy/Ss+yRNBHnOxxBaxwk9NBE0q0l9e7tTUJdPc5svvpQ07HxO/IRPmKZzTiH7qD6RP8MPubFVX6eCZOFh0QNaiItDHlKNufczUdOMueyOy2j/8S5PGeusHaoN5duEm0soAxPyEFQ== X-Gm-Message-State: AOJu0YzXLAXFBWtiFsaHNlaZdh3bIjyFFS5x5lgE0fysGEEQazMiofZi 3GRNqEH6ZTYUr7CXztMXcfaRRQNz6PDZtR9IRMpsAqpg4Yyn7VbHoZKBhFJy X-Google-Smtp-Source: AGHT+IGv1aIgA06o9Fu8TIRgx/HOB3QdMC5g6WhXly0xhlmCYycmN3i4bcD6kTp8Utc1wDwGC1lc7A== X-Received: by 2002:a05:6358:fac6:b0:17f:729a:8562 with SMTP id ts6-20020a056358fac600b0017f729a8562mr2827009rwb.3.1711389192937; Mon, 25 Mar 2024 10:53:12 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id w189-20020a6362c6000000b005e438ea2a5asm6051492pgb.53.2024.03.25.10.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:53:12 -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@vger.kernel.org, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v2 11/14] s390: Add support for suppressing warning backtraces Date: Mon, 25 Mar 2024 10:52:45 -0700 Message-Id: <20240325175248.1499046-12-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240325175248.1499046-1-linux@roeck-us.net> References: <20240325175248.1499046-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-kselftest@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_SUPPRESS_BACKTRACE and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Signed-off-by: Guenter Roeck --- - Rebased to v6.9-rc1 (simplified assembler changes after upstream commit 3938490e78f4 ("s390/bug: remove entry size from __bug_table section") - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option arch/s390/include/asm/bug.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h index c500d45fb465..44d4e9f24ae0 100644 --- a/arch/s390/include/asm/bug.h +++ b/arch/s390/include/asm/bug.h @@ -8,6 +8,15 @@ #ifdef CONFIG_DEBUG_BUGVERBOSE +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR " .long %0-.\n" +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC_PTR +# define __BUG_FUNC NULL +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + #define __EMIT_BUG(x) do { \ asm_inline volatile( \ "0: mc 0,0\n" \ @@ -17,10 +26,12 @@ ".section __bug_table,\"aw\"\n" \ "2: .long 0b-.\n" \ " .long 1b-.\n" \ - " .short %0,%1\n" \ - " .org 2b+%2\n" \ + __BUG_FUNC_PTR \ + " .short %1,%2\n" \ + " .org 2b+%3\n" \ ".previous\n" \ - : : "i" (__LINE__), \ + : : "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (x), \ "i" (sizeof(struct bug_entry))); \ } while (0) From patchwork Mon Mar 25 17:52:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 782410 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (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 3947E137923; Mon, 25 Mar 2024 17:53:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389199; cv=none; b=LquZ38tbLkzMNP2WbfWzovE4Z4PAkcyxCVu6b8All7MIG5qFCfVc64e7X5urOkkJsPI+YZxOrCFUGuACa5B8RmgCwYrcM8hUAE32KzdAxX2LoMfUP0jr/rkWR5oHaQ+Uz0Xn0GcqrVKUTVohsqDzX14NAujEJE11FvPSb+SkEVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389199; c=relaxed/simple; bh=PWRyYNNTVSqaNxpe+46ccu4X3lA/e2YWTxFxcO7yBeg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZHcegd98n6dB+qFXKm12K4gz6Fbwu5eOZHQrXqeFseaCqtpPJoP4rAtwK+KQh7IoF4ideLDOPdzqBpCw5SnQSSrmFV+Lz7ZpR+KuYpqwzj507Da7KrjCkMRfkX3uCj9ivi1DShL3VIai0Cr0y5K/qoMfwX2Ob5wWI+4TlE526SE= 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=kyyM2TNZ; arc=none smtp.client-ip=209.85.215.182 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="kyyM2TNZ" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-5ce6b5e3c4eso2264175a12.2; Mon, 25 Mar 2024 10:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711389196; x=1711993996; 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=MnI6eL/80gG1dr8sD2qxmm+TprLGleZjKTemL3in51c=; b=kyyM2TNZoIhWmJoagcE8531p+vBD42M4SZncSl2yN90YNU3FJGaX1CllCsK89Wtimf fKo9hdAiXniHieSxKg7eD4thCdwQAC2O0rvU2k/RZLEByFYeQgQ354ijCOuBZWLoIBdj AJxlt+Iu/5EVnVrkleSJpUlUKOx/8QDO78NQbKs+2CdGG5MER/d5vooqVvdcrtjCXLGs Ri8DV8vfhzPeIjCblk7DWgI5WAYFllDcJhPZvfwc3vfbLSAuSLmpiGiUs78weXbQAP+h 00zkFKP/gRgUqvAwouf0l7vS8r+3kzf6R2FQSGnEt6ATKvojwbohSI4QMhvPAv0b7juo UtHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711389196; x=1711993996; 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=MnI6eL/80gG1dr8sD2qxmm+TprLGleZjKTemL3in51c=; b=ReKKIJPrdR6aQY2Gv/wT9jfeIjsVzSsAF6HfTTdMz8fivmMtCw0w53BD+DLyUMxgUa skoaqmMwBpTVqoNgAuQxko/pri6YxOWh2LbMphTa8hFsENk3djJhm3IbyiLjcf4mFyOs oswbBk1U9ik/GtjZL+ayFag++ozdGiRmxGozK/q/w9vhV/JeW9rtABPwfypWjrEiID9y BzHjbYJr9FKXc8s4+dBNqhs2vgPZjHrPL9WfNjDStaNdHCXsSlrfGNUHto9mLoWoweos OtDCaxRrIDRtT48rfFIILI+mrW9ieWh9YRebI6NtXYjKZ/EaDy0llUZxp8sGH2JgGzNI fhNA== X-Forwarded-Encrypted: i=1; AJvYcCW9RFAI0qX1SHsFLX6xVZ9uRLrv6NjbAAFQszWzEzlaFQyV1YQn/huNlfTXIKSdZdQdzMlalpLM2DsG22zX2Or+PL4qdkK7UTb4PAKK8ivlcNkLpx5Wc1W6+gOQY5BN5Yk9/KBcfitgX+bo+1NffZnyxIGmYiTC8LR0FDWt5OqMNqC8yIjqMnqNhTvo8eQmlJAdAsIifFOsL4uZlKJSDGYnRVZ4/BWtVhXWlgUM5x5tLrYdw8QD/LSwUEUZR5mHiXBTieTmsjaF2CmTJvez+g7ukHOvfZ4o47Dx6FnOzq7GtaVIm3N4DQ0wqqOjRmHHaA== X-Gm-Message-State: AOJu0Yxb2RnYnWy2K9h0vEIFbmbBpFZZ8GivMlSjC8BUt4jYSwXd1N06 QubBk36ZMQhuoyD/5JUCejiO9uQzcUqDdx7KZO7bNL4tAuzaWlQSdb3+SR8G X-Google-Smtp-Source: AGHT+IHmG43u1pjyB8NBsXBypuvw9vgspS+EVnSj7EhdYOTyM3AqirrFZJgzW3g0aAbgHMabNWrpgg== X-Received: by 2002:a17:90a:ec8d:b0:2a0:718a:8e49 with SMTP id f13-20020a17090aec8d00b002a0718a8e49mr2291608pjy.39.1711389196182; Mon, 25 Mar 2024 10:53:16 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id px8-20020a17090b270800b002a0544b81d6sm4083933pjb.35.2024.03.25.10.53.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:53: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@vger.kernel.org, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v2 13/14] riscv: Add support for suppressing warning backtraces Date: Mon, 25 Mar 2024 10:52:47 -0700 Message-Id: <20240325175248.1499046-14-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240325175248.1499046-1-linux@roeck-us.net> References: <20240325175248.1499046-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-kselftest@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_SUPPRESS_BACKTRACE and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). To simplify the implementation, unify the __BUG_ENTRY_ADDR and __BUG_ENTRY_FILE macros into a single macro named __BUG_REL() which takes the address, file, or function reference as parameter. Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Signed-off-by: Guenter Roeck --- - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option arch/riscv/include/asm/bug.h | 38 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h index 1aaea81fb141..79f360af4ad8 100644 --- a/arch/riscv/include/asm/bug.h +++ b/arch/riscv/include/asm/bug.h @@ -30,26 +30,39 @@ typedef u32 bug_insn_t; #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS -#define __BUG_ENTRY_ADDR RISCV_INT " 1b - ." -#define __BUG_ENTRY_FILE RISCV_INT " %0 - ." +#define __BUG_REL(val) RISCV_INT " " __stringify(val) " - ." #else -#define __BUG_ENTRY_ADDR RISCV_PTR " 1b" -#define __BUG_ENTRY_FILE RISCV_PTR " %0" +#define __BUG_REL(val) RISCV_PTR " " __stringify(val) #endif #ifdef CONFIG_DEBUG_BUGVERBOSE + +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%1) +#else +# define __BUG_FUNC_PTR +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + #define __BUG_ENTRY \ - __BUG_ENTRY_ADDR "\n\t" \ - __BUG_ENTRY_FILE "\n\t" \ - RISCV_SHORT " %1\n\t" \ - RISCV_SHORT " %2" + __BUG_REL(1b) "\n\t" \ + __BUG_REL(%0) "\n\t" \ + __BUG_FUNC_PTR "\n\t" \ + RISCV_SHORT " %2\n\t" \ + RISCV_SHORT " %3" #else #define __BUG_ENTRY \ - __BUG_ENTRY_ADDR "\n\t" \ - RISCV_SHORT " %2" + __BUG_REL(1b) "\n\t" \ + RISCV_SHORT " %3" #endif #ifdef CONFIG_GENERIC_BUG +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif + #define __BUG_FLAGS(flags) \ do { \ __asm__ __volatile__ ( \ @@ -58,10 +71,11 @@ do { \ ".pushsection __bug_table,\"aw\"\n\t" \ "2:\n\t" \ __BUG_ENTRY "\n\t" \ - ".org 2b + %3\n\t" \ + ".org 2b + %4\n\t" \ ".popsection" \ : \ - : "i" (__FILE__), "i" (__LINE__), \ + : "i" (__FILE__), "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (flags), \ "i" (sizeof(struct bug_entry))); \ } while (0)