All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] target-mips: Ignore unassigned accesses with KVM
@ 2014-07-28 11:37 ` James Hogan
  0 siblings, 0 replies; 6+ messages in thread
From: James Hogan @ 2014-07-28 11:37 UTC (permalink / raw)
  To: qemu-devel, Aurelien Jarno, Peter Maydell
  Cc: kvm, James Hogan, Paolo Bonzini, Gleb Natapov, Christoffer Dall,
	Sanjay Lal

MIPS registers an unassigned access handler which raises a guest bus
error exception. However this causes QEMU to crash when KVM is enabled
as it isn't called from the main execution loop so longjmp() gets called
without a corresponding setjmp().

Until the KVM API can be updated to trigger a guest exception in
response to an MMIO exit, prevent the bus error exception being raised
from mips_cpu_unassigned_access() if KVM is enabled.

The check is at run time since the do_unassigned_access callback is
initialised before it is known whether KVM will be enabled.

The problem can be triggered with Malta emulation by making the guest
write to the reset region at physical address 0x1bf00000, since it is
marked read-only which is treated as unassigned for writes.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Sanjay Lal <sanjayl@kymasys.com>
---
 target-mips/op_helper.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index 27651a4a00c1..df97b35f8701 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -21,6 +21,7 @@
 #include "qemu/host-utils.h"
 #include "exec/helper-proto.h"
 #include "exec/cpu_ldst.h"
+#include "sysemu/kvm.h"
 
 #ifndef CONFIG_USER_ONLY
 static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global);
@@ -2168,6 +2169,16 @@ void mips_cpu_unassigned_access(CPUState *cs, hwaddr addr,
     MIPSCPU *cpu = MIPS_CPU(cs);
     CPUMIPSState *env = &cpu->env;
 
+    /*
+     * Raising an exception with KVM enabled will crash because it won't be from
+     * the main execution loop so the longjmp won't have a matching setjmp.
+     * Until we can trigger a bus error exception through KVM lets just ignore
+     * the access.
+     */
+    if (kvm_enabled()) {
+        return;
+    }
+
     if (is_exec) {
         helper_raise_exception(env, EXCP_IBE);
     } else {
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH] target-mips: Ignore unassigned accesses with KVM
@ 2014-07-28 11:37 ` James Hogan
  0 siblings, 0 replies; 6+ messages in thread
From: James Hogan @ 2014-07-28 11:37 UTC (permalink / raw)
  To: qemu-devel, Aurelien Jarno, Peter Maydell
  Cc: James Hogan, kvm, Gleb Natapov, Sanjay Lal, Paolo Bonzini,
	Christoffer Dall

MIPS registers an unassigned access handler which raises a guest bus
error exception. However this causes QEMU to crash when KVM is enabled
as it isn't called from the main execution loop so longjmp() gets called
without a corresponding setjmp().

Until the KVM API can be updated to trigger a guest exception in
response to an MMIO exit, prevent the bus error exception being raised
from mips_cpu_unassigned_access() if KVM is enabled.

The check is at run time since the do_unassigned_access callback is
initialised before it is known whether KVM will be enabled.

The problem can be triggered with Malta emulation by making the guest
write to the reset region at physical address 0x1bf00000, since it is
marked read-only which is treated as unassigned for writes.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Sanjay Lal <sanjayl@kymasys.com>
---
 target-mips/op_helper.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index 27651a4a00c1..df97b35f8701 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -21,6 +21,7 @@
 #include "qemu/host-utils.h"
 #include "exec/helper-proto.h"
 #include "exec/cpu_ldst.h"
+#include "sysemu/kvm.h"
 
 #ifndef CONFIG_USER_ONLY
 static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global);
