Preserve the inherited value of the status register in cpu_set_upcall().

Instead of re-deriving the value of SR using logic similar to
exec_set_regs(), just inherit the value from the existing thread
similar to fork().

Reviewed by:	brooks
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D23059
This commit is contained in:
John Baldwin 2020-01-14 18:00:04 +00:00
parent 1e1c6bb49f
commit d0cacf5d12

View File

@ -414,7 +414,7 @@ cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
stack_t *stack)
{
struct trapframe *tf;
register_t sp;
register_t sp, sr;
sp = (((intptr_t)stack->ss_sp + stack->ss_size) & ~(STACK_ALIGN - 1)) -
CALLFRAME_SIZ;
@ -424,8 +424,10 @@ cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
* function.
*/
tf = td->td_frame;
sr = tf->sr;
bzero(tf, sizeof(struct trapframe));
tf->sp = sp;
tf->sr = sr;
tf->pc = (register_t)(intptr_t)entry;
/*
* MIPS ABI requires T9 to be the same as PC
@ -434,18 +436,6 @@ cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
tf->t9 = (register_t)(intptr_t)entry;
tf->a0 = (register_t)(intptr_t)arg;
/*
* Keep interrupt mask
*/
td->td_frame->sr = MIPS_SR_KSU_USER | MIPS_SR_EXL | MIPS_SR_INT_IE |
(mips_rd_status() & MIPS_SR_INT_MASK);
#if defined(__mips_n32)
td->td_frame->sr |= MIPS_SR_PX;
#elif defined(__mips_n64)
td->td_frame->sr |= MIPS_SR_PX | MIPS_SR_UX | MIPS_SR_KX;
#endif
/* tf->sr |= (ALL_INT_MASK & idle_mask) | SR_INT_ENAB; */
/**XXX the above may now be wrong -- mips2 implements this as panic */
/*
* FREEBSD_DEVELOPERS_FIXME:
* Setup any other CPU-Specific registers (Not MIPS Standard)