Message ID | ac17ee5e713b83ce64626b7b39c40515d98db09f.1625186503.git.isaku.yamahata@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: X86: TDX support | expand |
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) >
diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-x86-ops.h index 01457da0162b..95ae4a71cfbc 100644 --- a/arch/x86/include/asm/kvm-x86-ops.h +++ b/arch/x86/include/asm/kvm-x86-ops.h @@ -20,6 +20,7 @@ KVM_X86_OP(has_emulated_msr) KVM_X86_OP(vcpu_after_set_cpuid) KVM_X86_OP(is_vm_type_supported) KVM_X86_OP(vm_init) +KVM_X86_OP(vm_teardown) KVM_X86_OP_NULL(vm_destroy) KVM_X86_OP(vcpu_create) KVM_X86_OP(vcpu_free) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index e3abf077f328..96e6cd95d884 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1217,6 +1217,7 @@ struct kvm_x86_ops { bool (*is_vm_type_supported)(unsigned long vm_type); unsigned int vm_size; int (*vm_init)(struct kvm *kvm); + void (*vm_teardown)(struct kvm *kvm); void (*vm_destroy)(struct kvm *kvm); /* Create, but do not attach this VCPU */ diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 286a49b09269..bcc3fc4872a3 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4416,12 +4416,17 @@ static void svm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector) sev_vcpu_deliver_sipi_vector(vcpu, vector); } -static void svm_vm_destroy(struct kvm *kvm) +static void svm_vm_teardown(struct kvm *kvm) { avic_vm_destroy(kvm); sev_vm_destroy(kvm); } +static void svm_vm_destroy(struct kvm *kvm) +{ + +} + 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)