From hselasky@c2i.net  Sun Dec  8 23:12:55 2002
Return-Path: <hselasky@c2i.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CA8B137B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  8 Dec 2002 23:12:55 -0800 (PST)
Received: from fep03-svc.swip.net (fep03.swip.net [130.244.199.131])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7E9AD43E4A
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  8 Dec 2002 23:12:54 -0800 (PST)
	(envelope-from hselasky@c2i.net)
Received: from mta-int.swip.net ([192.168.145.27]) by fep03-svc.swip.net
          with SMTP
          id <20021209071253.NGNL5799.fep03-svc.swip.net@mta-int.swip.net>
          for <FreeBSD-gnats-submit@freebsd.org>;
          Mon, 9 Dec 2002 08:12:53 +0100
Message-Id: <20021209071253.NGNL5799.fep03-svc.swip.net@mta-int.swip.net>
Date: Mon, 9 Dec 2002 8:12:53 +0100
From: <hselasky@c2i.net>
To: FreeBSD-gnats-submit@freebsd.org
Subject: busspace bug

>Number:         46113
>Category:       i386
>Synopsis:       [bus] [patch] busspace bugs in parameter checking
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    remko
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 08 23:20:01 PST 2002
>Closed-Date:    Sun Nov 11 11:22:42 UTC 2007
>Last-Modified:  Sun Nov 11 11:30:02 UTC 2007
>Originator:     -
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD curly.tele2.no 5.0-CURRENT FreeBSD 5.0-CURRENT #458: Sat Dec 7 18:40:33 CET 2002 root@curly.tele2.no:/usr/obj/usr/src/sys/custom i386


	
>Description:
	Some busspace functions lack check for (count == 0). Some busspace functions interpret (count == 0) as (unsigned)(-1) + 1. 
>How-To-Repeat:
	
>Fix:

	

--- bus_at386.h.diff begins here ---
*** /mnt3/src/sys/i386/include/bus_at386.h	Mon Jul 29 12:21:22 2002
--- bus_at386.h	Mon Nov 18 17:42:32 2002
***************
*** 277,282 ****
--- 277,284 ----
  #endif
  	{
  #ifdef __GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	movb (%2),%%al				\n\
***************
*** 285,290 ****
--- 287,293 ----
  		    "=D" (addr), "=c" (count)			:
  		    "r" (bsh + offset), "0" (addr), "1" (count)	:
  		    "%eax", "memory");
+ 		}
  #endif
  	}
  #endif
***************
*** 306,311 ****
--- 309,316 ----
  #endif
  	{
  #ifdef __GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	movw (%2),%%ax				\n\
***************
*** 314,319 ****
--- 319,325 ----
  		    "=D" (addr), "=c" (count)			:
  		    "r" (bsh + offset), "0" (addr), "1" (count)	:
  		    "%eax", "memory");
+ 		}
  #endif
  	}
  #endif
***************
*** 335,340 ****
--- 341,348 ----
  #endif
  	{
  #ifdef __GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	movl (%2),%%eax				\n\
***************
*** 343,348 ****
--- 351,357 ----
  		    "=D" (addr), "=c" (count)			:
  		    "r" (bsh + offset), "0" (addr), "1" (count)	:
  		    "%eax", "memory");
+ 		}
  #endif
  	}
  #endif
***************
*** 384,389 ****
--- 393,400 ----
  	{
  		int _port_ = bsh + offset;
  #ifdef __GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	inb %w2,%%al				\n\
***************
*** 393,398 ****
--- 404,410 ----
  		    "=D" (addr), "=c" (count), "=d" (_port_)	:
  		    "0" (addr), "1" (count), "2" (_port_)	:
  		    "%eax", "memory", "cc");
+ 		}
  #endif
  	}
  #endif
***************
*** 426,431 ****
--- 438,445 ----
  	{
  		int _port_ = bsh + offset;
  #ifdef	__GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	inw %w2,%%ax				\n\
***************
*** 435,440 ****
--- 449,455 ----
  		    "=D" (addr), "=c" (count), "=d" (_port_)	:
  		    "0" (addr), "1" (count), "2" (_port_)	:
  		    "%eax", "memory", "cc");
+ 		}
  #endif
  	}
  #endif
***************
*** 468,473 ****
--- 483,490 ----
  	{
  		int _port_ = bsh + offset;
  #ifdef	__GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	inl %w2,%%eax				\n\
***************
*** 477,482 ****
--- 494,500 ----
  		    "=D" (addr), "=c" (count), "=d" (_port_)	:
  		    "0" (addr), "1" (count), "2" (_port_)	:
  		    "%eax", "memory", "cc");
