Skip to content

RFC KVM: x86: Make Hyper-V emulation optional (AKA introduce CONFIG_KVM_HYPERV)

Vitaly Kuznetsov kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest11 patches 19 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11KVM: x86: xen: Remove unneeded xen context from struct kvm_arch when !CONFIG_KVM_XENarch/x86/include/asm/kvm_host.h arch/x86/kvm/irq.c+7 -01 reply
2/11KVM: x86: hyper-v: Move Hyper-V partition assist page out of Hyper-V emulation contextarch/x86/include/asm/kvm_host.h arch/x86/kvm/svm/svm_onhyperv.c arch/x86/kvm/vmx/vmx.c +1 more+6 -42 replies
3/11KVM: VMX: Split off vmx_onhyperv.{ch} from hyperv.{ch}arch/x86/kvm/Makefile arch/x86/kvm/vmx/hyperv.c arch/x86/kvm/vmx/hyperv.h +4 more+271 -2521 reply
4/11KVM: x86: hyper-v: Introduce kvm_hv_synic_auto_eoi_set()arch/x86/kvm/hyperv.h arch/x86/kvm/lapic.c+6 -11 reply
5/11KVM: x86: hyper-v: Introduce kvm_hv_synic_has_vector()arch/x86/kvm/hyperv.h arch/x86/kvm/lapic.c+6 -21 reply
6/11KVM: VMX: Split off hyperv_evmcs.{ch}arch/x86/kvm/Makefile arch/x86/kvm/vmx/hyperv.c arch/x86/kvm/vmx/hyperv.h +3 more+477 -4722 replies
7/11KVM: x86: Make Hyper-V emulation optionalarch/x86/include/asm/kvm_host.h arch/x86/kvm/Kconfig arch/x86/kvm/Makefile +9 more+143 -235 replies
8/11KVM: nVMX: hyper-v: Introduce nested_vmx_evmptr() accessorarch/x86/kvm/vmx/hyperv.h arch/x86/kvm/vmx/nested.c arch/x86/kvm/vmx/nested.h+29 -233 replies
9/11KVM: nVMX: hyper-v: Introduce nested_vmx_evmcs() accessorarch/x86/kvm/vmx/hyperv.h arch/x86/kvm/vmx/nested.c+26 -151 reply
10/11KVM: nVMX: hyper-v: Hide more stuff under CONFIG_KVM_HYPERVarch/x86/kvm/vmx/nested.c arch/x86/kvm/vmx/vmx.c arch/x86/kvm/vmx/vmx.h+7 -01 reply
11/11KVM: nSVM: hyper-v: Hide more stuff under CONFIG_KVM_HYPERV/CONFIG_HYPERVarch/x86/kvm/svm/nested.c arch/x86/kvm/svm/svm.h+16 -61 reply

Reviews trailers per patch

8 of 11 patches have a Reviewed-by or Acked-by.

PatchMaxim Levitsky
1/11R-b
2/11
3/11R-b
4/11R-b
5/11R-b
6/11R-b
7/11
8/11
9/11R-b
10/11R-b
11/11R-b

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/11] KVM: x86: Make Hyper-V emulation optional (AKA introduce CONFIG_KVM_HYPERV)

Ideas to make Hyper-V emulation by KVM optional were expressed in the past so I've decided to take a look at what would it take us to implement it. Turns out it's quite a lot of code churn but the gain is also significant. Just comparing the resulting module sizes, I can see:

    # CONFIG_KVM_HYPERV is not set
    # CONFIG_HYPERV is not set

    -rw-r--r--. 1 user user 3612632 Oct 10 16:53 arch/x86/kvm/kvm-amd.ko
    -rw-r--r--. 1 user user 5343968 Oct 10 16:53 arch/x86/kvm/kvm-intel.ko

    CONFIG_KVM_HYPERV=y
    # CONFIG_HYPERV is not set

    -rw-r--r--. 1 user user 3925704 Oct 10 16:51 arch/x86/kvm/kvm-amd.ko
    -rw-r--r--. 1 user user 5819192 Oct 10 16:51 arch/x86/kvm/kvm-intel.ko

    # CONFIG_KVM_HYPERV is not set
    CONFIG_HYPERV=m

    -rw-r--r--. 1 user user 3928440 Oct 10 16:40 arch/x86/kvm/kvm-amd.ko
    -rw-r--r--. 1 user user 8156464 Oct 10 16:40 arch/x86/kvm/kvm-intel.ko

    CONFIG_KVM_HYPERV=y
    CONFIG_HYPERV=m

    -rw-r--r--. 1 user user 4245440 Oct 10 16:37 arch/x86/kvm/kvm-amd.ko
    -rw-r--r--. 1 user user 8583872 Oct 10 16:37 arch/x86/kvm/kvm-intel.ko

