aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMing-Yi Lai <ming-yi.lai@mediatek.com>2024-01-10 13:19:11 +0800
committerMing-Yi Lai <ming-yi.lai@mediatek.com>2024-02-15 13:11:05 +0800
commit6c62461a1ea56db6c5f264e26c52dcc118094697 (patch)
tree2c8b31886ea271bdf7df271127323c3aee089adb
parent3bd964f233ea04008b30bd2bdedc25a7f9545fc0 (diff)
downloadpk-6c62461a1ea56db6c5f264e26c52dcc118094697.zip
pk-6c62461a1ea56db6c5f264e26c52dcc118094697.tar.gz
pk-6c62461a1ea56db6c5f264e26c52dcc118094697.tar.bz2
Zicfilp: Support enabling userspace Zicfilp mechanism
-rw-r--r--pk/pk.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/pk/pk.c b/pk/pk.c
index 31d8c79..dbfaa5a 100644
--- a/pk/pk.c
+++ b/pk/pk.c
@@ -13,6 +13,7 @@
elf_info current;
long disabled_hart_mask;
+bool zicfilp_enabled;
static void help()
{
@@ -22,6 +23,7 @@ static void help()
printk(" -h, --help Print this help message\n");
printk(" -p Disable on-demand program paging\n");
printk(" -s Print cycles upon termination\n");
+ printk(" --zicfilp Enable Zicfilp CFI mechanism for user program\n");
shutdown(0);
}
@@ -54,6 +56,11 @@ static void handle_option(const char* arg)
return;
}
+ if (strcmp(arg, "--zicfilp") == 0) {
+ zicfilp_enabled = true;
+ return;
+ }
+
panic("unrecognized option: `%s'", arg);
suggest_help();
}
@@ -177,6 +184,8 @@ static void run_loaded_program(size_t argc, char** argv, uintptr_t kstack_top)
init_tf(&tf, current.entry, stack_top);
__riscv_flush_icache();
write_csr(sscratch, kstack_top);
+ if (zicfilp_enabled)
+ set_csr(senvcfg, SENVCFG_LPE);
start_user(&tf);
}