AMD SVM, hanlde intercepted page fault

Discussion created by terovn on Apr 26, 2009
Latest reply on Apr 30, 2009 by devcentral
How to handle intercepted page fault.

I am trying to write a simple hypervisor using AMD SVM.

I was able to intercept Page Fault created by the guest (not Nested page fault). I handled it by injecting an PF event into the guest.

The handler code is given below:

vm->vmcb->eventinj.fields.vector =  14;
vm->vmcb->eventinj.fields.type = EVENT_TYPE_EXCEPTION;
vm->vmcb->eventinj.fields.ev = 1;
vm->vmcb->eventinj.fields.v = 1;
vm->vmcb->eventinj.fields.errorcode = vm->vmcb->exitinfo1;
//errorcode givein in exitinfo1, will be pushed to the stack
vm->vmcb->cr2 = vm->vmcb->exitinfo2;
//exitinfo2 contains the faulting address, which should be put into cr2

vm->vmcb is a pointer to the vmcb structure.


Somehow the guest OS behaves different (does not boot correctly) if I enable this interception and handler.

Anyone who have got Page fault interception to work, please tell me how you did it. It would help a lot.