From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754816AbdKNKri (ORCPT ); Tue, 14 Nov 2017 05:47:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52197 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751802AbdKNKrb (ORCPT ); Tue, 14 Nov 2017 05:47:31 -0500 Subject: Re: [patch v2 3/8] KVM: x86: add Intel processor trace virtualization mode To: "Kang, Luwei" , "kvm@vger.kernel.org" Cc: "rkrcmar@redhat.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , Chao Peng References: <1509401117-15521-1-git-send-email-luwei.kang@intel.com> <1509401117-15521-4-git-send-email-luwei.kang@intel.com> <9838721f-ed64-cec8-f3dc-895c0bb7a681@redhat.com> <82D7661F83C1A047AF7DC287873BF1E167E37638@SHSMSX101.ccr.corp.intel.com> From: Paolo Bonzini Message-ID: Date: Tue, 14 Nov 2017 11:47:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <82D7661F83C1A047AF7DC287873BF1E167E37638@SHSMSX101.ccr.corp.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 14 Nov 2017 10:47:31 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/11/2017 08:31, Kang, Luwei wrote: >>> + if (!(_cpu_based_2nd_exec_control & SECONDARY_EXEC_PT_USE_GPA) || >>> + !(_vmexit_control & VM_EXIT_CLEAR_IA32_RTIT_CTL) || >>> + !(_vmentry_control & VM_ENTRY_LOAD_IA32_RTIT_CTL)) { >>> + _cpu_based_2nd_exec_control &= ~SECONDARY_EXEC_PT_USE_GPA; >> >> Also, you are not checking anywhere if the SUPPRESS_PIP controls are available. This is probably the best place. > > SUPPRESS_PIP(should be "CONCEAL", will fix it.) is use for control of processor trace packet. > I think we should clear it when in SYSTEM mode (For example, PIPs are > generated on VM exit, with NonRoot=0. On VM exit to SMM, VMCS packets > are additionally generated). Why need check this here? I agree. But if SUPPRESS_PIP/CONCEAL is not available, you cannot enable HOST_GUEST mode I think? >> >>> + _vmexit_control &= ~VM_EXIT_CLEAR_IA32_RTIT_CTL; >>> + _vmentry_control &= ~VM_ENTRY_LOAD_IA32_RTIT_CTL; >> >> These two are not needed; disabling SECONDARY_EXEC_PT_USE_GPA is enough. >> The tracing mode will revert to PT_SYSTEM, which does not use the load/clear RTIT_CTL controls. > > The status of *_RTIT_CTL should be same with SECONDARY_EXEC_PT_USE_GPA > or would cause VM-entry failed. > (architecture-instruction-set-extensions-programming-reference 5.2.3) Indeed: - disable "use GPA" here - hardware_setup notices !cpu_has_vmx_pt_use_gpa() and switches tracing mode to system - vmx_vcpu_setup (via vmx_vmentry_control and vmx_vmexit_control) turns off the IA32_RIT_CTL vmentry/vmexit controls (and also turns off SUPPRESS_PIP) - everybody is happy Paolo