[PATCH 0/5] KVM: x86: Partially allow KVM_SET_CPUID{,2} after KVM_RUN for CPU hotplug

From: Vitaly Kuznetsov
Date: Thu Jan 13 2022 - 08:37:27 EST


Recently, KVM made it illegal to change CPUID after KVM_RUN but
unfortunately this change is not fully compatible with existing VMMs.
In particular, QEMU reuses vCPU fds for CPU hotplug after unplug and it
calls KVM_SET_CPUID2. Relax the requirement by implementing an allowlist
of entries which are allowed to change.

Going forward, VMMs are supposed to change the behavior. There is no real
need to change CPUID information. For hotplug purposes (and if reusing vCPU
fds is still considered being worthy), VMMs can be a bit smarter and always
pick the fd with the required LAPIC/x2APIC id to eliminate the need to
change this info later.

Vitaly Kuznetsov (5):
KVM: x86: Fix indentation in kvm_set_cpuid()
KVM: x86: Do runtime CPUID update before updating
vcpu->arch.cpuid_entries
KVM: x86: Partially allow KVM_SET_CPUID{,2} after KVM_RUN
KVM: selftests: Rename 'get_cpuid_test' to 'cpuid_test'
KVM: selftests: Test KVM_SET_CPUID2 after KVM_RUN

arch/x86/kvm/cpuid.c | 120 ++++++++++++++----
arch/x86/kvm/x86.c | 19 ---
tools/testing/selftests/kvm/.gitignore | 2 +-
tools/testing/selftests/kvm/Makefile | 5 +-
.../selftests/kvm/include/x86_64/processor.h | 7 +
.../selftests/kvm/lib/x86_64/processor.c | 33 ++++-
.../x86_64/{get_cpuid_test.c => cpuid_test.c} | 78 ++++++++++++
7 files changed, 216 insertions(+), 48 deletions(-)
rename tools/testing/selftests/kvm/x86_64/{get_cpuid_test.c => cpuid_test.c} (66%)

--
2.34.1