Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 09 Nov 2002 04:18:02 +0900 (JST)
From:      Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
To:        arg-bsd@arg1.demon.co.uk
Cc:        stable@FreeBSD.org
Subject:   Re: machdep.c problem
Message-ID:  <20021109.041802.45867347.iwasaki@jp.FreeBSD.org>
In-Reply-To: <20021108180141.B21142-100000@server.arg.sj.co.uk>
References:  <20021109.013230.98854530.iwasaki@jp.FreeBSD.org> <20021108180141.B21142-100000@server.arg.sj.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

> The patch does not work for me (Intel SCB2 motherboard, SMP, 2xP3Xeon).

Thanks for reporting.

> It stops in much the same place as before, but apparently gives
> "Privileged instruction fault" this time (I do not have console access to
> this machine, so I have to ask someone to look at the screen when it fails
> to boot).

OK, revised patches (w/ debug printing) attached.
Could you let me know what was the last message one of these?
 1. getmemsize: mapping BIOS work pages
 2. getmemsize: calling INT 15:E820
 3. getmemsize: unmapping BIOS work pages

Also previous patches might give too many pages to BIOS.
Can you adjust this value and try again increasing up to 159?
#define BIOSWORKSTARTPAGE	152

> Perhaps you should back out the 1.135.2.26 commit to -stable until the
> problem is fixed.

Newer BIOS have another problem before 1.135.2.26 as you know.
Modern OSes (such as MS WindowsXX and Linux) never use INT 12H to
determine base memory size.
If somebody can fix both problems, I would glad to commit the patches :-)

Thanks

Index: machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/machdep.c,v
retrieving revision 1.385.2.26
diff -u -r1.385.2.26 machdep.c
--- machdep.c	2 Nov 2002 05:07:18 -0000	1.385.2.26
+++ machdep.c	8 Nov 2002 18:39:19 -0000
@@ -1456,6 +1456,7 @@
 	struct vm86context vmc;
 	vm_offset_t pa, physmap[PHYSMAP_SIZE];
 	pt_entry_t pte;
+	unsigned int saved_pte[160];
 	const char *cp;
 	struct {
 		u_int64_t base;
@@ -1468,6 +1469,27 @@
 	basemem = 0;
 
 	/*
+	 * Older BIOSes might intend to write to memory below 640kb.
+	 * It is very small region actually, but we cannot determine
+	 * the accurate base memory size here.
+	 * Give enough pages to BIOS temporary during calling
+	 * INT 15:E820 so that BIOS can access them.
+	 */
+#define BIOSWORKSTARTPAGE	152
+printf("%s: mapping BIOS work pages\n", __func__);
+	for (pa = (BIOSWORKSTARTPAGE << PAGE_SHIFT);
+	     pa < ISA_HOLE_START; pa += PAGE_SIZE) {
+		pte = (pt_entry_t)vtopte(pa + KERNBASE);
+		*pte = pa | PG_RW | PG_V;
+	}
+
+	pte = (pt_entry_t)vm86paddr;
+	for (i = BIOSWORKSTARTPAGE; i < 160; i++) {
+		saved_pte[i] = pte[i];
+		pte[i] |= PG_V | PG_RW | PG_U;
+	}
+
+	/*
 	 * map page 1 R/W into the kernel page table so we can use it
 	 * as a buffer.  The kernel will unmap this page later.
 	 */
@@ -1479,6 +1501,7 @@
 	 */
 #define SMAPSIZ 	sizeof(*smap)
 #define SMAP_SIG	0x534D4150			/* 'SMAP' */
+printf("%s: calling INT 15:E820\n", __func__);
 
 	vmc.npages = 0;
 	smap = (void *)vm86_addpage(&vmc, 1, KERNBASE + (1 << PAGE_SHIFT));
@@ -1537,6 +1560,22 @@
 		physmap[physmap_idx + 1] = smap->base + smap->length;
 next_run:
 	} while (vmf.vmf_ebx != 0);
+
+	/*
+	 * Unmap the pages which were given for BIOS.
+	 * Some pages below 640kb will be mapped again if necessary
+	 * after base memory size is determined.
+	 */
+printf("%s: unmapping BIOS work pages\n", __func__);
+	pte = (pt_entry_t)vm86paddr;
+	for (i = BIOSWORKSTARTPAGE; i < 160; i++)
+		pte[i] = saved_pte[i];
+	for (pa = (BIOSWORKSTARTPAGE << PAGE_SHIFT);
+	     pa < ISA_HOLE_START; pa += PAGE_SIZE) {
+		pte = (pt_entry_t)vtopte(pa + KERNBASE);
+		*pte = 0;
+	}
+#undef BIOSWORKSTARTPAGE
 
 	/*
 	 * Perform "base memory" related probes & setup

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021109.041802.45867347.iwasaki>