Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1381828

[PATCH 2/8] arm64: kernel: use literal for relocated address of __secondary_switched

From Ard Biesheuvel <ard.biesheuvel@linaro.org>
Newsgroups linux.kernel
Subject [PATCH 2/8] arm64: kernel: use literal for relocated address of __secondary_switched
Date 2016-04-18 17:20 +0200
Message-ID <rpj80-7JL-63@gated-at.bofh.it> (permalink)
References <rpj7X-7JL-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 is not dereferenced until after we have enabled the MMU.

So jump via a small __secondary_switch() function covered by the ID map
that performs the literal load and branch-to-register.

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 ac27d8d937b2..f13276d4ca91 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -468,9 +468,7 @@ __mmap_switched:
 	str	x15, [x11, x23]
 	b	0b
 
-2:	adr_l	x8, kimage_vaddr		// make relocated kimage_vaddr
-	dc	cvac, x8			// value visible to secondaries
-	dsb	sy				// with MMU off
+2:
 #endif
 
 	adr_l	sp, initial_sp, x4
@@ -699,12 +697,9 @@ 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
+	adr_l	x27, __secondary_switch		// address to jump to after enabling the MMU
 	b	__enable_mmu
 ENDPROC(secondary_startup)
-0:	.long	(_text - TEXT_OFFSET) - __secondary_switched
 
 __secondary_switched:
 	adr_l	x5, vectors
@@ -806,3 +801,8 @@ __no_granule_support:
 	wfi
 	b 1b
 ENDPROC(__no_granule_support)
+
+__secondary_switch:
+	ldr	x8, =__secondary_switched
+	br	x8
+ENDPROC(__secondary_switch)
-- 
2.5.0

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/8] arm64: kaslr cleanups and improvements Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-04-18 17:20 +0200
  [PATCH 4/8] arm64: introduce mov_q macro to move a constant into a 64-bit register Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-04-18 17:20 +0200
  [PATCH 8/8] arm64: kaslr: increase randomization granularity Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-04-18 17:20 +0200
    Re: [PATCH 8/8] arm64: kaslr: increase randomization granularity Will Deacon <will.deacon@arm.com> - 2016-04-26 13:30 +0200
      Re: [PATCH 8/8] arm64: kaslr: increase randomization granularity Matt Fleming <matt@codeblueprint.co.uk> - 2016-04-26 17:30 +0200
  [PATCH 1/8] arm64: kernel: don't export local symbols from head.S Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-04-18 17:20 +0200
    Re: [PATCH 1/8] arm64: kernel: don't export local symbols from head.S Mark Rutland <mark.rutland@arm.com> - 2016-04-18 17:40 +0200
  [PATCH 2/8] arm64: kernel: use literal for relocated address of __secondary_switched Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-04-18 17:20 +0200
    Re: [PATCH 2/8] arm64: kernel: use literal for relocated address of  __secondary_switched Mark Rutland <mark.rutland@arm.com> - 2016-04-18 18:00 +0200
  Re: [PATCH 0/8] arm64: kaslr cleanups and improvements Catalin Marinas <catalin.marinas@arm.com> - 2016-04-25 18:40 +0200

csiph-web