diff options
| -rw-r--r-- | arch/arm/include/asm/kvm_emulate.h | 5 | ||||
| -rw-r--r-- | arch/arm/kvm/psci.c | 17 | ||||
| -rw-r--r-- | arch/arm64/include/asm/kvm_emulate.h | 5 |
3 files changed, 23 insertions, 4 deletions
diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h index a464e8d7b6c5..708e4d8a647f 100644 --- a/arch/arm/include/asm/kvm_emulate.h +++ b/arch/arm/include/asm/kvm_emulate.h | |||
| @@ -157,4 +157,9 @@ static inline u32 kvm_vcpu_hvc_get_imm(struct kvm_vcpu *vcpu) | |||
| 157 | return kvm_vcpu_get_hsr(vcpu) & HSR_HVC_IMM_MASK; | 157 | return kvm_vcpu_get_hsr(vcpu) & HSR_HVC_IMM_MASK; |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | static inline unsigned long kvm_vcpu_get_mpidr(struct kvm_vcpu *vcpu) | ||
| 161 | { | ||
| 162 | return vcpu->arch.cp15[c0_MPIDR]; | ||
| 163 | } | ||
| 164 | |||
| 160 | #endif /* __ARM_KVM_EMULATE_H__ */ | 165 | #endif /* __ARM_KVM_EMULATE_H__ */ |
diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c index 86a693a02ba3..311263124acf 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) | |||
| 34 | static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) | 35 | static 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; |
diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h index eec073875218..6df93cdc652b 100644 --- a/arch/arm64/include/asm/kvm_emulate.h +++ b/arch/arm64/include/asm/kvm_emulate.h | |||
| @@ -177,4 +177,9 @@ static inline u8 kvm_vcpu_trap_get_fault(const struct kvm_vcpu *vcpu) | |||
| 177 | return kvm_vcpu_get_hsr(vcpu) & ESR_EL2_FSC_TYPE; | 177 | return kvm_vcpu_get_hsr(vcpu) & ESR_EL2_FSC_TYPE; |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | static inline unsigned long kvm_vcpu_get_mpidr(struct kvm_vcpu *vcpu) | ||
| 181 | { | ||
| 182 | return vcpu_sys_reg(vcpu, MPIDR_EL1); | ||
| 183 | } | ||
| 184 | |||
| 180 | #endif /* __ARM64_KVM_EMULATE_H__ */ | 185 | #endif /* __ARM64_KVM_EMULATE_H__ */ |
