Execute smp_init() before keyboard_init() in case ACPI tables are overwritten.

When USB keyboard detection is enabled, physical memory pages are reserved
for use by the USB drivers. The physical memory map exposed by pmem.h does
not indicate where the ACPI tables reside, so we may end up using pages
that contain ACPI tables (or for that matter, the boot parameters and boot
command line). So rather than introduce a more complicated memory allocation
scheme, make sure we have finished with all the data passed to us by the
BIOS and/or boot loader before we start probing for USB devices.

The only downside to this is that it is no longer possible to interactively
disable parsing of the ACPI tables - that can now only be done by using the
"nosmp" boot option.
This commit is contained in:
Martin Whitaker 2022-05-04 22:42:31 +01:00
parent 7b41830c40
commit af54067228
3 changed files with 15 additions and 10 deletions

View File

@ -170,7 +170,7 @@ At startup, and when running tests, Memtest86+ responds to the following keys:
* F1 * F1
* enters the configuration menu * enters the configuration menu
* F2 * F2
* toggles detection and use of multiple CPU cores (SMP) * toggles use of multiple CPU cores (SMP)
* Space * Space
* toggles scroll lock (stops/starts error message scrolling) * toggles scroll lock (stops/starts error message scrolling)
* Enter * Enter

View File

@ -795,9 +795,9 @@ void config_menu(bool initial)
prints(POP_R+5, POP_LI, "<F3> CPU sequencing mode"); prints(POP_R+5, POP_LI, "<F3> CPU sequencing mode");
prints(POP_R+6, POP_LI, "<F4> Error reporting mode"); prints(POP_R+6, POP_LI, "<F4> Error reporting mode");
if (initial) { if (initial) {
if (num_available_cpus < 2) set_foreground_colour(BOLD+BLACK); if (!smp_enabled) set_foreground_colour(BOLD+BLACK);
prints(POP_R+7, POP_LI, "<F5> CPU selection"); prints(POP_R+7, POP_LI, "<F5> CPU selection");
if (num_available_cpus < 2) set_foreground_colour(WHITE); if (!smp_enabled) set_foreground_colour(WHITE);
if (no_temperature) set_foreground_colour(BOLD+BLACK); if (no_temperature) set_foreground_colour(BOLD+BLACK);
printf(POP_R+8, POP_LI, "<F6> Temperature %s", enable_temperature ? "disable" : "enable "); printf(POP_R+8, POP_LI, "<F6> Temperature %s", enable_temperature ? "disable" : "enable ");
if (no_temperature) set_foreground_colour(WHITE); if (no_temperature) set_foreground_colour(WHITE);
@ -829,7 +829,7 @@ void config_menu(bool initial)
break; break;
case '5': case '5':
if (initial) { if (initial) {
if (num_available_cpus > 1) { if (smp_enabled) {
cpu_selection_menu(); cpu_selection_menu();
} }
} else { } else {
@ -880,7 +880,9 @@ void initial_config(void)
{ {
display_initial_notice(); display_initial_notice();
bool smp_init_done = false; if (num_available_cpus < 2) {
smp_enabled = false;
}
if (pause_at_start) { if (pause_at_start) {
bool got_key = false; bool got_key = false;
for (int i = 0; i < 3000 && !got_key; i++) { for (int i = 0; i < 3000 && !got_key; i++) {
@ -892,8 +894,6 @@ void initial_config(void)
reboot(); reboot();
break; break;
case '1': case '1':
smp_init(smp_enabled);
smp_init_done = true;
config_menu(true); config_menu(true);
got_key = true; got_key = true;
break; break;
@ -913,7 +913,4 @@ void initial_config(void)
} }
} }
} }
if (!smp_init_done) {
smp_init(smp_enabled);
}
} }

View File

@ -224,6 +224,14 @@ static void global_init(void)
config_init(); config_init();
smp_init(smp_enabled);
// At this point we have started reserving physical pages in the memory
// map for data structures that need to be permanently pinned in place.
// This may overwrite any data structures passed to us by the BIOS and/or
// boot loader, e.g. the boot parameters, boot command line, and ACPI
// tables. So do not access those data structures after this point.
keyboard_init(); keyboard_init();
display_init(); display_init();