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


Groups > linux.kernel > #1711263 > unrolled thread

Re: [PATCH 10/14] arm64: assembler: allow adr_this_cpu to use the stack pointer

Started byCatalin Marinas <catalin.marinas@arm.com>
First post2017-08-14 19:20 +0200
Last post2017-08-14 19:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 10/14] arm64: assembler: allow adr_this_cpu to use the  stack pointer Catalin Marinas <catalin.marinas@arm.com> - 2017-08-14 19:20 +0200
    Re: [PATCH 10/14] arm64: assembler: allow adr_this_cpu to use the  stack pointer Mark Rutland <mark.rutland@arm.com> - 2017-08-14 19:50 +0200

#1711263 — Re: [PATCH 10/14] arm64: assembler: allow adr_this_cpu to use the stack pointer

FromCatalin Marinas <catalin.marinas@arm.com>
Date2017-08-14 19:20 +0200
SubjectRe: [PATCH 10/14] arm64: assembler: allow adr_this_cpu to use the stack pointer
Message-ID<uerbY-6WD-9@gated-at.bofh.it>
On Mon, Aug 07, 2017 at 07:36:01PM +0100, Mark Rutland wrote:
> From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> 
> Given that adr_this_cpu already requires a temp register in addition
> to the destination register, tweak the instruction sequence so that sp
> may be used as well.
> 
> This will simplify switching to per-cpu stacks in subsequent patches. While
> this limits the range of adr_this_cpu, to +/-4GiB, we don't currently use
> adr_this_cpu in modules, and this is not problematic for the main kernel image.
> 
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> [Mark: add more commit text]
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: James Morse <james.morse@arm.com>
> Cc: Laura Abbott <labbott@redhat.com>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm64/include/asm/assembler.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
> index 610a420..4775af5 100644
> --- a/arch/arm64/include/asm/assembler.h
> +++ b/arch/arm64/include/asm/assembler.h
> @@ -235,7 +235,8 @@
>  	 * @tmp: scratch register
>  	 */
>  	.macro adr_this_cpu, dst, sym, tmp
> -	adr_l	\dst, \sym
> +	adrp	\tmp, \sym
> +	add	\dst, \tmp, #:lo12:\sym
>  	mrs	\tmp, tpidr_el1
>  	add	\dst, \dst, \tmp
>  	.endm

Nitpick: it may be worth adding an #ifndef MODULE around these macros,
together with a comment, just in case. There are other macros in this
file like adr_l which are used in modules (crypto).

-- 
Catalin

[toc] | [next] | [standalone]


#1711286

FromMark Rutland <mark.rutland@arm.com>
Date2017-08-14 19:50 +0200
Message-ID<uerF1-76t-21@gated-at.bofh.it>
In reply to#1711263
On Mon, Aug 14, 2017 at 06:13:39PM +0100, Catalin Marinas wrote:
> On Mon, Aug 07, 2017 at 07:36:01PM +0100, Mark Rutland wrote:

> >  	.macro adr_this_cpu, dst, sym, tmp
> > -	adr_l	\dst, \sym
> > +	adrp	\tmp, \sym
> > +	add	\dst, \tmp, #:lo12:\sym
> >  	mrs	\tmp, tpidr_el1
> >  	add	\dst, \dst, \tmp
> >  	.endm
> 
> Nitpick: it may be worth adding an #ifndef MODULE around these macros,
> together with a comment, just in case. There are other macros in this
> file like adr_l which are used in modules (crypto).

I've folded in the below, in keeping with the other MODULE fallbacks.

Thanks,
Mark.

---->8----
diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 4775af5..50c5592 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -230,13 +230,18 @@
        .endm
 
        /*
-        * @dst: Result of per_cpu(sym, smp_processor_id())
+        * @dst: Result of per_cpu(sym, smp_processor_id()), can be SP for
+        *       non-module code
         * @sym: The name of the per-cpu variable
         * @tmp: scratch register
         */
        .macro adr_this_cpu, dst, sym, tmp
+#ifndef MODULE
        adrp    \tmp, \sym
        add     \dst, \tmp, #:lo12:\sym
+#else
+       adr_l   \tmp, \sym
+#endif
        mrs     \tmp, tpidr_el1
        add     \dst, \dst, \tmp
        .endm

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web