arm64: Improve detection of user/non-user mappings in set_pte(_at)
authorCatalin Marinas <catalin.marinas@arm.com>
Fri, 27 Jan 2017 10:54:12 +0000 (10:54 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 14 May 2017 12:00:15 +0000 (14:00 +0200)
commitf46fdb8a2611b4ffe9dda5b712ac02add90e930f
tree16c94a7326cce07bfbc8cf825773d33d283913ee
parentaadb7e073e813a447ba6c5f5636702f07e8805dd
arm64: Improve detection of user/non-user mappings in set_pte(_at)

commit ec663d967b2276448a416406ca59ff247c0c80c5 upstream.

Commit cab15ce604e5 ("arm64: Introduce execute-only page access
permissions") allowed a valid user PTE to have the PTE_USER bit clear.
As a consequence, the pte_valid_not_user() macro in set_pte() was
replaced with pte_valid_global() under the assumption that only user
pages have the nG bit set. EFI mappings, however, also have the nG bit
set and set_pte() wrongly ignores issuing the DSB+ISB.

This patch reinstates the pte_valid_not_user() macro and adds the
PTE_UXN bit check since all kernel mappings have this bit set. For
clarity, pte_exec() is renamed to pte_user_exec() as it only checks for
the absence of PTE_UXN. Consequently, the user executable check in
set_pte_at() drops the pte_ng() test since pte_user_exec() is
sufficient.

Fixes: cab15ce604e5 ("arm64: Introduce execute-only page access permissions")
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/include/asm/pgtable.h