Clear the C bit of the saved program state register when also clearing the

return value. We use this bit to signal when a syscall has failed, and
without this getcontext/setcontext may fail.

MFC after:	1 week
This commit is contained in:
Andrew Turner 2015-06-01 18:13:32 +00:00
parent 48056c88e1
commit 93b9a2a6f8

View File

@ -741,10 +741,13 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
struct trapframe *tf = td->td_frame;
__greg_t *gr = mcp->__gregs;
if (clear_ret & GET_MC_CLEAR_RET)
if (clear_ret & GET_MC_CLEAR_RET) {
gr[_REG_R0] = 0;
else
gr[_REG_CPSR] = tf->tf_spsr & ~PSR_C;
} else {
gr[_REG_R0] = tf->tf_r0;
gr[_REG_CPSR] = tf->tf_spsr;
}
gr[_REG_R1] = tf->tf_r1;
gr[_REG_R2] = tf->tf_r2;
gr[_REG_R3] = tf->tf_r3;
@ -760,7 +763,6 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
gr[_REG_SP] = tf->tf_usr_sp;
gr[_REG_LR] = tf->tf_usr_lr;
gr[_REG_PC] = tf->tf_pc;
gr[_REG_CPSR] = tf->tf_spsr;
return (0);
}