diff mbox series

[v2,18/55] target/sparc: Implement do_unaligned_access for user-only

Message ID 20210803041443.55452-19-richard.henderson@linaro.org
State Superseded
Headers show
Series Unaligned access for user-only | expand

Commit Message

Richard Henderson Aug. 3, 2021, 4:14 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/mmu_helper.c   |  4 +++-
 3 files changed, 15 insertions(+), 2 deletions(-)

-- 
2.25.1

Comments

Mark Cave-Ayland Aug. 18, 2021, 8:48 a.m. UTC | #1
On 03/08/2021 05:14, 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/mmu_helper.c   |  4 +++-

>   3 files changed, 15 insertions(+), 2 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/mmu_helper.c b/target/sparc/mmu_helper.c

> index 2f260b0085..6b4aa32181 100644

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

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

> @@ -946,6 +946,7 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)

>       }

>       return phys_addr;

>   }

> +#endif /* CONFIG_USER_ONLY */

>   

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

>                                                    MMUAccessType access_type,

> @@ -956,7 +957,9 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,

>       CPUSPARCState *env = &cpu->env;

>   

>   #ifdef TARGET_SPARC64

> +#ifndef CONFIG_USER_ONLY

>       env->dmmu.sfsr = build_sfsr(env, mmu_idx, access_type);

> +#endif

>       env->dmmu.sfar = addr;

>   #else

>       env->mmuregs[4] = addr;

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

>   

>       cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr);

>   }

> -#endif /* CONFIG_USER_ONLY */


I'm fairly weak on the user side, however the setting of the fault address looks okay 
to me so:

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



ATB,

Mark.
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/mmu_helper.c b/target/sparc/mmu_helper.c
index 2f260b0085..6b4aa32181 100644
--- a/target/sparc/mmu_helper.c
+++ b/target/sparc/mmu_helper.c
@@ -946,6 +946,7 @@  hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
     }
     return phys_addr;
 }
+#endif /* CONFIG_USER_ONLY */
 
 void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
                                                  MMUAccessType access_type,
@@ -956,7 +957,9 @@  void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
     CPUSPARCState *env = &cpu->env;
 
 #ifdef TARGET_SPARC64
+#ifndef CONFIG_USER_ONLY
     env->dmmu.sfsr = build_sfsr(env, mmu_idx, access_type);
+#endif
     env->dmmu.sfar = addr;
 #else
     env->mmuregs[4] = addr;
@@ -964,4 +967,3 @@  void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
 
     cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr);
 }
-#endif /* CONFIG_USER_ONLY */