[PATCH v3 7/9] ARM: page: Turn highpage accesses into static inlines
Ard Biesheuvel
ardb at kernel.org
Mon Mar 11 05:15:06 PDT 2024
On Mon, 11 Mar 2024 at 10:15, Linus Walleij <linus.walleij at linaro.org> wrote:
>
> Clearing and copying pages in highmem uses either the cpu_user
> vtable or the __glue() assembler stubs to call into per-CPU
> versions of these functions.
>
> This is all really confusing for KCFI so wrap these into static
> inlines and prefix each inline function with __nocfi.
>
> __cpu_clear_user_highpage() and __cpu_copy_user_highpage() are
> exported in arch/arm/mm/proc-syms.c which causes a problem with
> using static inlines, but it turns out that these exports are
> completely unused, so we can just delete them.
>
> Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
> ---
> arch/arm/include/asm/page.h | 36 +++++++++++++++++++++++++++++-------
> arch/arm/mm/proc-syms.c | 7 +------
> 2 files changed, 30 insertions(+), 13 deletions(-)
>
Are you sure this patch is needed?
> diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
> index 119aa85d1feb..8bf297228627 100644
> --- a/arch/arm/include/asm/page.h
> +++ b/arch/arm/include/asm/page.h
> @@ -138,17 +138,39 @@ void xscale_mc_clear_user_highpage(struct page *page, unsigned long vaddr);
> #ifdef MULTI_USER
> extern struct cpu_user_fns cpu_user;
>
> -#define __cpu_clear_user_highpage cpu_user.cpu_clear_user_highpage
> -#define __cpu_copy_user_highpage cpu_user.cpu_copy_user_highpage
> +static inline void __nocfi __cpu_clear_user_highpage(struct page *page,
> + unsigned long vaddr)
> +{
> + cpu_user.cpu_clear_user_highpage(page, vaddr);
> +}
> +
> +static inline void __nocfi __cpu_copy_user_highpage(struct page *to,
> + struct page *from, unsigned long vaddr,
> + struct vm_area_struct *vma)
> +{
> + cpu_user.cpu_copy_user_highpage(to, from, vaddr, vma);
> +}
>
> #else
>
> -#define __cpu_clear_user_highpage __glue(_USER,_clear_user_highpage)
> -#define __cpu_copy_user_highpage __glue(_USER,_copy_user_highpage)
> +/* These turn into function declarations for each per-CPU glue function */
> +void __glue(_USER,_clear_user_highpage)(struct page *page, unsigned long vaddr);
> +void __glue(_USER,_copy_user_highpage)(struct page *to, struct page *from,
> + unsigned long vaddr, struct vm_area_struct *vma);
> +
> +static inline void __nocfi __cpu_clear_user_highpage(struct page *page,
> + unsigned long vaddr)
> +{
> + __glue(_USER,_clear_user_highpage)(page, vaddr);
> +}
> +
> +static inline void __nocfi __cpu_copy_user_highpage(struct page *to,
> + struct page *from, unsigned long vaddr,
> + struct vm_area_struct *vma)
> +{
> + __glue(_USER,_copy_user_highpage)(to, from, vaddr, vma);
> +}
>
> -extern void __cpu_clear_user_highpage(struct page *page, unsigned long vaddr);
> -extern void __cpu_copy_user_highpage(struct page *to, struct page *from,
> - unsigned long vaddr, struct vm_area_struct *vma);
> #endif
>
> #define clear_user_highpage(page,vaddr) \
> diff --git a/arch/arm/mm/proc-syms.c b/arch/arm/mm/proc-syms.c
> index e21249548e9f..c93fec38d9f4 100644
> --- a/arch/arm/mm/proc-syms.c
> +++ b/arch/arm/mm/proc-syms.c
> @@ -31,14 +31,9 @@ EXPORT_SYMBOL(__cpuc_flush_dcache_area);
> EXPORT_SYMBOL(cpu_cache);
> #endif
>
> -#ifdef CONFIG_MMU
> -#ifndef MULTI_USER
> -EXPORT_SYMBOL(__cpu_clear_user_highpage);
> -EXPORT_SYMBOL(__cpu_copy_user_highpage);
> -#else
> +#if defined(CONFIG_MMU) && defined(MULTI_USER)
> EXPORT_SYMBOL(cpu_user);
> #endif
> -#endif
>
> /*
> * No module should need to touch the TLB (and currently
>
> --
> 2.34.1
>
More information about the linux-arm-kernel
mailing list