[PATCH v6 1/7] powerpc: mm: Separate set_pte, set_pte_at for internal, external use

Christophe Leroy christophe.leroy at csgroup.eu
Tue Feb 14 16:59:15 AEDT 2023



Le 14/02/2023 à 02:59, Rohan McLure a écrit :
> Produce separate symbols for set_pte, which is to be used in
> arch/powerpc for reassignment of pte's, and set_pte_at, used in generic
> code.
> 
> The reason for this distinction is to support the Page Table Check
> sanitiser. Having this distinction allows for set_pte_at to
> instrumented, but set_pte not to be, permitting for uninstrumented
> internal mappings. This distinction in names is also present in x86.
> 
> Signed-off-by: Rohan McLure <rmclure at linux.ibm.com>
> ---
> v6: new patch
> ---
>   arch/powerpc/include/asm/book3s/pgtable.h | 4 ++--
>   arch/powerpc/include/asm/nohash/pgtable.h | 4 ++--
>   arch/powerpc/include/asm/pgtable.h        | 1 +
>   arch/powerpc/mm/pgtable.c                 | 4 ++--
>   4 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/book3s/pgtable.h b/arch/powerpc/include/asm/book3s/pgtable.h
> index d18b748ea3ae..dbcdc2103c59 100644
> --- a/arch/powerpc/include/asm/book3s/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/pgtable.h
> @@ -12,8 +12,8 @@
>   /* Insert a PTE, top-level function is out of line. It uses an inline
>    * low level function in the respective pgtable-* files
>    */
> -extern void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
> -		       pte_t pte);
> +extern void set_pte(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
> +		    pte_t pte);

Remove 'extern' keyword, it's pointless and deprecated, checkpatch 
--strict is likely complaining about it too.

Then have the protoype fit on a single line.

>   
>   
>   #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
> diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
> index 69c3a050a3d8..ac3e69a18253 100644
> --- a/arch/powerpc/include/asm/nohash/pgtable.h
> +++ b/arch/powerpc/include/asm/nohash/pgtable.h
> @@ -154,8 +154,8 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
>   /* Insert a PTE, top-level function is out of line. It uses an inline
>    * low level function in the respective pgtable-* files
>    */
> -extern void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
> -		       pte_t pte);
> +extern void set_pte(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
> +		    pte_t pte);

Remove 'extern' keyword and have the protoype fit on a single line.


>   
>   /* This low level function performs the actual PTE insertion
>    * Setting the PTE depends on the MMU type and other factors. It's
> diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
> index 9972626ddaf6..17d30359d1f4 100644
> --- a/arch/powerpc/include/asm/pgtable.h
> +++ b/arch/powerpc/include/asm/pgtable.h
> @@ -48,6 +48,7 @@ struct mm_struct;
>   /* Keep these as a macros to avoid include dependency mess */
>   #define pte_page(x)		pfn_to_page(pte_pfn(x))
>   #define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
> +#define set_pte_at  		set_pte
>   /*
>    * Select all bits except the pfn
>    */
> diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
> index cb2dcdb18f8e..e9a464e0d081 100644
> --- a/arch/powerpc/mm/pgtable.c
> +++ b/arch/powerpc/mm/pgtable.c
> @@ -187,8 +187,8 @@ static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma,
>   /*
>    * set_pte stores a linux PTE into the linux page table.
>    */
> -void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
> -		pte_t pte)
> +void set_pte(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
> +	     pte_t pte)

Have it fit on a single line.

>   {
>   	/*
>   	 * Make sure hardware valid bit is not set. We don't do


More information about the Linuxppc-dev mailing list