From nobody Mon Apr 6 09:43:15 2026 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 0101EC6FA82 for ; Thu, 8 Sep 2022 23:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230249AbiIHX2U (ORCPT ); Thu, 8 Sep 2022 19:28:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbiIHX1Y (ORCPT ); Thu, 8 Sep 2022 19:27:24 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44DB412BFAF; Thu, 8 Sep 2022 16:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662679596; x=1694215596; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Dn+T+C8mc7SutVui360EYL0Vvmak+kXGxLlZyx8Iru0=; b=WqsjdebmBxCXWFyitMAMOY6WwoEbsos3lmMo3w8VzkcIVAy3Q+I8dT4u 0bbTH2HfihFuftuRanfqUFTB+maceMMn5mVbb3u3xGQU08TzgKJZtBXXV eD3HI33FptvMKpM0fI96un53jLCIlfMh38YmwWc2s+fjeywT67qmNgSQN ZjeMsOL3sclgBkQeP+32M6jDFm95OK/gu8Z4f3mzkDiumcCHq0iyFfMnq m9oSoZth9/ohtnF9OpFuSvj5MGJ2KlhQ59GZYdr/bBP90IUkwJ8MB9DHW HQSDfQtFor+muTruF0mDpOHHH4a5hVwZS+BbMmO6iTg07I2GdGATEWGag A==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="298687056" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="298687056" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 16:26:17 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="610863292" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 16:26:16 -0700 From: isaku.yamahata@intel.com To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Marc Zyngier , Will Deacon , Yuan Yao Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Kai Huang , Chao Gao , Atish Patra , Shaokun Zhang , Qi Liu , John Garry , Daniel Lezcano , Huang Ying , Huacai Chen Subject: [PATCH v4 25/26] RFC: KVM: x86: Remove cpus_hardware_enabled and related sanity check Date: Thu, 8 Sep 2022 16:25:41 -0700 Message-Id: <4da304db9dfa544564bbcb89957914a0f3dc136b.1662679124.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Isaku Yamahata cpus_hardware_enabled mask seems incomplete protection against other kernel component using CPU virtualization feature. Because it's obscure and incomplete, remove the check. Suggested-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- arch/x86/kvm/x86.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 84cc459575e2..623a5993d608 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11836,23 +11836,16 @@ void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu= *vcpu, u8 vector) } EXPORT_SYMBOL_GPL(kvm_vcpu_deliver_sipi_vector); =20 -static cpumask_t cpus_hardware_enabled =3D CPU_MASK_NONE; - static int __hardware_enable(void *caller_name) { - int cpu =3D raw_smp_processor_id(); int r; =20 WARN_ON_ONCE(preemptible()); =20 - if (cpumask_test_cpu(cpu, &cpus_hardware_enabled)) - return 0; r =3D static_call(kvm_x86_hardware_enable)(); if (r) pr_warn("kvm: enabling virtualization on CPU%d failed during %s()\n", - cpu, (const char *)caller_name); - else - cpumask_set_cpu(cpu, &cpus_hardware_enabled); + smp_processor_id(), (const char *)caller_name); return r; } =20 @@ -11866,13 +11859,7 @@ static void hardware_enable(void *arg) =20 static void hardware_disable(void *junk) { - int cpu =3D raw_smp_processor_id(); - WARN_ON_ONCE(preemptible()); - - if (!cpumask_test_cpu(cpu, &cpus_hardware_enabled)) - return; - cpumask_clear_cpu(cpu, &cpus_hardware_enabled); static_call(kvm_x86_hardware_disable)(); drop_user_return_notifiers(); } --=20 2.25.1