X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm.c;h=d1125eef170aaade706f46412b7d466035f03f29;hb=a4fd5bcc79e7cdf9a3bd879294566bff0666ced7;hp=c9ef918a7a4676106cb444ebeefc39f377d02663;hpb=915d7c977583d5f376624216d30676d412a989a7;p=palacios.git diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index c9ef918..d1125ee 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -39,6 +39,7 @@ #include #include +#include #ifdef V3_CONFIG_CHECKPOINT @@ -52,6 +53,9 @@ #include +#ifdef V3_CONFIG_TM_FUNC +#include +#endif #ifndef V3_CONFIG_DEBUG_SVM #undef PrintDebug @@ -59,6 +63,7 @@ #endif + uint32_t v3_last_exit; // This is a global pointer to the host's VMCB @@ -74,7 +79,7 @@ extern int v3_svm_launch(vmcb_t * vmcb, struct v3_gprs * vm_regs, vmcb_t * host_ static vmcb_t * Allocate_VMCB() { vmcb_t * vmcb_page = NULL; - addr_t vmcb_pa = (addr_t)V3_AllocPages(1); + addr_t vmcb_pa = (addr_t)V3_AllocPages(1); // need not be shadow safe, not exposed to guest if ((void *)vmcb_pa == NULL) { PrintError(VM_NONE, VCORE_NONE, "Error allocating VMCB\n"); @@ -154,6 +159,10 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info * core) { ctrl_area->exceptions.nmi = 1; */ + +#ifdef V3_CONFIG_TM_FUNC + v3_tm_set_excp_intercepts(ctrl_area); +#endif ctrl_area->instrs.NMI = 1; @@ -281,11 +290,13 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info * core) { PrintDebug(core->vm_info, core, "Created\n"); core->ctrl_regs.cr0 |= 0x80000000; - core->ctrl_regs.cr3 = core->direct_map_pt; + + v3_activate_passthrough_pt(core); ctrl_area->cr_reads.cr0 = 1; ctrl_area->cr_writes.cr0 = 1; - //ctrl_area->cr_reads.cr4 = 1; + //intercept cr4 read so shadow pager can use PAE independently of guest + ctrl_area->cr_reads.cr4 = 1; ctrl_area->cr_writes.cr4 = 1; ctrl_area->cr_reads.cr3 = 1; ctrl_area->cr_writes.cr3 = 1; @@ -666,6 +677,8 @@ int v3_svm_enter(struct guest_info * info) { guest_state->rip = info->rip; guest_state->rsp = info->vm_regs.rsp; + V3_FP_ENTRY_RESTORE(info); + #ifdef V3_CONFIG_SYMCALL if (info->sym_core_state.symcall_state.sym_call_active == 0) { update_irq_entry_state(info); @@ -674,6 +687,10 @@ int v3_svm_enter(struct guest_info * info) { update_irq_entry_state(info); #endif +#ifdef V3_CONFIG_TM_FUNC + v3_tm_check_intr_state(info, guest_ctrl, guest_state); +#endif + /* ** */ @@ -733,6 +750,8 @@ int v3_svm_enter(struct guest_info * info) { info->num_exits++; + V3_FP_EXIT_SAVE(info); + // Save Guest state from VMCB info->rip = guest_state->rip; info->vm_regs.rsp = guest_state->rsp; @@ -823,7 +842,9 @@ int v3_start_svm_guest(struct guest_info * info) { info->core_run_state = CORE_RUNNING; } else { PrintDebug(info->vm_info, info, "SVM core %u (on %u): Waiting for core initialization\n", info->vcpu_id, info->pcpu_id); - + + V3_NO_WORK(info); + while (info->core_run_state == CORE_STOPPED) { if (info->vm_info->run_state == VM_STOPPED) { @@ -831,9 +852,12 @@ int v3_start_svm_guest(struct guest_info * info) { return 0; } - v3_yield(info,-1); + V3_STILL_NO_WORK(info); + //PrintDebug(info->vm_info, info, "SVM core %u: still waiting for INIT\n", info->vcpu_id); } + + V3_HAVE_WORK_AGAIN(info); PrintDebug(info->vm_info, info, "SVM core %u(on %u) initialized\n", info->vcpu_id, info->pcpu_id); @@ -1042,7 +1066,7 @@ void v3_init_svm_cpu(int cpu_id) { V3_Print(VM_NONE, VCORE_NONE, "SVM Enabled\n"); // Setup the host state save area - host_vmcbs[cpu_id] = (addr_t)V3_AllocPages(4); + host_vmcbs[cpu_id] = (addr_t)V3_AllocPages(4); // need not be shadow-safe, not exposed to guest if (!host_vmcbs[cpu_id]) { PrintError(VM_NONE, VCORE_NONE, "Failed to allocate VMCB\n"); @@ -1287,7 +1311,7 @@ void Init_VMCB_pe(vmcb_t *vmcb, struct guest_info vm_info) { ctrl_area->instrs.IOIO_PROT = 1; - ctrl_area->IOPM_BASE_PA = (uint_t)V3_AllocPages(3); + ctrl_area->IOPM_BASE_PA = (uint_t)V3_AllocPages(3); // need not be shadow-safe, not exposed to guest if (!ctrl_area->IOPM_BASE_PA) { PrintError(core->vm_info, core, "Cannot allocate IO bitmap\n");