[PATCH v2 11/19] arm64: add PTE_UXN/PTE_WRITE to SWAPPER_*_FLAGS

Joey Gouly joey.gouly at arm.com
Thu Apr 20 08:29:17 PDT 2023


Hi,

On Thu, Apr 13, 2023 at 05:35:15PM +0100, Catalin Marinas wrote:
> On Thu, Apr 13, 2023 at 12:05:05PM +0100, 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)
> 
> I mentioned on the previous version, I think it's better not to add the
> PTE_WRITE here but in the users of these macros where writeable is
> required (e.g. SWAPPER_RX_MMUFLAGS doesn't need PTE_WRITE as it has
> PTE_RDONLY).

I didn't ignore the previous comment, I just misunderstood it and thought I
should leave it as is. I've made the change now!

Thanks,
Joey



More information about the linux-arm-kernel mailing list