diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2016-03-08 05:55:04 -0500 |
---|---|---|
committer | Christian Borntraeger <borntraeger@de.ibm.com> | 2016-06-20 03:53:59 -0400 |
commit | 6ea427bbbd4078297bb1dbd6c5cb83f3f48aac46 (patch) | |
tree | 7ed574fcca3cae5d6a50211d43c3d5ab21620d3a /arch/s390/kvm | |
parent | b2d73b2a0ad1c758cb0c1acb01a911744b845942 (diff) |
s390/mm: add reference counter to gmap structure
Let's use a reference counter mechanism to control the lifetime of
gmap structures. This will be needed for further changes related to
gmap shadows.
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Diffstat (limited to 'arch/s390/kvm')
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index b6e7f66f0f01..9dd52980605c 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -532,20 +532,20 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *att | |||
532 | if (!new_limit) | 532 | if (!new_limit) |
533 | return -EINVAL; | 533 | return -EINVAL; |
534 | 534 | ||
535 | /* gmap_alloc takes last usable address */ | 535 | /* gmap_create takes last usable address */ |
536 | if (new_limit != KVM_S390_NO_MEM_LIMIT) | 536 | if (new_limit != KVM_S390_NO_MEM_LIMIT) |
537 | new_limit -= 1; | 537 | new_limit -= 1; |
538 | 538 | ||
539 | ret = -EBUSY; | 539 | ret = -EBUSY; |
540 | mutex_lock(&kvm->lock); | 540 | mutex_lock(&kvm->lock); |
541 | if (!kvm->created_vcpus) { | 541 | if (!kvm->created_vcpus) { |
542 | /* gmap_alloc will round the limit up */ | 542 | /* gmap_create will round the limit up */ |
543 | struct gmap *new = gmap_alloc(current->mm, new_limit); | 543 | struct gmap *new = gmap_create(current->mm, new_limit); |
544 | 544 | ||
545 | if (!new) { | 545 | if (!new) { |
546 | ret = -ENOMEM; | 546 | ret = -ENOMEM; |
547 | } else { | 547 | } else { |
548 | gmap_free(kvm->arch.gmap); | 548 | gmap_remove(kvm->arch.gmap); |
549 | new->private = kvm; | 549 | new->private = kvm; |
550 | kvm->arch.gmap = new; | 550 | kvm->arch.gmap = new; |
551 | ret = 0; | 551 | ret = 0; |
@@ -1394,7 +1394,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) | |||
1394 | else | 1394 | else |
1395 | kvm->arch.mem_limit = min_t(unsigned long, TASK_MAX_SIZE, | 1395 | kvm->arch.mem_limit = min_t(unsigned long, TASK_MAX_SIZE, |
1396 | sclp.hamax + 1); | 1396 | sclp.hamax + 1); |
1397 | kvm->arch.gmap = gmap_alloc(current->mm, kvm->arch.mem_limit - 1); | 1397 | kvm->arch.gmap = gmap_create(current->mm, kvm->arch.mem_limit - 1); |
1398 | if (!kvm->arch.gmap) | 1398 | if (!kvm->arch.gmap) |
1399 | goto out_err; | 1399 | goto out_err; |
1400 | kvm->arch.gmap->private = kvm; | 1400 | kvm->arch.gmap->private = kvm; |
@@ -1427,7 +1427,7 @@ void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) | |||
1427 | sca_del_vcpu(vcpu); | 1427 | sca_del_vcpu(vcpu); |
1428 | 1428 | ||
1429 | if (kvm_is_ucontrol(vcpu->kvm)) | 1429 | if (kvm_is_ucontrol(vcpu->kvm)) |
1430 | gmap_free(vcpu->arch.gmap); | 1430 | gmap_remove(vcpu->arch.gmap); |
1431 | 1431 | ||
1432 | if (vcpu->kvm->arch.use_cmma) | 1432 | if (vcpu->kvm->arch.use_cmma) |
1433 | kvm_s390_vcpu_unsetup_cmma(vcpu); | 1433 | kvm_s390_vcpu_unsetup_cmma(vcpu); |
@@ -1460,7 +1460,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm) | |||
1460 | debug_unregister(kvm->arch.dbf); | 1460 | debug_unregister(kvm->arch.dbf); |
1461 | free_page((unsigned long)kvm->arch.sie_page2); | 1461 | free_page((unsigned long)kvm->arch.sie_page2); |
1462 | if (!kvm_is_ucontrol(kvm)) | 1462 | if (!kvm_is_ucontrol(kvm)) |
1463 | gmap_free(kvm->arch.gmap); | 1463 | gmap_remove(kvm->arch.gmap); |
1464 | kvm_s390_destroy_adapters(kvm); | 1464 | kvm_s390_destroy_adapters(kvm); |
1465 | kvm_s390_clear_float_irqs(kvm); | 1465 | kvm_s390_clear_float_irqs(kvm); |
1466 | KVM_EVENT(3, "vm 0x%pK destroyed", kvm); | 1466 | KVM_EVENT(3, "vm 0x%pK destroyed", kvm); |
@@ -1469,7 +1469,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm) | |||
1469 | /* Section: vcpu related */ | 1469 | /* Section: vcpu related */ |
1470 | static int __kvm_ucontrol_vcpu_init(struct kvm_vcpu *vcpu) | 1470 | static int __kvm_ucontrol_vcpu_init(struct kvm_vcpu *vcpu) |
1471 | { | 1471 | { |
1472 | vcpu->arch.gmap = gmap_alloc(current->mm, -1UL); | 1472 | vcpu->arch.gmap = gmap_create(current->mm, -1UL); |
1473 | if (!vcpu->arch.gmap) | 1473 | if (!vcpu->arch.gmap) |
1474 | return -ENOMEM; | 1474 | return -ENOMEM; |
1475 | vcpu->arch.gmap->private = vcpu->kvm; | 1475 | vcpu->arch.gmap->private = vcpu->kvm; |