X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm.c;h=3c3329292bad022c6376ca7989420238e1c2b4a0;hb=068d7e66db537f981fde19a098a12e4390fa3de4;hp=8c2e2d7c1567d2615c02b7b18171b8e2b881fbef;hpb=11ae9bb2d18273267d41059a4bd7fb3c28c42abc;p=palacios.git diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 8c2e2d7..3c33292 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -36,8 +36,6 @@ #include -#include - #include #include @@ -47,7 +45,9 @@ // This is a global pointer to the host's VMCB -static void * host_vmcb = NULL; +static addr_t host_vmcbs[CONFIG_MAX_CPUS] = {0}; + + extern void v3_stgi(); extern void v3_clgi(); @@ -126,7 +126,8 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info *vm_info) { vm_info->vm_regs.rdx = 0x00000f00; - guest_state->cr0 = 0x60000010; + + guest_state->cr0 = 0x60010010; // Set the WP flag so the memory hooks work in real-mode guest_state->cs.selector = 0xf000; @@ -300,7 +301,7 @@ static int start_svm_guest(struct guest_info *info) { 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), (vmcb_t *)host_vmcb); + v3_svm_launch((vmcb_t *)V3_PAddr(info->vmm_data), &(info->vm_regs), (vmcb_t *)host_vmcbs[info->cpu_id]); rdtscll(tmp_tsc); @@ -320,12 +321,6 @@ static int start_svm_guest(struct guest_info *info) { if ((num_exits % 5000) == 0) { PrintDebug("SVM Exit number %d\n", num_exits); - -#ifdef CONFIG_PROFILE_VMM - if (info->enable_profiler) { - v3_print_profile(info); - } -#endif } if (v3_handle_svm_exit(info) != 0) { @@ -358,7 +353,7 @@ static int start_svm_guest(struct guest_info *info) { PrintDebug("Host Address of rip = 0x%p\n", (void *)host_addr); PrintDebug("Instr (15 bytes) at %p:\n", (void *)host_addr); - PrintTraceMemDump((uchar_t *)host_addr, 15); + v3_dump_mem((uint8_t *)host_addr, 15); break; } @@ -441,10 +436,9 @@ static int has_svm_nested_paging() { } - -void v3_init_SVM(struct v3_ctrl_ops * vmm_ops) { +void v3_init_svm_cpu(int cpu_id) { reg_ex_t msr; - extern v3_cpu_arch_t v3_cpu_type; + extern v3_cpu_arch_t v3_cpu_types[]; // Enable SVM on the CPU v3_get_msr(EFER_MSR, &(msr.e_reg.high), &(msr.e_reg.low)); @@ -454,24 +448,26 @@ void v3_init_SVM(struct v3_ctrl_ops * vmm_ops) { PrintDebug("SVM Enabled\n"); // Setup the host state save area - host_vmcb = V3_AllocPages(4); + host_vmcbs[cpu_id] = (addr_t)V3_AllocPages(4); /* 64-BIT-ISSUE */ // msr.e_reg.high = 0; //msr.e_reg.low = (uint_t)host_vmcb; - msr.r_reg = (addr_t)host_vmcb; + msr.r_reg = host_vmcbs[cpu_id]; - PrintDebug("Host State being saved at %p\n", (void *)(addr_t)host_vmcb); + PrintDebug("Host State being saved at %p\n", (void *)host_vmcbs[cpu_id]); v3_set_msr(SVM_VM_HSAVE_PA_MSR, msr.e_reg.high, msr.e_reg.low); - - if (has_svm_nested_paging() == 1) { - v3_cpu_type = V3_SVM_REV3_CPU; + v3_cpu_types[cpu_id] = V3_SVM_REV3_CPU; } else { - v3_cpu_type = V3_SVM_CPU; + v3_cpu_types[cpu_id] = V3_SVM_CPU; } +} + + +void v3_init_svm_hooks(struct v3_ctrl_ops * vmm_ops) { // Setup the SVM specific vmm operations vmm_ops->init_guest = &init_svm_guest; @@ -551,7 +547,7 @@ void v3_init_SVM(struct v3_ctrl_ops * vmm_ops) { vmsave "rdtsc ; " : "=D"(start_hi), "=S"(start_lo), "=a"(end_lo),"=d"(end_hi) - : "c"(host_vmcb), "0"(0), "1"(0), "2"(0), "3"(0) + : "c"(host_vmcb[cpu_id]), "0"(0), "1"(0), "2"(0), "3"(0) ); start = start_hi; @@ -571,8 +567,8 @@ void v3_init_SVM(struct v3_ctrl_ops * vmm_ops) { "movq %%rcx, %%rax ; " vmload "rdtsc ; " - : "=D"(start_hi), "=S"(start_lo), "=a"(end_lo),d"(end_hi) - : "c"(host_vmcb), "0"(0), "1"(0), "2"(0), "3"(0) + : "=D"(start_hi), "=S"(start_lo), "=a"(end_lo),"=d"(end_hi) + : "c"(host_vmcb[cpu_id]), "0"(0), "1"(0), "2"(0), "3"(0) ); start = start_hi;