Lines Matching refs:vcpu
34 static unsigned long kvm_psci_vcpu_suspend(struct kvm_vcpu *vcpu) in kvm_psci_vcpu_suspend() argument
49 kvm_vcpu_wfi(vcpu); in kvm_psci_vcpu_suspend()
54 static inline bool kvm_psci_valid_affinity(struct kvm_vcpu *vcpu, in kvm_psci_valid_affinity() argument
64 struct kvm_vcpu *vcpu = NULL; in kvm_psci_vcpu_on() local
72 vcpu = kvm_mpidr_to_vcpu(kvm, cpu_id); in kvm_psci_vcpu_on()
78 if (!vcpu) in kvm_psci_vcpu_on()
81 spin_lock(&vcpu->arch.mp_state_lock); in kvm_psci_vcpu_on()
82 if (!kvm_arm_vcpu_stopped(vcpu)) { in kvm_psci_vcpu_on()
91 reset_state = &vcpu->arch.reset_state; in kvm_psci_vcpu_on()
105 kvm_make_request(KVM_REQ_VCPU_RESET, vcpu); in kvm_psci_vcpu_on()
113 WRITE_ONCE(vcpu->arch.mp_state.mp_state, KVM_MP_STATE_RUNNABLE); in kvm_psci_vcpu_on()
114 kvm_vcpu_wake_up(vcpu); in kvm_psci_vcpu_on()
117 spin_unlock(&vcpu->arch.mp_state_lock); in kvm_psci_vcpu_on()
121 static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu) in kvm_psci_vcpu_affinity_info() argument
128 struct kvm *kvm = vcpu->kvm; in kvm_psci_vcpu_affinity_info()
131 target_affinity = smccc_get_arg1(vcpu); in kvm_psci_vcpu_affinity_info()
132 lowest_affinity_level = smccc_get_arg2(vcpu); in kvm_psci_vcpu_affinity_info()
134 if (!kvm_psci_valid_affinity(vcpu, target_affinity)) in kvm_psci_vcpu_affinity_info()
164 static void kvm_prepare_system_event(struct kvm_vcpu *vcpu, u32 type, u64 flags) in kvm_prepare_system_event() argument
178 kvm_for_each_vcpu(i, tmp, vcpu->kvm) { in kvm_prepare_system_event()
183 kvm_make_all_cpus_request(vcpu->kvm, KVM_REQ_SLEEP); in kvm_prepare_system_event()
185 memset(&vcpu->run->system_event, 0, sizeof(vcpu->run->system_event)); in kvm_prepare_system_event()
186 vcpu->run->system_event.type = type; in kvm_prepare_system_event()
187 vcpu->run->system_event.ndata = 1; in kvm_prepare_system_event()
188 vcpu->run->system_event.data[0] = flags; in kvm_prepare_system_event()
189 vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT; in kvm_prepare_system_event()
192 static void kvm_psci_system_off(struct kvm_vcpu *vcpu) in kvm_psci_system_off() argument
194 kvm_prepare_system_event(vcpu, KVM_SYSTEM_EVENT_SHUTDOWN, 0); in kvm_psci_system_off()
197 static void kvm_psci_system_reset(struct kvm_vcpu *vcpu) in kvm_psci_system_reset() argument
199 kvm_prepare_system_event(vcpu, KVM_SYSTEM_EVENT_RESET, 0); in kvm_psci_system_reset()
202 static void kvm_psci_system_reset2(struct kvm_vcpu *vcpu) in kvm_psci_system_reset2() argument
204 kvm_prepare_system_event(vcpu, KVM_SYSTEM_EVENT_RESET, in kvm_psci_system_reset2()
208 static void kvm_psci_system_suspend(struct kvm_vcpu *vcpu) in kvm_psci_system_suspend() argument
210 struct kvm_run *run = vcpu->run; in kvm_psci_system_suspend()
212 memset(&run->system_event, 0, sizeof(vcpu->run->system_event)); in kvm_psci_system_suspend()
217 static void kvm_psci_narrow_to_32bit(struct kvm_vcpu *vcpu) in kvm_psci_narrow_to_32bit() argument
226 vcpu_set_reg(vcpu, i, lower_32_bits(vcpu_get_reg(vcpu, i))); in kvm_psci_narrow_to_32bit()
229 static unsigned long kvm_psci_check_allowed_function(struct kvm_vcpu *vcpu, u32 fn) in kvm_psci_check_allowed_function() argument
234 if ((fn & PSCI_0_2_64BIT) && vcpu_mode_is_32bit(vcpu)) in kvm_psci_check_allowed_function()
240 static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) in kvm_psci_0_2_call() argument
242 u32 psci_fn = smccc_get_function(vcpu); in kvm_psci_0_2_call()
256 val = kvm_psci_vcpu_suspend(vcpu); in kvm_psci_0_2_call()
259 kvm_arm_vcpu_power_off(vcpu); in kvm_psci_0_2_call()
263 kvm_psci_narrow_to_32bit(vcpu); in kvm_psci_0_2_call()
266 val = kvm_psci_vcpu_on(vcpu); in kvm_psci_0_2_call()
269 kvm_psci_narrow_to_32bit(vcpu); in kvm_psci_0_2_call()
272 val = kvm_psci_vcpu_affinity_info(vcpu); in kvm_psci_0_2_call()
283 kvm_psci_system_off(vcpu); in kvm_psci_0_2_call()
298 kvm_psci_system_reset(vcpu); in kvm_psci_0_2_call()
311 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_0_2_call()
315 static int kvm_psci_1_x_call(struct kvm_vcpu *vcpu, u32 minor) in kvm_psci_1_x_call() argument
318 u32 psci_fn = smccc_get_function(vcpu); in kvm_psci_1_x_call()
319 struct kvm *kvm = vcpu->kvm; in kvm_psci_1_x_call()
328 arg = smccc_get_arg1(vcpu); in kvm_psci_1_x_call()
329 val = kvm_psci_check_allowed_function(vcpu, arg); in kvm_psci_1_x_call()
364 kvm_psci_narrow_to_32bit(vcpu); in kvm_psci_1_x_call()
373 kvm_psci_system_suspend(vcpu); in kvm_psci_1_x_call()
378 kvm_psci_narrow_to_32bit(vcpu); in kvm_psci_1_x_call()
382 arg = smccc_get_arg1(vcpu); in kvm_psci_1_x_call()
386 kvm_psci_system_reset2(vcpu); in kvm_psci_1_x_call()
387 vcpu_set_reg(vcpu, 0, PSCI_RET_INTERNAL_FAILURE); in kvm_psci_1_x_call()
396 return kvm_psci_0_2_call(vcpu); in kvm_psci_1_x_call()
399 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_1_x_call()
403 static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) in kvm_psci_0_1_call() argument
405 u32 psci_fn = smccc_get_function(vcpu); in kvm_psci_0_1_call()
410 kvm_arm_vcpu_power_off(vcpu); in kvm_psci_0_1_call()
414 val = kvm_psci_vcpu_on(vcpu); in kvm_psci_0_1_call()
421 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_0_1_call()
439 int kvm_psci_call(struct kvm_vcpu *vcpu) in kvm_psci_call() argument
441 u32 psci_fn = smccc_get_function(vcpu); in kvm_psci_call()
442 int version = kvm_psci_version(vcpu); in kvm_psci_call()
445 val = kvm_psci_check_allowed_function(vcpu, psci_fn); in kvm_psci_call()
447 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_call()
453 return kvm_psci_1_x_call(vcpu, 1); in kvm_psci_call()
455 return kvm_psci_1_x_call(vcpu, 0); in kvm_psci_call()
457 return kvm_psci_0_2_call(vcpu); in kvm_psci_call()
459 return kvm_psci_0_1_call(vcpu); in kvm_psci_call()
462 smccc_set_retval(vcpu, SMCCC_RET_NOT_SUPPORTED, 0, 0, 0); in kvm_psci_call()