From simon@comsys.ntu-kpi.kiev.ua  Mon Mar 21 15:34:51 2005
Return-Path: <simon@comsys.ntu-kpi.kiev.ua>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E819616A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 21 Mar 2005 15:34:51 +0000 (GMT)
Received: from comsys.ntu-kpi.kiev.ua (comsys.ntu-kpi.kiev.ua [195.245.194.142])
	by mx1.FreeBSD.org (Postfix) with ESMTP id AA55343D41
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 21 Mar 2005 15:34:37 +0000 (GMT)
	(envelope-from simon@comsys.ntu-kpi.kiev.ua)
Received: from pm514-9.comsys.ntu-kpi.kiev.ua (pm514-9.comsys.ntu-kpi.kiev.ua [10.18.54.109])
	(authenticated bits=0)
	by comsys.ntu-kpi.kiev.ua (8.12.10/8.12.10) with ESMTP id j2LFc6Bf033462
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 21 Mar 2005 17:38:07 +0200 (EET)
Received: by pm514-9.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1000)
	id 1AF2AB4; Mon, 21 Mar 2005 17:34:19 +0200 (EET)
Message-Id: <20050321153418.GA461@pm514-9.comsys.ntu-kpi.kiev.ua>
Date: Mon, 21 Mar 2005 17:34:18 +0200
From: Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
To: FreeBSD-gnats-submit@freebsd.org
Subject: Small optimization for i386/support.s

>Number:         79091
>Category:       i386
>Synopsis:       [i386] [patch] Small optimization for i386/support.s
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-i386
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 21 15:40:02 GMT 2005
>Closed-Date:    
>Last-Modified:  Wed Jun 22 14:00:30 UTC 2011
>Originator:     Andrey Simonenko
>Release:        FreeBSD 5.3-RELEASE-p5 i386
>Organization:
>Environment:

>Description:

suword(), suword16(), subyte() and copyinstr() from i386/support.s
restore "trashed" register %ecx, but this register is not really
trashed in case of non I386_CPU in su*() functions and in copyinstr().

The same situation with the same functions in amd64/support.S.

And the same situation with 4.x, 5.x and HEAD.

>How-To-Repeat:

>Fix:

--- support.s.orig	Sat Nov 13 11:29:48 2004
+++ support.s	Fri Mar 18 14:00:56 2005
@@ -1327,7 +1327,9 @@
 	movl	8(%esp),%eax
 	movl	%eax,(%edx)
 	xorl	%eax,%eax
-	movl	PCPU(CURPCB),%ecx
+#ifdef I386_CPU
+	movl	PCPU(CURPCB),%ecx		/* restore trashed register */
+#endif
 	movl	%eax,PCB_ONFAULT(%ecx)
 	ret
 
@@ -1370,7 +1372,9 @@
 	movw	8(%esp),%ax
 	movw	%ax,(%edx)
 	xorl	%eax,%eax
+#ifdef I386_CPU
 	movl	PCPU(CURPCB),%ecx		/* restore trashed register */
+#endif
 	movl	%eax,PCB_ONFAULT(%ecx)
 	ret
 
@@ -1412,7 +1416,9 @@
 	movb	8(%esp),%al
 	movb	%al,(%edx)
 	xorl	%eax,%eax
+#ifdef I386_CPU
 	movl	PCPU(CURPCB),%ecx		/* restore trashed register */
+#endif
 	movl	%eax,PCB_ONFAULT(%ecx)
 	ret
 
@@ -1475,7 +1481,6 @@
 
 cpystrflt_x:
 	/* set *lencopied and return %eax */
-	movl	PCPU(CURPCB),%ecx
 	movl	$0,PCB_ONFAULT(%ecx)
 	movl	20(%esp),%ecx
 	subl	%edx,%ecx
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: remko 
State-Changed-When: Wed Jul 14 07:06:16 UTC 2010 
State-Changed-Why:  
Hello, the code in question is using 'rcx' now instead of 'ecx'to restore 
the registers. That might have solved your problem can you please have a look at that please and confirm whether it's still relevant? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=79091 

From: "b. f." <bf1783@googlemail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: i386/79091: [i386] [patch] Small optimization for i386/support.s
Date: Tue, 31 May 2011 14:44:42 -0400

 Feedback for this PR was received on the freebsd-i386 mailing list,
 but was not recorded here:
 
 http://lists.freebsd.org/pipermail/freebsd-i386/2010-July/008712.html
 
 b.
State-Changed-From-To: feedback->open 
State-Changed-By: bf 
State-Changed-When: Wed Jun 22 13:59:43 UTC 2011 
State-Changed-Why:  
Feedback has been received 

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