From 99c12760d07df9dba7bc69f1ae0d915badc7ee17 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sun, 20 Jun 2021 17:58:11 +0300 Subject: [PATCH] amd64: do not touch BIOS reset flag halfword, unless we boot through BIOS (cherry picked from commit 33e1287b6a54672860d6646111ef0e544a00c569) --- sys/amd64/amd64/locore.S | 3 --- sys/amd64/amd64/machdep.c | 12 ++++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S index 3addc3fb10c..ce37288f440 100644 --- a/sys/amd64/amd64/locore.S +++ b/sys/amd64/amd64/locore.S @@ -56,9 +56,6 @@ */ NON_GPROF_ENTRY(btext) - /* Tell the bios to warmboot next time */ - movw $0x1234,0x472 - /* Don't trust what the loader gives for rflags. */ pushq $PSL_KERNEL popfq diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 2901ef15e69..0098e926d0f 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1613,11 +1613,20 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) struct region_descriptor r_gdt; size_t kstack0_sz; int late_console; + bool efi_boot; TSRAW(&thread0, TS_ENTER, __func__, NULL); kmdp = init_ops.parse_preload_data(modulep); + efi_boot = preload_search_info(kmdp, MODINFO_METADATA | + MODINFOMD_EFI_MAP) != NULL; + + if (!efi_boot) { + /* Tell the bios to warmboot next time */ + atomic_store_short((u_short *)0x472, 0x1234); + } + physfree += ucode_load_bsp(physfree + KERNBASE); physfree = roundup2(physfree, PAGE_SIZE); @@ -1769,8 +1778,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) * Once bootblocks have updated, we can test directly for * efi_systbl != NULL here... */ - if (preload_search_info(kmdp, MODINFO_METADATA | MODINFOMD_EFI_MAP) - != NULL) + if (efi_boot) vty_set_preferred(VTY_VT); TUNABLE_INT_FETCH("hw.ibrs_disable", &hw_ibrs_disable); -- 2.45.0