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

Table Of Contents
18-32 Vol. 3
DEBUGGING AND PERFORMANCE MONITORING
Pages that contain buffers must be mapped to the same physical addresses for all
processes, such that any change to control register CR3 will not change the DS
addresses.
The DS save area is expected to used only on systems with an enabled APIC. The
LVT Performance Counter entry in the APCI must be initialized to use an interrupt
gate instead of the trap gate.
18.7.8.3 Setting Up the BTS Buffer
Three flags in the MSR_DEBUGCTLA MSR (see Table 18-8), IA32_DEBUGCTL (see
Figure 18-8), or MSR_DEBUGCTLB (see Figure 18-10) control the generation of
branch records and storing of them in the BTS buffer; these are TR, BTS, and BTINT.
The TR flag enables the generation of BTMs. The BTS flag determines whether the
BTMs are sent out on the system bus (clear) or stored in the BTS buffer (set). BTMs
cannot be simultaneously sent to the system bus and logged in the BTS buffer. The
BTINT flag enables the generation of an interrupt when the BTS buffer is full. When
this flag is clear, the BTS buffer is a circular buffer.
The following procedure describes how to set up a Pentium 4 or Intel Xeon processor
to collect branch records in the BTS buffer in the DS save area:
1. Place values in the BTS buffer base, BTS index, BTS absolute maximum, and BTS
interrupt threshold fields of the DS buffer management area to set up the BTS
buffer in memory.
2. Set the TR and BTS flags in the MSR_DEBUGCTLA MSR (or IA32_DEBUGCTL for
Intel Core Solo and Intel Core Duo processors; or MSR_DEBUGCTLB for Pentium
M processors).
3. Either clear the BTINT flag in the MSR_DEBUGCTLA MSR (to set up a circular BTS
buffer) or set the BTINT flag (to generate an interrupt when the BTS buffer is
nearly full). For Intel Core Solo and Intel Core Duo processors, do the same in
IA32_DEBUGCTL; in MSR_DEBUGCTLB for Pentium M processors.
Table 18-8. MSR_DEBUGCTLA, IA32_DEBUGCTL, MSR_DEBUGCLTB
Flag Encodings
TR BTS BTINT Description
0 X X Branch trace messages (BTMs) off
1 0 X Generate BTMs
1 1 0 Store BTMs in the BTS buffer, used here as a circular buffer
1 1 1 Store BTMs in the BTS buffer, and generate an interrupt when
the buffer is nearly full