diff mbox series

[for-6.2,15/43] target/sparc: Implement do_unaligned_access for user-only

Message ID 20210729004647.282017-16-richard.henderson@linaro.org
State New
Headers show
Series Unaligned accesses for user-only | expand

Commit Message

Richard Henderson July 29, 2021, 12:46 a.m. UTC
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 linux-user/sparc/cpu_loop.c | 11 +++++++++++
 target/sparc/cpu.c          |  2 +-
 target/sparc/ldst_helper.c  |  2 --
 3 files changed, 12 insertions(+), 3 deletions(-)

-- 
2.25.1

Comments

Philippe Mathieu-Daudé July 29, 2021, 9:40 a.m. UTC | #1
On 7/29/21 2:46 AM, Richard Henderson wrote:
> Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>  linux-user/sparc/cpu_loop.c | 11 +++++++++++

>  target/sparc/cpu.c          |  2 +-

>  target/sparc/ldst_helper.c  |  2 --

>  3 files changed, 12 insertions(+), 3 deletions(-)

> 

> diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c

> index 02532f198d..612e77807e 100644

> --- a/linux-user/sparc/cpu_loop.c

> +++ b/linux-user/sparc/cpu_loop.c

> @@ -272,6 +272,17 @@ void cpu_loop (CPUSPARCState *env)

>                  queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);

>              }

>              break;

> +        case TT_UNALIGNED:

> +            info.si_signo = TARGET_SIGBUS;

> +            info.si_errno = 0;

> +            info.si_code = TARGET_BUS_ADRALN;

> +#ifdef TARGET_SPARC64

> +            info._sifields._sigfault._addr = env->dmmu.sfar;

> +#else

> +            info._sifields._sigfault._addr = env->mmuregs[4];

> +#endif

> +            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);

> +            break;

>          case EXCP_DEBUG:

>              info.si_signo = TARGET_SIGTRAP;

>              info.si_errno = 0;

> diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c

> index da6b30ec74..d33d41e837 100644

> --- a/target/sparc/cpu.c

> +++ b/target/sparc/cpu.c

> @@ -865,11 +865,11 @@ static const struct TCGCPUOps sparc_tcg_ops = {

>      .synchronize_from_tb = sparc_cpu_synchronize_from_tb,

>      .cpu_exec_interrupt = sparc_cpu_exec_interrupt,

>      .tlb_fill = sparc_cpu_tlb_fill,

> +    .do_unaligned_access = sparc_cpu_do_unaligned_access,

>  

>  #ifndef CONFIG_USER_ONLY

>      .do_interrupt = sparc_cpu_do_interrupt,

>      .do_transaction_failed = sparc_cpu_do_transaction_failed,

> -    .do_unaligned_access = sparc_cpu_do_unaligned_access,

>  #endif /* !CONFIG_USER_ONLY */

>  };

>  #endif /* CONFIG_TCG */

> diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c

> index 7367b48c8b..69b812e68c 100644

> --- a/target/sparc/ldst_helper.c

> +++ b/target/sparc/ldst_helper.c

> @@ -1954,7 +1954,6 @@ void sparc_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,

>  }

>  #endif

>  

> -#if !defined(CONFIG_USER_ONLY)

>  void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,

>                                                   MMUAccessType access_type,

>                                                   int mmu_idx,

> @@ -1973,4 +1972,3 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,

>  

>      cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr);

>  }

> -#endif

> 


Somewhere around this patch I get:

  SKIPPED signals on sparc64 because BROKEN awaiting sigframe clean-ups
and vdso support
  TEST    test-mmap (default) on sparc64
timeout: the monitored command dumped core
Bus error
make[2]: *** [tests/tcg/multiarch/Makefile.target:49: run-test-mmap]
Error 135
make[1]: *** [tests/tcg/Makefile.qemu:102: run-guest-tests] Error 2
make: *** [tests/Makefile.include:63: run-tcg-tests-sparc64-linux-user]
Error 2
Richard Henderson July 29, 2021, 6:20 p.m. UTC | #2
On 7/28/21 11:40 PM, Philippe Mathieu-Daudé wrote:
> On 7/29/21 2:46 AM, Richard Henderson wrote:

>> Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

>> ---

>>   linux-user/sparc/cpu_loop.c | 11 +++++++++++

>>   target/sparc/cpu.c          |  2 +-

>>   target/sparc/ldst_helper.c  |  2 --

>>   3 files changed, 12 insertions(+), 3 deletions(-)

>>

>> diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c

>> index 02532f198d..612e77807e 100644

>> --- a/linux-user/sparc/cpu_loop.c

>> +++ b/linux-user/sparc/cpu_loop.c

>> @@ -272,6 +272,17 @@ void cpu_loop (CPUSPARCState *env)

>>                   queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);

>>               }

>>               break;

>> +        case TT_UNALIGNED:

>> +            info.si_signo = TARGET_SIGBUS;

>> +            info.si_errno = 0;

