forked from luck/tmp_suning_uos_patched
KVM: Simplify kvm_free_memslot() and all its descendents
Now that all callers of kvm_free_memslot() pass NULL for @dont, remove the param from the top-level routine and all arch's implementations. No functional change intended. Tested-by: Christoffer Dall <christoffer.dall@arm.com> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
5c0b4f3d5c
commit
e96c81ee89
|
@ -1133,7 +1133,7 @@ extern unsigned long kvm_mips_get_ramsize(struct kvm *kvm);
|
|||
static inline void kvm_arch_hardware_unsetup(void) {}
|
||||
static inline void kvm_arch_sync_events(struct kvm *kvm) {}
|
||||
static inline void kvm_arch_free_memslot(struct kvm *kvm,
|
||||
struct kvm_memory_slot *free, struct kvm_memory_slot *dont) {}
|
||||
struct kvm_memory_slot *slot) {}
|
||||
static inline void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen) {}
|
||||
static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {}
|
||||
static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu) {}
|
||||
|
|
|
@ -200,8 +200,7 @@ extern void kvm_free_hpt_cma(struct page *page, unsigned long nr_pages);
|
|||
extern int kvmppc_core_init_vm(struct kvm *kvm);
|
||||
extern void kvmppc_core_destroy_vm(struct kvm *kvm);
|
||||
extern void kvmppc_core_free_memslot(struct kvm *kvm,
|
||||
struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont);
|
||||
struct kvm_memory_slot *slot);
|
||||
extern int kvmppc_core_prepare_memory_region(struct kvm *kvm,
|
||||
struct kvm_memory_slot *memslot,
|
||||
const struct kvm_userspace_memory_region *mem,
|
||||
|
@ -291,8 +290,7 @@ struct kvmppc_ops {
|
|||
int (*test_age_hva)(struct kvm *kvm, unsigned long hva);
|
||||
void (*set_spte_hva)(struct kvm *kvm, unsigned long hva, pte_t pte);
|
||||
void (*mmu_destroy)(struct kvm_vcpu *vcpu);
|
||||
void (*free_memslot)(struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont);
|
||||
void (*free_memslot)(struct kvm_memory_slot *slot);
|
||||
int (*init_vm)(struct kvm *kvm);
|
||||
void (*destroy_vm)(struct kvm *kvm);
|
||||
int (*get_smmu_info)(struct kvm *kvm, struct kvm_ppc_smmu_info *info);
|
||||
|
|
|
@ -804,10 +804,9 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log)
|
|||
return kvm->arch.kvm_ops->get_dirty_log(kvm, log);
|
||||
}
|
||||
|
||||
void kvmppc_core_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont)
|
||||
void kvmppc_core_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot)
|
||||
{
|
||||
kvm->arch.kvm_ops->free_memslot(free, dont);
|
||||
kvm->arch.kvm_ops->free_memslot(slot);
|
||||
}
|
||||
|
||||
void kvmppc_core_flush_memslot(struct kvm *kvm, struct kvm_memory_slot *memslot)
|
||||
|
|
|
@ -4447,13 +4447,10 @@ static int kvm_vm_ioctl_get_dirty_log_hv(struct kvm *kvm,
|
|||
return r;
|
||||
}
|
||||
|
||||
static void kvmppc_core_free_memslot_hv(struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont)
|
||||
static void kvmppc_core_free_memslot_hv(struct kvm_memory_slot *slot)
|
||||
{
|
||||
if (!dont || free->arch.rmap != dont->arch.rmap) {
|
||||
vfree(free->arch.rmap);
|
||||
free->arch.rmap = NULL;
|
||||
}
|
||||
vfree(slot->arch.rmap);
|
||||
slot->arch.rmap = NULL;
|
||||
}
|
||||
|
||||
static int kvmppc_core_prepare_memory_region_hv(struct kvm *kvm,
|
||||
|
|
|
@ -1942,8 +1942,7 @@ static void kvmppc_core_commit_memory_region_pr(struct kvm *kvm,
|
|||
return;
|
||||
}
|
||||
|
||||
static void kvmppc_core_free_memslot_pr(struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont)
|
||||
static void kvmppc_core_free_memslot_pr(struct kvm_memory_slot *slot)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1771,8 +1771,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log)
|
|||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
void kvmppc_core_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont)
|
||||
void kvmppc_core_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -685,10 +685,9 @@ long kvm_arch_dev_ioctl(struct file *filp,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont)
|
||||
void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot)
|
||||
{
|
||||
kvmppc_core_free_memslot(kvm, free, dont);
|
||||
kvmppc_core_free_memslot(kvm, slot);
|
||||
}
|
||||
|
||||
int kvm_arch_prepare_memory_region(struct kvm *kvm,
|
||||
|
|
|
@ -921,7 +921,7 @@ static inline void kvm_arch_hardware_disable(void) {}
|
|||
static inline void kvm_arch_sync_events(struct kvm *kvm) {}
|
||||
static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {}
|
||||
static inline void kvm_arch_free_memslot(struct kvm *kvm,
|
||||
struct kvm_memory_slot *free, struct kvm_memory_slot *dont) {}
|
||||
struct kvm_memory_slot *slot) {}
|
||||
static inline void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen) {}
|
||||
static inline void kvm_arch_flush_shadow_all(struct kvm *kvm) {}
|
||||
static inline void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
|
||||
|
|
|
@ -49,8 +49,7 @@ struct kvm_page_track_notifier_node {
|
|||
void kvm_page_track_init(struct kvm *kvm);
|
||||
void kvm_page_track_cleanup(struct kvm *kvm);
|
||||
|
||||
void kvm_page_track_free_memslot(struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont);
|
||||
void kvm_page_track_free_memslot(struct kvm_memory_slot *slot);
|
||||
int kvm_page_track_create_memslot(struct kvm_memory_slot *slot,
|
||||
unsigned long npages);
|
||||
|
||||
|
|
|
@ -19,16 +19,13 @@
|
|||
|
||||
#include "mmu.h"
|
||||
|
||||
void kvm_page_track_free_memslot(struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont)
|
||||
void kvm_page_track_free_memslot(struct kvm_memory_slot *slot)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < KVM_PAGE_TRACK_MAX; i++)
|
||||
if (!dont || free->arch.gfn_track[i] !=
|
||||
dont->arch.gfn_track[i]) {
|
||||
kvfree(free->arch.gfn_track[i]);
|
||||
free->arch.gfn_track[i] = NULL;
|
||||
for (i = 0; i < KVM_PAGE_TRACK_MAX; i++) {
|
||||
kvfree(slot->arch.gfn_track[i]);
|
||||
slot->arch.gfn_track[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +45,7 @@ int kvm_page_track_create_memslot(struct kvm_memory_slot *slot,
|
|||
return 0;
|
||||
|
||||
track_free:
|
||||
kvm_page_track_free_memslot(slot, NULL);
|
||||
kvm_page_track_free_memslot(slot);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
|
|
@ -9850,27 +9850,22 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
|
|||
kvm_hv_destroy_vm(kvm);
|
||||
}
|
||||
|
||||
void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont)
|
||||
void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < KVM_NR_PAGE_SIZES; ++i) {
|
||||
if (!dont || free->arch.rmap[i] != dont->arch.rmap[i]) {
|
||||
kvfree(free->arch.rmap[i]);
|
||||
free->arch.rmap[i] = NULL;
|
||||
}
|
||||
kvfree(slot->arch.rmap[i]);
|
||||
slot->arch.rmap[i] = NULL;
|
||||
|
||||
if (i == 0)
|
||||
continue;
|
||||
|
||||
if (!dont || free->arch.lpage_info[i - 1] !=
|
||||
dont->arch.lpage_info[i - 1]) {
|
||||
kvfree(free->arch.lpage_info[i - 1]);
|
||||
free->arch.lpage_info[i - 1] = NULL;
|
||||
}
|
||||
kvfree(slot->arch.lpage_info[i - 1]);
|
||||
slot->arch.lpage_info[i - 1] = NULL;
|
||||
}
|
||||
|
||||
kvm_page_track_free_memslot(free, dont);
|
||||
kvm_page_track_free_memslot(slot);
|
||||
}
|
||||
|
||||
static int kvm_alloc_memslot_metadata(struct kvm_memory_slot *slot,
|
||||
|
@ -10069,7 +10064,7 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
|
|||
|
||||
/* Free the arrays associated with the old memslot. */
|
||||
if (change == KVM_MR_MOVE)
|
||||
kvm_arch_free_memslot(kvm, old, NULL);
|
||||
kvm_arch_free_memslot(kvm, old);
|
||||
}
|
||||
|
||||
void kvm_arch_flush_shadow_all(struct kvm *kvm)
|
||||
|
|
|
@ -669,8 +669,7 @@ int kvm_set_memory_region(struct kvm *kvm,
|
|||
const struct kvm_userspace_memory_region *mem);
|
||||
int __kvm_set_memory_region(struct kvm *kvm,
|
||||
const struct kvm_userspace_memory_region *mem);
|
||||
void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont);
|
||||
void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot);
|
||||
void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen);
|
||||
int kvm_arch_prepare_memory_region(struct kvm *kvm,
|
||||
struct kvm_memory_slot *memslot,
|
||||
|
|
|
@ -2349,8 +2349,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
|
|||
return ret;
|
||||
}
|
||||
|
||||
void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont)
|
||||
void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -580,18 +580,14 @@ static void kvm_destroy_dirty_bitmap(struct kvm_memory_slot *memslot)
|
|||
memslot->dirty_bitmap = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free any memory in @free but not in @dont.
|
||||
*/
|
||||
static void kvm_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
|
||||
struct kvm_memory_slot *dont)
|
||||
static void kvm_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot)
|
||||
{
|
||||
if (!dont || free->dirty_bitmap != dont->dirty_bitmap)
|
||||
kvm_destroy_dirty_bitmap(free);
|
||||
kvm_destroy_dirty_bitmap(slot);
|
||||
|
||||
kvm_arch_free_memslot(kvm, free, dont);
|
||||
kvm_arch_free_memslot(kvm, slot);
|
||||
|
||||
free->npages = 0;
|
||||
slot->flags = 0;
|
||||
slot->npages = 0;
|
||||
}
|
||||
|
||||
static void kvm_free_memslots(struct kvm *kvm, struct kvm_memslots *slots)
|
||||
|
@ -602,7 +598,7 @@ static void kvm_free_memslots(struct kvm *kvm, struct kvm_memslots *slots)
|
|||
return;
|
||||
|
||||
kvm_for_each_memslot(memslot, slots)
|
||||
kvm_free_memslot(kvm, memslot, NULL);
|
||||
kvm_free_memslot(kvm, memslot);
|
||||
|
||||
kvfree(slots);
|
||||
}
|
||||
|
@ -1060,7 +1056,7 @@ static int kvm_delete_memslot(struct kvm *kvm,
|
|||
if (r)
|
||||
return r;
|
||||
|
||||
kvm_free_memslot(kvm, old, NULL);
|
||||
kvm_free_memslot(kvm, old);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user