Skip to content

RFC KVM: x86: hyper-v: Fine-grained access check to Hyper-V hypercalls and MSRs

Vitaly Kuznetsov kvm linux-hyperv lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest22 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/22asm-generic/hyperv: add HV_STATUS_ACCESS_DENIED definitioninclude/asm-generic/hyperv-tlfs.h+1 -03 replies
2/22KVM: x86: hyper-v: Cache guest CPUID leaves determining features availabilityarch/x86/include/asm/kvm_host.h arch/x86/kvm/hyperv.c+48 -100 replies
3/22KVM: x86: hyper-v: Honor HV_MSR_VP_RUNTIME_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+4 -00 replies
4/22KVM: x86: hyper-v: Honor HV_MSR_TIME_REF_COUNT_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+5 -00 replies
5/22KVM: x86: hyper-v: Honor HV_MSR_HYPERCALL_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+17 -00 replies
6/22KVM: x86: hyper-v: Honor HV_MSR_VP_INDEX_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+4 -00 replies
7/22KVM: x86: hyper-v: Honor HV_MSR_RESET_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+8 -00 replies
8/22KVM: x86: hyper-v: Honor HV_MSR_REFERENCE_TSC_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+8 -00 replies
9/22KVM: x86: hyper-v: Honor HV_MSR_SYNIC_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+7 -20 replies
10/22KVM: x86: hyper-v: Honor HV_MSR_SYNTIMER_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+28 -60 replies
11/22KVM: x86: hyper-v: Honor HV_MSR_APIC_ACCESS_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+32 -00 replies
12/22KVM: x86: hyper-v: Honor HV_ACCESS_FREQUENCY_MSRS privilege bitarch/x86/kvm/hyperv.c+8 -00 replies
13/22KVM: x86: hyper-v: Honor HV_ACCESS_REENLIGHTENMENT privilege bitarch/x86/kvm/hyperv.c+22 -10 replies
14/22KVM: x86: hyper-v: Honor HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+16 -00 replies
15/22KVM: x86: hyper-v: Honor HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+6 -20 replies
16/22KVM: x86: hyper-v: Honor HV_STIMER_DIRECT_MODE_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+5 -00 replies
17/22KVM: x86: hyper-v: Honor HV_POST_MESSAGES privilege bitarch/x86/kvm/hyperv.c+12 -20 replies
18/22KVM: x86: hyper-v: Honor HV_SIGNAL_EVENTS privilege bitarch/x86/kvm/hyperv.c+6 -00 replies
19/22KVM: x86: hyper-v: Honor HV_DEBUGGING privilege bitarch/x86/kvm/hyperv.c+6 -00 replies
20/22KVM: x86: hyper-v: Honor HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED bitarch/x86/kvm/hyperv.c+28 -00 replies
21/22KVM: x86: hyper-v: Honor HV_X64_CLUSTER_IPI_RECOMMENDED bitarch/x86/kvm/hyperv.c+14 -00 replies
22/22KVM: x86: hyper-v: Check access to HVCALL_NOTIFY_LONG_SPIN_WAIT hypercallarch/x86/kvm/hyperv.c+6 -00 replies

Reviews trailers per patch

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

PatchWei Liu
1/22A-b
2/22
3/22
4/22
5/22
6/22
7/22
8/22
9/22
10/22
11/22
12/22
13/22
14/22
15/22
16/22
17/22
18/22
19/22
20/22
21/22
22/22

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

Read the v1 thread

Cover letter [PATCH RFC 00/22] KVM: x86: hyper-v: Fine-grained access check to Hyper-V hypercalls and MSRs

Currently, all implemented Hyper-V features (MSRs and hypercalls) are available unconditionally to all Hyper-V enabled guests. This is not ideal as KVM userspace may decide to provide only a subset of the currently implemented features to emulate an older Hyper-V version, to reduce attack surface,... Implement checks against guest visible CPUIDs for all currently implemented MSRs and hypercalls.

RFC part:
- KVM has KVM_CAP_ENFORCE_PV_FEATURE_CPUID for KVM PV features. Should we use it for Hyper-V as well or should we rather add a Hyper-V specific CAP (or neither)?

TODO:
- Write a selftest
- Check with various Windows/Hyper-V versions that CPUID feature bits are actually respected.

Vitaly Kuznetsov (22):
asm-generic/hyperv: add HV_STATUS_ACCESS_DENIED definition
KVM: x86: hyper-v: Cache guest CPUID leaves determining features
availability
KVM: x86: hyper-v: Honor HV_MSR_VP_RUNTIME_AVAILABLE privilege bit
KVM: x86: hyper-v: Honor HV_MSR_TIME_REF_COUNT_AVAILABLE privilege bit
KVM: x86: hyper-v: Honor HV_MSR_HYPERCALL_AVAILABLE privilege bit
KVM: x86: hyper-v: Honor HV_MSR_VP_INDEX_AVAILABLE privilege bit
KVM: x86: hyper-v: Honor HV_MSR_RESET_AVAILABLE privilege bit
KVM: x86: hyper-v: Honor HV_MSR_REFERENCE_TSC_AVAILABLE privilege bit
KVM: x86: hyper-v: Honor HV_MSR_SYNIC_AVAILABLE privilege bit
KVM: x86: hyper-v: Honor HV_MSR_SYNTIMER_AVAILABLE privilege bit
KVM: x86: hyper-v: Honor HV_MSR_APIC_ACCESS_AVAILABLE privilege bit
KVM: x86: hyper-v: Honor HV_ACCESS_FREQUENCY_MSRS privilege bit
KVM: x86: hyper-v: Honor HV_ACCESS_REENLIGHTENMENT privilege bit
KVM: x86: hyper-v: Honor HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE
privilege bit
KVM: x86: hyper-v: Honor HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE
privilege bit
KVM: x86: hyper-v: Honor HV_STIMER_DIRECT_MODE_AVAILABLE privilege bit
KVM: x86: hyper-v: Honor HV_POST_MESSAGES privilege bit
KVM: x86: hyper-v: Honor HV_SIGNAL_EVENTS privilege bit
KVM: x86: hyper-v: Honor HV_DEBUGGING privilege bit
KVM: x86: hyper-v: Honor HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED bit
KVM: x86: hyper-v: Honor HV_X64_CLUSTER_IPI_RECOMMENDED bit
KVM: x86: hyper-v: Check access to HVCALL_NOTIFY_LONG_SPIN_WAIT
hypercall

 arch/x86/include/asm/kvm_host.h   |   8 +
 arch/x86/kvm/hyperv.c             | 305 +++++++++++++++++++++++++++---
 include/asm-generic/hyperv-tlfs.h |   1 +
 3 files changed, 291 insertions(+), 23 deletions(-)
Signature · 1 line
2.30.2