From owner-freebsd-bugs Sat Nov 22 02:05:14 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id CAA27192 for bugs-outgoing; Sat, 22 Nov 1997 02:05:14 -0800 (PST) (envelope-from owner-freebsd-bugs) Received: from utogw.gssm.otsuka.tsukuba.ac.jp (utogw.gssm.otsuka.tsukuba.ac.jp [192.50.17.2]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id CAA27156 for ; Sat, 22 Nov 1997 02:04:57 -0800 (PST) (envelope-from ohki@gssm.otsuka.tsukuba.ac.jp) From: ohki@gssm.otsuka.tsukuba.ac.jp Received: from smr00.gssm.otsuka.tsukuba.ac.jp (smr00 [192.50.17.5]) by utogw.gssm.otsuka.tsukuba.ac.jp (8.6.12/8.6.9) with ESMTP id TAA28135; Sat, 22 Nov 1997 19:03:35 +0900 Received: from localhost (localhost [127.0.0.1]) by smr00.gssm.otsuka.tsukuba.ac.jp (8.8.5/8.8.5) with ESMTP id TAA22516; Sat, 22 Nov 1997 19:03:16 +0900 (JST) Message-Id: <199711221003.TAA22516@smr00.gssm.otsuka.tsukuba.ac.jp> To: freebsd-bugs@FreeBSD.org Subject: Pentium f00f problem -- possible fix Mime-Version: 1.0 Content-Type: text/plain;charset="us-ascii" Cc: ohki@gssm.otsuka.tsukuba.ac.jp Date: Sat, 22 Nov 1997 19:03:16 +0900 Sender: owner-freebsd-bugs@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk Hi FreeBSD folks You might have fixed the problem of newly discovered bug of Pentium. (code sequence of 0xf0 0x0f 0xc7 0xc8 freezes the system) I implemented the recommended solution comes from Intel, and enclosed context diffs. It is my pleasure if it helps you. --- locore.s-ORIG Sat Feb 1 21:10:54 1997 +++ locore.s Sat Nov 22 16:42:23 1997 @@ -99,6 +99,17 @@ */ .data ALIGN_DATA /* just to be sure */ +#if defined(I586_CPU) + /* + * work around for f00f problem of Pentium + * trap to page fault before the machine hangs + */ + .globl _idt + .space PAGE_SIZE - 8*7 +_idt: + .space 8*7 /* cause page fault for idt[0] to idt[6] */ + .space PAGE_SIZE +#endif defined(I586_CPU) .globl tmpstk .space 0x2000 /* space for tmpstk - temporary stack */ --- machdep.c-ORIG Thu Apr 3 15:37:31 1997 +++ machdep.c Sat Nov 22 18:50:04 1997 @@ -39,6 +39,7 @@ */ #include "npx.h" +#include "opt_cpu.h" /* XXX */ #include "opt_sysvipc.h" #include "opt_ddb.h" #include "opt_bounce.h" @@ -206,6 +207,13 @@ * Good {morning,afternoon,evening,night}. */ printf(version); +#if defined(I586_CPU) + if (cpu == CPU_586) { + unsigned *pte = (unsigned *)vtopte(idt); + *pte &= ~PG_V; + printf("Pentium -- enable workaround for f00f problem!\n"); + } +#endif defined(I586_CPU) earlysetcpuclass(); startrtclock(); identifycpu(); --- exception.s-ORIG Mon Aug 12 02:41:23 1996 +++ exception.s Sat Nov 22 18:44:22 1997 @@ -33,6 +33,7 @@ * $Id: exception.s,v 1.19 1996/08/11 17:41:23 davidg Exp $ */ +#include "opt_cpu.h" /* XXX */ #include "npx.h" /* NNPX */ #include "assym.s" /* system defines */ #include /* error return codes */ @@ -42,6 +43,9 @@ #include /* syscall numbers */ #include /* miscellaneous macros */ #include /* CPP macros */ +#if defined(I586_CPU) +#include +#endif /* defined(I586) */ #define KDSEL 0x10 /* kernel data selector */ #define SEL_RPL_MASK 0x0003 @@ -112,6 +116,39 @@ IDTVEC(prot) TRAP(T_PROTFLT) IDTVEC(page) +#if defined(I586_CPU) +#define IDTVECnm(name) __CONCAT(_X,name) + /* data segment is not KERNEL ! */ + pushl %eax + cmpl $CPU_586,%cs:_cpu + jne 1f + movl %cr2,%eax + subl $_idt,%eax + shrl $3,%eax + cmpl $6,%eax + ja 1f + /* + * page fault via accessing idt[0] to idt[6] + * dispatch to them + */ + movl %cs:trp_vec(,%eax,4),%eax + movl %eax,4(%esp) /* holding error code */ + popl %eax + addl $4,%esp /* adjust stack to discard error code */ + jmp *-4(%esp) +trp_vec: + /* order must be the same as in machdep.c */ + .long IDTVECnm(div) + .long IDTVECnm(dbg) + .long IDTVECnm(nmi) + .long IDTVECnm(bpt) + .long IDTVECnm(ofl) + .long IDTVECnm(bnd) + .long IDTVECnm(ill) +#undef IDTVECnm +1: + popl %eax +#endif /* defined(I586_CPU) */ TRAP(T_PAGEFLT) IDTVEC(mchk) pushl $0; TRAP(T_MCHK)