* [Qemu-devel] [PATCH] hw/arm/boot: Set PC correctly when loading AArch64 ELF files
@ 2014-07-25 15:23 Peter Maydell
2014-07-25 16:09 ` Christopher Covington
2014-07-29 19:25 ` Richard Henderson
0 siblings, 2 replies; 5+ messages in thread
From: Peter Maydell @ 2014-07-25 15:23 UTC (permalink / raw)
To: qemu-devel; +Cc: Christopher Covington, qemu-stable
The code in do_cpu_reset() correctly handled AArch64 CPUs
when running Linux kernels, but was missing code in the
branch of the if() that deals with loading ELF files.
Correctly jump to the ELF entry point on reset rather than
leaving the reset PC at zero.
Reported-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-stable@nongnu.org
---
hw/arm/boot.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 3d1f4a2..1241761 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -417,8 +417,12 @@ static void do_cpu_reset(void *opaque)
if (info) {
if (!info->is_linux) {
/* Jump to the entry point. */
- env->regs[15] = info->entry & 0xfffffffe;
- env->thumb = info->entry & 1;
+ if (env->aarch64) {
+ env->pc = info->entry;
+ } else {
+ env->regs[15] = info->entry & 0xfffffffe;
+ env->thumb = info->entry & 1;
+ }
} else {
if (CPU(cpu) == first_cpu) {
if (env->aarch64) {
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/arm/boot: Set PC correctly when loading AArch64 ELF files
2014-07-25 15:23 [Qemu-devel] [PATCH] hw/arm/boot: Set PC correctly when loading AArch64 ELF files Peter Maydell
@ 2014-07-25 16:09 ` Christopher Covington
2014-07-29 19:25 ` Richard Henderson
1 sibling, 0 replies; 5+ messages in thread
From: Christopher Covington @ 2014-07-25 16:09 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, qemu-stable
On 07/25/2014 11:23 AM, Peter Maydell wrote:
> The code in do_cpu_reset() correctly handled AArch64 CPUs
> when running Linux kernels, but was missing code in the
> branch of the if() that deals with loading ELF files.
> Correctly jump to the ELF entry point on reset rather than
> leaving the reset PC at zero.
Thanks Peter! With this patch I can see the first few instructions being executed.
Tested-by: Christopher Covington <cov@codeaurora.org>
(The default Newlib/libgloss wants to touch EL3 registers that QEMU doesn't
yet have, but I can probably make my test case work with -nostdlib.)
Thanks,
Christopher
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by the Linux Foundation.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/arm/boot: Set PC correctly when loading AArch64 ELF files
2014-07-25 15:23 [Qemu-devel] [PATCH] hw/arm/boot: Set PC correctly when loading AArch64 ELF files Peter Maydell
2014-07-25 16:09 ` Christopher Covington
@ 2014-07-29 19:25 ` Richard Henderson
2014-07-29 19:31 ` Peter Maydell
1 sibling, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2014-07-29 19:25 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: Christopher Covington, qemu-stable
On 07/25/2014 05:23 AM, Peter Maydell wrote:
> + env->regs[15] = info->entry & 0xfffffffe;
You'd do well to use a U suffix here, otherwise c89 makes this -2 while c99
does what you want. Which makes a tiny difference on a 64-bit host.
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/arm/boot: Set PC correctly when loading AArch64 ELF files
2014-07-29 19:25 ` Richard Henderson
@ 2014-07-29 19:31 ` Peter Maydell
2014-07-29 19:57 ` Richard Henderson
0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2014-07-29 19:31 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-stable, QEMU Developers, Christopher Covington
On 29 July 2014 20:25, Richard Henderson <rth@twiddle.net> wrote:
> On 07/25/2014 05:23 AM, Peter Maydell wrote:
>> + env->regs[15] = info->entry & 0xfffffffe;
>
> You'd do well to use a U suffix here, otherwise c89 makes this -2 while c99
> does what you want. Which makes a tiny difference on a 64-bit host.
Given that env->regs[] is uint32_t, does it actually change the final
result? I agree that a U suffix would be a good idea, but given that
the code has been that way since 2009 it seems unlikely that we've
actually got breakage from it...
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/arm/boot: Set PC correctly when loading AArch64 ELF files
2014-07-29 19:31 ` Peter Maydell
@ 2014-07-29 19:57 ` Richard Henderson
0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2014-07-29 19:57 UTC (permalink / raw)
To: Peter Maydell; +Cc: Christopher Covington, qemu-stable, QEMU Developers
On 07/29/2014 09:31 AM, Peter Maydell wrote:
> Given that env->regs[] is uint32_t, does it actually change the final
> result?
Ah, no. I mis-remembered regs and xregs being shared.
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-07-29 19:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-25 15:23 [Qemu-devel] [PATCH] hw/arm/boot: Set PC correctly when loading AArch64 ELF files Peter Maydell
2014-07-25 16:09 ` Christopher Covington
2014-07-29 19:25 ` Richard Henderson
2014-07-29 19:31 ` Peter Maydell
2014-07-29 19:57 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).