From owner-svn-src-all@FreeBSD.ORG Thu Apr 19 10:53:18 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0EB4B106564A; Thu, 19 Apr 2012 10:53:18 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D3D278FC08; Thu, 19 Apr 2012 10:53:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3JArHcX085659; Thu, 19 Apr 2012 10:53:17 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3JArHKj085655; Thu, 19 Apr 2012 10:53:17 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204191053.q3JArHKj085655@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 19 Apr 2012 10:53:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234457 - in stable/8/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Apr 2012 10:53:18 -0000 Author: kib Date: Thu Apr 19 10:53:17 2012 New Revision: 234457 URL: http://svn.freebsd.org/changeset/base/234457 Log: MFC r234172: Add thread-private flag to indicate that error value is already placed in td_errno. Flag is supposed to be used by syscalls returning EJUSTRETURN because errno was already placed into the usermode frame by a call to set_syscall_retval(9). Both ktrace and dtrace get errno value from td_errno if the flag is set. Use the flag to fix sigsuspend(2) error return ktrace records. Modified: stable/8/sys/kern/kern_sig.c stable/8/sys/kern/subr_syscall.c stable/8/sys/sys/proc.h Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/kern/kern_sig.c ============================================================================== --- stable/8/sys/kern/kern_sig.c Thu Apr 19 10:48:25 2012 (r234456) +++ stable/8/sys/kern/kern_sig.c Thu Apr 19 10:53:17 2012 (r234457) @@ -1489,6 +1489,8 @@ kern_sigsuspend(struct thread *td, sigse mtx_unlock(&p->p_sigacts->ps_mtx); } PROC_UNLOCK(p); + td->td_errno = EINTR; + td->td_pflags |= TDP_NERRNO; return (EJUSTRETURN); } Modified: stable/8/sys/kern/subr_syscall.c ============================================================================== --- stable/8/sys/kern/subr_syscall.c Thu Apr 19 10:48:25 2012 (r234456) +++ stable/8/sys/kern/subr_syscall.c Thu Apr 19 10:53:17 2012 (r234457) @@ -115,7 +115,8 @@ syscallenter(struct thread *td, struct s AUDIT_SYSCALL_EXIT(error, td); /* Save the latest error return value. */ - td->td_errno = error; + if ((td->td_pflags & TDP_NERRNO) == 0) + td->td_errno = error; #ifdef KDTRACE_HOOKS /* @@ -169,9 +170,12 @@ syscallret(struct thread *td, int error, syscallname(p, sa->code), td, td->td_proc->p_pid, td->td_name); #ifdef KTRACE - if (KTRPOINT(td, KTR_SYSRET)) - ktrsysret(sa->code, error, td->td_retval[0]); + if (KTRPOINT(td, KTR_SYSRET)) { + ktrsysret(sa->code, (td->td_pflags & TDP_NERRNO) == 0 ? + error : td->td_errno, td->td_retval[0]); + } #endif + td->td_pflags &= ~TDP_NERRNO; if (p->p_flag & P_TRACED) { traced = 1; Modified: stable/8/sys/sys/proc.h ============================================================================== --- stable/8/sys/sys/proc.h Thu Apr 19 10:48:25 2012 (r234456) +++ stable/8/sys/sys/proc.h Thu Apr 19 10:53:17 2012 (r234457) @@ -410,6 +410,7 @@ do { \ #define TDP_IGNSUSP 0x00800000 /* Permission to ignore the MNTK_SUSPEND* */ #define TDP_AUDITREC 0x01000000 /* Audit record pending on thread */ #define TDP_RESETSPUR 0x04000000 /* Reset spurious page fault history. */ +#define TDP_NERRNO 0x08000000 /* Last errno is already in td_errno */ /* * Reasons that the current thread can not be run yet.