From b5a233da9fa0c9c8170bf287ef2758108d15ad40 Mon Sep 17 00:00:00 2001 From: Kaige Fu Date: Mon, 13 Aug 2018 13:20:24 +0800 Subject: [PATCH] HV: Enclose debug specific code with #ifdef HV_DEBUG Thare some debug specific code which don't run on release version, such as vmexit_time, vmexit_cnt, sbuf related codes, etc... This patch encloses the codes with #ifdef HV_DEBUG. Signed-off-by: Kaige Fu Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/vmcall.c | 2 ++ hypervisor/common/hv_main.c | 12 +++++++++--- hypervisor/common/hypercall.c | 7 +++++++ hypervisor/include/arch/x86/per_cpu.h | 4 +++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/hypervisor/arch/x86/guest/vmcall.c b/hypervisor/arch/x86/guest/vmcall.c index 12d8b2be7..e0e4fa56f 100644 --- a/hypervisor/arch/x86/guest/vmcall.c +++ b/hypervisor/arch/x86/guest/vmcall.c @@ -155,9 +155,11 @@ int vmcall_vmexit_handler(struct vcpu *vcpu) ret = hcall_reset_ptdev_intr_info(vm, (uint16_t)param1, param2); break; +#ifdef HV_DEBUG case HC_SETUP_SBUF: ret = hcall_setup_sbuf(vm, param1); break; +#endif case HC_WORLD_SWITCH: ret = hcall_world_switch(vcpu); diff --git a/hypervisor/common/hv_main.c b/hypervisor/common/hv_main.c index 15f1d9d05..e3657f9f8 100644 --- a/hypervisor/common/hv_main.c +++ b/hypervisor/common/hv_main.c @@ -59,11 +59,13 @@ void vcpu_thread(struct vcpu *vcpu) continue; } +#ifdef HV_DEBUG vmexit_end = rdtsc(); if (vmexit_begin != 0UL) { per_cpu(vmexit_time, vcpu->pcpu_id)[basic_exit_reason] += (vmexit_end - vmexit_begin); } +#endif TRACE_2L(TRACE_VM_ENTER, 0UL, 0UL); /* Restore guest TSC_AUX */ @@ -79,7 +81,9 @@ void vcpu_thread(struct vcpu *vcpu) continue; } +#ifdef HV_DEBUG vmexit_begin = rdtsc(); +#endif vcpu->arch_vcpu.nrexits++; /* Save guest TSC_AUX */ @@ -90,16 +94,18 @@ void vcpu_thread(struct vcpu *vcpu) CPU_IRQ_ENABLE(); /* Dispatch handler */ ret = vmexit_handler(vcpu); + basic_exit_reason = vcpu->arch_vcpu.exit_reason & 0xFFFFU; if (ret < 0) { pr_fatal("dispatch VM exit handler failed for reason" - " %d, ret = %d!", - vcpu->arch_vcpu.exit_reason & 0xFFFFU, ret); + " %d, ret = %d!", basic_exit_reason, ret); vcpu_inject_gp(vcpu, 0U); continue; } - basic_exit_reason = vcpu->arch_vcpu.exit_reason & 0xFFFFU; +#ifdef HV_DEBUG per_cpu(vmexit_cnt, vcpu->pcpu_id)[basic_exit_reason]++; +#endif + TRACE_2L(TRACE_VM_EXIT, basic_exit_reason, vcpu_get_rip(vcpu)); } while (1); } diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index fd4bc2992..35e0d90ac 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -788,6 +788,7 @@ hcall_reset_ptdev_intr_info(struct vm *vm, uint16_t vmid, uint64_t param) return ret; } +#ifdef HV_DEBUG int32_t hcall_setup_sbuf(struct vm *vm, uint64_t param) { struct sbuf_setup_param ssp; @@ -808,6 +809,12 @@ int32_t hcall_setup_sbuf(struct vm *vm, uint64_t param) return sbuf_share_setup(ssp.pcpu_id, ssp.sbuf_id, hva); } +#else +int32_t hcall_setup_sbuf(__unused struct vm *vm, __unused uint64_t param) +{ + return -ENODEV; +} +#endif int32_t hcall_get_cpu_pm_state(struct vm *vm, uint64_t cmd, uint64_t param) { diff --git a/hypervisor/include/arch/x86/per_cpu.h b/hypervisor/include/arch/x86/per_cpu.h index 4076e27a0..758f9c250 100644 --- a/hypervisor/include/arch/x86/per_cpu.h +++ b/hypervisor/include/arch/x86/per_cpu.h @@ -19,10 +19,12 @@ #include "arch/x86/guest/instr_emul.h" struct per_cpu_region { +#ifdef HV_DEBUG uint64_t *sbuf[ACRN_SBUF_ID_MAX]; - uint64_t irq_count[NR_IRQS]; uint64_t vmexit_cnt[64]; uint64_t vmexit_time[64]; +#endif + uint64_t irq_count[NR_IRQS]; uint64_t softirq_pending; uint64_t spurious; uint64_t vmxon_region_pa;