Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH 0/7] KVM: SVM: Add support for AMD LBR Extension v2
@ 2026-07-24 19:50 Shivansh Dhiman
  2026-07-24 19:50 ` [PATCH 1/7] KVM: SVM: Add VMCB fields for LBR v2 virtualization Shivansh Dhiman
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Shivansh Dhiman @ 2026-07-24 19:50 UTC (permalink / raw)
  To: seanjc, pbonzini, tglx, mingo
  Cc: kvm, x86, yosry, jmattson, thomas.lendacky, nikunj.dadhania,
	sandipan.das, santosh.shukla, shivansh.dhiman

This series adds SVM support for virtualizing AMD's Last Branch Record
Extension v2 (LbrExtV2) in KVM.

LbrExtV2, introduced on Zen 4, is a branch sampling facility providing a
16-entry stack of last-taken branches via dedicated MSRs:
  * MSR 0xC000010E - Last Branch Stack Select  (LBR_SELECT)
  * MSR 0xC000010F - Debug Extension Control   (DBG_EXTN_CFG)
  * MSR 0xC0010300..0xC001031F - 16 LBR FROM/TO MSR pairs

AMD hardware extends the VMCB save area with fields for these MSRs. When
V_LBR (VMCB.MISC_CTL2.LBR_VIRTUALIZATION_ENABLE) is set, the CPU saves and
restores the guest's LbrExtV2 state on VMRUN/#VMEXIT, letting the guest
use LBR v2 without being intercepted.

V_LBR is enabled lazily, i.e, LBR virtualization is enabled only when
guest flips the DbgExtnCfg.LBRv2En (bit 6) to record branches. This is done
to prevent MSR save/restore cost during VMRUN/#VMEXIT cycles when V_LBR
is disabled. The dependent LBR and PMC freeze-on-PMI feature is added on top.

Testing must be done by first disabling NMI watchdog on the host machine, and
enabling the Mediated PMU framework.
$ echo 0 | sudo tee /proc/sys/kernel/nmi_watchdog
$ sudo modprobe kvm_amd enable_mediated_pmu=1

Regards,
Shivansh

---
Sandipan Das (1):
  KVM: SVM: Add VMCB fields for LBR v2 virtualization

Shivansh Dhiman (6):
  KVM: SVM: Add capability for LbrExtV2
  KVM: SVM: Emulate guest accesses to LBR v2 MSRs
  KVM: SVM: Enable hardware-assisted LBR v2 virtualization
  KVM: SVM: Advertise LbrExtV2 to userspace
  KVM: SVM: Add LBR/PMC freeze support
  KVM: x86: Use SCATTERED_F() for PERFMON_V2

 arch/x86/events/core.c            |   1 +
 arch/x86/include/asm/perf_event.h |   1 +
 arch/x86/include/asm/svm.h        |  16 +++-
 arch/x86/kvm/cpuid.c              |   9 +-
 arch/x86/kvm/reverse_cpuid.h      |   6 +-
 arch/x86/kvm/svm/svm.c            | 140 +++++++++++++++++++++++++++++-
 arch/x86/kvm/svm/svm.h            |   7 +-
 7 files changed, 172 insertions(+), 8 deletions(-)


base-commit: 50406d35f5635e1cc523e61409d57e851b5f5df8
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-07-24 20:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 19:50 [PATCH 0/7] KVM: SVM: Add support for AMD LBR Extension v2 Shivansh Dhiman
2026-07-24 19:50 ` [PATCH 1/7] KVM: SVM: Add VMCB fields for LBR v2 virtualization Shivansh Dhiman
2026-07-24 20:08   ` sashiko-bot
2026-07-24 19:50 ` [PATCH 2/7] KVM: SVM: Add capability for LbrExtV2 Shivansh Dhiman
2026-07-24 19:50 ` [PATCH 3/7] KVM: SVM: Emulate guest accesses to LBR v2 MSRs Shivansh Dhiman
2026-07-24 20:13   ` sashiko-bot
2026-07-24 19:50 ` [PATCH 4/7] KVM: SVM: Enable hardware-assisted LBR v2 virtualization Shivansh Dhiman
2026-07-24 20:17   ` sashiko-bot
2026-07-24 19:50 ` [PATCH 5/7] KVM: SVM: Advertise LbrExtV2 to userspace Shivansh Dhiman
2026-07-24 20:06   ` sashiko-bot
2026-07-24 19:50 ` [PATCH 6/7] KVM: SVM: Add LBR/PMC freeze support Shivansh Dhiman
2026-07-24 20:13   ` sashiko-bot
2026-07-24 19:50 ` [PATCH 7/7] KVM: x86: Use SCATTERED_F() for PERFMON_V2 Shivansh Dhiman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox