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
71 vcpu = kvm_mpidr_to_vcpu(kvm, cpu_id); in kvm_psci_vcpu_on()
77 if (!vcpu) in kvm_psci_vcpu_on()
79 if (!kvm_arm_vcpu_stopped(vcpu)) { in kvm_psci_vcpu_on()
86 reset_state = &vcpu->arch.reset_state; in kvm_psci_vcpu_on()
100 kvm_make_request(KVM_REQ_VCPU_RESET, vcpu); in kvm_psci_vcpu_on()
108 vcpu->arch.mp_state.mp_state = KVM_MP_STATE_RUNNABLE; in kvm_psci_vcpu_on()
109 kvm_vcpu_wake_up(vcpu); in kvm_psci_vcpu_on()
114 static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu) in kvm_psci_vcpu_affinity_info() argument
121 struct kvm *kvm = vcpu->kvm; in kvm_psci_vcpu_affinity_info()
124 target_affinity = smccc_get_arg1(vcpu); in kvm_psci_vcpu_affinity_info()
125 lowest_affinity_level = smccc_get_arg2(vcpu); in kvm_psci_vcpu_affinity_info()
127 if (!kvm_psci_valid_affinity(vcpu, target_affinity)) in kvm_psci_vcpu_affinity_info()
157 static void kvm_prepare_system_event(struct kvm_vcpu *vcpu, u32 type, u64 flags) in kvm_prepare_system_event() argument
171 kvm_for_each_vcpu(i, tmp, vcpu->kvm) in kvm_prepare_system_event()
173 kvm_make_all_cpus_request(vcpu->kvm, KVM_REQ_SLEEP); in kvm_prepare_system_event()
175 memset(&vcpu->run->system_event, 0, sizeof(vcpu->run->system_event)); in kvm_prepare_system_event()
176 vcpu->run->system_event.type = type; in kvm_prepare_system_event()
177 vcpu->run->system_event.ndata = 1; in kvm_prepare_system_event()
178 vcpu->run->system_event.data[0] = flags; in kvm_prepare_system_event()
179 vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT; in kvm_prepare_system_event()
182 static void kvm_psci_system_off(struct kvm_vcpu *vcpu) in kvm_psci_system_off() argument
184 kvm_prepare_system_event(vcpu, KVM_SYSTEM_EVENT_SHUTDOWN, 0); in kvm_psci_system_off()
187 static void kvm_psci_system_reset(struct kvm_vcpu *vcpu) in kvm_psci_system_reset() argument
189 kvm_prepare_system_event(vcpu, KVM_SYSTEM_EVENT_RESET, 0); in kvm_psci_system_reset()
192 static void kvm_psci_system_reset2(struct kvm_vcpu *vcpu) in kvm_psci_system_reset2() argument
194 kvm_prepare_system_event(vcpu, KVM_SYSTEM_EVENT_RESET, in kvm_psci_system_reset2()
198 static void kvm_psci_system_suspend(struct kvm_vcpu *vcpu) in kvm_psci_system_suspend() argument
200 struct kvm_run *run = vcpu->run; in kvm_psci_system_suspend()
202 memset(&run->system_event, 0, sizeof(vcpu->run->system_event)); in kvm_psci_system_suspend()
207 static void kvm_psci_narrow_to_32bit(struct kvm_vcpu *vcpu) in kvm_psci_narrow_to_32bit() argument
216 vcpu_set_reg(vcpu, i, lower_32_bits(vcpu_get_reg(vcpu, i))); in kvm_psci_narrow_to_32bit()
219 static unsigned long kvm_psci_check_allowed_function(struct kvm_vcpu *vcpu, u32 fn) in kvm_psci_check_allowed_function() argument
224 if ((fn & PSCI_0_2_64BIT) && vcpu_mode_is_32bit(vcpu)) in kvm_psci_check_allowed_function()
230 static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) in kvm_psci_0_2_call() argument
232 struct kvm *kvm = vcpu->kvm; in kvm_psci_0_2_call()
233 u32 psci_fn = smccc_get_function(vcpu); in kvm_psci_0_2_call()
247 val = kvm_psci_vcpu_suspend(vcpu); in kvm_psci_0_2_call()
250 kvm_arm_vcpu_power_off(vcpu); in kvm_psci_0_2_call()
254 kvm_psci_narrow_to_32bit(vcpu); in kvm_psci_0_2_call()
258 val = kvm_psci_vcpu_on(vcpu); in kvm_psci_0_2_call()
262 kvm_psci_narrow_to_32bit(vcpu); in kvm_psci_0_2_call()
265 val = kvm_psci_vcpu_affinity_info(vcpu); in kvm_psci_0_2_call()
276 kvm_psci_system_off(vcpu); in kvm_psci_0_2_call()
291 kvm_psci_system_reset(vcpu); in kvm_psci_0_2_call()
304 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_0_2_call()
308 static int kvm_psci_1_x_call(struct kvm_vcpu *vcpu, u32 minor) in kvm_psci_1_x_call() argument
311 u32 psci_fn = smccc_get_function(vcpu); in kvm_psci_1_x_call()
312 struct kvm *kvm = vcpu->kvm; in kvm_psci_1_x_call()
321 arg = smccc_get_arg1(vcpu); in kvm_psci_1_x_call()
322 val = kvm_psci_check_allowed_function(vcpu, arg); in kvm_psci_1_x_call()
357 kvm_psci_narrow_to_32bit(vcpu); in kvm_psci_1_x_call()
366 kvm_psci_system_suspend(vcpu); in kvm_psci_1_x_call()
371 kvm_psci_narrow_to_32bit(vcpu); in kvm_psci_1_x_call()
375 arg = smccc_get_arg1(vcpu); in kvm_psci_1_x_call()
379 kvm_psci_system_reset2(vcpu); in kvm_psci_1_x_call()
380 vcpu_set_reg(vcpu, 0, PSCI_RET_INTERNAL_FAILURE); in kvm_psci_1_x_call()
389 return kvm_psci_0_2_call(vcpu); in kvm_psci_1_x_call()
392 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_1_x_call()
396 static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) in kvm_psci_0_1_call() argument
398 struct kvm *kvm = vcpu->kvm; in kvm_psci_0_1_call()
399 u32 psci_fn = smccc_get_function(vcpu); in kvm_psci_0_1_call()
404 kvm_arm_vcpu_power_off(vcpu); in kvm_psci_0_1_call()
409 val = kvm_psci_vcpu_on(vcpu); in kvm_psci_0_1_call()
417 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_0_1_call()
435 int kvm_psci_call(struct kvm_vcpu *vcpu) in kvm_psci_call() argument
437 u32 psci_fn = smccc_get_function(vcpu); in kvm_psci_call()
440 val = kvm_psci_check_allowed_function(vcpu, psci_fn); in kvm_psci_call()
442 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_call()
446 switch (kvm_psci_version(vcpu)) { in kvm_psci_call()
448 return kvm_psci_1_x_call(vcpu, 1); in kvm_psci_call()
450 return kvm_psci_1_x_call(vcpu, 0); in kvm_psci_call()
452 return kvm_psci_0_2_call(vcpu); in kvm_psci_call()
454 return kvm_psci_0_1_call(vcpu); in kvm_psci_call()