Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1cdfc007 authored by Mark Rutland's avatar Mark Rutland Committed by Zubin Mithra
Browse files

UPSTREAM: arm64: assembler: introduce ldr_this_cpu



Shortly we will want to load a percpu variable in the return from
userspace path. We can save an instruction by folding the addition of
the percpu offset into the load instruction, and this patch adds a new
helper to do so.

At the same time, we clean up this_cpu_ptr for consistency. As with
{adr,ldr,str}_l, we change the template to take the destination register
first, and name this dst. Secondly, we rename the macro to adr_this_cpu,
following the scheme of adr_l, and matching the newly added
ldr_this_cpu.

Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Tested-by: default avatarLaura Abbott <labbott@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>

Bug: 38331309
Change-Id: Iaaf4ea9674ab89289badee216b5305204172895e
(cherry picked from commit 1b7e2296a822dfd2349960addc42a139360ce769)
Signed-off-by: default avatarZubin Mithra <zsm@google.com>
parent f7f69dfb
Loading
Loading
Loading
Loading
+15 −4
Original line number Original line Diff line number Diff line
@@ -223,14 +223,25 @@ lr .req x30 // link register
	.endm
	.endm


	/*
	/*
	 * @dst: Result of per_cpu(sym, smp_processor_id())
	 * @sym: The name of the per-cpu variable
	 * @sym: The name of the per-cpu variable
	 * @reg: Result of per_cpu(sym, smp_processor_id())
	 * @tmp: scratch register
	 * @tmp: scratch register
	 */
	 */
	.macro this_cpu_ptr, sym, reg, tmp
	.macro adr_this_cpu, dst, sym, tmp
	adr_l	\reg, \sym
	adr_l	\dst, \sym
	mrs	\tmp, tpidr_el1
	mrs	\tmp, tpidr_el1
	add	\reg, \reg, \tmp
	add	\dst, \dst, \tmp
	.endm

	/*
	 * @dst: Result of READ_ONCE(per_cpu(sym, smp_processor_id()))
	 * @sym: The name of the per-cpu variable
	 * @tmp: scratch register
	 */
	.macro ldr_this_cpu dst, sym, tmp
	adr_l	\dst, \sym
	mrs	\tmp, tpidr_el1
	ldr	\dst, [\dst, \tmp]
	.endm
	.endm


/*
/*
+1 −1
Original line number Original line Diff line number Diff line
@@ -266,7 +266,7 @@ alternative_endif
	cmp	x25, tsk
	cmp	x25, tsk
	b.ne	9998f
	b.ne	9998f


	this_cpu_ptr irq_stack, x25, x26
	adr_this_cpu x25, irq_stack, x26
	mov	x26, #IRQ_STACK_START_SP
	mov	x26, #IRQ_STACK_START_SP
	add	x26, x25, x26
	add	x26, x25, x26