Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Aug 2018 17:36:50 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r338058 - head/sys/x86/x86
Message-ID:  <201808191736.w7JHaoKf052022@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Sun Aug 19 17:36:50 2018
New Revision: 338058
URL: https://svnweb.freebsd.org/changeset/base/338058

Log:
  Fix the MPTable probe code after the 4:4 changes on i386.
  
  The MPTable probe code was using PMAP_MAP_LOW as the PA -> VA offset
  when searching for the table signature but still using KERNBASE once
  it had found the table.  As a result, the mpfps table pointed into a
  random part of the kernel text instead of the actual MP Table.
  
  Rather than adding more #ifdef's, use BIOS_PADDRTOVADDR from
  <machine/pc/bios.h> which already uses PMAP_MAP_LOW on i386 and KERNBASE
  on amd64.
  
  Reviewed by:	kib
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D16802

Modified:
  head/sys/x86/x86/mptable.c

Modified: head/sys/x86/x86/mptable.c
==============================================================================
--- head/sys/x86/x86/mptable.c	Sun Aug 19 17:19:20 2018	(r338057)
+++ head/sys/x86/x86/mptable.c	Sun Aug 19 17:36:50 2018	(r338058)
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr_machdep.h>
 #include <x86/apicvar.h>
 #include <machine/md_var.h>
+#include <machine/pc/bios.h>
 #ifdef NEW_PCIB
 #include <machine/resource.h>
 #endif
@@ -223,11 +224,7 @@ search_for_sig(u_int32_t target, int count)
 	int     x;
 	u_int32_t *addr;
 
-#ifdef __amd64__
-	addr = (u_int32_t *) (KERNBASE + target);
-#else /* __i386__ */
-	addr = (u_int32_t *) (PMAP_MAP_LOW + target);
-#endif
+	addr = (u_int32_t *)BIOS_PADDRTOVADDR(target);
 	for (x = 0; x < count; x += 4)
 		if (addr[x] == MP_SIG)
 			/* make array index a byte index */
@@ -258,13 +255,7 @@ mptable_probe(void)
 	u_int32_t target;
 
 	/* see if EBDA exists */
-	if ((segment = (u_long) * (u_short *) (
-#ifdef __amd64__
-	    KERNBASE
-#else /* __i386__ */
-	    PMAP_MAP_LOW
-#endif
-	    + 0x40e)) != 0) {
+	if ((segment = *(u_short *)BIOS_PADDRTOVADDR(0x40e)) != 0) {
 		/* search first 1K of EBDA */
 		target = (u_int32_t) (segment << 4);
 		if ((x = search_for_sig(target, 1024 / 4)) >= 0)
@@ -285,7 +276,7 @@ mptable_probe(void)
 	return (ENXIO);
 
 found:
-	mpfps = (mpfps_t)(KERNBASE + x);
+	mpfps = (mpfps_t)BIOS_PADDRTOVADDR(x);
 
 	/* Map in the configuration table if it exists. */
 	if (mpfps->config_type != 0) {
@@ -306,7 +297,7 @@ found:
 			    __func__);
 			return (ENXIO);
 		}
-		mpct = (mpcth_t)(KERNBASE + (uintptr_t)mpfps->pap);
+		mpct = (mpcth_t)BIOS_PADDRTOVADDR((uintptr_t)mpfps->pap);
 		if (mpct->base_table_length + (uintptr_t)mpfps->pap >=
 		    1024 * 1024) {
 			printf("%s: Unable to map end of MP Config Table\n",



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