Received: by 10.192.165.148 with SMTP id m20csp1764746imm; Thu, 3 May 2018 05:11:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqzKVxRtdpAkNdLLSaFkmi8xQNEoaJUKWm8fj2FiMbMlq/l0k6QYcaZKQnzEBcZ47/ppDZd X-Received: by 2002:a65:4502:: with SMTP id n2-v6mr18511965pgq.95.1525349474699; Thu, 03 May 2018 05:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525349474; cv=none; d=google.com; s=arc-20160816; b=pBtpr7Bq8Yvakui3bfmnT7wQY9vkldSuVHys99DNj0oN7d9Os8IUMTtijJIfIOu8xX wfoYe7AXshOL/xMgsPn0jywAN294VlwgkKfKUcsy+JMNwXd/zBLXknn/aqXkLKvlvWby Tj3swhF01T0SfZVXSKezvo+tT8MI3LQMWCwNSTHw8NlfNlKPeSHDAqakmzGHqsKmYLBu Gi8n8TGpx1rcaRPqnoSn9AJPhzRee/q8CMcDPxI8NXodA5LdeTHr7EAwLyIhHbMmcdGp gTkFP0iOXQXARIg0gyUlSrIBBkmC2yR6PZ3EMpAeGTCvo1Lrv6BlrEBoQ3qe8m5FNw57 gxCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=G9P1phmJzJNEbUCj2pQtaQ18DgbqQB0DCYCW2OUefhI=; b=c12IRnWy0YSVgWpb8MsZuf2x9nLC1dOFQWM6O/nhhVTQAtlADHxqCrkcHRn2gCSCgC T4Ha4Ux702h+gQY21+fVXxPfNK5gARXUeKMHjqQ2s/Gdl8QB76DwqVWtVSQv4qRwSpej 8OnbTMf/+eNobM7RKofSF33R6tehIjjn156UParqsry3Y+FpHYwrw/QHfM8q6vR29WgR ZcOTyZKWxIvp3bfPprY1y1Sj9Up8qnwXookdSZt31WnmZLIidswe2HE80D9SLRsRu+6e TztLedJeA5AXJKdnU/InxFU8P+MnSlQib1CNPDNFCnPuY5H/wrIoqpkZmVCswCoObGla g2JQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c129si13305088pfc.367.2018.05.03.05.10.59; Thu, 03 May 2018 05:11:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751453AbeECMJi (ORCPT + 99 others); Thu, 3 May 2018 08:09:38 -0400 Received: from mga04.intel.com ([192.55.52.120]:56112 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751121AbeECMJe (ORCPT ); Thu, 3 May 2018 08:09:34 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 05:09:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,358,1520924400"; d="scan'208";a="225490995" Received: from um.fi.intel.com (HELO um) ([10.237.72.212]) by fmsmga006.fm.intel.com with ESMTP; 03 May 2018 05:09:30 -0700 Received: from ash by um with local (Exim 4.90_1) (envelope-from ) id 1fED3B-0007Te-35; Thu, 03 May 2018 15:09:29 +0300 Date: Thu, 3 May 2018 15:09:28 +0300 From: Alexander Shishkin To: Paolo Bonzini Cc: Alexander Shishkin , Luwei Kang , kvm@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, rkrcmar@redhat.com, linux-kernel@vger.kernel.org, joro@8bytes.org, peterz@infradead.org, chao.p.peng@linux.intel.com Subject: Re: [PATCH v7 06/13] KVM: x86: Add Intel Processor Trace virtualization mode Message-ID: <20180503120928.gsqwreqnu5sllzw2@um.fi.intel.com> References: <1525349323-9938-1-git-send-email-luwei.kang@intel.com> <1525349323-9938-7-git-send-email-luwei.kang@intel.com> <20180503113223.x2ykby6wglppgdwf@um.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 03, 2018 at 01:52:16PM +0200, Paolo Bonzini wrote: > On 03/05/2018 13:32, Alexander Shishkin wrote: > >> +static inline bool cpu_has_vmx_pt_use_gpa(void) > >> +{ > >> + return vmcs_config.cpu_based_2nd_exec_ctrl & SECONDARY_EXEC_PT_USE_GPA; > >> +} > > > > I can deduce the meaning of the previous one, but not this one, and there's > > no explanation. > > Within KVM, GPA always means guest physical address. I see, thanks. > >> + if (pt_mode == PT_MODE_SYSTEM) > >> + vmexit_control &= ~(VM_EXIT_CLEAR_IA32_RTIT_CTL | > >> + VM_EXIT_PT_CONCEAL_PIP); > > > > Ok, so what we really want to know is: is there an encompassing PT > > event on this cpu when we go into VMLAUNCH/VMRESTORE, right? > > We can find this out from the pt_ctx and avoid the pt_mode entirely. > > IOW, instead of having the 3 modes that you describe at the top, you > > can use something like the following: > > > > 1. Do we have an event in pt_ctx? > > * No -> Set up the context for VMX. > > * Yes -> 2. Is attr.exclude_guest set? > > * No -> Guest trace goes to the host's buffer, do nothing. > > * Yes -> Set up/switch the context for VMX. > > Can you explain this more clearly? Let's see; in the intel_pt driver we have a per-cpu PT "context", from which we can tell if there is a host event that wants to trace the guest. This should provide enough information to make a decision whether we want to context switch PT MSRs or not on the spot, instead of having a module parameter. Regards, -- Alex