Module Name:    src
Committed By:   dsl
Date:           Thu Feb 13 19:37:08 UTC 2014

Modified Files:
        src/sys/arch/x86/include: cpu_extended_state.h cpufunc.h
        src/sys/arch/x86/x86: fpu.c

Log Message:
Check the argument types for the fpu asm functions.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/include/cpu_extended_state.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/include/cpufunc.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/x86/fpu.c

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/x86/include/cpu_extended_state.h
diff -u src/sys/arch/x86/include/cpu_extended_state.h:1.5 src/sys/arch/x86/include/cpu_extended_state.h:1.6
--- src/sys/arch/x86/include/cpu_extended_state.h:1.5	Wed Feb 12 23:24:09 2014
+++ src/sys/arch/x86/include/cpu_extended_state.h	Thu Feb 13 19:37:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_extended_state.h,v 1.5 2014/02/12 23:24:09 dsl Exp $	*/
+/*	$NetBSD: cpu_extended_state.h,v 1.6 2014/02/13 19:37:08 dsl Exp $	*/
 
 #ifndef _X86_CPU_EXTENDED_STATE_H_
 #define _X86_CPU_EXTENDED_STATE_H_
@@ -55,13 +55,13 @@ union fp_addr {
 		uint16_t fa_seg;	/* code/data (etc) segment */
 		uint16_t fa_opcode;	/* last opcode (sometimes) */
 	} fa_32;
-} __packed;
+} __packed __aligned(4);
 
 /* The x87 registers are 80 bits */
 struct fpacc87 {
 	uint64_t	f87_mantissa;	/* mantissa */
 	uint16_t	f87_exp_sign;	/* exponent and sign */
-} __packed;
+} __packed __aligned(2);
 
 /* The x87 registers padded out to 16 bytes for fxsave */
 struct fpaccfx {
@@ -88,9 +88,9 @@ struct ymmreg {
  * The fxsave 'Abridged tag word' in inverted.
  */
 struct save87 {
-	uint32_t	s87_cw;		/* control word (16bits) */
-	uint32_t	s87_sw;		/* status word (16bits) */
-	uint32_t	s87_tw;		/* tag word (16bits) */
+	uint16_t	s87_cw __aligned(4);	/* control word (16bits) */
+	uint16_t	s87_sw __aligned(4);	/* status word (16bits) */
+	uint16_t	s87_tw __aligned(4);	/* tag word (16bits) */
 	union fp_addr	s87_ip;		/* floating point instruction pointer */
 #define s87_opcode s87_ip.fa_32.fa_opcode	/* opcode last executed (11bits) */
 	union fp_addr	s87_dp;		/* floating operand offset */
@@ -103,7 +103,6 @@ struct fxsave {
 /*0*/	uint16_t	fx_cw;		/* FPU Control Word */
 	uint16_t	fx_sw;		/* FPU Status Word */
 	uint8_t		fx_tw;		/* FPU Tag Word (abridged) */
-	uint8_t		fx_reserved1;
 	uint16_t	fx_opcode;	/* FPU Opcode */
 	union fp_addr	fx_ip;		/* FPU Instruction Pointer */
 /*16*/	union fp_addr	fx_dp;		/* FPU Data pointer */

Index: src/sys/arch/x86/include/cpufunc.h
diff -u src/sys/arch/x86/include/cpufunc.h:1.16 src/sys/arch/x86/include/cpufunc.h:1.17
--- src/sys/arch/x86/include/cpufunc.h:1.16	Wed Feb 12 23:24:09 2014
+++ src/sys/arch/x86/include/cpufunc.h	Thu Feb 13 19:37:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.16 2014/02/12 23:24:09 dsl Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.17 2014/02/13 19:37:08 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -76,25 +76,30 @@ void	breakpoint(void);
 void	x86_hlt(void);
 void	x86_stihlt(void);
 u_int	x86_getss(void);
-void	fldcw(void *);
+
+struct save87;
+struct fxsave;
+void	fldcw(const uint16_t *);
 void	fnclex(void);
 void	fninit(void);
-void	fnsave(void *);
+void	fnsave(struct save87 *);
 void	fnstcw(uint16_t *);
 uint16_t fngetsw(void);
 void	fnstsw(uint16_t *);
-void	fp_divide_by_0(void);
-void	frstor(void *);
+void	frstor(const struct save87 *);
 void	fwait(void);
 void	clts(void);
 void	stts(void);
+void	fxsave(struct fxsave *);
+void	fxrstor(const struct fxsave *);
+void	x86_ldmxcsr(const uint32_t *);
+void	x86_stmxcsr(uint32_t *);
+
 void	fldummy(void);
-void	fxsave(void *);
-void	fxrstor(void *);
+void	fp_divide_by_0(void);
+
 void	x86_monitor(const void *, uint32_t, uint32_t);
 void	x86_mwait(uint32_t, uint32_t);
-void	x86_ldmxcsr(const uint32_t *);
-void	x86_stmxcsr(uint32_t *);
 /* x86_cpuid2() writes four 32bit values, %eax, %ebx, %ecx and %edx */
 #define	x86_cpuid(a,b)	x86_cpuid2((a),0,(b))
 void	x86_cpuid2(uint32_t, uint32_t, uint32_t *);

Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.3 src/sys/arch/x86/x86/fpu.c:1.4
--- src/sys/arch/x86/x86/fpu.c:1.3	Wed Feb 12 23:24:09 2014
+++ src/sys/arch/x86/x86/fpu.c	Thu Feb 13 19:37:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.3 2014/02/12 23:24:09 dsl Exp $	*/
+/*	$NetBSD: fpu.c,v 1.4 2014/02/13 19:37:08 dsl Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.  All
@@ -100,7 +100,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.3 2014/02/12 23:24:09 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.4 2014/02/13 19:37:08 dsl Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -458,7 +458,7 @@ fpudna(struct trapframe *frame)
 		 * but we don't care since we're about to call fxrstor() anyway.
 		 */
 		fldummy();
-		fxrstor(&pcb->pcb_savefpu);
+		fxrstor(&pcb->pcb_savefpu.sv_xmm);
 	} else {
 		frstor(&pcb->pcb_savefpu.sv_87);
 	}
@@ -489,7 +489,7 @@ fpusave_cpu(bool save)
 	if (save) {
 		clts();
 		if (i386_use_fxsave) {
-			fxsave(&pcb->pcb_savefpu);
+			fxsave(&pcb->pcb_savefpu.sv_xmm);
 		} else {
 			fnsave(&pcb->pcb_savefpu.sv_87);
 		}

Reply via email to