From mboxrd@z Thu Jan 1 00:00:00 1970 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 1CF22C54EE9 for ; Thu, 22 Sep 2022 18:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232516AbiIVSWT (ORCPT ); Thu, 22 Sep 2022 14:22:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232146AbiIVSVd (ORCPT ); Thu, 22 Sep 2022 14:21:33 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7661C10AB39; Thu, 22 Sep 2022 11:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663870889; x=1695406889; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rkbhPAbj7cDgUM/73qRc/G+VqqyGPWDg7DKyVgG5eCc=; b=hmAIprvsgIthS4/HtgAkW6ZY3TH91+54z2/8L5jUDGwijBBR51M+Qkcx Lkas0rDegI551cCCIc+A9emNqWz1f/LLQ4xaXp378ft0Uj/3OvIcW0KH9 ehgrPtJ+3lZuAjuHDEL+Zk+N4+t0gVNhe5DWqTZkqvxSPQDjoXe3KSSBf aIa7ukKhAmBlXr0BBj7Bu/jsB9YDKt/0Wuz24m+nmQseEhn8I9QdSrrTw H2pBX3Qc2cij/+uGQyg07WiGw96yz1xUyXkFjJXUC5LwXIeNXQinuoWHy 5r6eNRLWcO3dtA6aACyByjzdMmRjhvpco6s/dRKTPmyesjhSTnyJ1ZF0M w==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="386675995" X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="386675995" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 11:21:20 -0700 X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="653086731" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 11:21:19 -0700 From: isaku.yamahata@intel.com To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Thomas Gleixner , Marc Zyngier , Will Deacon Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Kai Huang , Chao Gao , Atish Patra , Shaokun Zhang , Daniel Lezcano , Huang Ying , Huacai Chen , Dave Hansen , Borislav Petkov Subject: [PATCH v5 13/30] KVM: Add arch hook for resume event Date: Thu, 22 Sep 2022 11:20:42 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Isaku Yamahata Factor out the logic on resume event as arch callback. Later kvm/x86 will override it. Suggested-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 861aad8812ff..1adbf74e3047 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1436,6 +1436,7 @@ static inline void kvm_create_vcpu_debugfs(struct kvm_vcpu *vcpu) {} int kvm_arch_reboot(int val); int kvm_arch_suspend(int usage_count); +void kvm_arch_resume(int usage_count); int kvm_arch_hardware_enable(void); void kvm_arch_hardware_disable(void); diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 0ebe43a695e5..1270f88c2a1e 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1159,6 +1159,12 @@ int __weak kvm_arch_suspend(int usage_count) return 0; } +void __weak kvm_arch_resume(int usage_count) +{ + if (usage_count) + hardware_enable_nolock(NULL); +} + /* * Called just after removing the VM from the vm_list, but before doing any * other destruction. @@ -5769,10 +5775,8 @@ static int kvm_suspend(void) static void kvm_resume(void) { - if (kvm_usage_count) { - lockdep_assert_not_held(&kvm_lock); - hardware_enable_nolock(NULL); - } + lockdep_assert_not_held(&kvm_lock); + kvm_arch_resume(kvm_usage_count); } static struct syscore_ops kvm_syscore_ops = { -- 2.25.1