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 <will@kernel.org>
Bug: 259523340
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I44719466b7f5abddf73730a3b74db13f935f92ec
This commit is contained in:
Will Deacon
2022-11-17 12:19:49 +00:00
committed by Will Deacon
parent c2162eca3f
commit 3a049b038e

View File

@@ -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: