From 1ebf348bd078d6c908fd9dae35b458b526cf8f7e Mon Sep 17 00:00:00 2001
From: jhb <jhb@FreeBSD.org>
Date: Thu, 6 Jul 2000 00:13:21 +0000
Subject: Emulate the WBINVD instruction when it is called by the BIOS.

---
 sys/boot/i386/btx/btx/btx.S | 21 +++++++++++++++------
 sys/boot/i386/btx/btx/btx.s | 21 +++++++++++++++------
 2 files changed, 30 insertions(+), 12 deletions(-)

(limited to 'sys/boot')

diff --git a/sys/boot/i386/btx/btx/btx.S b/sys/boot/i386/btx/btx/btx.S
index 827a444..48729cf 100644
--- a/sys/boot/i386/btx/btx/btx.S
+++ b/sys/boot/i386/btx/btx/btx.S
@@ -480,6 +480,8 @@ v86mon.2:	cmpb $0xf4,%al			# HLT?
 		jmp intrtn			# Return to user mode
 v86mon.3:	cmpb $0xf,%al			# Prefixed instruction?
 		jne v86mon.4			# No
+		cmpb $0x09,(%esi)		# Is it a WBINVD?
+		je v86wbinvd			# Yes
 		cmpb $0x30,(%esi)		# Is it a WRMSR?
 		je v86wrmsr			# Yes
 		cmpb $0x32,(%esi)		# Is it a RDMSR?
@@ -522,18 +524,26 @@ v86mon.7:	subl %edi,%esi			# From linear
 #
 v86mov: 	movl %cr0,%eax			# CR0 to
 		movl %eax,0x1c(%ebp)		#  saved EAX
-		incl %esi			# Adjust
-		incl %esi			#  IP
+		incl %esi			# Adjust IP
+#
+# Return from emulating a 0x0f prefixed instruction
+#
+v86preret:	incl %esi			# Adjust IP
 		jmp v86mon.7			# Finish up
 #
+# Emulate WBINVD
+#
+v86wbinvd:	wbinvd				# Write back and invalidate
+						#  cache
+		jmp v86preret			# Finish up
+#
 # Emulate WRMSR
 #
 v86wrmsr:	movl 0x18(%ebp),%ecx		# Get user's %ecx (MSR to write)
 		movl 0x14(%ebp),%edx		# Load the value
 		movl 0x1c(%ebp),%eax		#  to write
 		wrmsr				# Write MSR
-		incl %esi			# Adjust IP
-		jmp v86mon.7			# Finish up
+		jmp v86preret			# Finish up
 #
 # Emulate RDMSR
 #
@@ -541,8 +551,7 @@ v86rdmsr:	movl 0x18(%ebp),%ecx		# MSR to read
 		rdmsr				# Read the MSR
 		movl %eax,0x1c(%ebp)		# Return the value of
 		movl %edx,0x14(%ebp)		#  the MSR to the user
-		incl %esi			# Adjust IP
-		jmp v86mon.7
+		jmp v86preret			# Finish up
 #
 # Emulate CLI.
 #
diff --git a/sys/boot/i386/btx/btx/btx.s b/sys/boot/i386/btx/btx/btx.s
index 827a444..48729cf 100644
--- a/sys/boot/i386/btx/btx/btx.s
+++ b/sys/boot/i386/btx/btx/btx.s
@@ -480,6 +480,8 @@ v86mon.2:	cmpb $0xf4,%al			# HLT?
 		jmp intrtn			# Return to user mode
 v86mon.3:	cmpb $0xf,%al			# Prefixed instruction?
 		jne v86mon.4			# No
+		cmpb $0x09,(%esi)		# Is it a WBINVD?
+		je v86wbinvd			# Yes
 		cmpb $0x30,(%esi)		# Is it a WRMSR?
 		je v86wrmsr			# Yes
 		cmpb $0x32,(%esi)		# Is it a RDMSR?
@@ -522,18 +524,26 @@ v86mon.7:	subl %edi,%esi			# From linear
 #
 v86mov: 	movl %cr0,%eax			# CR0 to
 		movl %eax,0x1c(%ebp)		#  saved EAX
-		incl %esi			# Adjust
-		incl %esi			#  IP
+		incl %esi			# Adjust IP
+#
+# Return from emulating a 0x0f prefixed instruction
+#
+v86preret:	incl %esi			# Adjust IP
 		jmp v86mon.7			# Finish up
 #
+# Emulate WBINVD
+#
+v86wbinvd:	wbinvd				# Write back and invalidate
+						#  cache
+		jmp v86preret			# Finish up
+#
 # Emulate WRMSR
 #
 v86wrmsr:	movl 0x18(%ebp),%ecx		# Get user's %ecx (MSR to write)
 		movl 0x14(%ebp),%edx		# Load the value
 		movl 0x1c(%ebp),%eax		#  to write
 		wrmsr				# Write MSR
-		incl %esi			# Adjust IP
-		jmp v86mon.7			# Finish up
+		jmp v86preret			# Finish up
 #
 # Emulate RDMSR
 #
@@ -541,8 +551,7 @@ v86rdmsr:	movl 0x18(%ebp),%ecx		# MSR to read
 		rdmsr				# Read the MSR
 		movl %eax,0x1c(%ebp)		# Return the value of
 		movl %edx,0x14(%ebp)		#  the MSR to the user
-		incl %esi			# Adjust IP
-		jmp v86mon.7
+		jmp v86preret			# Finish up
 #
 # Emulate CLI.
 #
-- 
cgit v1.1