From owner-svn-src-head@freebsd.org Tue Dec 6 22:48:29 2016 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 789ACC69353; Tue, 6 Dec 2016 22:48:29 +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 301111C5F; Tue, 6 Dec 2016 22:48:29 +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 uB6MmSvN015527; Tue, 6 Dec 2016 22:48:28 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uB6MmSJc015526; Tue, 6 Dec 2016 22:48:28 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201612062248.uB6MmSJc015526@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 6 Dec 2016 22:48:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309657 - head/sys/x86/x86 X-SVN-Group: head 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: Tue, 06 Dec 2016 22:48:29 -0000 Author: markj Date: Tue Dec 6 22:48:28 2016 New Revision: 309657 URL: https://svnweb.freebsd.org/changeset/base/309657 Log: Require the STACK option for code that captures stacks of running threads. stack_machdep.c is compiled if either of the DDB or STACK options is specified, but stack_save_td_running() isn't useable from DDB. Moreover, stack_save_td_running() works by raising an NMI on the CPU running the target thread, and the corresponding handler is compiled only if STACK is configured. Reported by: kib MFC after: 1 week Modified: head/sys/x86/x86/stack_machdep.c Modified: head/sys/x86/x86/stack_machdep.c ============================================================================== --- head/sys/x86/x86/stack_machdep.c Tue Dec 6 20:44:40 2016 (r309656) +++ head/sys/x86/x86/stack_machdep.c Tue Dec 6 22:48:28 2016 (r309657) @@ -28,6 +28,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_stack.h" + #include #include #include @@ -59,6 +61,7 @@ typedef struct i386_frame *x86_frame_t; typedef struct amd64_frame *x86_frame_t; #endif +#ifdef STACK static struct stack *nmi_stack; static volatile struct thread *nmi_pending; @@ -66,6 +69,7 @@ static volatile struct thread *nmi_pendi static struct mtx nmi_lock; MTX_SYSINIT(nmi_lock, &nmi_lock, "stack_nmi", MTX_SPIN); #endif +#endif static void stack_capture(struct thread *td, struct stack *st, register_t fp) @@ -95,6 +99,7 @@ int stack_nmi_handler(struct trapframe *tf) { +#ifdef STACK /* Don't consume an NMI that wasn't meant for us. */ if (nmi_stack == NULL || curthread != nmi_pending) return (0); @@ -107,6 +112,9 @@ stack_nmi_handler(struct trapframe *tf) atomic_store_rel_ptr((long *)&nmi_pending, (long)NULL); return (1); +#else + return (0); +#endif } void @@ -125,6 +133,7 @@ int stack_save_td_running(struct stack *st, struct thread *td) { +#ifdef STACK THREAD_LOCK_ASSERT(td, MA_OWNED); MPASS(TD_IS_RUNNING(td)); @@ -148,10 +157,13 @@ stack_save_td_running(struct stack *st, if (st->depth == 0) /* We interrupted a thread in user mode. */ return (EAGAIN); -#else +#else /* !SMP */ KASSERT(0, ("curthread isn't running")); -#endif +#endif /* SMP */ return (0); +#else /* !STACK */ + return (EOPNOTSUPP); +#endif /* STACK */ } void