* [PATCH] arm64: traps: Add a macro to simplify the condition codes check
@ 2026-03-20 8:28 Jinjie Ruan
2026-04-22 3:06 ` Jinjie Ruan
2026-04-23 5:29 ` Anshuman Khandual
0 siblings, 2 replies; 6+ messages in thread
From: Jinjie Ruan @ 2026-03-20 8:28 UTC (permalink / raw)
To: catalin.marinas, will, mark.rutland, kees, maz, ada.coupriediaz,
smostafa, leitao, mrigendra.chaubey, linux-arm-kernel,
linux-kernel
Cc: ruanjinjie
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 <ruanjinjie@huawei.com>
---
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 <asm/system_misc.h>
#include <asm/sysreg.h>
-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").
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64: traps: Add a macro to simplify the condition codes check
2026-03-20 8:28 [PATCH] arm64: traps: Add a macro to simplify the condition codes check Jinjie Ruan
@ 2026-04-22 3:06 ` Jinjie Ruan
2026-04-22 14:43 ` Vladimir Murzin
2026-04-23 5:29 ` Anshuman Khandual
1 sibling, 1 reply; 6+ messages in thread
From: Jinjie Ruan @ 2026-04-22 3:06 UTC (permalink / raw)
To: catalin.marinas, will, mark.rutland, kees, maz, ada.coupriediaz,
smostafa, leitao, mrigendra.chaubey, linux-arm-kernel,
linux-kernel
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 <ruanjinjie@huawei.com>
> ---
> 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 <asm/system_misc.h>
> #include <asm/sysreg.h>
>
> -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").
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64: traps: Add a macro to simplify the condition codes check
2026-04-22 3:06 ` Jinjie Ruan
@ 2026-04-22 14:43 ` Vladimir Murzin
2026-04-22 15:16 ` Mark Rutland
0 siblings, 1 reply; 6+ messages in thread
From: Vladimir Murzin @ 2026-04-22 14:43 UTC (permalink / raw)
To: Jinjie Ruan, catalin.marinas, will, mark.rutland, kees, maz,
ada.coupriediaz, smostafa, leitao, mrigendra.chaubey,
linux-arm-kernel, linux-kernel
Hi Jinjie,
On 4/22/26 04:06, Jinjie Ruan wrote:
>
> 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 <ruanjinjie@huawei.com>
>> ---
>> 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 <asm/system_misc.h>
>> #include <asm/sysreg.h>
>>
>> -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").
>
It looks like we now have a mix of checks implemented via macros
and others written out explicitly. The existing approach has the
advantage of being consistent and easy to follow, whereas
introducing macros here, even if it reduces some duplication,
adds a bit of cognitive overhead when reading the code.
This may come down to preference, but I think sticking to a
single, consistent style would make the code easier to scan and
maintain.
Just my 2p.
Cheers
Vladimir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64: traps: Add a macro to simplify the condition codes check
2026-04-22 14:43 ` Vladimir Murzin
@ 2026-04-22 15:16 ` Mark Rutland
0 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2026-04-22 15:16 UTC (permalink / raw)
To: Vladimir Murzin
Cc: smostafa, kees, catalin.marinas, Jinjie Ruan, linux-kernel,
mrigendra.chaubey, maz, leitao, will, linux-arm-kernel
On Wed, Apr 22, 2026 at 03:43:39PM +0100, Vladimir Murzin wrote:
> Hi Jinjie,
>
> On 4/22/26 04:06, Jinjie Ruan wrote:
> >
> > 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 <ruanjinjie@huawei.com>
> >> ---
> >> 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 <asm/system_misc.h>
> >> #include <asm/sysreg.h>
> >>
> >> -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").
> >
>
> It looks like we now have a mix of checks implemented via macros
> and others written out explicitly. The existing approach has the
> advantage of being consistent and easy to follow, whereas
> introducing macros here, even if it reduces some duplication,
> adds a bit of cognitive overhead when reading the code.
>
> This may come down to preference, but I think sticking to a
> single, consistent style would make the code easier to scan and
> maintain.
FWIW, I agree. I think it'd be better to leave this as-is for now.
Mark.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64: traps: Add a macro to simplify the condition codes check
2026-03-20 8:28 [PATCH] arm64: traps: Add a macro to simplify the condition codes check Jinjie Ruan
2026-04-22 3:06 ` Jinjie Ruan
@ 2026-04-23 5:29 ` Anshuman Khandual
2026-04-23 8:04 ` Marc Zyngier
1 sibling, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2026-04-23 5:29 UTC (permalink / raw)
To: Jinjie Ruan, catalin.marinas, will, mark.rutland, kees, maz,
ada.coupriediaz, smostafa, leitao, mrigendra.chaubey,
linux-arm-kernel, linux-kernel
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 <ruanjinjie@huawei.com>
> ---
> 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 <asm/system_misc.h>
> #include <asm/sysreg.h>
>
> -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.
>
> 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").
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64: traps: Add a macro to simplify the condition codes check
2026-04-23 5:29 ` Anshuman Khandual
@ 2026-04-23 8:04 ` Marc Zyngier
0 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2026-04-23 8:04 UTC (permalink / raw)
To: Anshuman Khandual
Cc: mark.rutland, smostafa, kees, catalin.marinas, Jinjie Ruan,
linux-kernel, mrigendra.chaubey, leitao, will, linux-arm-kernel
On Thu, 23 Apr 2026 06:29:09 +0100,
Anshuman Khandual <anshuman.khandual@arm.com> 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 <ruanjinjie@huawei.com>
> > ---
> > 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 <asm/system_misc.h>
> > #include <asm/sysreg.h>
> >
> > -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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-04-23 8:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 8:28 [PATCH] arm64: traps: Add a macro to simplify the condition codes check Jinjie Ruan
2026-04-22 3:06 ` Jinjie Ruan
2026-04-22 14:43 ` Vladimir Murzin
2026-04-22 15:16 ` Mark Rutland
2026-04-23 5:29 ` Anshuman Khandual
2026-04-23 8:04 ` Marc Zyngier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox