From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 04EAB260A20 for ; Thu, 13 Mar 2025 11:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866314; cv=none; b=kyUIs9P2HfE5R0JJgFuq8rVd3pZCJAjDAP6q95D5xWLQZwfxrME1BwFwAT0LON6zmX3+FA7+N1KaciQyAOmowolLP3A0b/oECMsyLSMGcAUdG/KXUiLiJ0DhfOP33s7ofl49/9bwfh+NxfypFvSn/UCm7l1NOU0gkuJJx8/CHCY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866314; c=relaxed/simple; bh=5fLDKvq7QfjMD1rpic/O5Jy44W9yZO5UGhmiIAM5Nww=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=rKV51m2g9tvSxEwIKKk7cxxQqzqwmfKurNSU7BvZHRIW4j2cFAoStgUzv7DuQbtUDexdgR5tWqVioBshEh1QL1WbqW/ntKxMLP4CUV35FixK2cpZI7m1lx1cXEbjc520m8vwL4I5iSXjUH+LxeIybGhNoWHY8+BvwAhGzw5WL/M= 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=BkKnUAfA; arc=none smtp.client-ip=170.10.133.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="BkKnUAfA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866312; 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=PbqX7vwCNjEpHKJ2wPiix10XVQC29l2r3Yj9fEcNr2k=; b=BkKnUAfA8053i/gkf56xw6O1xavjRsW6d2Oge/k5bKOVjngG1Wzi2ySZ568roRVcmfTMKm EYkXauroVcPC+QoSxCNoU4Avxmdkh4geGQcwxKAMIDjIDe3BmYAjGCbuFlf0qMEKycp7ri d16BbpRcK5o2HFXVSwUL5pXosTVxRBs= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-524-DfdBsyTAMkWc2-9TGXuzVg-1; Thu, 13 Mar 2025 07:44:48 -0400 X-MC-Unique: DfdBsyTAMkWc2-9TGXuzVg-1 X-Mimecast-MFC-AGG-ID: DfdBsyTAMkWc2-9TGXuzVg_1741866287 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43935e09897so6482245e9.1 for ; Thu, 13 Mar 2025 04:44:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866287; x=1742471087; 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=PbqX7vwCNjEpHKJ2wPiix10XVQC29l2r3Yj9fEcNr2k=; b=vps5iY/U+XhLfBOSggyFRlIA18jTSFjw5+aGR+rupzCPaXtZgDt6+A0YEKeOylNo1d f4Raf4IAfBa8OeIvl35H2Jd+Hz9FIJ3V8Cd4O04tbwmJ6xHWREqm25C1xVYAVg2OOqRH I74ZFSJNof/tLDWu7kRrn5Ipwt78rftg2ZB7P+xS0yOhqJY4aZ4nv5wFi6/FSJM7ymhW hammLG1V6Fpcs7/gACPZCnQg5WZmJt+6MuDF7S20MEP5uK5hz6dHvd0pWLfAyJsFiy2W Mdq5c6CD5023UNgf7QuI1nC3i5MAiazS69LCqzYX9T7hLTEu6lj0wf0UW5q8oS3raD+8 kvKQ== X-Forwarded-Encrypted: i=1; AJvYcCXC2XhFSqmEiVUEdQ4amL6oR7IxnDSs+QvpFcTVJSrcvA4KQOQcQaB19hgcRVI6t6/1UUZy+tb1Afo=@vger.kernel.org X-Gm-Message-State: AOJu0YwfTbUOOrQ9t8HCxxUW0543RqPXooTgWt5eegIuvAu90Zysdoe9 3QA1Mq2L8saseNgCcExdNrL2KWsPxDByc0QN539Hagh+AvUfNt4LPLgvHl+md9oa7IaC14mxIfL zlDx2EcDraNWqaVXopXckgQENiUB0Gree9ho3X3JJhjj0UO6YVD8pHo9RsA== X-Gm-Gg: ASbGncu8Knstd6BioQnQpM1lh+gTIXK5H+f4jyyrqh3DwovDz5MTMdF3kQWoGiqXsBF 2VoHqTw0/J3HIETsJ9knoZoVRVdQH/zTlKhW0ApbOgQklGqozpBN03BgzmrsBtLe157ySvhRRyN hx7Hu6goeI/b8M6r17JQOgGIPSXECpvO29JC+hPL7l9PwWRGZJvpi8Psm+u4B2HuQOlgJafF7GS AeEYsPfcuuuff1tVNN4uY2Vg2JPU885305vBwfVgypUgve7c2mPsl/E5IQhlfm6YxXLNjL8Mh9r wmCg3sYv9NEdpYIP/ycZ X-Received: by 2002:a05:600c:3512:b0:43c:fe15:41c9 with SMTP id 5b1f17b1804b1-43cfe154338mr111255255e9.9.1741866287298; Thu, 13 Mar 2025 04:44:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDgHdaZ1G01z8VuKBQ3BfPMVXgqQ5rvdTXEZ7bpTSjr+Dr16GZrLUPpD2KPNpGCET/hDHX7g== X-Received: by 2002:a05:600c:3512:b0:43c:fe15:41c9 with SMTP id 5b1f17b1804b1-43cfe154338mr111254865e9.9.1741866286869; Thu, 13 Mar 2025 04:44:46 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:45 -0700 (PDT) From: Alessandro Carminati 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 , 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 , Huacai Chen , Alessandro Carminati Subject: [PATCH v4 08/14] loongarch: Add support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:23 +0000 Message-Id: <20250313114329.284104-9-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-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit 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). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Cc: Huacai Chen Signed-off-by: Guenter Roeck Signed-off-by: Alessandro Carminati --- arch/loongarch/include/asm/bug.h | 42 ++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/arch/loongarch/include/asm/bug.h b/arch/loongarch/include/asm/bug.h index f6f254f2c5db..b79ff6696ce6 100644 --- a/arch/loongarch/include/asm/bug.h +++ b/arch/loongarch/include/asm/bug.h @@ -3,49 +3,65 @@ #define __ASM_BUG_H #include +#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, extra) \ - asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)) \ - extra); +#define __BUG_FLAGS(flags, extra) \ + asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags, %0)) \ + extra : : "i" (__BUG_FUNC) ); #define __WARN_FLAGS(flags) \ do { \ instrumentation_begin(); \ - __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\ + if (!KUNIT_IS_SUPPRESSED_WARNING(__func__)) \ + __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\ instrumentation_end(); \ } while (0) -- 2.34.1