@@ -157,6 +157,12 @@ struct kvm_nvhe_init_params {
unsigned long vector_ptr;
};
+enum kvm_nvhe_psci_state {
+ KVM_NVHE_PSCI_CPU_OFF = 0,
+ KVM_NVHE_PSCI_CPU_PENDING_ON,
+ KVM_NVHE_PSCI_CPU_ON,
+};
+
/* Translate a kernel address @ptr into its equivalent linear mapping */
#define kvm_ksym_ref(ptr) \
({ \
@@ -97,6 +97,7 @@ void deactivate_traps_vhe_put(void);
u64 __guest_enter(struct kvm_vcpu *vcpu);
#ifdef __KVM_NVHE_HYPERVISOR__
+void kvm_host_psci_cpu_init(void);
bool kvm_host_psci_handler(struct kvm_cpu_context *host_ctxt);
#endif
@@ -52,6 +52,7 @@ DECLARE_KVM_HYP_PER_CPU(unsigned long, kvm_hyp_vector);
static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page);
unsigned long kvm_arm_hyp_percpu_base[NR_CPUS];
DECLARE_KVM_NVHE_PER_CPU(struct kvm_nvhe_init_params, kvm_init_params);
+DECLARE_KVM_NVHE_PER_CPU(enum kvm_nvhe_psci_state, psci_cpu_state);
/* The VMID used in the VTTBR */
static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
@@ -1517,10 +1518,14 @@ static void init_psci(void)
{
extern u32 kvm_nvhe_sym(kvm_host_psci_version);
extern u32 kvm_nvhe_sym(kvm_host_psci_function_id)[PSCI_FN_MAX];
+ int cpu;
kvm_nvhe_sym(kvm_host_psci_version) = psci_driver_version;
memcpy(kvm_nvhe_sym(kvm_host_psci_function_id),
psci_function_id, sizeof(psci_function_id));
+
+ for_each_online_cpu(cpu)
+ *per_cpu_ptr_nvhe_sym(psci_cpu_state, cpu) = KVM_NVHE_PSCI_CPU_ON;
}
static int init_common_resources(void)
@@ -20,6 +20,8 @@ s64 hyp_physvirt_offset;
#define __hyp_pa(x) ((phys_addr_t)(x) + hyp_physvirt_offset)
+DEFINE_PER_CPU(enum kvm_nvhe_psci_state, psci_cpu_state);
+
static u64 get_psci_func_id(struct kvm_cpu_context *host_ctxt)
{
return host_ctxt->regs.regs[0];
Proxying host's PSCI SMCs will require synchronizing CPU_ON/OFF/SUSPEND calls based on the observed state of individual cores. Add a per-CPU enum that tracks the power state of each core and initialize all CPUs online at the point of KVM init to ON. Signed-off-by: David Brazdil <dbrazdil@google.com> --- arch/arm64/include/asm/kvm_asm.h | 6 ++++++ arch/arm64/include/asm/kvm_hyp.h | 1 + arch/arm64/kvm/arm.c | 5 +++++ arch/arm64/kvm/hyp/nvhe/psci.c | 2 ++ 4 files changed, 14 insertions(+)