Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1279105rwn; Thu, 8 Sep 2022 16:55:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Cm9/F9oYQXDNtrSlPlhZff7wQtZDielrlZgI5C9WOq8LkQR5AuE8rEi3DFGERk3qLxH+/ X-Received: by 2002:ac2:46f9:0:b0:498:f633:8136 with SMTP id q25-20020ac246f9000000b00498f6338136mr598453lfo.117.1662681334549; Thu, 08 Sep 2022 16:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662681334; cv=none; d=google.com; s=arc-20160816; b=eW5SJX5lDWbaU0XL9nm0lFk0/hpQVt4hLk9rpTTPGD2ejCKx3zLo/DKXFGWeK/jmX+ kbaWBCr4clYUJB4cMZHXtWnZG/+RiU/2cmq0X/xqsKamFyabprjPEp89ZLRTtYYd5mZi eJsvtpL6qjt8YY7rVykMspDjTU+EPkGts9TWmdUw+lB+B4FkTlz9ktxjznPkOKSkjfgM YC93oh6UG2VbUJdgqfeA5ignm+66c1B2yp+972sKwXoQS+PcHsYAUohLFv+7MkThnD86 N81L0DxLe6YM8269ZvyVT+SfZBEzBhtFhakYsdDG7Y9ky0CpJhY5lmk+02fhJdXLLcuK a/oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8be66l/y9utZ+zOtRUyqcAINn7DVR+D2hdzbPzuw3nU=; b=H5LkC6HWcO4d1lgixaoUZJUC+HW1MK+m9U/6iKpzuZeXZcUk0VmsPXggOrA6P63Wls kmP1jXKggAkjKCqwE+M+KqB4+yj5YMQZAK2tLZAbWQx6SPPBBz7wCQc/Zj5M/3MhPZHC puoaz3gGPYITdX2DGHp+ByulV4kouC61MBhEfNDcSY/r4L68D0Ditg3hJCHfnIbhPbcM WCALcIBmy3jcZH/RP001Kdpey4tcaLPw9N3wLSqAAIXprrY+8/xUCTFDOQKJuvI+CHMu hCv2KwhLHxjgpwmdSlsgTZVaDoAlSq0EhZ3mHB6YNHr+MYCn8GByIyDkTTvWJnAtjAfs 3PIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Wqsjdebm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x8-20020a2e8808000000b00267e1798d50si118754ljh.118.2022.09.08.16.55.05; Thu, 08 Sep 2022 16:55:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Wqsjdebm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230385AbiIHX2T (ORCPT + 99 others); Thu, 8 Sep 2022 19:28:19 -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: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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); -static cpumask_t cpus_hardware_enabled = CPU_MASK_NONE; - static int __hardware_enable(void *caller_name) { - int cpu = raw_smp_processor_id(); int r; WARN_ON_ONCE(preemptible()); - if (cpumask_test_cpu(cpu, &cpus_hardware_enabled)) - return 0; r = 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; } @@ -11866,13 +11859,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); static_call(kvm_x86_hardware_disable)(); drop_user_return_notifiers(); } -- 2.25.1