littlenewer ·¢±íÓÚ 2014-12-20 10:56

ΪʲôȱҳÒì³£µÄʱºòΨ¶À²»±£´ægs¼Ä´æÆ÷

gs¼Ä´æÆ÷µÄµØ·½´æµÄÊÇdo_page_faultµÄµØÖ·£¬¶øÏÂÃæµÄ×¢ÊÍҲ˵ÁËÕâ¸öÇé¿ö¡£Èç¹ûÓû§½ø³ÌʹÓÃÁËgs¼Ä´æÆ÷£¬·µ»ØµÄʱºò²»ÊÇÎÞ·¨»Ö¸´ÁËÂð¡£²»½öÊÇÕâÀϵͳµ÷ÓõÄʱºòҲûÓб£´ægs

ENTRY(page_fault)
        RING0_EC_FRAME
        ASM_CLAC
        pushl_cfi $do_page_fault
        ALIGN
error_code:
        /* the function address is in %gs's slot on the stack */
        pushl_cfi %fs
        /*CFI_REL_OFFSET fs, 0*/
        pushl_cfi %es
        /*CFI_REL_OFFSET es, 0*/
        pushl_cfi %ds
        /*CFI_REL_OFFSET ds, 0*/
        pushl_cfi %eax
        CFI_REL_OFFSET eax, 0
        pushl_cfi %ebp
        CFI_REL_OFFSET ebp, 0
        pushl_cfi %edi
        CFI_REL_OFFSET edi, 0
        pushl_cfi %esi
        CFI_REL_OFFSET esi, 0
        pushl_cfi %edx
        CFI_REL_OFFSET edx, 0
        pushl_cfi %ecx
        CFI_REL_OFFSET ecx, 0
        pushl_cfi %ebx
        CFI_REL_OFFSET ebx, 0

humjb_1983 ·¢±íÓÚ 2014-12-23 16:44

¶ÑÕ»ÖÐÔ­±¾ÓÃÓÚ´æ·ÅgsµÄslotÖ»ÊÇÁÙʱÓÃÀ´´æ·ÅÒ»ÏÂdo_page_faultµÄµØÖ·£¬gsµÄÄÚÈݺóÃæ»¹ÊÇͨ¹ýecx¼Ä´æÆ÷£¬ÖØÐ·ÅÈë¸ÃλÖÃÁË¡£
error_code:
        /* the function address is in %gs's slot on the stack */
        pushl_cfi %fs
        /*CFI_REL_OFFSET fs, 0*/
        pushl_cfi %es
        /*CFI_REL_OFFSET es, 0*/
        pushl_cfi %ds
        /*CFI_REL_OFFSET ds, 0*/
        pushl_cfi %eax
        CFI_REL_OFFSET eax, 0
        pushl_cfi %ebp
        CFI_REL_OFFSET ebp, 0
        pushl_cfi %edi
        CFI_REL_OFFSET edi, 0
        pushl_cfi %esi
        CFI_REL_OFFSET esi, 0
        pushl_cfi %edx
        CFI_REL_OFFSET edx, 0
        pushl_cfi %ecx
        CFI_REL_OFFSET ecx, 0
        pushl_cfi %ebx
        CFI_REL_OFFSET ebx, 0
        cld
        movl $(__KERNEL_PERCPU), %ecx
        movl %ecx, %fs
        UNWIND_ESPFIX_STACK
        # ½«gs±£´æµ½ecx¼Ä´æÆ÷ÖÐ
        GS_TO_REG %ecx
        # ½«¶ÑÕ»ÖÐÔ­±¾´æ·Ågs´¦µÄÄÚÈÝ(ÏÖÔÚÊÇÒì³£´¦Àíº¯Êýdo_page_faultµÄµØÖ·)£¬±£´æµ½ediÖÐ
        movl PT_GS(%esp), %edi                # get the function address
        movl PT_ORIG_EAX(%esp), %edx        # get the error code
        movl $-1, PT_ORIG_EAX(%esp)        # no syscall to restart
        # ½«ecxÖеÄÄÚÈÝ·ÅÈëµ½gs(%esp)ÖУ¬´ËʱecxÖб£´æµÄÊÇÔ­gsµÄÄÚÈÝ
        REG_TO_PTGS %ecx
        # ÉèÖÃgsÄÚÈÝΪ__KERNEL_STACK_CANARY(ÓëgccµÄstack protectorÏà¹Ø£¬Î´¿ªÆô´Ë¹¦Äܵϰ£¬Êµ¼ÊΪ0)
        SET_KERNEL_GS %ecx
        # È¡__USER_DS£¬·ÅÈëdsºÍesÖÐ
        movl $(__USER_DS), %ecx
        movl %ecx, %ds
        movl %ecx, %es
        TRACE_IRQS_OFF
        movl %esp,%eax                        # pt_regs pointer
        # µ÷ÓÃÒì³£´¦ÀíºÍº¯Êý
        call *%edi
        # Òì³£·µ»Ø
        jmp ret_from_exception
        CFI_ENDPROC
END(page_fault)

littlenewer ·¢±íÓÚ 2014-12-28 16:16

ÊÇÎÒ¿´Â©ÁË£¬·Ç³£Ð»Ð»
Ò³: [1]
²é¿´ÍêÕû°æ±¾: ΪʲôȱҳÒì³£µÄʱºòΨ¶À²»±£´ægs¼Ä´æÆ÷