From patchwork Tue Mar 5 18:40:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13582862 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 01346C54E41 for ; Tue, 5 Mar 2024 18:41:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=On5E12CTtD+PNRwMfWf0m3JHWQSoeDyT7dgM+MfJggM=; b=iph3wHvbohiKbr afziFNGk1dw7jZqP0rC06KOBJq1ka0mEaZfNJixIGAV0Vrd1Wmtcw+K3JUlPJAqEGkunIED55y57i R0Y2959OOe+xpnjrWe6ghQlexOedSTOMzV37WhrVpoDr3gexMYSwGzMoOM/tM2k7akK9nq65qhX7c pc9CvAZfjSNug/Pa+a2Ii8r4ZoQfAwxMqYrG5Wd1ZyRVAamq+Yh7yLjK2B0sct0Y3Z08ZSBXJtDh4 womBe6R8UFRpbmMPEril5pDEjZQz7X2vF7ne4e78+4Iy0VulUsKOJMgxtAvpqqnMTs290/U53k9kc VaK/Ulf9UA4A2wxHDKRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhZip-0000000EtQs-0bsL; Tue, 05 Mar 2024 18:41:03 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhZib-0000000EtDl-288h for linux-arm-kernel@lists.infradead.org; Tue, 05 Mar 2024 18:40:53 +0000 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5d8ddbac4fbso33457a12.0 for ; Tue, 05 Mar 2024 10:40:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709664047; x=1710268847; darn=lists.infradead.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=Y4kJHu3fBz5LPQvfwmucSB/iYHSk7Pg2H6338a3feOI=; b=l4gxnRrH8bLXnzt5eNws7KOyBPTNn2dBs+q82T3K9CMFLDSYOecaQovOOFrWT6VNXv cOGb5j0u1wNnvWWwwZacRg+H3pBgEhkz8m2CXPjC/1eGsEB5zRLYfmyNTVESjITCFASP zFnp7Hl6x2bsJ8dk7K1k4ii5/4tuOwY8YFPEUGiGQpYBw6t+H0uVXAqUbx2bYR0uZaOk AjV8mrUbXHo4WOfN/DSsd1hp8NRzGM/K+C+RNAhbEvSl8UczcjJ/H6x6JEdYl4uXk+yJ VhEpWS6/SNYm6di90kofVWQDwcoG/BfLUHcA3wRF9NdMklBBdlL1aheU011wAJJiLkQQ D0bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709664047; x=1710268847; 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=Y4kJHu3fBz5LPQvfwmucSB/iYHSk7Pg2H6338a3feOI=; b=NbzsXohOu6yEOvPumlypzDB9IsrSevLws7g4dBYTmUvYw1he3uaDO03jK8DsPqjCY5 NncxqOgTdHbFi7TkjG2GK1PEuLTY5utN+yePKYu6u/5cc7mq3J+mnuay42D7ClxT2PRF rQvv8IwSvyp94NHxh8Fw6BhfF4JHEq3m3EH3cSWY92IX8jJKk8qe8UQH26QuzkaPEtA1 37r0GHYdq1Qp+4dg8ElTvp2/JtHDgseXka2U4PaxzwzA8G7DqpiuGCncFZoaNN/cVa30 tl/pVo/YXHedLIRCA8pHHdzoRnbTFh24RSjH8g+eo3VX9Op6ounLX4wnD8J+JST6wP9T XTCQ== X-Forwarded-Encrypted: i=1; AJvYcCX1y7vIEw8U8NPDCpWY2gAAc6Nh7o73E/D05B733ka9czwmW4iRcXmE5X0rcphzyM0ZoFG9060ayAhB3E/0Uoo1t82VI9Sez+47mgmEtcs+iEewL8E= X-Gm-Message-State: AOJu0Yz+29fAwPPCg8IacG0vD9iAKdQk+jj+UpDS6QTMGnVTZxtRi1g4 XR/n6N0Wcw941uGzSJ5/k00gunGNEDw/B1jDDweul+gDFyQVRSNx X-Google-Smtp-Source: AGHT+IGTfVPApclyxUmAiyfZJFqyRfWQG5YrbUAWT/3uN8yhUmW/yeT/8jOIW+3RMo740Xw+nhtrew== X-Received: by 2002:a17:90a:fb81:b0:29a:f0eb:221f with SMTP id cp1-20020a17090afb8100b0029af0eb221fmr10745887pjb.10.1709664047094; Tue, 05 Mar 2024 10:40:47 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h8-20020a17090a3d0800b00299be0e00c1sm13136391pjc.33.2024.03.05.10.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 10:40:46 -0800 (PST) From: Guenter Roeck 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 , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, Guenter Roeck Subject: [RFC PATCH 3/5] x86: Add support for suppressing warning tracebacks Date: Tue, 5 Mar 2024 10:40:31 -0800 Message-Id: <20240305184033.425294-4-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305184033.425294-1-linux@roeck-us.net> References: <20240305184033.425294-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240305_104049_927161_55D0824C X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for selectively suppressing WARNING tracebacks to x86. This requires adding the function triggering tracebacks to the __bug_table object section. 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). Signed-off-by: Guenter Roeck --- arch/x86/include/asm/bug.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index a3ec87d198ac..8e45143fa676 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -21,6 +21,15 @@ # define __BUG_REL(val) ".long " __stringify(val) " - ." #endif +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR __BUG_REL(%c1) +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC_PTR +# define __BUG_FUNC NULL +#endif /* IS_ENABLED(CONFIG_KUNIT) */ + #ifdef CONFIG_DEBUG_BUGVERBOSE #define _BUG_FLAGS(ins, flags, extra) \ @@ -29,12 +38,13 @@ do { \ ".pushsection __bug_table,\"aw\"\n" \ "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \ - "\t.word %c1" "\t# bug_entry::line\n" \ - "\t.word %c2" "\t# bug_entry::flags\n" \ - "\t.org 2b+%c3\n" \ + "\t" __BUG_FUNC_PTR "\t# bug_entry::function\n" \ + "\t.word %c2" "\t# bug_entry::line\n" \ + "\t.word %c3" "\t# bug_entry::flags\n" \ + "\t.org 2b+%c4\n" \ ".popsection\n" \ extra \ - : : "i" (__FILE__), "i" (__LINE__), \ + : : "i" (__FILE__), "i" (__BUG_FUNC), "i" (__LINE__),\ "i" (flags), \ "i" (sizeof(struct bug_entry))); \ } while (0) @@ -80,7 +90,8 @@ do { \ do { \ __auto_type __flags = BUGFLAG_WARNING|(flags); \ instrumentation_begin(); \ - _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ + if (!IS_SUPPRESSED_WARNING(__func__)) \ + _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ instrumentation_end(); \ } while (0)