To be able to switch VMware products running on Linux to KVM some minor changes are required to let KVM run/resume unmodified VMware guests.
First allow enabling of the VMware backdoor via an api. Currently the setting of the VMware backdoor is limited to kernel boot parameters, which forces all VM's running on a host to either run with or without the VMware backdoor. Add a simple cap to allow enabling of the VMware backdoor on a per VM basis. The default for that setting remains the kvm.enable_vmware_backdoor boot parameter (which is false by default) and can be changed on a per-vm basis via the KVM_CAP_X86_VMWARE_BACKDOOR cap. Second add a cap to forward hypercalls to userspace. I know that in general that's frowned upon but VMwre guests send quite a few hypercalls from userspace and it would be both impractical and largelly impossible to handle all in the kernel. The change is trivial and I'd be maintaining this code so I hope it's not a big deal. The third commit just adds a self-test for the "forward VMware hypercalls to userspace" functionality. Cc: Doug Covelli <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: [email protected] Cc: "H. Peter Anvin" <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Isaku Yamahata <[email protected]> Cc: Joel Stanley <[email protected]> Cc: Zack Rusin <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Zack Rusin (3): KVM: x86: Allow enabling of the vmware backdoor via a cap KVM: x86: Add support for VMware guest specific hypercalls KVM: selftests: x86: Add a test for KVM_CAP_X86_VMWARE_HYPERCALL Documentation/virt/kvm/api.rst | 56 ++++++++- arch/x86/include/asm/kvm_host.h | 2 + arch/x86/kvm/emulate.c | 5 +- arch/x86/kvm/svm/svm.c | 6 +- arch/x86/kvm/vmx/vmx.c | 4 +- arch/x86/kvm/x86.c | 47 ++++++++ arch/x86/kvm/x86.h | 7 +- include/uapi/linux/kvm.h | 2 + tools/include/uapi/linux/kvm.h | 2 + tools/testing/selftests/kvm/Makefile | 1 + .../kvm/x86_64/vmware_hypercall_test.c | 108 ++++++++++++++++++ 11 files changed, 227 insertions(+), 13 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86_64/vmware_hypercall_test.c -- 2.43.0
