diff options
author | attilio <attilio@FreeBSD.org> | 2013-03-17 23:39:52 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2013-03-17 23:39:52 +0000 |
commit | d500d6361abe652aef27a2c034835bc2a60155ad (patch) | |
tree | 660c72c3a1b0cbf41943fa591b5ed5d1f31c50f6 /sys/amd64 | |
parent | a69d85af8b2642ba2d10b8aa37bc58a3123ec1c6 (diff) | |
parent | 960294c20051941b358bdc3d71e05fa682614d6f (diff) | |
download | FreeBSD-src-d500d6361abe652aef27a2c034835bc2a60155ad.zip FreeBSD-src-d500d6361abe652aef27a2c034835bc2a60155ad.tar.gz |
MFC
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/pmap.c | 24 | ||||
-rw-r--r-- | sys/amd64/vmm/intel/vmx.c | 7 | ||||
-rw-r--r-- | sys/amd64/vmm/vmm.c | 8 | ||||
-rw-r--r-- | sys/amd64/vmm/vmm_stat.c | 13 | ||||
-rw-r--r-- | sys/amd64/vmm/vmm_stat.h | 27 |
5 files changed, 68 insertions, 11 deletions
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 324fc69..55d2cff 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -4235,6 +4235,30 @@ pmap_copy_page(vm_page_t msrc, vm_page_t mdst) pagecopy((void *)src, (void *)dst); } +void +pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[], + vm_offset_t b_offset, int xfersize) +{ + void *a_cp, *b_cp; + vm_offset_t a_pg_offset, b_pg_offset; + int cnt; + + while (xfersize > 0) { + a_pg_offset = a_offset & PAGE_MASK; + cnt = min(xfersize, PAGE_SIZE - a_pg_offset); + a_cp = (char *)PHYS_TO_DMAP(ma[a_offset >> PAGE_SHIFT]-> + phys_addr) + a_pg_offset; + b_pg_offset = b_offset & PAGE_MASK; + cnt = min(cnt, PAGE_SIZE - b_pg_offset); + b_cp = (char *)PHYS_TO_DMAP(mb[b_offset >> PAGE_SHIFT]-> + phys_addr) + b_pg_offset; + bcopy(a_cp, b_cp, cnt); + a_offset += cnt; + b_offset += cnt; + xfersize -= cnt; + } +} + /* * Returns true if the pmap's pv is one of the first * 16 pvs linked to from this page. This count may diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c index 287ac8c..8db79ce 100644 --- a/sys/amd64/vmm/intel/vmx.c +++ b/sys/amd64/vmm/intel/vmx.c @@ -153,10 +153,7 @@ static int cap_unrestricted_guest; static int cap_monitor_trap; /* statistics */ -static VMM_STAT_DEFINE(VCPU_MIGRATIONS, "vcpu migration across host cpus"); -static VMM_STAT_DEFINE(VMEXIT_EXTINT, "vm exits due to external interrupt"); -static VMM_STAT_DEFINE(VMEXIT_HLT_IGNORED, "number of times hlt was ignored"); -static VMM_STAT_DEFINE(VMEXIT_HLT, "number of times hlt was intercepted"); +static VMM_STAT_INTEL(VMEXIT_HLT_IGNORED, "number of times hlt was ignored"); #ifdef KTR static const char * @@ -1216,6 +1213,8 @@ vmx_exit_process(struct vmx *vmx, int vcpu, struct vm_exit *vmexit) qual = vmexit->u.vmx.exit_qualification; vmexit->exitcode = VM_EXITCODE_BOGUS; + vmm_stat_incr(vmx->vm, vcpu, VMEXIT_COUNT, 1); + switch (vmexit->u.vmx.exit_reason) { case EXIT_REASON_CR_ACCESS: handled = vmx_emulate_cr_access(vmx, vcpu, qual); diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index 85d277e..1de4470 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -139,7 +139,7 @@ static MALLOC_DEFINE(M_VM, "vm", "vm"); CTASSERT(VMM_MSR_NUM <= 64); /* msr_mask can keep track of up to 64 msrs */ /* statistics */ -static VMM_STAT_DEFINE(VCPU_TOTAL_RUNTIME, "vcpu total runtime"); +static VMM_STAT(VCPU_TOTAL_RUNTIME, "vcpu total runtime"); static void vcpu_cleanup(struct vcpu *vcpu) @@ -612,7 +612,7 @@ save_guest_fpustate(struct vcpu *vcpu) fpu_start_emulating(); } -static VMM_STAT_DEFINE(VCPU_IDLE_TICKS, "number of ticks vcpu was idle"); +static VMM_STAT(VCPU_IDLE_TICKS, "number of ticks vcpu was idle"); int vm_run(struct vm *vm, struct vm_run *vmrun) @@ -717,7 +717,7 @@ vm_inject_event(struct vm *vm, int vcpuid, int type, return (VMINJECT(vm->cookie, vcpuid, type, vector, code, code_valid)); } -static VMM_STAT_DEFINE(VCPU_NMI_COUNT, "number of NMIs delivered to vcpu"); +static VMM_STAT(VCPU_NMI_COUNT, "number of NMIs delivered to vcpu"); int vm_inject_nmi(struct vm *vm, int vcpuid) @@ -937,7 +937,7 @@ vm_set_x2apic_state(struct vm *vm, int vcpuid, enum x2apic_state state) if (vcpuid < 0 || vcpuid >= VM_MAXCPU) return (EINVAL); - if (state < 0 || state >= X2APIC_STATE_LAST) + if (state >= X2APIC_STATE_LAST) return (EINVAL); vm->vcpu[vcpuid].x2apic_state = state; diff --git a/sys/amd64/vmm/vmm_stat.c b/sys/amd64/vmm/vmm_stat.c index ae60979..ae156ee 100644 --- a/sys/amd64/vmm/vmm_stat.c +++ b/sys/amd64/vmm/vmm_stat.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <sys/smp.h> #include <machine/vmm.h> +#include "vmm_util.h" #include "vmm_stat.h" static int vstnum; @@ -52,6 +53,12 @@ vmm_stat_init(void *arg) if (vst->desc == NULL) return; + if (vst->scope == VMM_STAT_SCOPE_INTEL && !vmm_is_intel()) + return; + + if (vst->scope == VMM_STAT_SCOPE_AMD && !vmm_is_amd()) + return; + if (vstnum >= MAX_VMM_STAT_TYPES) { printf("Cannot accomodate vmm stat type \"%s\"!\n", vst->desc); return; @@ -102,3 +109,9 @@ vmm_stat_desc(int index) else return (NULL); } + +/* global statistics */ +VMM_STAT(VCPU_MIGRATIONS, "vcpu migration across host cpus"); +VMM_STAT(VMEXIT_COUNT, "total number of vm exits"); +VMM_STAT(VMEXIT_EXTINT, "vm exits due to external interrupt"); +VMM_STAT(VMEXIT_HLT, "number of times hlt was intercepted"); diff --git a/sys/amd64/vmm/vmm_stat.h b/sys/amd64/vmm/vmm_stat.h index 7c075a6..a1c0967 100644 --- a/sys/amd64/vmm/vmm_stat.h +++ b/sys/amd64/vmm/vmm_stat.h @@ -36,19 +36,36 @@ struct vm; #define MAX_VMM_STAT_TYPES 64 /* arbitrary */ +enum vmm_stat_scope { + VMM_STAT_SCOPE_ANY, + VMM_STAT_SCOPE_INTEL, /* Intel VMX specific statistic */ + VMM_STAT_SCOPE_AMD, /* AMD SVM specific statistic */ +}; + struct vmm_stat_type { - const char *desc; /* description of statistic */ int index; /* position in the stats buffer */ + const char *desc; /* description of statistic */ + enum vmm_stat_scope scope; }; void vmm_stat_init(void *arg); -#define VMM_STAT_DEFINE(type, desc) \ +#define VMM_STAT_DEFINE(type, desc, scope) \ struct vmm_stat_type type[1] = { \ - { desc, -1 } \ + { -1, desc, scope } \ }; \ SYSINIT(type##_stat, SI_SUB_KLD, SI_ORDER_ANY, vmm_stat_init, type) +#define VMM_STAT_DECLARE(type) \ + extern struct vmm_stat_type type[1] + +#define VMM_STAT(type, desc) \ + VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_ANY) +#define VMM_STAT_INTEL(type, desc) \ + VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_INTEL) +#define VMM_STAT_AMD(type, desc) \ + VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_AMD) + void *vmm_stat_alloc(void); void vmm_stat_free(void *vp); @@ -68,4 +85,8 @@ vmm_stat_incr(struct vm *vm, int vcpu, struct vmm_stat_type *vst, uint64_t x) #endif } +VMM_STAT_DECLARE(VCPU_MIGRATIONS); +VMM_STAT_DECLARE(VMEXIT_COUNT); +VMM_STAT_DECLARE(VMEXIT_EXTINT); +VMM_STAT_DECLARE(VMEXIT_HLT); #endif |