Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1297079rwn; Thu, 8 Sep 2022 17:15:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR5QuWyEaYXjtQCjiLTETrxOnOr4+086g7eUPmz5S7jM7sflX2iIfulCDwl1b1ABb+j/fj8U X-Received: by 2002:a19:441a:0:b0:498:2943:a34 with SMTP id r26-20020a19441a000000b0049829430a34mr2242449lfa.238.1662682517827; Thu, 08 Sep 2022 17:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662682517; cv=none; d=google.com; s=arc-20160816; b=CEv3Iex3+/D3aIGsSNFaivxtjy5iX03WINxHSltB2pQw32YFJKVKCI9YAvk6u1mawR pwhcO9sqKBJulIOSmAyoOqSSDdoKsius77s2cXJl9dOIq2tRiHvwpQLotSNGlepQogvX tRxRLnncol69tER3yKwfDLwHOnRnEPeaW16hshvilMUEWRiLMSGgFbrKa9xHpn7KqPjo 0tOy6uegh+oV4J2bgux0mFIewza0qIywx9OtKfBOM5PLdUrFb1ZAqc78wsc6lz9Akch9 klr6wAG2plj48FY2s2cNZLeNaeL8GW3NHqbLinKWhzmR+rGLgGi3+PURgdge9grMVHkP xrwA== 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=pzQnGmYZ0nUyXGCFJYZgUjmKBe3F+ly0oKNnbW2E0w0=; b=lfzgiZc8NB0AOq4iRUswY37FJKRxlykJChq76ijIvklur0ZsbgJUAeE1ziDk8mALGa tmqHSz4aj38siXE27Nv8FKV1XHGwefnwnREyBKHT11UcvBxb+qji6A++9K+XMK5N3pT4 KzFOPTNe5TcEItR9gj9bQDSwvsXPZDict6YyyKfLTJ3QdL5Z084xw3eLYGUqK0+Evfvb 0+jkIr5/gFOh45FLzi1eBXg8+c76vVwqgTIT9RrrAlS9Wbke3nlCO8JiPU8A40fijZIi JtCX13BvF4UTA1wCMuARNFwMnwqyzz86gnhw1YGOK8LePi1kHgUHFbe2hJsqxNX8+G7K 0uxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Jl1KRZ6a; 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 bp36-20020a05651215a400b0049466b21f46si132825lfb.515.2022.09.08.17.14.48; Thu, 08 Sep 2022 17:15:17 -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=Jl1KRZ6a; 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 S230430AbiIHX1s (ORCPT + 99 others); Thu, 8 Sep 2022 19:27:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230204AbiIHX1A (ORCPT ); Thu, 8 Sep 2022 19:27:00 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EC7F115CC3; Thu, 8 Sep 2022 16:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662679583; x=1694215583; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IDO9vgRZGN9o4PRsD59O3z85CBSphz3E60aJtgsIp8c=; b=Jl1KRZ6aMhsDufaPPdWvxK5t+jPr/n4+ZFia8nNyQXja0JrDzTUjmc2l BWSQo9uZBjn0WHga3zwKAlnBIiGEz99EBb4cga6XZk1PGBMkvAL2VALsr kMl0AoosWcMmNkwq3YQxQnKqLxrlMyj0KG0Y4+fl3oJtJKU2PQx04033s DzXeuT4CQZRKhqNJlqSmB2Lp4y6C1otgYT4pglRBhpm9+tBK5h4DvyuJ3 qB32N5Io4+y+yyJD853oNmhK9zr7RGzRLpQ6llzA0x5P8PkY38qpuvHJZ Ak4YbXl2BD7KqGm1y2MVfZyskXCPBClVRQ99e9YnZ3PBQe1Zkl217BjsM Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="298687039" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="298687039" 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:15 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="610863274" 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:15 -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 22/26] KVM: x86: Make x86 processor compat check callback empty Date: Thu, 8 Sep 2022 16:25:38 -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=-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 Move processor compatibility check on all processors into kvm_arch_hardware_setup() and make kvm_arch_check_processor_compat{,_all}() empty. This is a preparation step to eliminate them. Suggested-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- arch/x86/kvm/x86.c | 47 +++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0c9d965859c6..9dd90f0521c3 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -129,6 +129,8 @@ static int kvm_vcpu_do_singlestep(struct kvm_vcpu *vcpu); static int __set_sregs2(struct kvm_vcpu *vcpu, struct kvm_sregs2 *sregs2); static void __get_sregs2(struct kvm_vcpu *vcpu, struct kvm_sregs2 *sregs2); +static int kvm_check_processor_compatibility(void); + struct kvm_x86_ops kvm_x86_ops __read_mostly; #define KVM_X86_OP(func) \ @@ -11911,21 +11913,8 @@ int kvm_arch_del_vm(int usage_count) return 0; } -static void check_processor_compat(void *rtn) -{ - *(int *)rtn = kvm_arch_check_processor_compat(); -} - int kvm_arch_check_processor_compat_all(void) { - int cpu; - int r; - - for_each_online_cpu(cpu) { - smp_call_function_single(cpu, check_processor_compat, &r, 1); - if (r < 0) - return r; - } return 0; } @@ -11933,7 +11922,7 @@ int kvm_arch_online_cpu(unsigned int cpu, int usage_count) { int ret; - ret = kvm_arch_check_processor_compat(); + ret = kvm_check_processor_compatibility(); if (ret) return ret; @@ -11997,7 +11986,7 @@ void kvm_arch_resume(int usage_count) u64 max_tsc = 0; bool stable, backwards_tsc = false; - if (kvm_arch_check_processor_compat()) + if (kvm_check_processor_compatibility()) return; /* FIXME: disable KVM. */ if (!usage_count) @@ -12103,6 +12092,24 @@ static inline void kvm_ops_update(struct kvm_x86_init_ops *ops) kvm_pmu_ops_update(ops->pmu_ops); } +static void check_processor_compat(void *rtn) +{ + *(int *)rtn = kvm_check_processor_compatibility(); +} + +static int kvm_check_processor_compatibility_all(void) +{ + int cpu; + int r; + + for_each_online_cpu(cpu) { + smp_call_function_single(cpu, check_processor_compat, &r, 1); + if (r < 0) + return r; + } + return 0; +} + int kvm_arch_hardware_setup(void *opaque) { struct kvm_x86_init_ops *ops = opaque; @@ -12143,7 +12150,8 @@ int kvm_arch_hardware_setup(void *opaque) } kvm_caps.default_tsc_scaling_ratio = 1ULL << kvm_caps.tsc_scaling_ratio_frac_bits; kvm_init_msr_list(); - return 0; + + return kvm_check_processor_compatibility_all(); } void kvm_arch_hardware_unsetup(void) @@ -12155,7 +12163,7 @@ void kvm_arch_hardware_unsetup(void) static_call(kvm_x86_hardware_unsetup)(); } -int kvm_arch_check_processor_compat(void) +static int kvm_check_processor_compatibility(void) { int cpu = smp_processor_id(); struct cpuinfo_x86 *c = &cpu_data(cpu); @@ -12175,6 +12183,11 @@ int kvm_arch_check_processor_compat(void) return static_call(kvm_x86_check_processor_compatibility)(); } +int kvm_arch_check_processor_compat(void) +{ + return 0; +} + bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu) { return vcpu->kvm->arch.bsp_vcpu_id == vcpu->vcpu_id; -- 2.25.1