Re-work efidev ordering to fix efirt preloaded by loader on amd64

On amd64, efi_enter calls fpu_kern_enter(). This may not be called until
fpuinitstate has been invoked, resulting in a kernel panic with
efirt_load="YES" in loader.conf(5).

Move fpuinitstate a little earlier in SI_SUB_DRIVERS so that we can squeeze
efirt between it and efirtc at SI_SUB_DRIVERS, SI_ORDER_ANY. efidev must be
after efirt and doesn't really need to be at SI_SUB_DEVFS, so drop it at
SI_SUB_DRIVER, SI_ORDER_ANY.

The not immediately obvious dependency of fpuinitstate by efirt has been
noted in both places.

Discussed with:	kib, andrew
Reported by:	Jakob Alvermark <jakob@alvermark.net>
X-MFC-With:	r330868
This commit is contained in:
Kyle Evans 2018-03-22 18:24:00 +00:00
parent c0505015d6
commit ad456dd9fa
3 changed files with 5 additions and 3 deletions

View File

@ -366,7 +366,8 @@ fpuinitstate(void *arg __unused)
start_emulating();
intr_restore(saveintr);
}
SYSINIT(fpuinitstate, SI_SUB_DRIVERS, SI_ORDER_ANY, fpuinitstate, NULL);
/* EFIRT needs this to be initialized before we can enter our EFI environment */
SYSINIT(fpuinitstate, SI_SUB_DRIVERS, SI_ORDER_FIRST, fpuinitstate, NULL);
/*
* Free coprocessor (if we have it).

View File

@ -216,6 +216,6 @@ static moduledata_t efidev_moddata = {
.priv = NULL,
};
DECLARE_MODULE(efidev, efidev_moddata, SI_SUB_DEVFS, SI_ORDER_ANY);
DECLARE_MODULE(efidev, efidev_moddata, SI_SUB_DRIVERS, SI_ORDER_ANY);
MODULE_VERSION(efidev, 1);
MODULE_DEPEND(efidev, efirt, 1, 1, 1);

View File

@ -450,5 +450,6 @@ static moduledata_t efirt_moddata = {
.evhand = efirt_modevents,
.priv = NULL,
};
DECLARE_MODULE(efirt, efirt_moddata, SI_SUB_VM_CONF, SI_ORDER_ANY);
/* After fpuinitstate, before efidev */
DECLARE_MODULE(efirt, efirt_moddata, SI_SUB_DRIVERS, SI_ORDER_SECOND);
MODULE_VERSION(efirt, 1);