diff mbox series

[for-6.2,04/43] target/hppa: Implement do_unaligned_access for user-only

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

Commit Message

Richard Henderson July 29, 2021, 12:46 a.m. UTC
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 linux-user/hppa/cpu_loop.c | 2 +-
 target/hppa/cpu.c          | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

-- 
2.25.1

Comments

Peter Maydell July 29, 2021, 1:15 p.m. UTC | #1
On Thu, 29 Jul 2021 at 01:57, Richard Henderson
<richard.henderson@linaro.org> wrote:
>

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

> ---

>  linux-user/hppa/cpu_loop.c | 2 +-

>  target/hppa/cpu.c          | 8 +++++---

>  2 files changed, 6 insertions(+), 4 deletions(-)

>

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

> index 82d8183821..5ce30fec8b 100644

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

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

> @@ -161,7 +161,7 @@ void cpu_loop(CPUHPPAState *env)

>          case EXCP_UNALIGN:

>              info.si_signo = TARGET_SIGBUS;

>              info.si_errno = 0;

> -            info.si_code = 0;

> +            info.si_code = TARGET_BUS_ADRALN;

>              info._sifields._sigfault._addr = env->cr[CR_IOR];

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

>              break;

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

> index 2eace4ee12..55c0d81046 100644

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

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

> @@ -71,7 +71,6 @@ static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)

>      info->print_insn = print_insn_hppa;

>  }

>

> -#ifndef CONFIG_USER_ONLY

>  static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,

>                                           MMUAccessType access_type,

>                                           int mmu_idx, uintptr_t retaddr)

> @@ -80,15 +79,18 @@ static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,

>      CPUHPPAState *env = &cpu->env;

>

>      cs->exception_index = EXCP_UNALIGN;

> +#ifdef CONFIG_USER_ONLY

> +    env->cr[CR_IOR] = addr;


Do we not need the top 32 bits of the address, which the softmmu
version is recording in CR_ISR ?

> +#else

>      if (env->psw & PSW_Q) {

>          /* ??? Needs tweaking for hppa64.  */

>          env->cr[CR_IOR] = addr;

>          env->cr[CR_ISR] = addr >> 32;

>      }

> +#endif

>

>      cpu_loop_exit_restore(cs, retaddr);

>  }

> -#endif /* CONFIG_USER_ONLY */


-- PMM
Richard Henderson July 29, 2021, 5:55 p.m. UTC | #2
On 7/29/21 3:15 AM, Peter Maydell wrote:
> On Thu, 29 Jul 2021 at 01:57, Richard Henderson

> <richard.henderson@linaro.org> wrote:

>>

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

>> ---

>>   linux-user/hppa/cpu_loop.c | 2 +-

>>   target/hppa/cpu.c          | 8 +++++---

>>   2 files changed, 6 insertions(+), 4 deletions(-)

>>

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

>> index 82d8183821..5ce30fec8b 100644

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

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

>> @@ -161,7 +161,7 @@ void cpu_loop(CPUHPPAState *env)

>>           case EXCP_UNALIGN:

>>               info.si_signo = TARGET_SIGBUS;

>>               info.si_errno = 0;

>> -            info.si_code = 0;

>> +            info.si_code = TARGET_BUS_ADRALN;

>>               info._sifields._sigfault._addr = env->cr[CR_IOR];

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

>>               break;

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

>> index 2eace4ee12..55c0d81046 100644

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

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

>> @@ -71,7 +71,6 @@ static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)

>>       info->print_insn = print_insn_hppa;

>>   }

>>

>> -#ifndef CONFIG_USER_ONLY

>>   static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,

>>                                            MMUAccessType access_type,

>>                                            int mmu_idx, uintptr_t retaddr)

>> @@ -80,15 +79,18 @@ static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,

>>       CPUHPPAState *env = &cpu->env;

>>

>>       cs->exception_index = EXCP_UNALIGN;

>> +#ifdef CONFIG_USER_ONLY

>> +    env->cr[CR_IOR] = addr;

> 

> Do we not need the top 32 bits of the address, which the softmmu

> version is recording in CR_ISR ?


No.  That's the "space" number, which for Linux user is always 0.

In system mode we use 64-bit addresses to make sure we can represent that; in user-only, 
we use 32-bit addresses.

r~

>> +#else

>>       if (env->psw & PSW_Q) {

>>           /* ??? Needs tweaking for hppa64.  */

>>           env->cr[CR_IOR] = addr;

>>           env->cr[CR_ISR] = addr >> 32;

>>       }

>> +#endif

>>

>>       cpu_loop_exit_restore(cs, retaddr);

>>   }

>> -#endif /* CONFIG_USER_ONLY */

> 

> -- PMM

>
diff mbox series

Patch

diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c
index 82d8183821..5ce30fec8b 100644
--- a/linux-user/hppa/cpu_loop.c
+++ b/linux-user/hppa/cpu_loop.c
@@ -161,7 +161,7 @@  void cpu_loop(CPUHPPAState *env)
         case EXCP_UNALIGN:
             info.si_signo = TARGET_SIGBUS;
             info.si_errno = 0;
-            info.si_code = 0;
+            info.si_code = TARGET_BUS_ADRALN;
             info._sifields._sigfault._addr = env->cr[CR_IOR];
             queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
             break;
diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index 2eace4ee12..55c0d81046 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -71,7 +71,6 @@  static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
     info->print_insn = print_insn_hppa;
 }
 
-#ifndef CONFIG_USER_ONLY
 static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
                                          MMUAccessType access_type,
                                          int mmu_idx, uintptr_t retaddr)
@@ -80,15 +79,18 @@  static void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
     CPUHPPAState *env = &cpu->env;
 
     cs->exception_index = EXCP_UNALIGN;
+#ifdef CONFIG_USER_ONLY
+    env->cr[CR_IOR] = addr;
+#else
     if (env->psw & PSW_Q) {
         /* ??? Needs tweaking for hppa64.  */
         env->cr[CR_IOR] = addr;
         env->cr[CR_ISR] = addr >> 32;
     }
+#endif
 
     cpu_loop_exit_restore(cs, retaddr);
 }
-#endif /* CONFIG_USER_ONLY */
 
 static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
 {
@@ -146,10 +148,10 @@  static const struct TCGCPUOps hppa_tcg_ops = {
     .synchronize_from_tb = hppa_cpu_synchronize_from_tb,
     .cpu_exec_interrupt = hppa_cpu_exec_interrupt,
     .tlb_fill = hppa_cpu_tlb_fill,
+    .do_unaligned_access = hppa_cpu_do_unaligned_access,
 
 #ifndef CONFIG_USER_ONLY
     .do_interrupt = hppa_cpu_do_interrupt,
-    .do_unaligned_access = hppa_cpu_do_unaligned_access,
 #endif /* !CONFIG_USER_ONLY */
 };