mbox series

[v4,00/13] Add Hyper-v extended hypercall support in KVM

Message ID 20221212183720.4062037-1-vipinsh@google.com (mailing list archive)
Headers show
Series Add Hyper-v extended hypercall support in KVM | expand

Message

Vipin Sharma Dec. 12, 2022, 6:37 p.m. UTC
Hi,

There are two patch series combined in this one because I have rebased
my patch series (patches 8 to 13) on top of Vitaly's "Hyper-V invariant TSC control
feature" (patches 1 to 7).
https://lore.kernel.org/kvm/87o7szouyr.fsf@ovpn-194-185.brq.redhat.com/

Vitaly's series had some small merge conflicts on the KVM queue branch I
have fixed them in this series, no code changes.

My patches (8 to 13) add Hyper-V extended hypercall support and selftests.

v4:
- Changed vm_vaddr_t to vm_paddr_t in hyperv_extended_hypercalls.
- Changed ASSERT_EXIT_REASON to TEST_ASSERT_KVM_EXIT_REASON

v3: https://lore.kernel.org/lkml/20221205191430.2455108-1-vipinsh@google.com/
- Rebased on top of Vitaly's "Hyper-V invariant TSC control feature"
  series.
- Removed enabling KVM_CAP_HYPERV_ENFORCE_CPUID in
  hyperv_extended_hypercalls test.


v2: https://lore.kernel.org/lkml/20221121234026.3037083-1-vipinsh@google.com/
- Intorduced ASSERT_EXIT_REASON macro and replaced all occurences of
  TEST_ASSERT for vcpu exit reason.
- Skip hyperv_extended_hypercalls test if extended hypercalls are not
  supported by the kernel.
- Rebased with latest KVM queue.
- Addressed all of the comments in patch 6 of v1.

v1: https://lore.kernel.org/lkml/20221105045704.2315186-1-vipinsh@google.com/

RFC: https://lore.kernel.org/lkml/20221021185916.1494314-1-vipinsh@google.com/

Vipin Sharma (6):
  KVM: x86: hyper-v: Use common code for hypercall userspace exit
  KVM: x86: hyper-v: Add extended hypercall support in Hyper-v
  KVM: selftests: Test Hyper-V extended hypercall enablement
  KVM: selftests: Replace hardcoded Linux OS id with HYPERV_LINUX_OS_ID
  KVM: selftests: Make vCPU exit reason test assertion common.
  KVM: selftests: Test Hyper-V extended hypercall exit to userspace

