From rmh@io.debian.net  Tue Feb 14 12:33:10 2006
Return-Path: <rmh@io.debian.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5968516A420
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 14 Feb 2006 12:33:10 +0000 (GMT)
	(envelope-from rmh@io.debian.net)
Received: from io.debian.net (io.ethz.ch [129.132.80.17])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 061DD43D53
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 14 Feb 2006 12:33:09 +0000 (GMT)
	(envelope-from rmh@io.debian.net)
Received: from rmh by io.debian.net with local (Exim 4.60)
	(envelope-from <rmh@io.debian.net>)
	id 1F8zMi-000GyN-05
	for FreeBSD-gnats-submit@freebsd.org; Tue, 14 Feb 2006 13:33:08 +0100
Message-Id: <E1F8zMi-000GyN-05@io.debian.net>
Date: Tue, 14 Feb 2006 13:33:08 +0100
From: Robert Millan <rmh@aybabtu.com>
Reply-To: Robert Millan <rmh@aybabtu.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] broken asm in kernel
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         93331
>Category:       kern
>Synopsis:       [kernel] [patch] broken asm in kernel
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 14 12:40:05 GMT 2006
>Closed-Date:    Fri Nov 02 22:13:57 UTC 2012
>Last-Modified:  Fri Nov 02 22:13:57 UTC 2012
>Originator:     Robert Millan
>Release:        
>Organization:
>Environment:
System: GNU/kFreeBSD io.debian.net 5.4-1-586 #0 Mon Dec 5 19:45:10 CET 2005 i586 i386 AMD-K6(tm) 3D processor GNU/kFreeBSD
Architecture: i586

	
>Description:
A few places in the kernel (see patch followup) are using the movl instruction
to copy data from/onto a 16-bit register.  While this is accepted by current
binutils, newer releases will barf on it.

>How-To-Repeat:
	
>Fix:

	


>Release-Note:
>Audit-Trail:

