All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] arm64: head.S cleanup
@ 2017-02-15 14:54 Mark Rutland
  2017-02-15 14:54 ` [PATCH 1/2] arm64: reduce el2_setup branching Mark Rutland
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mark Rutland @ 2017-02-15 14:54 UTC (permalink / raw)
  To: linux-arm-kernel

While looking at head.S, I saw that over time we've grown some
convoluted code paths that can be simplified.

These patches clean those up.

Thanks,
Mark.

Mark Rutland (2):
  arm64: reduce el2_setup branching
  arm64: move !VHE work to end of el2_setup

 arch/arm64/kernel/head.S | 52 ++++++++++++++++++++++--------------------------
 1 file changed, 24 insertions(+), 28 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] arm64: reduce el2_setup branching
  2017-02-15 14:54 [PATCH 0/2] arm64: head.S cleanup Mark Rutland
@ 2017-02-15 14:54 ` Mark Rutland
  2017-03-21 15:43   ` Marc Zyngier
  2017-02-15 14:54 ` [PATCH 2/2] arm64: move !VHE work to end of el2_setup Mark Rutland
  2017-03-21 15:37 ` [PATCH 0/2] arm64: head.S cleanup Catalin Marinas
  2 siblings, 1 reply; 8+ messages in thread
From: Mark Rutland @ 2017-02-15 14:54 UTC (permalink / raw)
  To: linux-arm-kernel

The early el2_setup code is a little convoluted, with two branches where
one would do. This makes the code more painful to read than is
necessary.

We can remove a branch and simplify the logic by moving the early return
in the booted-at-EL1 case earlier in the function. This separates it
from all the setup logic that only makes sense for EL2.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/kernel/head.S | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 4fb6ccd..2c37334 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -534,13 +534,8 @@ ENTRY(kimage_vaddr)
 ENTRY(el2_setup)
 	mrs	x0, CurrentEL
 	cmp	x0, #CurrentEL_EL2
-	b.ne	1f
-	mrs	x0, sctlr_el2
-CPU_BE(	orr	x0, x0, #(1 << 25)	)	// Set the EE bit for EL2
-CPU_LE(	bic	x0, x0, #(1 << 25)	)	// Clear the EE bit for EL2
-	msr	sctlr_el2, x0
-	b	2f
-1:	mrs	x0, sctlr_el1
+	b.eq	1f
+	mrs	x0, sctlr_el1
 CPU_BE(	orr	x0, x0, #(3 << 24)	)	// Set the EE and E0E bits for EL1
 CPU_LE(	bic	x0, x0, #(3 << 24)	)	// Clear the EE and E0E bits for EL1
 	msr	sctlr_el1, x0
@@ -548,7 +543,11 @@ CPU_LE(	bic	x0, x0, #(3 << 24)	)	// Clear the EE and E0E bits for EL1
 	isb
 	ret
 
-2:
+1:	mrs	x0, sctlr_el2
+CPU_BE(	orr	x0, x0, #(1 << 25)	)	// Set the EE bit for EL2
+CPU_LE(	bic	x0, x0, #(1 << 25)	)	// Clear the EE bit for EL2
+	msr	sctlr_el2, x0
+
 #ifdef CONFIG_ARM64_VHE
 	/*
 	 * Check for VHE being present. For the rest of the EL2 setup,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] arm64: move !VHE work to end of el2_setup
  2017-02-15 14:54 [PATCH 0/2] arm64: head.S cleanup Mark Rutland
  2017-02-15 14:54 ` [PATCH 1/2] arm64: reduce el2_setup branching Mark Rutland
