From nobody Sat Apr 4 07:51:22 2026 Received: from canpmsgout04.his.huawei.com (canpmsgout04.his.huawei.com [113.46.200.219]) (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 4837737188B for ; Fri, 20 Mar 2026 08:27:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.219 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773995261; cv=none; b=CuOM1R50m9F3etU6xK934cjC3Mlp20Feu43kcfClc8BI/BOWr7oKW0ZTCd76TrLFJlP6xlfar5Rfj1CrDwCAtyM/wAQA54gxcXMVvNN3BftEQ6byMKETLiKOfHwvnaWypIYlYKLPN99IBhhXtPcblXQAB7m/rv9qTllG/mT5ASM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773995261; c=relaxed/simple; bh=Q/bjtjpvYj+7uJHqGpPwZQgj8Ir5koubeWchy6o2w0g=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=gtroN+ce/vNtC0MiHC9cSZALP2FmTzqtbZDFZWZcxnyR2vbO+YbJ1CkkVPf7mJO1ex8KAO07LVppQVG03N266k8PSWdyt5bf7LqCqKAodVfzcQw/ZcKPEtI6YJTkwqncjJLbCTPSaPOyn13ZQ+XFdnanG15hW3KMbdkbOPxXH5s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=FojeOfqb; arc=none smtp.client-ip=113.46.200.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="FojeOfqb" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=l0ilgx0xyMp7X9gWaw2IrK0zdXLdb+KGTOoAmT+gWtU=; b=FojeOfqbqP4/nonn1s0YSltg4mW9Y6kdJGqrsHisoozUTqeZDSEQ98KH2Lb1z1meWcHG8mTVU SSlO2lKcIS5UCubrzaWvm7xcZj6p6bj+FaMG/cJWk7pQwABzmpdaWXZd8dLoQFfO5M7I1iiZHdo 7isB74vdKlTx5IIxVn6iCLc= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4fcbCQ5jcHz1prLJ; Fri, 20 Mar 2026 16:22:26 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id C7966404AD; Fri, 20 Mar 2026 16:27:29 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 20 Mar 2026 16:27:28 +0800 From: Jinjie Ruan To: , , , , , , , , , , CC: Subject: [PATCH] arm64: traps: Add a macro to simplify the condition codes check Date: Fri, 20 Mar 2026 16:28:46 +0800 Message-ID: <20260320082846.1235016-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" 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 =20 -static bool __kprobes __check_eq(unsigned long pstate) -{ - return (pstate & PSR_Z_BIT) !=3D 0; -} - -static bool __kprobes __check_ne(unsigned long pstate) -{ - return (pstate & PSR_Z_BIT) =3D=3D 0; -} - -static bool __kprobes __check_cs(unsigned long pstate) -{ - return (pstate & PSR_C_BIT) !=3D 0; -} - -static bool __kprobes __check_cc(unsigned long pstate) -{ - return (pstate & PSR_C_BIT) =3D=3D 0; -} - -static bool __kprobes __check_mi(unsigned long pstate) -{ - return (pstate & PSR_N_BIT) !=3D 0; -} - -static bool __kprobes __check_pl(unsigned long pstate) -{ - return (pstate & PSR_N_BIT) =3D=3D 0; -} - -static bool __kprobes __check_vs(unsigned long pstate) -{ - return (pstate & PSR_V_BIT) !=3D 0; -} - -static bool __kprobes __check_vc(unsigned long pstate) -{ - return (pstate & PSR_V_BIT) =3D=3D 0; -} +#define DEFINE_COND_CHECK(name, flag, expected) \ +static bool __kprobes __check_##name(unsigned long pstate) \ +{ \ + return ((pstate & (flag)) !=3D 0) =3D=3D (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 */ =20 static bool __kprobes __check_hi(unsigned long pstate) { @@ -131,11 +107,6 @@ static bool __kprobes __check_le(unsigned long pstate) return (temp & PSR_N_BIT) !=3D 0; } =20 -static bool __kprobes __check_al(unsigned long pstate) -{ - return true; -} - /* * Note that the ARMv8 ARM calls condition code 0b1111 "nv", but states th= at * it behaves identically to 0b1110 ("al"). --=20 2.34.1