Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4116760rwe; Tue, 30 Aug 2022 05:05:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR4q4OQlvCvZzushlajTsVRONastebtRQel3gY4TJAYMlaVKFqd1MTkHpnL1XZmBcYY9PT04 X-Received: by 2002:a17:90a:948b:b0:1fd:c277:fcc9 with SMTP id s11-20020a17090a948b00b001fdc277fcc9mr10978641pjo.185.1661861112061; Tue, 30 Aug 2022 05:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661861112; cv=none; d=google.com; s=arc-20160816; b=Wt2A/I9z3MV3NXPQam8f4/aEgOao6p06xVVrXShEolovLrBT4wqKvRubCDWzGv0w5/ ftZA5Z3Np6mpiMjI3dlYzeia3d7C1pZqcViAIK80ZGg02ktqO2lcLWyz1rN5f3MGsJzN RQ+ORufBXMQvi9Y0/pxWcPSN0Q9/qD3scIIrv2wDBH5rAh4plPjRU1pB1MlO/qRD+OO5 woSR13i4kpF4bB6qdyA+TGXLhSWArTOVI9z4mluv+WscieC9yekb2TiRkTZWLeMfQenk fAJSnCi2QPS3Yuo13XNqMHHllQ3ENlaQ4WJVErP02gmaxkwp40XTPwgYXpw4E00RdnAc 5h4Q== 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=+1ChfUAMelik/Be0F5AVEkmZcN9zcQ43mtpC0d0P+f4=; b=q67gE56ctcgKw/bf5XBalev/aX6tO5wxe0k/V6dxadOtLvuuDq/LDgVtLgjP76C79V utJp6mIL0esBhFgPA7IuqEuJGGNbRf5t8loiMS1IMiKDRDDR+Q+9YaIfa+wV9Gtso0MR f1+rDg0sOX/lN9B/X+kSsHNI2cJD9gHsBtOW8RDLMGe8UJBnrJCkZ4Jv2NEVVsL/VO0D PWbVNz9SbkgNtfSjzwlqeTnymD5MVztn1lZFLeQtoywuIc7ySTj/vhgK1Oz55CGSLi8Y DN0Vmv4sz8emvlFqSEqp/OV5AQAYy20AbM/GBATI+c/thck2LMKQEbn9pzk4HPTYHWix O6Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LW2Rd8ab; 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 p21-20020a63f455000000b0042c50dc425asi1895721pgk.446.2022.08.30.05.05.00; Tue, 30 Aug 2022 05:05:12 -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=LW2Rd8ab; 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 S230158AbiH3MCT (ORCPT + 99 others); Tue, 30 Aug 2022 08:02:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbiH3MB6 (ORCPT ); Tue, 30 Aug 2022 08:01:58 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E19E6E399B; Tue, 30 Aug 2022 05:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661860917; x=1693396917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=496gn+dXXIi7M5XXbuRczLDPDm6MGxriSqNHgXRr8zI=; b=LW2Rd8abBtMkbWLgZ3f91iejoQay8frD3nCq7te3BIf2Qa++rZI8JoP/ G0j3JMiJBnB1I2S5jAayKk9VbVmD8VkhVPipfrqOtPE5dNNKCQOPRftGS Crtv9aNTEzv/ccHpGymWsybAvuUDQOBWPxICgAOZI3sKOX7sc9iEohqgG yBpkMNZOnj0CNhgt1U6cjv/oz1mW9rLSBTBQMNzM/Lj9o59NJRBeSCuXX W8CJKSu+DeW2FyAHsnR3kPN6wx3PYmJ7a37xyG6nD/U6gblLM/GhXndpX 8tcMlAbyvLxrGFHndu5dM/AYLgS/escw5mzws/US6oAq7Snx/+/4fvHmS w==; X-IronPort-AV: E=McAfee;i="6500,9779,10454"; a="356870959" X-IronPort-AV: E=Sophos;i="5.93,274,1654585200"; d="scan'208";a="356870959" 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:55 -0700 X-IronPort-AV: E=Sophos;i="5.93,274,1654585200"; d="scan'208";a="787469619" 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:55 -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 , Suzuki K Poulose , Anup Patel , Claudio Imbrenda Subject: [PATCH v2 04/19] Partially revert "KVM: Pass kvm_init()'s opaque param to additional arch funcs" Date: Tue, 30 Aug 2022 05:01:19 -0700 Message-Id: <7f4a3ef13cc4b22aa77e8c5022e1710fd4189eff.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: Chao Gao This partially reverts commit b99040853738 ("KVM: Pass kvm_init()'s opaque param to additional arch funcs") remove opaque from kvm_arch_check_processor_compat because no one uses this opaque now. Address conflicts for ARM (due to file movement) and manually handle RISC-V which comes after the commit. The change about kvm_arch_hardware_setup() in original commit are still needed so they are not reverted. The current implementation enables hardware (e.g. enable VMX on all CPUs), arch-specific initialization for the first VM creation, and disables hardware (in x86, disable VMX on all CPUs) for last VM destruction. To support TDX, hardware_enable_all() will be done during module loading time. As a result, CPU compatibility check will be opportunistically moved to hardware_enable_nolock(), which doesn't take any argument. Instead of passing 'opaque' around to hardware_enable_nolock() and hardware_enable_all(), just remove the unused 'opaque' argument from kvm_arch_check_processor_compat(). Signed-off-by: Chao Gao Reviewed-by: Sean Christopherson Reviewed-by: Suzuki K Poulose Acked-by: Anup Patel Acked-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20220216031528.92558-3-chao.gao@intel.com Signed-off-by: Isaku Yamahata Reviewed-by: Kai Huang --- arch/arm64/kvm/arm.c | 2 +- arch/mips/kvm/mips.c | 2 +- arch/powerpc/kvm/powerpc.c | 2 +- arch/riscv/kvm/main.c | 2 +- arch/s390/kvm/kvm-s390.c | 2 +- arch/x86/kvm/x86.c | 2 +- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c | 16 +++------------- 8 files changed, 10 insertions(+), 20 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 2ff0ef62abad..3385fb57c11a 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -68,7 +68,7 @@ int kvm_arch_hardware_setup(void *opaque) return 0; } -int kvm_arch_check_processor_compat(void *opaque) +int kvm_arch_check_processor_compat(void) { return 0; } diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index a25e0b73ee70..092d09fb6a7e 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c @@ -140,7 +140,7 @@ int kvm_arch_hardware_setup(void *opaque) return 0; } -int kvm_arch_check_processor_compat(void *opaque) +int kvm_arch_check_processor_compat(void) { return 0; } diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index fb1490761c87..7b56d6ccfdfb 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -447,7 +447,7 @@ int kvm_arch_hardware_setup(void *opaque) return 0; } -int kvm_arch_check_processor_compat(void *opaque) +int kvm_arch_check_processor_compat(void) { return kvmppc_core_check_processor_compat(); } diff --git a/arch/riscv/kvm/main.c b/arch/riscv/kvm/main.c index 1549205fe5fe..f8d6372d208f 100644 --- a/arch/riscv/kvm/main.c +++ b/arch/riscv/kvm/main.c @@ -20,7 +20,7 @@ long kvm_arch_dev_ioctl(struct file *filp, return -EINVAL; } -int kvm_arch_check_processor_compat(void *opaque) +int kvm_arch_check_processor_compat(void) { return 0; } diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index edfd4bbd0cba..e26d4dd85668 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -254,7 +254,7 @@ int kvm_arch_hardware_enable(void) return 0; } -int kvm_arch_check_processor_compat(void *opaque) +int kvm_arch_check_processor_compat(void) { return 0; } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 985487fe0d63..ca920b6b925d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11994,7 +11994,7 @@ void kvm_arch_hardware_unsetup(void) static_call(kvm_x86_hardware_unsetup)(); } -int kvm_arch_check_processor_compat(void *opaque) +int kvm_arch_check_processor_compat(void) { struct cpuinfo_x86 *c = &cpu_data(smp_processor_id()); diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index f4519d3689e1..eab352902de7 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1438,7 +1438,7 @@ int kvm_arch_hardware_enable(void); void kvm_arch_hardware_disable(void); int kvm_arch_hardware_setup(void *opaque); void kvm_arch_hardware_unsetup(void); -int kvm_arch_check_processor_compat(void *opaque); +int kvm_arch_check_processor_compat(void); int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu); bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu); int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu); diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 584a5bab3af3..4243a9541543 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -5799,22 +5799,14 @@ void kvm_unregister_perf_callbacks(void) } #endif -struct kvm_cpu_compat_check { - void *opaque; - int *ret; -}; - -static void check_processor_compat(void *data) +static void check_processor_compat(void *rtn) { - struct kvm_cpu_compat_check *c = data; - - *c->ret = kvm_arch_check_processor_compat(c->opaque); + *(int *)rtn = kvm_arch_check_processor_compat(); } int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, struct module *module) { - struct kvm_cpu_compat_check c; int r; int cpu; @@ -5842,10 +5834,8 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, if (r < 0) goto out_free_1; - c.ret = &r; - c.opaque = opaque; for_each_online_cpu(cpu) { - smp_call_function_single(cpu, check_processor_compat, &c, 1); + smp_call_function_single(cpu, check_processor_compat, &r, 1); if (r < 0) goto out_free_2; } -- 2.25.1