mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-14 10:56:47 +07:00
c4ba1320b7
Add support for overlapping early memory reservations. In general, they still can't overlap, and will panic with "Overlapping early reservations" if they do overlap. But if a memory range is reserved with the new call: reserve_early_overlap_ok() rather than with the usual call: reserve_early() then subsequent early reservations are allowed to overlap. This new reserve_early_overlap_ok() call is only used in one place so far, which is the "BIOS reserved" reservation for the the EBDA region, which out of Paranoia reserves more than what the BIOS might have specified, and which thus might overlap with another legitimate early memory reservation (such as, perhaps, the EFI memmap.) Signed-off-by: Paul Jackson <pj@sgi.com> Cc: "Yinghai Lu" <yhlu.kernel@gmail.com> Cc: "Jack Steiner" <steiner@sgi.com> Cc: "Mike Travis" <travis@sgi.com> Cc: "Huang Cc: Ying" <ying.huang@intel.com> Cc: "Andi Kleen" <andi@firstfloor.org> Cc: "Andrew Morton" <akpm@linux-foundation.org> Cc: Paul Jackson <pj@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
74 lines
2.2 KiB
C
74 lines
2.2 KiB
C
#include <linux/kernel.h>
|
|
#include <linux/init.h>
|
|
|
|
#include <asm/setup.h>
|
|
#include <asm/bios_ebda.h>
|
|
|
|
#define BIOS_LOWMEM_KILOBYTES 0x413
|
|
|
|
/*
|
|
* The BIOS places the EBDA/XBDA at the top of conventional
|
|
* memory, and usually decreases the reported amount of
|
|
* conventional memory (int 0x12) too. This also contains a
|
|
* workaround for Dell systems that neglect to reserve EBDA.
|
|
* The same workaround also avoids a problem with the AMD768MPX
|
|
* chipset: reserve a page before VGA to prevent PCI prefetch
|
|
* into it (errata #56). Usually the page is reserved anyways,
|
|
* unless you have no PS/2 mouse plugged in.
|
|
*/
|
|
void __init reserve_ebda_region(void)
|
|
{
|
|
unsigned int lowmem, ebda_addr;
|
|
|
|
/* To determine the position of the EBDA and the */
|
|
/* end of conventional memory, we need to look at */
|
|
/* the BIOS data area. In a paravirtual environment */
|
|
/* that area is absent. We'll just have to assume */
|
|
/* that the paravirt case can handle memory setup */
|
|
/* correctly, without our help. */
|
|
if (paravirt_enabled())
|
|
return;
|
|
|
|
/* end of low (conventional) memory */
|
|
lowmem = *(unsigned short *)__va(BIOS_LOWMEM_KILOBYTES);
|
|
lowmem <<= 10;
|
|
|
|
/* start of EBDA area */
|
|
ebda_addr = get_bios_ebda();
|
|
|
|
/* Fixup: bios puts an EBDA in the top 64K segment */
|
|
/* of conventional memory, but does not adjust lowmem. */
|
|
if ((lowmem - ebda_addr) <= 0x10000)
|
|
lowmem = ebda_addr;
|
|
|
|
/* Fixup: bios does not report an EBDA at all. */
|
|
/* Some old Dells seem to need 4k anyhow (bugzilla 2990) */
|
|
if ((ebda_addr == 0) && (lowmem >= 0x9f000))
|
|
lowmem = 0x9f000;
|
|
|
|
/* Paranoia: should never happen, but... */
|
|
if ((lowmem == 0) || (lowmem >= 0x100000))
|
|
lowmem = 0x9f000;
|
|
|
|
/* reserve all memory between lowmem and the 1MB mark */
|
|
reserve_early_overlap_ok(lowmem, 0x100000, "BIOS reserved");
|
|
}
|
|
|
|
void __init reserve_setup_data(void)
|
|
{
|
|
struct setup_data *data;
|
|
u64 pa_data;
|
|
char buf[32];
|
|
|
|
if (boot_params.hdr.version < 0x0209)
|
|
return;
|
|
pa_data = boot_params.hdr.setup_data;
|
|
while (pa_data) {
|
|
data = early_ioremap(pa_data, sizeof(*data));
|
|
sprintf(buf, "setup data %x", data->type);
|
|
reserve_early(pa_data, pa_data+sizeof(*data)+data->len, buf);
|
|
pa_data = data->next;
|
|
early_iounmap(data, sizeof(*data));
|
|
}
|
|
}
|