While code churn is certainly something we can survive, adding more CONFIG options always comes with a risk of a broken build somewhere in the future.

Early RFC. I have only compile tested these patches in these four configurations and I'd like to get your opinion on whether it's worth it or not.

The first patch of the series is not Hyper-V related but as I hide Hyper-V emulation context under CONFIG_KVM_HYPERV I think it would make sense to do the same for Xen.

Vitaly Kuznetsov (11):
KVM: x86: xen: Remove unneeded xen context from struct kvm_arch when
!CONFIG_KVM_XEN
KVM: x86: hyper-v: Move Hyper-V partition assist page out of Hyper-V
emulation context
KVM: VMX: Split off vmx_onhyperv.{ch} from hyperv.{ch}
KVM: x86: hyper-v: Introduce kvm_hv_synic_auto_eoi_set()
KVM: x86: hyper-v: Introduce kvm_hv_synic_has_vector()
KVM: VMX: Split off hyperv_evmcs.{ch}
KVM: x86: Make Hyper-V emulation optional
KVM: nVMX: hyper-v: Introduce nested_vmx_evmptr() accessor
KVM: nVMX: hyper-v: Introduce nested_vmx_evmcs() accessor
KVM: nVMX: hyper-v: Hide more stuff under CONFIG_KVM_HYPERV
KVM: nSVM: hyper-v: Hide more stuff under
CONFIG_KVM_HYPERV/CONFIG_HYPERV

 arch/x86/include/asm/kvm_host.h |  11 +-
 arch/x86/kvm/Kconfig            |   9 +
 arch/x86/kvm/Makefile           |  19 +-
 arch/x86/kvm/cpuid.c            |   6 +
 arch/x86/kvm/hyperv.h           |  39 ++-
 arch/x86/kvm/irq.c              |   2 +
 arch/x86/kvm/irq_comm.c         |   9 +-
 arch/x86/kvm/lapic.c            |   5 +-
 arch/x86/kvm/svm/hyperv.h       |   7 +
 arch/x86/kvm/svm/nested.c       |  22 +-
 arch/x86/kvm/svm/svm.h          |   2 +
 arch/x86/kvm/svm/svm_onhyperv.c |   2 +-
 arch/x86/kvm/svm/svm_onhyperv.h |   2 +
 arch/x86/kvm/vmx/hyperv.c       | 447 --------------------------------
 arch/x86/kvm/vmx/hyperv.h       | 191 ++------------
 arch/x86/kvm/vmx/hyperv_evmcs.c | 311 ++++++++++++++++++++++
 arch/x86/kvm/vmx/hyperv_evmcs.h | 162 ++++++++++++
 arch/x86/kvm/vmx/nested.c       |  94 ++++---
 arch/x86/kvm/vmx/nested.h       |   3 +-
 arch/x86/kvm/vmx/vmx.c          |   6 +-
 arch/x86/kvm/vmx/vmx.h          |   2 +
 arch/x86/kvm/vmx/vmx_onhyperv.c |  36 +++
 arch/x86/kvm/vmx/vmx_onhyperv.h | 125 +++++++++
 arch/x86/kvm/vmx/vmx_ops.h      |   2 +-
 arch/x86/kvm/x86.c              |  60 +++--
 25 files changed, 885 insertions(+), 689 deletions(-)
 create mode 100644 arch/x86/kvm/vmx/hyperv_evmcs.c
 create mode 100644 arch/x86/kvm/vmx/hyperv_evmcs.h
 create mode 100644 arch/x86/kvm/vmx/vmx_onhyperv.c
 create mode 100644 arch/x86/kvm/vmx/vmx_onhyperv.h
Signature · 1 line
2.41.0