From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: KVM <kvm@vger.kernel.org>,
linux-s390 <linux-s390@vger.kernel.org>,
Dominik Dingel <dingel@linux.vnet.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>
Subject: [PATCH/RFC 03/21] KVM: s390: move vcpu specific initalization to a later point
Date: Thu, 15 Jan 2015 14:43:16 +0100 [thread overview]
Message-ID: <1421329414-76826-4-git-send-email-borntraeger@de.ibm.com> (raw)
In-Reply-To: <1421329414-76826-1-git-send-email-borntraeger@de.ibm.com>
From: Dominik Dingel <dingel@linux.vnet.ibm.com>
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>
---
arch/s390/kvm/kvm-s390.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index ec004f8..529f7905 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)
}
/* Section: vcpu related */
+static int __kvm_ucontrol_vcpu_init(struct kvm_vcpu *vcpu)
+{
+ vcpu->arch.gmap = gmap_alloc(current->mm, -1UL);
+ if (!vcpu->arch.gmap)
+ return -ENOMEM;
+ vcpu->arch.gmap->private = vcpu->kvm;
+
+ return 0;
+}
+
int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
{
vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID;
kvm_clear_async_pf_completion_queue(vcpu);
- if (kvm_is_ucontrol(vcpu->kvm)) {
- vcpu->arch.gmap = gmap_alloc(current->mm, -1UL);
- if (!vcpu->arch.gmap)
- return -ENOMEM;
- vcpu->arch.gmap->private = vcpu->kvm;
- return 0;
- }
-
- vcpu->arch.gmap = vcpu->kvm->arch.gmap;
vcpu->run->kvm_valid_regs = KVM_SYNC_PREFIX |
KVM_SYNC_GPRS |
KVM_SYNC_ACRS |
KVM_SYNC_CRS |
KVM_SYNC_ARCH0 |
KVM_SYNC_PFAULT;
+
+ if (kvm_is_ucontrol(vcpu->kvm))
+ return __kvm_ucontrol_vcpu_init(vcpu);
+
return 0;
}
@@ -617,6 +622,8 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu)
void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
{
+ if (!kvm_is_ucontrol(vcpu->kvm))
+ vcpu->arch.gmap = vcpu->kvm->arch.gmap;
}
static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu)
--
1.9.3
next prev parent reply other threads:[~2015-01-15 13:43 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-15 13:43 [PATCH/RFC 00/21] KVM: s390: fixes and features for kvm/next (3.20) Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 01/21] KVM: remove unneeded return value of vcpu_postcreate Christian Borntraeger
2015-01-22 16:55 ` Paolo Bonzini
2015-01-15 13:43 ` [PATCH/RFC 02/21] KVM: s390: make local function static Christian Borntraeger
2015-01-15 13:43 ` Christian Borntraeger [this message]
2015-01-15 13:43 ` [PATCH/RFC 04/21] KVM: s390: Allow userspace to limit guest memory size Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 05/21] KVM: s390: prevent sleep duration underflows in handle_wait() Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 06/21] KVM: s390: base hrtimer on a monotonic clock Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 07/21] KVM: s390: forward hrtimer if guest ckc not pending yet Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 08/21] KVM: s390: new parameter for SIGP STOP irqs Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 09/21] KVM: s390: handle stop irqs without action_bits Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 10/21] KVM: s390: a VCPU may only stop when no interrupts are left pending Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 11/21] KVM: s390: SIGP SET PREFIX cleanup Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 12/21] s390/sclp: introduce check for the SIGP Interpretation Facility Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 13/21] KVM: s390: only one external call may be pending at a time Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 14/21] KVM: s390: clear the pfault queue if user space sets the invalid token Christian Borntraeger
2015-01-17 10:50 ` Heiko Carstens
2015-01-19 8:19 ` Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 15/21] KVM: s390: forward most SIGP orders to user space Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 16/21] KVM: s390: no need to hold the kvm->mutex for floating interrupts Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 17/21] KVM: s390: Take addressing mode into account for MVPG interception Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 18/21] KVM: s390: fix bug in sigp emergency signal injection Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 19/21] KVM: s390: trace correct values for set prefix and machine checks Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 20/21] KVM: s390: Provide guest TOD Clock Get/Set Controls Christian Borntraeger
2015-01-15 13:43 ` [PATCH/RFC 21/21] KVM: s390/cpacf: Enable/disable protected key functions for kvm guest Christian Borntraeger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1421329414-76826-4-git-send-email-borntraeger@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=dingel@linux.vnet.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox