Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4118111rwe; Tue, 30 Aug 2022 05:06:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR5aBjOyYIeJdhG0WPwC3zETaydaEMv7PWg2I9z7l+GYNwbVWkTmpGDMFMjCjVo1qwbqicRe X-Received: by 2002:a17:90b:4c52:b0:1f6:3a26:9f08 with SMTP id np18-20020a17090b4c5200b001f63a269f08mr23767336pjb.206.1661861173871; Tue, 30 Aug 2022 05:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661861173; cv=none; d=google.com; s=arc-20160816; b=ZTBzXpswHbxDc33L8VKaFkojEYcwPzgShTpIL6hazDj3D5swJ2Gk6+38Vf740qiDyM nd7VwZQ2UWbD2+HYO0EJiA+e9tQC2PoW5WKwqWQPBKwJid3rzA0lxIXqawRFHIVeSk5M zu2x0ZoZUN9NL3iJjBpa86WZzAHrYGBNW/F4qr2Ru7rmN+y/52Dhp+TAVXOJaY9CqZYj rcDQlFLAJL8wWlYV0gUtT8YNGp4+StHNQPqjS/bJPSWzfrMC+4VybKsI4US5wQLpKIIk Ruatf5uiMlzh1QhGuwopzZnBFZ7pxNTdPnEIOwXmK8G0bEnDHYWaPN6B8TPYFjCW1Iaw Peug== 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=V4MOjp8MGY9Vi2QLovNs/Fxry1IKr22b8lSeJuw2vp4=; b=zQYWJOtyR4MxJZ+SH9UmPjxAkufVGurY3ojaYNTdWhpv/lRUMmagyXnymJaY2VKCu0 /tCkbu4D9J2rYmW3a9dgTW0Z5I2B24ht5O8crXmwya1Xj8xghc8B8ADCgjjg1VMw4Kbt AAKE4HKNqCSYugdUUyg0FEtN3Pt3NeQFrjuQJIwP/773/YTZcLJmMKOijq/u1QCO/7z/ jgaF+2nzhkcCeRnaF8TKp7u1/VHkSBolI0MFPwE+YGS2l3eL6spahn/hKm/VAjQeZkKt hh5+hG20xiTVCif05ezSmAKkybPSOMD1hHTDpsCR9H8dPamI5JK6xpGcNzYjBCbfPDfI 27dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hHfKnQob; 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 e3-20020a17090a7c4300b001faf24cf424si11257928pjl.64.2022.08.30.05.06.01; Tue, 30 Aug 2022 05:06:13 -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=hHfKnQob; 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 S230033AbiH3MDF (ORCPT + 99 others); Tue, 30 Aug 2022 08:03:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbiH3MCK (ORCPT ); Tue, 30 Aug 2022 08:02:10 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E834EA319; Tue, 30 Aug 2022 05:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661860923; x=1693396923; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9IEoA4ocQWS+BnaWE2eKSbUpco8c34vmEkNWuWscBno=; b=hHfKnQobAHiEoMzxgq07jRaP5BV/6b5IEWnB5iUWYzC9thg6BI3Et2CE eGEfs/RZeoTxwr02uxndbXGmv4dRqvFeJYUYM0f5obuOvJIrGInT4u1dh JrZZTrsTzI21RZqOuLCMCgiAlWIXGKzO0cSHG7Gs2mIC8fMHURXiN0LaQ 6ju1VsAqefG4tYVJsraw1HB18qnLll3e8o7k9HkWbSa5GAMmHODSVnWiP dKrDg4haDzhyOZcgJgsXC24Tyq4nkwCuKiRZEtI3Ssgc4zpBGx2VezqB7 jLwN9n/D/val6W/3QjfdSUAgvHiT/k8XLUQdH/EFRsLQiCLQDmRJRUX70 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10454"; a="356870988" X-IronPort-AV: E=Sophos;i="5.93,274,1654585200"; d="scan'208";a="356870988" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2022 05:01:59 -0700 X-IronPort-AV: E=Sophos;i="5.93,274,1654585200"; d="scan'208";a="787469651" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2022 05:01:59 -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: [PATCH v2 13/19] KVM: Do processor compatibility check on cpu online and resume Date: Tue, 30 Aug 2022 05:01:28 -0700 Message-Id: <436cecd4b5a11056f89a46f2cd1cae67be18b192.1661860550.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 So far the processor compatibility check is not done for newly added CPU. It should be done. For online cpu case, the function is called by kernel thread bind to the cpu without irq disabled. So remove WARN_ON(!irq_disabled()). Signed-off-by: Isaku Yamahata --- arch/x86/kvm/x86.c | 2 -- virt/kvm/kvm_arch.c | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0b112cd7de58..ac185e199f69 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -12003,8 +12003,6 @@ int kvm_arch_check_processor_compat(void) { struct cpuinfo_x86 *c = &cpu_data(smp_processor_id()); - WARN_ON(!irqs_disabled()); - if (__cr4_reserved_bits(cpu_has, c) != __cr4_reserved_bits(cpu_has, &boot_cpu_data)) return -EIO; diff --git a/virt/kvm/kvm_arch.c b/virt/kvm/kvm_arch.c index 3990f85edab3..e440d4a99c8a 100644 --- a/virt/kvm/kvm_arch.c +++ b/virt/kvm/kvm_arch.c @@ -99,6 +99,12 @@ __weak int kvm_arch_del_vm(int usage_count) __weak int kvm_arch_online_cpu(unsigned int cpu, int usage_count) { + int r; + + r = kvm_arch_check_processor_compat(); + if (r) + return r; + if (usage_count) { /* * Abort the CPU online process if hardware virtualization cannot @@ -132,6 +138,11 @@ __weak int kvm_arch_suspend(int usage_count) __weak void kvm_arch_resume(int usage_count) { - if (usage_count) - (void)__hardware_enable(); + if (kvm_arch_check_processor_compat()) + return; /* FIXME: disable KVM */ + + if (!usage_count) + return; + + (void)__hardware_enable(); } -- 2.25.1