Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Jun 2010 20:44:07 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r209483 - in head/sys: amd64/amd64 amd64/ia32 amd64/include i386/i386
Message-ID:  <201006232044.o5NKi70w075681@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Jun 23 20:44:07 2010
New Revision: 209483
URL: http://svn.freebsd.org/changeset/base/209483

Log:
  Clear DF bit in eflags/rflags on the kernel entry. The i386 and amd64
  ABI specifies the DF should be zero, and newer compilers do not clear
  DF before using DF-sensitive instructions.
  
  The DF clearing for signal handlers was done some time ago.
  
  MFC after:	1 week

Modified:
  head/sys/amd64/amd64/exception.S
  head/sys/amd64/ia32/ia32_exception.S
  head/sys/amd64/include/asmacros.h
  head/sys/i386/i386/apic_vector.s
  head/sys/i386/i386/atpic_vector.s
  head/sys/i386/i386/exception.s

Modified: head/sys/amd64/amd64/exception.S
==============================================================================
--- head/sys/amd64/amd64/exception.S	Wed Jun 23 19:42:01 2010	(r209482)
+++ head/sys/amd64/amd64/exception.S	Wed Jun 23 20:44:07 2010	(r209483)
@@ -191,6 +191,7 @@ alltraps_pushregs_no_rdi:
 	movq	%r14,TF_R14(%rsp)
 	movq	%r15,TF_R15(%rsp)
 	movl	$TF_HASSEGS,TF_FLAGS(%rsp)
+	cld
 	FAKE_MCOUNT(TF_RIP(%rsp))
 #ifdef KDTRACE_HOOKS
 	/*
@@ -270,6 +271,7 @@ IDTVEC(dblfault)
 	movw	%es,TF_ES(%rsp)
 	movw	%ds,TF_DS(%rsp)
 	movl	$TF_HASSEGS,TF_FLAGS(%rsp)
+	cld
 	testb	$SEL_RPL_MASK,TF_CS(%rsp) /* Did we come from kernel? */
 	jz	1f			/* already running with kernel GS.base */
 	swapgs
@@ -369,6 +371,7 @@ IDTVEC(fast_syscall)
 	movq	%r14,TF_R14(%rsp)	/* C preserved */
 	movq	%r15,TF_R15(%rsp)	/* C preserved */
 	movl	$TF_HASSEGS,TF_FLAGS(%rsp)
+	cld
 	FAKE_MCOUNT(TF_RIP(%rsp))
 	movq	%rsp,%rdi
 	call	syscall
@@ -434,6 +437,7 @@ IDTVEC(nmi)
 	movw	%es,TF_ES(%rsp)
 	movw	%ds,TF_DS(%rsp)
 	movl	$TF_HASSEGS,TF_FLAGS(%rsp)
+	cld
 	xorl	%ebx,%ebx
 	testb	$SEL_RPL_MASK,TF_CS(%rsp)
 	jnz	nmi_fromuserspace

Modified: head/sys/amd64/ia32/ia32_exception.S
==============================================================================
--- head/sys/amd64/ia32/ia32_exception.S	Wed Jun 23 19:42:01 2010	(r209482)
+++ head/sys/amd64/ia32/ia32_exception.S	Wed Jun 23 20:44:07 2010	(r209483)
@@ -67,6 +67,7 @@ IDTVEC(int0x80_syscall)
 	movq	%r14,TF_R14(%rsp)
 	movq	%r15,TF_R15(%rsp)
 	movl	$TF_HASSEGS,TF_FLAGS(%rsp)
+	cld
 	FAKE_MCOUNT(TF_RIP(%rsp))
 	movq	%rsp, %rdi
 	call	ia32_syscall

Modified: head/sys/amd64/include/asmacros.h
==============================================================================
--- head/sys/amd64/include/asmacros.h	Wed Jun 23 19:42:01 2010	(r209482)
+++ head/sys/amd64/include/asmacros.h	Wed Jun 23 20:44:07 2010	(r209483)
@@ -166,7 +166,8 @@
 	movw	%gs,TF_GS(%rsp) ;					\
 	movw	%es,TF_ES(%rsp) ;					\
 	movw	%ds,TF_DS(%rsp) ;					\
-	movl	$TF_HASSEGS,TF_FLAGS(%rsp)
+	movl	$TF_HASSEGS,TF_FLAGS(%rsp) ;				\
+	cld
 
 #define POP_FRAME							\
 	movq	TF_RDI(%rsp),%rdi ;					\

