diff --git a/arch/arm64/src/common/arm64_syscall.c b/arch/arm64/src/common/arm64_syscall.c index a192cabafba92..f21353db21cae 100644 --- a/arch/arm64/src/common/arm64_syscall.c +++ b/arch/arm64/src/common/arm64_syscall.c @@ -363,6 +363,8 @@ uint64_t *arm64_syscall(uint64_t *regs) /* Restore the cpu lock */ restore_critical_section(tcb, cpu); + //regs[REG_SP_EL0]=read_sysreg(sp_el0); + write_sysreg(ret_regs[REG_SP_EL0], sp_el0); } return ret_regs; diff --git a/arch/arm64/src/common/arm64_vector_table.S b/arch/arm64/src/common/arm64_vector_table.S index 2be686dc12025..5e60946c5587d 100644 --- a/arch/arm64/src/common/arm64_vector_table.S +++ b/arch/arm64/src/common/arm64_vector_table.S @@ -78,9 +78,9 @@ #endif stp \xreg0, \xreg1, [sp, #8 * REG_ELR] - mrs x0, sp_el0 - mrs x1, tpidrro_el0 - stp x0, x1, [sp, #8 * REG_SP_EL0] + mrs \xreg0, sp_el0 + mrs \xreg1, tpidrro_el0 + stp \xreg0, \xreg1, [sp, #8 * REG_SP_EL0] /* Increment exception depth */ @@ -268,7 +268,7 @@ SECTION_FUNC(text, arm64_exit_exception) #endif ldp x0, x1, [sp, #8 * REG_SP_EL0] - msr sp_el0, x0 + #msr sp_el0, x0 msr tpidrro_el0, x1 /* decrement exception depth */ diff --git a/arch/arm64/src/common/arm64_vectors.S b/arch/arm64/src/common/arm64_vectors.S index b7d16124a0def..d86401408ce75 100644 --- a/arch/arm64/src/common/arm64_vectors.S +++ b/arch/arm64/src/common/arm64_vectors.S @@ -126,6 +126,7 @@ SECTION_FUNC(text, arm64_jump_to_user) and x0, x0, #~SPSR_MODE_MASK #orr x0, x0, #SPSR_MODE_EL0T # EL0T=0x00, out of range for orr str x0, [sp, #8 * REG_SPSR] + mov x0, sp b arm64_exit_exception #endif @@ -177,6 +178,7 @@ SECTION_FUNC(text, arm64_sync_exc) /* Save the return value into the user context */ str x0, [sp, #8 * REG_X0] + mov sp, x0 /* Return from exception */