• Liran Alon's avatar
    KVM: nVMX: Change KVM_STATE_NESTED_EVMCS to signal vmcs12 is copied from eVMCS · 323d73a8
    Liran Alon authored
    Currently KVM_STATE_NESTED_EVMCS is used to signal that eVMCS
    capability is enabled on vCPU.
    As indicated by vmx->nested.enlightened_vmcs_enabled.
    
    This is quite bizarre as userspace VMM should make sure to expose
    same vCPU with same CPUID values in both source and destination.
    In case vCPU is exposed with eVMCS support on CPUID, it is also
    expected to enable KVM_CAP_HYPERV_ENLIGHTENED_VMCS capability.
    Therefore, KVM_STATE_NESTED_EVMCS is redundant.
    
    KVM_STATE_NESTED_EVMCS is currently used on restore path
    (vmx_set_nested_state()) only to enable eVMCS capability in KVM
    and to signal need_vmcs12_sync such that on next VMEntry to guest
    nested_sync_from_vmcs12() will be called to sync vmcs12 content
    into eVMCS in guest memory.
    However, because restore nested-state is rare enough, we could
    have just modified vmx_set_nested_state() to always signal
    need_vmcs12_sync.
    
    From all the above, it seems that we could have just removed
    the usage of KVM_STATE_NESTED_EVMCS. However, in order to preserve
    backwards migration compatibility, we cannot do that.
    (vmx_get_nested_state() needs to signal flag when migrating from
    new kernel to old kernel).
    
    Returning KVM_STATE_NESTED_EVMCS when just vCPU have eVMCS enabled
    have a bad side-effect of userspace VMM having to send nested-state
    from source to destination as part of migration stream. Even if
    guest have never used eVMCS as it doesn't even run a nested
    hypervisor workload. This requires destination userspace VMM and
    KVM to support setting nested-state. Which make it more difficult
    to migrate from new host to older host.
    To avoid this, change KVM_STATE_NESTED_EVMCS to signal eVMCS is
    not only enabled but also active. i.e. Guest have made some
    eVMCS active via an enlightened VMEntry. i.e. vmcs12 is copied
    from eVMCS and therefore should be restored into eVMCS resident
    in memory (by copy_vmcs12_to_enlightened()).
    Reviewed-by: 's avatarVitaly Kuznetsov <vkuznets@redhat.com>
    Reviewed-by: 's avatarMaran Wilson <maran.wilson@oracle.com>
    Reviewed-by: 's avatarKrish Sadhukhan <krish.sadhukhan@oracle.com>
    Signed-off-by: 's avatarLiran Alon <liran.alon@oracle.com>
    Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
    323d73a8
Name
Last commit
Last update
..
accounting Loading commit data...
arch Loading commit data...
bpf Loading commit data...
build Loading commit data...
cgroup Loading commit data...
crypto Loading commit data...
debugging Loading commit data...
firewire Loading commit data...
firmware Loading commit data...
gpio Loading commit data...
hv Loading commit data...
iio Loading commit data...
include Loading commit data...
io_uring Loading commit data...
kvm/kvm_stat Loading commit data...
laptop Loading commit data...
leds Loading commit data...
lib Loading commit data...
memory-model Loading commit data...
nfsd Loading commit data...
objtool Loading commit data...
pci Loading commit data...
pcmcia Loading commit data...
perf Loading commit data...
power Loading commit data...
scripts Loading commit data...
spi Loading commit data...
testing Loading commit data...
thermal/tmon Loading commit data...
time Loading commit data...
usb Loading commit data...
virtio Loading commit data...
vm Loading commit data...
wmi Loading commit data...
Makefile Loading commit data...