arm64: kernel: Don't toggle PAN on systems with UAO
authorJames Morse <james.morse@arm.com>
Fri, 5 Feb 2016 14:58:50 +0000 (14:58 +0000)
committerAlex Shi <alex.shi@linaro.org>
Wed, 11 May 2016 14:19:24 +0000 (22:19 +0800)
commitcdfec5aaf4a886521b7f54dfe2db61735558d546
treeb17c3c64f3ebfbd1720818c34ceeaa057750308c
parent31b28ec1f1051bf82515fe38d0ae1884f40783cf
arm64: kernel: Don't toggle PAN on systems with UAO

If a CPU supports both Privileged Access Never (PAN) and User Access
Override (UAO), we don't need to disable/re-enable PAN round all
copy_to_user() like calls.

UAO alternatives cause these calls to use the 'unprivileged' load/store
instructions, which are overridden to be the privileged kind when
fs==KERNEL_DS.

This patch changes the copy_to_user() calls to have their PAN toggling
depend on a new composite 'feature' ARM64_ALT_PAN_NOT_UAO.

If both features are detected, PAN will be enabled, but the copy_to_user()
alternatives will not be applied. This means PAN will be enabled all the
time for these functions. If only PAN is detected, the toggling will be
enabled as normal.

This will save the time taken to disable/re-enable PAN, and allow us to
catch copy_to_user() accesses that occur with fs==KERNEL_DS.

Futex and swp-emulation code continue to hang their PAN toggling code on
ARM64_HAS_PAN.

Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
(cherry picked from commit 705441960033e66b63524521f153fbb28c99ddbd)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
arch/arm64/include/asm/cpufeature.h
arch/arm64/include/asm/uaccess.h
arch/arm64/kernel/cpufeature.c
arch/arm64/lib/clear_user.S
arch/arm64/lib/copy_from_user.S
arch/arm64/lib/copy_in_user.S
arch/arm64/lib/copy_to_user.S
arch/arm64/mm/fault.c