From 16094a3633ce22ff4861d6381dd804538bcd25c5 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 16 Aug 2009 21:03:08 -0700 Subject: [PATCH] AMD64 - Fix bogus signal interruption * The TF_XFLAGS field in the trap frame was not getting cleared on trap and syscall entry. This field can cause a mailbox signal to be flagged in the signal frame which in turn can cause the next blockable system call to return EINTR. This fixes the last issue with mount_mfs. * Cast the signal function to intptr_t rather then int. --- sys/kern/kern_sig.c | 6 +++--- sys/platform/pc64/amd64/exception.S | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index c8030e7..d5fc263 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1677,8 +1677,8 @@ issignal(struct lwp *lp, int maytrace) * Return the signal's number, or fall through * to clear it from the pending mask. */ - switch ((int)(intptr_t)p->p_sigacts->ps_sigact[_SIG_IDX(sig)]) { - case (int)SIG_DFL: + switch ((intptr_t)p->p_sigacts->ps_sigact[_SIG_IDX(sig)]) { + case (intptr_t)SIG_DFL: /* * Don't take default actions on system processes. */ @@ -1731,7 +1731,7 @@ issignal(struct lwp *lp, int maytrace) /*NOTREACHED*/ - case (int)SIG_IGN: + case (intptr_t)SIG_IGN: /* * Masking above should prevent us ever trying * to take action on an ignored signal other diff --git a/sys/platform/pc64/amd64/exception.S b/sys/platform/pc64/amd64/exception.S index a925abe..a0c8c93 100644 --- a/sys/platform/pc64/amd64/exception.S +++ b/sys/platform/pc64/amd64/exception.S @@ -128,6 +128,7 @@ IDTVEC(xmm) subq $TF_ERR,%rsp; \ movq $(a),TF_TRAPNO(%rsp) ; \ movq $0,TF_ADDR(%rsp) ; \ + movq $0,TF_XFLAGS(%rsp) ; \ jmp alltraps IDTVEC(tss) TRAP_ERR(T_TSSFLT) @@ -200,6 +201,7 @@ IDTVEC(dblfault) movq $T_DOUBLEFLT,TF_TRAPNO(%rsp) movq $0,TF_ADDR(%rsp) movq $0,TF_ERR(%rsp) + movq $0,TF_XFLAGS(%rsp) movq %rdi,TF_RDI(%rsp) movq %rsi,TF_RSI(%rsp) movq %rdx,TF_RDX(%rsp) @@ -233,6 +235,7 @@ IDTVEC(page) movq %rdi,TF_RDI(%rsp) /* free up a GP register */ movq %cr2,%rdi /* preserve %cr2 before .. */ movq %rdi,TF_ADDR(%rsp) /* enabling interrupts. */ + movq $0,TF_XFLAGS(%rsp) testq $PSL_I,TF_RFLAGS(%rsp) jz alltraps_pushregs_no_rdi sti @@ -248,6 +251,7 @@ IDTVEC(prot) subq $TF_ERR,%rsp movq $T_PROTFLT,TF_TRAPNO(%rsp) movq $0,TF_ADDR(%rsp) + movq $0,TF_XFLAGS(%rsp) movq %rdi,TF_RDI(%rsp) /* free up a GP register */ leaq doreti_iret(%rip),%rdi cmpq %rdi,TF_RIP(%rsp) @@ -283,6 +287,7 @@ IDTVEC(fast_syscall) movq $KUDSEL,TF_SS(%rsp) movq $KUCSEL,TF_CS(%rsp) movq $2,TF_ERR(%rsp) + movq $0,TF_XFLAGS(%rsp) /* note: used in signal frame */ movq %rdi,TF_RDI(%rsp) /* arg 1 */ movq %rsi,TF_RSI(%rsp) /* arg 2 */ movq %rdx,TF_RDX(%rsp) /* arg 3 */ @@ -337,6 +342,7 @@ IDTVEC(nmi) movq $(T_NMI),TF_TRAPNO(%rsp) movq $0,TF_ADDR(%rsp) movq $0,TF_ERR(%rsp) + movq $0,TF_XFLAGS(%rsp) movq %rdi,TF_RDI(%rsp) movq %rsi,TF_RSI(%rsp) movq %rdx,TF_RDX(%rsp) -- 1.7.7.2