Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2702482lqz; Wed, 3 Apr 2024 06:22:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUiI6Q1jiL3I5kjzx6UMxG+qTEPXObmhH0XiGhQB4PvfFMRp/iNtajGnb+DQEpIUOv9FLuzNG2FWIaUhXtVgFIF6FKwvKnvdLi2TtTESg== X-Google-Smtp-Source: AGHT+IENOgKtqrD5Ymeo0EAPUQVehx/y/K/mC93+3OsuxQP681d860+GUeokp9Chp/lhAlvbkLrC X-Received: by 2002:a50:d6c1:0:b0:565:7ce5:abdc with SMTP id l1-20020a50d6c1000000b005657ce5abdcmr1912723edj.10.1712150564775; Wed, 03 Apr 2024 06:22:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712150564; cv=pass; d=google.com; s=arc-20160816; b=PXW/1vPifIltEWgbprsf9l8jR64JTrUA7Cg7iYpiakwufEzeVQe2tVOH0Mdj0r3hfA OCuLR0jFCKfvt2SHKF7xx44ccMLEqkKXzvMchIlDn9KmM0TfGU1wtd1jG8bKYca4mSsu DTNPcZ0Dd/GeCqDFK36UdyUBUjmvlK3PcqCaxvTUUZd8We2BPIYuOnB8br447HN74K5i UzdI10h06k/7H+RP+jrZnlmicJIekW1S/0E6irNtMaj/L83jbbGpMVAzdN9v9c4WPPC5 V856neVwAeZGlJyyz/SzEXjNo8ZxAMA4JryycbT/Okz+RqTb8ki0DaLvEfpXQUXtWiP3 wPFg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:sender:dkim-signature; bh=W4Cw0LtOjrrGR/zeu8wuFTPQ/EpLq4I/3itsXmN/APU=; fh=WBsFcA37zH2tjh9lMf3zTvlx8I75oaz7ldTu6nRLdI8=; b=JEtASvb4b+Y2I4pAbWOj9pqSHNbzLF9BOEpyDuuTXAMdv08N94nUN1RdNkSD/zZ6oQ ZoFoXirwxZAnkEFxOgAR1EjcQg19QcVK4q4m0uvzmouVsVkQQYoj0ZXA4Rhr0vmBheQT OG6BiqAYoq/sMLlieYv/4vi6QAeHAU4QRGLVpk731YAqETvYnMv+oUj6vwzxC2lijWQy mfSw07NpCrludEueF7q8TKFZSjmXiwce2jN+QpzkLFP/Wpt7ToAkyREghZ5jHijCXPux cZG27oubTccwRMFumwUT/6oGPSvbtxJgsCmBoueI5OSrO1vfe0OlBVU25DY+KnPasc82 JvlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Nu4h4TrH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-129811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129811-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id j24-20020a508a98000000b0056e045b1a37si799356edj.417.2024.04.03.06.22.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:22:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Nu4h4TrH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-129811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129811-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5A08E1F22F90 for ; Wed, 3 Apr 2024 13:22:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21FD514B063; Wed, 3 Apr 2024 13:20:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Nu4h4TrH" Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 65F9914A602; Wed, 3 Apr 2024 13:19:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712150401; cv=none; b=aC7k3kW99b5Bka3Oi3W2eSVXkRDx4QvnJmGFzKQ0IvFQUfRj8tVK65At8udJhJT2coNcHFyZ6nuuB7uWGuu3z6OhmR5HJoOA1x+Uyb4NJN7QTuF0Qg4739iHn1tjmfCa12RZlD0RgXurq9gwhUgFEC26X0DfLFC4vB0U1TE8TpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712150401; c=relaxed/simple; bh=0fLvUVIM8hMnJqHuv9ZzGmXuFPtZa8t4XuuwICdw7MQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gmxNdwFWx4d3aKpaNxzQZSTWmTnP6aDFiIMgXut1mtxm0TtPIX4Hd48gtxLzKKNsoIbxsB49E208/6r6e1kmtcT+eDDb4LzOKaiQBPDr9YHcchCj6K7L/lrSJ05wx21pps8zWE2xrxEQKZS/FbNnLNa7VvG9axmgVBxL2PDkun8= 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=Nu4h4TrH; arc=none smtp.client-ip=209.85.210.172 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 Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6e7425a6714so5223012b3a.0; Wed, 03 Apr 2024 06:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150398; x=1712755198; 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=W4Cw0LtOjrrGR/zeu8wuFTPQ/EpLq4I/3itsXmN/APU=; b=Nu4h4TrHzw6HDvBQjtBm3Axj4w4ZsmMHl984Pby1VZ7P0SJAv/VAN4KJxl3Qn1/rXf ulvJvpOVUg6WEhlIHozTuOsRI9Rxpwe8JXcPoPnt1dEwcCxRb2A0Odmqf0novqR5z8f+ 4C3w416CqqVygXZua5K9IDhuAS4Xsn5dJrJBzQ+qc1rpWrvTN2ddnn3Pje8U3AJmGhP6 dVdOk+YxUBIa1oXbTgI7iCxDoivyhSXlZG6kDGpqtYJn8OYTVLkq5eBpX06Y4h76uQ65 RUKPep/yh4YS0nvJKaU1A+3XSnMwz6O0aA46ypYp6j8zrL6OBb7R5bD84e7iwD6iN154 3FPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150398; x=1712755198; 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=W4Cw0LtOjrrGR/zeu8wuFTPQ/EpLq4I/3itsXmN/APU=; b=JlUWaeJch2h1jenU2gzuzukIPAtHUyzE/ah1oxY3fGOl6gpAn+N8ZSaCDQL/yKDGtz cR6IJeaB+AwKGftMftOFmHJyDk8Czmvuj4YIeWBQOEgMxxR/89FgBVGhdxivdmbJKZy9 4G2L7yKgLpb2GUhwwLQgCX2ZK38gipGmAt1N2qMjq6EzHklIZ637JuFdsX0Jp1yiNYY6 ULzeEuCAc3mV1LFEvgIb/7tjVNm3lxB8dtN20YyUyCed3Cvtlk4XANoikM4f7iqz2yhm POXO4t0/79fTKJbEqLYMV6XKL0UnkljbTS5wpszyj2ROUurrLm+7FSVyvCYWIjsNCbYU pM8w== X-Forwarded-Encrypted: i=1; AJvYcCWskwg6iFlsXWTN9vpJOEtZzi4UDZJNIhdBWsqVEt14ut2xidLtCbN7B3fi6nnJYszN6wirixNs1JJEMGdFfInfQP4c1LAe64pFQVId4+Ru4w8X/RJrhNwQPZuO/0COPGVckeeSTXL2xjdrcd7BluBd+j5zVlMwhDqlUXvr51JruJjWe3/4+lDtVmYdWpBZfpj1QkZJUh1RbVK7n17mIaCxCnDh8vfuHB0IerGqCmSquRs+RMEXjXJi0Dons9WsRTSo4d1EZlO8IMenLVrYcdxiamJnkfzsfj5D6QmHg4xQG6IulW3NfnIpfCMEaw7w/Q== X-Gm-Message-State: AOJu0Yx+MDsUFGPnmZQCO/q2LQ6SesPelNK1L+BWLmByv33Gx0XsKL6z vLm70lFxUn44yNXF5b/WGYIQDWuVoggkuBDnEkPc3O6yrd+Um4uPoooUlQrK X-Received: by 2002:a17:903:41c4:b0:1e0:a0d5:1d23 with SMTP id u4-20020a17090341c400b001e0a0d51d23mr17965782ple.29.1712150397884; Wed, 03 Apr 2024 06:19:57 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id i10-20020a17090332ca00b001e0f504a74csm13199577plr.269.2024.04.03.06.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:19:57 -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=20Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , 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, x86@kernel.org, Guenter Roeck , Linux Kernel Functional Testing , Huacai Chen Subject: [PATCH v3 09/15] loongarch: Add support for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:30 -0700 Message-Id: <20240403131936.787234-10-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240403131936.787234-1-linux@roeck-us.net> References: <20240403131936.787234-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add name of functions triggering warning backtraces to the __bug_table object section to enable support for suppressing WARNING backtraces. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT_SUPPRESS_BACKTRACE and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Cc: Huacai Chen Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1; resolved context conflict - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2; resolved context conflict 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 08388876ade4..193f396d81a0 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) \ +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR(func) .long func - .; +#else +# define __BUG_FUNC_PTR(func) +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + +#define __BUGVERBOSE_LOCATION(file, func, line) \ .pushsection .rodata.str, "aMS", @progbits, 1; \ 10002: .string file; \ .popsection; \ \ .long 10002b - .; \ + __BUG_FUNC_PTR(func) \ .short line; -#define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line) +#define _BUGVERBOSE_LOCATION(file, func, line) __BUGVERBOSE_LOCATION(file, func, line) #endif #ifndef CONFIG_GENERIC_BUG -#define __BUG_ENTRY(flags) +#define __BUG_ENTRY(flags, func) #else -#define __BUG_ENTRY(flags) \ +#define __BUG_ENTRY(flags, func) \ .pushsection __bug_table, "aw"; \ .align 2; \ 10000: .long 10001f - .; \ - _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ + _BUGVERBOSE_LOCATION(__FILE__, func, __LINE__) \ .short flags; \ .popsection; \ 10001: #endif -#define ASM_BUG_FLAGS(flags) \ - __BUG_ENTRY(flags) \ +#define ASM_BUG_FLAGS(flags, func) \ + __BUG_ENTRY(flags, func) \ break BRK_BUG -#define ASM_BUG() ASM_BUG_FLAGS(0) +#define ASM_BUG() ASM_BUG_FLAGS(0, .) + +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif #define __BUG_FLAGS(flags) \ - 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)); \ annotate_reachable(); \ instrumentation_end(); \ } while (0) -- 2.39.2