From f003787455709a1a6c69c1b6ab6a02d4d767c325 Mon Sep 17 00:00:00 2001 From: Atish Patra Date: Fri, 21 Dec 2018 11:06:20 +0530 Subject: [PATCH] lib: Hang in sbi_hart_boot_next() if next mode is not supported We should not jump to next stage if next mode (S-mode or U-mode) is not supported by HART. Signed-off-by: Atish Patra Signed-off-by: Anup Patel --- lib/sbi_hart.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/sbi_hart.c b/lib/sbi_hart.c index 5b26aead..a375ecf6 100644 --- a/lib/sbi_hart.c +++ b/lib/sbi_hart.c @@ -203,6 +203,10 @@ void __attribute__((noreturn)) sbi_hart_boot_next(unsigned long arg0, if (next_mode != PRV_S && next_mode != PRV_M && next_mode != PRV_U) sbi_hart_hang(); + if (next_mode == PRV_S && !misa_extension('S')) + sbi_hart_hang(); + if (next_mode == PRV_U && !misa_extension('U')) + sbi_hart_hang(); val = csr_read(mstatus); val = INSERT_FIELD(val, MSTATUS_MPP, next_mode);