Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2706111lqz; Wed, 3 Apr 2024 06:28:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbrc07g4UFnwFoo4Ai3vCF7sAsuRaHlb4Vc3LYL8yF0BDNK3TCfNmg6Ge3+T4zcCnZfQ3tb2m7NQerW9AlA6jgWxfAKzKMiX2MQT7dew== X-Google-Smtp-Source: AGHT+IEdvVJZHAcGh1otx7kGk8qWvQIdhWvNgC40jhTtcU6orIeAA4mcrjToQ/LHej7hGGS9pBSa X-Received: by 2002:a05:6870:e983:b0:22d:f675:d525 with SMTP id r3-20020a056870e98300b0022df675d525mr15253040oao.48.1712150929600; Wed, 03 Apr 2024 06:28:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712150929; cv=pass; d=google.com; s=arc-20160816; b=j9JEIHXyuWvJU/RlwtX6oJWRDJfe+EYlzZ1e3Al4XS8Y3Awk5OHeS8R2vt0a84JzNg wvRuiOGCPvdXzgWse5wGHbv5pnyzmNXKjLIRDp6jKCaRy7RBJ0nCrvHlb0F4zZvOoa7F QygCNQkDQC7ApbwCGVB4I4b1wByOf+6y0/anWA8XhNakRAFL1iDHwHkxU9MCqjUxg9Ty s2MJcz0DxB3RPrJNrdFA9my0QHqB3paT2tI4ScBJSIFltq32qmXmhzly6r9NtLOqKo8v uEHt2JQlbX0uaB/ZG06oI79IuQ6eAqQ+XjVIAzEWVZxSOTFVd124eCkmItUPskC404vi 4Amw== 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=ODnUVSnKJhDEm1BurB+AUz+TF6tuatLZNT+jGpCl49o=; fh=05bb3Ujr43Oc2W4wi27Wip79tbNvqsM1SkC5mlooUt4=; b=tB2YtGBy5W80q6T8kb+u7i95Y0SixMW/15D03a4FKSyK0rg4c2PFD3A7Z8HKLLdn8s 57z3b7AFh5heIJHkjzTZW1xnd0rICibTtVACfntxTZwl3qu4nTZOspvpMsgSVLbIOEXl +e236jxxyrgySPHS5n+NW30dom+qPI//WJWm8hMqf7PAwoj33B0PiwWdZOlT7tmYA+Zj QPbyaT2AT4Nq2dZYiV8o9TQz19u3aiTKLllQwb/VTjvCc8Pp3qrrs3rd5h/qKnYc7L6q KInMHdzqYToSYQ/zIZYT1yR/VNg2i2FTQp1Rwvaqq4Zgw44k9LPBIfc0/YOxe37LSCrY SEcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CsD0oyiP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-129816-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129816-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b5-20020a637145000000b005dc833ef4e5si13079269pgn.64.2024.04.03.06.28.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:28:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129816-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CsD0oyiP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-129816-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129816-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AEC38287C3C for ; Wed, 3 Apr 2024 13:24:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02AF414D45A; Wed, 3 Apr 2024 13:20:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CsD0oyiP" Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 584C614D425; Wed, 3 Apr 2024 13:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712150409; cv=none; b=ZSNTEXUCuxxy7oF8Fy1Q7fE9QcaMo+IVBXar/4fF4CArBLGiRQvlKpNp0aWMd/Csx89/x6xvXTxZMvUiBT25UcQbwNRkqCkba6+ckomyjSYllW1H7TmIVISM5guPOv3zzFU6iPfNmjX0jnCx8IdIC/F2Kla58Q9k2pJVLVvkWSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712150409; c=relaxed/simple; bh=6CYnXopnOEFDbmnJvQptcozsBT0uZcC6Gw55E5+uo5s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QOLjs5xqP0Lq4kMpuNkSJYySQVWzr5zzV3sv7058Q+7Ga+Gps07olqeswG9/IZQnQTNlVNdSft+zPKaSsejyEj4vVMnkw+AOYSFtxHo/SG6cbuJTqTQJp7mNwCF8zoRseMJ2Y9Rb74h72eGSkQ05BshZkAQHf3z/RvZrpWpbG00= 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=CsD0oyiP; arc=none smtp.client-ip=209.85.214.174 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-pl1-f174.google.com with SMTP id d9443c01a7336-1e27e174ccbso10908035ad.2; Wed, 03 Apr 2024 06:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712150406; x=1712755206; 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=ODnUVSnKJhDEm1BurB+AUz+TF6tuatLZNT+jGpCl49o=; b=CsD0oyiP2JQ991rgfHqWBL1D9T7YSZr45F+iyC38jltBcMOIX48ki8j60N8ck+XLh3 Ajko6sJcpH4IaghYFZjY8Bgd7/DJdFfA5aUf2jKuQKc8rjsSkor3Vw4PbM7VIXNG90HG 7vlFCvIQ8855G2VRAmoSSB1h+DXvRzhHRmefZt3gWrPbNc1WUn+eH/UVCy7UuMvVIOXi YXt9sTOnbjk18gCl4NcZYnWJd6auQAfQWsn3CGWYnWeXo0JD1lU4vRcHERVtM+MS14pC fD7SGXP7k7pOrKbFV6RdTfYfSLYm9JN1nAk1EyheE6tui5H05PgZF1bgGW4Rn5A4CaR4 wxeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150406; x=1712755206; 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=ODnUVSnKJhDEm1BurB+AUz+TF6tuatLZNT+jGpCl49o=; b=iGisyINYQyjneZ5zL4zNz7RK0X9xlLzuyv/6hjCLSGD+ZIuIrIrjtMp4AvnkiA+DpO RvegreJnmCjddB6QQHh4cHPiZEmqb+IoVAqvytig+/LTjLl5+emu/bSpHIoX/vGkY355 luBx0lPS9DmPOG4cLwszX0vQkdTOiJ06xDLWuAKunXiBfQJwmgA4U2NgxG1AguEaiyPW ZoXqK1aQ1l39y6hj4ezwyl0/QGP10n6Bk6Z/HrSp2zNokv9th4lZM8aJe242lt9BcCjX 4+5q+I209c2hCnbx7KHgdvsScnceh3y3EZFt6jWPxTzgH4qb6AfEpSX2iDlhrnJOGYzy nImw== X-Forwarded-Encrypted: i=1; AJvYcCWgvdAb3hjjj5r8idm5dzpJwQTVDmfhrWN3205eQPGJl9usESWnVQXstZQAsOJGXhshnL6qgxHze5JzJbnpscS/wyCu+J4tkH0Au/heFKlcrnkwk5IlME3gk5PrMqzGfociVuRfpGIJMFnljG0dmUVlCPOmP0UUsPfJptqBhpqRL5Jt+1pTlOonpL54D1rBUO4DtFBKwDKWnpNyoWMFNFCnZUQoqrCVokxexGrOiVTWnp5/IN4Vl2b+n6/YO3Db9jFUJ6CmXdNM6H9j7a0cqO+MbQkpI3GXkB/2huUyd1GERzMUtoQ5wjFr5Q7C5RZlHQ== X-Gm-Message-State: AOJu0YyoB8/uCRw8BDXx6zKklfgyB6/G0Nsd0Bxc9KgP0mj3x5CMwxAt HHiJd8wxtycBWBgJz9xCrtdhw9FuEDEK1/gv6EfN5n8olE4oYnDq5umPHZBt X-Received: by 2002:a17:902:ccc1:b0:1e2:3d61:e266 with SMTP id z1-20020a170902ccc100b001e23d61e266mr18724864ple.49.1712150405920; Wed, 03 Apr 2024 06:20:05 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b1-20020a170903228100b001db717d2dbbsm13207508plh.210.2024.04.03.06.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:20:05 -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 , Paul Walmsley , Palmer Dabbelt , Albert Ou Subject: [PATCH v3 14/15] riscv: Add support for suppressing warning backtraces Date: Wed, 3 Apr 2024 06:19:35 -0700 Message-Id: <20240403131936.787234-15-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). 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 Cc: Paul Walmsley Cc: Palmer Dabbelt Cc: Albert Ou Signed-off-by: Guenter Roeck --- v2: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option v3: - Rebased to v6.9-rc2 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) -- 2.39.2