All pastes #53770 Raw Edit

Untitled

public text v1 · immutable
#53770 ·published 2006-05-05 21:40 UTC
rendered paste body
#ifdef BRANCH_SINGLE_STEP
        movl    PCPU(CURPCB),%ebx
        movl    $MSR_DEBUGCTLMSR,%ecx
        testl   $PCB_BRANCH_SINGLE_STEP,PCB_FLAGS(%ebx)
        jnz 1f          /*
                         * Static branch prediction should predict to not take this branch,
                         * so we'll handle the default case here and accept a misprediction
                         * if we're using branch single-stepping.
                         */

        movl    $0,%eax
        movl    $0,%edx
        wrmsr
        jmp 2f:

        /*
         * Prepare to write the DebugCtlMSR, lower part is in %eax, higher part in %edx, but not in use
         * Bit 0: If set, record last branch/exception information in the Last(Branch|Exception)(From|To)IP MSRs
         * Bit 1: If set, change semantics of the single step flag (TF) in EFLAGS to single step only on branches
         * We want both.
         */
1f:
        movl    $3,%eax
        movl    $0,%edx
        wrmsr

1:      /*
         * Clear the MSR when this feature is not used
         */
        movl    $0,%eax
        movl    $0,%edx
2:      wrmsr
#endif