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

Table Of Contents
18-30 Vol. 3
DEBUGGING AND PERFORMANCE MONITORING
BTMs when both the TR and LBR flags are set in the
MSR_DEBUGCTLA/IA32_DEBUGCTL MSR.
18.7.7 Last Exception Records
The Pentium 4 and Intel Xeon processors provide two 32 bit MSRs (the
MSR_LER_TO_LIP and the MSR_LER_FROM_LIP MSRs) that duplicate the functions
of the LastExceptionToIP and LastExceptionFromIP MSRs found in the P6 family
processors. The MSR_LER_TO_LIP and MSR_LER_FROM_LIP MSRs contain a branch
record for the last branch that the processor took prior to an exception or interrupt
being generated.
18.7.7.1 Last Exception Records and Intel 64 Architecture
The MSRs that store last exception records are 64-bits. If IA-32e mode is disabled,
only the lower 32-bits of the address is recorded. If IA-32e mode is enabled, the
processor writes 64-bit values into the MSR. In 64-bit mode, last exception records
store 64-bit addresses; in compatibility mode, the upper 32-bits of last exception
records are cleared.
18.7.8 Branch Trace Store (BTS)
A trace of taken branches, interrupts, and exceptions is useful for debugging code by
providing a method of determining the decision path taken to reach a particular code
location. The Pentium 4 and Intel Xeon processors provide a mechanism for
capturing records of taken branches, interrupts, and exceptions and saving them in
the last branch record (LBR) stack MSRs and/or sending them out onto the system
bus as BTMs. The branch trace store (BTS) mechanism provides the additional capa-
bility of saving the branch records in a memory-resident BTS buffer, which is part of
the DS save area. The BTS buffer can be configured to be circular so that the most
recent branch records are always available or it can be configured to generate an
interrupt when the buffer is nearly full so that all the branch records can be saved.
See Section 18.18.5, “DS Save Area.
18.7.8.1 Detection of the BTS 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 BTS (and
PEBS) facilities. When this bit is set, the following BTS facilities are available:
The BTS_UNAVAILABLE flag in the IA32_MISC_ENABLE MSR indicates (when
clear) the availability of the BTS facilities, including the ability to set the BTS and
BTINT bits in the MSR_DEBUGCTLA MSR.
The IA32_DS_AREA MSR can be programmed to point to the DS save area.