mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-24 10:17:28 +00:00
profiling: fix the system freeze issue when running profiling tool
The msr load/restore during vmexit/vmentry is enabled in HV by default. The profiling has assumption that it's only user for this feature, which could overwrite of HV default setting. This fix combine the msr load list for vmexit when profiling. Tracked-On: #2422 Signed-off-by: Min Lim <min.yeol.lim@intel.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -112,19 +113,20 @@ static void profiling_enable_pmu(void)
|
||||
__func__, MSR_IA32_EXT_APIC_LVT_PMI, lvt_perf_ctr);
|
||||
|
||||
if (ss->guest_debugctl_value != 0U) {
|
||||
/* Set the VM Exit MSR Load in VMCS */
|
||||
/* Merge the msr vmexit loading list with HV */
|
||||
if (ss->vmexit_msr_cnt == 0) {
|
||||
ss->vmexit_msr_cnt = 1;
|
||||
ss->vmexit_msr_list[0].msr_idx
|
||||
= MSR_IA32_DEBUGCTL;
|
||||
ss->vmexit_msr_list[0].msr_data
|
||||
= ss->guest_debugctl_value &
|
||||
VALID_DEBUGCTL_BIT_MASK;
|
||||
struct acrn_vcpu *vcpu = get_ever_run_vcpu(get_cpu_id());
|
||||
|
||||
exec_vmwrite64(VMX_EXIT_MSR_LOAD_ADDR_FULL,
|
||||
hva2hpa(ss->vmexit_msr_list));
|
||||
exec_vmwrite(VMX_EXIT_MSR_LOAD_COUNT,
|
||||
(uint64_t)ss->vmexit_msr_cnt);
|
||||
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[MAX_HV_MSR_LIST_NUM].value = ss->guest_debugctl_value & VALID_DEBUGCTL_BIT_MASK;
|
||||
ss->vmexit_msr_cnt++;
|
||||
|
||||
exec_vmwrite64(VMX_EXIT_MSR_LOAD_ADDR_FULL, hva2hpa(ss->vmexit_msr_list));
|
||||
exec_vmwrite32(VMX_EXIT_MSR_LOAD_COUNT, ss->vmexit_msr_cnt);
|
||||
}
|
||||
|
||||
/* VMCS GUEST field */
|
||||
@@ -171,11 +173,12 @@ static void profiling_disable_pmu(void)
|
||||
__func__, get_cpu_id());
|
||||
|
||||
if (ss != NULL) {
|
||||
if (ss->vmexit_msr_cnt == 1) {
|
||||
/* Set the VM Exit MSR Load in VMCS */
|
||||
exec_vmwrite(VMX_EXIT_MSR_LOAD_COUNT, 0x0U);
|
||||
exec_vmwrite64(VMX_GUEST_IA32_DEBUGCTL_FULL,
|
||||
ss->saved_debugctl_value);
|
||||
if (ss->vmexit_msr_cnt != 0) {
|
||||
/* 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, hva2hpa(vcpu->arch.msr_area.host));
|
||||
exec_vmwrite32(VMX_EXIT_MSR_LOAD_COUNT, MAX_HV_MSR_LIST_NUM);
|
||||
|
||||
ss->vmexit_msr_cnt = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user