0

I am trying to write a long mode guest program under hypervision. When I inject an external interrupt to the guest, the guest immediately triggered a #GP fault. The error code is 0x11, indicating that cs selector is 0x10, and that this fault is external. (The #GP fault was intercepted by my hypervisor. In other words, I did not set up #GP handler in IDT.)
I conjecture there is something wrong with my GDT. However, I specified the same cs selector (i.e: cs.selector=0x10) of interrupt handler as the normal control flow. The normal control flow went well with this cs selector, so what could be the real specific cause of the #GP fault?
An exhaustive checklist would be appreciated as well.

1 Answers1

0

It turns out that I forgot to initialize GDT for the Guest in my hypervisor. Therefore, external interrupt was referencing a null code segment and thereby triggers #GP fault.
In a word, segment state saved in VMCB does not necessarily synchronize with the Guest's GDT memory region.