From owner-freebsd-acpi@FreeBSD.ORG Mon Jul 15 22:06:06 2013 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A0AB91B8 for ; Mon, 15 Jul 2013 22:06:06 +0000 (UTC) (envelope-from taku@tackymt.homeip.net) Received: from basalt.tackymt.homeip.net (basalt.tackymt.homeip.net [IPv6:2001:470:fd92:0:20d:61ff:fecc:2253]) by mx1.freebsd.org (Postfix) with ESMTP id 6935DD8F for ; Mon, 15 Jul 2013 22:06:06 +0000 (UTC) Received: from basalt.tackymt.homeip.net (localhost [127.0.0.1]) by basalt.tackymt.homeip.net (Postfix) with ESMTP id D398183C5 for ; Tue, 16 Jul 2013 07:06:05 +0900 (JST) X-Virus-Scanned: amavisd-new at tackymt.homeip.net Received: from localhost by basalt.tackymt.homeip.net (amavisd-new, unix socket) with ESMTP id 9GL6RZcyBnku for ; Tue, 16 Jul 2013 07:06:04 +0900 (JST) Received: from biotite.tackymt.homeip.net (biotite.tackymt.homeip.net [IPv6:2001:470:fd92:0:216:cfff:febc:1472]) by basalt.tackymt.homeip.net (Postfix) with ESMTPSA for ; Tue, 16 Jul 2013 07:06:04 +0900 (JST) Date: Tue, 16 Jul 2013 07:07:16 +0900 From: Taku YAMAMOTO To: freebsd-acpi@freebsd.org Subject: Revisiting FPU context resume on i386 Message-Id: <20130716070716.15b7282b9dca2cbc8a767631@tackymt.homeip.net> X-Mailer: Sylpheed 3.3.0 (GTK+ 2.24.17; i386-portbld-freebsd10.0) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Tue__16_Jul_2013_07_07_16_+0900_h+CNhL/Y5tSJPtQm" X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jul 2013 22:06:06 -0000 This is a multi-part message in MIME format. --Multipart=_Tue__16_Jul_2013_07_07_16_+0900_h+CNhL/Y5tSJPtQm Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hi all, sys/i386/i386/swtch.s have a big FIX ME in resumectx() and I have occationally got bitten by it; resulting in SIGFPE disasters. After cursory looking around FPU context, I think it's the simplest way to set CR0_TS on resumectx() and to let npxdna() DTRT lazilly. Attached is the mods that I'm currently using without a problem at the moment. It at least doesn't interact with normal resume operations badly. Ah, of cource, we have a choice to throw i386 away and get on amd64, but at least I won't because I'd miss VOCALOIDs running on wine/i386 :) -- -|-__ YAMAMOTO, Taku | __ < - A chicken is an egg's way of producing more eggs. - --Multipart=_Tue__16_Jul_2013_07_07_16_+0900_h+CNhL/Y5tSJPtQm Content-Type: text/plain; name="i386-resumectx-fpu.patch" Content-Disposition: attachment; filename="i386-resumectx-fpu.patch" Content-Transfer-Encoding: 7bit commit 99a24d7c19d624654afbd574e604d8a011ed28b3 Author: Taku YAMAMOTO Date: Sun Jul 14 07:36:29 2013 +0900 i386: defer FPU context resume from resumectx() to npxdna() by CR0_TS. diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s index 80aa6c4..71efae1 100644 --- a/sys/i386/i386/swtch.s +++ b/sys/i386/i386/swtch.s @@ -36,6 +36,7 @@ #include "opt_sched.h" #include +#include #include "assym.s" @@ -487,6 +488,10 @@ ENTRY(resumectx) movl PCB_CR3(%ecx),%eax movl %eax,%cr3 movl PCB_CR0(%ecx),%eax +#ifdef DEV_NPX + /* Let npxdna() restore the FPU context lazily. */ + orl $CR0_TS,%eax +#endif movl %eax,%cr0 jmp 1f 1: @@ -519,10 +524,6 @@ ENTRY(resumectx) movl PCB_DR7(%ecx),%eax movl %eax,%dr7 -#ifdef DEV_NPX - /* XXX FIX ME */ -#endif - /* Restore other registers */ movl PCB_EDI(%ecx),%edi movl PCB_ESI(%ecx),%esi --Multipart=_Tue__16_Jul_2013_07_07_16_+0900_h+CNhL/Y5tSJPtQm--