From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 BA007C54E58 for ; Tue, 12 Mar 2024 17:13:24 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BbmNIYdG; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TvKwg2Gxyz3w5T for ; Wed, 13 Mar 2024 04:13:23 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BbmNIYdG; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::62d; helo=mail-pl1-x62d.google.com; envelope-from=groeck7@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TvKjY2LTSz3dfb for ; Wed, 13 Mar 2024 04:03:45 +1100 (AEDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1ddbad11823so7183535ad.0 for ; Tue, 12 Mar 2024 10:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710263023; x=1710867823; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Mb4FmIopiSO+/3QwXjaWJkazatuyJXVbnhhdOwFBf/s=; b=BbmNIYdGACNsjNz6YGqqqYHy6ghPKZtpW9KFck4og30Z8yByXTNL822YtttVv7YtKr RuIK7IqW/+wQquTwefgzMi/2F95U0RINpImbXQz+FEymV7e//WjRWhrnRfZAxULlDtA0 Lb8Bo+Xx+b3w9n7UXLoEZCDJhXInr39+CNNPY7ugEEuzQZ88Su0BSXLycVY2AthPuaaL /OZwJx+0jN+QHT3xZJ7mKQgTIoR76C2B3Ukz2FNdt261yuj9AV72ENFkf4w+/htJq2Mb S6P/8HkrvHR6LuhEPzuRbmpVPqsXTO5t59p/brvrtt/drseW+oJkRDPFUoeCHjzmAHeb zi7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710263024; x=1710867824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Mb4FmIopiSO+/3QwXjaWJkazatuyJXVbnhhdOwFBf/s=; b=vLdVfqyqaTacGhvGArvKDcdWS9+919EAw3hxyb4bOmKeLvgKnG3XNqkXo9IfM7hdpc 0rw99Yx8+AGPyIsF4UKtqWFVPHbqGU+rgJWjVLhHgTKhBxxbAICw0OkCRh/W2i4Vybew aYv7lg2+ZNxLIZscwCxHh5gJ6iDv9k500X3GfUC1+JVAo0tpGKBF+ddF3zb8wxZGKU4S 2ImHxQlOQCuxTiHVQ2rQwk0vu+sXpstm/VJ6MWjy5EgbRdzpleUNPPTiu56ug49W2AHM 7yBiRfAP3LBDjRanNPfHOQx1rr192sffo8SaiJcEPARr+80/wD9nuvn4yWEGlhZD5d7+ G5ZA== X-Forwarded-Encrypted: i=1; AJvYcCXwYEbHr+FHhjAaAAyddmvLWRSderIOxVuH9pKi7tB+bqRdE2I4865Jdf3+v2IxOn/QlnLeiIRsPU4kwLP2tS03ZoIxgvf1s5CrlP1bKg== X-Gm-Message-State: AOJu0YyFSUKrx4TOB5u6oCAGbdCQAQFer/qRhhCwDwajbkEFWeWRBQV5 dLkZEJh0eIVgQiFHGZ+j5ptH5NvOi1KxU0BcJ6Gvpo0heucFd4TM X-Google-Smtp-Source: AGHT+IESK+W76sbv32507e8vr+AETbi9zHy7dM6LrGga9gr4qnmj+9kyX8nY1a/g+A7cAY64N5ru0w== X-Received: by 2002:a17:902:edd0:b0:1dc:a8aa:3c86 with SMTP id q16-20020a170902edd000b001dca8aa3c86mr9530991plk.5.1710263023689; Tue, 12 Mar 2024 10:03:43 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id w17-20020a170902d11100b001dca68b97d3sm6991774plw.44.2024.03.12.10.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:03:43 -0700 (PDT) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Subject: [PATCH 13/14] riscv: Add support for suppressing warning backtraces Date: Tue, 12 Mar 2024 10:03:08 -0700 Message-Id: <20240312170309.2546362-14-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312170309.2546362-1-linux@roeck-us.net> References: <20240312170309.2546362-1-linux@roeck-us.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, Brendan Higgins , linux-riscv@lists.infradead.org, David Airlie , Arthur Grillo , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Daniel Diaz , linux-sh@vger.kernel.org, Naresh Kamboju , =?UTF-8?q?Ma=C3=ADra=20Canal?= , Dan Carpenter , Guenter Roeck , netdev@lists.linux.dev, Kees Cook , Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , David Gow , Daniel Vetter , linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Zimmerman n , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Add name of functions triggering warning backtraces to the __bug_table object section to enable support for suppressing WARNING backtraces. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). To simplify the implementation, unify the __BUG_ENTRY_ADDR and __BUG_ENTRY_FILE macros into a single macro named __BUG_REL() which takes the address, file, or function reference as parameter. Signed-off-by: Guenter Roeck --- arch/riscv/include/asm/bug.h | 38 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h index 1aaea81fb141..8955ee5c1c27 100644 --- a/arch/riscv/include/asm/bug.h +++ b/arch/riscv/include/asm/bug.h @@ -30,26 +30,39 @@ typedef u32 bug_insn_t; #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS -#define __BUG_ENTRY_ADDR RISCV_INT " 1b - ." -#define __BUG_ENTRY_FILE RISCV_INT " %0 - ." +#define __BUG_REL(val) RISCV_INT " " __stringify(val) " - ." #else -#define __BUG_ENTRY_ADDR RISCV_PTR " 1b" -#define __BUG_ENTRY_FILE RISCV_PTR " %0" +#define __BUG_REL(val) RISCV_PTR " " __stringify(val) #endif #ifdef CONFIG_DEBUG_BUGVERBOSE + +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%1) +#else +# define __BUG_FUNC_PTR +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #define __BUG_ENTRY \ - __BUG_ENTRY_ADDR "\n\t" \ - __BUG_ENTRY_FILE "\n\t" \ - RISCV_SHORT " %1\n\t" \ - RISCV_SHORT " %2" + __BUG_REL(1b) "\n\t" \ + __BUG_REL(%0) "\n\t" \ + __BUG_FUNC_PTR "\n\t" \ + RISCV_SHORT " %2\n\t" \ + RISCV_SHORT " %3" #else #define __BUG_ENTRY \ - __BUG_ENTRY_ADDR "\n\t" \ - RISCV_SHORT " %2" + __BUG_REL(1b) "\n\t" \ + RISCV_SHORT " %3" #endif #ifdef CONFIG_GENERIC_BUG +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif + #define __BUG_FLAGS(flags) \ do { \ __asm__ __volatile__ ( \ @@ -58,10 +71,11 @@ do { \ ".pushsection __bug_table,\"aw\"\n\t" \ "2:\n\t" \ __BUG_ENTRY "\n\t" \ - ".org 2b + %3\n\t" \ + ".org 2b + %4\n\t" \ ".popsection" \ : \ - : "i" (__FILE__), "i" (__LINE__), \ + : "i" (__FILE__), "i" (__BUG_FUNC), \ + "i" (__LINE__), \ "i" (flags), \ "i" (sizeof(struct bug_entry))); \ } while (0) -- 2.39.2