1

I am recently writing a micro-hypervisor for Intel CPUs. My micro-hypervisor runs while VMX is enabled. However, I ran into problem when trying to reboot the machine.

I decide to follow https://wiki.osdev.org/Reboot and perform a PS/2 8042 reset (i.e. write command 0xfe to IO port 0x64). However, I discover that when VMX is enabled, the 8042 reset is not successful (I have to use the power button to restart the machine). However, if I disable VMX using VMXOFF and then perform the 8042 reset, the reset is successful (I then see BIOS splashscreen, etc.)

My question is: why cannot I perform a 8042 reset with VMX enabled? OSDev says that the 8042 controller will pulse the reset line. I am assuming that it means asserting the RESET# pin. Intel's SDM does not say that VMX will cause RESET# to be ignored.

Also, while googling around, I saw this comment in Linux's reboot code:

Disable virtualization, i.e. VMX or SVM, to ensure INIT is recognized during reboot. VMX blocks INIT if the CPU is post-VMXON, and SVM blocks INIT if GIF=0, i.e. if the crash occurred between CLGI and STGI.

Intel's SDM does say that when VMX is enabled, INIT interrupts are blocked. Is INIT interrupts related to 8042 reset? Or is Linux using a method other than 8042 reset to reboot? In general, how does the hardware reset the CPU?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Eric Stdlib
  • 1,292
  • 1
  • 18
  • 32
  • Obviously a guest kernel must not be allowed to reset the whole physical machine. It sounds like Intel chose to disable that way of rebooting entirely while VMX is enabled at all, instead of having a check based on whether you're in the hypervisor on inside a guest. But I don't know the details; maybe someone else does. – Peter Cordes Apr 07 '23 at 01:49
  • My hypervisor writes port 0xcf9 with 0x02 followed by 0x06 to reboot the system. I haven't encountered a system on which this doesn't work. – prl Apr 07 '23 at 05:36
  • 1
    It is possible that your system doesn't actually have an 8042 and its functions are emulated by the BIOS and your BIOS doesn't emulate the reset function. – prl Apr 07 '23 at 05:44

0 Answers0