Changeset View
Standalone View
sys/amd64/amd64/machdep.c
Show First 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | |||||
struct mtx icu_lock; | struct mtx icu_lock; | ||||
struct mem_range_softc mem_range_softc; | struct mem_range_softc mem_range_softc; | ||||
struct mtx dt_lock; /* lock for GDT and LDT */ | struct mtx dt_lock; /* lock for GDT and LDT */ | ||||
void (*vmm_resume_p)(void); | void (*vmm_resume_p)(void); | ||||
bool efi_boot; | |||||
static void | static void | ||||
cpu_startup(dummy) | cpu_startup(dummy) | ||||
void *dummy; | void *dummy; | ||||
{ | { | ||||
uintmax_t memsize; | uintmax_t memsize; | ||||
char *sysenv; | char *sysenv; | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 601 Lines • ▼ Show 20 Lines | native_parse_memmap(caddr_t kmdp, vm_paddr_t *physmap, int *physmap_idx) | ||||
/* | /* | ||||
* Memory map from INT 15:E820. | * Memory map from INT 15:E820. | ||||
* | * | ||||
* subr_module.c says: | * subr_module.c says: | ||||
* "Consumer may safely assume that size value precedes data." | * "Consumer may safely assume that size value precedes data." | ||||
* ie: an int32_t immediately precedes smap. | * ie: an int32_t immediately precedes smap. | ||||
*/ | */ | ||||
if (firmware_type == FW_UEFI) { | |||||
efihdr = (struct efi_map_header *)preload_search_info(kmdp, | efihdr = (struct efi_map_header *)preload_search_info(kmdp, | ||||
MODINFO_METADATA | MODINFOMD_EFI_MAP); | MODINFO_METADATA | MODINFOMD_EFI_MAP); | ||||
add_efi_map_entries(efihdr, physmap, physmap_idx); | |||||
return; | |||||
} | |||||
smap = (struct bios_smap *)preload_search_info(kmdp, | smap = (struct bios_smap *)preload_search_info(kmdp, | ||||
MODINFO_METADATA | MODINFOMD_SMAP); | MODINFO_METADATA | MODINFOMD_SMAP); | ||||
if (efihdr == NULL && smap == NULL) | if (smap == NULL) | ||||
panic("No BIOS smap or EFI map info from loader!"); | panic("No BIOS smap or EFI map info from loader!"); | ||||
if (efihdr != NULL) { | |||||
add_efi_map_entries(efihdr, physmap, physmap_idx); | |||||
strlcpy(bootmethod, "UEFI", sizeof(bootmethod)); | |||||
} else { | |||||
size = *((u_int32_t *)smap - 1); | size = *((u_int32_t *)smap - 1); | ||||
bios_add_smap_entries(smap, size, physmap, physmap_idx); | bios_add_smap_entries(smap, size, physmap, physmap_idx); | ||||
strlcpy(bootmethod, "BIOS", sizeof(bootmethod)); | |||||
} | } | ||||
} | |||||
#define PAGES_PER_GB (1024 * 1024 * 1024 / PAGE_SIZE) | #define PAGES_PER_GB (1024 * 1024 * 1024 / PAGE_SIZE) | ||||
/* | /* | ||||
* Populate the (physmap) array with base/bound pairs describing the | * Populate the (physmap) array with base/bound pairs describing the | ||||
* available physical memory in the system, then test this memory and | * available physical memory in the system, then test this memory and | ||||
* build the phys_avail array describing the actually-available memory. | * build the phys_avail array describing the actually-available memory. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 291 Lines • ▼ Show 20 Lines | #endif | ||||
init_static_kenv(envp, 0); | init_static_kenv(envp, 0); | ||||
#ifdef DDB | #ifdef DDB | ||||
ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); | ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); | ||||
ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); | ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); | ||||
db_fetch_ksymtab(ksym_start, ksym_end, 0); | db_fetch_ksymtab(ksym_start, ksym_end, 0); | ||||
#endif | #endif | ||||
efi_systbl_phys = MD_FETCH(kmdp, MODINFOMD_FW_HANDLE, vm_paddr_t); | efi_systbl_phys = MD_FETCH(kmdp, MODINFOMD_FW_HANDLE, vm_paddr_t); | ||||
firmware_type = MD_FETCH(kmdp, MODINFOMD_EFI_MAP, void *) != NULL ? | |||||
FW_UEFI : FW_BIOS; | |||||
return (kmdp); | return (kmdp); | ||||
} | } | ||||
static void | static void | ||||
amd64_kdb_init(void) | amd64_kdb_init(void) | ||||
{ | { | ||||
kdb_init(); | kdb_init(); | ||||
#ifdef KDB | #ifdef KDB | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | hammer_time(u_int64_t modulep, u_int64_t physfree) | ||||
kernphys = (vm_paddr_t)(*pde & ~PDRMASK) - | kernphys = (vm_paddr_t)(*pde & ~PDRMASK) - | ||||
(vm_paddr_t)(((vm_offset_t)hammer_time - KERNBASE) & ~PDRMASK); | (vm_paddr_t)(((vm_offset_t)hammer_time - KERNBASE) & ~PDRMASK); | ||||
/* Fix-up for 2M hole */ | /* Fix-up for 2M hole */ | ||||
physfree += kernphys; | physfree += kernphys; | ||||
kernphys += NBPDR; | kernphys += NBPDR; | ||||
kmdp = init_ops.parse_preload_data(modulep); | kmdp = init_ops.parse_preload_data(modulep); | ||||
efi_boot = preload_search_info(kmdp, MODINFO_METADATA | | if (firmware_type != FW_UEFI) { | ||||
kib: If doing this way, the condition should be `firmware_type == FW_BIOS` | |||||
Done Inline ActionsThat changes the logic if firmware_type == FW_HYPER (of course that change could be correct). ehem_freebsd_m5p.com: That changes the logic if `firmware_type == FW_HYPER` (of course that change //could// be… | |||||
Done Inline ActionsHow could firmware_type not be FW_NONE there? kib: How could firmware_type not be FW_NONE there? | |||||
Done Inline ActionsIf xen_pvh_parse_reload_data() (as init_ops.parse_preload_data()) sets firmware_type = FW_HYPER;. Your asking this seems to suggest you think init_ops.parse_preload_data() should always set firmware_type even though that results in a bit of code duplication (both native_parse_preload_data() and xen_pvh_parse_reload_data() end up with this conditional). I had been wondering whether to do that instead. ehem_freebsd_m5p.com: If `xen_pvh_parse_reload_data()` (as `init_ops.parse_preload_data()`) sets `firmware_type =… | |||||
Not Done Inline ActionsSo does xen pv emulate low bios data? I highly doubt it, but I cannot deny it. I do believe that the answer is no, and think that all existing uses of if (!efi_boot) should be translated into if (firmware_type == FW_BIOS). That said, why do you need FW_HYPER? Also why not FW_XEN? kib: So does xen pv emulate low bios data? I highly doubt it, but I cannot deny it.
I do believe… | |||||
Done Inline ActionsOriginally I was thinking set firmare_type = FW_HYPER; vm_guest = VM_GUEST_XEN; would be the way to handle this. The response would be Xen is the only one which features direct kernel loading. Other hypervisors load an emulated BIOS or UEFI environment, and use that to load FreeBSD or other OS. In this case Xen really is a genuinely distinct firmware_type/bootmethod and deserves a distinct value. So, having thought about it, the current version has FW_XEN, rather than FW_HYPER. ehem_freebsd_m5p.com: Originally I was thinking set `firmare_type = FW_HYPER; vm_guest = VM_GUEST_XEN;` would be the… | |||||
MODINFOMD_EFI_MAP) != NULL; | |||||
if (!efi_boot) { | |||||
/* Tell the bios to warmboot next time */ | /* Tell the bios to warmboot next time */ | ||||
atomic_store_short((u_short *)0x472, 0x1234); | atomic_store_short((u_short *)0x472, 0x1234); | ||||
} | } | ||||
physfree += ucode_load_bsp(physfree - kernphys + KERNSTART); | physfree += ucode_load_bsp(physfree - kernphys + KERNSTART); | ||||
Not Done Inline Actionsfirmware_type = preload_search_info(kmdp, MODINFO_METADATA | MODINFOMD_EFI_MAP) != NULL ? FW_UEFI : FW_BIOS; kib: `firmware_type = preload_search_info(kmdp, MODINFO_METADATA | MODINFOMD_EFI_MAP) != NULL ? | |||||
Done Inline ActionsWhat you typed works if inside the outer if. firmware_type = preload_search_info(kmdp, MODINFO_METADATA | MODINFOMD_EFI_MAP) != NULL ? FW_UEFI : firmware_type == FW_NONE ? FW_BIOS : FW_TYPE; if you want to capture everything. I was emulating existing style and shying away from the conditional operator. ehem_freebsd_m5p.com: What you typed works if inside the outer `if`. `firmware_type = preload_search_info(kmdp… | |||||
Done Inline ActionsAlways spot the typo afterwards. s/FW_TYPE/firmware_type/ ehem_freebsd_m5p.com: Always spot the typo afterwards. s/FW_TYPE/firmware_type/ | |||||
physfree = roundup2(physfree, PAGE_SIZE); | physfree = roundup2(physfree, PAGE_SIZE); | ||||
identify_cpu1(); | identify_cpu1(); | ||||
identify_hypervisor(); | identify_hypervisor(); | ||||
identify_cpu_fixup_bsp(); | identify_cpu_fixup_bsp(); | ||||
identify_cpu2(); | identify_cpu2(); | ||||
initializecpucache(); | initializecpucache(); | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | #endif | ||||
clock_init(); | clock_init(); | ||||
/* | /* | ||||
* Use vt(4) by default for UEFI boot (during the sc(4)/vt(4) | * Use vt(4) by default for UEFI boot (during the sc(4)/vt(4) | ||||
* transition). | * transition). | ||||
* Once bootblocks have updated, we can test directly for | * Once bootblocks have updated, we can test directly for | ||||
* efi_systbl != NULL here... | * efi_systbl != NULL here... | ||||
*/ | */ | ||||
if (efi_boot) | if (firmware_type == FW_UEFI) | ||||
vty_set_preferred(VTY_VT); | vty_set_preferred(VTY_VT); | ||||
TUNABLE_INT_FETCH("hw.ibrs_disable", &hw_ibrs_disable); | TUNABLE_INT_FETCH("hw.ibrs_disable", &hw_ibrs_disable); | ||||
TUNABLE_INT_FETCH("machdep.mitigations.ibrs.disable", &hw_ibrs_disable); | TUNABLE_INT_FETCH("machdep.mitigations.ibrs.disable", &hw_ibrs_disable); | ||||
TUNABLE_INT_FETCH("hw.spec_store_bypass_disable", &hw_ssb_disable); | TUNABLE_INT_FETCH("hw.spec_store_bypass_disable", &hw_ssb_disable); | ||||
TUNABLE_INT_FETCH("machdep.mitigations.ssb.disable", &hw_ssb_disable); | TUNABLE_INT_FETCH("machdep.mitigations.ssb.disable", &hw_ssb_disable); | ||||
▲ Show 20 Lines • Show All 422 Lines • Show Last 20 Lines |
If doing this way, the condition should be firmware_type == FW_BIOS