From patchwork Thu Mar 13 11:43:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014818 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 862FE26AA89 for ; Thu, 13 Mar 2025 11:45:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866304; cv=none; b=GTYx1MyDpAQb7sjUZ869CR3kglEt28JQOvcEZ4O414fSwBn8ot26AFtARP6sSdcM9GeHboF+oi4r5zlsT9sEXmTwIWXldJ1SQcWDDgA+a7xsYki9MOkJI+Z/qk1AfZg/dNjQDft4hzxhj94izya/jPKCCk53+g8TMdLot/D0qsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866304; c=relaxed/simple; bh=IBY1cNO3qDPo2x35DSNukBNEFYKja79GMNoThS6fomc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=WzKCw3qeMkHJKGa4LvjpZoCkZOIXPmtJO61cTrGurSGHibOqLzBzcmJdqiv/C1D0EXbit+kjAZrKXxO+lo6BsYAOn3St/8OQVt3q4ZyGRCCEycXPM+rZR2b/atgxj2KY5h7nYZJxaVTdyGkxLrXWBrmkYrnZeptLajhNenU6/wI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AdZUmITh; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AdZUmITh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gL6tEDolxd3AJJcGJnpcVh0p0Gir2o2MhbQax2LwBfI=; b=AdZUmIThaO+7PmVyeiYExyWTUizak90Xq2SvYlC/Cu9cOT9o258bwIIUcPmh7kyuDqYlW/ w0wgFW7BrbCn+wQ46Pya/dtXsNlIjQRp38f/NXywbxi5c4OzqVIcPtn14glxp12czAjE6g jC16flXV1/EKVSMTuO6KbfKBNrpyBOk= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-389-INsd3sA_M9mK4gYSrSesbQ-1; Thu, 13 Mar 2025 07:44:59 -0400 X-MC-Unique: INsd3sA_M9mK4gYSrSesbQ-1 X-Mimecast-MFC-AGG-ID: INsd3sA_M9mK4gYSrSesbQ_1741866298 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43cf172ffe1so5893835e9.3 for ; Thu, 13 Mar 2025 04:44:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866298; x=1742471098; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gL6tEDolxd3AJJcGJnpcVh0p0Gir2o2MhbQax2LwBfI=; b=On0+AF8ZDzv2MFiufLEKnul6g5zofB/Dy9zr3So1fMC/nkqEiZdlF7qMJnzrR0bdsX wo7JlguhPehbof8RTSpVaFW3sppHdQ5ebsUmzlDfen0sFe7RP06b0mh+O3m4OubgE3Dj 1CWrcXDSJEOq0/0TsdSxgvw1P7kWgBbyh9ay2dnfV9z55Y8SSD7DP3qjhiEhyiyTTE03 w+t3uCCyw8Vzd4TAGJznDN95yfSqo2wXfRZaic9m4DmiPQs1v+Jk0diyoan2X3W0mzuo 3RxuHbwuZ2b1IZodgjTvMwSQ11ft+p7zrZrZni2jV9+jjxWCxsKYmQLl2FmSgBzT6Cnu 8yzA== X-Forwarded-Encrypted: i=1; AJvYcCXtvzwPSShsu8IAI29BbJYxqOGUiywi1sltyV1rm+eAJv6MVbuaVRtUbh4JioIwmKGGj/W336vgESAkhSQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwWWNGwaaflzcm8VmM22yGZra0BkPMs5T02vzp5TNfsdr2ojbdG qktuJf+Vw0ay+qo0m28GIl3uqL1tRPeU3/rqDkDcdv2D8nTPBow/JN5I9qTn+U5z7rtMnr+siRk P6jLUM3goH3BXSZwu05TQrzACsVP1nkxrFNlZrWtBbBKyrDKPHk4OJ4qxu3Rnkg== X-Gm-Gg: ASbGncsNMVH2z0GHGN05DLOnrfWoo0P16OWz5A+/wQlx6moh6iLzLd5XZq7eQxj45cE xoNBBcO6TI7f81MvcfGmE6kfMBOeLm0NGh2IFZ2CmM+qeyeGK6Uqpx0Cd0vuHQXyO1kPryj+DHs V1j3wnzZHS+tmN3f16pepMevnxV9zpKpNKdK8OOdApFwOGGRgiVU3G01AzcBX9wuXUt0HecyJ5H LpKi5ctwqljYEUSxUGsl/52yuWC9EI1qO529MP8PqfqV7aGBSRLjGC9GGCl76MjaQJkZLpVn6Rk WysdnuKNp1axLEbe0mXl X-Received: by 2002:a05:600c:1908:b0:43c:ec28:d31b with SMTP id 5b1f17b1804b1-43cec28d58fmr198762375e9.10.1741866298362; Thu, 13 Mar 2025 04:44:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3R3Nh+MesHXp5r1AiRFiydlKhpsUv7CB4RneKkaatJviaz79nmlaZTG/mhvpsulZ3LqTgOQ== X-Received: by 2002:a05:600c:1908:b0:43c:ec28:d31b with SMTP id 5b1f17b1804b1-43cec28d58fmr198761995e9.10.1741866297943; Thu, 13 Mar 2025 04:44:57 -0700 (PDT) Received: from lab.hqhome163.com ([81.57.75.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d188b754asm17844115e9.14.2025.03.13.04.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:57 -0700 (PDT) From: Alessandro Carminati 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 , Guenter Roeck , Alessandro Carminati , Jani Nikula , 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, x86@kernel.org, Linux Kernel Functional Testing , Paul Walmsley , Palmer Dabbelt , Albert Ou , Charlie Jenkins , Alessandro Carminati Subject: [PATCH v4 13/14] riscv: Add support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:28 +0000 Message-Id: <20250313114329.284104-14-acarmina@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250313114329.284104-1-acarmina@redhat.com> References: <20250313114329.284104-1-acarmina@redhat.com> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain From: Guenter Roeck 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 Reviewed-by: Charlie Jenkins Signed-off-by: Alessandro Carminati --- 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)