From owner-svn-src-head@freebsd.org Mon Jul 31 17:57:56 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E786DB5A6E; Mon, 31 Jul 2017 17:57:56 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 28355294F; Mon, 31 Jul 2017 17:57:56 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6VHvteQ061353; Mon, 31 Jul 2017 17:57:55 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6VHvtlP061352; Mon, 31 Jul 2017 17:57:55 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201707311757.v6VHvtlP061352@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 31 Jul 2017 17:57:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r321803 - head/sys/x86/x86 X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/x86/x86 X-SVN-Commit-Revision: 321803 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Jul 2017 17:57:56 -0000 Author: markj Date: Mon Jul 31 17:57:54 2017 New Revision: 321803 URL: https://svnweb.freebsd.org/changeset/base/321803 Log: Don't trace running threads that have interrupts disabled. In this case we shouldn't assume that the thread has a valid frame pointer. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D11787 Modified: head/sys/x86/x86/stack_machdep.c Modified: head/sys/x86/x86/stack_machdep.c ============================================================================== --- head/sys/x86/x86/stack_machdep.c Mon Jul 31 17:57:44 2017 (r321802) +++ head/sys/x86/x86/stack_machdep.c Mon Jul 31 17:57:54 2017 (r321803) @@ -49,12 +49,14 @@ __FBSDID("$FreeBSD$"); #ifdef __i386__ #define PCB_FP(pcb) ((pcb)->pcb_ebp) +#define TF_FLAGS(tf) ((tf)->tf_eflags) #define TF_FP(tf) ((tf)->tf_ebp) #define TF_PC(tf) ((tf)->tf_eip) typedef struct i386_frame *x86_frame_t; #else #define PCB_FP(pcb) ((pcb)->pcb_rbp) +#define TF_FLAGS(tf) ((tf)->tf_rflags) #define TF_FP(tf) ((tf)->tf_rbp) #define TF_PC(tf) ((tf)->tf_rip) @@ -104,10 +106,10 @@ stack_nmi_handler(struct trapframe *tf) if (nmi_stack == NULL || curthread != nmi_pending) return (0); - if (INKERNEL(TF_PC(tf))) + if (INKERNEL(TF_PC(tf)) && (TF_FLAGS(tf) & PSL_I) != 0) stack_capture(curthread, nmi_stack, TF_FP(tf)); else - /* We interrupted a thread in user mode. */ + /* We were running in usermode or had interrupts disabled. */ nmi_stack->depth = 0; atomic_store_rel_ptr((long *)&nmi_pending, (long)NULL); @@ -155,7 +157,6 @@ stack_save_td_running(struct stack *st, struct thread mtx_unlock_spin(&nmi_lock); if (st->depth == 0) - /* We interrupted a thread in user mode. */ return (EAGAIN); #else /* !SMP */ KASSERT(0, ("curthread isn't running"));