| From foo@baz Sat Mar 19 01:51:18 PM CET 2022 |
| From: James Morse <james.morse@arm.com> |
| Date: Fri, 18 Mar 2022 17:48:25 +0000 |
| Subject: arm64: entry: Make the trampoline cleanup optional |
| To: stable@vger.kernel.org |
| Cc: linux-kernel@vger.kernel.org, james.morse@arm.com, catalin.marinas@arm.com |
| Message-ID: <20220318174842.2321061-6-james.morse@arm.com> |
| |
| From: James Morse <james.morse@arm.com> |
| |
| commit d739da1694a0eaef0358a42b76904b611539b77b upstream. |
| |
| Subsequent patches will add additional sets of vectors that use |
| the same tricks as the kpti vectors to reach the full-fat vectors. |
| The full-fat vectors contain some cleanup for kpti that is patched |
| in by alternatives when kpti is in use. Once there are additional |
| vectors, the cleanup will be needed in more cases. |
| |
| But on big/little systems, the cleanup would be harmful if no |
| trampoline vector were in use. Instead of forcing CPUs that don't |
| need a trampoline vector to use one, make the trampoline cleanup |
| optional. |
| |
| Entry at the top of the vectors will skip the cleanup. The trampoline |
| vectors can then skip the first instruction, triggering the cleanup |
| to run. |
| |
| Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> |
| Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> |
| Signed-off-by: James Morse <james.morse@arm.com> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| arch/arm64/kernel/entry.S | 10 +++++++--- |
| 1 file changed, 7 insertions(+), 3 deletions(-) |
| |
| --- a/arch/arm64/kernel/entry.S |
| +++ b/arch/arm64/kernel/entry.S |
| @@ -72,16 +72,20 @@ |
| .align 7 |
| .Lventry_start\@: |
| #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 |
| -alternative_if ARM64_UNMAP_KERNEL_AT_EL0 |
| .if \el == 0 |
| + /* |
| + * This must be the first instruction of the EL0 vector entries. It is |
| + * skipped by the trampoline vectors, to trigger the cleanup. |
| + */ |
| + b .Lskip_tramp_vectors_cleanup\@ |
| .if \regsize == 64 |
| mrs x30, tpidrro_el0 |
| msr tpidrro_el0, xzr |
| .else |
| mov x30, xzr |
| .endif |
| +.Lskip_tramp_vectors_cleanup\@: |
| .endif |
| -alternative_else_nop_endif |
| #endif |
| |
| sub sp, sp, #S_FRAME_SIZE |
| @@ -983,7 +987,7 @@ alternative_insn isb, nop, ARM64_WORKARO |
| #endif |
| prfm plil1strm, [x30, #(1b - tramp_vectors)] |
| msr vbar_el1, x30 |
| - add x30, x30, #(1b - tramp_vectors) |
| + add x30, x30, #(1b - tramp_vectors + 4) |
| isb |
| ret |
| .org 1b + 128 // Did we overflow the ventry slot? |