Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13820096pxu; Mon, 4 Jan 2021 05:29:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrMA6nI6LZ+Q9JJazk3ZgR4cxzolkEbQrqTQnD2YWp81E24WGDsS89wwkx967y6IYFMXag X-Received: by 2002:a17:907:105e:: with SMTP id oy30mr66251078ejb.495.1609766980935; Mon, 04 Jan 2021 05:29:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609766980; cv=none; d=google.com; s=arc-20160816; b=VSdRjYp4yyKdIs1FlG4bOQHIRfeF5Jx6C6CQK/b5mxURO8oQ/GN3I6ogDbc2HXMbdZ DbKPEwJpmIOgu1/L+1ERjjN4oXvSmZGtR76y0RPzu7JZbr2HnS0GkfSRyfHDZ5f1njm/ olv5GMrgth1txGu+VxDDVO+E/xjQtEcufbv+SgHznNaWOflKIIO2ji0c1a0NHipJjhOd TAbTjLOC04PIQnWfducHaSfA6Yc+g37F+mJY9TKzjgyi6TKPaeunqz/9QLKz4Zqd2H31 VRB6IBIEW8rn6tIA5e07jjBBXxIXtgBUJdkRzsIJQl9M36Br0ZxQjBfC54qgMbhQT3DP RrAg== 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=KL66o+/0WfiLatwTnELs8u86BU5+MoaHCvc6JFKdfcw=; b=XbseWcEGXbu/e1qLwnuoI3rS1A07QXMQMBVpIsLkuwa7TyU3THEZKu1mP+b9Xdxedr 1gbkp/ZAyrLfrJWFtrY8BQxOsQt6L3azMMKACeJF+pop8juXYXwGny/kimjqRcEa98mS i9VCFSifO6iCYuKbdwOhr3mIQNYcXcEbGmq5aBMUoe3bRH9+wIXxeoZfIpeGvaGANzd2 9pBfZ/PWUpTDBuY5emW4tcSy3UFSaJHEriclEcP6j/SfLUq6Iq78s0g6AR8ZULe1d1lF roeSh7BIFpIV0UMDNY3E6FfO/ohwBSKa3p0r+LAyyp2U4J9WP03JlwlDtfuAIPv90Ebs Bu2g== 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 e26si27319932ejc.540.2021.01.04.05.29.17; Mon, 04 Jan 2021 05:29:40 -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 S1727024AbhADN1z (ORCPT + 99 others); Mon, 4 Jan 2021 08:27:55 -0500 Received: from mga07.intel.com ([134.134.136.100]:23250 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726949AbhADN1y (ORCPT ); Mon, 4 Jan 2021 08:27:54 -0500 IronPort-SDR: jWUFtDG4FwP8M8pKqdtNRmQUp6McTy6H1iVlKgpmmD4dMiVbGIkZn9qSYdoQU35490zVnHlb8G 2w6jubUVfcxA== X-IronPort-AV: E=McAfee;i="6000,8403,9853"; a="241034378" X-IronPort-AV: E=Sophos;i="5.78,474,1599548400"; d="scan'208";a="241034378" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2021 05:22:36 -0800 IronPort-SDR: l19BMzjNTlN/BTyti0zTilEiSu6YZB6XiS2NF5WSDfdpqI0QLhhLY7UNObLXxYhhjd1YDNF3oQ eeqLJkcwTikw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,474,1599548400"; d="scan'208";a="461944630" Received: from clx-ap-likexu.sh.intel.com ([10.239.48.108]) by fmsmga001.fm.intel.com with ESMTP; 04 Jan 2021 05:22:33 -0800 From: Like Xu To: Peter Zijlstra , Paolo Bonzini , eranian@google.com, kvm@vger.kernel.org Cc: Ingo Molnar , Sean Christopherson , Thomas Gleixner , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Andi Kleen , Kan Liang , wei.w.wang@intel.com, luwei.kang@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 11/17] KVM: x86/pmu: Adjust precise_ip to emulate Ice Lake guest PDIR counter Date: Mon, 4 Jan 2021 21:15:36 +0800 Message-Id: <20210104131542.495413-12-like.xu@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210104131542.495413-1-like.xu@linux.intel.com> References: <20210104131542.495413-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 2e81c50323e2..67c20ab81991 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c @@ -144,6 +144,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.29.2