Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch pmapboot_enter simplication



details:   https://anonhg.NetBSD.org/src/rev/9a46be1361ac
branches:  trunk
changeset: 936025:9a46be1361ac
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Jul 16 11:36:35 2020 +0000

description:
pmapboot_enter simplication
- bootpage_alloc in asm becomes pmapboot_pagealloc in C
- PMAPBOOT_ENTER_NOBLOCK is removed as it's not used
- PMAPBOOT_ENTER_NOOVERWRITE is removed as it's now always on
- physpage_allocator argument is removed as it's always
  pmapboot_pagealloc
- Support for EARLYCONS without CONSADDR is removed so that the identity
  map for CONSADDR is always known.

For the assembly files:
 2 files changed, 40 insertions(+), 89 deletions(-)

LGTM ryo

diffstat:

 sys/arch/aarch64/aarch64/aarch64_machdep.c |    8 +-
 sys/arch/aarch64/aarch64/efi_machdep.c     |    6 +-
 sys/arch/aarch64/aarch64/locore.S          |  128 ++++++++--------------------
 sys/arch/aarch64/aarch64/pmap.c            |    7 +-
 sys/arch/aarch64/aarch64/pmapboot.c        |  104 ++++++++++++-----------
 sys/arch/aarch64/aarch64/start.S           |    9 +-
 sys/arch/aarch64/include/asan.h            |    4 +-
 sys/arch/aarch64/include/pmap.h            |   17 +--
 sys/arch/evbarm/conf/GENERIC64             |    8 +-
 9 files changed, 121 insertions(+), 170 deletions(-)

diffs (truncated from 661 to 300 lines):

diff -r 0d18f4a3cc31 -r 9a46be1361ac sys/arch/aarch64/aarch64/aarch64_machdep.c
--- a/sys/arch/aarch64/aarch64/aarch64_machdep.c        Thu Jul 16 03:08:58 2020 +0000
+++ b/sys/arch/aarch64/aarch64/aarch64_machdep.c        Thu Jul 16 11:36:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.44 2020/07/01 08:01:07 ryo Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.45 2020/07/16 11:36:35 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.44 2020/07/01 08:01:07 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.45 2020/07/16 11:36:35 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -161,9 +161,9 @@
                start = trunc_page(bootconfig.dram[blk].address);
                end = round_page(bootconfig.dram[blk].address +
                    (uint64_t)bootconfig.dram[blk].pages * PAGE_SIZE);
+
                pmapboot_enter_range(AARCH64_PA_TO_KVA(start), start,
-                   end - start, ksegattr, PMAPBOOT_ENTER_NOOVERWRITE,
-                   bootpage_alloc, printf);
+                   end - start, ksegattr, printf);
        }
        aarch64_dcache_wbinv_all();
 
diff -r 0d18f4a3cc31 -r 9a46be1361ac sys/arch/aarch64/aarch64/efi_machdep.c
--- a/sys/arch/aarch64/aarch64/efi_machdep.c    Thu Jul 16 03:08:58 2020 +0000
+++ b/sys/arch/aarch64/aarch64/efi_machdep.c    Thu Jul 16 11:36:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efi_machdep.c,v 1.5 2019/12/16 00:03:50 jmcneill Exp $ */
+/* $NetBSD: efi_machdep.c,v 1.6 2020/07/16 11:36:35 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.5 2019/12/16 00:03:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.6 2020/07/16 11:36:35 skrll Exp $");
 
 #include <sys/param.h>
 #include <uvm/uvm_extern.h>
@@ -70,7 +70,7 @@
                panic("arm_efirt_md_map_range: unsupported type %d", type);
        }
 
-       pmapboot_enter(va, pa, sz, L3_SIZE, attr, 0, bootpage_alloc, NULL);
+       pmapboot_enter(va, pa, sz, L3_SIZE, attr, NULL);
        while (sz >= PAGE_SIZE) {
                aarch64_tlbi_by_va(va);
                va += PAGE_SIZE;
diff -r 0d18f4a3cc31 -r 9a46be1361ac sys/arch/aarch64/aarch64/locore.S
--- a/sys/arch/aarch64/aarch64/locore.S Thu Jul 16 03:08:58 2020 +0000
+++ b/sys/arch/aarch64/aarch64/locore.S Thu Jul 16 11:36:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.66 2020/07/12 06:37:39 skrll Exp $        */
+/*     $NetBSD: locore.S,v 1.67 2020/07/16 11:36:35 skrll Exp $        */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -38,7 +38,7 @@
 #include <aarch64/hypervisor.h>
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.66 2020/07/12 06:37:39 skrll Exp $")
+RCSID("$NetBSD: locore.S,v 1.67 2020/07/16 11:36:35 skrll Exp $")
 
 #ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED
 #define        MAIR_DEVICE_MEM         MAIR_DEVICE_nGnRnE
