Re: [PATCH v7 09/13] KVM: x86: Implement Intel Processor Trace context switch
From: Alexander Shishkin
Date: Fri May 04 2018 - 06:30:11 EST
On Thu, May 03, 2018 at 08:08:39PM +0800, Luwei Kang wrote:
> +static void pt_guest_enter(struct vcpu_vmx *vmx)
> +{
> + if (pt_mode == PT_MODE_HOST || pt_mode == PT_MODE_HOST_GUEST)
> + rdmsrl(MSR_IA32_RTIT_CTL, vmx->pt_desc.host.ctl);
> +
> + if (pt_mode == PT_MODE_HOST_GUEST &&
> + vmx->pt_desc.guest.ctl & RTIT_CTL_TRACEEN) {
> + wrmsrl(MSR_IA32_RTIT_CTL, 0);
> + pt_save_msr(&vmx->pt_desc.host, vmx->pt_desc.range_cnt);
> + pt_load_msr(&vmx->pt_desc.guest, vmx->pt_desc.range_cnt);
> + }
> +}
> +
> +static void pt_guest_exit(struct vcpu_vmx *vmx)
> +{
> + if (pt_mode == PT_MODE_HOST_GUEST &&
> + vmx->pt_desc.guest.ctl & RTIT_CTL_TRACEEN) {
> + pt_save_msr(&vmx->pt_desc.guest, vmx->pt_desc.range_cnt);
> + pt_load_msr(&vmx->pt_desc.host, vmx->pt_desc.range_cnt);
> + }
> +
> + if (pt_mode == PT_MODE_HOST || pt_mode == PT_MODE_HOST_GUEST)
> + wrmsrl(MSR_IA32_RTIT_CTL, vmx->pt_desc.host.ctl);
> +}
This means that a host PT event won't get the guest traces and won't get
any notification as to what'd happened or why. At the minimum we need to
send a PARTIAL AUX record at the pt_guest_enter(), when we turn the host
tracing off.
Regards,
--
Alex