4 ms·
If I'm understanding this right: - Firefox is seeing a crash associated with use of the AVX vector-processing (~= high-performance math) instructions - The AV
by geofft 10y ago
If I'm understanding this right:
- Firefox is seeing a crash associated with use of the AVX vector-processing (~= high-performance math) instructions
- The AVX instructions use more registers, and registers need to be saved/restored during a context switch, so you can switch back to a program and have it be transparent. So you can only use AVX if the OS supports it, and promises to save/restore those registers in addition to regular registers when it does a context switch. The OS reports to the CPU "Yes, it's okay to let people use AVX" by setting a bit in a control register. Applications check that bit before using AVX instructions.
- The crash is an illegal-operation exception, which should be impossible because Firefox checks to see if that bit is set before using those instructions.
The answer to the mystery: Some people are using an old version of Windows, that does not support AVX, but with a bootloader from a new version of Windows. For whatever reason, the bootloader sets the "Yeah, AVX is fine" bit, and expects the new version of Windows to detect AVX and set support as appropriate. Old versions of Windows don't know about that bit, though, and never clear it. So Firefox proceeds to use AVX on a CPU that has no AVX support.
This was discovered by someone mentioning that they were dual-booting Windows versions, and that the crash went away when restoring the older bootloader.
- yuhong 10y agoThe newer BOOTMGR chains to the older NTLDR which in turns loads XP/Server 2003 or older, and they forgot to clear the bits when chaining.
- daeken 10y agoIt seems a bit odd that they'd be enabling AVX in the bootloader. Any idea why they do that? Seems like something for the kernel to do during initialization (like most other features), not the bootloader.
- prodigal_erik 10y agoDoes the bootloader choose a kernel entry point based on the CPU features?
- yuhong 10y agoMy understanding is that BOOTMGR goes to WINLOAD when booting Vista or later. The routine that ensures the correct CR4/XCR0 values in this case is called bootmgr!ArchRestoreProcessorFeatures and it is called just before bootmgr!BlBdStop in bootmgr!ArchExecuteTransition.
- aaronmdjones 10y ago"So Firefox proceeds to use AVX on a CPU that has no AVX support". To make it clear; it uses AVX on a CPU that does support it (otherwise you'd run into an illegal instruction error), but the OS doesn't. Firefox doesn't know this, however, because it thinks the OS set the bit that says it does.
- geofft 10y agoOh, does VZEROUPPER generate an illegal instruction if the OS has set the control register bit but has not called XSETBV? OK, that makes more sense.