arm64: pac: Optimize kernel entry/exit key installation code paths
authorPeter Collingbourne <pcc@google.com>
Fri, 19 Mar 2021 03:10:54 +0000 (20:10 -0700)
committerCatalin Marinas <catalin.marinas@arm.com>
Tue, 13 Apr 2021 16:31:44 +0000 (17:31 +0100)
commitb90e483938ce387c256e03fb144f82f64551847b
tree142877923b78d506be4812ecacc65fb8718adf29
parent201698626fbca1cf1a3b686ba14cf2a056500716
arm64: pac: Optimize kernel entry/exit key installation code paths

The kernel does not use any keys besides IA so we don't need to
install IB/DA/DB/GA on kernel exit if we arrange to install them
on task switch instead, which we can expect to happen an order of
magnitude less often.

Furthermore we can avoid installing the user IA in the case where the
user task has IA disabled and just leave the kernel IA installed. This
also lets us avoid needing to install IA on kernel entry.

On an Apple M1 under a hypervisor, the overhead of kernel entry/exit
has been measured to be reduced by 15.6ns in the case where IA is
enabled, and 31.9ns in the case where IA is disabled.

Signed-off-by: Peter Collingbourne <pcc@google.com>
Link: https://linux-review.googlesource.com/id/Ieddf6b580d23c9e0bed45a822dabe72d2ffc9a8e
Link: https://lore.kernel.org/r/2d653d055f38f779937f2b92f8ddd5cf9e4af4f4.1616123271.git.pcc@google.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/asm_pointer_auth.h
arch/arm64/include/asm/pointer_auth.h
arch/arm64/kernel/asm-offsets.c
arch/arm64/kernel/entry.S
arch/arm64/kernel/pointer_auth.c
arch/arm64/kernel/process.c
arch/arm64/kernel/suspend.c