Subject: port-i386/14435: i386 machdep.c patch
To: None <>
From: None <>
List: netbsd-bugs
Date: 11/02/2001 14:11:11
>Number:         14435
>Category:       port-i386
>Synopsis:       assymetry between old and new bootcode in i386/machdep.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-i386-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 02 05:17:00 PST 2001
>Originator:     Feico Dillema
>Release:        NetBSD 1.5Y
University of Tromsų
System: NetBSD 1.5Y NetBSD 1.5Y (DRIFTER) #6: Thu Nov 1 17:29:22 CET 2001 i386
Architecture: i386
Machine: i386
i386/machdep.c has two different code paths for registring the physical memory
in a machine at boottime. The first use add_mem_cluster() and the second is the
`old style' code that is used when add_mem_cluster() fails for some reason or
when kernel options REALBASEMEM and REALEXTMEM are set.

While debugging my problem with booting a Compaq Proliant Server I stumbled
across some descrepancy between the two code paths. I believed fixing that
would solve my problem with the Compaq. It didn't, as I found out my problem
was caused by the bootloader I was using (Grub).

Even though it did not solve my problem, I still think my patch is relevant.
How relevant, is up to somebody who is more knowledgeable on these things
than me to decide.

NA. Only report a fix, not a problem it actually fixes...

Here's the patch against for sys/arch/i386/i386:

/*      $NetBSD: machdep.c,v 1.457 2001/09/19 01:26:19 thorpej Exp $    */

--- machdep.c.orig	Fri Nov  2 13:56:26 2001
+++ machdep.c	Fri Nov  2 13:57:03 2001
@@ -2546,11 +2546,14 @@
 		mem_clusters[1].start = IOM_END;
 		mem_clusters[1].size = trunc_page(KBTOB(biosextmem));
+		if ((mem_clusters[1].start + mem_clusters[1].size) == 0x100000000ULL)
+			mem_clusters[1].size -= PAGE_SIZE;
 		physmem += atop(mem_clusters[1].size);
 		mem_cluster_cnt = 2;
-		avail_end = IOM_END + trunc_page(KBTOB(biosextmem));
+		avail_end = mem_clusters[1].start + mem_clusters[1].size;