[PATCH] target/arm: set the correct TI bits for WFIT traps

Alex Bennée posted 1 patch 1 month, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260220171945.1065102-1-alex.bennee@linaro.org
Maintainers: Peter Maydell <peter.maydell@linaro.org>
target/arm/tcg/op_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] target/arm: set the correct TI bits for WFIT traps
Posted by Alex Bennée 1 month, 2 weeks ago
The WFIT trap should be reported as 0b10.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 target/arm/tcg/op_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c
index 4d708635068..aa14f15eb62 100644
--- a/target/arm/tcg/op_helper.c
+++ b/target/arm/tcg/op_helper.c
@@ -448,7 +448,7 @@ void HELPER(wfit)(CPUARMState *env, uint64_t timeout)
 
     if (target_el) {
         env->pc -= 4;
-        raise_exception(env, excp, syn_wfx(1, 0xe, 0, false), target_el);
+        raise_exception(env, excp, syn_wfx(1, 0xe, 2, false), target_el);
     }
 
     if (uadd64_overflow(timeout, offset, &nexttick)) {
-- 
2.47.3


Re: [PATCH] target/arm: set the correct TI bits for WFIT traps
Posted by Peter Maydell 1 month, 2 weeks ago
On Fri, 20 Feb 2026 at 17:19, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> The WFIT trap should be reported as 0b10.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  target/arm/tcg/op_helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c
> index 4d708635068..aa14f15eb62 100644
> --- a/target/arm/tcg/op_helper.c
> +++ b/target/arm/tcg/op_helper.c
> @@ -448,7 +448,7 @@ void HELPER(wfit)(CPUARMState *env, uint64_t timeout)
>
>      if (target_el) {
>          env->pc -= 4;
> -        raise_exception(env, excp, syn_wfx(1, 0xe, 0, false), target_el);
> +        raise_exception(env, excp, syn_wfx(1, 0xe, 2, false), target_el);
>      }

It would be nice to also report the register number in the
syndrome (especially since KVM will use it if it's there),
but that is architecturally optional, and getting the TI bits
right is a bug fix.



Applied to target-arm.next, thanks.

-- PMM
Re: [PATCH] target/arm: set the correct TI bits for WFIT traps
Posted by Alex Bennée 1 month, 2 weeks ago
Peter Maydell <peter.maydell@linaro.org> writes:

> On Fri, 20 Feb 2026 at 17:19, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>> The WFIT trap should be reported as 0b10.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  target/arm/tcg/op_helper.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c
>> index 4d708635068..aa14f15eb62 100644
>> --- a/target/arm/tcg/op_helper.c
>> +++ b/target/arm/tcg/op_helper.c
>> @@ -448,7 +448,7 @@ void HELPER(wfit)(CPUARMState *env, uint64_t timeout)
>>
>>      if (target_el) {
>>          env->pc -= 4;
>> -        raise_exception(env, excp, syn_wfx(1, 0xe, 0, false), target_el);
>> +        raise_exception(env, excp, syn_wfx(1, 0xe, 2, false), target_el);
>>      }
>
> It would be nice to also report the register number in the
> syndrome (especially since KVM will use it if it's there),
> but that is architecturally optional, and getting the TI bits
> right is a bug fix.

Turned out just getting the rd information is trivially simple so I sent
a follow-up series.

  https://patchew.org/QEMU/20260224154347.344219-1-alex.bennee@linaro.org/

>
>
>
> Applied to target-arm.next, thanks.
>
> -- PMM

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH] target/arm: set the correct TI bits for WFIT traps
Posted by Gustavo Romero 1 month, 2 weeks ago
Hi Alex,

On 2/20/26 14:19, Alex Bennée wrote:
> The WFIT trap should be reported as 0b10.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   target/arm/tcg/op_helper.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c
> index 4d708635068..aa14f15eb62 100644
> --- a/target/arm/tcg/op_helper.c
> +++ b/target/arm/tcg/op_helper.c
> @@ -448,7 +448,7 @@ void HELPER(wfit)(CPUARMState *env, uint64_t timeout)
>   
>       if (target_el) {
>           env->pc -= 4;
> -        raise_exception(env, excp, syn_wfx(1, 0xe, 0, false), target_el);
> +        raise_exception(env, excp, syn_wfx(1, 0xe, 2, false), target_el);

As per the AArch64.WFxTrap() Arm Arm pseudo code:

Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>


Cheers,
Gustavo

>       }
>   
>       if (uadd64_overflow(timeout, offset, &nexttick)) {