Lines Matching +full:psci +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2012 - ARM Ltd
7 #include <linux/arm-smccc.h>
24 #define AFFINITY_MASK(level) ~((0x1UL << ((level) * MPIDR_LEVEL_BITS)) - 1)
31 return 0; in psci_affinity_mask()
38 * same-as WFI (Wait-for-interrupt) emulation. in kvm_psci_vcpu_suspend()
42 * in section 5.4.1 of PSCI v0.2 specification (ARM DEN 0022A). in kvm_psci_vcpu_suspend()
44 * Further, we also treat power-down request to be same as in kvm_psci_vcpu_suspend()
45 * stand-by request as-per section 5.4.2 clause 3 of PSCI v0.2 in kvm_psci_vcpu_suspend()
63 struct kvm *kvm = source_vcpu->kvm; in kvm_psci_vcpu_on()
81 spin_lock(&vcpu->arch.mp_state_lock); in kvm_psci_vcpu_on()
91 reset_state = &vcpu->arch.reset_state; in kvm_psci_vcpu_on()
93 reset_state->pc = smccc_get_arg2(source_vcpu); in kvm_psci_vcpu_on()
96 reset_state->be = kvm_vcpu_is_be(source_vcpu); in kvm_psci_vcpu_on()
99 * NOTE: We always update r0 (or x0) because for PSCI v0.1 in kvm_psci_vcpu_on()
102 reset_state->r0 = smccc_get_arg3(source_vcpu); in kvm_psci_vcpu_on()
104 reset_state->reset = true; in kvm_psci_vcpu_on()
113 WRITE_ONCE(vcpu->arch.mp_state.mp_state, KVM_MP_STATE_RUNNABLE); in kvm_psci_vcpu_on()
117 spin_unlock(&vcpu->arch.mp_state_lock); in kvm_psci_vcpu_on()
123 int matching_cpus = 0; in kvm_psci_vcpu_affinity_info()
128 struct kvm *kvm = vcpu->kvm; in kvm_psci_vcpu_affinity_info()
172 * actual request is made. Since we are implementing PSCI and a in kvm_prepare_system_event()
173 * caller of PSCI reboot and shutdown expects that the system shuts in kvm_prepare_system_event()
176 * re-initialized. in kvm_prepare_system_event()
178 kvm_for_each_vcpu(i, tmp, vcpu->kvm) { in kvm_prepare_system_event()
179 spin_lock(&tmp->arch.mp_state_lock); in kvm_prepare_system_event()
180 WRITE_ONCE(tmp->arch.mp_state.mp_state, KVM_MP_STATE_STOPPED); in kvm_prepare_system_event()
181 spin_unlock(&tmp->arch.mp_state_lock); 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()
194 kvm_prepare_system_event(vcpu, KVM_SYSTEM_EVENT_SHUTDOWN, 0); in kvm_psci_system_off()
199 kvm_prepare_system_event(vcpu, KVM_SYSTEM_EVENT_RESET, 0); in kvm_psci_system_reset()
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()
213 run->system_event.type = KVM_SYSTEM_EVENT_SUSPEND; in kvm_psci_system_suspend()
214 run->exit_reason = KVM_EXIT_SYSTEM_EVENT; in kvm_psci_system_suspend()
232 * Prevent 32 bit guests from calling 64 bit PSCI functions. in kvm_psci_check_allowed_function()
237 return 0; in kvm_psci_check_allowed_function()
249 * Bits[31:16] = Major Version = 0 in kvm_psci_0_2_call()
250 * Bits[15:0] = Minor Version = 2 in kvm_psci_0_2_call()
290 * VCPU should see internal failure from PSCI return in kvm_psci_0_2_call()
292 * PSCI return value INTERNAL_FAILURE. in kvm_psci_0_2_call()
295 ret = 0; in kvm_psci_0_2_call()
301 * with PSCI return value INTERNAL_FAILURE. in kvm_psci_0_2_call()
304 ret = 0; in kvm_psci_0_2_call()
311 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_0_2_call()
319 struct kvm *kvm = vcpu->kvm; in kvm_psci_1_x_call()
325 val = minor == 0 ? KVM_ARM_PSCI_1_0 : KVM_ARM_PSCI_1_1; in kvm_psci_1_x_call()
349 val = 0; in kvm_psci_1_x_call()
353 if (test_bit(KVM_ARCH_FLAG_SYSTEM_SUSPEND_ENABLED, &kvm->arch.flags)) in kvm_psci_1_x_call()
354 val = 0; in kvm_psci_1_x_call()
359 val = 0; in kvm_psci_1_x_call()
372 if (test_bit(KVM_ARCH_FLAG_SYSTEM_SUSPEND_ENABLED, &kvm->arch.flags)) { in kvm_psci_1_x_call()
374 return 0; in kvm_psci_1_x_call()
387 vcpu_set_reg(vcpu, 0, PSCI_RET_INTERNAL_FAILURE); in kvm_psci_1_x_call()
388 return 0; in kvm_psci_1_x_call()
399 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_1_x_call()
421 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_0_1_call()
426 * kvm_psci_call - handle PSCI call if r0 value is in range
429 * Handle PSCI calls from guests through traps from HVC instructions.
433 * This function returns: > 0 (success), 0 (success but exit to user
434 * space), and < 0 (errors)
437 * -EINVAL: Unrecognized PSCI function
447 smccc_set_retval(vcpu, val, 0, 0, 0); in kvm_psci_call()
455 return kvm_psci_1_x_call(vcpu, 0); in kvm_psci_call()
461 WARN_ONCE(1, "Unknown PSCI version %d", version); in kvm_psci_call()
462 smccc_set_retval(vcpu, SMCCC_RET_NOT_SUPPORTED, 0, 0, 0); in kvm_psci_call()