Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2900616pxb; Sun, 8 Nov 2020 18:19:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2JjthQ5po+TEwhlnjm72r1hJy7h2Op3B85wm+j7705TGf8lBlVAY08wOCk/nkUTED/Woz X-Received: by 2002:a17:906:804:: with SMTP id e4mr12717283ejd.420.1604888389771; Sun, 08 Nov 2020 18:19:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604888389; cv=none; d=google.com; s=arc-20160816; b=cuC3yEOYUf8kzIXcclGRuRcsrgjv2XLA9QJSbjvRGDfkPTjEs7yDqhUpD1x7gOXsxy cVPLRXk88svbXbymLJE6P+498tVEKqC3pHnS9lcptca9/X/+9qVb8bagp6Yt60Wpbpem iBg7Z55r4oDAM9g9Q4l2dLtQjU7j93yb+HzFjHaIvf5EaLTaMe9278PF9qZ7lmJisFAI +AKh1cFSSJox6NSr245v4WMmBQdxzBJJM4qy8ZfwYV/Hren6noxvYKv3R08RwfM681FM xXvE3LohtkQ82pTH7dyH1v9muRlE1gX8lbvoqJP6MucvlIh5vb3rrC68Fwg4/1GETdR7 6e2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=bGKBaeM+78cDdAB5/kMNqdFAbPhRdCSB53S8ZrOto78=; b=TDXzt4FX4N4UKVHA408LQiX75ywvDJ21QkU1WXqgulVD0sTQ8QrOJTOXNBFTkbgnRs ZSE2HedAhXA3fQoEwe3svlsM/CD2FMdfJ15M3MNWkAVhDH7pv7qwSM2XHyFzb8fbNmWb p1pQlDqVx6M0nnKXfUAMYeTaH7ORHbkVHMAbNcDBRdSIEEV1un28cNvUSoaGm6SbJikt 2DN5HNgPuJqpcjc/bMLs8sLMACwsonJT2QMBPOP/P7NXlXm1IVGGuLJgi4idspTga/hi C+i4PKTJQ4hLWbT80XzEJlHpsDo+pxSJt1FrnERLQg57bGdNnGJdYPfDx+WF8E9nLNpF 6nJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk4si652808edb.429.2020.11.08.18.19.27; Sun, 08 Nov 2020 18:19:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729375AbgKICRe (ORCPT + 99 others); Sun, 8 Nov 2020 21:17:34 -0500 Received: from mga01.intel.com ([192.55.52.88]:64940 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729119AbgKICRd (ORCPT ); Sun, 8 Nov 2020 21:17:33 -0500 IronPort-SDR: B3vATKxX3FdziCFSTuGuNvQkrUgs6Dp6IkX9oRX6LGoZgzj9dAP+rUbK1N8w12pQQ3KGHSza0a PWlq+xOTWBmQ== X-IronPort-AV: E=McAfee;i="6000,8403,9799"; a="187684639" X-IronPort-AV: E=Sophos;i="5.77,462,1596524400"; d="scan'208";a="187684639" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2020 18:17:33 -0800 IronPort-SDR: 1DJa5aO5qgliI4MDOmZ6cu0/ZPi/NKaXmatoWKIKF3yBIsmuhYCH7HnobbRAihVJh35ZEjXU1h 7U8JpWF8QoOw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,462,1596524400"; d="scan'208";a="540646242" Received: from e5-2699-v4-likexu.sh.intel.com ([10.239.48.39]) by orsmga005.jf.intel.com with ESMTP; 08 Nov 2020 18:17:29 -0800 From: Like Xu To: Peter Zijlstra , Paolo Bonzini , kvm@vger.kernel.org Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Kan Liang , luwei.kang@intel.com, Thomas Gleixner , wei.w.wang@intel.com, Tony Luck , Stephane Eranian , Mark Gross , Srinivas Pandruvada , linux-kernel@vger.kernel.org Subject: [PATCH v2 11/17] KVM: x86/pmu: Adjust precise_ip to emulate Ice Lake guest PDIR counter Date: Mon, 9 Nov 2020 10:12:48 +0800 Message-Id: <20201109021254.79755-12-like.xu@linux.intel.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201109021254.79755-1-like.xu@linux.intel.com> References: <20201109021254.79755-1-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The PEBS-PDIR facility on Ice Lake server is supported on IA31_FIXED0 only. If the guest configures counter 32 and PEBS is enabled, the PEBS-PDIR facility is supposed to be used, in which case KVM adjusts attr.precise_ip to 3 and request host perf to assign the exactly requested counter or fail. The cpu model check is also required since some platforms may place the PEBS-PDIR facility in another counter index. Signed-off-by: Like Xu --- arch/x86/kvm/pmu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c index c6208234e007..f8aa4724d67b 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c @@ -143,6 +143,8 @@ static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type, * in the PEBS record is calibrated on the guest side. */ attr.precise_ip = 1; + if (x86_match_cpu(vmx_icl_pebs_cpu) && pmc->idx == 32) + attr.precise_ip = 3; } event = perf_event_create_kernel_counter(&attr, -1, current, -- 2.21.3