Page fault

The more romantic this bug is, the more beautiful it is. Parting is the most overwhelming.

I can not bear to see you back most surface I turn
to go, please do not have a lot of nostalgic moment
drifting waves like the crowds will not miss what
you could not speak to me sad goodbye
--- "could not speak good-bye."

Okay, Page fault exceptions is ready to unveil its mystery...

Let's start with the root cause

Indicates that, with paging enabled (the PG flag in the CR0 register is set), the processor detected one of the following conditions
while using the page-translation mechanism to translate a linear address to a physical address

    /**
         传递给 thread_state_suspend()三个参数
         wo: 
            即x0  
            #define THREAD_FLAGS_EXIT_ON_FOREIGN_INTR   (1 << 2)

            在整个os中仅有两处调用 thread_state_suspend ,

            另一处是在thread_rpc中 : 

            FUNC thread_rpc , 
            .....
            mov w0, #THREAD_FLAGS_COPY_ARGS_ON_RETURN
            bl  thread_state_suspend

            当thread_resume_from_rpc()的时候,会检查该flags,

            Return From RPC To Request Service of a foreign interrupt must not
            get parameters from non-secure world

            if (threads[n].flags & THREAD_FLAGS_COPY_ARGS_ON_RETURN) {
                ....
            }
            两者不只是调用同一个函数,且都是运行在屏蔽intr环境中,都是一个密室
            这里是和linux kernel intr top half 是相似的地方 

            好了,那么会问 : 到底什么是intr ? 
            为什么这么重要,为什么要处处防着它 ?

            牙膏厂给intr下了一个定义 : 

            Interrupts and exceptions are events that indicate that
            a condition exists Somewhere In The System

            哈哈,感觉起来是不是如沐春风呢! 
    */
    mov w0, #THREAD_FLAGS_EXIT_ON_FOREIGN_INTR
    mrs x1, spsr_el1
    mrs x2, elr_el1
    bl  thread_state_suspend
    mov w4, w0      /* Supply thread index */

Guess you like

Origin blog.csdn.net/leesagacious/article/details/81953050