From mboxrd@z Thu Jan 1 00:00:00 1970 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 3D0E2F99350 for ; Thu, 23 Apr 2026 08:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: MIME-Version:References:In-Reply-To:Subject:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=y83iUPAKvYT1ek6ribgh/7zCM3p3RtrhhjsRYjN01rg=; b=yWU9+qnRZivH2ZQz04VDrl+7eB lsoEO4F7k0ZxjN0fPl5VlnUy1s2figW0jES1q2LBw9eg4Ww/UH3bR9n3rKNcBsUJiGtjZ3CyauSCt l+mCEoC566bTWveiCDigT4UVAaIn9iFM1goCyHPLU6VkDiSvmjl2O04zU9U+E5bHvjQII+q19Hy5c jZtTJHbKi5YpDPvNcKdnjyQaF5P5b0apkgQ9LlcXetTZVmWJxF/5eoc0HoRbhjXKBaRDdY7hZgrVn MbtuMh8AaZSBViqv/F/P6eE/hYIk6s5MeVFD7BwwzZp7hfr+GAvquii34iYlx9H4X0adssg4ixsnD HHrgukBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wFp3E-0000000BCQx-31yb; Thu, 23 Apr 2026 08:04:44 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wFp3D-0000000BCQr-1tYE for linux-arm-kernel@lists.infradead.org; Thu, 23 Apr 2026 08:04:43 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id A2EBF60052; Thu, 23 Apr 2026 08:04:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54D34C2BCAF; Thu, 23 Apr 2026 08:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776931482; bh=qG9pG1phr7b239BL1vrZMGDft9bK9wGgMZDgINmbnOg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IC2Ntx9xNKoQGHHqsXPbV5RvHaXjNGE3pMlZEnorannyjObrEaOMgjnM+ZWCl78/3 03HX0nlcnuY9zGgY4rY0c393i5WiJXgtU7UiEOUTkwASCITLjkQ5iGJrCdxknnAbTQ d9imafkf/+Iuf82uXVCzvNcbRa8Zvt9relvLSxxnvubKaCHAcWiWPOr73uMVdXfiZy 1+PIHuYXKMvAqiY7culbjJWwADLUPf9NfrqTM+jzXo5QtIMb5ROFqsCR0sDCwSVAen Cl64WBrRj7q3Jcd0ODrfPjRorLobl/O/xULUnciid5LKe22dpYFr7okEWTEaIFWgku BOSLrRxY6Z4hA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wFp3A-0000000Dy5B-07WP; Thu, 23 Apr 2026 08:04:40 +0000 Date: Thu, 23 Apr 2026 09:04:39 +0100 Message-ID: <868qae14rs.wl-maz@kernel.org> From: Marc Zyngier To: Anshuman Khandual Subject: Re: [PATCH] arm64: traps: Add a macro to simplify the condition codes check In-Reply-To: References: <20260320082846.1235016-1-ruanjinjie@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: anshuman.khandual@arm.com, ruanjinjie@huawei.com, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, kees@kernel.org, ada.coupriediaz@arm.com, smostafa@google.com, leitao@debian.org, mrigendra.chaubey@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false 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: , Cc: mark.rutland@arm.com, smostafa@google.com, kees@kernel.org, catalin.marinas@arm.com, Jinjie Ruan , linux-kernel@vger.kernel.org, mrigendra.chaubey@gmail.com, leitao@debian.org, will@kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 23 Apr 2026 06:29:09 +0100, Anshuman Khandual wrote: > > > > On 20/03/26 1:58 PM, Jinjie Ruan wrote: > > Add DEFINE_COND_CHECK macro to define the simple __check_* functions > > to simplify the condition codes check. > > > > No functional changes. > > > > Signed-off-by: Jinjie Ruan > > --- > > arch/arm64/kernel/traps.c | 59 ++++++++++----------------------------- > > 1 file changed, 15 insertions(+), 44 deletions(-) > > > > diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c > > index 914282016069..6216fe9e8e42 100644 > > --- a/arch/arm64/kernel/traps.c > > +++ b/arch/arm64/kernel/traps.c > > @@ -49,45 +49,21 @@ > > #include > > #include > > > > -static bool __kprobes __check_eq(unsigned long pstate) > > -{ > > - return (pstate & PSR_Z_BIT) != 0; > > -} > > - > > -static bool __kprobes __check_ne(unsigned long pstate) > > -{ > > - return (pstate & PSR_Z_BIT) == 0; > > -} > > - > > -static bool __kprobes __check_cs(unsigned long pstate) > > -{ > > - return (pstate & PSR_C_BIT) != 0; > > -} > > - > > -static bool __kprobes __check_cc(unsigned long pstate) > > -{ > > - return (pstate & PSR_C_BIT) == 0; > > -} > > - > > -static bool __kprobes __check_mi(unsigned long pstate) > > -{ > > - return (pstate & PSR_N_BIT) != 0; > > -} > > - > > -static bool __kprobes __check_pl(unsigned long pstate) > > -{ > > - return (pstate & PSR_N_BIT) == 0; > > -} > > - > > -static bool __kprobes __check_vs(unsigned long pstate) > > -{ > > - return (pstate & PSR_V_BIT) != 0; > > -} > > - > > -static bool __kprobes __check_vc(unsigned long pstate) > > -{ > > - return (pstate & PSR_V_BIT) == 0; > > -} > > +#define DEFINE_COND_CHECK(name, flag, expected) \ > > +static bool __kprobes __check_##name(unsigned long pstate) \ > > +{ \ > > + return ((pstate & (flag)) != 0) == (expected); \ > > +} > > + > > +DEFINE_COND_CHECK(eq, PSR_Z_BIT, true) > > +DEFINE_COND_CHECK(ne, PSR_Z_BIT, false) > > +DEFINE_COND_CHECK(cs, PSR_C_BIT, true) > > +DEFINE_COND_CHECK(cc, PSR_C_BIT, false) > > +DEFINE_COND_CHECK(mi, PSR_N_BIT, true) > > +DEFINE_COND_CHECK(pl, PSR_N_BIT, false) > > +DEFINE_COND_CHECK(vs, PSR_V_BIT, true) > > +DEFINE_COND_CHECK(vc, PSR_V_BIT, false) > > +DEFINE_COND_CHECK(al, 0, false) /* Always true */ > > (((pstate & 0 == 0) != 0) == false) ---> return true > > Although this looks OK but wondering if __check_al() should > be left unchanged for simplicity. OR could all its call sites > be changed assuming an unconditional 'true' return thus later > __check_al() can be dropped. Which call site? We emulate an instruction, and we're not in control of the condition code associated with it. The condition code directly indexes into aarch32_opcode_cond_checks[]. Anyway, this is a moot point, as we have consensus to not touch that code at all. M. -- Without deviation from the norm, progress is not possible.