Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1230289rwb; Thu, 22 Sep 2022 11:56:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66u9JD0F0fk+563oNaWY8CDcYnzZKyzblePgmhO3hF3c4eK+6t5mp07VL21GpqXdM6jEGd X-Received: by 2002:a17:907:802:b0:781:8017:b2df with SMTP id wv2-20020a170907080200b007818017b2dfmr4058219ejb.606.1663873014191; Thu, 22 Sep 2022 11:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663873014; cv=none; d=google.com; s=arc-20160816; b=Y9YEMKOtyVv1hm9Vlqxat1PgX/bw2XcBeQZ+dM6yuKsyj8bJPa+vsm8nIftGROvXuF 8AjozCkZ1f6fOwBLmFvFMalzmJa+IkvKjdki+aFBGtdz5RejTQTuWWQsh8Fqk8WkVRB1 ufgm8SNzxPKa5eZIkq4CmxEQ9L+iM7Q2/NjzruPhPHnbMKIRKSqz2zbd6bZTW1lJVr/b qBpCx+4oQxptKixwc2FflmbV1TaIeukLMPxvcNNhjfI7oLxNohcWRQ4K+IqHyb/vVfq7 MnI0ouulPQNSR9x6h8G2mV5tmgA914EWwCTW3h3NUCUBR7G/4leB6HemaYA4lSrCMMJi vsXA== 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=2YGp3Z96UnhBhv3+2lLzNC1XvZcIaZl/TgN9zQq2Ah0=; b=VsorInB9k1acFpI+AeH1N8D7nPsRTO1bRBHh9MtRWGFDKp7dHw+CJ8IaYxOc9Qps45 nB4QlWa24uK5ZD6EEGoicOlF4xFCXHpMm790fs1NtHQreQsH9qMHzmlBX8IZ9nPJTfgm MmrziOgF9WF/i5nuwG6p60nXFm9Tas0OLT0x9qKOYWKfgbHUtaxxNcI23AcV5Gt/Yt1A kK2T2rhOX6bz4C1L8HBEpcb0w2g1AdFx1l3hYYKoPHRM9QxnOWT3h6ZZaYGWaB9lp+8Z S86DrjpQKw9C2I3UfK+4+/M7NfpdRFGBXbI5WCCj+abGIqEbOrFWIxsNxMc1+v+6C1CZ EngQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DKH4f+st; 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 bo7-20020a170906d04700b00781132a4ca6si5140875ejb.850.2022.09.22.11.56.28; Thu, 22 Sep 2022 11:56:54 -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=DKH4f+st; 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 S232495AbiIVSYr (ORCPT + 99 others); Thu, 22 Sep 2022 14:24:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232692AbiIVSXt (ORCPT ); Thu, 22 Sep 2022 14:23:49 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F7810D66B; Thu, 22 Sep 2022 11:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663870954; x=1695406954; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0GvMWbVPXwgA7CdFobND5PDqeVhAEZxtFBVTWjqYWSY=; b=DKH4f+sthQUZKp0X5/i9XD8Mt6YsivATG3eWmp0eGebXJFZDyS1lvVos dCQHfjQsCpVWhEEEFxyvO+b34z6MmG12J0IS6GK/Y674+foTBbrhgT/+n 8KpEzJBua7pX2maic5FYMka0WTmrOEKZvwVwqje8it09HrUVzqedrRP+c a1m2z/KI6aIokujfLf9DtGfgwmQaroNdHKK6jThb0ve1qKklr0/y78F78 YUbGFc3BQ2d1UMtZRLdNf7hTbd4JR//+S1ErGaJRmO+GBe2fZtRPNrLa1 H7q1akRzk8M4FP4dUnTzLUboNrojx1xBrydA8nqw1/NPIfFlIm/cRlble Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="326712948" X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="326712948" 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="653086946" 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:29 -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 29/30] RFC: KVM: x86: Remove cpus_hardware_enabled and related sanity check Date: Thu, 22 Sep 2022 11:20:58 -0700 Message-Id: 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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 1f791c93391b..7505dd4ae695 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11958,23 +11958,16 @@ void kvm_arch_resume(int usage_count) } } -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 = static_call(kvm_x86_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; } @@ -11988,13 +11981,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