qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target/alpha: fix tlb_fill trap_arg2 value for instruction fetch
@ 2019-08-21 13:39 Aurelien Jarno
  2019-08-21 13:52 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Aurelien Jarno @ 2019-08-21 13:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable, Aurelien Jarno, Richard Henderson

Commit e41c94529740cc26 ("target/alpha: Convert to CPUClass::tlb_fill")
slightly changed the way the trap_arg2 value is computed in case of TLB
fill. The type of the variable used in the ternary operator has been
changed from an int to an enum. This causes the -1 value to not be
sign-extended to 64-bit in case of an instruction fetch. The trap_arg2
ends up with 0xffffffff instead of 0xffffffffffffffff. Fix that by
changing the -1 into -1LL.

This fixes the execution of user space processes in qemu-system-alpha.

Fixes: e41c94529740cc26
Cc: qemu-stable@nongnu.org
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 target/alpha/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/alpha/helper.c b/target/alpha/helper.c
index 93b8e788b1..9e9d880c1a 100644
--- a/target/alpha/helper.c
+++ b/target/alpha/helper.c
@@ -283,7 +283,7 @@ bool alpha_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
         cs->exception_index = EXCP_MMFAULT;
         env->trap_arg0 = addr;
         env->trap_arg1 = fail;
-        env->trap_arg2 = (access_type == MMU_INST_FETCH ? -1 : access_type);
+        env->trap_arg2 = (access_type == MMU_INST_FETCH ? -1LL : access_type);
         cpu_loop_exit_restore(cs, retaddr);
     }
 
-- 
2.23.0.rc1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] target/alpha: fix tlb_fill trap_arg2 value for instruction fetch
  2019-08-21 13:39 [Qemu-devel] [PATCH] target/alpha: fix tlb_fill trap_arg2 value for instruction fetch Aurelien Jarno
@ 2019-08-21 13:52 ` Peter Maydell
  2019-08-22  2:56   ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2019-08-21 13:52 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: Richard Henderson, QEMU Developers, qemu-stable

On Wed, 21 Aug 2019 at 14:42, Aurelien Jarno <aurelien@aurel32.net> wrote:
>
> Commit e41c94529740cc26 ("target/alpha: Convert to CPUClass::tlb_fill")
> slightly changed the way the trap_arg2 value is computed in case of TLB
> fill. The type of the variable used in the ternary operator has been
> changed from an int to an enum. This causes the -1 value to not be
> sign-extended to 64-bit in case of an instruction fetch. The trap_arg2
> ends up with 0xffffffff instead of 0xffffffffffffffff. Fix that by
> changing the -1 into -1LL.
>
> This fixes the execution of user space processes in qemu-system-alpha.
>
> Fixes: e41c94529740cc26
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
>  target/alpha/helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/alpha/helper.c b/target/alpha/helper.c
> index 93b8e788b1..9e9d880c1a 100644
> --- a/target/alpha/helper.c
> +++ b/target/alpha/helper.c
> @@ -283,7 +283,7 @@ bool alpha_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
>          cs->exception_index = EXCP_MMFAULT;
>          env->trap_arg0 = addr;
>          env->trap_arg1 = fail;
> -        env->trap_arg2 = (access_type == MMU_INST_FETCH ? -1 : access_type);
> +        env->trap_arg2 = (access_type == MMU_INST_FETCH ? -1LL : access_type);
>          cpu_loop_exit_restore(cs, retaddr);
>      }

Oops. Thanks for the catch.

Maybe we should not rely directly on the value of the access_type
enum to set trap_arg2 at all (ie just go for a switch on access_type and
set env->trap_arg2 to the right h/w value in the three cases)?

thanks
-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] target/alpha: fix tlb_fill trap_arg2 value for instruction fetch
  2019-08-21 13:52 ` Peter Maydell
@ 2019-08-22  2:56   ` Richard Henderson
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2019-08-22  2:56 UTC (permalink / raw)
  To: Peter Maydell, Aurelien Jarno
  Cc: qemu-stable, QEMU Developers, Richard Henderson

On 8/21/19 6:52 AM, Peter Maydell wrote:
> On Wed, 21 Aug 2019 at 14:42, Aurelien Jarno <aurelien@aurel32.net> wrote:
>>
>> Commit e41c94529740cc26 ("target/alpha: Convert to CPUClass::tlb_fill")
>> slightly changed the way the trap_arg2 value is computed in case of TLB
>> fill. The type of the variable used in the ternary operator has been
>> changed from an int to an enum. This causes the -1 value to not be
>> sign-extended to 64-bit in case of an instruction fetch. The trap_arg2
>> ends up with 0xffffffff instead of 0xffffffffffffffff. Fix that by
>> changing the -1 into -1LL.
>>
>> This fixes the execution of user space processes in qemu-system-alpha.
>>
>> Fixes: e41c94529740cc26
>> Cc: qemu-stable@nongnu.org
>> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
>> ---
>>  target/alpha/helper.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/target/alpha/helper.c b/target/alpha/helper.c
>> index 93b8e788b1..9e9d880c1a 100644
>> --- a/target/alpha/helper.c
>> +++ b/target/alpha/helper.c
>> @@ -283,7 +283,7 @@ bool alpha_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
>>          cs->exception_index = EXCP_MMFAULT;
>>          env->trap_arg0 = addr;
>>          env->trap_arg1 = fail;
>> -        env->trap_arg2 = (access_type == MMU_INST_FETCH ? -1 : access_type);
>> +        env->trap_arg2 = (access_type == MMU_INST_FETCH ? -1LL : access_type);
>>          cpu_loop_exit_restore(cs, retaddr);
>>      }
> 
> Oops. Thanks for the catch.
> 
> Maybe we should not rely directly on the value of the access_type
> enum to set trap_arg2 at all (ie just go for a switch on access_type and
> set env->trap_arg2 to the right h/w value in the three cases)?

Yes, I'll do that.  I'm somewhat embarrassed that I haven't tested Alpha in a
while, and moreso because we just did a release.


r~


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-22  2:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-21 13:39 [Qemu-devel] [PATCH] target/alpha: fix tlb_fill trap_arg2 value for instruction fetch Aurelien Jarno
2019-08-21 13:52 ` Peter Maydell
2019-08-22  2:56   ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).