!234 用户态异常处理,进程退出时恢复系统正常运行的过程依赖编译器行为,存在风险
Merge pull request !234 from zhushengle/exc
This commit is contained in:
commit
d724a975b5
|
@ -40,11 +40,6 @@ extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
STATIC INLINE VOID OsSetCurrCpuSp(UINTPTR regSp)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__("mov sp, %0" :: "r"(regSp));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define OS_SYSTEM_NORMAL 0
|
#define OS_SYSTEM_NORMAL 0
|
||||||
#define OS_SYSTEM_EXC_CURR_CPU 1
|
#define OS_SYSTEM_EXC_CURR_CPU 1
|
||||||
#define OS_SYSTEM_EXC_OTHER_CPU 2
|
#define OS_SYSTEM_EXC_OTHER_CPU 2
|
||||||
|
|
|
@ -525,7 +525,7 @@ VOID OsDumpContextMem(const ExcContext *excBufAddr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID OsExcRestore(UINTPTR taskStackPointer)
|
STATIC VOID OsExcRestore(VOID)
|
||||||
{
|
{
|
||||||
UINT32 currCpuID = ArchCurrCpuid();
|
UINT32 currCpuID = ArchCurrCpuid();
|
||||||
|
|
||||||
|
@ -536,8 +536,6 @@ STATIC VOID OsExcRestore(UINTPTR taskStackPointer)
|
||||||
OsPercpuGet()->excFlag = CPU_RUNNING;
|
OsPercpuGet()->excFlag = CPU_RUNNING;
|
||||||
#endif
|
#endif
|
||||||
OsPercpuGet()->taskLockCnt = 0;
|
OsPercpuGet()->taskLockCnt = 0;
|
||||||
|
|
||||||
OsSetCurrCpuSp(taskStackPointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||||
|
@ -564,8 +562,6 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||||
#endif
|
#endif
|
||||||
runProcess->processStatus &= ~OS_PROCESS_FLAG_EXIT;
|
runProcess->processStatus &= ~OS_PROCESS_FLAG_EXIT;
|
||||||
|
|
||||||
OsExcRestore(excBufAddr->SP);
|
|
||||||
|
|
||||||
#if (LOSCFG_KERNEL_SMP == YES)
|
#if (LOSCFG_KERNEL_SMP == YES)
|
||||||
#ifdef LOSCFG_FS_VFS
|
#ifdef LOSCFG_FS_VFS
|
||||||
OsWakeConsoleSendTask();
|
OsWakeConsoleSendTask();
|
||||||
|
@ -577,6 +573,9 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||||
#endif
|
#endif
|
||||||
OsProcessExitCodeSignalSet(runProcess, SIGUSR2);
|
OsProcessExitCodeSignalSet(runProcess, SIGUSR2);
|
||||||
|
|
||||||
|
/* Exception handling All operations should be kept prior to that operation */
|
||||||
|
OsExcRestore();
|
||||||
|
|
||||||
/* kill user exc process */
|
/* kill user exc process */
|
||||||
LOS_Exit(OS_PRO_EXIT_OK);
|
LOS_Exit(OS_PRO_EXIT_OK);
|
||||||
|
|
||||||
|
@ -962,7 +961,7 @@ STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID OsCheckAllCpuStatus(UINTPTR taskStackPointer)
|
STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||||
{
|
{
|
||||||
UINT32 currCpuID = ArchCurrCpuid();
|
UINT32 currCpuID = ArchCurrCpuid();
|
||||||
UINT32 ret, target;
|
UINT32 ret, target;
|
||||||
|
@ -982,7 +981,7 @@ STATIC VOID OsCheckAllCpuStatus(UINTPTR taskStackPointer)
|
||||||
} else if (g_excFromUserMode[currCpuID] == TRUE) {
|
} else if (g_excFromUserMode[currCpuID] == TRUE) {
|
||||||
if (OsCurrProcessGet()->processID == g_currHandleExcPID) {
|
if (OsCurrProcessGet()->processID == g_currHandleExcPID) {
|
||||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||||
OsExcRestore(taskStackPointer);
|
OsExcRestore();
|
||||||
while (1) {
|
while (1) {
|
||||||
ret = LOS_TaskSuspend(OsCurrTaskGet()->taskID);
|
ret = LOS_TaskSuspend(OsCurrTaskGet()->taskID);
|
||||||
PrintExcInfo("%s supend task :%u failed: 0x%x\n", __FUNCTION__, OsCurrTaskGet()->taskID, ret);
|
PrintExcInfo("%s supend task :%u failed: 0x%x\n", __FUNCTION__, OsCurrTaskGet()->taskID, ret);
|
||||||
|
@ -1010,12 +1009,11 @@ STATIC VOID OsCheckAllCpuStatus(UINTPTR taskStackPointer)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC VOID OsCheckCpuStatus(UINTPTR taskStackPointer)
|
STATIC VOID OsCheckCpuStatus(VOID)
|
||||||
{
|
{
|
||||||
#if (LOSCFG_KERNEL_SMP == YES)
|
#if (LOSCFG_KERNEL_SMP == YES)
|
||||||
OsCheckAllCpuStatus(taskStackPointer);
|
OsCheckAllCpuStatus();
|
||||||
#else
|
#else
|
||||||
(VOID)taskStackPointer;
|
|
||||||
g_currHandleExcCpuID = ArchCurrCpuid();
|
g_currHandleExcCpuID = ArchCurrCpuid();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1036,7 +1034,7 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
|
||||||
g_excFromUserMode[ArchCurrCpuid()] = FALSE;
|
g_excFromUserMode[ArchCurrCpuid()] = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
OsCheckCpuStatus(excBufAddr->SP);
|
OsCheckCpuStatus();
|
||||||
|
|
||||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
|
@ -371,6 +371,13 @@ _osExceptDispatch:
|
||||||
|
|
||||||
MOV R1, SP
|
MOV R1, SP
|
||||||
|
|
||||||
|
#ifdef LOSCFG_KERNEL_VM
|
||||||
|
LDR R2, [SP, #(19 * 4)] @ Get CPSR
|
||||||
|
AND R2, R2, #CPSR_MASK_MODE @ Interrupted mode
|
||||||
|
CMP R2, #CPSR_USER_MODE @ User mode
|
||||||
|
BEQ _osExceptionGetSP
|
||||||
|
#endif
|
||||||
|
|
||||||
EXC_SP_SET __exc_stack_top, OS_EXC_STACK_SIZE, R6, R7
|
EXC_SP_SET __exc_stack_top, OS_EXC_STACK_SIZE, R6, R7
|
||||||
|
|
||||||
MRC P15, 0, R4, C0, C0, 5
|
MRC P15, 0, R4, C0, C0, 5
|
||||||
|
|
Loading…
Reference in New Issue