>> +            info.si_code = TARGET_BUS_ADRALN;

>> +#ifdef TARGET_SPARC64

>> +            info._sifields._sigfault._addr = env->dmmu.sfar;

>> +#else

>> +            info._sifields._sigfault._addr = env->mmuregs[4];

>> +#endif

>> +            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);

>> +            break;

>>           case EXCP_DEBUG:

>>               info.si_signo = TARGET_SIGTRAP;

>>               info.si_errno = 0;

>> diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c

>> index da6b30ec74..d33d41e837 100644

>> --- a/target/sparc/cpu.c

>> +++ b/target/sparc/cpu.c

>> @@ -865,11 +865,11 @@ static const struct TCGCPUOps sparc_tcg_ops = {

>>       .synchronize_from_tb = sparc_cpu_synchronize_from_tb,

>>       .cpu_exec_interrupt = sparc_cpu_exec_interrupt,

>>       .tlb_fill = sparc_cpu_tlb_fill,

>> +    .do_unaligned_access = sparc_cpu_do_unaligned_access,

>>   

>>   #ifndef CONFIG_USER_ONLY

>>       .do_interrupt = sparc_cpu_do_interrupt,

>>       .do_transaction_failed = sparc_cpu_do_transaction_failed,

>> -    .do_unaligned_access = sparc_cpu_do_unaligned_access,

>>   #endif /* !CONFIG_USER_ONLY */

>>   };

>>   #endif /* CONFIG_TCG */

>> diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c

>> index 7367b48c8b..69b812e68c 100644

>> --- a/target/sparc/ldst_helper.c

>> +++ b/target/sparc/ldst_helper.c

>> @@ -1954,7 +1954,6 @@ void sparc_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,

>>   }

>>   #endif

>>   

>> -#if !defined(CONFIG_USER_ONLY)

>>   void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,

>>                                                    MMUAccessType access_type,

>>                                                    int mmu_idx,

>> @@ -1973,4 +1972,3 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,

>>   

>>       cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr);

>>   }

>> -#endif

>>

> 

> Somewhere around this patch I get:

> 

>    SKIPPED signals on sparc64 because BROKEN awaiting sigframe clean-ups

> and vdso support

>    TEST    test-mmap (default) on sparc64

> timeout: the monitored command dumped core

> Bus error

> make[2]: *** [tests/tcg/multiarch/Makefile.target:49: run-test-mmap]

> Error 135

> make[1]: *** [tests/tcg/Makefile.qemu:102: run-guest-tests] Error 2

> make: *** [tests/Makefile.include:63: run-tcg-tests-sparc64-linux-user]


That's really surprising, since the do_unaligned_access hook is not yet used?  Oh, but 
then target/sparc/ does some of its own manual TT_UNALIGNED exceptions for some ASI 
access.  I'll have a look, but you should have been seeing a different assert for that case.


r~
diff mbox series

Patch

diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c
index 02532f198d..612e77807e 100644
--- a/linux-user/sparc/cpu_loop.c
+++ b/linux-user/sparc/cpu_loop.c
@@ -272,6 +272,17 @@  void cpu_loop (CPUSPARCState *env)
                 queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
             }
             break;
+        case TT_UNALIGNED:
+            info.si_signo = TARGET_SIGBUS;
+            info.si_errno = 0;
+            info.si_code = TARGET_BUS_ADRALN;
+#ifdef TARGET_SPARC64
+            info._sifields._sigfault._addr = env->dmmu.sfar;
+#else
+            info._sifields._sigfault._addr = env->mmuregs[4];
+#endif
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
         case EXCP_DEBUG:
             info.si_signo = TARGET_SIGTRAP;
             info.si_errno = 0;
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index da6b30ec74..d33d41e837 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -865,11 +865,11 @@  static const struct TCGCPUOps sparc_tcg_ops = {
     .synchronize_from_tb = sparc_cpu_synchronize_from_tb,
     .cpu_exec_interrupt = sparc_cpu_exec_interrupt,
     .tlb_fill = sparc_cpu_tlb_fill,
+    .do_unaligned_access = sparc_cpu_do_unaligned_access,
 
 #ifndef CONFIG_USER_ONLY
     .do_interrupt = sparc_cpu_do_interrupt,
     .do_transaction_failed = sparc_cpu_do_transaction_failed,
-    .do_unaligned_access = sparc_cpu_do_unaligned_access,
 #endif /* !CONFIG_USER_ONLY */
 };
 #endif /* CONFIG_TCG */
diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
index 7367b48c8b..69b812e68c 100644
--- a/target/sparc/ldst_helper.c
+++ b/target/sparc/ldst_helper.c
@@ -1954,7 +1954,6 @@  void sparc_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
 }
 #endif
 
-#if !defined(CONFIG_USER_ONLY)
 void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
                                                  MMUAccessType access_type,
                                                  int mmu_idx,
@@ -1973,4 +1972,3 @@  void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
 
     cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr);
 }
-#endif