ANDROID: gunyah: Handle platform specific return value of vcpu_run

PSCI_SYSTEM_RESET is a valid return value of the vcpu_run
hypercall. As kernel doesn't have any special handling of this
case, treat it as a generic SYSTEM_OFF and let the VMM take the
appropriate action as the vcpu_run structure will have the
necessary details for this exit.

Bug: 409998900
Change-Id: I0275e887f869964cb2a27e74f2f55b8ec3febf3c
Signed-off-by: Prakruthi Deepak Heragu <quic_pheragu@quicinc.com>
This commit is contained in:
Prakruthi Deepak Heragu
2025-04-02 17:37:38 -07:00
committed by Carlos Llamas
parent f49bbfed7a
commit 8ffa03307c
3 changed files with 15 additions and 2 deletions

View File

@@ -8,6 +8,7 @@
#include <linux/gunyah.h>
#include <linux/uuid.h>
#define GUNYAH_VCPU_RUN_STATE_PSCI_SYSTEM_RESET 256
/* {c1d58fcd-a453-5fdb-9265-ce36673d5f14} */
static const uuid_t GUNYAH_UUID = UUID_INIT(0xc1d58fcd, 0xa453, 0x5fdb, 0x92,
0x65, 0xce, 0x36, 0x67, 0x3d, 0x5f,
@@ -285,6 +286,14 @@ gunyah_hypercall_vcpu_run(u64 capid, unsigned long *resume_data,
resp->state_data[2] = res.a4;
}
/*
* PSCI_SYSTEM_RESET is also a state where VM is shutdown
* Translate it to GUNYAH_VCPU_STATE_SYSTEM_OFF as VMM will
* be able to take the action based on the exit_info.
*/
if (resp->sized_state == GUNYAH_VCPU_RUN_STATE_PSCI_SYSTEM_RESET)
resp->sized_state = GUNYAH_VCPU_STATE_SYSTEM_OFF;
return res.a0;
}
EXPORT_SYMBOL_GPL(gunyah_hypercall_vcpu_run);

View File

@@ -277,6 +277,8 @@ static int gunyah_vcpu_run(struct gunyah_vcpu *vcpu)
schedule();
break;
case GUNYAH_VCPU_STATE_POWERED_OFF:
fallthrough;
case GUNYAH_VCPU_STATE_SYSTEM_OFF:
/**
* vcpu might be off because the VM is shut down
* If so, it won't ever run again
@@ -326,8 +328,8 @@ static int gunyah_vcpu_run(struct gunyah_vcpu *vcpu)
pr_warn_ratelimited(
"Unknown vCPU state: %llx\n",
vcpu_run_resp.sized_state);
schedule();
break;
ret = -EINVAL;
goto out;
}
} else if (gunyah_error == GUNYAH_ERROR_RETRY) {
schedule();

View File

@@ -526,6 +526,8 @@ struct gunyah_hypercall_vcpu_run_resp {
GUNYAH_VCPU_ADDRSPACE_VMMIO_WRITE = 5,
/* VCPU blocked on fault where we can demand page */
GUNYAH_VCPU_ADDRSPACE_PAGE_FAULT = 7,
/* VCPU is powered off due to some system event/reset */
GUNYAH_VCPU_STATE_SYSTEM_OFF = 0x100,
/* clang-format on */
} state;
u64 sized_state;