x86/sgx: Replace kmap/kunmap_atomic() calls
authorKristen Carlson Accardi <kristen@linux.intel.com>
Tue, 15 Nov 2022 16:16:26 +0000 (08:16 -0800)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 2 Dec 2022 13:59:56 +0000 (14:59 +0100)
commit89e927bbcd45d507e5612ef72fda04182e544a38
tree014facff69c8f3b34e9336d1ba56c316f3b6842d
parent16a7fe3728a8b832ef0d1add66875a666b1f24fc
x86/sgx: Replace kmap/kunmap_atomic() calls

kmap_local_page() is the preferred way to create temporary mappings when it
is feasible, because the mappings are thread-local and CPU-local.

kmap_local_page() uses per-task maps rather than per-CPU maps. This in
effect removes the need to disable preemption on the local CPU while the
mapping is active, and thus vastly reduces overall system latency. It is
also valid to take pagefaults within the mapped region.

The use of kmap_atomic() in the SGX code was not an explicit design choice
to disable page faults or preemption, and there is no compelling design
reason to using kmap_atomic() vs. kmap_local_page().

Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/linux-sgx/Y0biN3%2FJsZMa0yUr@kernel.org/
Link: https://lore.kernel.org/r/20221115161627.4169428-1-kristen@linux.intel.com
arch/x86/kernel/cpu/sgx/encl.c
arch/x86/kernel/cpu/sgx/ioctl.c
arch/x86/kernel/cpu/sgx/main.c