From patchwork Thu Sep 22 18:20:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 12985675 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 D6B0BECAAD8 for ; Thu, 22 Sep 2022 18:24:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232533AbiIVSYr (ORCPT ); Thu, 22 Sep 2022 14:24:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232380AbiIVSXv (ORCPT ); Thu, 22 Sep 2022 14:23:51 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F4BD10D66E; Thu, 22 Sep 2022 11:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663870956; x=1695406956; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e7eFeq+AhqW0LXyZEdeUIZ0W61VhBhwYbIGQ5iPG5f0=; b=AV/3lU3OvnOLkDEB851zm7NVzvzyGEpyvL1H2eqFJZO1L2bock6N79Cc YrIr6QCR0WWd5U7Ga6nqTQM2dhlUesvHHPT4N6Z4nBYJ42I7G3kPP6Cn7 9qOo9ZH7ot0ua0KA/pldBZmukrbkxSWfsh27I6kJJLeUT7Cue1LIhgkm5 gxqV3GsppHZJV2ZS2ktDUsz5a/k/WAs+RHOe6121LTexXk9Hm4H5/r4lf 0z5tYVf71a0zyZ80Jb88Qm6RwVcB/KC2XD83DCC0+TCUTrBpTiXzgVF1A rbMS0QUNQE2KLba6Lq+4pk+5Qz/CEJTOtFHgzVbO8HgBxgF3MQZ3oU5lI g==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="326712953" X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="326712953" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 11:21:30 -0700 X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="653086961" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 11:21:30 -0700 From: isaku.yamahata@intel.com To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Thomas Gleixner , Marc Zyngier , Will Deacon Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Kai Huang , Chao Gao , Atish Patra , Shaokun Zhang , Daniel Lezcano , Huang Ying , Huacai Chen , Dave Hansen , Borislav Petkov Subject: [PATCH v5 30/30] RFC: KVM: Remove cpus_hardware_enabled and related sanity check Date: Thu, 22 Sep 2022 11:20:59 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- virt/kvm/kvm_arch.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/virt/kvm/kvm_arch.c b/virt/kvm/kvm_arch.c index 076a55d59988..e7708bfa0360 100644 --- a/virt/kvm/kvm_arch.c +++ b/virt/kvm/kvm_arch.c @@ -12,23 +12,16 @@ #include -static cpumask_t cpus_hardware_enabled = CPU_MASK_NONE; - static int __hardware_enable(void) { - int cpu = raw_smp_processor_id(); int r; WARN_ON_ONCE(preemptible()); - if (cpumask_test_cpu(cpu, &cpus_hardware_enabled)) - return 0; r = kvm_arch_hardware_enable(); if (r) pr_warn("kvm: enabling virtualization on CPU%d failed during %pSb\n", - cpu, __builtin_return_address(0)); - else - cpumask_set_cpu(cpu, &cpus_hardware_enabled); + smp_processor_id(), __builtin_return_address(0)); return r; } @@ -42,13 +35,7 @@ static void hardware_enable(void *arg) static void hardware_disable(void *junk) { - int cpu = raw_smp_processor_id(); - WARN_ON_ONCE(preemptible()); - - if (!cpumask_test_cpu(cpu, &cpus_hardware_enabled)) - return; - cpumask_clear_cpu(cpu, &cpus_hardware_enabled); kvm_arch_hardware_disable(); }