From patchwork Tue Mar 5 18:40:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13582864 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 8D045C54E41 for ; Tue, 5 Mar 2024 18:41:22 +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=MV4QIh0hYAt+U/NjgXa1ExZh+03ZC/trx2cpkarz2dE=; b=sgt4Akod97CYGv f99HsZs/Mv/U6doj86Xo1/ruPIAaTDZRyOI0c9HMgZbZeP8z4BKOL9ddG0dM5Rw0zp0a9qqIxajeB p4/nXfjgKbn7DTj+KHr8d4faMBxsLINrJ96nQhpLOOKMYYeTwhjzaV7WOE8UoDUFBe1+4NiCjjsB4 IoB+UfDN7+BmK7Npmcc7CsQl33732YuyvNjNDeOD37/Is9coX0wOCOg63HPZBr9Fxwm2mmGWwriMN rSHx0hpWea+Q13/9/S8wX+t4dRffrIefjNJCNBd1UOWk9M96Q1hTGOT5AqaCGilYfm32rKBFLh3ER +4kEBQXL6cLSXDNXvIaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhZit-0000000EtUX-3BIC; Tue, 05 Mar 2024 18:41:07 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhZic-0000000EtFq-1b2L for linux-arm-kernel@lists.infradead.org; Tue, 05 Mar 2024 18:40:53 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1dcce5e84bcso48699945ad.1 for ; Tue, 05 Mar 2024 10:40:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709664049; x=1710268849; 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=ENga0JZ5rPZBACTN6wZjT+Dt35XTgUy/8PrYsu9aECA=; b=KNfkePDbuOeaUWIH9jrnhMuVOQfJ7qLHY5eut944RQ3Yxd/bO/E8dREuIjJ4jBLVAw 894sWPjETu9fqhgIr2i3vr/z3I9/WnvTFHz+OFc8q2BRj3MHXpxEkOTpE+buTuPHfdkt UMiAqynFc/VpqAKtHhFWfZ6ttrnN5zb2KTOQioICGB70VaNAF8SsXymiLNvMj/5D8mSj yYx671D0gHXKVNocCWUKIby9aPyYoaJdBVlFKb066ri9psG4ppDAncKNgJIMP1Lm7q8T eCJ+u4Nw7UKFHWz+iYADn4PpFoauZ9ryhvA7Fj1sUONjjpoGrlT73HD+uWW+DEQNvsNP OVGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709664049; x=1710268849; 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=ENga0JZ5rPZBACTN6wZjT+Dt35XTgUy/8PrYsu9aECA=; b=lf0kaeFwkTA+A+H1JpgXaMQCTOWWl31hSMFXjPYbhSZNDvwrOMZkYBtMDBb/VT6W4R uQxWyAWVuamqwOKID2pY+bh+Q2WuKWyYbdRgdjRsuZAbh4LPIIDIzb4a0n86/2ZeBwV1 rBcSflw37dq0cb0L0L+0LUydUa7SsixSLeYlOkptUZCLGMz6hoEnI5CVjeleKF8QUBe1 dOJQZd2YdgtLqY4KI7bvZL81i3iymkdV7VeiXEbs9DHSU1Vw3OhczcR17R+R0TWXnJue xEMxRD9rDZGjZA6XhrdR1sNJAfEgqaa/jcjyQn6TKxamezUPz1f1BD/d28EHkNUwZBQd 6v6w== X-Forwarded-Encrypted: i=1; AJvYcCXhveHyPmGr3DlI9e1GzQOkslkuIxYudm6qRVec+Xn6t9wNJQOPpccAEotQSM7wKZdBaiRpDcg2CPzRU1nyQ0TfB3QMeAEx1Mmwwv41tWOXw7ifrYg= X-Gm-Message-State: AOJu0YzXtA/th7rOBwZ7OYoTqvJkGQ33fDgVReeGhDo2mzwkIE7jWuRT 2NFOPpEyfApPlXOvMUZjmN0kDX4H9F9CILSn6u3sirFYQ4gHl1JE X-Google-Smtp-Source: AGHT+IGaNADSHdFncEfR/LWfbyCwmjp0o5rxbAapZy8J6iNa5dKZ3vsRFEkgrPD+a1CNTYdARh80Yg== X-Received: by 2002:a17:903:2406:b0:1db:a6b9:a311 with SMTP id e6-20020a170903240600b001dba6b9a311mr3070617plo.41.1709664048799; Tue, 05 Mar 2024 10:40:48 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id p16-20020a170902e75000b001dc6b99af70sm10896612plf.108.2024.03.05.10.40.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 10:40:47 -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 4/5] arm64: Add support for suppressing warning tracebacks Date: Tue, 5 Mar 2024 10:40:32 -0800 Message-Id: <20240305184033.425294-5-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_104050_570756_FC5E5440 X-CRM114-Status: GOOD ( 14.73 ) 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 arm64. 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/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); \