Skip to content

Commit 0dab98b

Browse files
Sean Christophersonbonzini
authored andcommitted
KVM: x86: Allocate memslot resources during prepare_memory_region()
Allocate the various metadata structures associated with a new memslot during kvm_arch_prepare_memory_region(), which paves the way for removing kvm_arch_create_memslot() altogether. Moving x86's memory allocation only changes the order of kernel memory allocations between x86 and common KVM code. 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>
1 parent 82307e6 commit 0dab98b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

arch/x86/kvm/x86.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9875,6 +9875,12 @@ void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
98759875

98769876
int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
98779877
unsigned long npages)
9878+
{
9879+
return 0;
9880+
}
9881+
9882+
static int kvm_alloc_memslot_metadata(struct kvm_memory_slot *slot,
9883+
unsigned long npages)
98789884
{
98799885
int i;
98809886

@@ -9966,10 +9972,9 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
99669972
const struct kvm_userspace_memory_region *mem,
99679973
enum kvm_mr_change change)
99689974
{
9969-
if (change == KVM_MR_MOVE)
9970-
return kvm_arch_create_memslot(kvm, memslot,
9971-
mem->memory_size >> PAGE_SHIFT);
9972-
9975+
if (change == KVM_MR_CREATE || change == KVM_MR_MOVE)
9976+
return kvm_alloc_memslot_metadata(memslot,
9977+
mem->memory_size >> PAGE_SHIFT);
99739978
return 0;
99749979
}
99759980

0 commit comments

Comments
 (0)