@@ -2168,6 +2169,16 @@ void mips_cpu_unassigned_access(CPUState *cs, hwaddr addr,
     MIPSCPU *cpu = MIPS_CPU(cs);
     CPUMIPSState *env = &cpu->env;
 
+    /*
+     * Raising an exception with KVM enabled will crash because it won't be from
+     * the main execution loop so the longjmp won't have a matching setjmp.
+     * Until we can trigger a bus error exception through KVM lets just ignore
+     * the access.
+     */
+    if (kvm_enabled()) {
+        return;
+    }
+
     if (is_exec) {
         helper_raise_exception(env, EXCP_IBE);
     } else {
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] target-mips: Ignore unassigned accesses with KVM
  2014-07-28 11:37 ` [Qemu-devel] " James Hogan
@ 2014-07-28 21:36   ` Aurelien Jarno
  -1 siblings, 0 replies; 6+ messages in thread
From: Aurelien Jarno @ 2014-07-28 21:36 UTC (permalink / raw)
  To: James Hogan
  Cc: qemu-devel, Peter Maydell, kvm, Paolo Bonzini, Gleb Natapov,
	Christoffer Dall, Sanjay Lal

On Mon, Jul 28, 2014 at 12:37:50PM +0100, James Hogan wrote:
> MIPS registers an unassigned access handler which raises a guest bus
> error exception. However this causes QEMU to crash when KVM is enabled
> as it isn't called from the main execution loop so longjmp() gets called
> without a corresponding setjmp().
> 
> Until the KVM API can be updated to trigger a guest exception in
> response to an MMIO exit, prevent the bus error exception being raised
> from mips_cpu_unassigned_access() if KVM is enabled.
> 
> The check is at run time since the do_unassigned_access callback is
> initialised before it is known whether KVM will be enabled.
> 
> The problem can be triggered with Malta emulation by making the guest
> write to the reset region at physical address 0x1bf00000, since it is
> marked read-only which is treated as unassigned for writes.
> 
> Signed-off-by: James Hogan <james.hogan@imgtec.com>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Christoffer Dall <christoffer.dall@linaro.org>
> Cc: Sanjay Lal <sanjayl@kymasys.com>
> ---
>  target-mips/op_helper.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
> index 27651a4a00c1..df97b35f8701 100644
> --- a/target-mips/op_helper.c
> +++ b/target-mips/op_helper.c
> @@ -21,6 +21,7 @@
>  #include "qemu/host-utils.h"
>  #include "exec/helper-proto.h"
>  #include "exec/cpu_ldst.h"
> +#include "sysemu/kvm.h"
>  
>  #ifndef CONFIG_USER_ONLY
>  static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global);
> @@ -2168,6 +2169,16 @@ void mips_cpu_unassigned_access(CPUState *cs, hwaddr addr,
>      MIPSCPU *cpu = MIPS_CPU(cs);
>      CPUMIPSState *env = &cpu->env;
>  
> +    /*
> +     * Raising an exception with KVM enabled will crash because it won't be from
> +     * the main execution loop so the longjmp won't have a matching setjmp.
> +     * Until we can trigger a bus error exception through KVM lets just ignore
> +     * the access.
> +     */
> +    if (kvm_enabled()) {
> +        return;
> +    }
> +
>      if (is_exec) {
>          helper_raise_exception(env, EXCP_IBE);
>      } else {

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>

Note that even if the test is added for each exception, it is light
enough compared to triggering and handling an exception so that it has
no impact on performance.

Paolo, do you want to take this patch in your kvm tree?

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] target-mips: Ignore unassigned accesses with KVM
@ 2014-07-28 21:36   ` Aurelien Jarno
  0 siblings, 0 replies; 6+ messages in thread
From: Aurelien Jarno @ 2014-07-28 21:36 UTC (permalink / raw)
  To: James Hogan
  Cc: Peter Maydell, kvm, Gleb Natapov, qemu-devel, Sanjay Lal,
	Paolo Bonzini, Christoffer Dall

On Mon, Jul 28, 2014 at 12:37:50PM +0100, James Hogan wrote:
> MIPS registers an unassigned access handler which raises a guest bus
> error exception. However this causes QEMU to crash when KVM is enabled
> as it isn't called from the main execution loop so longjmp() gets called
> without a corresponding setjmp().
> 
> Until the KVM API can be updated to trigger a guest exception in
> response to an MMIO exit, prevent the bus error exception being raised
> from mips_cpu_unassigned_access() if KVM is enabled.
> 
> The check is at run time since the do_unassigned_access callback is
> initialised before it is known whether KVM will be enabled.
> 
> The problem can be triggered with Malta emulation by making the guest
> write to the reset region at physical address 0x1bf00000, since it is
> marked read-only which is treated as unassigned for writes.
> 
> Signed-off-by: James Hogan <james.hogan@imgtec.com>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Christoffer Dall <christoffer.dall@linaro.org>
> Cc: Sanjay Lal <sanjayl@kymasys.com>
> ---
>  target-mips/op_helper.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
> index 27651a4a00c1..df97b35f8701 100644
> --- a/target-mips/op_helper.c
> +++ b/target-mips/op_helper.c
> @@ -21,6 +21,7 @@
>  #include "qemu/host-utils.h"
>  #include "exec/helper-proto.h"
>  #include "exec/cpu_ldst.h"
> +#include "sysemu/kvm.h"
>  
>  #ifndef CONFIG_USER_ONLY
>  static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global);
> @@ -2168,6 +2169,16 @@ void mips_cpu_unassigned_access(CPUState *cs, hwaddr addr,
>      MIPSCPU *cpu = MIPS_CPU(cs);
>      CPUMIPSState *env = &cpu->env;
>  
> +    /*
> +     * Raising an exception with KVM enabled will crash because it won't be from
> +     * the main execution loop so the longjmp won't have a matching setjmp.
> +     * Until we can trigger a bus error exception through KVM lets just ignore
> +     * the access.
> +     */
> +    if (kvm_enabled()) {
> +        return;
> +    }
> +
>      if (is_exec) {
>          helper_raise_exception(env, EXCP_IBE);
>      } else {

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>

Note that even if the test is added for each exception, it is light
enough compared to triggering and handling an exception so that it has
no impact on performance.

Paolo, do you want to take this patch in your kvm tree?

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] target-mips: Ignore unassigned accesses with KVM
  2014-07-28 21:36   ` [Qemu-devel] " Aurelien Jarno
@ 2014-07-29  8:55     ` Paolo Bonzini
  -1 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2014-07-29  8:55 UTC (permalink / raw)
  To: Aurelien Jarno, James Hogan
  Cc: qemu-devel, Peter Maydell, kvm, Gleb Natapov, Christoffer Dall,
	Sanjay Lal

Il 28/07/2014 23:36, Aurelien Jarno ha scritto:
> On Mon, Jul 28, 2014 at 12:37:50PM +0100, James Hogan wrote:
>> MIPS registers an unassigned access handler which raises a guest bus
>> error exception. However this causes QEMU to crash when KVM is enabled
>> as it isn't called from the main execution loop so longjmp() gets called
>> without a corresponding setjmp().
>>
>> Until the KVM API can be updated to trigger a guest exception in
>> response to an MMIO exit, prevent the bus error exception being raised
>> from mips_cpu_unassigned_access() if KVM is enabled.
>>
>> The check is at run time since the do_unassigned_access callback is
>> initialised before it is known whether KVM will be enabled.
>>
>> The problem can be triggered with Malta emulation by making the guest
>> write to the reset region at physical address 0x1bf00000, since it is
>> marked read-only which is treated as unassigned for writes.
>>
>> Signed-off-by: James Hogan <james.hogan@imgtec.com>
>> Cc: Aurelien Jarno <aurelien@aurel32.net>
>> Cc: Peter Maydell <peter.maydell@linaro.org>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: Gleb Natapov <gleb@redhat.com>
>> Cc: Christoffer Dall <christoffer.dall@linaro.org>
>> Cc: Sanjay Lal <sanjayl@kymasys.com>
>> ---
>>  target-mips/op_helper.c | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
>> index 27651a4a00c1..df97b35f8701 100644
>> --- a/target-mips/op_helper.c
>> +++ b/target-mips/op_helper.c
>> @@ -21,6 +21,7 @@
>>  #include "qemu/host-utils.h"
>>  #include "exec/helper-proto.h"
>>  #include "exec/cpu_ldst.h"
>> +#include "sysemu/kvm.h"
>>  
>>  #ifndef CONFIG_USER_ONLY
>>  static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global);
>> @@ -2168,6 +2169,16 @@ void mips_cpu_unassigned_access(CPUState *cs, hwaddr addr,
>>      MIPSCPU *cpu = MIPS_CPU(cs);
>>      CPUMIPSState *env = &cpu->env;
>>  
>> +    /*
>> +     * Raising an exception with KVM enabled will crash because it won't be from
>> +     * the main execution loop so the longjmp won't have a matching setjmp.
>> +     * Until we can trigger a bus error exception through KVM lets just ignore
>> +     * the access.
>> +     */
>> +    if (kvm_enabled()) {
>> +        return;
>> +    }
>> +
>>      if (is_exec) {
>>          helper_raise_exception(env, EXCP_IBE);
>>      } else {
> 
> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
> 
> Note that even if the test is added for each exception, it is light
> enough compared to triggering and handling an exception so that it has
> no impact on performance.
> 
> Paolo, do you want to take this patch in your kvm tree?

Sure, I'll include it for 2.2.

Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] target-mips: Ignore unassigned accesses with KVM
@ 2014-07-29  8:55     ` Paolo Bonzini
  0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2014-07-29  8:55 UTC (permalink / raw)
  To: Aurelien Jarno, James Hogan
  Cc: Peter Maydell, kvm, Gleb Natapov, qemu-devel, Sanjay Lal,
	Christoffer Dall

Il 28/07/2014 23:36, Aurelien Jarno ha scritto:
> On Mon, Jul 28, 2014 at 12:37:50PM +0100, James Hogan wrote:
>> MIPS registers an unassigned access handler which raises a guest bus
>> error exception. However this causes QEMU to crash when KVM is enabled
>> as it isn't called from the main execution loop so longjmp() gets called
>> without a corresponding setjmp().
>>
>> Until the KVM API can be updated to trigger a guest exception in
>> response to an MMIO exit, prevent the bus error exception being raised
>> from mips_cpu_unassigned_access() if KVM is enabled.
>>
>> The check is at run time since the do_unassigned_access callback is
>> initialised before it is known whether KVM will be enabled.
>>
>> The problem can be triggered with Malta emulation by making the guest
>> write to the reset region at physical address 0x1bf00000, since it is
>> marked read-only which is treated as unassigned for writes.
>>
>> Signed-off-by: James Hogan <james.hogan@imgtec.com>
>> Cc: Aurelien Jarno <aurelien@aurel32.net>
>> Cc: Peter Maydell <peter.maydell@linaro.org>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: Gleb Natapov <gleb@redhat.com>
>> Cc: Christoffer Dall <christoffer.dall@linaro.org>
>> Cc: Sanjay Lal <sanjayl@kymasys.com>
>> ---
>>  target-mips/op_helper.c | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
>> index 27651a4a00c1..df97b35f8701 100644
>> --- a/target-mips/op_helper.c
>> +++ b/target-mips/op_helper.c
>> @@ -21,6 +21,7 @@
>>  #include "qemu/host-utils.h"
>>  #include "exec/helper-proto.h"
>>  #include "exec/cpu_ldst.h"
>> +#include "sysemu/kvm.h"
>>  
>>  #ifndef CONFIG_USER_ONLY
>>  static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global);
>> @@ -2168,6 +2169,16 @@ void mips_cpu_unassigned_access(CPUState *cs, hwaddr addr,
>>      MIPSCPU *cpu = MIPS_CPU(cs);
>>      CPUMIPSState *env = &cpu->env;
>>  
>> +    /*
>> +     * Raising an exception with KVM enabled will crash because it won't be from
>> +     * the main execution loop so the longjmp won't have a matching setjmp.
>> +     * Until we can trigger a bus error exception through KVM lets just ignore
>> +     * the access.
>> +     */
>> +    if (kvm_enabled()) {
>> +        return;
>> +    }
>> +
>>      if (is_exec) {
>>          helper_raise_exception(env, EXCP_IBE);
>>      } else {
> 
> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
> 
> Note that even if the test is added for each exception, it is light
> enough compared to triggering and handling an exception so that it has
> no impact on performance.
> 
> Paolo, do you want to take this patch in your kvm tree?

Sure, I'll include it for 2.2.

Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-07-29  8:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-28 11:37 [PATCH] target-mips: Ignore unassigned accesses with KVM James Hogan
2014-07-28 11:37 ` [Qemu-devel] " James Hogan
2014-07-28 21:36 ` Aurelien Jarno
2014-07-28 21:36   ` [Qemu-devel] " Aurelien Jarno
2014-07-29  8:55   ` Paolo Bonzini
2014-07-29  8:55     ` [Qemu-devel] " Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.