diff --git a/arch/arm/arm/include/los_hw_cpu.h b/arch/arm/arm/include/los_hw_cpu.h index 02c7ea4d..f6fc4460 100644 --- a/arch/arm/arm/include/los_hw_cpu.h +++ b/arch/arm/arm/include/los_hw_cpu.h @@ -189,6 +189,24 @@ STATIC INLINE UINT32 ArchIntUnlock(VOID) return intSave; } +STATIC INLINE VOID ArchIrqDisable(VOID) +{ + __asm__ __volatile__( + "cpsid i " + : + : + : "memory", "cc"); +} + +STATIC INLINE VOID ArchIrqEnable(VOID) +{ + __asm__ __volatile__( + "cpsie i " + : + : + : "memory", "cc"); +} + #else STATIC INLINE UINT32 ArchIntLock(VOID) diff --git a/arch/arm/arm/src/los_exc.c b/arch/arm/arm/src/los_exc.c index 3197c397..dd94396d 100644 --- a/arch/arm/arm/src/los_exc.c +++ b/arch/arm/arm/src/los_exc.c @@ -185,18 +185,29 @@ STATIC INT32 OsDecodeDataFSR(UINT32 regDFSR) #ifdef LOSCFG_KERNEL_VM UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT32 fsr) { - PRINT_INFO("page fault entry!!!\n"); - BOOL instruction_fault = FALSE; + BOOL instructionFault = FALSE; UINT32 pfFlags = 0; UINT32 fsrFlag; BOOL write = FALSE; + UINT32 ret; + PRINT_INFO("page fault entry!!!\n"); if (OsGetSystemStatus() == OS_SYSTEM_EXC_CURR_CPU) { return LOS_ERRNO_VM_NOT_FOUND; } - +#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION) + BOOL irqEnable = !(LOS_SpinHeld(&g_taskSpin) && (OsPercpuGet()->taskLockCnt != 0)); + if (irqEnable) { + ArchIrqEnable(); + } else { + PrintExcInfo("[ERR][%s] may be held scheduler lock when entering [%s]\n", + OsCurrTaskGet()->taskName, __FUNCTION__); + } +#else + ArchIrqEnable(); +#endif if (excType == OS_EXCEPT_PREFETCH_ABORT) { - instruction_fault = TRUE; + instructionFault = TRUE; } else { write = !!BIT_GET(fsr, WNR_BIT); } @@ -214,13 +225,23 @@ UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT3 BOOL user = (frame->regCPSR & CPSR_MODE_MASK) == CPSR_MODE_USR; pfFlags |= write ? VM_MAP_PF_FLAG_WRITE : 0; pfFlags |= user ? VM_MAP_PF_FLAG_USER : 0; - pfFlags |= instruction_fault ? VM_MAP_PF_FLAG_INSTRUCTION : 0; + pfFlags |= instructionFault ? VM_MAP_PF_FLAG_INSTRUCTION : 0; pfFlags |= VM_MAP_PF_FLAG_NOT_PRESENT; - return OsVmPageFaultHandler(far, pfFlags, frame); + ret = OsVmPageFaultHandler(far, pfFlags, frame); + break; } default: - return LOS_ERRNO_VM_NOT_FOUND; + ret = LOS_ERRNO_VM_NOT_FOUND; + break; } +#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION) + if (irqEnable) { + ArchIrqDisable(); + } +#else + ArchIrqDisable(); +#endif + return ret; } #endif diff --git a/arch/arm/arm/src/los_hw_exc.S b/arch/arm/arm/src/los_hw_exc.S index 007537d1..a1d7d2e9 100644 --- a/arch/arm/arm/src/los_hw_exc.S +++ b/arch/arm/arm/src/los_hw_exc.S @@ -331,9 +331,7 @@ _osExcPageFault: MOV R5, R0 MOV R8, R2 MOV R9, R3 - CPSIE I BLX OsArmSharedPageFault - CPSID I POP_FPU_REGS R1 MOV SP, R4