X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm.c;h=f02a8947c9450309bca78a358f8bb42ef219e945;hb=df88a0e0e54e9f499fbf38b25863bc04c8a37934;hp=c577a7df6cc87740eb45049f59cf513c01a22b0f;hpb=29e825c5f095066bbb5ebbec5a5af1419d883264;p=palacios.git diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index c577a7d..f02a894 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -209,8 +209,6 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info *vm_info) { ctrl_area->cr_reads.cr3 = 1; ctrl_area->cr_writes.cr3 = 1; - vm_info->guest_efer.value = 0x0LL; - v3_hook_msr(vm_info, EFER_MSR, &v3_handle_efer_read, &v3_handle_efer_write, @@ -220,8 +218,6 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info *vm_info) { ctrl_area->exceptions.pf = 1; - - guest_state->g_pat = 0x7040600070406ULL; guest_state->cr0 |= 0x80000000; @@ -246,12 +242,6 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info *vm_info) { guest_state->g_pat = 0x7040600070406ULL; } - - - - /* Safety locations for fs/gs */ - // vm_info->fs = 0; - // vm_info->gs = 0; } @@ -270,8 +260,6 @@ static int init_svm_guest(struct guest_info *info, struct v3_vm_config * config_ info->run_state = VM_STOPPED; - // info->rip = 0; - info->vm_regs.rdi = 0; info->vm_regs.rsi = 0; info->vm_regs.rbp = 0; @@ -303,24 +291,33 @@ static int start_svm_guest(struct guest_info *info) { ullong_t tmp_tsc; +#ifdef __V3_64BIT__ -#define MSR_STAR 0xc0000081 -#define MSR_LSTAR 0xc0000082 -#define MSR_CSTAR 0xc0000083 -#define MSR_SF_MASK 0xc0000084 -#define MSR_GS_BASE 0xc0000101 +#define MSR_LSTAR 0xc0000082 +#define MSR_CSTAR 0xc0000083 +#define MSR_SF_MASK 0xc0000084 +#define MSR_GS_BASE 0xc0000101 #define MSR_KERNGS_BASE 0xc0000102 - - struct v3_msr host_cstar; - struct v3_msr host_star; struct v3_msr host_lstar; struct v3_msr host_syscall_mask; struct v3_msr host_gs_base; struct v3_msr host_kerngs_base; -/* v3_enable_ints(); */ -/* v3_clgi(); */ +#else + +#define MSR_SYSENTER_CS 0x00000174 +#define MSR_SYSENTER_ESP 0x00000175 +#define MSR_SYSENTER_EIP 0x00000176 + + struct v3_msr host_sysenter_cs; + struct v3_msr host_sysenter_esp; + struct v3_msr host_sysenter_eip; + +#endif + +#define MSR_STAR 0xc0000081 + struct v3_msr host_star; /* @@ -330,28 +327,39 @@ static int start_svm_guest(struct guest_info *info) { */ - v3_get_msr(MSR_STAR, &(host_star.hi), &(host_star.lo)); +#ifdef __V3_64BIT__ + v3_get_msr(MSR_SF_MASK, &(host_syscall_mask.hi), &(host_syscall_mask.lo)); v3_get_msr(MSR_LSTAR, &(host_lstar.hi), &(host_lstar.lo)); v3_get_msr(MSR_CSTAR, &(host_cstar.hi), &(host_cstar.lo)); - v3_get_msr(MSR_SF_MASK, &(host_syscall_mask.hi), &(host_syscall_mask.lo)); v3_get_msr(MSR_GS_BASE, &(host_gs_base.hi), &(host_gs_base.lo)); v3_get_msr(MSR_KERNGS_BASE, &(host_kerngs_base.hi), &(host_kerngs_base.lo)); - +#else + v3_get_msr(MSR_SYSENTER_CS, &(host_sysenter_cs.hi), &(host_sysenter_cs.lo)); + v3_get_msr(MSR_SYSENTER_ESP, &(host_sysenter_esp.hi), &(host_sysenter_esp.lo)); + v3_get_msr(MSR_SYSENTER_EIP, &(host_sysenter_eip.hi), &(host_sysenter_eip.lo)); +#endif + v3_get_msr(MSR_STAR, &(host_star.hi), &(host_star.lo)); rdtscll(info->time_state.cached_host_tsc); // guest_ctrl->TSC_OFFSET = info->time_state.guest_tsc - info->time_state.cached_host_tsc; - //v3_svm_launch((vmcb_t*)V3_PAddr(info->vmm_data), &(info->vm_regs), &(info->fs), &(info->gs)); v3_svm_launch((vmcb_t*)V3_PAddr(info->vmm_data), &(info->vm_regs)); rdtscll(tmp_tsc); - v3_set_msr(MSR_STAR, host_star.hi, host_star.lo); +#ifdef __V3_64BIT__ + v3_set_msr(MSR_SF_MASK, host_syscall_mask.hi, host_syscall_mask.lo); v3_set_msr(MSR_LSTAR, host_lstar.hi, host_lstar.lo); v3_set_msr(MSR_CSTAR, host_cstar.hi, host_cstar.lo); - v3_set_msr(MSR_SF_MASK, host_syscall_mask.hi, host_syscall_mask.lo); v3_set_msr(MSR_GS_BASE, host_gs_base.hi, host_gs_base.lo); v3_set_msr(MSR_KERNGS_BASE, host_kerngs_base.hi, host_kerngs_base.lo); +#else + v3_set_msr(MSR_SYSENTER_CS, host_sysenter_cs.hi, host_sysenter_cs.lo); + v3_set_msr(MSR_SYSENTER_ESP, host_sysenter_esp.hi, host_sysenter_esp.lo); + v3_set_msr(MSR_SYSENTER_EIP, host_sysenter_eip.hi, host_sysenter_eip.lo); +#endif + v3_set_msr(MSR_STAR, host_star.hi, host_star.lo); + //PrintDebug("SVM Returned\n"); @@ -396,7 +404,7 @@ static int start_svm_guest(struct guest_info *info) { PrintDebug("Shadow Paging Guest Registers:\n"); PrintDebug("\tGuest CR0=%p\n", (void *)(addr_t)(info->shdw_pg_state.guest_cr0)); PrintDebug("\tGuest CR3=%p\n", (void *)(addr_t)(info->shdw_pg_state.guest_cr3)); - // efer + PrintDebug("\tGuest EFER=%p\n", (void *)(addr_t)(info->shdw_pg_state.guest_efer.value)); // CR4 } v3_print_GPRs(info);