+ 		}
  #endif
  	}
  #endif
***************
*** 616,621 ****
--- 634,641 ----
  #endif
  	{
  #ifdef	__GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	lodsb					\n\
***************
*** 624,629 ****
--- 644,650 ----
  		    "=S" (addr), "=c" (count)			:
  		    "r" (bsh + offset), "0" (addr), "1" (count)	:
  		    "%eax", "memory", "cc");
+ 		}
  #endif
  	}
  #endif
***************
*** 645,650 ****
--- 666,673 ----
  #endif
  	{
  #ifdef	__GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	lodsw					\n\
***************
*** 653,658 ****
--- 676,682 ----
  		    "=S" (addr), "=c" (count)			:
  		    "r" (bsh + offset), "0" (addr), "1" (count)	:
  		    "%eax", "memory", "cc");
+ 		}
  #endif
  	}
  #endif
***************
*** 674,679 ****
--- 698,705 ----
  #endif
  	{
  #ifdef	__GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	lodsl					\n\
***************
*** 682,687 ****
--- 708,714 ----
  		    "=S" (addr), "=c" (count)			:
  		    "r" (bsh + offset), "0" (addr), "1" (count)	:
  		    "%eax", "memory", "cc");
+ 		}
  #endif
  	}
  #endif
***************
*** 724,729 ****
--- 751,758 ----
  	{
  		int _port_ = bsh + offset;
  #ifdef	__GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	lodsb					\n\
***************
*** 733,738 ****
--- 762,768 ----
  		    "=d" (_port_), "=S" (addr), "=c" (count)	:
  		    "0" (_port_), "1" (addr), "2" (count)	:
  		    "%eax", "memory", "cc");
+ 		}
  #endif
  	}
  #endif
***************
*** 766,771 ****
--- 796,803 ----
  	{
  		int _port_ = bsh + offset;
  #ifdef	__GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	lodsw					\n\
***************
*** 775,780 ****
--- 807,813 ----
  		    "=d" (_port_), "=S" (addr), "=c" (count)	:
  		    "0" (_port_), "1" (addr), "2" (count)	:
  		    "%eax", "memory", "cc");
+ 		}
  #endif
  	}
  #endif
***************
*** 808,813 ****
--- 841,848 ----
  	{
  		int _port_ = bsh + offset;
  #ifdef	__GNUC__
+ 		if(count != 0)
+ 		{
  		__asm __volatile("				\n\
  			cld					\n\
  		1:	lodsl					\n\
***************
*** 817,822 ****
--- 852,858 ----
  		    "=d" (_port_), "=S" (addr), "=c" (count)	:
  		    "0" (_port_), "1" (addr), "2" (count)	:
  		    "%eax", "memory", "cc");
+ 		}
  #endif
  	}
  #endif
--- bus_at386.h.diff ends here ---





-------------------------------------------------
WebMail fra Tele2 http://www.tele2.no
-------------------------------------------------

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: remko 
State-Changed-When: Mon Sep 11 12:16:49 UTC 2006 
State-Changed-Why:  
Hello, 

can you tell me whether this had been resolved or not 
already? Thanks! 


Responsible-Changed-From-To: freebsd-i386->remko 
Responsible-Changed-By: remko 
Responsible-Changed-When: Mon Sep 11 12:16:49 UTC 2006 
Responsible-Changed-Why:  
grab the pr 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46113 
State-Changed-From-To: feedback->closed 
State-Changed-By: remko 
State-Changed-When: Sun Nov 11 11:22:40 UTC 2007 
State-Changed-Why:  
This had been discussed before and a different approach had been 
implemented, therefor I see this as resolved. 

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

From: Remko Lodder <remko@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: i386/46113: [bus] [patch] busspace bugs in parameter checking
Date: Sun, 11 Nov 2007 12:22:20 +0100

 Hans Petter Selasky wrote:
 > 
 > Last time this was discussed, it ended something like this:
 > 
 > If the code currently never calls these functions with "count == 0", 
 > then assume it is an optimization to not check for "count == 0".
 > 
 > The isssue has not been resolved, rather worked around, by having:
 > 
 > if (count != 0) {
 >   bus_space_xxxx(....);
 > }
 > 
 > in the drivers in question.
 > 
 > --HPS
 
 Update with the last available information (already from way
 back). I see that it also had been discussed already and that
 a different approach had been taken into account.
 
 I will remark this PR as resolved in that case.
 
 -- 
 Kind regards,
 
      Remko Lodder               ** remko@elvandar.org
      FreeBSD                    ** remko@FreeBSD.org
 
      /* Quis custodiet ipsos custodes */
>Unformatted:
