18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2012,2013 - ARM Ltd 48c2ecf20Sopenharmony_ci * Author: Marc Zyngier <marc.zyngier@arm.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef __KVM_ARM_PSCI_H__ 88c2ecf20Sopenharmony_ci#define __KVM_ARM_PSCI_H__ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/kvm_host.h> 118c2ecf20Sopenharmony_ci#include <uapi/linux/psci.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define KVM_ARM_PSCI_0_1 PSCI_VERSION(0, 1) 148c2ecf20Sopenharmony_ci#define KVM_ARM_PSCI_0_2 PSCI_VERSION(0, 2) 158c2ecf20Sopenharmony_ci#define KVM_ARM_PSCI_1_0 PSCI_VERSION(1, 0) 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define KVM_ARM_PSCI_LATEST KVM_ARM_PSCI_1_0 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* 208c2ecf20Sopenharmony_ci * We need the KVM pointer independently from the vcpu as we can call 218c2ecf20Sopenharmony_ci * this from HYP, and need to apply kern_hyp_va on it... 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_cistatic inline int kvm_psci_version(struct kvm_vcpu *vcpu, struct kvm *kvm) 248c2ecf20Sopenharmony_ci{ 258c2ecf20Sopenharmony_ci /* 268c2ecf20Sopenharmony_ci * Our PSCI implementation stays the same across versions from 278c2ecf20Sopenharmony_ci * v0.2 onward, only adding the few mandatory functions (such 288c2ecf20Sopenharmony_ci * as FEATURES with 1.0) that are required by newer 298c2ecf20Sopenharmony_ci * revisions. It is thus safe to return the latest, unless 308c2ecf20Sopenharmony_ci * userspace has instructed us otherwise. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_ci if (test_bit(KVM_ARM_VCPU_PSCI_0_2, vcpu->arch.features)) { 338c2ecf20Sopenharmony_ci if (vcpu->kvm->arch.psci_version) 348c2ecf20Sopenharmony_ci return vcpu->kvm->arch.psci_version; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci return KVM_ARM_PSCI_LATEST; 378c2ecf20Sopenharmony_ci } 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci return KVM_ARM_PSCI_0_1; 408c2ecf20Sopenharmony_ci} 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ciint kvm_psci_call(struct kvm_vcpu *vcpu); 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistruct kvm_one_reg; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ciint kvm_arm_get_fw_num_regs(struct kvm_vcpu *vcpu); 488c2ecf20Sopenharmony_ciint kvm_arm_copy_fw_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices); 498c2ecf20Sopenharmony_ciint kvm_arm_get_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg); 508c2ecf20Sopenharmony_ciint kvm_arm_set_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#endif /* __KVM_ARM_PSCI_H__ */ 53