Account for dmap limit when selecting the pages for the bootstrap
pagetables. physmap[] can be inconsistent with the physical memory limit due to buggy bios, or to the hw.physmem tunable. Since bootstrap pagetables are initialized by accesses through the DMAP, we must ensure that DMAP really cover the selected pages. This is only relevant when machine has less than 4G RAM and buggy BIOS, which is the combination on Acer Chromebook 720. The call to mp_bootaddress() is moved later to have Maxmem initialized. An alternative could be to always cover 4G for DMAP, but this change seems to be simpler. Reported and tested by: grembo Reviewed by: royger Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D15675
This commit is contained in:
parent
1930b98d49
commit
943defc3a0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334799
@ -1247,15 +1247,6 @@ getmemsize(caddr_t kmdp, u_int64_t first)
|
||||
basemem = 640;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make hole for "AP -> long mode" bootstrap code. The
|
||||
* mp_bootaddress vector is only available when the kernel
|
||||
* is configured to support APs and APs for the system start
|
||||
* in real mode mode (e.g. SMP bare metal).
|
||||
*/
|
||||
if (init_ops.mp_bootaddress)
|
||||
init_ops.mp_bootaddress(physmap, &physmap_idx);
|
||||
|
||||
/*
|
||||
* Maxmem isn't the "maximum memory", it's one larger than the
|
||||
* highest page of the physical address space. It should be
|
||||
@ -1294,6 +1285,15 @@ getmemsize(caddr_t kmdp, u_int64_t first)
|
||||
(boothowto & RB_VERBOSE))
|
||||
printf("Physical memory use set to %ldK\n", Maxmem * 4);
|
||||
|
||||
/*
|
||||
* Make hole for "AP -> long mode" bootstrap code. The
|
||||
* mp_bootaddress vector is only available when the kernel
|
||||
* is configured to support APs and APs for the system start
|
||||
* in real mode mode (e.g. SMP bare metal).
|
||||
*/
|
||||
if (init_ops.mp_bootaddress)
|
||||
init_ops.mp_bootaddress(physmap, &physmap_idx);
|
||||
|
||||
/* call pmap initialization to make new kernel address space */
|
||||
pmap_bootstrap(&first);
|
||||
|
||||
|
@ -113,12 +113,16 @@ mp_bootaddress(vm_paddr_t *physmap, unsigned int *physmap_idx)
|
||||
allocated = false;
|
||||
for (i = *physmap_idx; i <= *physmap_idx; i -= 2) {
|
||||
/*
|
||||
* Find a memory region big enough below the 4GB boundary to
|
||||
* store the initial page tables. Note that it needs to be
|
||||
* aligned to a page boundary.
|
||||
* Find a memory region big enough below the 4GB
|
||||
* boundary to store the initial page tables. Region
|
||||
* must be mapped by the direct map.
|
||||
*
|
||||
* Note that it needs to be aligned to a page
|
||||
* boundary.
|
||||
*/
|
||||
if (physmap[i] >= GiB(4) ||
|
||||
(physmap[i + 1] - round_page(physmap[i])) < (PAGE_SIZE * 3))
|
||||
if (physmap[i] >= GiB(4) || physmap[i + 1] -
|
||||
round_page(physmap[i]) < PAGE_SIZE * 3 ||
|
||||
physmap[i + 1] > Maxmem)
|
||||
continue;
|
||||
|
||||
allocated = true;
|
||||
|
Loading…
Reference in New Issue
Block a user