From owner-freebsd-hackers@FreeBSD.ORG Mon Jun 13 12:11:48 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E33CA16A41C for ; Mon, 13 Jun 2005 12:11:48 +0000 (GMT) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe05.swip.net [212.247.154.129]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7296343D1D for ; Mon, 13 Jun 2005 12:11:47 +0000 (GMT) (envelope-from hselasky@c2i.net) X-T2-Posting-ID: Y1QAsIk9O44SO+J/q9KNyQ== Received: from mp-217-230-219.daxnet.no ([193.217.230.219] verified) by mailfe05.swip.net (CommuniGate Pro SMTP 4.3.2) with ESMTP id 197082139 for freebsd-hackers@freebsd.org; Mon, 13 Jun 2005 14:11:46 +0200 From: Hans Petter Selasky To: freebsd-hackers@freebsd.org Date: Mon, 13 Jun 2005 14:12:38 +0200 User-Agent: KMail/1.7 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200506131412.38967.hselasky@c2i.net> Subject: Obvious bug in /sys/i386/include/bus.h (was: bus_at386.h) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: hselasky@c2i.net List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2005 12:11:49 -0000 Hi, I stumbled across this bug a year ago, but still none has managed to fix it. Instead the PR got lost and I am now posting it a second time: http://www.freebsd.org/cgi/query-pr.cgi?pr=80980 In FreeBSD 6-current the code for "bus_space_write_multi_1()" says: __asm __volatile(" \n\ cld \n\ 1: lodsb \n\ movb %%al,(%2) \n\ loop 1b" : "=S" (addr), "=c" (count) : "r" (bsh + offset), "0" (addr), "1" (count) : "%eax", "memory", "cc"); This is equivalent to: while(--count) { /* I/O */ } which is obviously wrong, because it doesn't check for count equal to zero. So how can I fix this in assembly. I am not an expert with inlined assembly, so maybe someone can correct me if I am wrong, but something like this needs to be added: or %ecx, %ecx jz 2 2: Another solution would be to wrap the inlined assembly into if(count) { ... } So can someone have this fixed, or is there a reason not to fix it. The one who wrote the code has done the same mistake with every one of the bus_space_XXXX that does memory mapped I/O. It currently breaks my drivers. --HPS