qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Fedorov <serge.fdrv@gmail.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Sergey Fedorov <serge.fdrv@gmail.com>
Subject: [Qemu-devel] [PATCH 1/3] hw/arm/boot: add secondary loader for AArch64
Date: Tue, 24 Mar 2015 16:55:29 -0700	[thread overview]
Message-ID: <1427241331-11403-2-git-send-email-serge.fdrv@gmail.com> (raw)
In-Reply-To: <1427241331-11403-1-git-send-email-serge.fdrv@gmail.com>

This default secondary loader is used to bring up secondary CPUs using
spin table boot method.

Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com>
---
 hw/arm/boot.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index a48d1b2..2bff2f2 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -57,6 +57,18 @@ static const ARMInsnFixup bootloader_aarch64[] = {
     { 0, FIXUP_TERMINATOR }
 };
 
+static const ARMInsnFixup smpboot_aarch64[] = {
+    { 0xd503205f }, /* wfe */
+    { 0x580000a0 }, /* ldr x0, bootreg_addr */
+    { 0xf9400000 }, /* ldr x0, [x0] */
+    { 0xb4ffffa0 }, /* cbz x0, <wfe> */
+    { 0xd61f0000 }, /* br  x0 */
+    { 0xd503201f }, /* nop */
+    { 0, FIXUP_BOOTREG }, /* bootreg_addr: .word 0x... */
+    { 0 }, /* .word 0 */
+    { 0, FIXUP_TERMINATOR }
+};
+
 /* The worlds second smallest bootloader.  Set r0-r2, then jump to kernel.  */
 static const ARMInsnFixup bootloader[] = {
     { 0xe3a00000 }, /* mov     r0, #0 */
@@ -152,6 +164,7 @@ static void default_write_secondary(ARMCPU *cpu,
                                     const struct arm_boot_info *info)
 {
     uint32_t fixupcontext[FIXUP_MAX];
+    const ARMInsnFixup *secondary_loader;
 
     fixupcontext[FIXUP_GIC_CPU_IF] = info->gic_cpu_if_addr;
     fixupcontext[FIXUP_BOOTREG] = info->smp_bootreg_addr;
@@ -161,8 +174,13 @@ static void default_write_secondary(ARMCPU *cpu,
         fixupcontext[FIXUP_DSB] = CP15_DSB_INSN;
     }
 
+    if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
+        secondary_loader = smpboot_aarch64;
+    } else {
+        secondary_loader = smpboot;
+    }
     write_bootloader("smpboot", info->smp_loader_start,
-                     smpboot, fixupcontext);
+                     secondary_loader, fixupcontext);
 }
 
 static void default_reset_secondary(ARMCPU *cpu,
@@ -171,7 +189,11 @@ static void default_reset_secondary(ARMCPU *cpu,
     CPUARMState *env = &cpu->env;
 
     stl_phys_notdirty(&address_space_memory, info->smp_bootreg_addr, 0);
-    env->regs[15] = info->smp_loader_start;
+    if (is_a64(env)) {
+        env->pc = info->smp_loader_start;
+    } else {
+        env->regs[15] = info->smp_loader_start;
+    }
 }
 
 static inline bool have_dtb(const struct arm_boot_info *info)
-- 
2.3.4

  reply	other threads:[~2015-03-24 23:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-24 23:55 [Qemu-devel] [PATCH 0/3] hw/arm: add Fixed Virtual Platform VE support Sergey Fedorov
2015-03-24 23:55 ` Sergey Fedorov [this message]
2015-03-24 23:55 ` [Qemu-devel] [PATCH 2/3] hw/arm/vexpress: introduce VEDBoardInfo::smp_bootreg_addr Sergey Fedorov
2015-03-24 23:55 ` [Qemu-devel] [PATCH 3/3] hw/arm/vexpress: add FVP VE board support Sergey Fedorov
2015-03-25  0:13 ` [Qemu-devel] [PATCH 0/3] hw/arm: add Fixed Virtual Platform VE support Peter Maydell
2015-03-25  0:18   ` Sergey Fedorov
2015-03-25  0:23     ` Peter Maydell
2015-03-25  0:31       ` Sergey Fedorov
2015-03-25  0:48         ` Peter Maydell
2015-03-25  1:30           ` Sergey Fedorov
2015-03-25  1:43             ` Sergey Fedorov
2015-03-25 11:06               ` Peter Maydell
2015-03-25 17:52                 ` Sergey Fedorov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427241331-11403-2-git-send-email-serge.fdrv@gmail.com \
    --to=serge.fdrv@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).