diff mbox series

[v3,10/66] target/ppc: Set fault address in ppc_cpu_do_unaligned_access

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

Commit Message

Richard Henderson Aug. 18, 2021, 7:18 p.m. UTC
We ought to have been recording the virtual address for reporting
to the guest trap handler.

Cc: qemu-ppc@nongnu.org
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 target/ppc/excp_helper.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

-- 
2.25.1

Comments

Peter Maydell Aug. 19, 2021, 3:41 p.m. UTC | #1
On Wed, 18 Aug 2021 at 20:33, Richard Henderson
<richard.henderson@linaro.org> wrote:
>

> We ought to have been recording the virtual address for reporting

> to the guest trap handler.

>

> Cc: qemu-ppc@nongnu.org

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

> ---

>  target/ppc/excp_helper.c | 14 ++++++++++++++

>  1 file changed, 14 insertions(+)

>

> diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c

> index 0df358f93f..d7743704ac 100644

> --- a/target/ppc/excp_helper.c

> +++ b/target/ppc/excp_helper.c

> @@ -1504,6 +1504,20 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,

>  {

>      CPUPPCState *env = cs->env_ptr;

>

> +    switch (env->mmu_model) {

> +    case POWERPC_MMU_SOFT_4xx:

> +    case POWERPC_MMU_SOFT_4xx_Z:

> +        env->spr[SPR_40x_DEAR] = vaddr;

> +        break;

> +    case POWERPC_MMU_BOOKE:

> +    case POWERPC_MMU_BOOKE206:

> +        env->spr[SPR_BOOKE_DEAR] = vaddr;

> +        break;

> +    default:

> +        env->spr[SPR_DAR] = vaddr;

> +        break;

> +    }

> +

>      cs->exception_index = POWERPC_EXCP_ALIGN;

>      env->error_code = 0;

>      cpu_loop_exit_restore(cs, retaddr);

> --


Reviewed-by: Peter Maydell <peter.maydell@linaro.org>


thanks
-- PMM
diff mbox series

Patch

diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
index 0df358f93f..d7743704ac 100644
--- a/target/ppc/excp_helper.c
+++ b/target/ppc/excp_helper.c
@@ -1504,6 +1504,20 @@  void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
 {
     CPUPPCState *env = cs->env_ptr;
 
+    switch (env->mmu_model) {
+    case POWERPC_MMU_SOFT_4xx:
+    case POWERPC_MMU_SOFT_4xx_Z:
+        env->spr[SPR_40x_DEAR] = vaddr;
+        break;
+    case POWERPC_MMU_BOOKE:
+    case POWERPC_MMU_BOOKE206:
+        env->spr[SPR_BOOKE_DEAR] = vaddr;
+        break;
+    default:
+        env->spr[SPR_DAR] = vaddr;
+        break;
+    }
+
     cs->exception_index = POWERPC_EXCP_ALIGN;
     env->error_code = 0;
     cpu_loop_exit_restore(cs, retaddr);