[PATCH v1 12/18] arm64: add PTE_UXN/PTE_WRITE to SWAPPER_*_FLAGS
Catalin Marinas
catalin.marinas at arm.com
Mon Mar 27 09:44:37 PDT 2023
On Thu, Mar 09, 2023 at 02:52:40PM +0000, Joey Gouly wrote:
> With PIE enabled, the swapper PTEs would have a Permission Indirection Index (PIIndex)
> of 0. A PIIndex of 0 is not currently used by any other PTEs.
>
> To avoid using index 0 specifically for the swapper PTEs, mark them as PTE_UXN
> and PTE_WRITE, so that they map to a PAGE_KERNEL_EXEC equivalent.
>
> Signed-off-by: Joey Gouly <joey.gouly at arm.com>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: Will Deacon <will at kernel.org>
> Cc: Mark Rutland <mark.rutland at arm.com>
> ---
> arch/arm64/include/asm/kernel-pgtable.h | 4 ++--
> arch/arm64/kernel/head.S | 8 ++++----
> arch/arm64/mm/proc.S | 2 +-
> 3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kernel-pgtable.h b/arch/arm64/include/asm/kernel-pgtable.h
> index fcd14197756f..daf1909116f6 100644
> --- a/arch/arm64/include/asm/kernel-pgtable.h
> +++ b/arch/arm64/include/asm/kernel-pgtable.h
> @@ -104,8 +104,8 @@
> /*
> * Initial memory map attributes.
> */
> -#define SWAPPER_PTE_FLAGS (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED)
> -#define SWAPPER_PMD_FLAGS (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S)
> +#define SWAPPER_PTE_FLAGS (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED | PTE_UXN | PTE_WRITE)
> +#define SWAPPER_PMD_FLAGS (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S | PTE_UXN | PTE_WRITE)
Adding PTE_UXN is fine but we have SWAPPER_RX_MMUFLAGS which is no
longer read-only after this change. I don't think this matters much as
IIUC we only use init_pg_dir briefly before creating the proper
swapper_pg_dir.
--
Catalin
More information about the linux-arm-kernel
mailing list