Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4809566ybg; Tue, 29 Oct 2019 12:43:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSfLt23OAL3gCcm+mxYETDqJFmg7AUpQY9Z97eIUzP2RaQsc/PZpGoxBvB8zqG19en63/f X-Received: by 2002:a17:906:6942:: with SMTP id c2mr4988493ejs.152.1572378219785; Tue, 29 Oct 2019 12:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572378219; cv=none; d=google.com; s=arc-20160816; b=O0Cw4WRM+sRZr8w9fF/vUJ1ppyu7r7YXjUCdcwppil1CWSUOYIKNH/3IF5vo2S1swx baGpNGMoM55Kdhufgv9B83+nU27eRjAmPrg8x5gCzX8BT/6dTzamFFCneOF3ClZ/MxGV 7aYnxZCqO59AwoQIeUZBcHNa1K1EjNySJll984z5mYetFui54hhUI4iDKyaTkRK0i6eV Wj8bOvG0tGGQAbBzd0YVW/NDi4WLmz+jzVTaeRETtRamCvdfmE19VfiHLVq4ISWMJQjE lxYGt0/IAH4NLBJ2fawMVCPgercU+80cazUwQm3mgAemH7MIteyqlHvIa0lXTRgr20Pm BcSw== 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:dkim-signature; bh=yPYBOVbzLkddXxQyoPdM/cinJsJOnw5vh/XAFVlfDHM=; b=GmaequU/MYpYhiiRXIP3cHcL8La/tBtdIwcZJltRs6tP88whAhcHlUB7bEVZ231Jyo xxMp1YJRH6XWlT2HZo1WQ1iFK8UDCPB8Akml1FWNf02eFM9sEn5apQraoPyhKI4rd9L7 dd0+af14KbbfYHOmrnq4ddKD6vCWt/xogR+OWUnR7rNwm+j5fvjM+5UsC5PPfF6/uWPe XYOxFKUwJ2F6m7keGkWRI8NmApq7wSa22vwHCF4SBjJ7B0Ty6C2K0rgRuKbYJcyvBcLK YpMu64F/PfDLoUq1bg4Eu0r31IZCXXP6jj7/y8qj2l5SiUCXvfMOrEnMSmESkl4opo0o xwPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="L9o/9d7l"; 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 x18si8980543ejo.78.2019.10.29.12.43.16; Tue, 29 Oct 2019 12:43:39 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="L9o/9d7l"; 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 S2389763AbfJ2PDJ (ORCPT + 99 others); Tue, 29 Oct 2019 11:03:09 -0400 Received: from merlin.infradead.org ([205.233.59.134]:41228 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbfJ2PDJ (ORCPT ); Tue, 29 Oct 2019 11:03:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yPYBOVbzLkddXxQyoPdM/cinJsJOnw5vh/XAFVlfDHM=; b=L9o/9d7ljXJbX9mcF5Ru9ZBZG g1r7VSnXDcAzdDvKHTB52IikrHsdoE/BddnxtMhK3toC53ejzx2xN3NG+fh6u3i3FcZ2DANbUw43y QYFFEPqehro/BHuF3J0K9kkb5H5qDGqER81BxxXJe33XHIpcOpNaGHCayDIAmxSVr9jAYbo/BNMuU emAvJakMUB+zqjrv1volXvTz3iDeYBD8nWocPZ0poGWUHhNFeO74ZMXU2L3u1xjP36Cw5NW627TSN IUVGywLVQJC5uL85TI9/7bzjymznmI46x6v1Sz2DAGIuQ7YDS3sBsvkyU2xMRQLblEKc4K67gxxS8 s6j+HBRvg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iPT1B-00052p-K7; Tue, 29 Oct 2019 15:02:45 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 54DE4300E4D; Tue, 29 Oct 2019 16:01:42 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1C7AE2B43836D; Tue, 29 Oct 2019 16:02:43 +0100 (CET) Date: Tue, 29 Oct 2019 16:02:43 +0100 From: Peter Zijlstra To: Luwei Kang Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, ak@linux.intel.com, thomas.lendacky@amd.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org Subject: Re: [PATCH v1 2/8] KVM: x86: PEBS output to Intel PT MSRs emulation Message-ID: <20191029150243.GM4097@hirez.programming.kicks-ass.net> References: <1572217877-26484-1-git-send-email-luwei.kang@intel.com> <1572217877-26484-3-git-send-email-luwei.kang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1572217877-26484-3-git-send-email-luwei.kang@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 27, 2019 at 07:11:11PM -0400, Luwei Kang wrote: > Intel new hardware introduces a mechanism to direct PEBS records > output into the Intel PT buffer that can be used for enabling PEBS > in KVM guest. This patch implements the registers read and write > emulation when PEBS is supported in KVM guest. > > KMM needs to reprogram the counters when the value of these MSRs > be changed that to make sure it can take effect in hardware. > > Signed-off-by: Luwei Kang > --- > arch/x86/include/asm/kvm_host.h | 4 +++ > arch/x86/include/asm/msr-index.h | 6 ++++ > arch/x86/kvm/vmx/capabilities.h | 15 ++++++++++ > arch/x86/kvm/vmx/pmu_intel.c | 63 ++++++++++++++++++++++++++++++++++++++-- > 4 files changed, 86 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h > index 20ce682..d22f8d9 100644 > --- a/arch/x86/include/asm/msr-index.h > +++ b/arch/x86/include/asm/msr-index.h > @@ -131,9 +131,13 @@ > #define LBR_INFO_ABORT BIT_ULL(61) > #define LBR_INFO_CYCLES 0xffff > > +#define MSR_IA32_PEBS_PMI_AFTER_REC BIT_ULL(60) > +#define MSR_IA32_PEBS_OUTPUT_PT BIT_ULL(61) > +#define MSR_IA32_PEBS_OUTPUT_MASK (3ULL << 61) > #define MSR_IA32_PEBS_ENABLE 0x000003f1 > #define MSR_PEBS_DATA_CFG 0x000003f2 > #define MSR_IA32_DS_AREA 0x00000600 > +#define MSR_IA32_PERF_CAP_PEBS_OUTPUT_PT BIT_ULL(16) > #define MSR_IA32_PERF_CAPABILITIES 0x00000345 > #define MSR_PEBS_LD_LAT_THRESHOLD 0x000003f6 > > @@ -665,6 +669,8 @@ > #define MSR_IA32_MISC_ENABLE_FERR (1ULL << MSR_IA32_MISC_ENABLE_FERR_BIT) > #define MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX_BIT 10 > #define MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX (1ULL << MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX_BIT) > +#define MSR_IA32_MISC_ENABLE_PEBS_BIT 12 > +#define MSR_IA32_MISC_ENABLE_PEBS (1ULL << MSR_IA32_MISC_ENABLE_PEBS_BIT) > #define MSR_IA32_MISC_ENABLE_TM2_BIT 13 > #define MSR_IA32_MISC_ENABLE_TM2 (1ULL << MSR_IA32_MISC_ENABLE_TM2_BIT) > #define MSR_IA32_MISC_ENABLE_ADJ_PREF_DISABLE_BIT 19 Some of these already exist but are local to perf. Don't blindly introduce more without unifying.