From patchwork Fri Oct 10 15:19:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 38593 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A888B205D8 for ; Fri, 10 Oct 2014 15:20:11 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id cc10sf964100wib.11 for ; Fri, 10 Oct 2014 08:20:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=MBv7vSGUXCnfSFxxRGl5Qo82MGu6+eY6MvmxGLjamsw=; b=JdJEUqsZ9DoYnKmqsdUpWb/8EbyFYMSMzYlJ+XCrke3cNaAthacGUYqLKh8zYriNPr yraOBX8oGtS1iPR4NJjZ3S4PjJwYDXIhP8LMFesx1iHY9rauILPSbcBvz/QEPSTuwMQp z5wGPc+9ezwbv4BwEqnyM2Rg0wrZTU70byKJzaZ0o0WZf2s90/S2wOOkg2+MVe32M6O1 BEeGeAdD+BRj5da1Sw8BnvolR+ow/qoAF01l990Dfr5mSZLUdJX9urEsY8yI0Dlm0xvt VNTRsghiSLC7rqjTllLKN83Au1Ep0T2qaoLFqsxUN2g4+CGJTv6UIIcSk08Cz/c5Q+tj p0jw== X-Gm-Message-State: ALoCoQlRrnLRDou2dIOzZ0KGOAfYUYQhbyd4uKzgqTg2QTexRZiKgx9h1yU8OE6Fs+3M/mopPd8X X-Received: by 10.180.106.197 with SMTP id gw5mr1186136wib.1.1412954410845; Fri, 10 Oct 2014 08:20:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.131 with SMTP id f3ls284185lae.38.gmail; Fri, 10 Oct 2014 08:20:10 -0700 (PDT) X-Received: by 10.112.132.102 with SMTP id ot6mr5383742lbb.15.1412954410585; Fri, 10 Oct 2014 08:20:10 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by mx.google.com with ESMTPS id y2si9798821lae.49.2014.10.10.08.20.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 Oct 2014 08:20:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id b6so3287428lbj.17 for ; Fri, 10 Oct 2014 08:20:09 -0700 (PDT) X-Received: by 10.112.52.165 with SMTP id u5mr5468617lbo.80.1412954408938; Fri, 10 Oct 2014 08:20:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp447812lbz; Fri, 10 Oct 2014 08:20:08 -0700 (PDT) X-Received: by 10.140.21.36 with SMTP id 33mr9151778qgk.63.1412954407498; Fri, 10 Oct 2014 08:20:07 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t98si11415003qga.109.2014.10.10.08.20.06 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 10 Oct 2014 08:20:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:48970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcbzC-0000gq-LV for patch@linaro.org; Fri, 10 Oct 2014 11:20:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xcbyh-0000OF-NA for qemu-devel@nongnu.org; Fri, 10 Oct 2014 11:19:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xcbyb-00011f-Pp for qemu-devel@nongnu.org; Fri, 10 Oct 2014 11:19:35 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:54511) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xcbyb-00011b-K4 for qemu-devel@nongnu.org; Fri, 10 Oct 2014 11:19:29 -0400 Received: by mail-wi0-f169.google.com with SMTP id cc10so4603226wib.4 for ; Fri, 10 Oct 2014 08:19:28 -0700 (PDT) X-Received: by 10.181.5.42 with SMTP id cj10mr5700074wid.28.1412954368662; Fri, 10 Oct 2014 08:19:28 -0700 (PDT) Received: from ards-macbook-pro.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id lp8sm2947291wic.17.2014.10.10.08.19.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 Oct 2014 08:19:27 -0700 (PDT) From: Ard Biesheuvel To: peter.maydell@linaro.org Date: Fri, 10 Oct 2014 17:19:25 +0200 Message-Id: <1412954365-14727-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.212.169 Cc: Ard Biesheuvel , qemu-devel@nongnu.org, greg.bellows@linaro.org Subject: [Qemu-devel] [PATCH v3] hw/arm/boot: register cpu reset handlers if using -bios X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Move the registering of CPU reset handlers to before the point where we leave the function in the -bios (not -kernel) case, so CPU reset works correctly with -bios as well. Signed-off-by: Ard Biesheuvel --- Changes since v2: - split into two loops again, as the boot_info field must not be assigned in the -bios case - add clarifying comment - don't use the 'cpu' function parameter as an iterator inside the loop Changes since v1: - instead of duplicating part of the loop for the -bios case, move the loop to the beginning of the function hw/arm/boot.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index c8dc34f0865b..bffbea5e0e73 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -478,7 +478,7 @@ static void do_cpu_reset(void *opaque) void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) { - CPUState *cs = CPU(cpu); + CPUState *cs; int kernel_size; int initrd_size; int is_linux = 0; @@ -488,6 +488,15 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) int big_endian; static const ARMInsnFixup *primary_loader; + /* CPU objects (unlike devices) are not automatically reset on system + * reset, so we must always register a handler to do so. If we're + * actually loading a kernel, the handler is also responsible for + * arranging that we start it correctly. + */ + for (cs = CPU(cpu); cs; cs = CPU_NEXT(cs)) { + qemu_register_reset(do_cpu_reset, ARM_CPU(cs)); + } + /* Load the kernel. */ if (!info->kernel_filename) { @@ -652,9 +661,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) } info->is_linux = is_linux; - for (; cs; cs = CPU_NEXT(cs)) { - cpu = ARM_CPU(cs); - cpu->env.boot_info = info; - qemu_register_reset(do_cpu_reset, cpu); + for (cs = CPU(cpu); cs; cs = CPU_NEXT(cs)) { + ARM_CPU(cs)->env.boot_info = info; } }