From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCFak-0005Ht-0D for qemu-devel@nongnu.org; Mon, 06 Jul 2015 19:14:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCFai-0007pR-SW for qemu-devel@nongnu.org; Mon, 06 Jul 2015 19:14:25 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44121 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCFai-0007oy-Gr for qemu-devel@nongnu.org; Mon, 06 Jul 2015 19:14:24 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 7 Jul 2015 01:13:57 +0200 Message-Id: <1436224445-19449-15-git-send-email-afaerber@suse.de> In-Reply-To: <1436224445-19449-1-git-send-email-afaerber@suse.de> References: <1436224445-19449-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 14/22] hw/arm/boot: Use cpu_set_pc() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Peter Crosthwaite , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Peter Crosthwaite 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=C3=A4rber Signed-off-by: Peter Crosthwaite [AF: Avoid repeated casts with local variables] Signed-off-by: Andreas F=C3=A4rber --- 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 =3D &cpu->env; + CPUState *cs =3D CPU(cpu); =20 address_space_stl_notdirty(&address_space_memory, info->smp_bootreg_= addr, 0, MEMTXATTRS_UNSPECIFIED, NULL); - env->regs[15] =3D info->smp_loader_start; + cpu_set_pc(cs, info->smp_loader_start); } =20 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 =3D opaque; + CPUState *cs =3D CPU(cpu); CPUARMState *env =3D &cpu->env; const struct arm_boot_info *info =3D env->boot_info; =20 - cpu_reset(CPU(cpu)); + cpu_reset(cs); if (info) { if (!info->is_linux) { /* Jump to the entry point. */ - if (env->aarch64) { - env->pc =3D info->entry; - } else { - env->regs[15] =3D info->entry & 0xfffffffe; + uint64_t entry =3D info->entry; + + if (!env->aarch64) { env->thumb =3D info->entry & 1; + entry &=3D 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 st= ate @@ -487,12 +489,8 @@ static void do_cpu_reset(void *opaque) } } =20 - if (CPU(cpu) =3D=3D first_cpu) { - if (env->aarch64) { - env->pc =3D info->loader_start; - } else { - env->regs[15] =3D info->loader_start; - } + if (cs =3D=3D first_cpu) { + cpu_set_pc(cs, info->loader_start); =20 if (!have_dtb(info)) { if (old_param) { --=20 2.1.4