Skip to content

Commit

Permalink
profiling: simplify the handling of vmexit loading list
Browse files Browse the repository at this point in the history
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 <min.yeol.lim@intel.com>
  • Loading branch information
mlim19 authored and wenlingz committed Feb 3, 2019
1 parent 135ed80 commit ff48cb0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
23 changes: 11 additions & 12 deletions hypervisor/debug/profiling.c
Expand Up @@ -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);

Expand All @@ -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 */
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions hypervisor/include/debug/profiling_internal.h
Expand Up @@ -12,7 +12,7 @@
#include <vcpu.h>

#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

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ff48cb0

Please sign in to comment.