Date: Sat, 22 Nov 1997 19:03:16 +0900 From: ohki@gssm.otsuka.tsukuba.ac.jp To: freebsd-bugs@FreeBSD.org Cc: ohki@gssm.otsuka.tsukuba.ac.jp Subject: Pentium f00f problem -- possible fix Message-ID: <199711221003.TAA22516@smr00.gssm.otsuka.tsukuba.ac.jp>
next in thread | raw e-mail | index | archive | help
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 <sys/errno.h> /* error return codes */ @@ -42,6 +43,9 @@ #include <sys/syscall.h> /* syscall numbers */ #include <machine/asmacros.h> /* miscellaneous macros */ #include <sys/cdefs.h> /* CPP macros */ +#if defined(I586_CPU) +#include <machine/cputypes.h> +#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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711221003.TAA22516>