Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.
1121 Discussions

monitor/mwait disabled by IA32_MISC_ENABLES MSR?

godofpumpkins
Beginner
2,729 Views
Hi everyone,

I'm having a strange issue, so I'll give a high-level description of it first, and then explain the details.

I bought an Intel Xeon 5405 to put into my Mac Pro. It seems to work fine, but when I try to boot into Mac OS, I get a kernel panic claiming the CPU doesn't support the monitor/mwait instruction. I manage to remove the check from the boot process, and everything else seems to function normally. Out of curiosity though, I wrote myself a little utility to check the cpuid, and it gave me the following:

fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clfsh ds acpi mmx fxsr sse sse2 ss htt tm pbe sse3 tm2 ssse3 xd em64t lahf

Sure enough, no mon feature bit is set. If I issue cpuid with eax=5 (monitor/mwait-specific information), though, I get the same output as a CPU that reports having the monitor feature, so it's puzzling. I was under the impression that cpuid output was relatively static for a given CPU, so I set out to find what could cause mon to not show up. In the monitor/mwait documentation, I found the following passage:

The operating system or system BIOS may disable this instruction by using the IA32_MISC_ENABLES MSR; disabling MONITOR clears the CPUID feature flag and causes execution to generate an illegal opcode exception.

So it seemed like someone was disabling this MSR sometime early in the boot process and that it was causing my OS to panic due to the apparent lack of the monitor instruction. I tried to look up more information on the IA32_MISC_ENABLES MSR but google only showed occasional bit mentions of it. One useful link came from this forum mentioning that bit 18 of that MSR enabled/disabled the mwait instruction. Given that I can't really jump in between Mac OS and power-on though, I can't determine what is turning off that bit in the MSR or when.

My main questions are:
Is there a canonical list of what Intel CPUs support what features (as reported by cpuid)?
Does anyone have any idea what could be causing my broad issue? Being a Mac motherboard (still manufactured by Intel I believe, but not publicly available) it uses EFI rather than BIOS, so there's no boot screen I can jump into to disable that bit.
Is there a list of what bits mean what in the IA32_MISC_ENABLES MSR, in case I want to try something more involved?

Thank you,
Daniel Peebles
0 Kudos
3 Replies
levicki
Valued Contributor I
2,729 Views
No list but the bits are documented in Software Developer's Manual -- register IA32_MISC_ENABLE (MSR 0x1A0), ENABLE MONITOR FSM (bit 18) has to be set to 1 for MONITOR/MWAIT to be available. You can include this code in a boot sector if there is any free space in it:
[cpp]	mov	ecx, 0x1A0
	rdmsr
	and	edx, 0x00000004
	and	eax, 0x00C51889
	or	eax, 0x00040000
	wrmsr
[/cpp]
Any reserved bits from that MSR should read as zero so the AND masks probably aren't neccessary, but I like to respect certain rules when it comes to programming the hardware so I included those.

0 Kudos
godofpumpkins
Beginner
2,729 Views
Quoting - Igor Levicki
No list but the bits are documented in Software Developer's Manual -- register IA32_MISC_ENABLE (MSR 0x1A0), ENABLE MONITOR FSM (bit 18) has to be set to 1 for MONITOR/MWAIT to be available. You can include this code in a boot sector if there is any free space in it:
[cpp]	mov	ecx, 0x1A0
	rdmsr
	and	edx, 0x00000004
	and	eax, 0x00C51889
	or	eax, 0x00040000
	wrmsr
[/cpp]
Any reserved bits from that MSR should read as zero so the AND masks probably aren't neccessary, but I like to respect certain rules when it comes to programming the hardware so I included those.


Thank you for this! The masking makes sense and I would probably try to do the same thing. I will have to think about where I can put this code, and why it is necessary, because in my understanding that bit starts off set when the computer boots up, and some code somewhere needs to explicitly unset it to get the behavior I'm getting? My concern is that I could jump in at one stage of the boot process and whatever code is unsetting the bit will still do so after me.

Anyway, I'll look around in the EFI documentation and try to understand the EFI/Mac OS boot process (my experience so far has only ever been with BIOS) better and then see where I can jump in with your code easily.

Thank you, I'll post on this thread if I figure anything out.
Daniel Peebles
0 Kudos
levicki
Valued Contributor I
2,729 Views
The only one who may attempt to disable this bit is BIOS (EFI or not). So, if you set it again after BIOS initialization and before loading the kernel then you will get the behavior you desire.

0 Kudos
Reply