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
This commit is contained in:
John Baldwin 2018-08-19 17:36:50 +00:00
parent 4de0d16b8c
commit 38a13e9002
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=338058

View File

@ -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 @@ mptable_probe(void)
__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",