• Chao Gao's avatar
    KVM: Rename and move CPUHP_AP_KVM_STARTING to ONLINE section · aaf12a7b
    Chao Gao authored
    
    
    The CPU STARTING section doesn't allow callbacks to fail. Move KVM's
    hotplug callback to ONLINE section so that it can abort onlining a CPU in
    certain cases to avoid potentially breaking VMs running on existing CPUs.
    For example, when KVM fails to enable hardware virtualization on the
    hotplugged CPU.
    
    Place KVM's hotplug state before CPUHP_AP_SCHED_WAIT_EMPTY as it ensures
    when offlining a CPU, all user tasks and non-pinned kernel tasks have left
    the CPU, i.e. there cannot be a vCPU task around. So, it is safe for KVM's
    CPU offline callback to disable hardware virtualization at that point.
    Likewise, KVM's online callback can enable hardware virtualization before
    any vCPU task gets a chance to run on hotplugged CPUs.
    
    Drop kvm_x86_check_processor_compatibility()'s WARN that IRQs are
    disabled, as the ONLINE section runs with IRQs disabled.  The WARN wasn't
    intended to be a requirement, e.g. disabling preemption is sufficient,
    the IRQ thing was purely an aggressive sanity check since the helper was
    only ever invoked via SMP function call.
    
    Rename KVM's CPU hotplug callbacks accordingly.
    Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Signed-off-by: default avatarChao Gao <chao.gao@intel.com>
    Signed-off-by: default avatarIsaku Yamahata <isaku.yamahata@intel.com>
    Reviewed-by: default avatarYuan Yao <yuan.yao@intel.com>
    [sean: drop WARN that IRQs are disabled]
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Message-Id: <20221130230934.1014142-42-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    aaf12a7b
x86.c 358 KB