Skip to content

Commit 94871af

Browse files
committed
feat(arm/psci): add psci_reset support
Signed-off-by: Jose Martins <[email protected]>
1 parent e59e294 commit 94871af

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/arch/armv8/inc/arch/psci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define PSCI_AFFINITY_INFO_SMC64 (0xc4000004)
2222
#define PSCI_FEATURES (0x8400000A)
2323
#define PSCI_MIG_INFO_TYPE (0x84000006)
24+
#define PSCI_SYSTEM_RESET (0x84000009)
2425

2526
#ifdef AARCH32
2627
#define PSCI_CPU_SUSPEND PSCI_CPU_SUSPEND_SMC32

src/arch/armv8/psci.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ static int32_t psci_features_handler(uint32_t feature_id)
177177
case PSCI_AFFINITY_INFO_SMC32:
178178
case PSCI_AFFINITY_INFO_SMC64:
179179
case PSCI_FEATURES:
180+
case PSCI_SYSTEM_RESET:
180181
ret = PSCI_E_SUCCESS;
181182
break;
182183
default:
@@ -187,6 +188,21 @@ static int32_t psci_features_handler(uint32_t feature_id)
187188
return ret;
188189
}
189190

191+
static int32_t psci_reset()
192+
{
193+
// Although the spec mandates this call cannot fail, this might actually happen if Bao did
194+
// not keep a copy of the original guest image around
195+
bool res = PSCI_E_DENIED;
196+
197+
if (vm_reset(cpu()->vcpu->vm)) {
198+
// Note that, if successful, this PSCI call does not actually return. We still "return"
199+
// success to keep the compiler happy.
200+
res = PSCI_E_SUCCESS;
201+
}
202+
203+
return res;
204+
}
205+
190206
int32_t psci_smc_handler(uint32_t smc_fid, unsigned long x1, unsigned long x2, unsigned long x3)
191207
{
192208
int32_t ret = PSCI_E_NOT_SUPPORTED;
@@ -223,6 +239,9 @@ int32_t psci_smc_handler(uint32_t smc_fid, unsigned long x1, unsigned long x2, u
223239
ret = PSCI_TOS_NOT_PRESENT_MP;
224240
break;
225241

242+
case PSCI_SYSTEM_RESET:
243+
ret = psci_reset();
244+
break;
226245
default:
227246
INFO("unkown psci smc_fid 0x%lx", smc_fid);
228247
}

0 commit comments

Comments
 (0)