diff options
| author | Shell <[email protected]> | 2023-02-14 23:08:32 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-14 23:08:32 +0800 |
| commit | 2d0974908659bd41d748e69fac0166c37b15cb02 (patch) | |
| tree | ef9a9eb4ee3d6351138349d2314f48ccb9e6fa36 /libcpu/aarch64 | |
| parent | fc1aced66574e6ef144b6b228978e734456e6f95 (diff) | |
[rt-smart] PV_OFFSET as a variable (#6904)
* [rt-smart/mem] remove pv_offset
* [rt-smart] list kernel space command
* [rt-smart] restore ioremap region
* [revert] restore kernel space isolation
* [rt-smart/pv_off] code format
* [rt-smart] add get_pvoff()
* [pvoffset] pvoff as constant for C codes
* [pvoff] pvoff as interfaces
Diffstat (limited to 'libcpu/aarch64')
| -rw-r--r-- | libcpu/aarch64/common/mmu.c | 9 | ||||
| -rw-r--r-- | libcpu/aarch64/common/mmu.h | 2 | ||||
| -rw-r--r-- | libcpu/aarch64/common/trap.c | 1 | ||||
| -rw-r--r-- | libcpu/aarch64/cortex-a/entry_point.S | 44 |
4 files changed, 30 insertions, 26 deletions
diff --git a/libcpu/aarch64/common/mmu.c b/libcpu/aarch64/common/mmu.c index d567d111d9..b175450dc7 100644 --- a/libcpu/aarch64/common/mmu.c +++ b/libcpu/aarch64/common/mmu.c @@ -309,6 +309,9 @@ void rt_hw_mmu_setup(rt_aspace_t aspace, struct mem_desc *mdesc, int desc_nr) mdesc->vaddr_start + 1, .prefer = (void *)mdesc->vaddr_start}; + if (mdesc->paddr_start == (rt_size_t)ARCH_MAP_FAILED) + mdesc->paddr_start = mdesc->vaddr_start + PV_OFFSET; + rt_aspace_map_phy_static(aspace, &mdesc->varea, &hint, attr, mdesc->paddr_start >> MM_PAGE_SHIFT, &err); mdesc++; @@ -656,10 +659,14 @@ int rt_hw_mmu_control(struct rt_aspace *aspace, void *vaddr, size_t size, return err; } -void rt_hw_mmu_setup_early(unsigned long *tbl0, unsigned long *tbl1, +void rt_hw_mem_setup_early(unsigned long *tbl0, unsigned long *tbl1, unsigned long size, unsigned long pv_off) { int ret; + + /* setup pv off */ + rt_kmem_pvoff_set(pv_off); + unsigned long va = KERNEL_VADDR_START; unsigned long count = (size + ARCH_SECTION_MASK) >> ARCH_SECTION_SHIFT; unsigned long normal_attr = MMU_MAP_CUSTOM(MMU_AP_KAUN, NORMAL_MEM); diff --git a/libcpu/aarch64/common/mmu.h b/libcpu/aarch64/common/mmu.h index 6dc8cdca31..912ee6fdb9 100644 --- a/libcpu/aarch64/common/mmu.h +++ b/libcpu/aarch64/common/mmu.h @@ -74,7 +74,7 @@ struct mem_desc struct rt_aspace; void rt_hw_mmu_ktbl_set(unsigned long tbl); -void rt_hw_mmu_setup_early(unsigned long *tbl0, unsigned long *tbl1, +void rt_hw_mem_setup_early(unsigned long *tbl0, unsigned long *tbl1, unsigned long size, unsigned long pv_off); void rt_hw_mmu_setup(struct rt_aspace *aspace, struct mem_desc *mdesc, int desc_nr); diff --git a/libcpu/aarch64/common/trap.c b/libcpu/aarch64/common/trap.c index 0a2dd2e9ed..7527440f9f 100644 --- a/libcpu/aarch64/common/trap.c +++ b/libcpu/aarch64/common/trap.c @@ -45,6 +45,7 @@ void check_user_fault(struct rt_hw_exp_stack *regs, uint32_t pc_adj, char *info) #ifdef LWP_USING_CORE_DUMP lwp_core_dump(regs, pc_adj); #endif + backtrace((unsigned long)regs->pc, (unsigned long)regs->x30, (unsigned long)regs->x29); sys_exit(-1); } } diff --git a/libcpu/aarch64/cortex-a/entry_point.S b/libcpu/aarch64/cortex-a/entry_point.S index 89c383a1e5..a73b420781 100644 --- a/libcpu/aarch64/cortex-a/entry_point.S +++ b/libcpu/aarch64/cortex-a/entry_point.S @@ -78,12 +78,12 @@ __start: eret /* exception return. from EL2. continue from .L__in_el1 */ +.macro GET_PHY reg, symbol + adrp \reg, \symbol + add \reg, \reg, #:lo12:\symbol +.endm + .L__in_el1: -#ifdef RT_USING_LWP - ldr x9, =PV_OFFSET -#else - mov x9, #0 -#endif mov sp, x1 /* in EL1. Set sp to _start */ /* Set CPACR_EL1 (Architecture Feature Access Control Register) to avoid trap from SIMD or float point instruction */ @@ -91,15 +91,13 @@ __start: msr cpacr_el1, x1 /* clear bss */ - adrp x1, __bss_start /* get bss start address */ - add x1, x1, #:lo12:__bss_start - adrp x2, __bss_end - add x1, x1, #:lo12:__bss_end - sub x2, x2, x1 /* get bss size */ + GET_PHY x1, __bss_start + GET_PHY x2, __bss_end + sub x2, x2, x1 /* get bss size */ - and x3, x2, #7 /* x3 is < 7 */ + and x3, x2, #7 /* x3 is < 7 */ ldr x4, =~0x7 - and x2, x2, x4 /* mask ~7 */ + and x2, x2, x4 /* mask ~7 */ .L__clean_bss_loop: cbz x2, .L__clean_bss_loop_1 @@ -116,7 +114,7 @@ __start: .L__jump_to_entry: /* jump to C code, should not return */ bl mmu_tcr_init - adr x1, __start + adr x1, __start /* install early page table */ ldr x0, =~0x1fffff and x0, x1, x0 add x1, x0, #0x1000 @@ -125,11 +123,13 @@ __start: msr ttbr1_el1, x1 dsb sy - ldr x2, =0x40000000 /* map 1G memory for kernel space */ -#ifdef RT_USING_LWP - ldr x3, =PV_OFFSET +#ifdef RT_USING_SMART + ldr x2, =__start + GET_PHY x3, __start + sub x3, x3, x2 #endif - bl rt_hw_mmu_setup_early + ldr x2, =0x40000000 /* map 1G memory for kernel space */ + bl rt_hw_mem_setup_early ldr x30, =after_mmu_enable /* set LR to after_mmu_enable function, it's a v_addr */ @@ -152,7 +152,7 @@ __start: ret after_mmu_enable: -#ifdef RT_USING_LWP +#ifdef RT_USING_SMART mrs x0, tcr_el1 /* disable ttbr0, only using kernel space */ orr x0, x0, #(1 << 7) msr tcr_el1, x0 @@ -172,7 +172,7 @@ after_mmu_enable: * secondary cpu */ -.globl _secondary_cpu_entry +.global _secondary_cpu_entry _secondary_cpu_entry: bl rt_hw_cpu_id_set adr x1, __start @@ -225,10 +225,6 @@ _secondary_cpu_entry: eret /* exception return. from EL2. continue from .L__in_el1 */ .L__in_el1_cpux: - adr x19, .L__in_el1_cpux - ldr x8, =.L__in_el1_cpux - sub x19, x19, x8 /* get PV_OFFSET */ - mrs x0, tpidr_el1 /* each cpu init stack is 8k */ sub x1, x1, x0, lsl #13 @@ -244,7 +240,7 @@ _secondary_cpu_entry: bl mmu_tcr_init - adr x1, __start + adr x1, __start /* GET & setup early page table */ ldr x0, =~0x1fffff and x0, x1, x0 add x1, x0, #0x1000 |
