I am writing a debugger based on Intel VT.
As the iret instruction's performance in vmx-guest is changed while NMI-Exiting=1. So I should handle NMI in the vmx-host myself,otherwise,guest will have nmi reentrant bugs.
I checked the Intel manual :
While an NMI interrupt handler is executing, the processor disables additional calls to the NMI handler until the next IRET instruction is executed. This blocking of subse-quent NMIs prevents stacking up calls to the NMI handler.
So I am trying to simulate a iret in the vmx-host myself. the CPL remains ring0 and keep stack and code segment no change.
I write a sample code below,it was after vmx-exit caused by NMI:
asm volatile(
"pushfq \n\t"
"mov %%cs.%%ax \n\t"
"push %%rax\n\t"
"mov $._restart_code,%%rax \n\t"
"push %%rax \n\t"
"iret \n\t"/*manully iret in the host before vmx-entry.*/
"._restart_code:"
"nop":);
Anyone can show some guides?