diff options
author | Dominik Dingel <dingel@linux.vnet.ibm.com> | 2014-12-02 10:53:21 -0500 |
---|---|---|
committer | Christian Borntraeger <borntraeger@de.ibm.com> | 2015-01-23 07:25:30 -0500 |
commit | dafd032a15f8f165a7d10e00217d3b74f70a7b0f (patch) | |
tree | 2d9d9a572db8bdbca6c8f99fc06dcbd8812bfb15 /arch/s390/kvm | |
parent | 0675d92dcf44aafc4aa40a60d1f4316e933c030d (diff) |
KVM: s390: move vcpu specific initalization to a later point
As we will allow in a later patch to recreate gmaps with new limits,
we need to make sure that vcpus get their reference for that gmap
after they increased the online_vcpu counter, so there is no possible race.
While we are doing this, we also can simplify the vcpu_init function, by
moving ucontrol specifics to an own function.
That way we also start now setting the kvm_valid_regs for the ucontrol path.
Reviewed-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Dominik Dingel <dingel@linux.vnet.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 | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index ec004f80ee45..529f7905b341 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -546,25 +546,30 @@ void kvm_arch_destroy_vm(struct kvm *kvm) | |||
546 | } | 546 | } |
547 | 547 | ||
548 | /* Section: vcpu related */ | 548 | /* Section: vcpu related */ |
549 | static int __kvm_ucontrol_vcpu_init(struct kvm_vcpu *vcpu) | ||
550 | { | ||
551 | vcpu->arch.gmap = gmap_alloc(current->mm, -1UL); | ||
552 | if (!vcpu->arch.gmap) | ||
553 | return -ENOMEM; | ||
554 | vcpu->arch.gmap->private = vcpu->kvm; | ||
555 | |||
556 | return 0; | ||
557 | } | ||
558 | |||
549 | int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) | 559 | int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) |
550 | { | 560 | { |
551 | vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID; | 561 | vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID; |
552 | kvm_clear_async_pf_completion_queue(vcpu); | 562 | kvm_clear_async_pf_completion_queue(vcpu); |
553 | if (kvm_is_ucontrol(vcpu->kvm)) { | ||
554 | vcpu->arch.gmap = gmap_alloc(current->mm, -1UL); | ||
555 | if (!vcpu->arch.gmap) | ||
556 | return -ENOMEM; | ||
557 | vcpu->arch.gmap->private = vcpu->kvm; | ||
558 | return 0; | ||
559 | } | ||
560 | |||
561 | vcpu->arch.gmap = vcpu->kvm->arch.gmap; | ||
562 | vcpu->run->kvm_valid_regs = KVM_SYNC_PREFIX | | 563 | vcpu->run->kvm_valid_regs = KVM_SYNC_PREFIX | |
563 | KVM_SYNC_GPRS | | 564 | KVM_SYNC_GPRS | |
564 | KVM_SYNC_ACRS | | 565 | KVM_SYNC_ACRS | |
565 | KVM_SYNC_CRS | | 566 | KVM_SYNC_CRS | |
566 | KVM_SYNC_ARCH0 | | 567 | KVM_SYNC_ARCH0 | |
567 | KVM_SYNC_PFAULT; | 568 | KVM_SYNC_PFAULT; |
569 | |||
570 | if (kvm_is_ucontrol(vcpu->kvm)) | ||
571 | return __kvm_ucontrol_vcpu_init(vcpu); | ||
572 | |||
568 | return 0; | 573 | return 0; |
569 | } | 574 | } |
570 | 575 | ||
@@ -617,6 +622,8 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu) | |||
617 | 622 | ||
618 | void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) | 623 | void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) |
619 | { | 624 | { |
625 | if (!kvm_is_ucontrol(vcpu->kvm)) | ||
626 | vcpu->arch.gmap = vcpu->kvm->arch.gmap; | ||
620 | } | 627 | } |
621 | 628 | ||
622 | static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu) | 629 | static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu) |