From nobody Fri May 3 15:41:21 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1579601654; cv=none; d=zohomail.com; s=zohoarc; b=RGwXvLYL5Q4O5zWsWWbwkBgW3cB+8XGb8EEYbre6m1rx8MCffu6mY8jtDV0eTD4/Y9VmEudf0oA4CFSYqPR3OXcY0O1hD0H+gn0tWG448BJ3qFmzbAGaOiNfNy0lEiT0MGCmC7kdD0VWT85OTFztBKG79Z0XY/GGbEM4BzQHqII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579601654; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tEF2YzRf0FrC3h2lPTqTcAR/fnio/L8sFxnaOmgW7Rk=; b=ea859ynJgrJ5AhshB2ASPkxUsZAETwi5uUfxY7ryFdXzOKACBqR3Uc3KM0btum2kSaVPdUvRCBhuLA+JEYHYbHBYfOjAJzzjdh7GQwWZpFB+hSu5JffRA1UFXGNB2PtC6tEORzg9NkfRbz3WVZrwxhpOnSJB1/fKzxud+tGLCic= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1579601654489778.1156286291241; Tue, 21 Jan 2020 02:14:14 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1itqXH-0004gu-9Y; Tue, 21 Jan 2020 10:13:27 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1itqXF-0004gp-R7 for xen-devel@lists.xenproject.org; Tue, 21 Jan 2020 10:13:25 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a7003772-3c36-11ea-ba5f-12813bfff9fa; Tue, 21 Jan 2020 10:13:22 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 08E83B303; Tue, 21 Jan 2020 10:13:21 +0000 (UTC) X-Inumbo-ID: a7003772-3c36-11ea-ba5f-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Tue, 21 Jan 2020 11:13:00 +0100 Message-Id: <20200121101301.421-2-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200121101301.421-1-jgross@suse.com> References: <20200121101301.421-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v3 1/2] xen: add config option to include failing condition in BUG_ON() message X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Jan Beulich , Volodymyr Babchuk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Today a triggering BUG_ON() will only print source file and line information. Add the possibility to print the triggering condition like ASSERT(). Do that by introducing BUG_VERBOSE() and add a Kconfig option to make BUG_ON use BUG_VERBOSE(). Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- V3: - move kconfig option out of DEBUG || expert section (Jan Beulich) - fix ARM build (Jan Beulich) - eliminate BUG_ON_VERBOSE() (Jan Beulich) --- xen/Kconfig.debug | 8 +++++++- xen/include/asm-arm/bug.h | 6 ++++-- xen/include/asm-x86/bug.h | 5 +++-- xen/include/xen/lib.h | 4 ++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug index b3511e81a2..75c855e4ae 100644 --- a/xen/Kconfig.debug +++ b/xen/Kconfig.debug @@ -11,6 +11,13 @@ config DEBUG =20 You probably want to say 'N' here. =20 +config DEBUG_BUGVERBOSE + bool "Verbose BUG_ON messages" + default DEBUG + ---help--- + In case a BUG_ON triggers additionally print the triggering + condition on the console. + if DEBUG || EXPERT =3D "y" =20 config CRASH_DEBUG @@ -81,7 +88,6 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. =20 - config VERBOSE_DEBUG bool "Verbose debug messages" default DEBUG diff --git a/xen/include/asm-arm/bug.h b/xen/include/asm-arm/bug.h index 36c803357c..90b231e77a 100644 --- a/xen/include/asm-arm/bug.h +++ b/xen/include/asm-arm/bug.h @@ -60,11 +60,13 @@ struct bug_frame { =20 #define WARN() BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, "") =20 -#define BUG() do { \ - BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, ""); \ +#define BUG_VERBOSE(msg) do { \ + BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, msg); \ unreachable(); \ } while (0) =20 +#define BUG() BUG_VERBOSE("") + #define assert_failed(msg) do { \ BUG_FRAME(BUGFRAME_assert, __LINE__, __FILE__, 1, msg); \ unreachable(); \ diff --git a/xen/include/asm-x86/bug.h b/xen/include/asm-x86/bug.h index 9bb4a19420..46d282777f 100644 --- a/xen/include/asm-x86/bug.h +++ b/xen/include/asm-x86/bug.h @@ -60,10 +60,11 @@ struct bug_frame { =20 =20 #define WARN() BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, NULL) -#define BUG() do { \ - BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, NULL); \ +#define BUG_VERBOSE(msg) do { \ + BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, msg); \ unreachable(); \ } while (0) +#define BUG() BUG_VERBOSE(NULL) =20 #define run_in_exception_handler(fn) BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, = NULL) =20 diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 5d718bbdba..543b75952a 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -22,7 +22,11 @@ #include #include =20 +#ifdef CONFIG_DEBUG_BUGVERBOSE +#define BUG_ON(p) do { if (unlikely(p)) BUG_VERBOSE(#p); } while (0) +#else #define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0) +#endif #define WARN_ON(p) do { if (unlikely(p)) WARN(); } while (0) =20 #if __GNUC__ > 4 || (__GNUC__ =3D=3D 4 && __GNUC_MINOR__ >=3D 6) --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 15:41:21 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1579601656; cv=none; d=zohomail.com; s=zohoarc; b=FMeeQfVeQk7CDg+ziayRdfoOaF1l8SWb1zOTMtlQgc+AQLj9soJ47hfL4o0SretU4WSLGi1s+Qu5PrQpprF43egGEPxcZmJpSB2UlijCBlcScB8q6VLVCaVQt4V5JUiMPTAPnE8G7TE1M9L+xGIR9HkkKpDOXJn1ewRsbpz+FEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579601656; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/3JgL0JjzRKlbvYp1u9n6bcjufmvlhnEHEPO2Tpc6+0=; b=LDKWRCExx4mGTvbqj/iMe2fgNegaaETLPawufZWtmjZgP8wgyDITLrwBcyfihMMhpD9niyv3IZo/7GwyF9X1+3Ja2RgaDhiTU/nVfkkfTepctiZXl89BVisydomTA/JEiFeP4IpC/UhIL19zPAJlM7IY7HgPNoWI5cFUuVGIUeM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1579601656856649.1253664308877; Tue, 21 Jan 2020 02:14:16 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1itqXS-0004jf-TD; Tue, 21 Jan 2020 10:13:38 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1itqXS-0004jO-0m for xen-devel@lists.xenproject.org; Tue, 21 Jan 2020 10:13:38 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a7005f54-3c36-11ea-9fd7-bc764e2007e4; Tue, 21 Jan 2020 10:13:22 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 293DFB305; Tue, 21 Jan 2020 10:13:21 +0000 (UTC) X-Inumbo-ID: a7005f54-3c36-11ea-9fd7-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Tue, 21 Jan 2020 11:13:01 +0100 Message-Id: <20200121101301.421-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200121101301.421-1-jgross@suse.com> References: <20200121101301.421-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v3 2/2] xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In expert mode it is possible to enable CONFIG_DEBUG_LOCKS without having enabled CONFIG_DEBUG. The coding is depending on CONFIG_DEBUG as it is using ASSERT(), however. Fix that by using BUG_ON() instead of ASSERT() in rel_lock(). Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- xen/common/spinlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c index 286f916bca..344981c54a 100644 --- a/xen/common/spinlock.c +++ b/xen/common/spinlock.c @@ -86,7 +86,7 @@ static void got_lock(union lock_debug *debug) static void rel_lock(union lock_debug *debug) { if ( atomic_read(&spin_debug) > 0 ) - ASSERT(debug->cpu =3D=3D smp_processor_id()); + BUG_ON(debug->cpu !=3D smp_processor_id()); debug->cpu =3D SPINLOCK_NO_CPU; } =20 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel