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
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 <redacted>
Cc: Will Deacon <redacted>
---
arch/arm64/kernel/head.S | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
@@ -534,13 +534,8 @@ ENTRY(kimage_vaddr)ENTRY(el2_setup)mrsx0,CurrentELcmpx0,#CurrentEL_EL2-b.ne1f-mrsx0,sctlr_el2-CPU_BE(orrx0,x0,#(1 << 25) ) // Set the EE bit for EL2-CPU_LE(bicx0,x0,#(1 << 25) ) // Clear the EE bit for EL2-msrsctlr_el2,x0-b2f-1:mrsx0,sctlr_el1+b.eq1f+mrsx0,sctlr_el1CPU_BE(orrx0,x0,#(3 << 24) ) // Set the EE and E0E bits for EL1CPU_LE(bicx0,x0,#(3 << 24) ) // Clear the EE and E0E bits for EL1msrsctlr_el1,x0
@@ -548,7 +543,11 @@ CPU_LE( bic x0, x0, #(3 << 24) ) // Clear the EE and E0E bits for EL1isbret-2:+1:mrsx0,sctlr_el2+CPU_BE(orrx0,x0,#(1 << 25) ) // Set the EE bit for EL2+CPU_LE(bicx0,x0,#(1 << 25) ) // Clear the EE bit for EL2+msrsctlr_el2,x0+#ifdef CONFIG_ARM64_VHE/**CheckforVHEbeingpresent.FortherestoftheEL2setup,
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 <redacted>
Cc: Will Deacon <redacted>
---
arch/arm64/kernel/head.S | 37 +++++++++++++++++--------------------
1 file changed, 17 insertions(+), 20 deletions(-)
@@ -611,26 +611,6 @@ set_hcr:msrvpidr_el2,x0msrvmpidr_el2,x1-/*-*WhenVHEisnotinuse,earlyinitofEL2andEL1needstobe-*donehere.-*WhenVHE_is_inuse,EL1willnotbeusedinthehostand-*requiresnoconfiguration,andallnon-hyp-specificEL2setup-*willbedoneviathe_EL1systemregisteraliasesin__cpu_setup.-*/-cbnzx2,1f--/*sctlr_el1*/-movx0,#0x0800 // Set/clear RES{1,0} bits-CPU_BE(movkx0,#0x33d0, lsl #16 ) // Set EE and E0E on BE systems-CPU_LE(movkx0,#0x30d0, lsl #16 ) // Clear EE and E0E on LE systems-msrsctlr_el1,x0--/*Coprocessortraps.*/-movx0,#0x33ff-msrcptr_el2,x0//Disablecopro.trapstoEL2-1:-#ifdef CONFIG_COMPATmsrhstr_el2,xzr//DisableCP15trapstoEL2#endif
@@ -667,6 +647,23 @@ CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systemsretinstall_el2_stub:+/*+*WhenVHEisnotinuse,earlyinitofEL2andEL1needstobe+*donehere.+*WhenVHE_is_inuse,EL1willnotbeusedinthehostand+*requiresnoconfiguration,andallnon-hyp-specificEL2setup+*willbedoneviathe_EL1systemregisteraliasesin__cpu_setup.+*/+/*sctlr_el1*/+movx0,#0x0800 // Set/clear RES{1,0} bits+CPU_BE(movkx0,#0x33d0, lsl #16 ) // Set EE and E0E on BE systems+CPU_LE(movkx0,#0x30d0, lsl #16 ) // Clear EE and E0E on LE systems+msrsctlr_el1,x0++/*Coprocessortraps.*/+movx0,#0x33ff+msrcptr_el2,x0//Disablecopro.trapstoEL2+/*Hypervisorstub*/adr_lx0,__hyp_stub_vectorsmsrvbar_el2,x0
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
From: Marc Zyngier <hidden> Date: 2017-03-21 15:43:32
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 <redacted>
Cc: Will Deacon <redacted>
Acked-by: Marc Zyngier <redacted>
M.
--
Jazz is not dead. It just smells funny...
From: Marc Zyngier <hidden> Date: 2017-03-21 15:47:49
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 <redacted>
Cc: Will Deacon <redacted>
Acked-by: Marc Zyngier <redacted>
M.
--
Jazz is not dead. It just smells funny...
From: Marc Zyngier <hidden> Date: 2017-03-21 15:51:55
On 21/03/17 15:37, Catalin Marinas wrote:
On Wed, Feb 15, 2017 at 02:54:15PM +0000, Mark Rutland wrote:
quoted
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...
On Tue, Mar 21, 2017 at 03:51:55PM +0000, Marc Zyngier wrote:
On 21/03/17 15:37, Catalin Marinas wrote:
quoted
On Wed, Feb 15, 2017 at 02:54:15PM +0000, Mark Rutland wrote:
quoted
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