void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch);
int sbi_hsm_hart_start(struct sbi_scratch *scratch, u32 hartid,
- ulong saddr, ulong priv);
+ ulong saddr, ulong smode, ulong priv);
int sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow);
int sbi_hsm_hart_get_state(u32 hartid);
int sbi_hsm_hart_state_to_status(int state);
unsigned long *args, unsigned long *out_val,
struct sbi_trap_info *out_trap)
{
+ ulong smode;
int ret = 0, hstate;
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
switch (funcid) {
case SBI_EXT_HSM_HART_START:
- ret = sbi_hsm_hart_start(scratch, args[0], args[1], args[2]);
+ smode = csr_read(CSR_MSTATUS);
+ smode = (smode & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT;
+ ret = sbi_hsm_hart_start(scratch, args[0], args[1],
+ smode, args[2]);
break;
case SBI_EXT_HSM_HART_STOP:
ret = sbi_hsm_hart_stop(scratch, TRUE);
}
int sbi_hsm_hart_start(struct sbi_scratch *scratch, u32 hartid,
- ulong saddr, ulong priv)
+ ulong saddr, ulong smode, ulong priv)
{
int rc;
unsigned long init_count;
struct sbi_hsm_data *hdata;
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
+ if (smode != PRV_M && smode != PRV_S && smode != PRV_U)
+ return SBI_EINVAL;
+
rscratch = sbi_hartid_to_scratch(hartid);
if (!rscratch)
return SBI_EINVAL;
init_count = sbi_init_count(hartid);
rscratch->next_arg1 = priv;
rscratch->next_addr = saddr;
+ rscratch->next_mode = smode;
if (sbi_platform_has_hart_hotplug(plat) ||
(sbi_platform_has_hart_secondary_boot(plat) && !init_count)) {