Finding a bug in Win10 BOOTMGR when chaining to NTLDR
bugzilla.mozilla.org
bugzilla.mozilla.org
And yuhong has found that the reason Firefox thinks that, specifically on Windows XP which is booted with the Windows 10 loader, is that the Windows 10 loader sets some bit "I know about AVX" instead of clearing it before entering in Windows XP.
It would probably be quite a simple project to work on, and a fun way to learn about bootloader-level software development. Chainloading NTLDR is well-understood (and will never change), and being booted by BOOTMGR is also fairly well understood too. If I was running Windows at the moment I'd be seriously considering playing with this myself.
So... BOOTMGR (Win10) is chaining through to NTLDR to load WinXP. And either Win10 comes with a copy of NTLDR, or pokes around to find the one on the XP system.
By my reasoning, Secure Boot should say "okay" and happily start the machine when it decides BOOTMGR is okay, on the basis that BOOTMGR will verify whatever it loads. The question is whether BOOTMGR actually does that, and seeing as if it doesn't then there isn't really a boot trust chain, well, it probably does verify what it loads.
I fear this is something only Microsoft would be able to fix properly for users who want/need Secure Boot. Slightly ironic. But thinking about it, Secure Boot on XP is kind of like deadbolting your front door when your walls have completely disappeared (picture a door sitting in the middle of nowhere), because XP is officially EOL now.
Not even other signed and verified uefi bootloaders.
A checked build basically has optimization off and assert() on.
> Many compiler optimizations (such as stack frame elimination) are disabled in the checked build. This makes it easier to understand disassembled machine instructions, and therefore it is easier to trace the cause of problems in system software.
Also, how did you remove the real-mode stub? Hex editing, or is there a tool that will do that if fed the right combination of [obscure] options?
IMHO, the best way to finish this off would be an in-depth tutorial-style blog post. You definitely get my recommendation to consider that :)
And MZ-hunting makes perfect sense.
Thanks for the quick reply :) and kudos for figuring out it was the bootloader, hah
If so, do you use a Windows 10 (NT6) boot menu to select from other operating systems which incude Windows XP (or presumably other versions of NT5)?
Then the defective Microsoft engineering described, applies to your use of XP after it is booted from the W10 menu.
Looks like it may also apply to other Windows versions or operating systems like some Linux distributions, so beware.
This bug was reported by user Brindusa Tot during operation of Mozilla Firefox. 2015-11-16
Confirmed with difficulty by engineer Yuhong Bao as a defect in the Windows 10 BOOTMGR routine. 2017-01-27
yuhong is on this thread, this is the kind of engineer I would want on my team.
Further testing needs to be done to determine if there is an alternative BOOTMGR or procedure which does not suffer from this insidious failure.
Mozilla is not a source of this defect at all.
It's simply the Microsoft Windows 10 code that's failing to properly do what it says it does.
- 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.