How to simulate iiret on linux x86_64

I am writing an Intel VT debugger.

As the performance of the iret command in vmx-guest changes, and NMI-Exiting = 1. Therefore, I must handle NMI in vmx-host myself, otherwise the guest will get nmi errors.

I checked the Intel manual:

While the NMI interrupt handler is running, the processor disconnects additional calls to the NMI handler until the next IRET command is executed. This blocking of subsequent NMIs prevents stacking calls to the NMI handler.

So, I am trying to simulate iiret in vmx-host myself. CPL remains ring0 and does not change the stack segment and code.

I write the sample code below, it was after the vmx output called 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":); 

Can anyone show some guides?

+2
source share

All Articles