[RFC 8/8] arm64/head: convert idmap_pg_dir and init_pg_dir to __create_pgd_mapping()

Pingfan Liu kernelfans at gmail.com
Mon Apr 19 15:10:57 BST 2021


On Sat, Apr 10, 2021 at 5:57 PM Pingfan Liu <kernelfans at gmail.com> wrote:
>
[...]
>         /*
>          * Map the kernel image (starting with PHYS_OFFSET).
>          */
>         adrp    x0, init_pg_dir
> -       mov_q   x5, KIMAGE_VADDR                // compile time __va(_text)
> -       add     x5, x5, x23                     // add KASLR displacement
> -       mov     x4, PTRS_PER_PGD
> -       adrp    x6, _end                        // runtime __pa(_end)
> -       adrp    x3, _text                       // runtime __pa(_text)
> -       sub     x6, x6, x3                      // _end - _text
> -       add     x6, x6, x5                      // runtime __va(_end)
> +       adrp    x1, init_pg_end
> +       sub     x1, x1, x0
> +       bl      set_cur_mempool
>
> -       map_memory x0, x1, x5, x6, x7, x3, x4, x10, x11, x12, x13, x14
> +       mov     x1, PTRS_PER_PGD
> +       adrp    x3, _text                       // runtime __pa(_text)
> +       mov_q   x4, KIMAGE_VADDR                // compile time __va(_text)
> +       add     x4, x4, x23                     // add KASLR displacement
> +       adrp    x5, _end                        // runtime __pa(_end)
> +       sub     x5, x5, x3                      // _end - _text
> +
> +       ldr     x3, =PAGE_KERNEL_EXEC
> +       adr_l   x4, head_pgtable_alloc
> +       mov     x5, #0
> +       mov     x6, #NO_FIXMAP
> +
> +       bl      create_init_pgd_mapping

This calling convention is wrong, should be changed as the following (
will be updated in v2)
        adrp    x0, init_pg_dir
        adrp    x1, init_pg_end
        sub     x1, x1, x0
        bl      set_cur_mempool
        mov     x0, #0
        mov     x0, #0
        bl      head_pgtable_alloc              // x0 is init_pg_dir

        adrp    x1, _text                       // runtime __pa(_text)
        mov_q   x2, KIMAGE_VADDR                // compile time __va(_text)
        add     x2, x2, x23                     // add KASLR displacement
        adrp    x3, _end                        // runtime __pa(_end)
        sub     x3, x3, x1                      // _end - _text

        ldr     x4, =PAGE_KERNEL_EXEC
        adr_l   x5, head_pgtable_alloc
        mov     x6, #0
        mov     x7, #(NO_FIXMAP | NO_PRINTK | BOOT_HEAD)

        bl      create_init_pgd_mapping

Thanks,
Pingfan



More information about the linux-arm-kernel mailing list