It still looks like your fixed bits might be off for CR0/CR4, the NE bit in CR0 is set in bochs after going through that process for me, there might be some in CR4.
This is the code I use preceding the initialization of the VMXON region to set the necessary fixed bits. It's probably possible in theory for VMX to require you to disable some feature your OS relies on too and complete code would require some checks for that as well.
Code:
//Get the current state of our CR4 and CR0 registers
asm ( "mov %%cr4, %%rax\n"
"or $0x2000, %%rax\n"
"mov %%rax, %%cr4\n": "=a" ( cr4 ) : );
asm ( "mov %%cr0, %%rax\n": "=a" ( cr0 ) : );
//Set and clear the required bits in CR0 and CR4
fixedCr0 = readMSR ( MSR_VMX_CR0_FIXED1 );
fixedCr4 = readMSR ( MSR_VMX_CR4_FIXED1 );
//Clear the necessary fixed bits
cr0 &= fixedCr0;
cr4 &= fixedCr4;
//Set the necessary fixed bits
cr0 |= readMSR ( MSR_VMX_CR0_FIXED0 );
cr4 |= readMSR ( MSR_VMX_CR4_FIXED0 );
//Load new CR0/CR4 values
asm ( "mov %%rax, %%cr0\n":: "a" ( cr0 ) );
asm ( "mov %%rax, %%cr4\n":: "a" ( cr4 ) );
MSRs:
Code:
#define MSR_VMX_CR0_FIXED0 0x486
#define MSR_VMX_CR0_FIXED1 0x487
#define MSR_VMX_CR4_FIXED0 0x488
#define MSR_VMX_CR4_FIXED1 0x489
You're right about the asm code too, it doesn't matter. I must have confused that with something else, my apologies.