powerpc/book3s64/pkeys: Optimize KUAP and KUEP feature disabled case
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Fri, 27 Nov 2020 04:44:24 +0000 (10:14 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 3 Dec 2020 14:01:28 +0000 (01:01 +1100)
commitec0f9b98f7d01b15c804e77e12a515ffc56d7309
tree23794b88b29e60ab53600836bd4b9ca8922a5a5e
parent61130e203dca3ba1f0c510eb12f7a4294e31a834
powerpc/book3s64/pkeys: Optimize KUAP and KUEP feature disabled case

If FTR_BOOK3S_KUAP is disabled, kernel will continue to run with the same AMR
value with which it was entered. Hence there is a high chance that
we can return without restoring the AMR value. This also helps the case
when applications are not using the pkey feature. In this case, different
applications will have the same AMR values and hence we can avoid restoring
AMR in this case too.

Also avoid isync() if not really needed.

Do the same for IAMR.

null-syscall benchmark results:

With smap/smep disabled:
Without patch:
957.95 ns    2778.17 cycles
With patch:
858.38 ns    2489.30 cycles

With smap/smep enabled:
Without patch:
1017.26 ns    2950.36 cycles
With patch:
1021.51 ns    2962.44 cycles

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201127044424.40686-23-aneesh.kumar@linux.ibm.com
arch/powerpc/include/asm/book3s/64/kup.h
arch/powerpc/kernel/entry_64.S
arch/powerpc/kernel/syscall_64.c