From patchwork Tue Jul 7 17:16:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 492421 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DF0CF1402C7 for ; Wed, 8 Jul 2015 03:19:14 +1000 (AEST) Received: from localhost ([::1]:59623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCWWW-0005k9-QU for incoming@patchwork.ozlabs.org; Tue, 07 Jul 2015 13:19:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCWU3-0000jn-Jt for qemu-devel@nongnu.org; Tue, 07 Jul 2015 13:16:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCWTz-00067F-G3 for qemu-devel@nongnu.org; Tue, 07 Jul 2015 13:16:39 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49698 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCWTz-00065A-8e for qemu-devel@nongnu.org; Tue, 07 Jul 2015 13:16:35 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id ED62DADDD; Tue, 7 Jul 2015 17:16:34 +0000 (UTC) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Tue, 7 Jul 2015 19:16:21 +0200 Message-Id: <1436289389-5403-15-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436289389-5403-1-git-send-email-afaerber@suse.de> References: <1436289389-5403-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 Cc: Peter Maydell , Peter Crosthwaite , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Peter Crosthwaite Subject: [Qemu-devel] [PULL v2 14/22] hw/arm/boot: Use cpu_set_pc() 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Crosthwaite Use cpu_set_pc() across the board for setting program counters. This removes instances of system level code having to reach into the CPU env. Reviewed-by: Peter Maydell Reviewed-by: Andreas Färber Signed-off-by: Peter Crosthwaite [AF: Avoid repeated casts with local variables] Signed-off-by: Andreas Färber --- hw/arm/boot.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 1e7fd28..f48ed2d 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -168,11 +168,11 @@ static void default_write_secondary(ARMCPU *cpu, static void default_reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info) { - CPUARMState *env = &cpu->env; + CPUState *cs = CPU(cpu); address_space_stl_notdirty(&address_space_memory, info->smp_bootreg_addr, 0, MEMTXATTRS_UNSPECIFIED, NULL); - env->regs[15] = info->smp_loader_start; + cpu_set_pc(cs, info->smp_loader_start); } static inline bool have_dtb(const struct arm_boot_info *info) @@ -445,19 +445,21 @@ fail: static void do_cpu_reset(void *opaque) { ARMCPU *cpu = opaque; + CPUState *cs = CPU(cpu); CPUARMState *env = &cpu->env; const struct arm_boot_info *info = env->boot_info; - cpu_reset(CPU(cpu)); + cpu_reset(cs); if (info) { if (!info->is_linux) { /* Jump to the entry point. */ - if (env->aarch64) { - env->pc = info->entry; - } else { - env->regs[15] = info->entry & 0xfffffffe; + uint64_t entry = info->entry; + + if (!env->aarch64) { env->thumb = info->entry & 1; + entry &= 0xfffffffe; } + cpu_set_pc(cs, entry); } else { /* If we are booting Linux then we need to check whether we are * booting into secure or non-secure state and adjust the state @@ -487,12 +489,8 @@ static void do_cpu_reset(void *opaque) } } - if (CPU(cpu) == first_cpu) { - if (env->aarch64) { - env->pc = info->loader_start; - } else { - env->regs[15] = info->loader_start; - } + if (cs == first_cpu) { + cpu_set_pc(cs, info->loader_start); if (!have_dtb(info)) { if (old_param) {