mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 14:58:13 +08:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user