Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1268259rwb; Thu, 22 Sep 2022 12:29:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4mBHT8VeehNZqVmqBsl6zcqbR+ugHprr3tNN5+DowNiaIqVY8lKCFn0r0xIu90+8WvTT5Z X-Received: by 2002:a17:907:7d87:b0:780:3ce9:4309 with SMTP id oz7-20020a1709077d8700b007803ce94309mr4232660ejc.400.1663874941002; Thu, 22 Sep 2022 12:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663874940; cv=none; d=google.com; s=arc-20160816; b=WKFIIuMYPk4SOLIseGPw8T3fNW9vFD4hgSeiv14FK6Q2VSGGi1Pwn+tpJtma4wlFMH uhPoUUvcN2cldhKcgyVfZPbOErTnRNK/7dt5xcels1CJtxQSnYLPtMgFpdJiMgi7lpQR lvj5pB0agWh5J4jcLw0sK0VmIsBObsC1VwCqutWVvkLqo27rst0dilbDqMuW9ae8bEoc 3JMXyOqRFFO245cU0XUwwnlqrZ+we7gfvUj4QDfo2SFSQXQn8ZD/kyg+CnhToHSYCgZ1 GPxqxfYj2eKNCS9tvjMtSeLEBtEBoXUW26QznyxUZdVVFJlJfwqHaqsiAI64Dw7ll8GY j6rw== 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=wePzvnp2MCqY3YDAyJVDjo6G8v6/DhUje+48cQpQzDo=; b=X3+Q5bjt4xf003G9rOUsj+pQ1XuDUrDe4HyP5FdAb+pG/b7wqpb5TsCDRCxdYz6NOP 4B5h0sTVSK4LgiDrI2bVmmrtPSEhMKcAblZ2kAT9cnNUavCZoWXAHb+dPSmGzy8udpC2 1fPnn3LJYoowoo7Raa7OAP999evGvl+wx+NIka7c9c7j2T1rPZ6zx7YllWXEv74Nr3C+ 0XSEJeCNSXBk7vm+ePda+AeOxcE+MTjMCNvKy1/vTpQBqMwNXgPcJpRzyEU6s3Ak5OfX VV0Bdkj+ZAOkkb04MMSp2O9RLcv4hKyRDAuKRvFfWqEMa8d164Pn9CsauA+NvSCfTxU4 UZVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SyvpkJdP; 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 hc17-20020a170907169100b007822665aa3csi5185560ejc.911.2022.09.22.12.28.35; Thu, 22 Sep 2022 12:29:00 -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=SyvpkJdP; 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 S232486AbiIVSWB (ORCPT + 99 others); Thu, 22 Sep 2022 14:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231972AbiIVSVc (ORCPT ); Thu, 22 Sep 2022 14:21:32 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 921CF10AB27; Thu, 22 Sep 2022 11:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663870886; x=1695406886; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3j7AGT1eIC/BE0MhW+coP+8A6Ov/SyQoyWvgLPvXMnc=; b=SyvpkJdP7b70ZGFSZNoWMCFSyTUjmW89uB7vQViUZg2fqYVGuZmz2pZX g3YXqPLqHK++29qmF9Nns9hAfhYIVWoGf6OfHHuRecMfzzqTTC/YXA0q4 gefPLShTnwQjVP88WCcbjE8oKoGskmlMPP/5JdbQBQit5xeVm6W92nedh pfMKE9jMH07w5UsDb9FLIIs800TfC1f9gxfelivAyC/cyXlJTDP5E8O2N Nsh5ctFyaFdYkIebXhQllQm6bKq4rFiilPmHBU4Wh91KPKRJVHn6W9nqq 5qp/tp2oqp7tiPgI6gB+wz28N99xeXrOG+Y30z5pX3EAiKcY045UkoZrQ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="386675992" X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="386675992" 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="653086727" 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 12/30] KVM: Add arch hook for suspend Date: Thu, 22 Sep 2022 11:20:41 -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 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 Factor out the logic on suspend 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 | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 084ee8a13e9f..861aad8812ff 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1435,6 +1435,7 @@ static inline void kvm_create_vcpu_debugfs(struct kvm_vcpu *vcpu) {} #endif int kvm_arch_reboot(int val); +int kvm_arch_suspend(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 58385000b73f..0ebe43a695e5 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1148,6 +1148,17 @@ int __weak kvm_arch_reboot(int val) return NOTIFY_OK; } +int __weak kvm_arch_suspend(int usage_count) +{ + if (usage_count) + /* + * Because kvm_suspend() is called with interrupt disabled, no + * need to disable preemption. + */ + hardware_disable_nolock(NULL); + return 0; +} + /* * Called just after removing the VM from the vm_list, but before doing any * other destruction. @@ -5753,15 +5764,7 @@ static int kvm_suspend(void) * locking. */ lockdep_assert_not_held(&kvm_lock); - - if (kvm_usage_count) { - /* - * Because kvm_suspend() is called with interrupt disabled, no - * need to disable preemption. - */ - hardware_disable_nolock(NULL); - } - return 0; + return kvm_arch_suspend(kvm_usage_count); } static void kvm_resume(void) -- 2.25.1