From: Christoffer Dall <cdall@kernel.org>
To: kvm@vger.kernel.org
Cc: linux-mips@linux-mips.org, Marc Zyngier <marc.zyngier@arm.com>,
James Hogan <jhogan@kernel.org>,
Cornelia Huck <cohuck@redhat.com>,
kvm-ppc@vger.kernel.org, Paul Mackerras <paulus@ozlabs.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
linux-arm-kernel@lists.infradead.org,
Paolo Bonzini <pbonzini@redhat.com>,
linux-s390@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Subject: [PATCH v3 03/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run
Date: Mon, 04 Dec 2017 20:35:25 +0000 [thread overview]
Message-ID: <20171204203538.8370-4-cdall@kernel.org> (raw)
In-Reply-To: <20171204203538.8370-1-cdall@kernel.org>
From: Christoffer Dall <christoffer.dall@linaro.org>
Move vcpu_load() and vcpu_put() into the architecture specific
implementations of kvm_arch_vcpu_ioctl_run().
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
arch/mips/kvm/mips.c | 3 +++
arch/powerpc/kvm/powerpc.c | 6 +++++-
arch/s390/kvm/kvm-s390.c | 10 ++++++++--
arch/x86/kvm/x86.c | 3 +++
virt/kvm/arm/arm.c | 15 +++++++++++----
virt/kvm/kvm_main.c | 2 --
6 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index d535edc01434..b5c28f0730f8 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -447,6 +447,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
int r = -EINTR;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
@@ -483,6 +485,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+ vcpu_put(vcpu);
return r;
}
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 6b6c53c42ac9..c06bc9552438 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -1409,6 +1409,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
int r;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
if (vcpu->mmio_needed) {
vcpu->mmio_needed = 0;
if (!vcpu->mmio_is_write)
@@ -1423,7 +1425,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
r = kvmppc_emulate_mmio_vsx_loadstore(vcpu, run);
if (r = RESUME_HOST) {
vcpu->mmio_needed = 1;
- return r;
+ goto out;
}
}
#endif
@@ -1459,6 +1461,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+out:
+ vcpu_put(vcpu);
return r;
}
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 98ad8b9e0360..2b3e874ea76c 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -3377,9 +3377,12 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
if (kvm_run->immediate_exit)
return -EINTR;
+ vcpu_load(vcpu);
+
if (guestdbg_exit_pending(vcpu)) {
kvm_s390_prepare_debug_exit(vcpu);
- return 0;
+ rc = 0;
+ goto out;
}
if (vcpu->sigset_active)
@@ -3390,7 +3393,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
} else if (is_vcpu_stopped(vcpu)) {
pr_err_ratelimited("can't run stopped vcpu %d\n",
vcpu->vcpu_id);
- return -EINVAL;
+ rc = -EINVAL;
+ goto out;
}
sync_regs(vcpu, kvm_run);
@@ -3421,6 +3425,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
vcpu->stat.exit_userspace++;
+out:
+ vcpu_put(vcpu);
return rc;
}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9b8f864243c9..d9deb6222055 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7252,6 +7252,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
int r;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
fpu__initialize(fpu);
if (vcpu->sigset_active)
@@ -7301,6 +7303,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+ vcpu_put(vcpu);
return r;
}
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index a6524ff27de4..1f448b208686 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -620,18 +620,22 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (unlikely(!kvm_vcpu_initialized(vcpu)))
return -ENOEXEC;
+ vcpu_load(vcpu);
+
ret = kvm_vcpu_first_run_init(vcpu);
if (ret)
- return ret;
+ goto out;
if (run->exit_reason = KVM_EXIT_MMIO) {
ret = kvm_handle_mmio_return(vcpu, vcpu->run);
if (ret)
- return ret;
+ goto out;
}
- if (run->immediate_exit)
- return -EINTR;
+ if (run->immediate_exit) {
+ ret = -EINTR;
+ goto out;
+ }
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
@@ -771,6 +775,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+
+out:
+ vcpu_put(vcpu);
return ret;
}
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 480b16c48f6b..198f2f9edcaf 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2531,7 +2531,6 @@ static long kvm_vcpu_ioctl(struct file *filp,
r = -EINVAL;
if (arg)
goto out;
- vcpu_load(vcpu);
oldpid = rcu_access_pointer(vcpu->pid);
if (unlikely(oldpid != current->pids[PIDTYPE_PID].pid)) {
/* The thread running this VCPU changed. */
@@ -2543,7 +2542,6 @@ static long kvm_vcpu_ioctl(struct file *filp,
put_pid(oldpid);
}
r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
- vcpu_put(vcpu);
trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
break;
}
--
2.14.2
WARNING: multiple messages have this Message-ID (diff)
From: Christoffer Dall <cdall@kernel.org>
To: kvm@vger.kernel.org
Cc: linux-mips@linux-mips.org, Marc Zyngier <marc.zyngier@arm.com>,
James Hogan <jhogan@kernel.org>,
Cornelia Huck <cohuck@redhat.com>,
kvm-ppc@vger.kernel.org, Paul Mackerras <paulus@ozlabs.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
linux-arm-kernel@lists.infradead.org,
Paolo Bonzini <pbonzini@redhat.com>,
linux-s390@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Subject: [PATCH v3 03/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run
Date: Mon, 4 Dec 2017 21:35:25 +0100 [thread overview]
Message-ID: <20171204203538.8370-4-cdall@kernel.org> (raw)
In-Reply-To: <20171204203538.8370-1-cdall@kernel.org>
From: Christoffer Dall <christoffer.dall@linaro.org>
Move vcpu_load() and vcpu_put() into the architecture specific
implementations of kvm_arch_vcpu_ioctl_run().
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
arch/mips/kvm/mips.c | 3 +++
arch/powerpc/kvm/powerpc.c | 6 +++++-
arch/s390/kvm/kvm-s390.c | 10 ++++++++--
arch/x86/kvm/x86.c | 3 +++
virt/kvm/arm/arm.c | 15 +++++++++++----
virt/kvm/kvm_main.c | 2 --
6 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index d535edc01434..b5c28f0730f8 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -447,6 +447,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
int r = -EINTR;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
@@ -483,6 +485,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+ vcpu_put(vcpu);
return r;
}
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 6b6c53c42ac9..c06bc9552438 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -1409,6 +1409,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
int r;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
if (vcpu->mmio_needed) {
vcpu->mmio_needed = 0;
if (!vcpu->mmio_is_write)
@@ -1423,7 +1425,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
r = kvmppc_emulate_mmio_vsx_loadstore(vcpu, run);
if (r == RESUME_HOST) {
vcpu->mmio_needed = 1;
- return r;
+ goto out;
}
}
#endif
@@ -1459,6 +1461,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+out:
+ vcpu_put(vcpu);
return r;
}
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 98ad8b9e0360..2b3e874ea76c 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -3377,9 +3377,12 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
if (kvm_run->immediate_exit)
return -EINTR;
+ vcpu_load(vcpu);
+
if (guestdbg_exit_pending(vcpu)) {
kvm_s390_prepare_debug_exit(vcpu);
- return 0;
+ rc = 0;
+ goto out;
}
if (vcpu->sigset_active)
@@ -3390,7 +3393,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
} else if (is_vcpu_stopped(vcpu)) {
pr_err_ratelimited("can't run stopped vcpu %d\n",
vcpu->vcpu_id);
- return -EINVAL;
+ rc = -EINVAL;
+ goto out;
}
sync_regs(vcpu, kvm_run);
@@ -3421,6 +3425,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
vcpu->stat.exit_userspace++;
+out:
+ vcpu_put(vcpu);
return rc;
}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9b8f864243c9..d9deb6222055 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7252,6 +7252,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
int r;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
fpu__initialize(fpu);
if (vcpu->sigset_active)
@@ -7301,6 +7303,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+ vcpu_put(vcpu);
return r;
}
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index a6524ff27de4..1f448b208686 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -620,18 +620,22 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (unlikely(!kvm_vcpu_initialized(vcpu)))
return -ENOEXEC;
+ vcpu_load(vcpu);
+
ret = kvm_vcpu_first_run_init(vcpu);
if (ret)
- return ret;
+ goto out;
if (run->exit_reason == KVM_EXIT_MMIO) {
ret = kvm_handle_mmio_return(vcpu, vcpu->run);
if (ret)
- return ret;
+ goto out;
}
- if (run->immediate_exit)
- return -EINTR;
+ if (run->immediate_exit) {
+ ret = -EINTR;
+ goto out;
+ }
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
@@ -771,6 +775,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+
+out:
+ vcpu_put(vcpu);
return ret;
}
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 480b16c48f6b..198f2f9edcaf 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2531,7 +2531,6 @@ static long kvm_vcpu_ioctl(struct file *filp,
r = -EINVAL;
if (arg)
goto out;
- vcpu_load(vcpu);
oldpid = rcu_access_pointer(vcpu->pid);
if (unlikely(oldpid != current->pids[PIDTYPE_PID].pid)) {
/* The thread running this VCPU changed. */
@@ -2543,7 +2542,6 @@ static long kvm_vcpu_ioctl(struct file *filp,
put_pid(oldpid);
}
r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
- vcpu_put(vcpu);
trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
break;
}
--
2.14.2
WARNING: multiple messages have this Message-ID (diff)
From: Christoffer Dall <cdall@kernel.org>
To: kvm@vger.kernel.org
Cc: "Andrew Jones" <drjones@redhat.com>,
"Christoffer Dall" <christoffer.dall@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Marc Zyngier" <marc.zyngier@arm.com>,
kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org,
"James Hogan" <jhogan@kernel.org>,
linux-mips@linux-mips.org, "Paul Mackerras" <paulus@ozlabs.org>,
kvm-ppc@vger.kernel.org,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
"Cornelia Huck" <cohuck@redhat.com>,
linux-s390@vger.kernel.org
Subject: [PATCH v3 03/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run
Date: Mon, 4 Dec 2017 21:35:25 +0100 [thread overview]
Message-ID: <20171204203538.8370-4-cdall@kernel.org> (raw)
In-Reply-To: <20171204203538.8370-1-cdall@kernel.org>
From: Christoffer Dall <christoffer.dall@linaro.org>
Move vcpu_load() and vcpu_put() into the architecture specific
implementations of kvm_arch_vcpu_ioctl_run().
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
arch/mips/kvm/mips.c | 3 +++
arch/powerpc/kvm/powerpc.c | 6 +++++-
arch/s390/kvm/kvm-s390.c | 10 ++++++++--
arch/x86/kvm/x86.c | 3 +++
virt/kvm/arm/arm.c | 15 +++++++++++----
virt/kvm/kvm_main.c | 2 --
6 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index d535edc01434..b5c28f0730f8 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -447,6 +447,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
int r = -EINTR;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
@@ -483,6 +485,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+ vcpu_put(vcpu);
return r;
}
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 6b6c53c42ac9..c06bc9552438 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -1409,6 +1409,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
int r;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
if (vcpu->mmio_needed) {
vcpu->mmio_needed = 0;
if (!vcpu->mmio_is_write)
@@ -1423,7 +1425,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
r = kvmppc_emulate_mmio_vsx_loadstore(vcpu, run);
if (r == RESUME_HOST) {
vcpu->mmio_needed = 1;
- return r;
+ goto out;
}
}
#endif
@@ -1459,6 +1461,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+out:
+ vcpu_put(vcpu);
return r;
}
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 98ad8b9e0360..2b3e874ea76c 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -3377,9 +3377,12 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
if (kvm_run->immediate_exit)
return -EINTR;
+ vcpu_load(vcpu);
+
if (guestdbg_exit_pending(vcpu)) {
kvm_s390_prepare_debug_exit(vcpu);
- return 0;
+ rc = 0;
+ goto out;
}
if (vcpu->sigset_active)
@@ -3390,7 +3393,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
} else if (is_vcpu_stopped(vcpu)) {
pr_err_ratelimited("can't run stopped vcpu %d\n",
vcpu->vcpu_id);
- return -EINVAL;
+ rc = -EINVAL;
+ goto out;
}
sync_regs(vcpu, kvm_run);
@@ -3421,6 +3425,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
vcpu->stat.exit_userspace++;
+out:
+ vcpu_put(vcpu);
return rc;
}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9b8f864243c9..d9deb6222055 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7252,6 +7252,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
int r;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
fpu__initialize(fpu);
if (vcpu->sigset_active)
@@ -7301,6 +7303,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+ vcpu_put(vcpu);
return r;
}
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index a6524ff27de4..1f448b208686 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -620,18 +620,22 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (unlikely(!kvm_vcpu_initialized(vcpu)))
return -ENOEXEC;
+ vcpu_load(vcpu);
+
ret = kvm_vcpu_first_run_init(vcpu);
if (ret)
- return ret;
+ goto out;
if (run->exit_reason == KVM_EXIT_MMIO) {
ret = kvm_handle_mmio_return(vcpu, vcpu->run);
if (ret)
- return ret;
+ goto out;
}
- if (run->immediate_exit)
- return -EINTR;
+ if (run->immediate_exit) {
+ ret = -EINTR;
+ goto out;
+ }
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
@@ -771,6 +775,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+
+out:
+ vcpu_put(vcpu);
return ret;
}
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 480b16c48f6b..198f2f9edcaf 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2531,7 +2531,6 @@ static long kvm_vcpu_ioctl(struct file *filp,
r = -EINVAL;
if (arg)
goto out;
- vcpu_load(vcpu);
oldpid = rcu_access_pointer(vcpu->pid);
if (unlikely(oldpid != current->pids[PIDTYPE_PID].pid)) {
/* The thread running this VCPU changed. */
@@ -2543,7 +2542,6 @@ static long kvm_vcpu_ioctl(struct file *filp,
put_pid(oldpid);
}
r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
- vcpu_put(vcpu);
trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
break;
}
--
2.14.2
WARNING: multiple messages have this Message-ID (diff)
From: cdall@kernel.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 03/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run
Date: Mon, 4 Dec 2017 21:35:25 +0100 [thread overview]
Message-ID: <20171204203538.8370-4-cdall@kernel.org> (raw)
In-Reply-To: <20171204203538.8370-1-cdall@kernel.org>
From: Christoffer Dall <christoffer.dall@linaro.org>
Move vcpu_load() and vcpu_put() into the architecture specific
implementations of kvm_arch_vcpu_ioctl_run().
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
arch/mips/kvm/mips.c | 3 +++
arch/powerpc/kvm/powerpc.c | 6 +++++-
arch/s390/kvm/kvm-s390.c | 10 ++++++++--
arch/x86/kvm/x86.c | 3 +++
virt/kvm/arm/arm.c | 15 +++++++++++----
virt/kvm/kvm_main.c | 2 --
6 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index d535edc01434..b5c28f0730f8 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -447,6 +447,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
int r = -EINTR;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
@@ -483,6 +485,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+ vcpu_put(vcpu);
return r;
}
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 6b6c53c42ac9..c06bc9552438 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -1409,6 +1409,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
int r;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
if (vcpu->mmio_needed) {
vcpu->mmio_needed = 0;
if (!vcpu->mmio_is_write)
@@ -1423,7 +1425,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
r = kvmppc_emulate_mmio_vsx_loadstore(vcpu, run);
if (r == RESUME_HOST) {
vcpu->mmio_needed = 1;
- return r;
+ goto out;
}
}
#endif
@@ -1459,6 +1461,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+out:
+ vcpu_put(vcpu);
return r;
}
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 98ad8b9e0360..2b3e874ea76c 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -3377,9 +3377,12 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
if (kvm_run->immediate_exit)
return -EINTR;
+ vcpu_load(vcpu);
+
if (guestdbg_exit_pending(vcpu)) {
kvm_s390_prepare_debug_exit(vcpu);
- return 0;
+ rc = 0;
+ goto out;
}
if (vcpu->sigset_active)
@@ -3390,7 +3393,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
} else if (is_vcpu_stopped(vcpu)) {
pr_err_ratelimited("can't run stopped vcpu %d\n",
vcpu->vcpu_id);
- return -EINVAL;
+ rc = -EINVAL;
+ goto out;
}
sync_regs(vcpu, kvm_run);
@@ -3421,6 +3425,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
vcpu->stat.exit_userspace++;
+out:
+ vcpu_put(vcpu);
return rc;
}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9b8f864243c9..d9deb6222055 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7252,6 +7252,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
int r;
sigset_t sigsaved;
+ vcpu_load(vcpu);
+
fpu__initialize(fpu);
if (vcpu->sigset_active)
@@ -7301,6 +7303,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+ vcpu_put(vcpu);
return r;
}
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index a6524ff27de4..1f448b208686 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -620,18 +620,22 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (unlikely(!kvm_vcpu_initialized(vcpu)))
return -ENOEXEC;
+ vcpu_load(vcpu);
+
ret = kvm_vcpu_first_run_init(vcpu);
if (ret)
- return ret;
+ goto out;
if (run->exit_reason == KVM_EXIT_MMIO) {
ret = kvm_handle_mmio_return(vcpu, vcpu->run);
if (ret)
- return ret;
+ goto out;
}
- if (run->immediate_exit)
- return -EINTR;
+ if (run->immediate_exit) {
+ ret = -EINTR;
+ goto out;
+ }
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
@@ -771,6 +775,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+
+out:
+ vcpu_put(vcpu);
return ret;
}
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 480b16c48f6b..198f2f9edcaf 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2531,7 +2531,6 @@ static long kvm_vcpu_ioctl(struct file *filp,
r = -EINVAL;
if (arg)
goto out;
- vcpu_load(vcpu);
oldpid = rcu_access_pointer(vcpu->pid);
if (unlikely(oldpid != current->pids[PIDTYPE_PID].pid)) {
/* The thread running this VCPU changed. */
@@ -2543,7 +2542,6 @@ static long kvm_vcpu_ioctl(struct file *filp,
put_pid(oldpid);
}
r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
- vcpu_put(vcpu);
trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
break;
}
--
2.14.2
next prev parent reply other threads:[~2017-12-04 20:35 UTC|newest]
Thread overview: 152+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-04 20:35 [PATCH v3 00/16] Move vcpu_load and vcpu_put calls to arch code Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` [PATCH v3 01/16] KVM: Take vcpu->mutex outside vcpu_load Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-05 14:32 ` Christian Borntraeger
2017-12-05 14:32 ` Christian Borntraeger
2017-12-05 14:32 ` Christian Borntraeger
2017-12-11 11:51 ` Cornelia Huck
2017-12-11 11:51 ` Cornelia Huck
2017-12-11 11:51 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 02/16] KVM: Prepare for moving vcpu_load/vcpu_put into arch specific code Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-11 11:57 ` Cornelia Huck
2017-12-11 11:57 ` Cornelia Huck
2017-12-11 11:57 ` Cornelia Huck
2017-12-04 20:35 ` Christoffer Dall [this message]
2017-12-04 20:35 ` [PATCH v3 03/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-05 14:39 ` Christian Borntraeger
2017-12-05 14:39 ` Christian Borntraeger
2017-12-05 14:39 ` Christian Borntraeger
2017-12-11 12:02 ` Cornelia Huck
2017-12-11 12:02 ` Cornelia Huck
2017-12-11 12:02 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 04/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_regs Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-08 16:21 ` David Hildenbrand
2017-12-08 16:21 ` David Hildenbrand
2017-12-08 16:21 ` David Hildenbrand
2017-12-11 12:07 ` Cornelia Huck
2017-12-11 12:07 ` Cornelia Huck
2017-12-11 12:07 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 05/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_regs Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-08 16:22 ` David Hildenbrand
2017-12-08 16:22 ` David Hildenbrand
2017-12-08 16:22 ` David Hildenbrand
2017-12-08 16:22 ` David Hildenbrand
2017-12-11 12:09 ` Cornelia Huck
2017-12-11 12:09 ` Cornelia Huck
2017-12-11 12:09 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 06/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_sregs Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-08 16:23 ` David Hildenbrand
2017-12-08 16:23 ` David Hildenbrand
2017-12-08 16:23 ` David Hildenbrand
2017-12-11 12:13 ` Cornelia Huck
2017-12-11 12:13 ` Cornelia Huck
2017-12-11 12:13 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 07/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_sregs Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-08 16:26 ` David Hildenbrand
2017-12-08 16:26 ` David Hildenbrand
2017-12-08 16:26 ` David Hildenbrand
2017-12-11 9:19 ` Christoffer Dall
2017-12-11 9:19 ` Christoffer Dall
2017-12-11 9:19 ` Christoffer Dall
2017-12-11 9:19 ` Christoffer Dall
2017-12-12 16:33 ` Paolo Bonzini
2017-12-12 16:33 ` Paolo Bonzini
2017-12-12 16:33 ` Paolo Bonzini
2017-12-12 16:33 ` Paolo Bonzini
2017-12-11 12:15 ` Cornelia Huck
2017-12-11 12:15 ` Cornelia Huck
2017-12-11 12:15 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 08/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_mpstate Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-11 12:23 ` Cornelia Huck
2017-12-11 12:23 ` Cornelia Huck
2017-12-11 12:23 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 09/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_mpstate Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-11 12:25 ` Cornelia Huck
2017-12-11 12:25 ` Cornelia Huck
2017-12-11 12:25 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 10/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_translate Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-11 12:29 ` Cornelia Huck
2017-12-11 12:29 ` Cornelia Huck
2017-12-11 12:29 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 11/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_guest_debug Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-11 12:39 ` Cornelia Huck
2017-12-11 12:39 ` Cornelia Huck
2017-12-11 12:39 ` Cornelia Huck
2017-12-11 12:39 ` Cornelia Huck
2017-12-11 15:18 ` Christoffer Dall
2017-12-11 15:18 ` Christoffer Dall
2017-12-11 15:18 ` Christoffer Dall
2017-12-11 15:18 ` Christoffer Dall
2017-12-12 16:36 ` Paolo Bonzini
2017-12-12 16:36 ` Paolo Bonzini
2017-12-12 16:36 ` Paolo Bonzini
2017-12-04 20:35 ` [PATCH v3 12/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_fpu Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-11 12:43 ` Cornelia Huck
2017-12-11 12:43 ` Cornelia Huck
2017-12-11 12:43 ` Cornelia Huck
2017-12-11 12:43 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 13/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_fpu Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-11 12:45 ` Cornelia Huck
2017-12-11 12:45 ` Cornelia Huck
2017-12-11 12:45 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 14/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-11 13:12 ` Cornelia Huck
2017-12-11 13:12 ` Cornelia Huck
2017-12-11 13:12 ` Cornelia Huck
2017-12-11 15:22 ` Christoffer Dall
2017-12-11 15:22 ` Christoffer Dall
2017-12-11 15:22 ` Christoffer Dall
2017-12-12 16:47 ` Paolo Bonzini
2017-12-12 16:47 ` Paolo Bonzini
2017-12-12 16:47 ` Paolo Bonzini
2017-12-04 20:35 ` [PATCH v3 15/16] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` [PATCH v3 16/16] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
2017-12-04 20:35 ` Christoffer Dall
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=20171204203538.8370-4-cdall@kernel.org \
--to=cdall@kernel.org \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=jhogan@kernel.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-s390@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=paulus@ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.