Modified: head/sys/i386/i386/apic_vector.s
==============================================================================
--- head/sys/i386/i386/apic_vector.s	Wed Jun 23 19:42:01 2010	(r209482)
+++ head/sys/i386/i386/apic_vector.s	Wed Jun 23 20:44:07 2010	(r209483)
@@ -56,6 +56,7 @@
 IDTVEC(vec_name) ;							\
 	PUSH_FRAME ;							\
 	SET_KERNEL_SREGS ;						\
+	cld ;								\
 	FAKE_MCOUNT(TF_EIP(%esp)) ;					\
 	movl	lapic, %edx ;	/* pointer to local APIC */		\
 	movl	LA_ISR + 16 * (index)(%edx), %eax ;	/* load ISR */	\
@@ -103,6 +104,7 @@ IDTVEC(spuriousint)
 IDTVEC(timerint)
 	PUSH_FRAME
 	SET_KERNEL_SREGS
+	cld
 	FAKE_MCOUNT(TF_EIP(%esp))
 	pushl	%esp
 	call	lapic_handle_timer
@@ -118,6 +120,7 @@ IDTVEC(timerint)
 IDTVEC(cmcint)
 	PUSH_FRAME
 	SET_KERNEL_SREGS
+	cld
 	FAKE_MCOUNT(TF_EIP(%esp))
 	call	lapic_handle_cmc
 	MEXITCOUNT
@@ -131,6 +134,7 @@ IDTVEC(cmcint)
 IDTVEC(errorint)
 	PUSH_FRAME
 	SET_KERNEL_SREGS
+	cld
 	FAKE_MCOUNT(TF_EIP(%esp))
 	call	lapic_handle_error
 	MEXITCOUNT
@@ -302,6 +306,7 @@ IDTVEC(invlcache)
 IDTVEC(ipi_intr_bitmap_handler)	
 	PUSH_FRAME
 	SET_KERNEL_SREGS
+	cld
 
 	movl	lapic, %edx
 	movl	$0, LA_EOI(%edx)	/* End Of Interrupt to APIC */
@@ -320,6 +325,7 @@ IDTVEC(ipi_intr_bitmap_handler)	
 IDTVEC(cpustop)
 	PUSH_FRAME
 	SET_KERNEL_SREGS
+	cld
 
 	movl	lapic, %eax
 	movl	$0, LA_EOI(%eax)	/* End Of Interrupt to APIC */
@@ -339,6 +345,7 @@ IDTVEC(cpustop)
 IDTVEC(rendezvous)
 	PUSH_FRAME
 	SET_KERNEL_SREGS
+	cld
 
 #ifdef COUNT_IPIS
 	movl	PCPU(CPUID), %eax
@@ -360,6 +367,7 @@ IDTVEC(rendezvous)
 IDTVEC(lazypmap)
 	PUSH_FRAME
 	SET_KERNEL_SREGS
+	cld
 
 	call	pmap_lazyfix_action
 

Modified: head/sys/i386/i386/atpic_vector.s
==============================================================================
--- head/sys/i386/i386/atpic_vector.s	Wed Jun 23 19:42:01 2010	(r209482)
+++ head/sys/i386/i386/atpic_vector.s	Wed Jun 23 20:44:07 2010	(r209483)
@@ -49,6 +49,7 @@
 IDTVEC(vec_name) ;							\
 	PUSH_FRAME ;							\
 	SET_KERNEL_SREGS ;						\
+	cld ;								\
 ;									\
 	FAKE_MCOUNT(TF_EIP(%esp)) ;					\
 	pushl	%esp		;                                       \

Modified: head/sys/i386/i386/exception.s
==============================================================================
--- head/sys/i386/i386/exception.s	Wed Jun 23 19:42:01 2010	(r209482)
+++ head/sys/i386/i386/exception.s	Wed Jun 23 20:44:07 2010	(r209483)
@@ -159,6 +159,7 @@ alltraps:
 	pushl	%fs
 alltraps_with_regs_pushed:
 	SET_KERNEL_SREGS
+	cld
 	FAKE_MCOUNT(TF_EIP(%esp))
 calltrap:
 	pushl	%esp
@@ -233,6 +234,7 @@ IDTVEC(lcall_syscall)
 	pushl	%es
 	pushl	%fs
 	SET_KERNEL_SREGS
+	cld
 	FAKE_MCOUNT(TF_EIP(%esp))
 	pushl	%esp
 	call	syscall
@@ -256,6 +258,7 @@ IDTVEC(int0x80_syscall)
 	pushl	%es
 	pushl	%fs
 	SET_KERNEL_SREGS
+	cld
 	FAKE_MCOUNT(TF_EIP(%esp))
 	pushl	%esp
 	call	syscall



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006232044.o5NKi70w075681>