From nobody Fri Apr 10 20:21:46 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 27AABC25B08 for ; Sat, 20 Aug 2022 06:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343559AbiHTGCL (ORCPT ); Sat, 20 Aug 2022 02:02:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244618AbiHTGAy (ORCPT ); Sat, 20 Aug 2022 02:00:54 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE84EA287E; Fri, 19 Aug 2022 23:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660975253; x=1692511253; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k5e1P3AKVcgtCAeIF9Lz4zIaHf3w2yygo+9il05lYr4=; b=SMEehBLMSA+4yoWH1wiYWsdtvyqGzo4ASPsoRzcDmwK+Uv70iTh2CxxN y3UTBl3XRujWXUMvxIuSGgBr/Pxsel9Q0jUHheKApjcVe8aCimpVw5fgL xbvc9TTsjOiueTdNZ7ZbdVK5FCFrmLUO8xUOwpJBNT6yrmKOcNdK6IsMA j/PyKP3hlZYZpf70qLu8p8cdHyEGo95a9jL8tlOf5ZlwnHcFqdp/0HGUS K0NjdWBhXy7aXzJ6wicYQiM4MabZBBN3pn5qFv0u4OQ4G2celOKFaI5ic 6PQba/AuJgUt+vj026KLLnalvN9oPHw2O83jFDRkujF4IGDzz2S9nXZEX w==; X-IronPort-AV: E=McAfee;i="6500,9779,10444"; a="379448984" X-IronPort-AV: E=Sophos;i="5.93,250,1654585200"; d="scan'208";a="379448984" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2022 23:00:51 -0700 X-IronPort-AV: E=Sophos;i="5.93,250,1654585200"; d="scan'208";a="668857565" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2022 23:00:51 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , Sean Christopherson , Kai Huang , Chao Gao , Will Deacon Subject: [RFC PATCH 17/18] KVM: x86: Remove cpus_hardware_enabled and related sanity check Date: Fri, 19 Aug 2022 23:00:23 -0700 Message-Id: <305ce2cbf6bc01736091f7e7ef1302fb994a48ad.1660974106.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. 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 5aa6d5308ee8..f43caa8919ea 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11830,22 +11830,15 @@ 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) { - 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_info("kvm: enabling virtualization on CPU%d failed\n", cpu); - else - cpumask_set_cpu(cpu, &cpus_hardware_enabled); + pr_info("kvm: enabling virtualization on CPU%d failed\n", smp_processor_= id()); return r; } =20 @@ -11859,13 +11852,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