1 #include <geekos/svm_ctrl_regs.h>
2 #include <geekos/vmm_mem.h>
3 #include <geekos/vmm.h>
4 #include <geekos/vmcb.h>
5 #include <geekos/vmm_emulate.h>
6 #include <geekos/vm_guest_mem.h>
8 int handle_cr0_write(struct guest_info * info, ullong_t * new_cr0) {
9 //vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA((vmcb_t *)(info->vmm_data));
10 vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
16 if (info->cpu_mode == REAL) {
17 read_guest_pa_memory(info, (addr_t)guest_state->rip, 15, instr);
20 while (is_prefix_byte(instr[index])) {
21 PrintDebug("instr(%d): 0x%x\n", index, instr[index]);
24 PrintDebug("instr(%d): 0x%x\n", index, instr[index]);
25 PrintDebug("instr(%d): 0x%x\n", index+1, instr[index + 1]);
27 if ((instr[index] == cr_access_byte) &&
28 (instr[index + 1] == lmsw_byte) &&
29 (MODRM_REG(instr[index + 2]) == lmsw_reg_byte)) {
32 addr_t second_operand;
39 if (decode_operands16(&(info->vm_regs), instr + index, &first_operand, &second_operand, REG16) != 0) {
40 // error... don't know what to do
44 PrintDebug("FirstOperand addr: %x, RAX addr: %x\n", first_operand, &(info->vm_regs.rax));
49 } else if ((instr[index] == cr_access_byte) &&
50 (instr[index + 1] == clts_byte)) {
53 // unsupported instruction, GPF the guest