Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752644AbcDRP6I (ORCPT ); Mon, 18 Apr 2016 11:58:08 -0400 Received: from foss.arm.com ([217.140.101.70]:34896 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752037AbcDRP54 (ORCPT ); Mon, 18 Apr 2016 11:57:56 -0400 Date: Mon, 18 Apr 2016 16:57:33 +0100 From: Mark Rutland To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, james.morse@arm.com, catalin.marinas@arm.com Subject: Re: [PATCH 2/8] arm64: kernel: use literal for relocated address of __secondary_switched Message-ID: <20160418155733.GB7521@leverpostej> References: <1460992188-23295-1-git-send-email-ard.biesheuvel@linaro.org> <1460992188-23295-3-git-send-email-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1460992188-23295-3-git-send-email-ard.biesheuvel@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1846 Lines: 62 On Mon, Apr 18, 2016 at 05:09:42PM +0200, Ard Biesheuvel wrote: > 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 Neat! Acked-by: Mark Rutland Mark. > --- > 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 >