From ff48cb07785bbc5891f56c1b18fd28eb200f9abb Mon Sep 17 00:00:00 2001 From: Min Lim Date: Fri, 1 Feb 2019 12:52:11 -0800 Subject: [PATCH] profiling: simplify the handling of vmexit loading list The patch simplifies the way to merge the msr vmexit loading list with HV, which was already merged to master. Tracked-On: #2422 Signed-off-by: Min Lim --- hypervisor/debug/profiling.c | 23 +++++++++---------- hypervisor/include/debug/profiling_internal.h | 6 ++--- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/hypervisor/debug/profiling.c b/hypervisor/debug/profiling.c index 7a7fb1941..f9c6419b8 100644 --- a/hypervisor/debug/profiling.c +++ b/hypervisor/debug/profiling.c @@ -90,6 +90,7 @@ static void profiling_enable_pmu(void) uint32_t lvt_perf_ctr; uint32_t i; uint32_t group_id; + uint32_t size; struct profiling_msr_op *msrop = NULL; struct sep_state *ss = &get_cpu_var(profiling_info.sep_state); @@ -116,22 +117,21 @@ static void profiling_enable_pmu(void) if (ss->vmexit_msr_cnt == 0) { struct acrn_vcpu *vcpu = get_ever_run_vcpu(get_cpu_id()); - ss->vmexit_msr_cnt = 1 + MSR_AREA_COUNT; - ss->vmexit_msr_list[0].msr_num + size = sizeof(struct msr_store_entry) * MAX_HV_MSR_LIST_NUM; + (void)memcpy_s(ss->vmexit_msr_list, size, vcpu->arch.msr_area.host, size); + ss->vmexit_msr_cnt = MAX_HV_MSR_LIST_NUM; + + ss->vmexit_msr_list[MAX_HV_MSR_LIST_NUM].msr_num = MSR_IA32_DEBUGCTL; - ss->vmexit_msr_list[0].value + ss->vmexit_msr_list[MAX_HV_MSR_LIST_NUM].value = ss->guest_debugctl_value & VALID_DEBUGCTL_BIT_MASK; - - for (i = 0; i < MSR_AREA_COUNT; i++) { - ss->vmexit_msr_list[i + 1].msr_num = vcpu->arch.msr_area.host[i].msr_num; - ss->vmexit_msr_list[i + 1].value = vcpu->arch.msr_area.host[i].value; - } + ss->vmexit_msr_cnt++; exec_vmwrite64(VMX_EXIT_MSR_LOAD_ADDR_FULL, hva2hpa(ss->vmexit_msr_list)); exec_vmwrite32(VMX_EXIT_MSR_LOAD_COUNT, - (uint64_t)ss->vmexit_msr_cnt); + ss->vmexit_msr_cnt); } /* VMCS GUEST field */ @@ -182,9 +182,8 @@ static void profiling_disable_pmu(void) /* Restore the msr exit loading list of HV */ struct acrn_vcpu *vcpu = get_ever_run_vcpu(get_cpu_id()); - exec_vmwrite64(VMX_EXIT_MSR_LOAD_ADDR_FULL, (uint64_t)vcpu->arch.msr_area.host); - exec_vmwrite32(VMX_EXIT_MSR_LOAD_COUNT, MSR_AREA_COUNT); - + exec_vmwrite64(VMX_EXIT_MSR_LOAD_ADDR_FULL, hva2hpa(vcpu->arch.msr_area.host)); + exec_vmwrite32(VMX_EXIT_MSR_LOAD_COUNT, MAX_HV_MSR_LIST_NUM); ss->vmexit_msr_cnt = 0; } diff --git a/hypervisor/include/debug/profiling_internal.h b/hypervisor/include/debug/profiling_internal.h index 6feb651fe..557ddca20 100644 --- a/hypervisor/include/debug/profiling_internal.h +++ b/hypervisor/include/debug/profiling_internal.h @@ -12,7 +12,7 @@ #include #define MAX_MSR_LIST_NUM 15U -#define MAX_PROFILING_MSR_LIST_NUM (MAX_MSR_LIST_NUM) +#define MAX_PROFILING_MSR_STORE_NUM 1 #define MAX_HV_MSR_LIST_NUM (MSR_AREA_COUNT) #define MAX_GROUP_NUM 1U @@ -208,8 +208,8 @@ struct sep_state { uint32_t frozen_delayed; uint32_t nofrozen_pmi; - struct msr_store_entry vmexit_msr_list[MAX_PROFILING_MSR_LIST_NUM + MAX_HV_MSR_LIST_NUM]; - int32_t vmexit_msr_cnt; + struct msr_store_entry vmexit_msr_list[MAX_PROFILING_MSR_STORE_NUM + MAX_HV_MSR_LIST_NUM]; + uint32_t vmexit_msr_cnt; uint64_t guest_debugctl_value; uint64_t saved_debugctl_value; } __aligned(8);