diff options
author | Ruslan Bukin <br@FreeBSD.org> | 2018-07-27 16:13:06 +0000 |
---|---|---|
committer | Ruslan Bukin <br@FreeBSD.org> | 2018-07-27 16:13:06 +0000 |
commit | b51092c7ec2db8b52c50bafce4fd51e15e090560 (patch) | |
tree | e4f9aad2b481b885929e938e14d2636c107275cc /sys/riscv | |
parent | 6c85795a256fac2ca714542b7241c6b28f1023da (diff) | |
download | src-b51092c7ec2db8b52c50bafce4fd51e15e090560.tar.gz src-b51092c7ec2db8b52c50bafce4fd51e15e090560.zip |
Use SPP (Supervisor Previous Privilege) bit in the sstatus
register to determine if trap is from userspace.
Otherwise if we jump to kernel address from userspace, then
TRAPF_USERMODE failed to detect usermode and then do_ast
triggers a panic "ast in kernel mode".
Reviewed by: markj@
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D16469
Notes
Notes:
svn path=/head/; revision=336766
Diffstat (limited to 'sys/riscv')
-rw-r--r-- | sys/riscv/include/cpu.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/riscv/include/cpu.h b/sys/riscv/include/cpu.h index 9b488ac9ecb6..92c5c67ef597 100644 --- a/sys/riscv/include/cpu.h +++ b/sys/riscv/include/cpu.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015-2016 Ruslan Bukin <br@bsdpad.com> + * Copyright (c) 2015-2018 Ruslan Bukin <br@bsdpad.com> * All rights reserved. * * Portions of this software were developed by SRI International and the @@ -41,7 +41,7 @@ #include <machine/frame.h> #define TRAPF_PC(tfp) ((tfp)->tf_ra) -#define TRAPF_USERMODE(tfp) (((tfp)->tf_sepc & (1ul << 63)) == 0) +#define TRAPF_USERMODE(tfp) (((tfp)->tf_sstatus & SSTATUS_SPP) == 0) #define cpu_getstack(td) ((td)->td_frame->tf_sp) #define cpu_setstack(td, sp) ((td)->td_frame->tf_sp = (sp)) |