Re: [PATCH V7 11/18] KVM: x86/pmu: Add IA32_DS_AREA MSR emulation to support guest DS

Zhu, Lingshan
2021-07-08T08:52:50Z

On 7/2/2021 7:52 PM, Peter Zijlstra wrote:
> On Tue, Jun 22, 2021 at 05:42:59PM +0800, Zhu Lingshan wrote:
>> diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
>> index 190d8d98abf0..b336bcaad626 100644
>> --- a/arch/x86/events/intel/core.c
>> +++ b/arch/x86/events/intel/core.c
>> @@ -21,6 +21,7 @@
>> #include <asm/intel_pt.h>
>> #include <asm/apic.h>
>> #include <asm/cpu_device_id.h>
>> +#include <asm/kvm_host.h>
>>
>> #include "../perf_event.h"
>>
>> @@ -3915,6 +3916,7 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data)
>> {
>> struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
>> struct perf_guest_switch_msr *arr = cpuc->guest_switch_msrs;
>> + struct kvm_pmu *pmu = (struct kvm_pmu *)data;
>> u64 intel_ctrl = hybrid(cpuc->pmu, intel_ctrl);
>> u64 pebs_mask = cpuc->pebs_enabled & x86_pmu.pebs_capable;
>>
>> @@ -3945,9 +3947,15 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data)
>> return arr;
>> }
>>
>> - if (!x86_pmu.pebs_vmx)
>> + if (!pmu || !x86_pmu.pebs_vmx)
>> return arr;
>>
>> + arr[(*nr)++] = (struct perf_guest_switch_msr){
>> + .msr = MSR_IA32_DS_AREA,
>> + .host = (unsigned long)cpuc->ds,
>> + .guest = pmu->ds_area,
>> + };
>> +
>> arr[*nr] = (struct perf_guest_switch_msr){
>> .msr = MSR_IA32_PEBS_ENABLE,
>> .host = cpuc->pebs_enabled & ~cpuc->intel_ctrl_guest_mask,
> s/pmu/kvm_pmu/ or something. pmu is normally a struct pmu *, and having
> it be kvm_pmu here is super confusing.
will fix this in V8, Thanks!