You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
riscv-pke/user/app_errorline.c

17 lines
540 B

/*
* Below is the given application for lab1_challenge2 (same as lab1_2).
* This app attempts to issue M-mode instruction in U-mode, and consequently raises an exception.
*/
#include "user_lib.h"
#include "util/types.h"
int main(void) {
printu("Going to hack the system by running privilege instructions.\n");
// we are now in U(user)-mode, but the "csrw" instruction requires M-mode privilege.
// Attempting to execute such instruction will raise illegal instruction exception.
asm volatile("csrw sscratch, 0");
exit(0);
}