Skip to content

Guest Architectural LBR Enabling

Like Xu kvm lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6KVM: vmx/pmu: Add VMCS field check before exposing LBR_FMTarch/x86/kvm/vmx/capabilities.h+8 -10 replies
2/6perf/x86/lbr: Unify LBR_INFO registers exposure check conditionarch/x86/events/intel/lbr.c+1 -30 replies
3/6KVM: vmx/pmu: Add MSR_ARCH_LBR_DEPTH emulation for Arch LBRarch/x86/kvm/vmx/pmu_intel.c arch/x86/kvm/vmx/vmx.h+47 -00 replies
4/6KVM: vmx/pmu: Add MSR_ARCH_LBR_CTL emulation for Arch LBRarch/x86/include/asm/vmx.h arch/x86/kvm/vmx/pmu_intel.c arch/x86/kvm/vmx/vmx.c+23 -00 replies
5/6KVM: vmx/pmu: Add Arch LBR emulation and its VMCS fieldarch/x86/include/asm/vmx.h arch/x86/kvm/vmx/capabilities.h arch/x86/kvm/vmx/pmu_intel.c +1 more+28 -60 replies
6/6KVM: x86: Expose Architectural LBR CPUID and its XSAVES bitarch/x86/kvm/cpuid.c arch/x86/kvm/vmx/vmx.c arch/x86/kvm/x86.c+27 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/6] Guest Architectural LBR Enabling

Hi All (especially developers who use perf in guest),

Please help review the ssuccessor pacthes to enable Arch LBR on KVM. (The prerequisite v13 LBR patchset [2] seems more eager to get the attention of reviewers and maintainer).

LBR (Last Branch Records) enables recording of software path history by logging taken branches and other control flows within architectural registers. Intel CPUs have had model-specific LBRs for quite some time but this evolves them into an architectural feature now.

The Architectural Last Branch Records (LBRS) is already publiced in the 319433-040 release of Intel® Architecture Instruction Set Extensions and Future Features Programming Reference [0].

The main advantages for the Arch LBR users are [1]:
- Faster context switching due to XSAVES support and faster reset of LBR MSRs via the new DEPTH MSR
- Faster LBR read for a non-PEBS event due to XSAVES support, which lowers the overhead of the NMI handler. (For a PEBS event, the LBR information is recorded in the PEBS records. There is no impact on the PEBS event.)
- Linux kernel can support the LBR features without knowing the model number of the current CPU.

The Kernel 5.9 will enable Arch LBR on the host based on tip/perf/core, so this patchset happens to enable it on KVM as well.

Before 'git am' this patchset, you may need merge the latest tip/perf/core branch and the legacy LBR enabling patches [PATCH v13 00/10] Guest Last Branch Recording Enabling [2]. or just wait for the above pacthes to be merged upstream.

[0] https://software.intel.com/content/www/us/en/develop/download/
intel-architecture-instruction-set-extensions-and-future-features-programming-reference.html
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/kvm/[email protected]/

Please check more details in each commit and feel free to comment.

Like Xu (6):
KVM: vmx/pmu: Add VMCS field check before exposing LBR_FMT perf/x86/lbr: Unify LBR_INFO registers exposure check condition
KVM: vmx/pmu: Add MSR_ARCH_LBR_DEPTH emulation for Arch LBR
KVM: vmx/pmu: Add MSR_ARCH_LBR_CTL emulation for Arch LBR
KVM: vmx/pmu: Add Arch LBR emulation and its VMCS field
KVM: x86: Expose Architectural LBR CPUID and its XSAVES bit

 arch/x86/events/intel/lbr.c     |  4 +-
 arch/x86/include/asm/vmx.h      |  4 ++
 arch/x86/kvm/cpuid.c            | 19 +++++++++
 arch/x86/kvm/vmx/capabilities.h | 16 ++++++-
 arch/x86/kvm/vmx/pmu_intel.c    | 74 +++++++++++++++++++++++++++++++--
 arch/x86/kvm/vmx/vmx.c          | 16 ++++++-
 arch/x86/kvm/vmx/vmx.h          |  3 ++
 arch/x86/kvm/x86.c              |  6 +++
 8 files changed, 133 insertions(+), 9 deletions(-)
Signature · 1 line
2.21.3