From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF59CC433FE for ; Wed, 9 Feb 2022 07:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232016AbiBIHs6 (ORCPT ); Wed, 9 Feb 2022 02:48:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237374AbiBIHsz (ORCPT ); Wed, 9 Feb 2022 02:48:55 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7E30C0613CB; Tue, 8 Feb 2022 23:48:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644392939; x=1675928939; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=UHxQ0y6ReTg5fAil+JKwO37ROUMI1ZBKsYOkDDrvDa0=; b=JAKJTt7lQ3ErEl1627tkNZltivTKJCYgoSsISDIzydbmgqDXe5PULrxB EIfJx62CVNN6HebphBDc/DnD+HsJW+d3nPGZvogpDXBV8gHgPFl9Ii5oC V9atX26WowaahJXqHSYPu5Bl65ZAOx+vOKQKHd1I6rQkUyL4UDlZJQCH+ 5AMwdrkE0Pw18bdf5ceUMNHldCzx4c9Bqo+gSo+8HqagjS7R0K0i0QKl6 Aih6qw0SL+oZrC1yCNFsgdtOFgEad2wDOD4fewyNeGRxOxZ1uNwtEp8KA lEintS/aIaQq0l308ODwwZJQ4PqmwnNbg3BE4JYvp4vsfh/gfGY6I70fL g==; X-IronPort-AV: E=McAfee;i="6200,9189,10252"; a="273682787" X-IronPort-AV: E=Sophos;i="5.88,355,1635231600"; d="scan'208";a="273682787" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2022 23:48:59 -0800 X-IronPort-AV: E=Sophos;i="5.88,355,1635231600"; d="scan'208";a="525893576" Received: from gao-cwp.sh.intel.com (HELO gao-cwp) ([10.239.159.105]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2022 23:48:56 -0800 Date: Wed, 9 Feb 2022 15:59:51 +0800 From: Chao Gao To: Sean Christopherson Cc: kvm@vger.kernel.org, pbonzini@redhat.com, kevin.tian@intel.com, tglx@linutronix.de, John Garry , Will Deacon , "Darrick J. Wong" , Shaokun Zhang , Thomas Richter , Tony Lindgren , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/4] KVM: Rename and move CPUHP_AP_KVM_STARTING to ONLINE section Message-ID: <20220209075950.GA7943@gao-cwp> References: <20220118064430.3882337-1-chao.gao@intel.com> <20220118064430.3882337-4-chao.gao@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 09, 2022 at 12:29:57AM +0000, Sean Christopherson wrote: >On Tue, Jan 18, 2022, Chao Gao wrote: >> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c >> index 148f7169b431..528741601122 100644 >> --- a/virt/kvm/kvm_main.c >> +++ b/virt/kvm/kvm_main.c >> @@ -4856,13 +4856,25 @@ static void hardware_enable_nolock(void *junk) >> } >> } >> >> -static int kvm_starting_cpu(unsigned int cpu) >> +static int kvm_online_cpu(unsigned int cpu) >> { >> + int ret = 0; >> + >> raw_spin_lock(&kvm_count_lock); >> - if (kvm_usage_count) >> + /* >> + * Abort the CPU online process if hardware virtualization cannot >> + * be enabled. Otherwise running VMs would encounter unrecoverable >> + * errors when scheduled to this CPU. >> + */ >> + if (kvm_usage_count) { > > >> hardware_enable_nolock(NULL); >> + if (atomic_read(&hardware_enable_failed)) { > >This needs: > > atomic_set(&hardware_enable_failed, 0); > >otherwise failure to online one CPU will prevent onlining other non-broken CPUs. >It's probably worth adding a WARN_ON_ONCE above this too, e.g. Thanks. All your comments to this series make sense. I just post a revised version.