[Midnightbsd-cvs] src [7945] trunk/sys/amd64/amd64: xsavem natively supported, get rid of assembly versions in code

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Wed Sep 14 18:12:09 EDT 2016


Revision: 7945
          http://svnweb.midnightbsd.org/src/?rev=7945
Author:   laffer1
Date:     2016-09-14 18:12:09 -0400 (Wed, 14 Sep 2016)
Log Message:
-----------
xsavem natively supported, get rid of assembly versions in code

Modified Paths:
--------------
    trunk/sys/amd64/amd64/cpu_switch.S
    trunk/sys/amd64/amd64/fpu.c

Modified: trunk/sys/amd64/amd64/cpu_switch.S
===================================================================
--- trunk/sys/amd64/amd64/cpu_switch.S	2016-09-14 22:11:02 UTC (rev 7944)
+++ trunk/sys/amd64/amd64/cpu_switch.S	2016-09-14 22:12:09 UTC (rev 7945)
@@ -122,8 +122,7 @@
 1:	movq	%rdx,%rcx
 	movl	xsave_mask,%eax
 	movl	xsave_mask+4,%edx
-/*	xsave	(%r8) */
-	.byte	0x41,0x0f,0xae,0x20
+	xsave	(%r8)
 	movq	%rcx,%rdx
 2:	smsw	%ax
 	orb	$CR0_TS,%al

Modified: trunk/sys/amd64/amd64/fpu.c
===================================================================
--- trunk/sys/amd64/amd64/fpu.c	2016-09-14 22:11:02 UTC (rev 7944)
+++ trunk/sys/amd64/amd64/fpu.c	2016-09-14 22:12:09 UTC (rev 7945)
@@ -85,9 +85,7 @@
 
 	low = mask;
 	hi = mask >> 32;
-	/* xrstor (%rdi) */
-	__asm __volatile(".byte	0x0f,0xae,0x2f" : :
-	    "a" (low), "d" (hi), "D" (addr));
+	__asm __volatile("xrstor %0" : : "m" (*addr), "a" (low), "d" (hi));
 }
 
 static __inline void
@@ -97,22 +95,10 @@
 
 	low = mask;
 	hi = mask >> 32;
-	/* xsave (%rdi) */
-	__asm __volatile(".byte	0x0f,0xae,0x27" : :
-	    "a" (low), "d" (hi), "D" (addr) : "memory");
+	__asm __volatile("xsave %0" : "=m" (*addr) : "a" (low), "d" (hi) :
+	    "memory");
 }
 
-static __inline void
-xsetbv(uint32_t reg, uint64_t val)
-{
-	uint32_t low, hi;
-
-	low = val;
-	hi = val >> 32;
-	__asm __volatile(".byte 0x0f,0x01,0xd1" : :
-	    "c" (reg), "a" (low), "d" (hi));
-}
-
 #else	/* !(__GNUCLIKE_ASM && !lint) */
 
 void	fldcw(u_short cw);
@@ -127,7 +113,6 @@
 void	stop_emulating(void);
 void	xrstor(char *addr, uint64_t mask);
 void	xsave(char *addr, uint64_t mask);
-void	xsetbv(uint32_t reg, uint64_t val);
 
 #endif	/* __GNUCLIKE_ASM && !lint */
 
@@ -238,7 +223,7 @@
 
 	if (use_xsave) {
 		load_cr4(rcr4() | CR4_XSAVE);
-		xsetbv(XCR0, xsave_mask);
+		load_xcr(XCR0, xsave_mask);
 	}
 
 	/*



More information about the Midnightbsd-cvs mailing list