From: Christoffer Dall Subject: BUG: commit 50a2c6e breaks KVM/ARM (reset/init vcpu order) Date: Mon, 26 May 2014 11:18:13 +0200 Message-ID: <20140526091813.GA31431@lvm> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, Peter Maydell , Alexander Graf , afaerber@suse.de, Paolo Bonzini To: qemu-devel@nongnu.org Return-path: Received: from mail-lb0-f170.google.com ([209.85.217.170]:55086 "EHLO mail-lb0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751668AbaEZJSR (ORCPT ); Mon, 26 May 2014 05:18:17 -0400 Received: by mail-lb0-f170.google.com with SMTP id w7so4125025lbi.1 for ; Mon, 26 May 2014 02:18:16 -0700 (PDT) Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: Hi, I noticed that commit 50a2c6e55fa2ce5a2916a2c206bad2c6b0e06df1 broke KVM/ARM, because the realize function (arm_cpu_realizefn()) now calls cpu_reset() before qemu_init_vcpu(), which causes kvm_arm_reset_cpu() to segfault because it dereferences cpu->cpreg_reset_values, which is not allocated before kvm_arch_init_vcpu(). Simply changing the order of the reset/init calls (see the tiny patch below) seems to fix it, but I'm not completely sure this is a clean and correct fix: 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); } Please adivce :) Thanks, -Christoffer