From: Christopher Covington <cov@codeaurora.org>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: edgar.iglesias@xilinx.com, peter.maydell@linaro.org,
qemu-devel@nongnu.org, rob.herring@linaro.org
Subject: Re: [Qemu-devel] [RFC v1 2/2] arm: boot: Add EL jump-down code for Linux
Date: Tue, 19 Aug 2014 12:50:35 -0400 [thread overview]
Message-ID: <53F3805B.4010107@codeaurora.org> (raw)
In-Reply-To: <be3ee5ea9513adc8768c3bb5edf0a6348f16d13d.1408350779.git.peter.crosthwaite@xilinx.com>
Hi Peter,
On 08/18/2014 08:54 PM, Peter Crosthwaite wrote:
> Linux should boot in EL2 or EL1. If in EL3, jump down before handing
> off to Linux.
>
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
>
> hw/arm/boot.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index 840f5da..f1f6365 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -35,6 +35,7 @@ typedef enum {
> FIXUP_GIC_CPU_IF, /* overwrite with GIC CPU interface address */
> FIXUP_BOOTREG, /* overwrite with boot register address */
> FIXUP_DSB, /* overwrite with correct DSB insn for cpu */
> + FIXUP_EL, /* overwrite with kernel entry EL */
> FIXUP_MAX,
> } FixupType;
>
> @@ -46,6 +47,20 @@ typedef struct ARMInsnFixup {
> } ARMInsnFixup;
>
> static const ARMInsnFixup bootloader_aarch64[] = {
> + { 0xd5384240 }, /* mrs x0, currentel */
> + { 0x7100301f }, /* cmp w0, #0xc */
> + { 0x54000001 + (9 << 5) }, /* b.ne ELx_start */
> +/* Jump down from EL3 to ELx */
> + { 0x10000001 + (9 << 5) }, /* adr x1, ELx_start */
Nit: Consider putting this right before the usage to make the code slightly
easier to follow. Always using a distinct GPR per SR (such as x2 for SPSR) or
reusing the same GPR for all the SRs (such as x0 for ELR) might also make the
code easier to follow.
> + { 0xd53e1100 }, /* mrs x0, scr_el3 */
> + { 0xb2400000 }, /* orr x0, x0, #0x1 - SCR.NS */
> + { 0xb2780000 }, /* orr x0, x0, #0x80 - SCR.HCE */
> + { 0xd51e1100 }, /* msr scr_el3, x0 */
> + { 0xd2807820, FIXUP_EL, 7, 2 }, /* movz x0, 0x3c1 (+ EL<<2) */
> + { 0xd51e4000 }, /* msr spsr_el3, x0 */
> + { 0xd51e4021 }, /* msr elr_el3, x1 */
> + { 0xd69f03e0 }, /* eret */
> +/* ELx_start: */
> { 0x580000c0 }, /* ldr x0, arg ; Load the lower 32-bits of DTB */
> { 0xaa1f03e1 }, /* mov x1, xzr */
> { 0xaa1f03e2 }, /* mov x2, xzr */
> @@ -141,6 +156,7 @@ static void write_bootloader(const char *name, hwaddr addr,
> case FIXUP_GIC_CPU_IF:
> case FIXUP_BOOTREG:
> case FIXUP_DSB:
> + case FIXUP_EL:
> insn = deposit32(insn, shift, length, fixupcontext[fixup]);
> break;
> default:
> @@ -583,6 +599,11 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
> }
> fixupcontext[FIXUP_ENTRYPOINT] = entry;
>
> + fixupcontext[FIXUP_EL] = 1;
> + if (arm_feature(&cpu->env, ARM_FEATURE_EL2)) {
> + fixupcontext[FIXUP_EL] = 2;
> + }
> +
> write_bootloader("bootloader", info->loader_start,
> primary_loader, fixupcontext);
>
>
Thanks,
Christopher
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by the Linux Foundation.
next prev parent reply other threads:[~2014-08-19 16:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-19 0:53 [Qemu-devel] [RFC v1 0/2] EL3 support for AArch64 Linux bootloader Peter Crosthwaite
2014-08-19 0:53 ` [Qemu-devel] [RFC v1 1/2] arm: boot: Add partial machine code fixup Peter Crosthwaite
2014-08-19 0:54 ` [Qemu-devel] [RFC v1 2/2] arm: boot: Add EL jump-down code for Linux Peter Crosthwaite
2014-08-19 16:50 ` Christopher Covington [this message]
2014-09-01 17:15 ` Peter Maydell
2014-09-01 22:41 ` Peter Crosthwaite
2014-09-01 22:56 ` Peter Maydell
2014-09-01 23:06 ` Peter Crosthwaite
2014-09-01 23:12 ` Peter Maydell
2014-09-01 23:22 ` Peter Crosthwaite
2014-09-01 23:38 ` Peter Maydell
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=53F3805B.4010107@codeaurora.org \
--to=cov@codeaurora.org \
--cc=edgar.iglesias@xilinx.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rob.herring@linaro.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).