From b0821890140f70e9e8358a5d7d1764f182999781 Mon Sep 17 00:00:00 2001
From: Mark Kettenis <kettenis@cvs.openbsd.org>
Date: Thu, 19 Aug 2010 19:31:54 +0000
Subject: Add "memory" clobber to lidt inline asm, to prevent the GCC optimizer
 from getting stupid ideas like optimizing away stores to the descriptor that
 we're setting.  This may be overkill, but this code is far from performance
 critical and it may prevent future surprises.  Fixes instant reboots with
 bsd.rd on Pentiums with the F00F bug.

Thanks to espie@, for narrowing the issue down enough for me to find the
problem.  ok deraadt@
---
 sys/arch/amd64/include/cpufunc.h | 4 ++--
 sys/arch/i386/include/cpufunc.h  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

(limited to 'sys/arch')

diff --git a/sys/arch/amd64/include/cpufunc.h b/sys/arch/amd64/include/cpufunc.h
index 31a2c67ebc3..d57afa55048 100644
--- a/sys/arch/amd64/include/cpufunc.h
+++ b/sys/arch/amd64/include/cpufunc.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: cpufunc.h,v 1.4 2009/12/09 14:28:46 oga Exp $	*/
+/*	$OpenBSD: cpufunc.h,v 1.5 2010/08/19 19:31:53 kettenis Exp $	*/
 /*	$NetBSD: cpufunc.h,v 1.3 2003/05/08 10:27:43 fvdl Exp $	*/
 
 /*-
@@ -61,7 +61,7 @@ invlpg(u_int64_t addr)
 static __inline void
 lidt(void *p)
 {
-	__asm __volatile("lidt (%0)" : : "r" (p));
+	__asm __volatile("lidt (%0)" : : "r" (p) : "memory");
 }
 
 static __inline void
diff --git a/sys/arch/i386/include/cpufunc.h b/sys/arch/i386/include/cpufunc.h
index 3f37e86627c..0da7c4807a6 100644
--- a/sys/arch/i386/include/cpufunc.h
+++ b/sys/arch/i386/include/cpufunc.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: cpufunc.h,v 1.16 2009/12/09 14:28:46 oga Exp $	*/
+/*	$OpenBSD: cpufunc.h,v 1.17 2010/08/19 19:31:53 kettenis Exp $	*/
 /*	$NetBSD: cpufunc.h,v 1.8 1994/10/27 04:15:59 cgd Exp $	*/
 
 /*
@@ -78,7 +78,7 @@ invlpg(u_int addr)
 static __inline void
 lidt(void *p)
 {
-	__asm __volatile("lidt (%0)" : : "r" (p));
+	__asm __volatile("lidt (%0)" : : "r" (p) : "memory");
 }
 
 static __inline void
-- 
cgit v1.2.3