Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2687530rwb; Sun, 4 Sep 2022 22:50:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR6bnendqYffyu6N/ABsVI+k0pK/GKOCd4QKIR98kRVc6N5axR4/61538Ca4JRtO2cZk0fVI X-Received: by 2002:a05:6402:911:b0:44e:a5b4:74f7 with SMTP id g17-20020a056402091100b0044ea5b474f7mr588615edz.249.1662357003816; Sun, 04 Sep 2022 22:50:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662357003; cv=none; d=google.com; s=arc-20160816; b=TjV02M0YC+CekPxiS8HAfD3PL/qRIECT6Qn9m4hj2WBM7eNnmVANMbF8orXN06wjuH BAOsxgKVYeljl8sa2yM96fOUeI1dZrbabaOyjMbRJ+0t5Lc7EZJXhboalHwqv6igKiwf TpZb/akvBXP7zxNaUUkpuvfYBzGeYe+s0hxOvfulTWdQI9i+iSXGa+RhPUqLSwXMNbc7 cGQQ4ixl5yxcrMQY1SQECrD/OjjxQlxNG2IAa99yH+UjQ93IiRk6h35QR9MyK81FP3cJ IcFvzRvUdWbcVlC3BmHzKt4/2thpLhlAU7cQC5ydBMMl/Dc3ptTsSi0Ibvh7ufzYO1Vc HObA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=EHbS4nTyMkeBd/eWAsnx2T6ebBA/WkoIFTVVHcHi0yw=; b=Y8whVY9DEOhgcTyp7aRPXPp2fr/L4AqsarhDooD6hRgBZ6I+orug/46Xtxh0LlZJPB +ZwQ8ymSuQ5KHfNm8rswoKzqeDKJUG4KFUIFnkci17/tYCKhx3ntf+9MJMRe2wjQfCo/ kkBofZlghVlkts4F03CS7H7ehpYo5m9y95Zwi3qVJ7cVeZl9ioXNiSIzLA3G3l1jNSQp mw8oX9/Ybxf8NNHkFnWW3fJewGAxEANCYXigi8p8Q7c0LsMXk81bvLqJiC9aBSCiUn/Z giyvt1Hp/5fJCRKjMOB2f+ep3qrsdY87b/WzVOoxLmGLWHg1OZv6MYPNwGCxLbidad+G tEng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hpdjKovC; 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 hb40-20020a170907162800b0072f0a99a62bsi7336612ejc.143.2022.09.04.22.49.38; Sun, 04 Sep 2022 22:50:03 -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=hpdjKovC; 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 S235455AbiIEFnJ (ORCPT + 99 others); Mon, 5 Sep 2022 01:43:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbiIEFnF (ORCPT ); Mon, 5 Sep 2022 01:43:05 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 816502D1E6; Sun, 4 Sep 2022 22:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662356584; x=1693892584; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=FfaurS8Eqj1F9kuGI61H90o+/5niy1dzQ3FNUYnyU6M=; b=hpdjKovCjw7FB6xthJyWbJueiYLnR0AB6RDQok9zHnjgxG9r22v3/ii9 q2j+16xBYNDRH9OFzv7lG5owZ3J971sfjLBUg3umlWXISqt0WZucu86W8 iBRXZbxu9aqv4jv0oWpkUNrOniS7+PjM+LPiprOdyh6teAIDTr+vNmx6X 7+j46p9CySJ5m2l0WDGribSvm9A1C1ZZKTD5OYF2u/4aFND94hPzOB/Uq xO01cOAm50o3c5KP2S+W6ZMw35tc66EuJk0hG4Pf7w7ZymdB29dQVSCqr ssxT3OO9qK1mdi2Alu76bTnQD2gjgswg3sviGtViu78E1QTjRISL1SYzR Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10460"; a="322476004" X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="322476004" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2022 22:43:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,290,1654585200"; d="scan'208";a="675134595" Received: from yy-desk-7060.sh.intel.com (HELO localhost) ([10.239.159.76]) by fmsmga008.fm.intel.com with ESMTP; 04 Sep 2022 22:42:57 -0700 Date: Mon, 5 Sep 2022 13:42:57 +0800 From: Yuan Yao To: isaku.yamahata@intel.com Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Thomas Gleixner , Marc Zyngier , Will Deacon , isaku.yamahata@gmail.com, Kai Huang , Chao Gao , Atish Patra , Shaokun Zhang , Qi Liu , John Garry , Daniel Lezcano , Huang Ying , Huacai Chen , Dave Hansen , Borislav Petkov Subject: Re: [PATCH v3 03/22] KVM: x86: Move check_processor_compatibility from init ops to runtime ops Message-ID: <20220905054257.swzn4r4rrz762lxc@yy-desk-7060> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 On Thu, Sep 01, 2022 at 07:17:38PM -0700, isaku.yamahata@intel.com wrote: > From: Chao Gao > > so that KVM can do compatibility checks on hotplugged CPUs. Drop __init > from check_processor_compatibility() and its callees. > > use a static_call() to invoke .check_processor_compatibility. > > Opportunistically rename {svm,vmx}_check_processor_compat to conform > to the naming convention of fields of kvm_x86_ops. > > Signed-off-by: Chao Gao > Reviewed-by: Sean Christopherson > Link: https://lore.kernel.org/r/20220216031528.92558-2-chao.gao@intel.com > Signed-off-by: Isaku Yamahata Reviewed-by: Yuan Yao > --- > arch/x86/include/asm/kvm-x86-ops.h | 1 + > arch/x86/include/asm/kvm_host.h | 2 +- > arch/x86/kvm/svm/svm.c | 4 ++-- > arch/x86/kvm/vmx/vmx.c | 14 +++++++------- > arch/x86/kvm/x86.c | 3 +-- > 5 files changed, 12 insertions(+), 12 deletions(-) > > diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-x86-ops.h > index 51f777071584..3bc45932e2d1 100644 > --- a/arch/x86/include/asm/kvm-x86-ops.h > +++ b/arch/x86/include/asm/kvm-x86-ops.h > @@ -129,6 +129,7 @@ KVM_X86_OP(msr_filter_changed) > KVM_X86_OP(complete_emulated_msr) > KVM_X86_OP(vcpu_deliver_sipi_vector) > KVM_X86_OP_OPTIONAL_RET0(vcpu_get_apicv_inhibit_reasons); > +KVM_X86_OP(check_processor_compatibility) > > #undef KVM_X86_OP > #undef KVM_X86_OP_OPTIONAL > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 2c96c43c313a..5df5d88d345f 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1445,6 +1445,7 @@ static inline u16 kvm_lapic_irq_dest_mode(bool dest_mode_logical) > struct kvm_x86_ops { > const char *name; > > + int (*check_processor_compatibility)(void); > int (*hardware_enable)(void); > void (*hardware_disable)(void); > void (*hardware_unsetup)(void); > @@ -1655,7 +1656,6 @@ struct kvm_x86_nested_ops { > struct kvm_x86_init_ops { > int (*cpu_has_kvm_support)(void); > int (*disabled_by_bios)(void); > - int (*check_processor_compatibility)(void); > int (*hardware_setup)(void); > unsigned int (*handle_intel_pt_intr)(void); > > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index f3813dbacb9f..371300f03f55 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -4134,7 +4134,7 @@ svm_patch_hypercall(struct kvm_vcpu *vcpu, unsigned char *hypercall) > hypercall[2] = 0xd9; > } > > -static int __init svm_check_processor_compat(void) > +static int svm_check_processor_compatibility(void) > { > return 0; > } > @@ -4740,6 +4740,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata = { > .name = "kvm_amd", > > .hardware_unsetup = svm_hardware_unsetup, > + .check_processor_compatibility = svm_check_processor_compatibility, > .hardware_enable = svm_hardware_enable, > .hardware_disable = svm_hardware_disable, > .has_emulated_msr = svm_has_emulated_msr, > @@ -5122,7 +5123,6 @@ static struct kvm_x86_init_ops svm_init_ops __initdata = { > .cpu_has_kvm_support = has_svm, > .disabled_by_bios = is_disabled, > .hardware_setup = svm_hardware_setup, > - .check_processor_compatibility = svm_check_processor_compat, > > .runtime_ops = &svm_x86_ops, > .pmu_ops = &amd_pmu_ops, > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index d7f8331d6f7e..3cf7f18a4115 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -2495,8 +2495,8 @@ static bool cpu_has_sgx(void) > return cpuid_eax(0) >= 0x12 && (cpuid_eax(0x12) & BIT(0)); > } > > -static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt, > - u32 msr, u32 *result) > +static int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt, > + u32 msr, u32 *result) > { > u32 vmx_msr_low, vmx_msr_high; > u32 ctl = ctl_min | ctl_opt; > @@ -2514,7 +2514,7 @@ static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt, > return 0; > } > > -static __init u64 adjust_vmx_controls64(u64 ctl_opt, u32 msr) > +static u64 adjust_vmx_controls64(u64 ctl_opt, u32 msr) > { > u64 allowed; > > @@ -2523,8 +2523,8 @@ static __init u64 adjust_vmx_controls64(u64 ctl_opt, u32 msr) > return ctl_opt & allowed; > } > > -static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf, > - struct vmx_capability *vmx_cap) > +static int setup_vmcs_config(struct vmcs_config *vmcs_conf, > + struct vmx_capability *vmx_cap) > { > u32 vmx_msr_low, vmx_msr_high; > u32 min, opt, min2, opt2; > @@ -7417,7 +7417,7 @@ static int vmx_vm_init(struct kvm *kvm) > return 0; > } > > -static int __init vmx_check_processor_compat(void) > +static int vmx_check_processor_compatibility(void) > { > struct vmcs_config vmcs_conf; > struct vmx_capability vmx_cap; > @@ -8015,6 +8015,7 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = { > > .hardware_unsetup = vmx_hardware_unsetup, > > + .check_processor_compatibility = vmx_check_processor_compatibility, > .hardware_enable = vmx_hardware_enable, > .hardware_disable = vmx_hardware_disable, > .has_emulated_msr = vmx_has_emulated_msr, > @@ -8404,7 +8405,6 @@ static __init int hardware_setup(void) > static struct kvm_x86_init_ops vmx_init_ops __initdata = { > .cpu_has_kvm_support = cpu_has_kvm_support, > .disabled_by_bios = vmx_disabled_by_bios, > - .check_processor_compatibility = vmx_check_processor_compat, > .hardware_setup = hardware_setup, > .handle_intel_pt_intr = NULL, > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index fd021581ca60..5f12a7ed6f94 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -12001,7 +12001,6 @@ void kvm_arch_hardware_unsetup(void) > int kvm_arch_check_processor_compat(void *opaque) > { > struct cpuinfo_x86 *c = &cpu_data(smp_processor_id()); > - struct kvm_x86_init_ops *ops = opaque; > > WARN_ON(!irqs_disabled()); > > @@ -12009,7 +12008,7 @@ int kvm_arch_check_processor_compat(void *opaque) > __cr4_reserved_bits(cpu_has, &boot_cpu_data)) > return -EIO; > > - return ops->check_processor_compatibility(); > + return static_call(kvm_x86_check_processor_compatibility)(); > } > > bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu) > -- > 2.25.1 >