@ 2017-02-15 14:54 ` Mark Rutland
  2017-03-21 15:47   ` Marc Zyngier
  2017-03-21 15:37 ` [PATCH 0/2] arm64: head.S cleanup Catalin Marinas
  2 siblings, 1 reply; 8+ messages in thread
From: Mark Rutland @ 2017-02-15 14:54 UTC (permalink / raw)
  To: linux-arm-kernel

We only need to initialise sctlr_el1 if we're installing an EL2 stub, so
we may as well defer this until we're doing so. Similarly, we can defer
intialising CPTR_EL2 until then, as we do not access any trapped
functionality as part of el2_setup.

This patch modified el2_setup accordingly, allowing us to remove a
branch and simplify the code flow.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/kernel/head.S | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 2c37334..0b13748 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -611,26 +611,6 @@ set_hcr:
 	msr	vpidr_el2, x0
 	msr	vmpidr_el2, x1
 
-	/*
-	 * When VHE is not in use, early init of EL2 and EL1 needs to be
-	 * done here.
-	 * When VHE _is_ in use, EL1 will not be used in the host and
-	 * requires no configuration, and all non-hyp-specific EL2 setup
-	 * will be done via the _EL1 system register aliases in __cpu_setup.
-	 */
-	cbnz	x2, 1f
-
-	/* sctlr_el1 */
-	mov	x0, #0x0800			// Set/clear RES{1,0} bits
-CPU_BE(	movk	x0, #0x33d0, lsl #16	)	// Set EE and E0E on BE systems
-CPU_LE(	movk	x0, #0x30d0, lsl #16	)	// Clear EE and E0E on LE systems
-	msr	sctlr_el1, x0
-
-	/* Coprocessor traps. */
-	mov	x0, #0x33ff
-	msr	cptr_el2, x0			// Disable copro. traps to EL2
-1:
-
 #ifdef CONFIG_COMPAT
 	msr	hstr_el2, xzr			// Disable CP15 traps to EL2
 #endif
@@ -667,6 +647,23 @@ CPU_LE(	movk	x0, #0x30d0, lsl #16	)	// Clear EE and E0E on LE systems
 	ret
 
 install_el2_stub:
+	/*
+	 * When VHE is not in use, early init of EL2 and EL1 needs to be
+	 * done here.
+	 * When VHE _is_ in use, EL1 will not be used in the host and
+	 * requires no configuration, and all non-hyp-specific EL2 setup
+	 * will be done via the _EL1 system register aliases in __cpu_setup.
+	 */
+	/* sctlr_el1 */
+	mov	x0, #0x0800			// Set/clear RES{1,0} bits
+CPU_BE(	movk	x0, #0x33d0, lsl #16	)	// Set EE and E0E on BE systems
+CPU_LE(	movk	x0, #0x30d0, lsl #16	)	// Clear EE and E0E on LE systems
+	msr	sctlr_el1, x0
+
+	/* Coprocessor traps. */
+	mov	x0, #0x33ff
+	msr	cptr_el2, x0			// Disable copro. traps to EL2
+
 	/* Hypervisor stub */
 	adr_l	x0, __hyp_stub_vectors
 	msr	vbar_el2, x0
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 0/2] arm64: head.S cleanup
  2017-02-15 14:54 [PATCH 0/2] arm64: head.S cleanup Mark Rutland
  2017-02-15 14:54 ` [PATCH 1/2] arm64: reduce el2_setup branching Mark Rutland
  2017-02-15 14:54 ` [PATCH 2/2] arm64: move !VHE work to end of el2_setup Mark Rutland
@ 2017-03-21 15:37 ` Catalin Marinas
  2017-03-21 15:51   ` Marc Zyngier
  2 siblings, 1 reply; 8+ messages in thread
From: Catalin Marinas @ 2017-03-21 15:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Feb 15, 2017 at 02:54:15PM +0000, Mark Rutland wrote:
> Mark Rutland (2):
>   arm64: reduce el2_setup branching
>   arm64: move !VHE work to end of el2_setup

Mark, Marc, do these patches conflict with the hyp stub cleanup? If
there is some overlap, I'm happy for them to go via the kvm tree
together with the others.

-- 
Catalin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] arm64: reduce el2_setup branching
  2017-02-15 14:54 ` [PATCH 1/2] arm64: reduce el2_setup branching Mark Rutland
