Skip to content

Commit b5a233d

Browse files
KaigeFulijinxia
authored andcommitted
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 <kaige.fu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent b086162 commit b5a233d

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

hypervisor/arch/x86/guest/vmcall.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,11 @@ int vmcall_vmexit_handler(struct vcpu *vcpu)
155155
ret = hcall_reset_ptdev_intr_info(vm, (uint16_t)param1, param2);
156156
break;
157157

158+
#ifdef HV_DEBUG
158159
case HC_SETUP_SBUF:
159160
ret = hcall_setup_sbuf(vm, param1);
160161
break;
162+
#endif
161163

162164
case HC_WORLD_SWITCH:
163165
ret = hcall_world_switch(vcpu);

hypervisor/common/hv_main.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ void vcpu_thread(struct vcpu *vcpu)
5959
continue;
6060
}
6161

62+
#ifdef HV_DEBUG
6263
vmexit_end = rdtsc();
6364
if (vmexit_begin != 0UL) {
6465
per_cpu(vmexit_time, vcpu->pcpu_id)[basic_exit_reason]
6566
+= (vmexit_end - vmexit_begin);
6667
}
68+
#endif
6769
TRACE_2L(TRACE_VM_ENTER, 0UL, 0UL);
6870

6971
/* Restore guest TSC_AUX */
@@ -79,7 +81,9 @@ void vcpu_thread(struct vcpu *vcpu)
7981
continue;
8082
}
8183

84+
#ifdef HV_DEBUG
8285
vmexit_begin = rdtsc();
86+
#endif
8387

8488
vcpu->arch_vcpu.nrexits++;
8589
/* Save guest TSC_AUX */
@@ -90,16 +94,18 @@ void vcpu_thread(struct vcpu *vcpu)
9094
CPU_IRQ_ENABLE();
9195
/* Dispatch handler */
9296
ret = vmexit_handler(vcpu);
97+
basic_exit_reason = vcpu->arch_vcpu.exit_reason & 0xFFFFU;
9398
if (ret < 0) {
9499
pr_fatal("dispatch VM exit handler failed for reason"
95-
" %d, ret = %d!",
96-
vcpu->arch_vcpu.exit_reason & 0xFFFFU, ret);
100+
" %d, ret = %d!", basic_exit_reason, ret);
97101
vcpu_inject_gp(vcpu, 0U);
98102
continue;
99103
}
100104

101-
basic_exit_reason = vcpu->arch_vcpu.exit_reason & 0xFFFFU;
105+
#ifdef HV_DEBUG
102106
per_cpu(vmexit_cnt, vcpu->pcpu_id)[basic_exit_reason]++;
107+
#endif
108+
103109
TRACE_2L(TRACE_VM_EXIT, basic_exit_reason, vcpu_get_rip(vcpu));
104110
} while (1);
105111
}

hypervisor/common/hypercall.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ hcall_reset_ptdev_intr_info(struct vm *vm, uint16_t vmid, uint64_t param)
788788
return ret;
789789
}
790790

791+
#ifdef HV_DEBUG
791792
int32_t hcall_setup_sbuf(struct vm *vm, uint64_t param)
792793
{
793794
struct sbuf_setup_param ssp;
@@ -808,6 +809,12 @@ int32_t hcall_setup_sbuf(struct vm *vm, uint64_t param)
808809

809810
return sbuf_share_setup(ssp.pcpu_id, ssp.sbuf_id, hva);
810811
}
812+
#else
813+
int32_t hcall_setup_sbuf(__unused struct vm *vm, __unused uint64_t param)
814+
{
815+
return -ENODEV;
816+
}
817+
#endif
811818

812819
int32_t hcall_get_cpu_pm_state(struct vm *vm, uint64_t cmd, uint64_t param)
813820
{

hypervisor/include/arch/x86/per_cpu.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
#include "arch/x86/guest/instr_emul.h"
2020

2121
struct per_cpu_region {
22+
#ifdef HV_DEBUG
2223
uint64_t *sbuf[ACRN_SBUF_ID_MAX];
23-
uint64_t irq_count[NR_IRQS];
2424
uint64_t vmexit_cnt[64];
2525
uint64_t vmexit_time[64];
26+
#endif
27+
uint64_t irq_count[NR_IRQS];
2628
uint64_t softirq_pending;
2729
uint64_t spurious;
2830
uint64_t vmxon_region_pa;

0 commit comments

Comments
 (0)