From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Worcs-0000nr-CR for qemu-devel@nongnu.org; Mon, 26 May 2014 05:55:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Worcg-0002Dc-6U for qemu-devel@nongnu.org; Mon, 26 May 2014 05:55:26 -0400 Received: from mail-we0-x231.google.com ([2a00:1450:400c:c03::231]:60816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Worcf-0002DQ-Vn for qemu-devel@nongnu.org; Mon, 26 May 2014 05:55:14 -0400 Received: by mail-we0-f177.google.com with SMTP id x48so7524293wes.8 for ; Mon, 26 May 2014 02:55:12 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <53830F7A.3060306@redhat.com> Date: Mon, 26 May 2014 11:55:06 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <20140526091813.GA31431@lvm> In-Reply-To: <20140526091813.GA31431@lvm> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] BUG: commit 50a2c6e breaks KVM/ARM (reset/init vcpu order) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoffer Dall , qemu-devel@nongnu.org Cc: Peter Maydell , Alexander Graf , kvm@vger.kernel.org, afaerber@suse.de Il 26/05/2014 11:18, Christoffer Dall ha scritto: > 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 :) I looked at the kvm_arch_init_vcpu implementation and it looks good to me. Acked-by: Paolo Bonzini Paolo