]>
Commit | Line | Data |
---|---|---|
1aa7b030 SL |
1 | From 78e1a6eecafb6c58c0cd4b1455c9ba17345f0fc7 Mon Sep 17 00:00:00 2001 |
2 | From: Andrew Jones <drjones@redhat.com> | |
3 | Date: Thu, 4 Apr 2019 19:42:30 +0200 | |
4 | Subject: KVM: arm/arm64: Ensure vcpu target is unset on reset failure | |
5 | ||
6 | [ Upstream commit 811328fc3222f7b55846de0cd0404339e2e1e6d7 ] | |
7 | ||
8 | A failed KVM_ARM_VCPU_INIT should not set the vcpu target, | |
9 | as the vcpu target is used by kvm_vcpu_initialized() to | |
10 | determine if other vcpu ioctls may proceed. We need to set | |
11 | the target before calling kvm_reset_vcpu(), but if that call | |
12 | fails, we should then unset it and clear the feature bitmap | |
13 | while we're at it. | |
14 | ||
15 | Signed-off-by: Andrew Jones <drjones@redhat.com> | |
16 | [maz: Simplified patch, completed commit message] | |
17 | Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> | |
18 | Signed-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) |