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

Table Of Contents
Vol. 3 18-117
DEBUGGING AND PERFORMANCE MONITORING
In processors based on Intel Core microarchitecture, a similar PEBS mechanism is
also supported using IA32_PMC0 and IA32_PERFEVTSEL0 MSRs (See Section
18.15.4).
18.18.8.1 Detection of the Availability of the PEBS Facilities
The DS feature flag (bit 21) returned by the CPUID instruction indicates (when set)
the availability of the DS mechanism in the processor, which supports the PEBS (and
BTS) facilities. When this bit is set, the following PEBS facilities are available:
The PEBS_UNAVAILABLE flag in the IA32_MISC_ENABLE MSR indicates (when
clear) the availability of the PEBS facilities, including the MSR_PEBS_ENABLE
MSR.
The enable PEBS flag (bit 24) in the MSR_PEBS_ENABLE MSR allows PEBS to be
enabled (set) or disabled (clear).
The IA32_DS_AREA MSR can be programmed to point to the DS save area.
18.18.8.2 Setting Up the DS Save Area
Section 18.7.8.2, “Setting Up the DS Save Area,” describes how to set up and enable
the DS save area. This procedure is common for PEBS and BTS.
18.18.8.3 Setting Up the PEBS Buffer
Only the MSR_IQ_COUNTER4 performance counter can be used for PEBS. Use the
following procedure to set up the processor and this counter for PEBS:
1. Set up the precise event buffering facilities. Place values in the precise event
buffer base, precise event index, precise event absolute maximum, and precise
event interrupt threshold, and precise event counter reset fields of the DS buffer
management area (see Figure 18-38) to set up the precise event records buffer
in memory.
2. Enable PEBS. Set the Enable PEBS flag (bit 24) in MSR_PEBS_ENABLE MSR.
3. Set up the MSR_IQ_COUNTER4 performance counter and its associated CCCR
and one or more ESCRs for PEBS as described in Tables A-10 through A-14.
18.18.8.4 Writing a PEBS Interrupt Service Routine
The PEBS facilities share the same interrupt vector and interrupt service routine
(called the DS ISR) with the non-precise event-based sampling and BTS facilities. To
handle PEBS interrupts, PEBS handler code must be included in the DS ISR. See
Section 18.7.8.5, “Writing the DS Interrupt Service Routine,” for guidelines for
writing the DS ISR.