Vitaly Kuznetsov (7):
  x86/hyperv: Add HV_EXPOSE_INVARIANT_TSC define
  KVM: x86: Add a KVM-only leaf for CPUID_8000_0007_EDX
  KVM: x86: Hyper-V invariant TSC control
  KVM: selftests: Rename 'msr->available' to 'msr->fault_exepected' in
    hyperv_features test
  KVM: selftests: Convert hyperv_features test to using
    KVM_X86_CPU_FEATURE()
  KVM: selftests: Test that values written to Hyper-V MSRs are preserved
  KVM: selftests: Test Hyper-V invariant TSC control

 arch/x86/include/asm/hyperv-tlfs.h            |   3 +
 arch/x86/include/asm/kvm_host.h               |   1 +
 arch/x86/kernel/cpu/mshyperv.c                |   2 +-
 arch/x86/kvm/cpuid.c                          |  11 +-
 arch/x86/kvm/hyperv.c                         |  74 +++-
 arch/x86/kvm/hyperv.h                         |  27 ++
 arch/x86/kvm/reverse_cpuid.h                  |   7 +
 arch/x86/kvm/x86.c                            |   4 +-
 tools/testing/selftests/kvm/.gitignore        |   1 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../testing/selftests/kvm/aarch64/psci_test.c |   4 +-
 .../testing/selftests/kvm/include/test_util.h |  10 +
 .../selftests/kvm/include/x86_64/hyperv.h     | 149 +++++---
 .../selftests/kvm/include/x86_64/processor.h  |   1 +
 .../kvm/lib/s390x/diag318_test_handler.c      |   3 +-
 .../selftests/kvm/s390x/sync_regs_test.c      |  15 +-
 .../selftests/kvm/set_memory_region_test.c    |   6 +-
 tools/testing/selftests/kvm/x86_64/amx_test.c |   8 +-
 .../kvm/x86_64/cr4_cpuid_sync_test.c          |   8 +-
 .../testing/selftests/kvm/x86_64/debug_regs.c |   2 +-
 .../selftests/kvm/x86_64/flds_emulation.h     |   5 +-
 .../selftests/kvm/x86_64/hyperv_clock.c       |   9 +-
 .../selftests/kvm/x86_64/hyperv_evmcs.c       |   8 +-
 .../kvm/x86_64/hyperv_extended_hypercalls.c   |  93 +++++
 .../selftests/kvm/x86_64/hyperv_features.c    | 353 +++++++++++-------
 .../testing/selftests/kvm/x86_64/hyperv_ipi.c |   6 +-
 .../selftests/kvm/x86_64/hyperv_svm_test.c    |   7 +-
 .../selftests/kvm/x86_64/hyperv_tlb_flush.c   |  14 +-
 .../selftests/kvm/x86_64/kvm_clock_test.c     |   5 +-
 .../selftests/kvm/x86_64/kvm_pv_test.c        |   5 +-
 .../selftests/kvm/x86_64/monitor_mwait_test.c |   9 +-
 .../kvm/x86_64/nested_exceptions_test.c       |   5 +-
 .../selftests/kvm/x86_64/platform_info_test.c |  14 +-
 .../kvm/x86_64/pmu_event_filter_test.c        |   6 +-
 tools/testing/selftests/kvm/x86_64/smm_test.c |   9 +-
 .../testing/selftests/kvm/x86_64/state_test.c |   8 +-
 .../selftests/kvm/x86_64/svm_int_ctl_test.c   |   8 +-
 .../kvm/x86_64/svm_nested_shutdown_test.c     |   7 +-
 .../kvm/x86_64/svm_nested_soft_inject_test.c  |   6 +-
 .../selftests/kvm/x86_64/svm_vmcall_test.c    |   6 +-
 .../selftests/kvm/x86_64/sync_regs_test.c     |  25 +-
 .../kvm/x86_64/triple_fault_event_test.c      |   9 +-
 .../selftests/kvm/x86_64/tsc_scaling_sync.c   |   6 +-
 .../kvm/x86_64/ucna_injection_test.c          |  22 +-
 .../selftests/kvm/x86_64/userspace_io_test.c  |   6 +-
 .../kvm/x86_64/userspace_msr_exit_test.c      |  22 +-
 .../kvm/x86_64/vmx_apic_access_test.c         |  11 +-
 .../kvm/x86_64/vmx_close_while_nested_test.c  |   5 +-
 .../selftests/kvm/x86_64/vmx_dirty_log_test.c |   7 +-
 .../vmx_exception_with_invalid_guest_state.c  |   4 +-
 .../x86_64/vmx_invalid_nested_guest_state.c   |   4 +-
 .../kvm/x86_64/vmx_nested_tsc_scaling_test.c  |   6 +-
 .../kvm/x86_64/vmx_preemption_timer_test.c    |   8 +-
 .../kvm/x86_64/vmx_tsc_adjust_test.c          |   6 +-
 .../selftests/kvm/x86_64/xapic_ipi_test.c     |   6 +-
 .../selftests/kvm/x86_64/xen_shinfo_test.c    |   7 +-
 .../selftests/kvm/x86_64/xen_vmcall_test.c    |   5 +-
 57 files changed, 586 insertions(+), 493 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/hyperv_extended_hypercalls.c

Comments

