Skip to content

KVM monolithic v1

Andrea Arcangeli kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest17 patches 50 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/17x86: spec_ctrl: fix SPEC_CTRL initialization after kexecarch/x86/include/asm/msr-index.h arch/x86/kernel/cpu/bugs.c+21 -14 replies
2/17KVM: monolithic: x86: convert the kvm_x86_ops methods to external functionsarch/x86/include/asm/kvm_ops.h arch/x86/kvm/svm_ops.c arch/x86/kvm/vmx/vmx_ops.c+1510 -04 replies
3/17KVM: monolithic: x86: handle the request_immediate_exit variationarch/x86/kvm/vmx/vmx_ops.c+4 -14 replies
4/17KVM: monolithic: x86: convert the kvm_pmu_ops methods to external functionsarch/x86/kvm/pmu_amd_ops.c arch/x86/kvm/pmu_ops.h arch/x86/kvm/vmx/pmu_intel_ops.c+158 -00 replies
5/17KVM: monolithic: x86: enable the kvm_x86_ops external functionsarch/x86/include/asm/kvm_host.h arch/x86/kvm/svm.c arch/x86/kvm/vmx/vmx.c+6 -00 replies
6/17KVM: monolithic: x86: enable the kvm_pmu_ops external functionsarch/x86/kvm/pmu.h arch/x86/kvm/pmu_amd.c arch/x86/kvm/vmx/pmu_intel.c+6 -00 replies
7/17KVM: monolithic: x86: adjust the section prefixesarch/x86/kvm/svm.c arch/x86/kvm/vmx/vmx.c arch/x86/kvm/x86.c+4 -43 replies
8/17KVM: monolithic: adjust the section prefixes in the KVM common codevirt/kvm/kvm_main.c+3 -30 replies
9/17KVM: monolithic: x86: remove kvm.koarch/x86/kvm/Makefile+2 -30 replies
10/17KVM: monolithic: x86: use the external functions instead of kvm_x86_opsarch/x86/include/asm/kvm_host.h arch/x86/kvm/cpuid.c arch/x86/kvm/hyperv.c +10 more+222 -2221 reply
11/17KVM: monolithic: x86: remove exportsarch/x86/kvm/cpuid.c arch/x86/kvm/hyperv.c arch/x86/kvm/irq.c +6 more+0 -1590 replies
12/17KVM: monolithic: remove exports from KVM common codevirt/kvm/eventfd.c virt/kvm/kvm_main.c+0 -660 replies
13/17KVM: monolithic: x86: drop the kvm_pmu_ops structurearch/x86/include/asm/kvm_host.h arch/x86/kvm/pmu.h arch/x86/kvm/pmu_amd.c +3 more+0 -553 replies
14/17KVM: monolithic: x86: inline more exit handlers in vmx.carch/x86/kvm/vmx/vmx.c+3 -36 replies
15/17KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlersarch/x86/kvm/vmx/vmx.c+22 -223 replies
16/17KVM: retpolines: x86: eliminate retpoline from svm.c exit handlersarch/x86/kvm/svm.c+14 -01 reply
17/17x86: retpolines: eliminate retpoline from msr event handlersarch/x86/events/intel/core.c+11 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/17] KVM monolithic v1

Hello,

This patchset micro optimizes the vmexit to increase performance by dropping the kvm.ko kernel module.

All common KVM code gets linked twice into kvm-intel and kvm-amd with the only cons of using more disk space, but the pros of CPU (and RAM) runtime benefits.

This improves the vmexit performance by two digits percent on microbenchmarks with the spectre_v2 default mitigation on both VMX and SVM. With spectre_v2=off or with CPUs with IBRS_ALL in ARCH_CAPABILITIES this still improve performance but it's more of the order of 1%.

We'll still have to deal with CPUs without IBRS_ALL for a decade and reducing the vmexit latency is important to pass certain benchmarks with workloads that happen to trigger frequent vmexits without having to set spectre_v2=off in the host (which at least in theory would make the host kernel vulnerable from a spectre v2 attack from the guest, even through hyperthreading).

