X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fgeekos%2Fsvm_ctrl_regs.c;h=656bb9eb87d8af00df734cfa7e81a0034ebcace6;hb=8cb3daaded0d8c80be801aa74493006b5a06999f;hp=e822e633d45dadd7f291dfe8ad40c779fcc34f2e;hpb=7acd54f8c3b30d118d56186a9c6506f21f85096d;p=palacios.git diff --git a/palacios/src/geekos/svm_ctrl_regs.c b/palacios/src/geekos/svm_ctrl_regs.c index e822e63..656bb9e 100644 --- a/palacios/src/geekos/svm_ctrl_regs.c +++ b/palacios/src/geekos/svm_ctrl_regs.c @@ -5,32 +5,39 @@ #include -int handle_cr0_write(guest_info_t * info, ullong_t * new_cr0) { - // vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA((vmcb_t *)(info->vmm_data)); - //vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data)); +int handle_cr0_write(struct guest_info * info, ullong_t * new_cr0) { + vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA((vmcb_t *)(info->vmm_data)); + vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data)); + char instr[15]; - - /* + if (info->cpu_mode == REAL) { - addr_t host_addr; - shadow_region_t * region = get_shadow_region_by_addr(&(info->mem_map), (addr_t)(info->rip)); - if (!region || (region->host_type != HOST_REGION_PHYSICAL_MEMORY)) { - //PANIC + read_guest_pa_memory(info, (addr_t)guest_state->rip, 15, instr); + int index = 0; + + while (is_prefix_byte(instr[index])) { + index++; + } + + if ((instr[index] == cr_access_byte) && + (instr[index + 1] == lmsw_byte)) { + // LMSW + // decode mod/RM + + } else if ((instr[index] == cr_access_byte) && + (instr[index + 1] == clts_byte)) { + // CLTS + } else { + // unsupported instruction, GPF the guest return -1; } - guest_paddr_to_host_paddr(region, (addr_t)(info->rip), &host_addr); - // pa to va + + } - PrintDebug("Instr: %.4x\n", *(ushort_t*)host_addr); - - if ((*(ushort_t*)host_addr) == LMSW_EAX) { - PrintDebug("lmsw from eax (0x%x)\n", guest_state->rax); - } - }*/ return 0; }