protected build: userspace threads will unexpectly work in privileged mode after syscall

In protected build mode, the syscall returns without setting correct value for the CONTROL register, which causes the userspace threads working in privileged mode after syscall.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
This commit is contained in:
pangzhen1 2024-07-30 18:46:35 +08:00 committed by Xiang Xiao
parent d59fbfdbdc
commit dee4c63adb
6 changed files with 9 additions and 0 deletions

View File

@ -142,6 +142,7 @@ struct xcpt_syscall_s
{
uint32_t excreturn; /* The EXC_RETURN value */
uint32_t sysreturn; /* The return PC */
uint32_t ctrlreturn; /* The return CONTROL value */
};
#endif

View File

@ -202,6 +202,7 @@ struct xcpt_syscall_s
{
uint32_t excreturn; /* The EXC_RETURN value */
uint32_t sysreturn; /* The return PC */
uint32_t ctrlreturn; /* The return CONTROL value */
};
#endif

View File

@ -213,6 +213,7 @@ struct xcpt_syscall_s
{
uint32_t excreturn; /* The EXC_RETURN value */
uint32_t sysreturn; /* The return PC */
uint32_t ctrlreturn; /* The return CONTROL value */
};
#endif

View File

@ -224,6 +224,7 @@ int arm_svcall(int irq, void *context, void *arg)
regs[REG_PC] = rtcb->xcp.syscall[index].sysreturn;
regs[REG_EXC_RETURN] = rtcb->xcp.syscall[index].excreturn;
regs[REG_CONTROL] = rtcb->xcp.syscall[index].ctrlreturn;
rtcb->xcp.nsyscalls = index;
/* The return value must be in R0-R1. dispatch_syscall()
@ -417,6 +418,7 @@ int arm_svcall(int irq, void *context, void *arg)
rtcb->xcp.syscall[index].sysreturn = regs[REG_PC];
rtcb->xcp.syscall[index].excreturn = regs[REG_EXC_RETURN];
rtcb->xcp.syscall[index].ctrlreturn = regs[REG_CONTROL];
rtcb->xcp.nsyscalls = index + 1;
regs[REG_PC] = (uint32_t)dispatch_syscall;

View File

@ -233,6 +233,7 @@ int arm_svcall(int irq, void *context, void *arg)
regs[REG_PC] = rtcb->xcp.syscall[index].sysreturn;
regs[REG_EXC_RETURN] = rtcb->xcp.syscall[index].excreturn;
regs[REG_CONTROL] = rtcb->xcp.syscall[index].ctrlreturn;
rtcb->xcp.nsyscalls = index;
/* The return value must be in R0-R1. dispatch_syscall()
@ -426,6 +427,7 @@ int arm_svcall(int irq, void *context, void *arg)
rtcb->xcp.syscall[index].sysreturn = regs[REG_PC];
rtcb->xcp.syscall[index].excreturn = regs[REG_EXC_RETURN];
rtcb->xcp.syscall[index].ctrlreturn = regs[REG_CONTROL];
rtcb->xcp.nsyscalls = index + 1;
regs[REG_PC] = (uint32_t)dispatch_syscall & ~1;

View File

@ -232,6 +232,7 @@ int arm_svcall(int irq, void *context, void *arg)
regs[REG_PC] = rtcb->xcp.syscall[index].sysreturn;
regs[REG_EXC_RETURN] = rtcb->xcp.syscall[index].excreturn;
regs[REG_CONTROL] = rtcb->xcp.syscall[index].ctrlreturn;
rtcb->xcp.nsyscalls = index;
/* The return value must be in R0-R1. dispatch_syscall()
@ -427,6 +428,7 @@ int arm_svcall(int irq, void *context, void *arg)
rtcb->xcp.syscall[index].sysreturn = regs[REG_PC];
rtcb->xcp.syscall[index].excreturn = regs[REG_EXC_RETURN];
rtcb->xcp.syscall[index].ctrlreturn = regs[REG_CONTROL];
rtcb->xcp.nsyscalls = index + 1;
regs[REG_PC] = (uint32_t)dispatch_syscall & ~1;