aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kvm/psci.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/kvm/psci.c')
-rw-r--r--arch/arm/kvm/psci.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c
index 86a693a02ba3..0881bf169fbc 100644
--- a/arch/arm/kvm/psci.c
+++ b/arch/arm/kvm/psci.c
@@ -18,6 +18,7 @@
18#include <linux/kvm_host.h> 18#include <linux/kvm_host.h>
19#include <linux/wait.h> 19#include <linux/wait.h>
20 20
21#include <asm/cputype.h>
21#include <asm/kvm_emulate.h> 22#include <asm/kvm_emulate.h>
22#include <asm/kvm_psci.h> 23#include <asm/kvm_psci.h>
23 24
@@ -34,22 +35,30 @@ static void kvm_psci_vcpu_off(struct kvm_vcpu *vcpu)
34static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) 35static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
35{ 36{
36 struct kvm *kvm = source_vcpu->kvm; 37 struct kvm *kvm = source_vcpu->kvm;
37 struct kvm_vcpu *vcpu; 38 struct kvm_vcpu *vcpu = NULL, *tmp;
38 wait_queue_head_t *wq; 39 wait_queue_head_t *wq;
39 unsigned long cpu_id; 40 unsigned long cpu_id;
41 unsigned long mpidr;
40 phys_addr_t target_pc; 42 phys_addr_t target_pc;
43 int i;
41 44
42 cpu_id = *vcpu_reg(source_vcpu, 1); 45 cpu_id = *vcpu_reg(source_vcpu, 1);
43 if (vcpu_mode_is_32bit(source_vcpu)) 46 if (vcpu_mode_is_32bit(source_vcpu))
44 cpu_id &= ~((u32) 0); 47 cpu_id &= ~((u32) 0);
45 48
46 if (cpu_id >= atomic_read(&kvm->online_vcpus)) 49 kvm_for_each_vcpu(i, tmp, kvm) {
50 mpidr = kvm_vcpu_get_mpidr(tmp);
51 if ((mpidr & MPIDR_HWID_BITMASK) == (cpu_id & MPIDR_HWID_BITMASK)) {
52 vcpu = tmp;
53 break;
54 }
55 }
56
57 if (!vcpu)
47 return KVM_PSCI_RET_INVAL; 58 return KVM_PSCI_RET_INVAL;
48 59
49 target_pc = *vcpu_reg(source_vcpu, 2); 60 target_pc = *vcpu_reg(source_vcpu, 2);
50 61
51 vcpu = kvm_get_vcpu(kvm, cpu_id);
52
53 wq = kvm_arch_vcpu_wq(vcpu); 62 wq = kvm_arch_vcpu_wq(vcpu);
54 if (!waitqueue_active(wq)) 63 if (!waitqueue_active(wq))
55 return KVM_PSCI_RET_INVAL; 64 return KVM_PSCI_RET_INVAL;
@@ -62,6 +71,10 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
62 vcpu_set_thumb(vcpu); 71 vcpu_set_thumb(vcpu);
63 } 72 }
64 73
74 /* Propagate caller endianness */
75 if (kvm_vcpu_is_be(source_vcpu))
76 kvm_vcpu_set_be(vcpu);
77
65 *vcpu_pc(vcpu) = target_pc; 78 *vcpu_pc(vcpu) = target_pc;
66 vcpu->arch.pause = false; 79 vcpu->arch.pause = false;
67 smp_mb(); /* Make sure the above is visible */ 80 smp_mb(); /* Make sure the above is visible */