From owner-freebsd-current@freebsd.org Mon Aug 8 18:37:49 2016 Return-Path: Delivered-To: freebsd-current@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 78DFBBB2F78 for ; Mon, 8 Aug 2016 18:37:49 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 09C4E180B; Mon, 8 Aug 2016 18:37:48 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u78IbhN9043163 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Mon, 8 Aug 2016 21:37:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u78IbhN9043163 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u78IbhKB043162; Mon, 8 Aug 2016 21:37:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 8 Aug 2016 21:37:43 +0300 From: Konstantin Belousov To: Don Lewis Cc: freebsd-current@freebsd.org, John Baldwin Subject: Re: kernel panic caused by virtualbox(?) Message-ID: <20160808183743.GL83214@kib.kiev.ua> References: <201608050132.u751WE75016607@gw.catspoiler.org> <2743385.seuRjyAMVA@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2743385.seuRjyAMVA@ralph.baldwin.cx> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2016 18:37:49 -0000 On Mon, Aug 08, 2016 at 10:22:44AM -0700, John Baldwin wrote: > On Thursday, August 04, 2016 05:10:29 PM Don Lewis wrote: > > Reposted to -current to get some more eyes on this ... > > > > I just got a kernel panic when I started up a CentOS 7 VM in virtualbox. > > The host is: > > FreeBSD 12.0-CURRENT #17 r302500 GENERIC amd64 > > The virtualbox version is: > > virtualbox-ose-5.0.26 > > virtualbox-ose-kmod-5.0.26_1 > > > > The panic message is: > > > > panic: Unregistered use of FPU in kernel > > cpuid = 1 > > KDB: stack backtrace: > > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe085a55d030 > > vpanic() at vpanic+0x182/frame 0xfffffe085a55d0b0 > > kassert_panic() at kassert_panic+0x126/frame 0xfffffe085a55d120 > > trap() at trap+0x7ae/frame 0xfffffe085a55d330 > > calltrap() at calltrap+0x8/frame 0xfffffe085a55d330 > > --- trap 0x16, rip = 0xffffffff827dd3a9, rsp = 0xfffffe085a55d408, rbp = 0xfffffe085a55d430 --- > > g_pLogger() at 0xffffffff827dd3a9/frame 0xfffffe085a55d430 > > g_pLogger() at 0xffffffff8274e5c7/frame 0x3 > > KDB: enter: panic > > > > Since g_pLogger is a symbol in vboxdrv.ko, it looks like virtualbox is > > the trigger. > > > > There are no symbols for the virtualbox kmods, possibly because I > > installed them as an upgrade using packages (built with the same source > > tree version) instead of by using PORTS_MODULES in make.conf, so ports > > kgdb didn't have anything useful to say about what happened before the > > trap. > > > > This panic is very repeatable. I just got another one when starting the > > same VM., but this time the two calls before the trap were > > null_bug_bypass(). Hmn, that symbol is in nullfs ... > > > > I don't see this with a Windows 7 VM. > > > > All of the virtualbox kmod files are compiled with -mno-mmx -mno-sse > > -msoft-float -mno-aes -mno-avx Your disassemble listed fxrstor instruction that failing, or did I mis-remembered ? This is most likely some context switch code, either by virtual machine or erronously executed guest code. It is not a spontaneous use of FPU, but more likely something different. Can you confirm ? In either case, I do not remember any KBI changes around PCB layout or fpu_enter() KPI recently. > > I suspect head packages are quite likely built against the a "wrong" KBI > and are too fragile to use for kmods vs compiling from ports. :-/ I would > try a built-from-ports kmod to see if the panics go away. FWIW, I will commit the following change shortly. Since third-party modules break the invariant, either due to bugs (ndis wrappers) or possibly due to KBI breakage, it is worth to have the detection enabled for production kernels. diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 1b85b32..04c5dcc 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -443,8 +443,8 @@ trap(struct trapframe *frame) goto out; case T_DNA: - KASSERT(!PCB_USER_FPU(td->td_pcb), - ("Unregistered use of FPU in kernel")); + if (PCB_USER_FPU(td->td_pcb)) + panic("Unregistered use of FPU in kernel"); fpudna(); goto out; diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 40f7204..c540a49 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -540,8 +540,8 @@ trap(struct trapframe *frame) case T_DNA: #ifdef DEV_NPX - KASSERT(!PCB_USER_FPU(td->td_pcb), - ("Unregistered use of FPU in kernel")); + if (PCB_USER_FPU(td->td_pcb)) + panic("Unregistered use of FPU in kernel"); if (npxdna()) goto out; #endif