Skip to content

KVM: x86: RDPID/RDTSCP fixes and uret MSR cleanups

Sean Christopherson kvm lkml 1 version Applied

Status from this message: Queued, thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest15 patches 52 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/15KVM: VMX: Do not adverise RDPID if ENABLE_RDTSCP control is unsupportedarch/x86/kvm/vmx/vmx.c+4 -25 replies
2/15KVM: x86: Emulate RDPID only if RDTSCP is supportedarch/x86/kvm/cpuid.c+2 -16 replies
3/15KVM: SVM: Inject #UD on RDTSCP when it should be disabled in the guestarch/x86/kvm/svm/svm.c+13 -414 replies
4/15KVM: x86: Move RDPID emulation intercept to its own enumarch/x86/kvm/emulate.c arch/x86/kvm/kvm_emulate.h arch/x86/kvm/vmx/vmx.c+4 -22 replies
5/15KVM: VMX: Disable preemption when probing user return MSRsarch/x86/include/asm/kvm_host.h arch/x86/kvm/vmx/vmx.c arch/x86/kvm/x86.c+18 -42 replies
6/15KVM: SVM: Probe and load MSR_TSC_AUX regardless of RDTSCP support in hostarch/x86/kvm/svm/svm.c+10 -81 reply
7/15KVM: x86: Add support for RDPID without RDTSCParch/x86/kvm/svm/svm.c arch/x86/kvm/vmx/vmx.c arch/x86/kvm/x86.c+29 -71 reply
8/15KVM: VMX: Configure list of user return MSRs at module initarch/x86/kvm/vmx/vmx.c arch/x86/kvm/vmx/vmx.h+50 -214 replies
9/15KVM: VMX: Use flag to indicate "active" uret MSRs instead of sorting listarch/x86/kvm/vmx/vmx.c arch/x86/kvm/vmx/vmx.h+42 -404 replies
10/15KVM: VMX: Use common x86's uret MSR list as the one true listarch/x86/include/asm/kvm_host.h arch/x86/kvm/vmx/vmx.c arch/x86/kvm/x86.c+53 -571 reply
11/15KVM: VMX: Disable loading of TSX_CTRL MSR the more conventional wayarch/x86/kvm/vmx/vmx.c+10 -124 replies
12/15KVM: x86: Export the number of uret MSRs to vendor modulesarch/x86/include/asm/kvm_host.h arch/x86/kvm/x86.c+14 -161 reply
13/15KVM: x86: Move uret MSR slot management to common x86arch/x86/include/asm/kvm_host.h arch/x86/kvm/svm/svm.c arch/x86/kvm/vmx/vmx.c +1 more+17 -291 reply
14/15KVM: x86: Tie Intel and AMD behavior for MSR_TSC_AUX to guest CPU modelarch/x86/include/asm/kvm_host.h arch/x86/kvm/svm/svm.c arch/x86/kvm/vmx/vmx.c +1 more+41 -394 replies
15/15KVM: x86: Hide RDTSCP and RDPID if MSR_TSC_AUX probing failedarch/x86/kvm/cpuid.c+15 -01 reply

Reviews trailers per patch

All 15 patches have a Reviewed-by or Acked-by.

PatchJim MattsonReiji WatanabeMaxim Levitsky
1/15R-b R-b R-b
2/15R-b
3/15R-b R-b R-b
4/15R-b
5/15R-b R-b
6/15R-b
7/15R-b
8/15R-b
9/15R-b
10/15R-b
11/15R-b
12/15R-b
13/15R-b
14/15R-b
15/15R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 00/15] KVM: x86: RDPID/RDTSCP fixes and uret MSR cleanups

This is a continuation of a less ambitious effort to unify MSR_TSC_AUX handling across SVM and VMX. Reiji pointed out that MSR_TSC_AUX exists if RDTSCP *or* RDPID is supported, and things went downhill from there.

The first half of this series fixes a variety of RDTSCP and RDPID related bugs.

The second half of the series cleans up VMX's user return MSR framework and consolidates more of the uret logic into common x86.

The last two patches leverage the uret MSR cleanups to move MSR_TSC_AUX handling to common x86 and add sanity checks to guard against misreporting of RDPID and/or RDTSCP support.

This will conflict with my vCPU RESET/INIT cleanup series. Feel free to punt the conflicts to me.

Other "fun" things to tackle:

- The kernel proper also botches RDPID vs. RDTSCP, as MSR_TSC_AUX is configured if RDTSCP is supported, but is consumed if RDPID is supported. I'll send this fix separately.

- Commit 844d69c26d83 ("KVM: SVM: Delay restoration of host MSR_TSC_AUX until return to userspace") unwittingly fixed a bug where KVM would write MSR_TSC_AUX with the guest's value when svm->guest_state_loaded is false, which could lead to running the host with the guest's value. The bug only exists in 5.12 (maybe 5.11 too?), so crafting a fix for stable won't be too awful.

Sean Christopherson (15):
KVM: VMX: Do not adverise RDPID if ENABLE_RDTSCP control is
unsupported
KVM: x86: Emulate RDPID only if RDTSCP is supported
KVM: SVM: Inject #UD on RDTSCP when it should be disabled in the guest
KVM: x86: Move RDPID emulation intercept to its own enum
KVM: VMX: Disable preemption when probing user return MSRs
KVM: SVM: Probe and load MSR_TSC_AUX regardless of RDTSCP support in
host
KVM: x86: Add support for RDPID without RDTSCP
KVM: VMX: Configure list of user return MSRs at module init
KVM: VMX: Use flag to indicate "active" uret MSRs instead of sorting
list
KVM: VMX: Use common x86's uret MSR list as the one true list
KVM: VMX: Disable loading of TSX_CTRL MSR the more conventional way
KVM: x86: Export the number of uret MSRs to vendor modules
KVM: x86: Move uret MSR slot management to common x86
KVM: x86: Tie Intel and AMD behavior for MSR_TSC_AUX to guest CPU
model
KVM: x86: Hide RDTSCP and RDPID if MSR_TSC_AUX probing failed

 arch/x86/include/asm/kvm_host.h |   9 +-
 arch/x86/kvm/cpuid.c            |  18 ++-
 arch/x86/kvm/emulate.c          |   2 +-
 arch/x86/kvm/kvm_emulate.h      |   1 +
 arch/x86/kvm/svm/svm.c          |  50 +++-----
 arch/x86/kvm/vmx/vmx.c          | 217 ++++++++++++++++----------------
 arch/x86/kvm/vmx/vmx.h          |  12 +-
 arch/x86/kvm/x86.c              | 101 ++++++++++++---
 8 files changed, 245 insertions(+), 165 deletions(-)
Signature · 1 line
2.31.1.527.g47e6f16901-goog