Module Name:    src
Committed By:   maxv
Date:           Wed Oct 30 17:06:57 UTC 2019

Modified Files:
        src/sys/arch/amd64/amd64: cpufunc.S
        src/sys/arch/i386/i386: cpufunc.S
        src/sys/arch/x86/include: cpufunc.h

Log Message:
More inlined ASM.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/i386/i386/cpufunc.S
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/x86/include/cpufunc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.45 src/sys/arch/amd64/amd64/cpufunc.S:1.46
--- src/sys/arch/amd64/amd64/cpufunc.S:1.45	Sat Sep  7 18:56:01 2019
+++ src/sys/arch/amd64/amd64/cpufunc.S	Wed Oct 30 17:06:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.45 2019/09/07 18:56:01 maxv Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.46 2019/10/30 17:06:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -313,16 +313,6 @@ ENTRY(x86_mwait)
 	ret
 END(x86_mwait)
 
-ENTRY(fnsave)
-	fnsave	(%rdi)
-	ret
-END(fnsave)
-
-ENTRY(frstor)
-	frstor	(%rdi)
-	ret
-END(frstor)
-
 ENTRY(stts)
 	movq	%cr0, %rax
 	orq	$CR0_TS, %rax
@@ -330,46 +320,12 @@ ENTRY(stts)
 	ret
 END(stts)
 
-ENTRY(fxsave)
-	fxsave	(%rdi)
-	ret
-END(fxsave)
-
-ENTRY(fxrstor)
-	fxrstor	(%rdi)
-	ret
-END(fxrstor)
-
 ENTRY(fldummy)
 	ffree	%st(7)
 	fldz
 	ret
 END(fldummy)
 
-ENTRY(xsave)
-	movq	%rsi, %rax
-	movq	%rsi, %rdx
-	shrq	$32, %rdx
-	xsave	(%rdi)
-	ret
-END(xsave)
-
-ENTRY(xsaveopt)
-	movq	%rsi, %rax
-	movq	%rsi, %rdx
-	shrq	$32, %rdx
-	xsaveopt	(%rdi)
-	ret
-END(xsaveopt)
-
-ENTRY(xrstor)
-	movq	%rsi, %rax
-	movq	%rsi, %rdx
-	shrq	$32, %rdx
-	xrstor	(%rdi)
-	ret
-END(xrstor)
-
 ENTRY(inb)
 	movq	%rdi, %rdx
 	xorq	%rax, %rax

Index: src/sys/arch/i386/i386/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.35 src/sys/arch/i386/i386/cpufunc.S:1.36
--- src/sys/arch/i386/i386/cpufunc.S:1.35	Sat Sep  7 18:33:16 2019
+++ src/sys/arch/i386/i386/cpufunc.S	Wed Oct 30 17:06:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.35 2019/09/07 18:33:16 maxv Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.36 2019/10/30 17:06:57 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include <sys/errno.h>
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.35 2019/09/07 18:33:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.36 2019/10/30 17:06:57 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -224,18 +224,6 @@ ENTRY(x86_mwait)  
 	ret
 END(x86_mwait)  
 
-ENTRY(fnsave)
-	movl	4(%esp), %eax
-	fnsave	(%eax)
-	ret
-END(fnsave)
-
-ENTRY(frstor)
-	movl	4(%esp), %eax
-	frstor	(%eax)
-	ret
-END(frstor)
-
 ENTRY(stts)
 	movl	%cr0, %eax
 	testl	$CR0_TS, %eax
@@ -246,42 +234,6 @@ ENTRY(stts)
 	ret
 END(stts)
 