@ 2017-03-21 15:43   ` Marc Zyngier
  0 siblings, 0 replies; 8+ messages in thread
From: Marc Zyngier @ 2017-03-21 15:43 UTC (permalink / raw)
  To: linux-arm-kernel

On 15/02/17 14:54, Mark Rutland wrote:
> The early el2_setup code is a little convoluted, with two branches where
> one would do. This makes the code more painful to read than is
> necessary.
> 
> We can remove a branch and simplify the logic by moving the early return
> in the booted-at-EL1 case earlier in the function. This separates it
> from all the setup logic that only makes sense for EL2.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

	M.
-- 
Jazz is not dead. It just smells funny...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/2] arm64: move !VHE work to end of el2_setup
  2017-02-15 14:54 ` [PATCH 2/2] arm64: move !VHE work to end of el2_setup Mark Rutland
@ 2017-03-21 15:47   ` Marc Zyngier
  0 siblings, 0 replies; 8+ messages in thread
From: Marc Zyngier @ 2017-03-21 15:47 UTC (permalink / raw)
  To: linux-arm-kernel

On 15/02/17 14:54, Mark Rutland wrote:
> We only need to initialise sctlr_el1 if we're installing an EL2 stub, so
> we may as well defer this until we're doing so. Similarly, we can defer
> intialising CPTR_EL2 until then, as we do not access any trapped
> functionality as part of el2_setup.
> 
> This patch modified el2_setup accordingly, allowing us to remove a
> branch and simplify the code flow.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

	M.
-- 
Jazz is not dead. It just smells funny...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 0/2] arm64: head.S cleanup
  2017-03-21 15:37 ` [PATCH 0/2] arm64: head.S cleanup Catalin Marinas
@ 2017-03-21 15:51   ` Marc Zyngier
  2017-03-21 16:03     ` Catalin Marinas
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Zyngier @ 2017-03-21 15:51 UTC (permalink / raw)
  To: linux-arm-kernel

On 21/03/17 15:37, Catalin Marinas wrote:
> On Wed, Feb 15, 2017 at 02:54:15PM +0000, Mark Rutland wrote:
>> Mark Rutland (2):
>>   arm64: reduce el2_setup branching
>>   arm64: move !VHE work to end of el2_setup
> 
> Mark, Marc, do these patches conflict with the hyp stub cleanup? If
> there is some overlap, I'm happy for them to go via the kvm tree
> together with the others.

I don't think there is any overlap, my changes stay clear of head.S.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 0/2] arm64: head.S cleanup
  2017-03-21 15:51   ` Marc Zyngier
@ 2017-03-21 16:03     ` Catalin Marinas
  0 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2017-03-21 16:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Mar 21, 2017 at 03:51:55PM +0000, Marc Zyngier wrote:
> On 21/03/17 15:37, Catalin Marinas wrote:
> > On Wed, Feb 15, 2017 at 02:54:15PM +0000, Mark Rutland wrote:
> >> Mark Rutland (2):
> >>   arm64: reduce el2_setup branching
> >>   arm64: move !VHE work to end of el2_setup
> > 
> > Mark, Marc, do these patches conflict with the hyp stub cleanup? If
> > there is some overlap, I'm happy for them to go via the kvm tree
> > together with the others.
> 
> I don't think there is any overlap, my changes stay clear of head.S.

Thanks (for the ack as well). Queued for 4.12.

-- 
Catalin

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-03-21 16:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-15 14:54 [PATCH 0/2] arm64: head.S cleanup Mark Rutland
2017-02-15 14:54 ` [PATCH 1/2] arm64: reduce el2_setup branching Mark Rutland
2017-03-21 15:43   ` Marc Zyngier
2017-02-15 14:54 ` [PATCH 2/2] arm64: move !VHE work to end of el2_setup Mark Rutland
2017-03-21 15:47   ` Marc Zyngier
2017-03-21 15:37 ` [PATCH 0/2] arm64: head.S cleanup Catalin Marinas
2017-03-21 15:51   ` Marc Zyngier
2017-03-21 16:03     ` Catalin Marinas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.