diff mbox

[v2] arm: Bugfix: Fix cpu_reset() / vcpu_init() order

Message ID 1401193328-12786-1-git-send-email-christoffer.dall@linaro.org
State Superseded
Headers show

Commit Message

Christoffer Dall May 27, 2014, 12:22 p.m. UTC
Commit 50a2c6e55fa introduced a bug where QEMU would segfault on startup
when using KVM on ARM hosts, because kvm_arm_reset_cpu() accesses
cpu->cpreg_reset_values, which is not allocated before
kvm_arch_init_vcpu(). Fix this by not calling cpu_reset() until after
qemu_init_vcpu().

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
Changes since v1:
 - Updated commit message (current version by Peter Maydell)

 target-arm/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Färber May 27, 2014, 12:33 p.m. UTC | #1
Am 27.05.2014 14:22, schrieb Christoffer Dall:
> Commit 50a2c6e55fa introduced a bug where QEMU would segfault on startup
> when using KVM on ARM hosts, because kvm_arm_reset_cpu() accesses
> cpu->cpreg_reset_values, which is not allocated before
> kvm_arch_init_vcpu(). Fix this by not calling cpu_reset() until after
> qemu_init_vcpu().
> 
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> ---
> Changes since v1:
>  - Updated commit message (current version by Peter Maydell)

You missed updating the subject line. ;) That said,

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas
Christoffer Dall May 27, 2014, 12:39 p.m. UTC | #2
On 27 May 2014 14:33, Andreas Färber <afaerber@suse.de> wrote:
> Am 27.05.2014 14:22, schrieb Christoffer Dall:
>> Commit 50a2c6e55fa introduced a bug where QEMU would segfault on startup
>> when using KVM on ARM hosts, because kvm_arm_reset_cpu() accesses
>> cpu->cpreg_reset_values, which is not allocated before
>> kvm_arch_init_vcpu(). Fix this by not calling cpu_reset() until after
>> qemu_init_vcpu().
>>
>> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
>> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
>> ---
>> Changes since v1:
>>  - Updated commit message (current version by Peter Maydell)
>
> You missed updating the subject line. ;) That said,
>
> Reviewed-by: Andreas Färber <afaerber@suse.de>
>
goddammit, so much for my multi-tasking capabilities.  Hopefully v3
gets the job done, if not, we're probably better off letting Peter fix
it:)

/me goes back to reviewing kvm patches
diff mbox

Patch

diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index 6c6f2b3..794dcb9 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -370,8 +370,8 @@  static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
 
     init_cpreg_list(cpu);
 
-    cpu_reset(cs);
     qemu_init_vcpu(cs);
+    cpu_reset(cs);
 
     acc->parent_realize(dev, errp);
 }