UEFI Debug with Intel Architectural Event Trace

16
presented by UEFI Debug with Intel Architectural Event Trace UEFI 2021 Virtual Plugfest February 25, 2021 Presented by Alan Sguigna, ASSET InterTech, Inc. www.uefi.org 1

Transcript of UEFI Debug with Intel Architectural Event Trace

Page 1: UEFI Debug with Intel Architectural Event Trace

presented by

UEFI Debug with Intel Architectural Event Trace

UEFI 2021 Virtual PlugfestFebruary 25, 2021

Presented by Alan Sguigna, ASSET InterTech, Inc.

www.uefi.org 1

Presenter
Presentation Notes
.
Page 2: UEFI Debug with Intel Architectural Event Trace

Meet the Presenter

Alan SguignaVice President, Sales & Customer Service, ASSET InterTech, Inc.

www.uefi.org 2

Page 3: UEFI Debug with Intel Architectural Event Trace

Agenda

• Debug & Trace Described• The Intel Trace Hub• AET• Other Trace• Demo• Call to Action

www.uefi.org 3

Page 4: UEFI Debug with Intel Architectural Event Trace

Debug vs Trace• Debug (Static)

– Run-control (Break, Halt, Go)– Code Walking (stepping and

running to a break)• Trace (Dynamic)

– Root causing more obscure (hard to find) bugs

– These are the few bugs that really blow up the schedule

– Finding these bugs is where Trace shines

www.uefi.org 4

Page 5: UEFI Debug with Intel Architectural Event Trace

“New” Intel Trace Features

• Instruction Trace (Intel Processor Trace)• Event Trace (Intel Trace Hub)

www.uefi.org 5

Page 6: UEFI Debug with Intel Architectural Event Trace

Intel Trace Hub• Logic that comprises trace sources, a

global hub with timestamp, trace destinations, and a trigger unit

• A sink for writes from cores and any other trace sources

• Acts as a PCI device, and aligned with industry standards

• Trace destinations include:– MTB (8kB, out of reset)– System Memory (after MRC)– Direct Connect Interface (out of

reset, supports streaming trace)

www.uefi.org 6

Page 7: UEFI Debug with Intel Architectural Event Trace

AET

www.uefi.org 7

Event Type Event SubTypes DescriptionHW/SW Interrupt HW_INTR HW interrupt traceIRET IRET IRET traceException Exception Exception, fault, trap traceMSR RDMSR, WRMSR MSR tracePower Management POWER_ENTRY, POWER_EXIT Power managementIO PORT_IN, PORT_OUT, PORT_IN_ADDR IO traceSGX AEX, EENTER, ERESUME, EEXIT SGX traceCODE_BP CODE_BP Code breakpoint traceDATA_BP DATA_BP Data breakpointFIXED_INT SMI, RSM, NMI “Fixed” interrupt traceSW_POWER MONITOR/MWAIT MONITOR/MWAIT traceWBINVD WBINVD_BEGIN, WBINVD_END Write-back invalidate trace

Page 8: UEFI Debug with Intel Architectural Event Trace

AET Tips #1

www.uefi.org 8

• Probe-mode (JTAG) needed to initialize AET – use outside of probe mode (i.e. BIOS, device driver) causes #GP.

• AET is implemented in CPU microcode and does not modify the architectural behavior* of the processors – no need to instrument code!– * Enabling CODE/DATA_BP changes the behavior of normal

breakpoints – causes a trace event rather than a debug exception. Great for critical sections of code, concurrency issues, debugging memory accesses, etc.

• This is event trace, not instruction trace - source code/ symbols not required (but it’s great if you have them!)

Page 9: UEFI Debug with Intel Architectural Event Trace

AET Tips #2• A Last Branch Record (LBR) instruction trace stack can be added to all

event traces – a fast way to trace back ~ 160 instructions• LBR uses MSRs to track from_address and to_address pairs, so operates out of reset –

no need for system memory• Intel Processor Trace and AET can run concurrently

• IPT places trace data in system memory• On Ice Lake processors, both AET LBR tracing and Intel Processor Trace

can be enabled at the same time• AET using XDP access became available initially on Skylake Client and

Server• AET Streaming through DCI (USB) first became available on Ice Lake Client

(not available on Purley or Whitley platforms)

www.uefi.org 9

Page 10: UEFI Debug with Intel Architectural Event Trace

Other Trace Hub Trace• SW/FW Trace

– Replacement for printf– Avoids backpressure

from serial port– Great for “Heisenbugs”

• CSME (Management Engine)

• All timestamped and correlated*

www.uefi.org 10

SW/FW Trace timestamp correlation only available on later silicon.

Page 11: UEFI Debug with Intel Architectural Event Trace

Demo Configuration

www.uefi.org 11

SourcePoint debugger

Ice Lake Client

“Special” USB cable

Intel DesignInTools

Page 12: UEFI Debug with Intel Architectural Event Trace

www.uefi.org 12

Demo

Page 13: UEFI Debug with Intel Architectural Event Trace

Call to Action

• Take advantage of open source UEFI learning/ development opportunities– Debugging Intel Firmware using DCI & USB

3.0– Advanced Capabilities of Architectural

Event Trace

www.uefi.org 13

Page 14: UEFI Debug with Intel Architectural Event Trace

Questions?

www.uefi.org 14

Page 15: UEFI Debug with Intel Architectural Event Trace

More Questions?

www.uefi.org 15

Following today’s webinar, join the live, interactive WebEx Q&A for the opportunity to chat with the presenter

Visit this link to attend: https://bit.ly/38JIx9RMeeting number (access code): 126 016 9253Meeting password: UEFIForum (83343678 from phones and video systems)

Page 16: UEFI Debug with Intel Architectural Event Trace

Thanks for attending the UEFI 2021 Virtual Plugfest

For more information on UEFI Forum and UEFI Specifications, visit http://www.uefi.org

presented by

www.uefi.org 16