Vipin Sharma Jan. 4, 2023, 12:33 a.m. UTC | #1
On Mon, Dec 12, 2022 at 10:37 AM Vipin Sharma <vipinsh@google.com> wrote:
>
> Hi,
>
> There are two patch series combined in this one because I have rebased
> my patch series (patches 8 to 13) on top of Vitaly's "Hyper-V invariant TSC control
> feature" (patches 1 to 7).
> https://lore.kernel.org/kvm/87o7szouyr.fsf@ovpn-194-185.brq.redhat.com/
>
> Vitaly's series had some small merge conflicts on the KVM queue branch I
> have fixed them in this series, no code changes.
>
> My patches (8 to 13) add Hyper-V extended hypercall support and selftests.
>
> v4:
> - Changed vm_vaddr_t to vm_paddr_t in hyperv_extended_hypercalls.
> - Changed ASSERT_EXIT_REASON to TEST_ASSERT_KVM_EXIT_REASON
>
> v3: https://lore.kernel.org/lkml/20221205191430.2455108-1-vipinsh@google.com/
> - Rebased on top of Vitaly's "Hyper-V invariant TSC control feature"
>   series.
> - Removed enabling KVM_CAP_HYPERV_ENFORCE_CPUID in
>   hyperv_extended_hypercalls test.
>
>
> v2: https://lore.kernel.org/lkml/20221121234026.3037083-1-vipinsh@google.com/
> - Intorduced ASSERT_EXIT_REASON macro and replaced all occurences of
>   TEST_ASSERT for vcpu exit reason.
> - Skip hyperv_extended_hypercalls test if extended hypercalls are not
>   supported by the kernel.
> - Rebased with latest KVM queue.
> - Addressed all of the comments in patch 6 of v1.
>
> v1: https://lore.kernel.org/lkml/20221105045704.2315186-1-vipinsh@google.com/
>
> RFC: https://lore.kernel.org/lkml/20221021185916.1494314-1-vipinsh@google.com/
>
> Vipin Sharma (6):
>   KVM: x86: hyper-v: Use common code for hypercall userspace exit
>   KVM: x86: hyper-v: Add extended hypercall support in Hyper-v
>   KVM: selftests: Test Hyper-V extended hypercall enablement
>   KVM: selftests: Replace hardcoded Linux OS id with HYPERV_LINUX_OS_ID
>   KVM: selftests: Make vCPU exit reason test assertion common.
>   KVM: selftests: Test Hyper-V extended hypercall exit to userspace
>
> Vitaly Kuznetsov (7):
>   x86/hyperv: Add HV_EXPOSE_INVARIANT_TSC define
>   KVM: x86: Add a KVM-only leaf for CPUID_8000_0007_EDX
>   KVM: x86: Hyper-V invariant TSC control
>   KVM: selftests: Rename 'msr->available' to 'msr->fault_exepected' in
>     hyperv_features test
>   KVM: selftests: Convert hyperv_features test to using
>     KVM_X86_CPU_FEATURE()
>   KVM: selftests: Test that values written to Hyper-V MSRs are preserved
>   KVM: selftests: Test Hyper-V invariant TSC control
>
>  arch/x86/include/asm/hyperv-tlfs.h            |   3 +
>  arch/x86/include/asm/kvm_host.h               |   1 +
>  arch/x86/kernel/cpu/mshyperv.c                |   2 +-
>  arch/x86/kvm/cpuid.c                          |  11 +-
>  arch/x86/kvm/hyperv.c                         |  74 +++-
>  arch/x86/kvm/hyperv.h                         |  27 ++
>  arch/x86/kvm/reverse_cpuid.h                  |   7 +
>  arch/x86/kvm/x86.c                            |   4 +-
>  tools/testing/selftests/kvm/.gitignore        |   1 +
>  tools/testing/selftests/kvm/Makefile          |   1 +
>  .../testing/selftests/kvm/aarch64/psci_test.c |   4 +-
>  .../testing/selftests/kvm/include/test_util.h |  10 +
>  .../selftests/kvm/include/x86_64/hyperv.h     | 149 +++++---
>  .../selftests/kvm/include/x86_64/processor.h  |   1 +
>  .../kvm/lib/s390x/diag318_test_handler.c      |   3 +-
>  .../selftests/kvm/s390x/sync_regs_test.c      |  15 +-
>  .../selftests/kvm/set_memory_region_test.c    |   6 +-
>  tools/testing/selftests/kvm/x86_64/amx_test.c |   8 +-
>  .../kvm/x86_64/cr4_cpuid_sync_test.c          |   8 +-
>  .../testing/selftests/kvm/x86_64/debug_regs.c |   2 +-
>  .../selftests/kvm/x86_64/flds_emulation.h     |   5 +-
>  .../selftests/kvm/x86_64/hyperv_clock.c       |   9 +-
>  .../selftests/kvm/x86_64/hyperv_evmcs.c       |   8 +-
>  .../kvm/x86_64/hyperv_extended_hypercalls.c   |  93 +++++
>  .../selftests/kvm/x86_64/hyperv_features.c    | 353 +++++++++++-------
>  .../testing/selftests/kvm/x86_64/hyperv_ipi.c |   6 +-
>  .../selftests/kvm/x86_64/hyperv_svm_test.c    |   7 +-
>  .../selftests/kvm/x86_64/hyperv_tlb_flush.c   |  14 +-
>  .../selftests/kvm/x86_64/kvm_clock_test.c     |   5 +-
>  .../selftests/kvm/x86_64/kvm_pv_test.c        |   5 +-
>  .../selftests/kvm/x86_64/monitor_mwait_test.c |   9 +-
>  .../kvm/x86_64/nested_exceptions_test.c       |   5 +-
>  .../selftests/kvm/x86_64/platform_info_test.c |  14 +-
>  .../kvm/x86_64/pmu_event_filter_test.c        |   6 +-
>  tools/testing/selftests/kvm/x86_64/smm_test.c |   9 +-
>  .../testing/selftests/kvm/x86_64/state_test.c |   8 +-
>  .../selftests/kvm/x86_64/svm_int_ctl_test.c   |   8 +-
>  .../kvm/x86_64/svm_nested_shutdown_test.c     |   7 +-
>  .../kvm/x86_64/svm_nested_soft_inject_test.c  |   6 +-
>  .../selftests/kvm/x86_64/svm_vmcall_test.c    |   6 +-
>  .../selftests/kvm/x86_64/sync_regs_test.c     |  25 +-
>  .../kvm/x86_64/triple_fault_event_test.c      |   9 +-
>  .../selftests/kvm/x86_64/tsc_scaling_sync.c   |   6 +-
>  .../kvm/x86_64/ucna_injection_test.c          |  22 +-
>  .../selftests/kvm/x86_64/userspace_io_test.c  |   6 +-
>  .../kvm/x86_64/userspace_msr_exit_test.c      |  22 +-
>  .../kvm/x86_64/vmx_apic_access_test.c         |  11 +-
>  .../kvm/x86_64/vmx_close_while_nested_test.c  |   5 +-
>  .../selftests/kvm/x86_64/vmx_dirty_log_test.c |   7 +-
>  .../vmx_exception_with_invalid_guest_state.c  |   4 +-
>  .../x86_64/vmx_invalid_nested_guest_state.c   |   4 +-
>  .../kvm/x86_64/vmx_nested_tsc_scaling_test.c  |   6 +-
>  .../kvm/x86_64/vmx_preemption_timer_test.c    |   8 +-
>  .../kvm/x86_64/vmx_tsc_adjust_test.c          |   6 +-
>  .../selftests/kvm/x86_64/xapic_ipi_test.c     |   6 +-
>  .../selftests/kvm/x86_64/xen_shinfo_test.c    |   7 +-
>  .../selftests/kvm/x86_64/xen_vmcall_test.c    |   5 +-
>  57 files changed, 586 insertions(+), 493 deletions(-)
>  create mode 100644 tools/testing/selftests/kvm/x86_64/hyperv_extended_hypercalls.c
>
> --
> 2.39.0.rc1.256.g54fd8350bd-goog
>

