From 7e6fdcc86b75fe5fae7f8d592ccf997298fca97c Mon Sep 17 00:00:00 2001 From: _xeroxz Date: Tue, 16 Feb 2021 03:25:03 +0000 Subject: [PATCH] Update README.md --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c86e47..f001d3a 100644 --- a/README.md +++ b/README.md @@ -120,4 +120,22 @@ vcpu->tss.interrupt_stack_table[idt::ist_idx::de] = PAGE_SIZE * HOST_STACK_PAGES)) + (PAGE_SIZE * HOST_STACK_PAGES); ``` -#### IDT - Interrupt Descriptor Table \ No newline at end of file +#### IDT - Interrupt Descriptor Table + +The host IDT is 1:1 to the guest IDT except for three interrupt handlers, #PF, #DE, and #GP. These three different interrupt handlers all route to the same SEH handler function +which just changes RIP to the catch block of whatever try/except the exception happened in. This allows for page faults, general protection faults and division errors to not be handled +by guest controlled interrupt handlers. + +```cpp +// setup IDT for host.... +segment_descriptor_register_64 idt_value; +__sidt(&idt_value); + +// copy the guest IDT entries... +memcpy(idt::table, (void*)idt_value.base_address, idt_value.limit); + +// change gp, pf, and de to vmxroot handlers... +idt::table[general_protection] = idt::create_entry(hv::idt_addr_t{ __gp_handler }, idt::ist_idx::gp); +idt::table[page_fault] = idt::create_entry(hv::idt_addr_t{ __pf_handler }, idt::ist_idx::pf); +idt::table[divide_error] = idt::create_entry(hv::idt_addr_t{ __de_handler }, idt::ist_idx::de); +```