From b6cfd9d69f5f3302e92bc42e4b32dab1970413eb Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Thu, 17 Nov 2022 12:19:49 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Fix repainting of PSCI SYSTEM_RESET2 calls If the host issues a PSCI SYSTEM_RESET2 call requesting a warm reset while guest pages are live in the system, then pKVM attempts to convert this to a cold PSCI SYSTEM_RESET request to ensure the EL3 will clear memory on the next boot. However, this logic is quite badly broken and will instead attempt to take the 'mem_protect_lock' spinlock twice which results in a deadlock. Fix the repainting so that the 'host_ctxt' is updated inline and we forward the updated request directly to EL3. Signed-off-by: Will Deacon Bug: 259523340 Signed-off-by: Will Deacon Change-Id: I44719466b7f5abddf73730a3b74db13f935f92ec --- arch/arm64/kvm/hyp/nvhe/psci-relay.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/psci-relay.c b/arch/arm64/kvm/hyp/nvhe/psci-relay.c index 85f7cad956d5..1a4d2a67b813 100644 --- a/arch/arm64/kvm/hyp/nvhe/psci-relay.c +++ b/arch/arm64/kvm/hyp/nvhe/psci-relay.c @@ -307,10 +307,8 @@ static unsigned long psci_1_0_handler(u64 func_id, struct kvm_cpu_context *host_ case PSCI_1_1_FN64_SYSTEM_RESET2: pkvm_clear_pvmfw_pages(); hyp_spin_lock(&mem_protect_lock); - if (psci_mem_protect_active()) { - return psci_0_2_handler(PSCI_0_2_FN_SYSTEM_RESET, - host_ctxt); - } + if (psci_mem_protect_active()) + cpu_reg(host_ctxt, 0) = PSCI_0_2_FN_SYSTEM_RESET; fallthrough; case PSCI_1_0_FN_PSCI_FEATURES: case PSCI_1_0_FN_SET_SUSPEND_MODE: