From nobody Fri Apr 10 20:21:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38CD6C25B08 for ; Sat, 20 Aug 2022 06:02:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343496AbiHTGCA (ORCPT ); Sat, 20 Aug 2022 02:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244589AbiHTGAy (ORCPT ); Sat, 20 Aug 2022 02:00:54 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 366BFA2628; Fri, 19 Aug 2022 23:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660975253; x=1692511253; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IHSa0WBYx0BgB2/RDKlw4uOS3JdT2/kSZliV76NwxJ8=; b=k3VcEZhkz9WFbeBZbbo9MnLW1HNtDZZoSrf11hfSqVdAa58Wa/qLbIVD z7Xaa0Z9NWalueumBGYAUISGDGUO6PpWN3vWlJcpc9N0r5Frfb//8Ey19 grRzJY0+ePrfUngwGTAq9bGM3pu07pvh4itJqXgABMsAx3UPTRDNZP4i2 Mn1p2XzqAwYCe3jrYpuv2ZDhiPM1FuqnmvoLH/AEKCKZhAjZ84umJ31uf WO2OU/B/FSx+trV84I+uo4PbZ9r1mQEx7YZJeqjtB2QczR+rMPKAO/HyP p7NuueULFHa1jP5q4qFylR+Np9NDfiY30/O3D2Pom2Ja8XA9OK35/pXxq A==; X-IronPort-AV: E=McAfee;i="6500,9779,10444"; a="379448982" X-IronPort-AV: E=Sophos;i="5.93,250,1654585200"; d="scan'208";a="379448982" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2022 23:00:51 -0700 X-IronPort-AV: E=Sophos;i="5.93,250,1654585200"; d="scan'208";a="668857558" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2022 23:00:50 -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: [RFC PATCH 15/18] KVM: x86: Delete kvm_arch_hardware_enable/disable() Date: Fri, 19 Aug 2022 23:00:21 -0700 Message-Id: <49aa53f11283b826ccbca3755e2548464b7f8db7.1660974106.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Isaku Yamahata Now they're function call and there is no point to keep them. Opportunistically make kvm_arch_pre_hardware_unsetup() empty. Suggested-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- arch/x86/kvm/x86.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a1e8d15aa6b8..5aa6d5308ee8 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -354,7 +354,7 @@ static void kvm_on_user_return(struct user_return_notif= ier *urn) =20 /* * Disabling irqs at this point since the following code could be - * interrupted and executed through kvm_arch_hardware_disable() + * interrupted and executed through hardware_disable() */ local_irq_save(flags); if (msrs->registered) { @@ -11830,17 +11830,6 @@ void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu = *vcpu, u8 vector) } EXPORT_SYMBOL_GPL(kvm_vcpu_deliver_sipi_vector); =20 -int kvm_arch_hardware_enable(void) -{ - return static_call(kvm_x86_hardware_enable)(); -} - -void kvm_arch_hardware_disable(void) -{ - static_call(kvm_x86_hardware_disable)(); - drop_user_return_notifiers(); -} - static cpumask_t cpus_hardware_enabled =3D CPU_MASK_NONE; =20 static int __hardware_enable(void) @@ -11852,7 +11841,7 @@ static int __hardware_enable(void) =20 if (cpumask_test_cpu(cpu, &cpus_hardware_enabled)) return 0; - r =3D kvm_arch_hardware_enable(); + r =3D static_call(kvm_x86_hardware_enable)(); if (r) pr_info("kvm: enabling virtualization on CPU%d failed\n", cpu); else @@ -11877,12 +11866,13 @@ static void hardware_disable(void *junk) if (!cpumask_test_cpu(cpu, &cpus_hardware_enabled)) return; cpumask_clear_cpu(cpu, &cpus_hardware_enabled); - kvm_arch_hardware_disable(); + static_call(kvm_x86_hardware_disable)(); + drop_user_return_notifiers(); } =20 void kvm_arch_pre_hardware_unsetup(void) { - on_each_cpu(hardware_disable, NULL, 1); + /* TODO: eliminate this function */ } =20 /* @@ -11968,7 +11958,7 @@ void kvm_arch_resume(int usage_count) =20 if (kvm_arch_check_processor_compat()) return; - if (kvm_arch_hardware_enable()) + if (static_call(kvm_x86_hardware_enable)()) return; =20 local_tsc =3D rdtsc(); @@ -12109,6 +12099,8 @@ int kvm_arch_hardware_setup(void *opaque) =20 void kvm_arch_hardware_unsetup(void) { + on_each_cpu(hardware_disable, NULL, 1); + kvm_unregister_perf_callbacks(); =20 static_call(kvm_x86_hardware_unsetup)(); --=20 2.25.1