Don't allow MAXMEM or hw.physmem to extend the top of memory if our memory
map was obtained from the SMAP. SMAP is trustworthy, and the memory extending feature is a band-aid for older systems where FreeBSD's methods of detecting memory were not always trustworthy. This fixes the issue where using hw.physmem could result in the ACPI tables getting trashed breaking ACPI. MFC after: 3 days Tested on: i386
This commit is contained in:
parent
38fbd89386
commit
c95747d9a1
@ -947,17 +947,17 @@ getmemsize(caddr_t kmdp, u_int64_t first)
|
||||
if (TUNABLE_ULONG_FETCH("hw.physmem", &physmem_tunable))
|
||||
Maxmem = atop(physmem_tunable);
|
||||
|
||||
/*
|
||||
* Don't allow MAXMEM or hw.physmem to extend the amount of memory
|
||||
* in the system.
|
||||
*/
|
||||
if (Maxmem > atop(physmap[physmap_idx + 1]))
|
||||
Maxmem = atop(physmap[physmap_idx + 1]);
|
||||
|
||||
if (atop(physmap[physmap_idx + 1]) != Maxmem &&
|
||||
(boothowto & RB_VERBOSE))
|
||||
printf("Physical memory use set to %ldK\n", Maxmem * 4);
|
||||
|
||||
/*
|
||||
* If Maxmem has been increased beyond what the system has detected,
|
||||
* extend the last memory segment to the new limit.
|
||||
*/
|
||||
if (atop(physmap[physmap_idx + 1]) < Maxmem)
|
||||
physmap[physmap_idx + 1] = ptoa((vm_paddr_t)Maxmem);
|
||||
|
||||
/* call pmap initialization to make new kernel address space */
|
||||
pmap_bootstrap(&first);
|
||||
|
||||
|
@ -1633,7 +1633,7 @@ static void
|
||||
getmemsize(int first)
|
||||
{
|
||||
int i, physmap_idx, pa_indx, da_indx;
|
||||
int hasbrokenint12;
|
||||
int hasbrokenint12, has_smap;
|
||||
u_long physmem_tunable;
|
||||
u_int extmem;
|
||||
struct vm86frame vmf;
|
||||
@ -1661,6 +1661,7 @@ getmemsize(int first)
|
||||
bzero(&vmf, sizeof(vmf));
|
||||
bzero(physmap, sizeof(physmap));
|
||||
basemem = 0;
|
||||
has_smap = 0;
|
||||
|
||||
/*
|
||||
* Some newer BIOSes has broken INT 12H implementation which cause
|
||||
@ -1742,6 +1743,7 @@ getmemsize(int first)
|
||||
if (boothowto & RB_VERBOSE)
|
||||
printf("SMAP type=%02x base=%016llx len=%016llx\n",
|
||||
smap->type, smap->base, smap->length);
|
||||
has_smap = 1;
|
||||
|
||||
if (smap->type != 0x01)
|
||||
continue;
|
||||
@ -1883,6 +1885,13 @@ getmemsize(int first)
|
||||
if (TUNABLE_ULONG_FETCH("hw.physmem", &physmem_tunable))
|
||||
Maxmem = atop(physmem_tunable);
|
||||
|
||||
/*
|
||||
* If we have an SMAP, don't allow MAXMEM or hw.physmem to extend
|
||||
* the amount of memory in the system.
|
||||
*/
|
||||
if (has_smap && Maxmem > atop(physmap[physmap_idx + 1]))
|
||||
Maxmem = atop(physmap[physmap_idx + 1]);
|
||||
|
||||
if (atop(physmap[physmap_idx + 1]) != Maxmem &&
|
||||
(boothowto & RB_VERBOSE))
|
||||
printf("Physical memory use set to %ldK\n", Maxmem * 4);
|
||||
|
Loading…
Reference in New Issue
Block a user