From patchwork Tue Mar 5 18:40:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13582865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 488C7C54798 for ; Tue, 5 Mar 2024 18:41:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p7NQBRROmRE2L32T6oSoRSn+/WsoC6/Yr8hGA7E1m7o=; b=RjisQr6EZyQrum l+bhNW8o+mmU9MzOLTyuRvfi3nE62MVaacBGjEBW6ZxcdGscqxZepGa0B4urfv/JwvkLGSFiBQsI2 Ykpz+Aaa4/Ug8yVVsDx/SYr5+DWxNtypaX1CLPnEoL6bsXu0AT1oMpiVvWG1l7cVPKvxztfwoXIIY TInfXjbJnwIVhUmpeUi94MO8kG5lokyfuVaS/Jri46ZDESAcncS7L2kbFp6cMfPD5QEe/cCzsqZB7 rb/KLNvErfSursyJamn+d3iP9FIlh1A5XaScJ6flUwaRBCZPX63lySw5y9/f3VUVb9M0+CPpzVUhk KrON0oAMS45pU2og+USg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhZj8-0000000Etf1-3vI7; Tue, 05 Mar 2024 18:41:22 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhZij-0000000EtHc-2zoN for linux-arm-kernel@lists.infradead.org; Tue, 05 Mar 2024 18:41:05 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6e622b46f45so2080226b3a.1 for ; Tue, 05 Mar 2024 10:40:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709664051; x=1710268851; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=X0gUmPSeCCdcwdwoiei/E0Jjh2VpvFQYRxx27Vw8kHc=; b=kRPkdS0+TWEmtMb8sroCmjzjWbfzzmTKDEEnYD1eDHdOHAx0lQMc0gyKNy6DK3fM50 7Uonn20kCQWdaBEvVfBs1zHq3A+iJVPhmUGELlmBDcRgbGUmlLE3/yaMkQAoEzMnj+eH Ryu+Y4ZF7SblCDy0DwShvxHmVyNLGFynb/Zj0UJ7yerKpKc8E/oknukbglKON1tyhZu8 YEAOievHvz5o/PmlNjnUH2rLTdTrt0LrakOlcnruijx1hK1u9wOXMLJkxtKNRNzN7ltI NTRKUqQp2ZbE5H3MQMbKZS3fpUHXKmBi65v1PmnUzeTJX/lU/FGDO4vXw/GjMqZOYIaa vv+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709664051; x=1710268851; 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=X0gUmPSeCCdcwdwoiei/E0Jjh2VpvFQYRxx27Vw8kHc=; b=eKxqPWPYPU1lIYLTjIgK/iONTmFGOtz1M0f4yY0PbSErkIOo5lU4ydRzzPKaOvSUDe 6dLyIOPx4AIUSj5W+z2p8bywxu1rffMGrKlPPHWyfXoZffFy5lES9YKSYVBwwY7s5xyQ 1uhPNZneOKBeKZBj7G+xdgxxwqPg+A74AiWgjKx2bdiXH+HtoMEBb4qq5diqAtT7Gqip jjE7aqFvdQwpWga8wgr1PRG/RtPUEhxu8BzNQwQa4U0AitijCr8R36PRu0MeFLs94NG0 G/hdECyWEdB39NOV27SWiHgADlOnrtiWHhRRrbo1GtDcvZF2BLS8M3H+iQR78b300TZP 3NaQ== X-Forwarded-Encrypted: i=1; AJvYcCUrSz9NJIOcq7iQcffTTjM2nj+C/9wJhl2EeWU4urRnaHIl1Ip7bMzf80Kz1IPL8J4WKOcy9kTFW6ZvLrV5JLFZzXCxKu7hXaf8gTMxCh3wxBvujgk= X-Gm-Message-State: AOJu0YxToMZgXgJ4QN4Sca+dAUGxmNJ8ZTCjhIXoVLKlYwKym3SXYJHI fI8DwlTwCGSKdkJPEC2ToI6okcC25ml6hMCG0uZzf5nfd1J2VQ9N X-Google-Smtp-Source: AGHT+IEh5cNC1e3ALin9EYEqP1JMKTTzvFIxop5uA7PitJpNaz0+Cvy9gmZD//Z/el6YtUoATah/OA== X-Received: by 2002:a05:6a21:3403:b0:1a0:e089:e25e with SMTP id yn3-20020a056a21340300b001a0e089e25emr2819250pzb.46.1709664050630; Tue, 05 Mar 2024 10:40:50 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id p2-20020aa78602000000b006e24991dd5bsm9538237pfn.98.2024.03.05.10.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 10:40:49 -0800 (PST) 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, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, Guenter Roeck Subject: [RFC PATCH 5/5] loongarch: Add support for suppressing warning tracebacks Date: Tue, 5 Mar 2024 10:40:33 -0800 Message-Id: <20240305184033.425294-6-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305184033.425294-1-linux@roeck-us.net> References: <20240305184033.425294-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240305_104057_815221_0AECEC0A X-CRM114-Status: GOOD ( 14.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for selectively suppressing WARNING tracebacks to loongarch. This requires adding the function triggering tracebacks to the __bug_table object section. 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)