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 833FFC6FD1C for ; Sun, 12 Mar 2023 09:59:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbjCLJ67 (ORCPT ); Sun, 12 Mar 2023 05:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230101AbjCLJ6h (ORCPT ); Sun, 12 Mar 2023 05:58:37 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9E6C5551F for ; Sun, 12 Mar 2023 01:57:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678615062; x=1710151062; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gI+Q28upI7JfkXbgE8jla0kNkqrHsRYK9ZUDdqIcMS0=; b=WyijkeTY4MYjhcINHtvrXF0jhN+cRTIqT/2bU2hO1vm6kg1UrYFS9r6L Te1o8snYtqMv8yHKQSY5AwW/YD12CvydmWZUeHVE5zkhvP7YE7/Sn/aXB qORvlVBP1mV8wr2lFFjWBFcvqy3KavYzbcQ0iW6TLHEbLLw1Op+oQQUri Igva4XNEdd5H/MS1zrWO/6dAJmLbuDI8BpoSPmeq8kZYyF06yxUS6HQPm F+UGrfm8b/+CPpIHbHT6z7dVjo/3FCjLTcuk9jgg77W13VPUFNZ2/0yKW IAPKKVMnT+20ZTpXZ87OGKYevD353iBRMuiphrTjUtpWbLU+SR74QTjuM A==; X-IronPort-AV: E=McAfee;i="6500,9779,10646"; a="336998104" X-IronPort-AV: E=Sophos;i="5.98,254,1673942400"; d="scan'208";a="336998104" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2023 01:56:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10646"; a="680677679" X-IronPort-AV: E=Sophos;i="5.98,254,1673942400"; d="scan'208";a="680677679" Received: from jiechen-ubuntu-dev.sh.intel.com ([10.239.154.150]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2023 01:56:15 -0800 From: Jason Chen CJ To: kvm@vger.kernel.org Cc: Jason Chen CJ , Chuanxiao Dong Subject: [RFC PATCH part-5 06/22] KVM: VMX: Add new kvm_x86_ops vm_free Date: Mon, 13 Mar 2023 02:02:47 +0800 Message-Id: <20230312180303.1778492-7-jason.cj.chen@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230312180303.1778492-1-jason.cj.chen@intel.com> References: <20230312180303.1778492-1-jason.cj.chen@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org pKVM expect teardown shadow vm after all shadow vcpu got teardown, as shadow vcpu data structure is attached with shadow vm. Meanwhile kvm_x86_ops provided ops vm_destroy is called before vcpu_free, so add a new kvm_x86_ops vm_free which called after all vcpu got freed. Signed-off-by: Jason Chen CJ Signed-off-by: Chuanxiao Dong --- arch/x86/include/asm/kvm-x86-ops.h | 1 + arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/x86.c | 1 + 3 files changed, 3 insertions(+) diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-x86-ops.h index abccd51dcfca..444ff48ef2ac 100644 --- a/arch/x86/include/asm/kvm-x86-ops.h +++ b/arch/x86/include/asm/kvm-x86-ops.h @@ -22,6 +22,7 @@ KVM_X86_OP(vcpu_after_set_cpuid) KVM_X86_OP(vm_init) KVM_X86_OP_OPTIONAL(vm_destroy) KVM_X86_OP_OPTIONAL_RET0(vcpu_precreate) +KVM_X86_OP_OPTIONAL(vm_free) KVM_X86_OP(vcpu_create) KVM_X86_OP(vcpu_free) KVM_X86_OP(vcpu_reset) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index c3cf849a1370..3dea471bfca4 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1529,6 +1529,7 @@ struct kvm_x86_ops { unsigned int vm_size; int (*vm_init)(struct kvm *kvm); void (*vm_destroy)(struct kvm *kvm); + void (*vm_free)(struct kvm *kvm); /* Create, but do not attach this VCPU */ int (*vcpu_precreate)(struct kvm *kvm); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 84ddeabbf94b..877715426dac 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -12309,6 +12309,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm) kvm_page_track_cleanup(kvm); kvm_xen_destroy_vm(kvm); kvm_hv_destroy_vm(kvm); + static_call_cond(kvm_x86_vm_free)(kvm); } static void memslot_rmap_free(struct kvm_memory_slot *slot) -- 2.25.1