From nobody Fri May 17 18:27:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1661336574; cv=none; d=zohomail.com; s=zohoarc; b=GeaVU7z96MXJhYHVzC8VCD8bjXhy8ZiBP+j6Klp+Q5WcG8zmsgTjtw/gDB6yJv2BVZfaLtla1c3DaFqyQrjCnO7Ss+yYx83xMemWCMR1Z5M1zk5BTW4t11E+jlVRcLXMhlpkuanb1FRtGOmkuPk52wqJbaPLPO/1fev7O4IZtBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661336574; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=/7EYD7Keid1p57myps4QR3QvxF3egN0T6fhaNudvLW0=; b=A8H2yB6BZmidlyXQXx8M3QKwEKyM/tfIL9OMFWZWD7v+oQ2z5ynaGzpl77IH996s9lw6Np15uhnMa2CVvRK+b3cwrZkAC739ciAbjY49ILM3Nvx1CvD4Nm6GmvuddGbMOCtgETWVhZT2WmyPqGv9QbtR9Q2ocLuSENnf+ROX10U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1661336574612922.7640624778267; Wed, 24 Aug 2022 03:22:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.392368.630670 (Exim 4.92) (envelope-from ) id 1oQnWn-00039s-LY; Wed, 24 Aug 2022 10:22:29 +0000 Received: by outflank-mailman (output) from mailman id 392368.630670; Wed, 24 Aug 2022 10:22:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oQnWn-00039l-Ir; Wed, 24 Aug 2022 10:22:29 +0000 Received: by outflank-mailman (input) for mailman id 392368; Wed, 24 Aug 2022 10:22:28 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oQnWm-00039P-4i for xen-devel@lists.xenproject.org; Wed, 24 Aug 2022 10:22:28 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a6d0ec8e-2396-11ed-9250-1f966e50362f; Wed, 24 Aug 2022 12:22:27 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B7278203AB; Wed, 24 Aug 2022 10:22:26 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 69BBE13AC0; Wed, 24 Aug 2022 10:22:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id z1VqGOL7BWNCGQAAMHmgww (envelope-from ); Wed, 24 Aug 2022 10:22:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a6d0ec8e-2396-11ed-9250-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1661336546; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=/7EYD7Keid1p57myps4QR3QvxF3egN0T6fhaNudvLW0=; b=Vc4VIyX2sK0MlN5HoOs6QGgP7qxdRX1eTIKAMnFz3PdckVok5H88iTzSjA9UaMaEeUTwUb tUBwA8K17e2PkI5L1lrUwQABsF6TpWG8tBHKi58mKrjvqYoC1ilQbqtpEdiobe/wLCakYW gUW6IFi7xrCwtzLibB5gYT9IW+KTcvs= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Henry.Wang@arm.com, Juergen Gross , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH] xen: let ASSERT_UNREACHABLE() WARN() in non-debug builds Date: Wed, 24 Aug 2022 12:22:25 +0200 Message-Id: <20220824102225.11431-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1661336575845100001 Content-Type: text/plain; charset="utf-8" Hitting an ASSERT_UNREACHABLE() is always wrong, so even in production builds a warning seems to be appropriate when hitting one. In order not to flood the console in reproducible cases, introduce WARN_ONCE() to be used in this case. Signed-off-by: Juergen Gross Acked-by: Julien Grall --- Notice for the release manager: this patch isn't really urgent for the 4.17 release, OTOH it is adding probably useful debug information for the unlikely case of hitting an ASSERT_UNREACHABLE(). The risk for taking the patch should be rather low, but you have the last saying, of course. Signed-off-by: Juergen Gross --- xen/include/xen/lib.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 05ee1e18af..b8472d753c 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -40,6 +40,16 @@ unlikely(ret_warn_on_); \ }) =20 +#define WARN_ONCE() do { \ + static bool warned =3D false; \ + \ + if ( !warned ) \ + { \ + warned =3D true; \ + WARN(); \ + } \ +} while (0) + /* All clang versions supported by Xen have _Static_assert. */ #if defined(__clang__) || \ (__GNUC__ > 4 || (__GNUC__ =3D=3D 4 && __GNUC_MINOR__ >=3D 6)) @@ -63,7 +73,7 @@ #define ASSERT_UNREACHABLE() assert_failed("unreachable") #else #define ASSERT(p) do { if ( 0 && (p) ) {} } while (0) -#define ASSERT_UNREACHABLE() do { } while (0) +#define ASSERT_UNREACHABLE() WARN_ONCE() #endif =20 #define ABS(_x) ({ \ --=20 2.35.3