From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout10.his.huawei.com (canpmsgout10.his.huawei.com [113.46.200.225]) (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 982152FA0DF for ; Wed, 22 Apr 2026 03:06:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.225 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776827207; cv=none; b=JtnAio0ubSCxtTdZeJrC066L74Nmcm3RO9J6NwZ5uYBrHUVTGyzPCSvkIc4ZuBbZWJaaFzQeWNp34ORYXCBySKMplwzemCD2tUBw9e+Z9XT0W0lQ+6Fbn3uujRZXcTZNlQsqSXoJ8AsoZ/jz7kwe6eZnhfTL6EwYueaupf8FQtc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776827207; c=relaxed/simple; bh=T1IQThO2iAo24hfKVzqi5owoPW+ECNRDjXuW509Z0yA=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=u+dpbUZI7Wv9Yqnpd2YBC7kV23waswxeIwsrOROmA3nV81gdxh7gjUpiT8YwbT7SjaEM37SVPJDdnwQ4Sfxs2sGEn0YfH3S3zwEqVVtTuPl1SQmm/lnzh2LRVyZyl5TcEIdN87j6FtdpIyeGr2uUW6T2zsb5KHMap4645iKwyXU= 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=pW7G/dPx; arc=none smtp.client-ip=113.46.200.225 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="pW7G/dPx" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=a1K1FlPxerHkP3OtkAaVvdapzcdqZs+umHPjWMKa3OM=; b=pW7G/dPxcTsFuEVM3uyarqrDXnKyps5rLrOKADI1Q7VoNCiMnQiunoJNWY67shG4vz6rSBb2u 4nf/PTB3Ad59fahfG1fV0wmV8veEE7pL4yFdkMoA18EALbPOUelwQ7grv1LHj5KBIoagZGyjwG3 804WW7mhG6/sCn1EHiqZn/g= Received: from mail.maildlp.com (unknown [172.19.163.163]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4g0kVP5P3dz1K99C; Wed, 22 Apr 2026 11:00:13 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 0152C4056E; Wed, 22 Apr 2026 11:06:34 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) 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; Wed, 22 Apr 2026 11:06:33 +0800 Message-ID: Date: Wed, 22 Apr 2026 11:06:30 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] arm64: traps: Add a macro to simplify the condition codes check To: , , , , , , , , , , References: <20260320082846.1235016-1-ruanjinjie@huawei.com> From: Jinjie Ruan In-Reply-To: <20260320082846.1235016-1-ruanjinjie@huawei.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To dggpemf500011.china.huawei.com (7.185.36.131) On 3/20/2026 4:28 PM, Jinjie Ruan wrote: > Add DEFINE_COND_CHECK macro to define the simple __check_* functions > to simplify the condition codes check. > > No functional changes. Gentle ping. > > 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 */ > > 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) != 0; > } > > -static bool __kprobes __check_al(unsigned long pstate) > -{ > - return true; > -} > - > /* > * Note that the ARMv8 ARM calls condition code 0b1111 "nv", but states that > * it behaves identically to 0b1110 ("al").