Skip to content

KVM: x86: Intel LBR related perf cleanups

Sean Christopherson kvm linux-perf-users lkml 3 versions – Applied

Status from this message: Queued, with patches 2-4 destined to kvm/master.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest8 patches 2 repliesApplied
  2. v45 patches 3 repliesSuperseded
  3. v33 patches 1 replySuperseded

Changes in v5 from the cover letter

- Drop perf patches that removed stubs. The stubs are sadly necessary when CPU_SUP_INTEL=n && KVM_INTEL={m,y}, which is possible due to KVM_INTEL effectively depending on INTEL || CENTAUR || ZHAOXIN. [hint provided by kernel test robot].
- Add a patch to ignore guest CPUID on host userspace MSR writes.
- Add supported PERF_CAPABILITIES to kvm_caps to simplify code for all parties.

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/8perf/x86/core: Zero @lbr instead of returning -1 in x86_perf_get_lbr() stubarch/x86/events/intel/lbr.c arch/x86/include/asm/perf_event.h+4 -80 replies
2/8KVM: VMX: Advertise PMU LBRs if and only if perf supports LBRsarch/x86/kvm/vmx/capabilities.h+4 -10 replies
3/8KVM: VMX: Fold vmx_supported_debugctl() into vcpu_supported_debugctl()arch/x86/kvm/vmx/capabilities.h arch/x86/kvm/vmx/vmx.c+7 -200 replies
4/8KVM: VMX: Ignore guest CPUID for host userspace writes to DEBUGCTLarch/x86/kvm/vmx/vmx.c+6 -40 replies
5/8KVM: x86: Track supported PERF_CAPABILITIES in kvm_capsarch/x86/kvm/svm/svm.c arch/x86/kvm/vmx/capabilities.h arch/x86/kvm/vmx/pmu_intel.c +2 more+34 -301 reply
6/8KVM: x86: Init vcpu->arch.perf_capabilities in common x86 codearch/x86/kvm/vmx/pmu_intel.c arch/x86/kvm/x86.c+2 -10 replies
7/8KVM: x86: Handle PERF_CAPABILITIES in common x86's kvm_get_msr_feature()arch/x86/kvm/svm/svm.c arch/x86/kvm/vmx/vmx.c arch/x86/kvm/x86.c+3 -60 replies
8/8KVM: x86: Directly query supported PERF_CAPABILITIES for WRMSR checksarch/x86/kvm/x86.c+2 -70 replies

Reviews trailers per patch

1 of 8 patches has a Reviewed-by or Acked-by.

PatchLike Xu
1/8
2/8
3/8
4/8
5/8A-b
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/8] KVM: x86: Intel LBR related perf cleanups

PeterZ, I dropped your ACK from v4 because the perf patches were completely broken.

Fix a bug where KVM incorrectly advertises PMU_CAP_LBR_FMT to userspace if perf has disabled LBRs, e.g. because probing one or more LBR MSRs during setup hit a #GP.

The non-KVM patch cleans up a KVM-specific perf API to fix a benign bug where KVM ignores the error return from the API.

The remaining patches clean up KVM's PERF_CAPABILITIES mess, which makes everything far more complex than it needs to be by

v5:
- Drop perf patches that removed stubs. The stubs are sadly necessary when CPU_SUP_INTEL=n && KVM_INTEL={m,y}, which is possible due to KVM_INTEL effectively depending on INTEL || CENTAUR || ZHAOXIN. [hint provided by kernel test robot].
- Add a patch to ignore guest CPUID on host userspace MSR writes.
- Add supported PERF_CAPABILITIES to kvm_caps to simplify code for all parties.

v4
- https://lore.kernel.org/all/[email protected]:
- Make vmx_get_perf_capabilities() non-inline to avoid references to x86_perf_get_lbr() when CPU_SUP_INTEL=n. [kernel test robot]

v3:
- https://lore.kernel.org/all/[email protected]
- Drop patches for bug #1 (already merged).
- Drop misguided "clean up the capability check" patch. [Like]

v2:
- https://lore.kernel.org/all/[email protected]
- Add patches to fix bug #2. [Like]
- Add a patch to clean up the capability check.
- Tweak the changelog for the PMU refresh bug fix to call out that KVM should disallow changing feature MSRs after KVM_RUN. [Like]

v1: https://lore.kernel.org/all/[email protected]

Sean Christopherson (8):
perf/x86/core: Zero @lbr instead of returning -1 in x86_perf_get_lbr()
stub
KVM: VMX: Advertise PMU LBRs if and only if perf supports LBRs
KVM: VMX: Fold vmx_supported_debugctl() into vcpu_supported_debugctl()
KVM: VMX: Ignore guest CPUID for host userspace writes to DEBUGCTL
KVM: x86: Track supported PERF_CAPABILITIES in kvm_caps
KVM: x86: Init vcpu->arch.perf_capabilities in common x86 code
KVM: x86: Handle PERF_CAPABILITIES in common x86's
kvm_get_msr_feature()
KVM: x86: Directly query supported PERF_CAPABILITIES for WRMSR checks

 arch/x86/events/intel/lbr.c       |  6 +---
 arch/x86/include/asm/perf_event.h |  6 ++--
 arch/x86/kvm/svm/svm.c            |  3 +-
 arch/x86/kvm/vmx/capabilities.h   | 37 ----------------------
 arch/x86/kvm/vmx/pmu_intel.c      |  1 -
 arch/x86/kvm/vmx/vmx.c            | 51 +++++++++++++++++++++++--------
 arch/x86/kvm/x86.c                | 14 ++++-----
 arch/x86/kvm/x86.h                |  1 +
 8 files changed, 52 insertions(+), 67 deletions(-)

base-commit: e18d6152ff0f41b7f01f9817372022df04e0d354

Signature · 1 line
2.38.0.rc1.362.ged0d419d3c-goog