@@ -54,9 +54,12 @@
 #define LOCORE_EL2
 
 #define BOOT_AP_STACKSIZE      256     /* size of temporally stack for APs */
-#define BOOTPAGE_ALLOC_MAX     (1024 * 1024)   /* reserved size from _end[] */
+#define PMAPBOOT_PAGEALLOCMAX  (1024 * 1024)   /* reserved size from _end[] */
 
 #if (defined(VERBOSE_INIT_ARM) || defined(DEBUG_LOCORE)) && defined(EARLYCONS)
+#if !defined(CONSADDR)
+#error CONSADDR required with EARLYCONS
+#endif
 #define VERBOSE_LOCORE
 #endif
 
@@ -774,11 +777,11 @@
        stp     x26, lr, [sp, #-16]!
 
        /* first allocated page must be kernel l0pt = ARM_BOOTSTRAP_LxPT */
-       bl      bootpage_alloc
+       bl      pmapboot_pagealloc
        cbz     x0, init_mmutable_error
        msr     ttbr1_el1, x0
 
-       bl      bootpage_alloc
+       bl      pmapboot_pagealloc
        cbz     x0, init_mmutable_error
        msr     ttbr0_el1, x0
 
@@ -799,85 +802,62 @@
         *     x2: psize_t size,
         *     x3: psize_t blocksize,  // L[123]_SIZE
         *     x4: pt_entry_t attr,    // pte attributes. LX_BLKPAG_*
-        *     x5: flags,
-        *     x6: pd_entry_t *(*physpage_allocator)(void),
-        *     x7: void (*pr)(const char *, ...)
+        *     x5: void (*pr)(const char *, ...)
         *  );
         */
 
 #ifdef CONSADDR
-       VPRINT("Creating VA=PA tables for CONSADDR\n")
-       mov     x7, x26                         /* pr func */
-       adr     x6, bootpage_alloc              /* allocator */
-       mov     x5, xzr                         /* flags = 0 */
-       mov     x4, #LX_BLKPAG_ATTR_DEVICE_MEM | LX_BLKPAG_AP_RW        /* attr */
-       orr     x4, x4, #LX_BLKPAG_UXN | LX_BLKPAG_PXN
-       mov     x3, #L2_SIZE                    /* blocksize */
+       VPRINT("Creating identity mapping for CONSADDR\n")
+       ldr     x0, =CONSADDR                   /* va = CONADDR (physical) */
+       mov     x1, x0                          /* pa = va */
        mov     x2, #L2_SIZE                    /* size */
-       ldr     x1, =CONSADDR                   /* pa */
-       mov     x0, x1                          /* va */
-       bl      pmapboot_enter
-       cbnz    x0, init_mmutable_error
-#elif defined(EARLYCONS)
-       /* CONSADDR is unknown, but need to map UART */
-       VPRINT("Creating VA=PA tables (0x00000000-0xffffffff)\n")
-       mov     x7, x26                         /* pr func */
-       adr     x6, bootpage_alloc              /* allocator */
-       mov     x5, xzr                         /* flags = 0 */
-       mov     x4, #LX_BLKPAG_ATTR_DEVICE_MEM | LX_BLKPAG_AP_RW        /* attr */
-       orr     x4, x4, #LX_BLKPAG_UXN | LX_BLKPAG_PXN
        mov     x3, #L2_SIZE                    /* blocksize */
