Intel 64 and IA-32 Architectures Software Developers Manual Volume 3B, System Programming Guide Part 2

Table Of Contents
18-18 Vol. 3
DEBUGGING AND PERFORMANCE MONITORING
Software should query an architectural MSR IA32_PERF_CAPABILITIES[5:0]
about the format of the address that is stored in the LBR stack. Three formats are
defined by following encoding:
000000B (32-bit record format) — Stores 32-bit offset in current CS of
respective source/destination,
000001B (64-bit LIP record format) — Stores 64-bit linear address of
respective source/destination,
000010B (64-bit EIP record format) — Stores 64-bit offset (effective
address) of respective source/destination.
Processor’s support for the architectural MSR IA32_PERF_CAPABILITIES is
provided by CPUID.01H:ECX[PERF_CAPAB_MSR] (bit 15).
Last Branch Record Top-of-Stack (TOS) Pointer — The lowest significant M
bits of the TOS Pointer MSR (MSR_LASTBRANCH_TOS, address 1C9H) contains
an M-bit pointer to the MSR in the LBR stack that contains the most recent
branch, interrupt, or exception recorded. The valid range of the M-bit POS pointer
is given in Table 18-3.
For compatibility, the MSR_LER_TO_LIP and the MSR_LER_FROM_LIP MSRs) dupli-
cate functions of the LastExceptionToIP and LastExceptionFromIP MSRs found in P6
family processors.
18.5.3 BTS and Related Facilities
The Debug store (DS) feature flag (bit 21), returned by CPUID.1:EDX[21] Indicates
that the processor provides the debug store (DS) mechanism. This mechanism
allows BTMs to be stored in a memory-resident BTS buffer. See Section 18.7.8,
“Branch Trace Store (BTS).” Precise event-based sampling (PEBS) also uses the DS
save area provided by debug store mechanism.
18.5.3.1 Freezing LBR and Performance Counters on PMI
Many issues may generate a performance monitoring interrupt (PMI); a PMI service
handler will need to determine cause to handle the situation. Two capabilities that
allow a PMI service routine to improve branch tracing and performance monitoring
are:
Freezing LBRs on PMI — The processor freezes LBRs on a PMI request by
clearing the LBR bit (bit 0) in IA32_DEBUGCTL. Software must then re-enable
IA32_DEBUGCTL.[0] to continue monitoring branches. When using this feature,
software should be careful about writes to IA32_DEBUGCTL to avoid re-enabling
LBRs by accident if they were just disabled.
Freezing PMCs on PMI — The processor freezes the performance counters on a
PMI request by clearing the MSR_PERF_GLOBAL_CTRL MSR (see Figure 18-22).
The PMCs affected include both general-purpose counters and fixed-function
counters (see Section 18.15.1, “Fixed-function Performance Counters”).