Skip to content

Commit d0cd742

Browse files
author
H. Peter Anvin
committed
x86, bios: By default, reserve the low 64K for all BIOSes
The laundry list of BIOSes that need the low 64K reserved is getting very long, so make it the default across all BIOSes. This also allows the code to be simplified and unified with the reservation code for the first 4K. This resolves kernel bugzilla 16661 and who knows what else... Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> LKML-Reference: <tip-*@git.kernel.org>
1 parent 76be97c commit d0cd742

File tree

2 files changed

+35
-96
lines changed

2 files changed

+35
-96
lines changed

arch/x86/Kconfig

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,25 +1326,34 @@ config X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK
13261326
Set whether the default state of memory_corruption_check is
13271327
on or off.
13281328

1329-
config X86_RESERVE_LOW_64K
1330-
bool "Reserve low 64K of RAM on AMI/Phoenix BIOSen"
1331-
default y
1332-
---help---
1333-
Reserve the first 64K of physical RAM on BIOSes that are known
1334-
to potentially corrupt that memory range. A numbers of BIOSes are
1335-
known to utilize this area during suspend/resume, so it must not
1336-
be used by the kernel.
1337-
1338-
Set this to N if you are absolutely sure that you trust the BIOS
1339-
to get all its memory reservations and usages right.
1340-
1341-
If you have doubts about the BIOS (e.g. suspend/resume does not
1342-
work or there's kernel crashes after certain hardware hotplug
1343-
events) and it's not AMI or Phoenix, then you might want to enable
1344-
X86_CHECK_BIOS_CORRUPTION=y to allow the kernel to check typical
1345-
corruption patterns.
1346-
1347-
Say Y if unsure.
1329+
config X86_LOW_RESERVE
1330+
int "Amount of low memory, in kilobytes, to reserve for the BIOS"
1331+
default 64
1332+
range 4 640
1333+
---help---
1334+
Specify the amount of low memory to reserve for the BIOS.
1335+
1336+
The first page contains BIOS data structures that the kernel
1337+
must not use, so that page must always be reserved.
1338+
1339+
By default we reserve the first 64K of physical RAM, as a
1340+
number of BIOSes are known to corrupt that memory range
1341+
during events such as suspend/resume or monitor cable
1342+
insertion, so it must not be used by the kernel.
1343+
1344+
You can set this to 4 if you are absolutely sure that you
1345+
trust the BIOS to get all its memory reservations and usages
1346+
right. If you know your BIOS have problems beyond the
1347+
default 64K area, you can set this to 640 to avoid using the
1348+
entire low memory range.
1349+
1350+
If you have doubts about the BIOS (e.g. suspend/resume does
1351+
not work or there's kernel crashes after certain hardware
1352+
hotplug events) then you might want to enable
1353+
X86_CHECK_BIOS_CORRUPTION=y to allow the kernel to check
1354+
typical corruption patterns.
1355+
1356+
Leave this to the default value of 64 if you are unsure.
13481357

13491358
config MATH_EMULATION
13501359
bool

arch/x86/kernel/setup.c

Lines changed: 7 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -618,88 +618,20 @@ static __init void reserve_ibft_region(void)
618618
reserve_early_overlap_ok(addr, addr + size, "ibft");
619619
}
620620

621-
#ifdef CONFIG_X86_RESERVE_LOW_64K
622-
static int __init dmi_low_memory_corruption(const struct dmi_system_id *d)
623-
{
624-
printk(KERN_NOTICE
625-
"%s detected: BIOS may corrupt low RAM, working around it.\n",
626-
d->ident);
627-
628-
e820_update_range(0, 0x10000, E820_RAM, E820_RESERVED);
629-
sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
630-
631-
return 0;
632-
}
633-
#endif
634-
635-
/* List of systems that have known low memory corruption BIOS problems */
636-
static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
637-
#ifdef CONFIG_X86_RESERVE_LOW_64K
638-
{
639-
.callback = dmi_low_memory_corruption,
640-
.ident = "AMI BIOS",
641-
.matches = {
642-
DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
643-
},
644-
},
645-
{
646-
.callback = dmi_low_memory_corruption,
647-
.ident = "Phoenix BIOS",
648-
.matches = {
649-
DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies"),
650-
},
651-
},
652-
{
653-
.callback = dmi_low_memory_corruption,
654-
.ident = "Phoenix/MSC BIOS",
655-
.matches = {
656-
DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix/MSC"),
657-
},
658-
},
659-
/*
660-
* AMI BIOS with low memory corruption was found on Intel DG45ID and
661-
* DG45FC boards.
662-
* It has a different DMI_BIOS_VENDOR = "Intel Corp.", for now we will
663-
* match only DMI_BOARD_NAME and see if there is more bad products
664-
* with this vendor.
665-
*/
666-
{
667-
.callback = dmi_low_memory_corruption,
668-
.ident = "AMI BIOS",
669-
.matches = {
670-
DMI_MATCH(DMI_BOARD_NAME, "DG45ID"),
671-
},
672-
},
673-
{
674-
.callback = dmi_low_memory_corruption,
675-
.ident = "AMI BIOS",
676-
.matches = {
677-
DMI_MATCH(DMI_BOARD_NAME, "DG45FC"),
678-
},
679-
},
680-
/*
681-
* The Dell Inspiron Mini 1012 has DMI_BIOS_VENDOR = "Dell Inc.", so
682-
* match on the product name.
683-
*/
684-
{
685-
.callback = dmi_low_memory_corruption,
686-
.ident = "Phoenix BIOS",
687-
.matches = {
688-
DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1012"),
689-
},
690-
},
691-
#endif
692-
{}
693-
};
694-
695621
static void __init trim_bios_range(void)
696622
{
697623
/*
698624
* A special case is the first 4Kb of memory;
699625
* This is a BIOS owned area, not kernel ram, but generally
700626
* not listed as such in the E820 table.
627+
*
628+
* This typically reserves additional memory (64KiB by default)
629+
* since some BIOSes are known to corrupt low memory. See the
630+
* Kconfig help text for X86_LOW_RESERVE.
701631
*/
702-
e820_update_range(0, PAGE_SIZE, E820_RAM, E820_RESERVED);
632+
e820_update_range(0, ALIGN(CONFIG_X86_LOW_RESERVE << 10, PAGE_SIZE),
633+
E820_RAM, E820_RESERVED);
634+
703635
/*
704636
* special case: Some BIOSen report the PC BIOS
705637
* area (640->1Mb) as ram even though it is not.
@@ -863,8 +795,6 @@ void __init setup_arch(char **cmdline_p)
863795

864796
dmi_scan_machine();
865797

866-
dmi_check_system(bad_bios_dmi_table);
867-
868798
/*
869799
* VMware detection requires dmi to be available, so this
870800
* needs to be done after dmi_scan_machine, for the BP.

0 commit comments

Comments
 (0)