-       mov     x2, #(1024*1024*1024*4)         /* size */
-       mov     x1, xzr                         /* pa */
-       mov     x0, xzr                         /* va */
+       mov     x4, #LX_BLKPAG_ATTR_DEVICE_MEM | LX_BLKPAG_AP_RW
+       orr     x4, x4, #LX_BLKPAG_UXN | LX_BLKPAG_PXN  /* attr */
+       mov     x5, x26                         /* pr func */
        bl      pmapboot_enter
        cbnz    x0, init_mmutable_error
 #endif
 
        /* identity mapping for kernel image */
-       VPRINT("Creating VA=PA tables for kernel image\n")
-       mov     x7, x26                         /* pr func */
-       adr     x6, bootpage_alloc              /* allocator */
-       mov     x5, xzr                         /* flags = 0 */
-       mov     x4, #LX_BLKPAG_ATTR_NORMAL_NC | LX_BLKPAG_AP_RW /* attr */
+       VPRINT("Creating identity mapping for kernel image\n")
+       adrl    x0, start                       /* va = start (physical) */
+
+       mov     x1, x0                          /* pa = va */
+       adrl    x2, _end
+       sub     x2, x2, x1                      /* size = _end - start */
+       add     x2, x2, #PMAPBOOT_PAGEALLOCMAX  /* for pmapboot_pagealloc() */
        mov     x3, #L2_SIZE                    /* blocksize */
-       adr     x0, start                       /* va = start */
-       adrl    x2, _end
-       sub     x2, x2, x0                      /* size = _end - start */
-       add     x2, x2, #BOOTPAGE_ALLOC_MAX     /* for bootpage_alloc() */
-       mov     x1, x0                          /* pa */
+       mov     x4, #LX_BLKPAG_ATTR_NORMAL_NC | LX_BLKPAG_AP_RW /* attr */
+       mov     x5, x26                         /* pr func */
        bl      pmapboot_enter
        cbnz    x0, init_mmutable_error
 
 #ifdef FDT
-       VPRINT("Creating VA=PA tables for FDT\n")
+       VPRINT("Creating identity mapping for FDT\n")
        adrl    x8, _C_LABEL(fdt_addr_r)
        ldr     x8, [x8]
 
-       mov     x7, x26                         /* pr func */
-       adr     x6, bootpage_alloc              /* allocator */
-       mov     x5, xzr                         /* flags = 0 */
-       mov     x4, #LX_BLKPAG_ATTR_NORMAL_NC | LX_BLKPAG_AP_RW /* attr */
-       orr     x4, x4, #LX_BLKPAG_UXN | LX_BLKPAG_PXN
+       mov     x0, x8                          /* va */
+       mov     x1, x8                          /* pa */
+       mov     x2, #L2_SIZE                    /* size */
        mov     x3, #L2_SIZE                    /* blocksize */
-       mov     x2, #L2_SIZE                    /* size */
-       mov     x1, x8                          /* pa */
-       mov     x0, x8                          /* va */
+       mov     x4, #LX_BLKPAG_ATTR_NORMAL_NC | LX_BLKPAG_AP_RW
+       orr     x4, x4, #LX_BLKPAG_UXN | LX_BLKPAG_PXN  /* attr */
+       mov     x5, x26                         /* pr func */
        bl      pmapboot_enter
        cbnz    x0, init_mmutable_error
 #endif
 
        VPRINT("Creating KVA=PA tables\n")
