From owner-cvs-all Fri Jun 22 22:42:48 2001 Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id A68DE37B401; Fri, 22 Jun 2001 22:42:38 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id PAA07057; Sat, 23 Jun 2001 15:42:31 +1000 Date: Sat, 23 Jun 2001 15:40:39 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Matthew Jacob Cc: John Baldwin , cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, Peter Wemm Subject: Re: D'oh! In-Reply-To: <20010622152459.X21527-100000@wonky.feral.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 22 Jun 2001, Matthew Jacob wrote: > Aghh.... internally to the kernel physmem is in units of pages for alpha or > the oldie moldy 'clicks' for i386. What *was* I thinking? It's really just > the sysctl representation, no? No. The kernel variable is in pages, but the sysctl scales it to bytes using broken scaling code: On i386's, the sshould-be-deprecated MI interface ctob() is used for scaling. ctob() is: /* clicks to bytes */ #define ctob(x) ((x)<= 2GB. When the result should be 4GB, it overflows to 0. When the result should be > 4GB, it overflows worse. Next, this int is passed to sysctl_int() which copies it out using: error = SYSCTL_IN(req, arg1, sizeof(int)); so userland sees an int. Peter's change just hides the previous overflows by making sysctl(8) print this int using the bogus format %u. On alphas, the scaling code is actually correct. ctob() is broken on alphas in the same was as on i386's, but the sysctl doesn't use it; it uses alpha_ptob(), which works up to size (2^64 - 1 page). The result of alpha_ptob() is unsigned long. Next, this unsigned long is corrupted to an int by passing it to sysctl_int(). The remaining bugs are the same as on i386's. There are many other bugs and bogons in the conversion macros in . Most seriously, dbtob() is broken on alphas. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message