lkml.org 
[lkml]   [2020]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v1 06/46] powerpc/kasan: Refactor update of early shadow mappings
From
Date
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@c-s.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)
>

\
 
 \ /
  Last update: 2020-04-02 12:20    [W:0.248 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site