Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4724018pxv; Tue, 6 Jul 2021 07:43:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEHrQu8Gpi3yfr1hG0v3Fc0lFQz1w8MjhUobTwg8sGwgVQVCL4vf514yuQTEFyCLxvZGEa X-Received: by 2002:a17:906:805:: with SMTP id e5mr687121ejd.310.1625582595746; Tue, 06 Jul 2021 07:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625582595; cv=none; d=google.com; s=arc-20160816; b=z8AAjbNnFzjjOhmDr6Cam3SZA/qPgFueb7wLPBP1pTykc0hOdLcU1JpncQLdp6KrXD hreNPAa0aa5O1JQnMYNnpXw+L6j1ZtRiQhMR5eXlvWLCn3K4KcyJpR9Zofu5wmXjeQsD 1zeO8r0QLfsi5QvArzb9CqzTB3ZuXMUBVHKLheOFSdiwUEfQbjYbIVBcbS15O9WQGZfn WjdBmga2C+K2TBu7EBuPAK9whPO/0ZgBOpsMa8Vh8VP0+sSGTDog/4dQUq9Z27DvJw1+ SOzKG8X7cbmIH1XnBHgoQmSclCapUBIvPFXszvKztj7NBh2pTJozzwYTbTDPqSP1g5SS J2Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=G/gssxW/mbIhY3PmRppDUAwsg3OaI9WCT71TjUjACeA=; b=uuM/PHhzNN7DyqcSkZA868a2SPAO8qNIN1Q/8jb+AF/MHvqX/3Y6hdSQeky1Igc85s KX/yUgtr87XFF2r7OK7NOTdaNKk8YhRPuWeSnyU2V9HefkZA8dYoNHF9Yri4G4wchg9h ugXSjkE3/zVyL+miN3pmhI0876nSI3MSqLU5TnFfHlMIZl7C2/CEjUz1HVMFcuKxqgTO nGBPrkYtfDHMnrw0kjoAelJOeLjZbjAqMszF3yvGqiXZ02uQUNpKrCE6VkTtK1nkHoOr bl5MR6/vvGkwT87MeMFSZbtZJjezHNt5B60+C3287RjrtQK2aoW5th/SuQacm/7mbdWl bNVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fGV5nQt+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d22si14111289edr.244.2021.07.06.07.42.52; Tue, 06 Jul 2021 07:43:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fGV5nQt+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232193AbhGFOhV (ORCPT + 99 others); Tue, 6 Jul 2021 10:37:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22241 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232073AbhGFOhU (ORCPT ); Tue, 6 Jul 2021 10:37:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625582081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G/gssxW/mbIhY3PmRppDUAwsg3OaI9WCT71TjUjACeA=; b=fGV5nQt+jG4lfliGdO5oXqzy686K3xlWrtU7PvrFWMm/S+M/xKsJ+6SUtfN2cpfTHaY+qL i6uW9U2yIT2F61Q79NTi52Zb04lfTtoqUU1eTuyBoWUedq8czIA6Q5k683RBOaaKue1c/S eN5MfPn0pm39zEJGlSW7Ezyu9Hi/R7M= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-602-hQ_vxDyrMBGLxmDoFgC3jg-1; Tue, 06 Jul 2021 10:34:40 -0400 X-MC-Unique: hQ_vxDyrMBGLxmDoFgC3jg-1 Received: by mail-wm1-f71.google.com with SMTP id p3-20020a05600c3583b02901f55d71e34aso1012174wmq.4 for ; Tue, 06 Jul 2021 07:34:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=G/gssxW/mbIhY3PmRppDUAwsg3OaI9WCT71TjUjACeA=; b=iv4HwIIBegeBUw3DlpkIkk7GkhkFGZq0qiG3HmD4VF/Z40PZ7okx28ps/V5YUAuEo6 YFX3yKsNkmsrKCJU4x8SNHANr2On/x2W7krhVgimkyyXGGK/OEhni2wZquG51xNBnUC5 bc3gSdwjZa2Lhf7mg5QcKahB5ZefE2TrUC5isTMW9lnHHoB271xgcD869ZVBZeM4WxnO Jo5Ptwfcj9W7d5BOSZol0aI9JHrZYcszjewEXYCJYtIFGXkn01Pu2w+lyn2b0qrxblyb s0V4/L8uQF9KcacgvQqCSUX0Ld4PUIlHZISTrMjZ7cAPzqSKXZqha/7nCMhYt4fCP/Gy qWLg== X-Gm-Message-State: AOAM5310DLh4O6t3g20GhnOt4Y8hF+eLCOfQ7uSoDykIon/NBTYC73xu 6NGf+Ma0MafxzCAqn9murG7Zd05zX3G6cozWwpMWyBVGMq9nr+NS1tHfQLP9vM8Yb8sNhn3xvuS hTO0vPzLI+lFrnG8lP2XgQebj X-Received: by 2002:a05:6000:1787:: with SMTP id e7mr21954377wrg.167.1625582079466; Tue, 06 Jul 2021 07:34:39 -0700 (PDT) X-Received: by 2002:a05:6000:1787:: with SMTP id e7mr21954354wrg.167.1625582079256; Tue, 06 Jul 2021 07:34:39 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm15936566wmi.13.2021.07.06.07.34.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Jul 2021 07:34:38 -0700 (PDT) To: isaku.yamahata@intel.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , erdemaktas@google.com, Connor Kuehl , Sean Christopherson , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: isaku.yamahata@gmail.com, Sean Christopherson References: From: Paolo Bonzini Subject: Re: [RFC PATCH v2 35/69] KVM: x86: Introduce vm_teardown() hook in kvm_arch_vm_destroy() Message-ID: <98e17bdc-cc91-f225-b24a-d64e052e1b3d@redhat.com> Date: Tue, 6 Jul 2021 16:34:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/07/21 00:04, isaku.yamahata@intel.com wrote: > -static void svm_vm_destroy(struct kvm *kvm) > +static void svm_vm_teardown(struct kvm *kvm) > { > avic_vm_destroy(kvm); > sev_vm_destroy(kvm); > } Please keep "destroy" as is and use "free" from the final step. > +static void svm_vm_destroy(struct kvm *kvm) > +{ > + Please remove the empty lines. Paolo > +} > + > static bool svm_is_vm_type_supported(unsigned long type) > { > return type == KVM_X86_LEGACY_VM; > @@ -4456,6 +4461,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata = { > .is_vm_type_supported = svm_is_vm_type_supported, > .vm_size = sizeof(struct kvm_svm), > .vm_init = svm_vm_init, > + .vm_teardown = svm_vm_teardown, > .vm_destroy = svm_vm_destroy, > > .prepare_guest_switch = svm_prepare_guest_switch, > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index 84c2df824ecc..36756a356704 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -6995,6 +6995,16 @@ static int vmx_vm_init(struct kvm *kvm) > return 0; > } > > +static void vmx_vm_teardown(struct kvm *kvm) > +{ > + > +} > + > +static void vmx_vm_destroy(struct kvm *kvm) > +{ > + > +} > + > static int __init vmx_check_processor_compat(void) > { > struct vmcs_config vmcs_conf; > @@ -7613,6 +7623,8 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = { > .is_vm_type_supported = vmx_is_vm_type_supported, > .vm_size = sizeof(struct kvm_vmx), > .vm_init = vmx_vm_init, > + .vm_teardown = vmx_vm_teardown, > + .vm_destroy = vmx_vm_destroy, > > .vcpu_create = vmx_create_vcpu, > .vcpu_free = vmx_free_vcpu, > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index da9f1081cb03..4b436cae1732 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -11043,7 +11043,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm) > __x86_set_memory_region(kvm, TSS_PRIVATE_MEMSLOT, 0, 0); > mutex_unlock(&kvm->slots_lock); > } > - static_call_cond(kvm_x86_vm_destroy)(kvm); > + static_call(kvm_x86_vm_teardown)(kvm); > kvm_free_msr_filter(srcu_dereference_check(kvm->arch.msr_filter, &kvm->srcu, 1)); > kvm_pic_destroy(kvm); > kvm_ioapic_destroy(kvm); > @@ -11054,6 +11054,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_destroy)(kvm); > } > > void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot) >