Skip to content

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

Vitaly Kuznetsov kvm lkml 2 versions – Applied

Status from this message: Queued, thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest30 patches 1 replyApplied
  2. v130 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- Rebase to kvm/next.

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/30asm-generic/hyperv: add HV_STATUS_ACCESS_DENIED definitioninclude/asm-generic/hyperv-tlfs.h+1 -00 replies
2/30KVM: x86: hyper-v: Introduce KVM_CAP_HYPERV_ENFORCE_CPUIDDocumentation/virt/kvm/api.rst arch/x86/include/asm/kvm_host.h arch/x86/kvm/hyperv.c +3 more+39 -00 replies
3/30KVM: x86: hyper-v: Cache guest CPUID leaves determining features availabilityarch/x86/include/asm/kvm_host.h arch/x86/kvm/hyperv.c+47 -100 replies
4/30KVM: x86: hyper-v: Prepare to check access to Hyper-V MSRsarch/x86/kvm/hyperv.c+18 -00 replies
5/30KVM: x86: hyper-v: Honor HV_MSR_HYPERCALL_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+12 -00 replies
6/30KVM: x86: hyper-v: Honor HV_MSR_VP_RUNTIME_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+3 -00 replies
7/30KVM: x86: hyper-v: Honor HV_MSR_TIME_REF_COUNT_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+3 -00 replies
8/30KVM: x86: hyper-v: Honor HV_MSR_VP_INDEX_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+3 -00 replies
9/30KVM: x86: hyper-v: Honor HV_MSR_RESET_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+3 -00 replies
10/30KVM: x86: hyper-v: Honor HV_MSR_REFERENCE_TSC_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+3 -00 replies
11/30KVM: x86: hyper-v: Honor HV_MSR_SYNIC_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+8 -00 replies
12/30KVM: x86: hyper-v: Honor HV_MSR_SYNTIMER_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+10 -00 replies
13/30KVM: x86: hyper-v: Honor HV_MSR_APIC_ACCESS_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+7 -00 replies
14/30KVM: x86: hyper-v: Honor HV_ACCESS_FREQUENCY_MSRS privilege bitarch/x86/kvm/hyperv.c+4 -00 replies
15/30KVM: x86: hyper-v: Honor HV_ACCESS_REENLIGHTENMENT privilege bitarch/x86/kvm/hyperv.c+5 -00 replies
16/30KVM: x86: hyper-v: Honor HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+4 -00 replies
17/30KVM: x86: hyper-v: Honor HV_FEATURE_DEBUG_MSRS_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+4 -00 replies
18/30KVM: x86: hyper-v: Inverse the default in hv_check_msr_access()arch/x86/kvm/hyperv.c+1 -10 replies
19/30KVM: x86: hyper-v: Honor HV_STIMER_DIRECT_MODE_AVAILABLE privilege bitarch/x86/kvm/hyperv.c+6 -00 replies
20/30KVM: x86: hyper-v: Prepare to check access to Hyper-V hypercallsarch/x86/kvm/hyperv.c+11 -00 replies
21/30KVM: x86: hyper-v: Check access to HVCALL_NOTIFY_LONG_SPIN_WAIT hypercallarch/x86/kvm/hyperv.c+11 -00 replies
22/30KVM: x86: hyper-v: Honor HV_POST_MESSAGES privilege bitarch/x86/kvm/hyperv.c+2 -00 replies
23/30KVM: x86: hyper-v: Honor HV_SIGNAL_EVENTS privilege bitarch/x86/kvm/hyperv.c+2 -00 replies
24/30KVM: x86: hyper-v: Honor HV_DEBUGGING privilege bitarch/x86/kvm/hyperv.c+9 -00 replies
25/30KVM: x86: hyper-v: Honor HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED bitarch/x86/kvm/hyperv.c+6 -00 replies
26/30KVM: x86: hyper-v: Honor HV_X64_CLUSTER_IPI_RECOMMENDED bitarch/x86/kvm/hyperv.c+4 -00 replies
27/30KVM: x86: hyper-v: Honor HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED bitarch/x86/kvm/hyperv.c+8 -00 replies
28/30KVM: selftests: move Hyper-V MSR definitions to hyperv.htools/testing/selftests/kvm/include/x86_64/hyperv.h tools/testing/selftests/kvm/x86_64/hyperv_clock.c+20 -70 replies
29/30KVM: selftests: Move evmcs.h to x86_64/tools/testing/selftests/kvm/include/x86_64/evmcs.h+1 -10 replies
30/30KVM: selftests: Introduce hyperv_features testtools/testing/selftests/kvm/.gitignore tools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/include/x86_64/hyperv.h +1 more+817 -00 replies

Reviews trailers per patch

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

PatchWei Liu
1/30A-b
2/30
3/30
4/30
5/30
6/30
7/30
8/30
9/30
10/30
11/30
12/30
13/30
14/30
15/30
16/30
17/30
18/30
19/30
20/30
21/30
22/30
23/30
24/30
25/30
26/30
27/30
28/30
29/30
30/30

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

Read the v2 thread

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

Changes since v1:
- Rebase to kvm/next.

Original description:

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.

Vitaly Kuznetsov (30):
asm-generic/hyperv: add HV_STATUS_ACCESS_DENIED definition
KVM: x86: hyper-v: Introduce KVM_CAP_HYPERV_ENFORCE_CPUID
KVM: x86: hyper-v: Cache guest CPUID leaves determining features
availability
KVM: x86: hyper-v: Prepare to check access to Hyper-V MSRs
KVM: x86: hyper-v: Honor HV_MSR_HYPERCALL_AVAILABLE privilege bit
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_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_DEBUG_MSRS_AVAILABLE privilege bit
KVM: x86: hyper-v: Inverse the default in hv_check_msr_access()
KVM: x86: hyper-v: Honor HV_STIMER_DIRECT_MODE_AVAILABLE privilege bit
KVM: x86: hyper-v: Prepare to check access to Hyper-V hypercalls
KVM: x86: hyper-v: Check access to HVCALL_NOTIFY_LONG_SPIN_WAIT
hypercall
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: Honor HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED bit
KVM: selftests: move Hyper-V MSR definitions to hyperv.h
KVM: selftests: Move evmcs.h to x86_64/
KVM: selftests: Introduce hyperv_features test

 Documentation/virt/kvm/api.rst                |  11 +
 arch/x86/include/asm/kvm_host.h               |   9 +
 arch/x86/kvm/hyperv.c                         | 216 +++++-
 arch/x86/kvm/hyperv.h                         |   1 +
 arch/x86/kvm/x86.c                            |   4 +
 include/asm-generic/hyperv-tlfs.h             |   1 +
 include/uapi/linux/kvm.h                      |   1 +
 tools/testing/selftests/kvm/.gitignore        |   1 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../kvm/include/{ => x86_64}/evmcs.h          |   2 +-
 .../selftests/kvm/include/x86_64/hyperv.h     | 185 +++++
 .../selftests/kvm/x86_64/hyperv_clock.c       |   8 +-
 .../selftests/kvm/x86_64/hyperv_features.c    | 649 ++++++++++++++++++
 13 files changed, 1071 insertions(+), 18 deletions(-)
 rename tools/testing/selftests/kvm/include/{ => x86_64}/evmcs.h (99%)
 create mode 100644 tools/testing/selftests/kvm/include/x86_64/hyperv.h
 create mode 100644 tools/testing/selftests/kvm/x86_64/hyperv_features.c
Signature · 1 line
2.31.1