-       mov     x7, x26                         /* pr func */
-       adr     x6, bootpage_alloc              /* allocator */
-       mov     x5, xzr                         /* flags = 0 */
+       ldr     x0, =start                      /* va */
+       adrl    x1, start                       /* pa = start (physical) */
+       adrl    x2, _end
+       sub     x2, x2, x1                      /* size = _end - start */
+       mov     x3, #L2_SIZE                    /* blocksize */
        mov     x4, #LX_BLKPAG_ATTR_NORMAL_WB | LX_BLKPAG_AP_RW /* attr */
        orr     x4, x4, #LX_BLKPAG_UXN
-       mov     x3, #L2_SIZE                    /* blocksize */
-       adr     x1, start                       /* pa = start */
-       adrl    x2, _end
-       sub     x2, x2, x1                      /* size = _end - start */
-       ldr     x0, =start                      /* va */
+       mov     x5, x26                         /* pr func */
        bl      pmapboot_enter
        cbnz    x0, init_mmutable_error
 
@@ -890,40 +870,6 @@
        ldp     x26, lr, [sp], #16
        ret
 
-/* return PA of allocated page */
-ENTRY_NP(bootpage_alloc)
-       /* x2 = kernend_extra */
-       adrl    x3, kernend_extra
-       ldr     x2, [x3]
-       /* if (kernend_extra < 0) return NULL */
-       mov     x0, xzr
-       cmp     x2, xzr
-       bmi     bootpage_alloc_done
-
-       /* x0 = PA of _end[] */
-       adrl    x1, kern_vtopdiff
-       ldr     x1, [x1]
-       ldr     x0, =ARM_BOOTSTRAP_LxPT
-       sub     x0, x0, x1
-
-       /* x0 = ARM_BOOTSTRAP_LxPT + kernend_extra */
-       add     x0, x0, x2
-
-       /* kernend_extra += PAGE_SIZE; */
-       add     x2, x2, #PAGE_SIZE
-       str     x2, [x3]
-
-       /* clear allocated page */
-       mov     x1, x0
-       add     x2, x1, #PAGE_SIZE
-1:     stp     xzr, xzr, [x1], #16
-       cmp     x1, x2
-       bcc     1b
-bootpage_alloc_done:
-       ret
-END(bootpage_alloc)
-
-
 mmu_disable:
        dsb     sy
        mrs     x0, sctlr_el1
diff -r 0d18f4a3cc31 -r 9a46be1361ac sys/arch/aarch64/aarch64/pmap.c
--- a/sys/arch/aarch64/aarch64/pmap.c   Thu Jul 16 03:08:58 2020 +0000
+++ b/sys/arch/aarch64/aarch64/pmap.c   Thu Jul 16 11:36:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.83 2020/07/04 16:58:11 rin Exp $    */
+/*     $NetBSD: pmap.c,v 1.84 2020/07/16 11:36:35 skrll Exp $  */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.83 2020/07/04 16:58:11 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.84 2020/07/16 11:36:35 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -322,8 +322,7 @@
 
        attr = _pmap_pte_adjust_prot(0, prot, VM_PROT_ALL, false);
        attr = _pmap_pte_adjust_cacheflags(attr, flags);
-       pmapboot_enter_range(va, pa, resid, attr,
-           PMAPBOOT_ENTER_NOOVERWRITE, bootpage_alloc, printf);
+       pmapboot_enter_range(va, pa, resid, attr, printf);
        aarch64_tlbi_all();
 
        return resid;
diff -r 0d18f4a3cc31 -r 9a46be1361ac sys/arch/aarch64/aarch64/pmapboot.c
--- a/sys/arch/aarch64/aarch64/pmapboot.c       Thu Jul 16 03:08:58 2020 +0000
+++ b/sys/arch/aarch64/aarch64/pmapboot.c       Thu Jul 16 11:36:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmapboot.c,v 1.7 2020/04/13 05:40:25 maxv Exp $        */
+/*     $NetBSD: pmapboot.c,v 1.8 2020/07/16 11:36:35 skrll Exp $       */
 
 /*
  * Copyright (c) 2018 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>



Home | Main Index | Thread Index | Old Index