X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm.c;h=ae275c165f32edeaf5f5a83eb24a8c44af43c616;hb=9928ec9289de6658a2830370b1d1b514833515d0;hp=76a57ddcb091f6f666de04c90bc677d173fb0ee1;hpb=6ce5a308d167ac392c0f0ca66811f51580358191;p=palacios.releases.git diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 76a57dd..ae275c1 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -458,6 +458,72 @@ void v3_init_SVM(struct v3_ctrl_ops * vmm_ops) { PrintDebug("Host State being saved at %p\n", (void *)(addr_t)host_vmcb); v3_set_msr(SVM_VM_HSAVE_PA_MSR, msr.e_reg.high, msr.e_reg.low); + + + /* + * Test VMSAVE/VMLOAD Latency + */ +#define vmsave ".byte 0x0F,0x01,0xDB ; " +#define vmload ".byte 0x0F,0x01,0xDA ; " + { + uint32_t start_lo, start_hi; + uint32_t end_lo, end_hi; + uint64_t start, end; + + __asm__ __volatile__ ( + "rdtsc ; " + "movl %%eax, %%esi ; " + "movl %%edx, %%edi ; " + "movq %%rcx, %%rax ; " + 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) + ); + + start = start_hi; + start <<= 32; + start += start_lo; + + end = end_hi; + end <<= 32; + end += end_lo; + + + PrintDebug("VMSave Cycle Latency: %d\n", (uint32_t)(end - start)); + + + + + __asm__ __volatile__ ( + "rdtsc ; " + "movl %%eax, %%esi ; " + "movl %%edx, %%edi ; " + "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) + ); + + start = start_hi; + start <<= 32; + start += start_lo; + + end = end_hi; + end <<= 32; + end += end_lo; + + + PrintDebug("VMLoad Cycle Latency: %d\n", (uint32_t)(end - start)); + + + + } + + + /* End Latency Test */ + if (has_svm_nested_paging() == 1) { v3_cpu_type = V3_SVM_REV3_CPU; } else {