[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <18fb9f4b-d110-ee41-af44-09a1f5072ecf@c-s.fr>
Date: Thu, 2 Apr 2020 12:19:13 +0200
From: Christophe Leroy <christophe.leroy@....fr>
To: Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>
Cc: linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 06/46] powerpc/kasan: Refactor update of early shadow
mappings
Michael,
Le 16/03/2020 à 13:35, Christophe Leroy a écrit :
> kasan_remap_early_shadow_ro() and kasan_unmap_early_shadow_vmalloc()
> are both updating the early shadow mapping: the first one sets
> the mapping read-only while the other clears the mapping.
>
> Refactor and create kasan_update_early_region()
There is a trivial conflict with this patch on powerpc/next.
Do you plan to take this series for 5.7 ? I so, I can repost the series
now with the fix, or just this patch ?
Otherwise, what are your plans ? This series (Patches 18 and 19) will
conflict with the 40x removal series as both do things about that
PTE_ATOMIC_UPDATE stuff. Which series would go first ?
Thanks
Christophe
>
> Signed-off-by: Christophe Leroy <christophe.leroy@....fr>
> ---
> arch/powerpc/mm/kasan/kasan_init_32.c | 39 +++++++++++++--------------
> 1 file changed, 18 insertions(+), 21 deletions(-)
>
> diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c
> index c9d053078c37..65fd8b891f8e 100644
> --- a/arch/powerpc/mm/kasan/kasan_init_32.c
> +++ b/arch/powerpc/mm/kasan/kasan_init_32.c
> @@ -79,45 +79,42 @@ static int __init kasan_init_region(void *start, size_t size)
> return 0;
> }
>
> -static void __init kasan_remap_early_shadow_ro(void)
> +static void __init
> +kasan_update_early_region(unsigned long k_start, unsigned long k_end, pte_t pte)
> {
> - pgprot_t prot = kasan_prot_ro();
> - unsigned long k_start = KASAN_SHADOW_START;
> - unsigned long k_end = KASAN_SHADOW_END;
> unsigned long k_cur;
> phys_addr_t pa = __pa(kasan_early_shadow_page);
>
> - kasan_populate_pte(kasan_early_shadow_pte, prot);
> -
> - for (k_cur = k_start & PAGE_MASK; k_cur < k_end; k_cur += PAGE_SIZE) {
> + for (k_cur = k_start; k_cur < k_end; k_cur += PAGE_SIZE) {
> pmd_t *pmd = pmd_ptr_k(k_cur);
> pte_t *ptep = pte_offset_kernel(pmd, k_cur);
>
> if ((pte_val(*ptep) & PTE_RPN_MASK) != pa)
> continue;
>
> - __set_pte_at(&init_mm, k_cur, ptep, pfn_pte(PHYS_PFN(pa), prot), 0);
> + __set_pte_at(&init_mm, k_cur, ptep, pte, 0);
> }
> - flush_tlb_kernel_range(KASAN_SHADOW_START, KASAN_SHADOW_END);
> +
> + flush_tlb_kernel_range(k_start, k_end);
> }
>
> -static void __init kasan_unmap_early_shadow_vmalloc(void)
> +static void __init kasan_remap_early_shadow_ro(void)
> {
> - unsigned long k_start = (unsigned long)kasan_mem_to_shadow((void *)VMALLOC_START);
> - unsigned long k_end = (unsigned long)kasan_mem_to_shadow((void *)VMALLOC_END);
> - unsigned long k_cur;
> + pgprot_t prot = kasan_prot_ro();
> phys_addr_t pa = __pa(kasan_early_shadow_page);
>
> - for (k_cur = k_start & PAGE_MASK; k_cur < k_end; k_cur += PAGE_SIZE) {
> - pmd_t *pmd = pmd_offset(pud_offset(pgd_offset_k(k_cur), k_cur), k_cur);
> - pte_t *ptep = pte_offset_kernel(pmd, k_cur);
> + kasan_populate_pte(kasan_early_shadow_pte, prot);
>
> - if ((pte_val(*ptep) & PTE_RPN_MASK) != pa)
> - continue;
> + kasan_update_early_region(KASAN_SHADOW_START, KASAN_SHADOW_END,
> + pfn_pte(PHYS_PFN(pa), prot));
> +}
>
> - __set_pte_at(&init_mm, k_cur, ptep, __pte(0), 0);
> - }
> - flush_tlb_kernel_range(k_start, k_end);
> +static void __init kasan_unmap_early_shadow_vmalloc(void)
> +{
> + unsigned long k_start = (unsigned long)kasan_mem_to_shadow((void *)VMALLOC_START);
> + unsigned long k_end = (unsigned long)kasan_mem_to_shadow((void *)VMALLOC_END);
> +
> + kasan_update_early_region(k_start, k_end, __pte(0));
> }
>
> static void __init kasan_mmu_init(void)
>
Powered by blists - more mailing lists