Skip to content

KVM: x86: Provide a cap to disable APERF/MPERF read intercepts

Sean Christopherson kvm kvmarm linux-arm-kernel lkml 1 version Applied

Status from this message: Applied to kvm-x86 misc, with the thean typo fixed. Thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v5 Latest5 patches 3 repliesApplied

Changes in v5 from the cover letter

- Rebase on top of the MSR interception rework.
- Support passthrough to L2 on VMX (it was there somewhat unintentionally for SVM).
- Expand the selftest to cover the nested case.
- Sanity check that the MSRs are inaccesible in the selftest.
- Add selftests patches to expand the task=>CPU pinning APIs.
- OR-in the new disabled exits in one batch.

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/5KVM: x86: Replace growing set of *_in_guest bools with a u64arch/x86/include/asm/kvm_host.h arch/x86/kvm/svm/svm.c arch/x86/kvm/vmx/vmx.c +2 more+13 -181 reply
2/5KVM: x86: Provide a capability to disable APERF/MPERF read interceptsDocumentation/virt/kvm/api.rst arch/x86/kvm/svm/nested.c arch/x86/kvm/svm/svm.c +6 more+53 -21 reply
3/5KVM: selftests: Expand set of APIs for pinning tasks to a single CPUtools/testing/selftests/kvm/include/kvm_util.h tools/testing/selftests/kvm/lib/kvm_util.c tools/testing/selftests/kvm/lib/memstress.c+38 -100 replies
4/5KVM: selftests: Test behavior of KVM_X86_DISABLE_EXITS_APERFMPERFtools/testing/selftests/kvm/Makefile.kvm tools/testing/selftests/kvm/x86/aperfmperf_test.c+214 -00 replies
5/5KVM: selftests: Convert arch_timer tests to common helpers to pin tasktools/testing/selftests/kvm/arch_timer.c tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c+3 -270 replies

Reviews trailers per patch

2 of 5 patches have a Reviewed-by or Acked-by.

PatchXiaoyao Li
1/5R-b
2/5R-b
3/5
4/5
5/5

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/5] KVM: x86: Provide a cap to disable APERF/MPERF read intercepts

arm64 folks, y'all got pulled in because of selftests changes. I deliberately put that patch at the end of the series so that it can be discarded/ignored without interfering with the x86 stuff.

Jim's series to allow a guest to read IA32_APERF and IA32_MPERF, so that it can determine the effective frequency multiplier for the physical LPU.

Commit b51700632e0e ("KVM: X86: Provide a capability to disable cstate msr read intercepts") allowed the userspace VMM to grant a guest read access to four core C-state residency MSRs. Do the same for IA32_APERF and IA32_MPERF.

While this isn't sufficient to claim support for CPUID.6:ECX.APERFMPERF[bit 0], it may suffice in a sufficiently restricted environment (i.e. vCPUs pinned to LPUs, no TSC multiplier, and no suspend/resume).

v5:
- Rebase on top of the MSR interception rework.
- Support passthrough to L2 on VMX (it was there somewhat unintentionally for SVM).
- Expand the selftest to cover the nested case.
- Sanity check that the MSRs are inaccesible in the selftest.
- Add selftests patches to expand the task=>CPU pinning APIs.
- OR-in the new disabled exits in one batch.

v4:
- https://lore.kernel.org/all/[email protected]
- Collect all disabled_exit flags in a u64 [Sean]
- Improve documentation [Sean]
- Add pin_task_to_one_cpu() to kvm selftests library [Sean]

v3:
- https://lore.kernel.org/all/[email protected]
- Add a selftest

v2:
- https://lore.kernel.org/all/[email protected]
- Add {IA32_APERF,IA32_MPERF} to vmx_possible_passthrough_msrs[]

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

Jim Mattson (3):
KVM: x86: Replace growing set of *_in_guest bools with a u64
KVM: x86: Provide a capability to disable APERF/MPERF read intercepts
KVM: selftests: Test behavior of KVM_X86_DISABLE_EXITS_APERFMPERF

Sean Christopherson (2):
KVM: selftests: Expand set of APIs for pinning tasks to a single CPU
KVM: selftests: Convert arch_timer tests to common helpers to pin task

 Documentation/virt/kvm/api.rst                |  23 ++
 arch/x86/include/asm/kvm_host.h               |   5 +-
 arch/x86/kvm/svm/nested.c                     |   4 +-
 arch/x86/kvm/svm/svm.c                        |   7 +-
 arch/x86/kvm/vmx/nested.c                     |   6 +
 arch/x86/kvm/vmx/vmx.c                        |   6 +-
 arch/x86/kvm/x86.c                            |  15 +-
 arch/x86/kvm/x86.h                            |  18 +-
 include/uapi/linux/kvm.h                      |   1 +
 tools/include/uapi/linux/kvm.h                |   1 +
 tools/testing/selftests/kvm/Makefile.kvm      |   1 +
 tools/testing/selftests/kvm/arch_timer.c      |   7 +-
 .../kvm/arm64/arch_timer_edge_cases.c         |  23 +-
 .../testing/selftests/kvm/include/kvm_util.h  |  31 ++-
 tools/testing/selftests/kvm/lib/kvm_util.c    |  15 +-
 tools/testing/selftests/kvm/lib/memstress.c   |   2 +-
 .../selftests/kvm/x86/aperfmperf_test.c       | 213 ++++++++++++++++++
 17 files changed, 321 insertions(+), 57 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86/aperfmperf_test.c

base-commit: 7ee45fdd644b138e7a213c6936474161b28d0e1a

Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog