Re: [PATCH v3 9/9] KVM: x86: Implement Intel Processor Trace context switch

From: Paolo Bonzini
Date: Thu Nov 30 2017 - 07:27:13 EST


On 27/11/2017 21:24, Luwei Kang wrote:
> + if (pt_mode == PT_MODE_HOST_GUEST) {
> + u32 eax, ebx, ecx, edx;
> +
> + cpuid_count(0x14, 1, &eax, &ebx, &ecx, &edx);

Since it's used in many places, it's better if you cache CPUID[14,1].EAX.

Thanks,

Paolo

> + memset(&vmx->pt_desc, 0, sizeof(vmx->pt_desc));
> + vmx->pt_desc.addr_num = eax & 0x7;
> + /* Bit[6~0] are forced to 1, writes are ignored. */
> + vmx->pt_desc.guest.output_mask = 0x7F;
> + vmcs_write64(GUEST_IA32_RTIT_CTL, 0);
> + }