Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2871589lqp; Mon, 25 Mar 2024 11:34:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhGMo9RWm5wFfaCL0sD2TEbod2VR5XevX7i9e2VWjQGY8+Q9LmcdbYWdGjuv95BGEO8AEl0y6MVHfDS/k9epIccPrCE/hOVtnRZhX6rA== X-Google-Smtp-Source: AGHT+IEtVL7h+bSnoi9HuxHBRZLZmNpkl4cfA1xe0rH5vyOAOGDqh/QnhVK9vEOOCbgLIROS7wDN X-Received: by 2002:a17:902:f551:b0:1e0:b871:53f5 with SMTP id h17-20020a170902f55100b001e0b87153f5mr5333603plf.20.1711391653165; Mon, 25 Mar 2024 11:34:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711391653; cv=pass; d=google.com; s=arc-20160816; b=HLwbRCVFKxC3k2cHRgwAMrKciYo/Jl0t4ECfdJfkVqNtiQwgfAtHu8cME0cSm16XBx +UNW8x0fDaL3JTcMaWTcsDnPvtBg8ckZ6Uh+PW4a2QclossWLk04i8q2HGRFqi+Nqf+9 1BcYg8wDgj8aSewFDiI79h0Fz/kKSnN9fpSqIHeXLiMWdQw0inc0B7IikwXytvUrpBzY TZBcJwCgMj2vu3Mbmk2jUtqvvcfc/xzifE9IcnsH212ZWl7D+F0dWxdhurRgGa2HEc9y n2LvquITxn6DJkUTBfnv9BNN+wcgZWpaeIX53OjekQsZp747qmbIrmTM0WJwkk9d4dwJ V99A== 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=F30AvGE946RVy95xtPHKquJN7yP343T7iOtn6SBetHs=; fh=E8+ZO715/BNxxIk4x4gWgnv42Mv+WPyrv8fslXbx/Ck=; b=V2+lMqKbs16rOuPE+26b1ZBMEJ7PVsqyddR9FmEqtWppxXPGi0FMHqVFbTXy+vjKnZ ANJ3VrrEupqU/Y3dgIOHXYldaenbdrCWJn9XgKKU2D9nryi5ZmLX14o57Iy58Ku/gp4A tXroLStYjroDxLF3KAYuvO2MVr4G6JWxYSpHnrPmm3bC4JWJ7y74G+TEUMK4Rd0ynT7G jmS8bHs9ApXVZoqTC6kVw2+UH7aDpzClpMSAHOXg2ecLnjK0o6Ca4P6mryyJylAe3PI8 j8ORTHID/6pQ6h2/r8hx+AWaAzWodUdtamzKYBqneOQC3l0JFd/gPm3xrG363sf+pWX1 ZZFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PqpEw88b; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-117652-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117652-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 q5-20020a170902a3c500b001e0c54819a9si1795621plb.165.2024.03.25.11.34.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 11:34:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117652-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=PqpEw88b; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-117652-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117652-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 AF54F299F5D for ; Mon, 25 Mar 2024 18:24:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DF6613AD21; Mon, 25 Mar 2024 17:53:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PqpEw88b" Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (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 63DA612FF73; Mon, 25 Mar 2024 17:53:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389194; cv=none; b=dv+f3YOOaMxxEywuXvmK6kEQIWwH/UABar2LmmmR3//pnwi2mLZilQwGGnhGwEfu+FyTBFc5BPyZdAtVG/h0Hx0Vrw5dMWR9oYhDAZNDQLxgA/wq1Ht4GEuCdmfY2lb1XAummneky2Z3HVG3WlXfbMLkQ66hh3N60OgVl961mAA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389194; c=relaxed/simple; bh=gXmhoSugTMNNbGcVNtnGx4y/QKbSNifMSyDkE7Ry1VI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K86DQNe+AyatNbiwm5CS12L99tXAnVPqp1JM8VudG8ONALxmgdLHW0TGtBG7udCLAwK171LPxm75Ht2vC1JT64Dmk9sD4UhsMaox1jIVPbyi5KqYDO9AcN+4l369YfiySCbhxIegWK9uy5Wo45HtbrxKtfhgTsJIiYMwVmh6+fA= 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=PqpEw88b; arc=none smtp.client-ip=209.85.161.52 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-oo1-f52.google.com with SMTP id 006d021491bc7-5a485724ddaso2776292eaf.1; Mon, 25 Mar 2024 10:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711389190; x=1711993990; 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=F30AvGE946RVy95xtPHKquJN7yP343T7iOtn6SBetHs=; b=PqpEw88b9CnxHKKcXYDzzFuCjAqkKSAsE6+/wxPgwSEaFuXu4b5PCJ4BiTmR4m6+8G wZWtFujT3XJgw4n27Dor3KzZJXgePpk/EsbiVhY7Vo+zJrJjq9BISILMkr+fWPcnRvOs cl10UEpwTHKhtoxDwzuSPrcZ1u3ZVlvFQj7+akvCMSF6ozpOz14tNeG3chqnWhjuOVL9 CjPiJn07s0i8W8CTwBtILRj60IjAzI1auQgtpGWLzT38J9CciOTQedgqKxqSNfO8R6V8 eEhuFvtUvG4ygBWPZlFrgDtltvAfmO9eNvQoWmOR+DqKcptLKQ7ZiCLCYQ4URsgfTExV OUdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711389190; x=1711993990; 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=F30AvGE946RVy95xtPHKquJN7yP343T7iOtn6SBetHs=; b=Jx1KQnwBGoPFH0F9jEFv8TGlZzb4QsOUgBwBHmCT3K9xOtlIcluzQJvpPqPgZVe80r DtADtF1sedVvES8wDLWMcsdcnm7ZIbvAu87F15Ctk5GTjXbCa1SRVzm+DRwGlTiYe5qS gIGJfMvZAQ3G8dc9PJj6i7G8dFBQ4ILMX/nb0FzGxcrK49hD/ioZA1w6DYQWNI+2Yonu kESWuFwb5oCSM1v2GpOliNhybAOfG+aj1RE3l4KlRhOONXb2q5pqpeKjkXkIkzZIpnb6 TTjOo5hCQEdgWagZqa0/AsxmpHMxeJyrqCkDguSbJJQOR06lOSweMEg4kW/dVnvzQZuc p9og== X-Forwarded-Encrypted: i=1; AJvYcCUQJ63ormHIuAUv+bevVs35oNCssBO3gOmaBmi2+zS/bhaoCgdfDaZgL2jJEFSx/KamRdsvvJ+6HLa8HPmEChylPQzw3VdKAOK99sQqVF10kBCrCwHD379wnfxVOGxTUfqZN+pE8yJueRGOYQHlmszILvMFwFO0TAT15buRb/kKj3MSo4BYyT32cUaGC4uFyT5/grMTrKNQ2eI7Rui3FztsEqgAnduaMhqCvHuseJAcyG0ju722twi5BtLFHEbm+VBRwWrQd515y5K3HkZqDiGq1NjiT9o/b3K/bQt9zlbU9JnFMI2OFhGA6EQch9pkeA== X-Gm-Message-State: AOJu0Yyn9U0gqO5GcX9w5/P9TzAx5wN5wYl06DeCVTf0TzfbE+BmjG0e QeCMqWp/j5dPzG++lkJpPMPOMYRk3l09Z76wZ4KfG4LdJQWH8YSC6cCrC9aX X-Received: by 2002:a05:6358:2922:b0:17e:4cad:a11b with SMTP id y34-20020a056358292200b0017e4cada11bmr9108706rwb.19.1711389189758; Mon, 25 Mar 2024 10:53:09 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id w62-20020a638241000000b005e485fbd455sm6068607pgd.45.2024.03.25.10.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:53:09 -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, Guenter Roeck , Linux Kernel Functional Testing Subject: [PATCH v2 09/14] loongarch: Add support for suppressing warning backtraces Date: Mon, 25 Mar 2024 10:52:43 -0700 Message-Id: <20240325175248.1499046-10-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240325175248.1499046-1-linux@roeck-us.net> References: <20240325175248.1499046-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). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Signed-off-by: Guenter Roeck --- - Rebased to v6.9-rc1; resolved context conflict - Added Tested-by:, Acked-by:, and Reviewed-by: tags - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option 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 08388876ade4..193f396d81a0 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) \ +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR(func) .long func - .; +#else +# define __BUG_FUNC_PTR(func) +#endif /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + +#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)); \ annotate_reachable(); \ instrumentation_end(); \ } while (0) -- 2.39.2