]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.4/kvm-arm-arm64-ensure-vcpu-target-is-unset-on-reset-f.patch
drop rdma-cma-consider-scope_id-while-binding-to-ipv6-ll-.patch from 4.4, 4.9, and...
[thirdparty/kernel/stable-queue.git] / queue-4.4 / kvm-arm-arm64-ensure-vcpu-target-is-unset-on-reset-f.patch
CommitLineData
1aa7b030
SL
1From 78e1a6eecafb6c58c0cd4b1455c9ba17345f0fc7 Mon Sep 17 00:00:00 2001
2From: Andrew Jones <drjones@redhat.com>
3Date: Thu, 4 Apr 2019 19:42:30 +0200
4Subject: KVM: arm/arm64: Ensure vcpu target is unset on reset failure
5
6[ Upstream commit 811328fc3222f7b55846de0cd0404339e2e1e6d7 ]
7
8A failed KVM_ARM_VCPU_INIT should not set the vcpu target,
9as the vcpu target is used by kvm_vcpu_initialized() to
10determine if other vcpu ioctls may proceed. We need to set
11the target before calling kvm_reset_vcpu(), but if that call
12fails, we should then unset it and clear the feature bitmap
13while we're at it.
14
15Signed-off-by: Andrew Jones <drjones@redhat.com>
16[maz: Simplified patch, completed commit message]
17Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
18Signed-off-by: Sasha Levin <sashal@kernel.org>
19---
811ef891 20 arch/arm/kvm/arm.c | 11 ++++++++---
1aa7b030
SL
21 1 file changed, 8 insertions(+), 3 deletions(-)
22
1aa7b030
SL
23--- a/arch/arm/kvm/arm.c
24+++ b/arch/arm/kvm/arm.c
811ef891 25@@ -744,7 +744,7 @@ int kvm_vm_ioctl_irq_line(struct kvm *kv
1aa7b030
SL
26 static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
27 const struct kvm_vcpu_init *init)
28 {
29- unsigned int i;
30+ unsigned int i, ret;
31 int phys_target = kvm_target_cpu();
32
33 if (init->target != phys_target)
811ef891 34@@ -779,9 +779,14 @@ static int kvm_vcpu_set_target(struct kv
1aa7b030
SL
35 vcpu->arch.target = phys_target;
36
37 /* Now we know what it is, we can reset it. */
38- return kvm_reset_vcpu(vcpu);
39-}
40+ ret = kvm_reset_vcpu(vcpu);
41+ if (ret) {
42+ vcpu->arch.target = -1;
43+ bitmap_zero(vcpu->arch.features, KVM_VCPU_MAX_FEATURES);
44+ }
45
46+ return ret;
47+}
48
49 static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu,
50 struct kvm_vcpu_init *init)