The first patch 1/17 should be splitted off from this series and it's intended to be merged separately, it's included here only to avoid any possible erroneous measurement if using kexec for testing, in turn if using kexec it's recommended to include it in the baseline measurements too.

A git clonable branch for quick testing is available here:

https://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git/log/?h=kvm-mono1

Thanks,
Andrea

Andrea Arcangeli (17):
x86: spec_ctrl: fix SPEC_CTRL initialization after kexec
KVM: monolithic: x86: convert the kvm_x86_ops methods to external
functions
KVM: monolithic: x86: handle the request_immediate_exit variation
KVM: monolithic: x86: convert the kvm_pmu_ops methods to external
functions
KVM: monolithic: x86: enable the kvm_x86_ops external functions
KVM: monolithic: x86: enable the kvm_pmu_ops external functions
KVM: monolithic: x86: adjust the section prefixes
KVM: monolithic: adjust the section prefixes in the KVM common code
KVM: monolithic: x86: remove kvm.ko
KVM: monolithic: x86: use the external functions instead of

    kvm_x86_ops

KVM: monolithic: x86: remove exports
KVM: monolithic: remove exports from KVM common code
KVM: monolithic: x86: drop the kvm_pmu_ops structure
KVM: monolithic: x86: inline more exit handlers in vmx.c
KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers
KVM: retpolines: x86: eliminate retpoline from svm.c exit handlers
x86: retpolines: eliminate retpoline from msr event handlers

 arch/x86/events/intel/core.c     |  11 +
 arch/x86/include/asm/kvm_host.h  |  15 +-
 arch/x86/include/asm/kvm_ops.h   | 166 ++++++++
 arch/x86/include/asm/msr-index.h |   2 +
 arch/x86/kernel/cpu/bugs.c       |  20 +-
 arch/x86/kvm/Makefile            |   5 +-
 arch/x86/kvm/cpuid.c             |  27 +-
 arch/x86/kvm/hyperv.c            |   8 +-
 arch/x86/kvm/irq.c               |   4 -
 arch/x86/kvm/irq_comm.c          |   2 -
 arch/x86/kvm/kvm_cache_regs.h    |  10 +-
 arch/x86/kvm/lapic.c             |  44 +-
 arch/x86/kvm/mmu.c               |  50 +--
 arch/x86/kvm/mmu.h               |   4 +-
 arch/x86/kvm/mtrr.c              |   2 -
 arch/x86/kvm/pmu.c               |  27 +-
 arch/x86/kvm/pmu.h               |  21 +-
 arch/x86/kvm/pmu_amd.c           |  15 +-
 arch/x86/kvm/pmu_amd_ops.c       |  68 ++++
 arch/x86/kvm/pmu_ops.h           |  22 +
 arch/x86/kvm/svm.c               |  19 +-
 arch/x86/kvm/svm_ops.c           | 672 ++++++++++++++++++++++++++++++
 arch/x86/kvm/trace.h             |   4 +-
 arch/x86/kvm/vmx/pmu_intel.c     |  17 +-
 arch/x86/kvm/vmx/pmu_intel_ops.c |  68 ++++
 arch/x86/kvm/vmx/vmx.c           |  36 +-
 arch/x86/kvm/vmx/vmx_ops.c       | 675 +++++++++++++++++++++++++++++++
 arch/x86/kvm/x86.c               | 409 +++++++------------
 arch/x86/kvm/x86.h               |   2 +-
 virt/kvm/eventfd.c               |   1 -
 virt/kvm/kvm_main.c              |  71 +---
 31 files changed, 1982 insertions(+), 515 deletions(-)
 create mode 100644 arch/x86/include/asm/kvm_ops.h
 create mode 100644 arch/x86/kvm/pmu_amd_ops.c
 create mode 100644 arch/x86/kvm/pmu_ops.h
 create mode 100644 arch/x86/kvm/svm_ops.c
 create mode 100644 arch/x86/kvm/vmx/pmu_intel_ops.c
 create mode 100644 arch/x86/kvm/vmx/vmx_ops.c