From patchwork Thu Mar 13 11:43:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Carminati X-Patchwork-Id: 14014860 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 465472686B4 for ; Thu, 13 Mar 2025 11:45:14 +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=1741866315; cv=none; b=icTME1pEnoI9GqWCHIBTbqDB+JDcK++ya+jaxYV+T/L16FXdugM/t/o6GShmn3P+gO9LALStqB7E/6iyNhQMzuKVOpEFLxveLy3djKnK7XzVL+NNfkupcFpVbUGn36XfbcVvfYiMJPluFNSEMlp4SCeyY2AvZtD3gl9jFNVT3Z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741866315; c=relaxed/simple; bh=wb4K6eThBhnG7QUcN+gX/b7GoXZu0I9IHZjPqusvMic=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-type; b=TT/TnJut7DnP1NaLcc5JzytHOcg6u+h0+6D3BhQRx8xsdEy2lIjKjkxTIkHo2HDjC0UD9EN/Vpjw9t+pyWKOIiw5tKAH/6j1NXcL14a2jnFDPTGDcTAYusPK6n6mEw0uDRnlVxabyzXDLIG5/ewe/OEtAOOAvsh2iJlP8bR8t1A= 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=ipYIuvNy; 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="ipYIuvNy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741866313; 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=8P6wNaO+XIHVOsaMiUxPKzcQyyRjSmyu7hy/Ke33WeI=; b=ipYIuvNyhFtr6MwEtvxNToqFUN/fjhR9UrDS6sERrpNsbnQ+TpwHX2+AeekXH7DzGOMwxM JSlmWV8ZmwWjIgIF0AbqHiOrmvzQ+uVwqWSvLxGQGEHUqwkVvUY7z4VfjHRB0IYCTLUhVG REGVjoQ5o1G7KZy9z3b1tV2xNnPDQbg= 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-529-UVBJ4r77P--7fgNw8dK3ow-1; Thu, 13 Mar 2025 07:44:43 -0400 X-MC-Unique: UVBJ4r77P--7fgNw8dK3ow-1 X-Mimecast-MFC-AGG-ID: UVBJ4r77P--7fgNw8dK3ow_1741866283 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43d01024089so5946245e9.1 for ; Thu, 13 Mar 2025 04:44:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741866282; x=1742471082; 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=8P6wNaO+XIHVOsaMiUxPKzcQyyRjSmyu7hy/Ke33WeI=; b=wv+qV7Z/qQ5mleeWFO16MBUiJL0FELeiBAYaVFGiQX8s8OiwtGBbXiyJCz9LaSncUX ocdoJ+bAoijvN7DdppL6bYfgh6sDunO70oa0SLeyUrP4105CSCsaJYQxPRymArtLCdRB 7zPGRo5uiaGW9+/AQsW2ElTh61lEFLBhAWaA3kG3yH1AlD2lrEjojZ0MeUSmd6RKakaX ctlXUvZdXr7oFg9G+7WeX/x988ueKgFxYmrKBlJvjrwIdJHSB/vqcCReUD2wxOteI6BV VBZN9qdtOg8TJv+iuaWDEB/jEqd4p+0zKxa8P1LVfzXEjkSCuoHFx5TMF14+8H9bns8m j2Ow== X-Forwarded-Encrypted: i=1; AJvYcCU8o1KLD0DGBf21h/lAa/Qxc7g8gyGyZ/5zJCv9NKDsetXxttfmbzXh5OjssgqygXsepJHpQHuIzQ==@vger.kernel.org X-Gm-Message-State: AOJu0YzwSVvJGvJl8TDwV2xMHgFKxCAFtUtCNLDbc0jJkffzSJahlw0h +E1edT1DgtrIe7LowEB1S3uwhNEyQyEP19iPU9O+d/NJA7IAy6K7bcaO1VPnoPyLgEZug3xQNM5 ovd90wQrsRRp9a7z6PtKPsvDOz3ERhSdUdRCDKjl84Wc6gUnCeaY6TQxQ X-Gm-Gg: ASbGncs/ed2cC7sGEmxPHzGxP8bqS+A2KlY1wvERlxHyQB4Opwk9L0vMsuJwu3uIYSk dL7yFztOVA/kT59KgHpYxj1z5DxCM8DLzbzSAMa9CEPdf8yoREYk6YBAI4w+/BEBlICVNQtCQpd Lv6mMDN6Rp3sP4cdUe5ZTM1hg2x7Ytyr+3nGaD7x5zxPuMaF1GDZ0gc5ZZK16MeZ+ech+F8ClyT sy2p4SnBO0NIIMexLd+kAVo+3SZM092t8T1ibvpjonlUeuxJ54aUPLONn8J2MIcHVaXIzCMKQyZ rOpsPYItlMenhtoFrfMI X-Received: by 2002:a05:600c:46d3:b0:439:9424:1b70 with SMTP id 5b1f17b1804b1-43c602223f0mr255847095e9.30.1741866282645; Thu, 13 Mar 2025 04:44:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXX+a12CkpViQK6U7ArlV7I00zmbs9phG5wa1a6gevfoSJzXsUnRwbzS8Xh3mqpEsYOihpsg== X-Received: by 2002:a05:600c:46d3:b0:439:9424:1b70 with SMTP id 5b1f17b1804b1-43c602223f0mr255846615e9.30.1741866282213; Thu, 13 Mar 2025 04:44:42 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:44:41 -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 , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Alessandro Carminati Subject: [PATCH v4 06/14] x86: Add support for suppressing warning backtraces Date: Thu, 13 Mar 2025 11:43:21 +0000 Message-Id: <20250313114329.284104-7-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-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: LCsA_CEVqLbJ67IqrcuEjT7try8B1p6pYo763yLWZ9A_1741866283 X-Mimecast-Originator: redhat.com 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). Tested-by: Linux Kernel Functional Testing Acked-by: Dan Carpenter Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Signed-off-by: Guenter Roeck Signed-off-by: Alessandro Carminati --- 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 e85ac0c7c039..f6e13fc675ab 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -35,18 +35,28 @@ #ifdef CONFIG_DEBUG_BUGVERBOSE +#ifdef CONFIG_KUNIT_SUPPRESS_BACKTRACE +# 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 /* CONFIG_KUNIT_SUPPRESS_BACKTRACE */ + #define _BUG_FLAGS(ins, flags, extra) \ do { \ asm_inline volatile("1:\t" ins "\n" \ ".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) @@ -92,7 +102,8 @@ do { \ do { \ __auto_type __flags = BUGFLAG_WARNING|(flags); \ instrumentation_begin(); \ - _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE(1b)); \ + if (!KUNIT_IS_SUPPRESSED_WARNING(__func__)) \ + _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE(1b)); \ instrumentation_end(); \ } while (0)