• Chao Gao's avatar
    KVM: x86: Do compatibility checks when onlining CPU · c82a5c5c
    Chao Gao authored
    Do compatibility checks when enabling hardware to effectively add
    compatibility checks when onlining a CPU.  Abort enabling, i.e. the
    online process, if the (hotplugged) CPU is incompatible with the known
    good setup.
    
    At init time, KVM does compatibility checks to ensure that all online
    CPUs support hardware virtualization and a common set of features. But
    KVM uses hotplugged CPUs without such compatibility checks. On Intel
    CPUs, this leads to #GP if the hotplugged CPU doesn't support VMX, or
    VM-Entry failure if the hotplugged CPU doesn't support all features
    enabled by KVM.
    
    Note, this is little more than a NOP on SVM, as SVM already checks for
    full SVM support during hardware enabling.
    
    Opportunistically add a pr_err() if setup_vmcs_config() fails, and
    tweak all error messages to output which CPU failed.
    Signed-off-by: default avatarChao Gao <chao.gao@intel.com>
    Co-developed-by: default avatarSean Christopherson <seanjc@google.com>
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Acked-by: default avatarKai Huang <kai.huang@intel.com>
    Message-Id: <20221130230934.1014142-41-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    c82a5c5c
x86.c 358 KB