From: Robert Millan <rmh@aybabtu.com>
To: bug-followup@FreeBSD.org
Cc: aurel32@debian.org
Subject: Re: kern/93331: [patch] broken asm in kernel
Date: Tue, 14 Feb 2006 14:03:54 +0100

 --T4sUOijqQbZv57TR
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 
 Here's a patch for kern/93331, made by Aurelien Jarno.
 
 (I verified it applies cleanly in HEAD)
 
 -- 
 Robert Millan
 
 --T4sUOijqQbZv57TR
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="binutils_movl.diff"
 
 --- sys.old/i386/i386/locore.s.orig	2005-09-05 22:35:16.000000000 +0200
 +++ sys/i386/i386/locore.s	2005-09-05 22:35:58.000000000 +0200
 @@ -358,7 +358,7 @@
  	pushl	%eax
  	testl	$PSL_VM,UC_EFLAGS(%eax)
  	jne	1f
 -	movl	UC_GS(%eax),%gs		/* restore %gs */
 +	movw	UC_GS(%eax),%gs		/* restore %gs */
  1:
  	movl	$SYS_sigreturn,%eax
  	pushl	%eax			/* junk to fake return addr. */
 @@ -375,7 +375,7 @@
  	pushl	%eax
  	testl	$PSL_VM,UC4_EFLAGS(%eax)
  	jne	1f
 -	movl	UC4_GS(%eax),%gs	/* restore %gs */
 +	movw	UC4_GS(%eax),%gs	/* restore %gs */
  1:
  	movl	$344,%eax		/* 4.x SYS_sigreturn */
  	pushl	%eax			/* junk to fake return addr. */
 @@ -393,7 +393,7 @@
  	pushl	%eax
  	testl	$PSL_VM,SC_PS(%eax)
  	jne	9f
 -	movl	SC_GS(%eax),%gs		/* restore %gs */
 +	movw	SC_GS(%eax),%gs		/* restore %gs */
  9:
  	movl	$103,%eax		/* 3.x SYS_sigreturn */
  	pushl	%eax			/* junk to fake return addr. */
 --- sys.old/i386/i386/swtch.s	2005-09-06 14:47:02.000000000 +0200
 +++ sys/i386/i386/swtch.s	2005-09-06 14:47:33.000000000 +0200
 @@ -111,7 +111,7 @@
  	movl	%ebp,PCB_EBP(%edx)
  	movl	%esi,PCB_ESI(%edx)
  	movl	%edi,PCB_EDI(%edx)
 -	movl	%gs,PCB_GS(%edx)
 +	movw	%gs,PCB_GS(%edx)
  	pushfl					/* PSL */
  	popl	PCB_PSL(%edx)
  	/* Check to see if we need to call a switchout function. */
 @@ -279,7 +279,7 @@
  	/* This must be done after loading the user LDT. */
  	.globl	cpu_switch_load_gs
  cpu_switch_load_gs:
 -	movl	PCB_GS(%edx),%gs
 +	movw	PCB_GS(%edx),%gs
  
  	/* Test if debug registers should be restored. */
  	testl	$PCB_DBREGS,PCB_FLAGS(%edx)
 @@ -348,7 +348,7 @@
  	movl	%ebp,PCB_EBP(%ecx)
  	movl	%esi,PCB_ESI(%ecx)
  	movl	%edi,PCB_EDI(%ecx)
 -	movl	%gs,PCB_GS(%ecx)
 +	movw	%gs,PCB_GS(%ecx)
  	pushfl
  	popl	PCB_PSL(%ecx)
 
 --- sys.old/i386/include/cpufunc.h	2005-09-06 17:32:18.000000000 +0200
 +++ sys/i386/include/cpufunc.h	2005-09-06 17:32:42.000000000 +0200
 @@ -456,7 +456,7 @@
  rgs(void)
  {
  	u_int sel;
 -	__asm __volatile("movl %%gs,%0" : "=rm" (sel));
 +	__asm __volatile("mov %%gs,%0" : "=rm" (sel));
  	return (sel);
  }
  
 @@ -477,7 +477,7 @@
  static __inline void
  load_gs(u_int sel)
  {
 -	__asm __volatile("movl %0,%%gs" : : "rm" (sel));
 +	__asm __volatile("mov %0,%%gs" : : "rm" (sel));
  }
  
  static __inline void
 --- sys.old/i386/linux/linux_locore.s	2005-09-06 20:28:47.000000000 +0200
 +++ sys/i386/linux/linux_locore.s	2005-09-06 20:29:05.000000000 +0200
 @@ -8,7 +8,7 @@
  NON_GPROF_ENTRY(linux_sigcode)
  	call	*LINUX_SIGF_HANDLER(%esp)
  	leal	LINUX_SIGF_SC(%esp),%ebx	/* linux scp */
 -	movl	LINUX_SC_GS(%ebx),%gs
 +	movw	LINUX_SC_GS(%ebx),%gs
  	movl	%esp, %ebx			/* pass sigframe */
  	push	%eax				/* fake ret addr */
  	movl	$LINUX_SYS_linux_sigreturn,%eax	/* linux_sigreturn() */
 @@ -19,7 +19,7 @@
  linux_rt_sigcode:
  	call	*LINUX_RT_SIGF_HANDLER(%esp)
  	leal	LINUX_RT_SIGF_UC(%esp),%ebx	/* linux ucp */
 -	movl	LINUX_SC_GS(%ebx),%gs
 +	movw	LINUX_SC_GS(%ebx),%gs
  	push	%eax				/* fake ret addr */
  	movl	$LINUX_SYS_linux_rt_sigreturn,%eax   /* linux_rt_sigreturn() */
  	int	$0x80				/* enter kernel with args */
 --- sys.old/compat/ndis/winx32_wrap.S	2005-09-06 21:47:21.000000000 +0200
 +++ sys/compat/ndis/winx32_wrap.S	2005-09-06 21:47:48.000000000 +0200
 @@ -348,7 +348,7 @@
  	ret
  
  ENTRY(x86_setfs)
 -	movl	4(%esp),%fs
 +	movw	4(%esp),%fs
  	ret
  
  ENTRY(x86_gettid)
 
 --T4sUOijqQbZv57TR--
State-Changed-From-To: open->closed 
State-Changed-By: gavin 
State-Changed-When: Sun Feb 21 22:47:58 UTC 2010 
State-Changed-Why:  
This was committed in SVN r187948.  Thanks for your submission! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=93331 
State-Changed-From-To: closed->patched 
State-Changed-By: gavin 
State-Changed-When: Sun Feb 21 22:53:22 UTC 2010 
State-Changed-Why:  
On second thoughts, mark this as patched - it's in head and RELENG_8, but 
looks like a good candidate to merge back to 7. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=93331 
State-Changed-From-To: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Fri Nov 2 22:13:56 UTC 2012 
State-Changed-Why:  
if its in 8 its fixed by now 

http://www.freebsd.org/cgi/query-pr.cgi?pr=93331 
>Unformatted:
