how does bluepill Trigger sigill?

22 views
Skip to first unread message

Kobe Kobe

unread,
Jan 21, 2021, 3:28:08 AM1/21/21
to gVisor Users [Public]
I know  sigill handler will call  bluepillHandler, but how does bluepill Trigger sigill?
// sighandler: see bluepill.go for documentation.
//
// The arguments are the following:
//
//      R0 - The signal number.
//      R1 - Pointer to siginfo_t structure.
//      R2 - Pointer to ucontext structure.
//
TEXT ·sighandler(SB),NOSPLIT,$0
        // si_signo should be sigill.
        MOVD    SIGINFO_SIGNO(R1), R7
        CMPW    $4, R7
        BNE     fallback

        MOVD    CONTEXT_PC(R2), R7
        CMPW    $0, R7
        BEQ     fallback

        MOVD    R2, 8(RSP)
        BL      ·bluepillHandler(SB)   // Call the handler.

        RET

fallback:
        // Jump to the previous signal handler.
        MOVD    ·savedHandler(SB), R7
        B       (R7)

// See bluepill.go.
TEXT ·bluepill(SB),NOSPLIT,$0
begin:
        MOVD    vcpu+0(FP), R8
        MOVD    $VCPU_CPU(R8), R9
        ORR     $0xffff000000000000, R9, R9
        // Trigger sigill.
        // In ring0.Start(), the value of R8 will be stored into tpidr_el1.
        // When the context was loaded into vcpu successfully,
        // we will check if the value of R10 and R9 are the same.
        WORD    $0xd538d08a // MRS TPIDR_EL1, R10
check_vcpu:
        CMP     R10, R9
        BEQ     right_vCPU
wrong_vcpu:
        CALL    ·redpill(SB)
        B       begin
right_vCPU:
        RET





Reply all
Reply to author
Forward
0 new messages