Hi Paolo, Sean

Is this one on your todo for 6.3?

Thanks
Vipin
Sean Christopherson Feb. 1, 2023, 10:39 p.m. UTC | #2
On Mon, 12 Dec 2022 10:37:07 -0800, Vipin Sharma wrote:
> There are two patch series combined in this one because I have rebased
> my patch series (patches 8 to 13) on top of Vitaly's "Hyper-V invariant TSC control
> feature" (patches 1 to 7).
> https://lore.kernel.org/kvm/87o7szouyr.fsf@ovpn-194-185.brq.redhat.com/
> 
> Vitaly's series had some small merge conflicts on the KVM queue branch I
> have fixed them in this series, no code changes.
> 
> [...]

Applied 8-11 and 13 to kvm-x86 misc.  1-7 were already merged, and I don't
want to carry the sweeping TEST_ASSERT_KVM_EXIT_REASON() change, at least
not in "misc", and I definitely don't want to grab it without Cc'ing the
other arch maintainers.  I'll follow up in that patch.

[08/13] KVM: x86: hyper-v: Use common code for hypercall userspace exit
        https://github.com/kvm-x86/linux/commit/1a9df3262a63
[09/13] KVM: x86: hyper-v: Add extended hypercall support in Hyper-v
        https://github.com/kvm-x86/linux/commit/db9cf24cea69
[10/13] KVM: selftests: Test Hyper-V extended hypercall enablement
        https://github.com/kvm-x86/linux/commit/c4a46627e5a8
[11/13] KVM: selftests: Replace hardcoded Linux OS id with HYPERV_LINUX_OS_ID
        https://github.com/kvm-x86/linux/commit/f65092015a83
[13/13] KVM: selftests: Test Hyper-V extended hypercall exit to userspace
        https://github.com/kvm-x86/linux/commit/60325261235a

--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes