diff mbox

[1/7] target-arm: use correct do_interrupt handler for AArch64 user mode

Message ID 1399305623-22016-2-git-send-email-robherring2@gmail.com
State New
Headers show

Commit Message

Rob Herring May 5, 2014, 4 p.m. UTC
From: Rob Herring <rob.herring@linaro.org>

User mode emulation should never get interrupts and thus should not
use the system emulation exception handler function.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
---
 target-arm/cpu64.c      | 4 ++++
 target-arm/helper-a64.c | 3 +++
 2 files changed, 7 insertions(+)

Comments

Peter Maydell May 5, 2014, 4:15 p.m. UTC | #1
On 5 May 2014 17:00, Rob Herring <robherring2@gmail.com> wrote:
> From: Rob Herring <rob.herring@linaro.org>
>
> User mode emulation should never get interrupts and thus should not
> use the system emulation exception handler function.

This is true, but arm_cpu_do_interrupt() is also a system
emulation exception handler function, so it's no better.

I assume we're doing this because we're about to add
code to aarch64_cpu_do_interrupt() which doesn't compile
in user mode, though you don't mention this in the commit
message.

> @@ -187,7 +187,11 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
>  {
>      CPUClass *cc = CPU_CLASS(oc);
>
> +#if defined(CONFIG_USER_ONLY)
> +    cc->do_interrupt = arm_cpu_do_interrupt;
> +#else
>      cc->do_interrupt = aarch64_cpu_do_interrupt;
> +#endif

I think you can simply only do the assignment ifndef
CONFIG_USER_ONLY (which will leave the pointer NULL
for user-mode) -- it will never be called (and if it does
it'll be easier to find the bug if it's a segfault than if it
tries to execute the 32 bit system mode interrupt code...)

thanks
-- PMM
diff mbox

Patch

diff --git a/target-arm/cpu64.c b/target-arm/cpu64.c
index 8daa622..98d402f 100644
--- a/target-arm/cpu64.c
+++ b/target-arm/cpu64.c
@@ -187,7 +187,11 @@  static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
 {
     CPUClass *cc = CPU_CLASS(oc);
 
+#if defined(CONFIG_USER_ONLY)
+    cc->do_interrupt = arm_cpu_do_interrupt;
+#else
     cc->do_interrupt = aarch64_cpu_do_interrupt;
+#endif
     cc->set_pc = aarch64_cpu_set_pc;
     cc->gdb_read_register = aarch64_cpu_gdb_read_register;
     cc->gdb_write_register = aarch64_cpu_gdb_write_register;
diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c
index bf921cc..84411b4 100644
--- a/target-arm/helper-a64.c
+++ b/target-arm/helper-a64.c
@@ -438,6 +438,8 @@  float32 HELPER(fcvtx_f64_to_f32)(float64 a, CPUARMState *env)
     return r;
 }
 
+#if !defined(CONFIG_USER_ONLY)
+
 /* Handle a CPU exception.  */
 void aarch64_cpu_do_interrupt(CPUState *cs)
 {
@@ -512,3 +514,4 @@  void aarch64_cpu_do_interrupt(CPUState *cs)
     env->pc = addr;
     cs->interrupt_request |= CPU_INTERRUPT_EXITTB;
 }
+#endif