-ENTRY(fxsave)
-	movl	4(%esp), %eax
-	fxsave	(%eax)
-	ret
-END(fxsave)
-
-ENTRY(fxrstor)
-	movl	4(%esp), %eax
-	fxrstor	(%eax)
-	ret
-END(fxrstor)
-
-ENTRY(xsave)
-	movl	4(%esp), %ecx
-	movl	8(%esp), %eax	/* feature mask bits */
-	movl	12(%esp), %edx
-	xsave	(%ecx)
-	ret
-END(xsave)
-
-ENTRY(xsaveopt)
-	movl	4(%esp), %ecx
-	movl	8(%esp), %eax	/* feature mask bits */
-	movl	12(%esp), %edx
-	xsaveopt	(%ecx)
-	ret
-END(xsaveopt)
-
-ENTRY(xrstor)
-	movl	4(%esp), %ecx
-	movl	8(%esp), %eax	/* feature mask bits */
-	movl	12(%esp), %edx
-	xrstor	(%ecx)
-	ret
-END(xrstor)
-
 ENTRY(fldummy)
 	ffree	%st(7)
 	fldz

Index: src/sys/arch/x86/include/cpufunc.h
diff -u src/sys/arch/x86/include/cpufunc.h:1.36 src/sys/arch/x86/include/cpufunc.h:1.37
--- src/sys/arch/x86/include/cpufunc.h:1.36	Sat Sep  7 18:33:16 2019
+++ src/sys/arch/x86/include/cpufunc.h	Wed Oct 30 17:06:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.36 2019/09/07 18:33:16 maxv Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.37 2019/10/30 17:06:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2019 The NetBSD Foundation, Inc.
@@ -358,15 +358,105 @@ wrxcr(uint32_t xcr, uint64_t val)
 	);
 }
 
-void	fnsave(union savefpu *);
-void	frstor(const union savefpu *);
+static inline void
+fnsave(void *addr)
+{
+	uint8_t *area = addr;
+
+	__asm volatile (
+		"fnsave	%[area]"
+		: [area] "=m" (*area)
+		:
+		: "memory"
+	);
+}
 
-void	fxsave(union savefpu *);
-void	fxrstor(const union savefpu *);
+static inline void
+frstor(void *addr)
+{
+	const uint8_t *area = addr;
+
+	__asm volatile (
+		"frstor	%[area]"
+		:
+		: [area] "m" (*area)
+		: "memory"
+	);
+}
 
-void	xsave(union savefpu *, uint64_t);
-void	xsaveopt(union savefpu *, uint64_t);
-void	xrstor(const union savefpu *, uint64_t);
+static inline void
+fxsave(void *addr)
+{
+	uint8_t *area = addr;
+
+	__asm volatile (
+		"fxsave	%[area]"
+		: [area] "=m" (*area)
+		:
+		: "memory"
+	);
+}
+
+static inline void
+fxrstor(void *addr)
+{
+	const uint8_t *area = addr;
+
+	__asm volatile (
+		"fxrstor %[area]"
+		:
+		: [area] "m" (*area)
+		: "memory"
+	);
+}
+
+static inline void
+xsave(void *addr, uint64_t mask)
+{
+	uint8_t *area = addr;
+	uint32_t low, high;
+
+	low = mask;
+	high = mask >> 32;
+	__asm volatile (
+		"xsave	%[area]"
+		: [area] "=m" (*area)
+		: "a" (low), "d" (high)
+		: "memory"
+	);
+}
+
+static inline void
+xsaveopt(void *addr, uint64_t mask)
+{
+	uint8_t *area = addr;
+	uint32_t low, high;
+
+	low = mask;
+	high = mask >> 32;
+	__asm volatile (
+		"xsaveopt %[area]"
+		: [area] "=m" (*area)
+		: "a" (low), "d" (high)
+		: "memory"
+	);
+}
+
+static inline void
+xrstor(void *addr, uint64_t mask)
+{
+	const uint8_t *area = addr;
+	uint32_t low, high;
+
+	low = mask;
+	high = mask >> 32;
+	__asm volatile (
+		"xrstor %[area]"
+		:
+		: [area] "m" (*area), "a" (low), "d" (high)
+		: "memory"
+	);
+}
 
 /* -------------------------------------------------------------------------- */
 

Reply via email to