Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-31 Thread Paolo Bonzini
On 31/10/2018 15:21, Alexander Shishkin wrote: > Paolo Bonzini writes: > >> On 31/10/2018 12:38, Alexander Shishkin wrote: There is no standard way to tell the guest that the host overrode its choice to use PT. However, the host will get a PGD/PGE packet around vmentry and vmexit,

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-31 Thread Alexander Shishkin
Paolo Bonzini writes: > On 31/10/2018 12:38, Alexander Shishkin wrote: >>> There is no standard way to tell the guest that the host overrode its >>> choice to use PT. However, the host will get a PGD/PGE packet around >>> vmentry and vmexit, so there _will_ be an indication that the guest >>> ow

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-31 Thread Paolo Bonzini
On 31/10/2018 12:38, Alexander Shishkin wrote: >> There is no standard way to tell the guest that the host overrode its >> choice to use PT. However, the host will get a PGD/PGE packet around >> vmentry and vmexit, so there _will_ be an indication that the guest >> owned the MSRs for that period o

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-31 Thread Alexander Shishkin
Paolo Bonzini writes: > On 30/10/2018 11:00, Thomas Gleixner wrote: >> So at least we need a way for perf on the host to programmatically detect, >> that 'guest traces itself' is enabled, so it can inject that information >> into the host data and post processing can tell that. W/o something like

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-31 Thread Alexander Shishkin
Paolo Bonzini writes: > On 30/10/2018 12:26, Alexander Shishkin wrote: >> There is a control in the perf event attribute that enables tracing the >> guest. If this control is enabled, the kvm needs to stay away from any >> PT related MSRs. > > This cannot happen once the guest has been told it ca

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-31 Thread Paolo Bonzini
On 30/10/2018 12:26, Alexander Shishkin wrote: >>> affects directly whether the tracing CPUID leaf can be added to the >>> guest. Therefore it's not perf that can decide whether to turn it on; >>> KVM must know it when /dev/kvm is opened, which is why it is a module >>> parameter. > > There is a

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-31 Thread Paolo Bonzini
On 30/10/2018 11:00, Thomas Gleixner wrote: > On Mon, 29 Oct 2018, Paolo Bonzini wrote: >> On 24/10/2018 12:13, Alexander Shishkin wrote: >>> Luwei Kang writes: + /* + * Set guest state of MSR_IA32_RTIT_CTL MSR (PT will be disabled + * on VM entry when it has been disabled in g

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-30 Thread Alexander Shishkin
Paolo Bonzini writes: >> If you "have to enable or disable anything" it means you have to >> override the default. But the default in this patches is "no change >> compared to before the patches", leaving tracing of both host and guest >> entirely to the host, so I don't understand your remark.

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-30 Thread Thomas Gleixner
On Mon, 29 Oct 2018, Paolo Bonzini wrote: > On 24/10/2018 12:13, Alexander Shishkin wrote: > > Luwei Kang writes: > >> + /* > >> + * Set guest state of MSR_IA32_RTIT_CTL MSR (PT will be disabled > >> + * on VM entry when it has been disabled in guest before). > >> + */ > >> + vmcs_write64(

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-29 Thread Paolo Bonzini
On 24/10/2018 12:13, Alexander Shishkin wrote: > Luwei Kang writes: > >> +static void pt_guest_enter(struct vcpu_vmx *vmx) >> +{ >> +if (pt_mode == PT_MODE_SYSTEM) >> +return; >> + >> +/* Save host state before VM entry */ >> +rdmsrl(MSR_IA32_RTIT_CTL, vmx->pt_desc.host.ct

RE: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-24 Thread Kang, Luwei
> > +static void pt_guest_enter(struct vcpu_vmx *vmx) { > > + if (pt_mode == PT_MODE_SYSTEM) > > + return; > > + > > + /* Save host state before VM entry */ > > + rdmsrl(MSR_IA32_RTIT_CTL, vmx->pt_desc.host.ctl); > > + > > + /* > > +* Set guest state of MSR_IA32_RTIT_CTL MSR (

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-24 Thread Alexander Shishkin
Luwei Kang writes: > +static void pt_guest_enter(struct vcpu_vmx *vmx) > +{ > + if (pt_mode == PT_MODE_SYSTEM) > + return; > + > + /* Save host state before VM entry */ > + rdmsrl(MSR_IA32_RTIT_CTL, vmx->pt_desc.host.ctl); > + > + /* > + * Set guest state of MSR_I