linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/8] arm64/kernel: use literal for relocated address of __secondary_switched
Date: Mon,  4 Apr 2016 16:52:17 +0200	[thread overview]
Message-ID: <1459781544-14310-2-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1459781544-14310-1-git-send-email-ard.biesheuvel@linaro.org>

We can simply use a relocated 64-bit literal to store the address of
__secondary_switched(), and the relocation code will ensure that it
holds the correct value at secondary entry time, as long as we make sure
that the literal value is visible to the secondaries before they enable
their MMUs. So place the literal next to kimage_vaddr, and set the alignment
so that it is covered by the same cacheline that we already have to clean
for a similar purpose.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/arm64/kernel/head.S | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 4203d5f257bc..69b33535911e 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -471,7 +471,8 @@ __mmap_switched:
 	b	0b
 
 2:	adr_l	x8, kimage_vaddr		// make relocated kimage_vaddr
-	dc	cvac, x8			// value visible to secondaries
+						// and __secondary_switched
+	dc	cvac, x8			// values visible to secondaries
 	dsb	sy				// with MMU off
 #endif
 
@@ -506,10 +507,12 @@ ENDPROC(__mmap_switched)
  * end early head section, begin head code that is also used for
  * hotplug and needs to have the same protections as the text region
  */
-	.section ".text","ax"
-
+	.section	".text","ax"
+	.align		4
 ENTRY(kimage_vaddr)
 	.quad		_text - TEXT_OFFSET
+.L__secondary_switched:
+	.quad		__secondary_switched
 
 /*
  * If we're fortunate enough to boot at EL2, ensure that the world is
@@ -701,12 +704,9 @@ ENTRY(secondary_startup)
 	adrp	x26, swapper_pg_dir
 	bl	__cpu_setup			// initialise processor
 
-	ldr	x8, kimage_vaddr
-	ldr	w9, 0f
-	sub	x27, x8, w9, sxtw		// address to jump to after enabling the MMU
+	ldr	x27, .L__secondary_switched
 	b	__enable_mmu
 ENDPROC(secondary_startup)
-0:	.long	(_text - TEXT_OFFSET) - __secondary_switched
 
 ENTRY(__secondary_switched)
 	adr_l	x5, vectors
-- 
2.5.0

  reply	other threads:[~2016-04-04 14:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-04 14:52 [PATCH 0/8] arm64: 2016 head.S spring cleaning Ard Biesheuvel
2016-04-04 14:52 ` Ard Biesheuvel [this message]
2016-04-07  9:38   ` [PATCH 1/8] arm64/kernel: use literal for relocated address of __secondary_switched Will Deacon
2016-04-07  9:43     ` Ard Biesheuvel
2016-04-04 14:52 ` [PATCH 2/8] arm64/kernel: reuse boot_args array to get to __fdt_pointer Ard Biesheuvel
2016-04-04 15:13   ` James Morse
2016-04-04 15:19     ` Ard Biesheuvel
2016-04-05 11:09       ` Ard Biesheuvel
2016-04-04 14:52 ` [PATCH 3/8] arm64/kernel: use a proper stack frame in __mmap_switched() Ard Biesheuvel
2016-04-04 15:33   ` James Morse
2016-04-04 15:40     ` Ard Biesheuvel
2016-04-04 14:52 ` [PATCH 4/8] arm64/kernel: use ordinary calling convention for EL2 setup Ard Biesheuvel
2016-04-04 14:52 ` [PATCH 5/8] arm64/kernel: refer to idmap_pg_dir and swapper_pg_dir directly Ard Biesheuvel
2016-04-04 14:52 ` [PATCH 6/8] arm64/kernel: pass virtual entry point as __enable_mmu() argument Ard Biesheuvel
2016-04-04 14:52 ` [PATCH 7/8] arm64/kernel: drop __PHYS_OFFSET register with file scope from head.S Ard Biesheuvel
2016-04-04 14:52 ` [PATCH 8/8] arm64/kernel: drop global kaslr_offset in x23 " Ard Biesheuvel

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=1459781544-14310-2-git-send-email-ard.biesheuvel@linaro.org \
    --to=ard.biesheuvel@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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).