Print this page
9736 kmdb tortures via single-step miscellaneous trap
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>


 389          * the saved %rsp.
 390          */
 391 
 392         pushq   %rsp            /* pushed value off by 8 */
 393         pushfq
 394         CLI(%rax)
 395         pushq   $KCS_SEL
 396         clrq    %rax
 397         movw    %ss, %ax
 398         pushq   %rax            /* rip should be here */
 399         pushq   $-1             /* phony trap error code */
 400         pushq   $-1             /* phony trap number */
 401 
 402         subq    $REG_OFF(KDIREG_TRAPNO), %rsp
 403         KDI_SAVE_REGS(%rsp)
 404 
 405         movq    %cr3, %rax
 406         movq    %rax, REG_OFF(KDIREG_CR3)(%rsp)
 407 
 408         movq    REG_OFF(KDIREG_SS)(%rsp), %rax

 409         xchgq   REG_OFF(KDIREG_RIP)(%rsp), %rax
 410         movq    %rax, REG_OFF(KDIREG_SS)(%rsp)
 411 
 412         movq    REG_OFF(KDIREG_RSP)(%rsp), %rax
 413         addq    $8, %rax
 414         movq    %rax, REG_OFF(KDIREG_RSP)(%rsp)
 415 
 416         /*
 417          * We've saved all of the general-purpose registers, and have a stack
 418          * that is irettable (after we strip down to the error code)
 419          */
 420 
 421         GET_CPUSAVE_ADDR        /* %rax = cpusave, %rbx = CPU ID */
 422 
 423         ADVANCE_CRUMB_POINTER(%rax, %rcx, %rdx)
 424 
 425         ADD_CRUMB(%rax, KRM_CPU_STATE, $KDI_CPU_STATE_SLAVE, %rdx)
 426 
 427         movq    REG_OFF(KDIREG_RIP)(%rsp), %rcx
 428         ADD_CRUMB(%rax, KRM_PC, %rcx, %rdx)



 429 


 430         pushq   %rax
 431         jmp     kdi_save_common_state
 432 
 433         SET_SIZE(kdi_slave_entry)
 434 
 435 /*
 436  * The state of the world:
 437  *
 438  * The stack has a complete set of saved registers and segment
 439  * selectors, arranged in the kdi_regs.h order.  It also has a pointer
 440  * to our cpusave area.
 441  *
 442  * We need to save, into the cpusave area, a pointer to these saved
 443  * registers.  First we check whether we should jump straight back to
 444  * the kernel.  If not, we save a few more registers, ready the
 445  * machine for debugger entry, and enter the debugger.
 446  */
 447 
 448         ENTRY_NP(kdi_save_common_state)
 449 




 389          * the saved %rsp.
 390          */
 391 
 392         pushq   %rsp            /* pushed value off by 8 */
 393         pushfq
 394         CLI(%rax)
 395         pushq   $KCS_SEL
 396         clrq    %rax
 397         movw    %ss, %ax
 398         pushq   %rax            /* rip should be here */
 399         pushq   $-1             /* phony trap error code */
 400         pushq   $-1             /* phony trap number */
 401 
 402         subq    $REG_OFF(KDIREG_TRAPNO), %rsp
 403         KDI_SAVE_REGS(%rsp)
 404 
 405         movq    %cr3, %rax
 406         movq    %rax, REG_OFF(KDIREG_CR3)(%rsp)
 407 
 408         movq    REG_OFF(KDIREG_SS)(%rsp), %rax
 409         movq    %rax, REG_OFF(KDIREG_SAVPC)(%rsp)
 410         xchgq   REG_OFF(KDIREG_RIP)(%rsp), %rax
 411         movq    %rax, REG_OFF(KDIREG_SS)(%rsp)
 412 
 413         movq    REG_OFF(KDIREG_RSP)(%rsp), %rax
 414         addq    $8, %rax
 415         movq    %rax, REG_OFF(KDIREG_RSP)(%rsp)
 416 
 417         /*
 418          * We've saved all of the general-purpose registers, and have a stack
 419          * that is irettable (after we strip down to the error code)
 420          */
 421 
 422         GET_CPUSAVE_ADDR        /* %rax = cpusave, %rbx = CPU ID */
 423 
 424         ADVANCE_CRUMB_POINTER(%rax, %rcx, %rdx)
 425 
 426         ADD_CRUMB(%rax, KRM_CPU_STATE, $KDI_CPU_STATE_SLAVE, %rdx)
 427 
 428         movq    REG_OFF(KDIREG_RIP)(%rsp), %rcx
 429         ADD_CRUMB(%rax, KRM_PC, %rcx, %rdx)
 430         movq    REG_OFF(KDIREG_RSP)(%rsp), %rcx
 431         ADD_CRUMB(%rax, KRM_SP, %rcx, %rdx)
 432         ADD_CRUMB(%rax, KRM_TRAPNO, $-1, %rdx)
 433 
 434         movq    $KDI_CPU_STATE_SLAVE, KRS_CPU_STATE(%rax)
 435 
 436         pushq   %rax
 437         jmp     kdi_save_common_state
 438 
 439         SET_SIZE(kdi_slave_entry)
 440 
 441 /*
 442  * The state of the world:
 443  *
 444  * The stack has a complete set of saved registers and segment
 445  * selectors, arranged in the kdi_regs.h order.  It also has a pointer
 446  * to our cpusave area.
 447  *
 448  * We need to save, into the cpusave area, a pointer to these saved
 449  * registers.  First we check whether we should jump straight back to
 450  * the kernel.  If not, we save a few more registers, ready the
 451  * machine for debugger entry, and enter the debugger.
 452  */
 453 
 454         ENTRY_NP(kdi_save_common_state)
 455