Commit 78b497f2 authored by Juergen Gross's avatar Juergen Gross Committed by Paolo Bonzini

kvm: use kvfree() in kvm_arch_free_vm()

By switching from kfree() to kvfree() in kvm_arch_free_vm() Arm64 can
use the common variant. This can be accomplished by adding another
macro __KVM_HAVE_ARCH_VM_FREE, which will be used only by x86 for now.

Further simplification can be achieved by adding __kvm_arch_free_vm()
doing the common part.
Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Message-Id: <20210903130808.30142-5-jgross@suse.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent b73a5432
...@@ -771,7 +771,6 @@ int kvm_set_ipa_limit(void); ...@@ -771,7 +771,6 @@ int kvm_set_ipa_limit(void);
#define __KVM_HAVE_ARCH_VM_ALLOC #define __KVM_HAVE_ARCH_VM_ALLOC
struct kvm *kvm_arch_alloc_vm(void); struct kvm *kvm_arch_alloc_vm(void);
void kvm_arch_free_vm(struct kvm *kvm);
int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type); int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type);
......
...@@ -297,14 +297,6 @@ struct kvm *kvm_arch_alloc_vm(void) ...@@ -297,14 +297,6 @@ struct kvm *kvm_arch_alloc_vm(void)
return vzalloc(sizeof(struct kvm)); return vzalloc(sizeof(struct kvm));
} }
void kvm_arch_free_vm(struct kvm *kvm)
{
if (!has_vhe())
kfree(kvm);
else
vfree(kvm);
}
int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id) int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id)
{ {
if (irqchip_in_kernel(kvm) && vgic_initialized(kvm)) if (irqchip_in_kernel(kvm) && vgic_initialized(kvm))
......
...@@ -1540,6 +1540,8 @@ static inline struct kvm *kvm_arch_alloc_vm(void) ...@@ -1540,6 +1540,8 @@ static inline struct kvm *kvm_arch_alloc_vm(void)
{ {
return __vmalloc(kvm_x86_ops.vm_size, GFP_KERNEL_ACCOUNT | __GFP_ZERO); return __vmalloc(kvm_x86_ops.vm_size, GFP_KERNEL_ACCOUNT | __GFP_ZERO);
} }
#define __KVM_HAVE_ARCH_VM_FREE
void kvm_arch_free_vm(struct kvm *kvm); void kvm_arch_free_vm(struct kvm *kvm);
#define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLB #define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLB
......
...@@ -11130,7 +11130,7 @@ void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) ...@@ -11130,7 +11130,7 @@ void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu)
void kvm_arch_free_vm(struct kvm *kvm) void kvm_arch_free_vm(struct kvm *kvm)
{ {
kfree(to_kvm_hv(kvm)->hv_pa_pg); kfree(to_kvm_hv(kvm)->hv_pa_pg);
vfree(kvm); __kvm_arch_free_vm(kvm);
} }
......
...@@ -1081,10 +1081,17 @@ static inline struct kvm *kvm_arch_alloc_vm(void) ...@@ -1081,10 +1081,17 @@ static inline struct kvm *kvm_arch_alloc_vm(void)
{ {
return kzalloc(sizeof(struct kvm), GFP_KERNEL); return kzalloc(sizeof(struct kvm), GFP_KERNEL);
} }
#endif
static inline void __kvm_arch_free_vm(struct kvm *kvm)
{
kvfree(kvm);
}
#ifndef __KVM_HAVE_ARCH_VM_FREE
static inline void kvm_arch_free_vm(struct kvm *kvm) static inline void kvm_arch_free_vm(struct kvm *kvm)
{ {
kfree(kvm); __kvm_arch_free_vm(kvm);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment