Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4275111pxj; Wed, 12 May 2021 01:48:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAiLwriOSORMIcBaNbNNM/BkdUT7EmE/sCrN5L0deDnHFoJMb+lgWEPPenmkc7wrb6fdCJ X-Received: by 2002:a05:6402:268f:: with SMTP id w15mr41063123edd.321.1620809307739; Wed, 12 May 2021 01:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620809307; cv=none; d=google.com; s=arc-20160816; b=DVS5nKM1oKsKq3U80MdF1jv4/AiBID60qbRrlwzTu9XQ88/XX4RSZrZuSYBsWp8Nlg k+74G7ZPVH4BHr++VZXfm5g3Ic04EVFO5HVy6AkyT0Y1YgkzHh3aQ8wnczu735b8JVgh Zvhk6OGvke8DVjMPXgPs2dV6lIZSIsgJsDepYXh3VZbHQE8bFwcFhuYEEYtsc++LLhaL Qc/fAeWCK2oUFUNYOu4l2ipWN4W7bidVrw7ZkE2InjqvpUcZ/fU7uKm2oCovvbqyO2vu nj9yawrmYskJiBwzRqEcqNOG85F4t05bf19US6XSR/zte/Cn/LMvdy2ojIvbpmzMWz8v Wc2Q== 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=axNkBpK8GACbft+i+7pNIeyRSP3aTZIvP57tGjiVpTA=; b=LNKi2dp2ssmdfmJtbzzsvmZAXhB9uID1GkNwANSLe4PQy7nk42Nv8pSV3xbAXnhRcN Czjujsl5SNlCnLn38YGUSjRRuHkXBN1cmxJGNI9Ajo5gubg6fIU9AiU4arCX1Gi+r0F+ MjKLngCvTRM3KImvL6y9NM+Caa3zRFY4h3cmvY3CS2IUCob1iP9m4+7x7Yi5qpaUj9RR 0Ai8wnXASqMuTuJUc4GkEvXE0YKxWTCP6lQjETe7UqkRmLBv51ARpWQJQSyYvhEoZxPV bM6cg+PsYvNaGDUKvm5cvBuzUTinyZmDDMogx/rWh+9OmpXExh8y2bvGpjcehOyZrJTY kihg== 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 m20si14248776edv.166.2021.05.12.01.48.03; Wed, 12 May 2021 01:48:27 -0700 (PDT) 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 S230387AbhELIrd (ORCPT + 99 others); Wed, 12 May 2021 04:47:33 -0400 Received: from mga17.intel.com ([192.55.52.151]:10038 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230498AbhELIq5 (ORCPT ); Wed, 12 May 2021 04:46:57 -0400 IronPort-SDR: SJfQ0DHc2GxqxaCGnpqoSYHE9pYkS/u3t5PBMEh5+Ep5weZot+zbDI1254xpM5RlqY8BCsXJsu lo8CxCEz0HZg== X-IronPort-AV: E=McAfee;i="6200,9189,9981"; a="179918887" X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="179918887" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2021 01:45:49 -0700 IronPort-SDR: H6o6VzF/Tuz6GSKhXx19UWOhNqXTidR80XhT9ufzH8IdO2tDOsbvOqxs6/FZJJWYokFcMhNt9e 9lVbj4V+hx5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="392636420" Received: from clx-ap-likexu.sh.intel.com ([10.239.48.108]) by orsmga006.jf.intel.com with ESMTP; 12 May 2021 01:45:45 -0700 From: Like Xu To: Paolo Bonzini , peterz@infradead.org Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , weijiang.yang@intel.com, eranian@google.com, wei.w.wang@intel.com, kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Like Xu , Alexander Shishkin , Andi Kleen Subject: [PATCH v3 5/5] KVM: x86/pmu: Expose PEBS-via-PT in the KVM supported capabilities Date: Wed, 12 May 2021 16:44:46 +0800 Message-Id: <20210512084446.342526-6-like.xu@linux.intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512084446.342526-1-like.xu@linux.intel.com> References: <20210512084446.342526-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 hypervisor userspace can dis/enable it via the MSR-based feature "MSR_IA32_PERF_CAPABILITIES [bit 16]". If guest also has basic PT support, it can output the PEBS records to the PT buffer. Cc: Alexander Shishkin Cc: Andi Kleen Signed-off-by: Like Xu --- arch/x86/kvm/vmx/capabilities.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vmx/capabilities.h index fd8c9822db9e..e04b50174dd5 100644 --- a/arch/x86/kvm/vmx/capabilities.h +++ b/arch/x86/kvm/vmx/capabilities.h @@ -398,8 +398,11 @@ static inline u64 vmx_get_perf_capabilities(void) perf_cap |= host_perf_cap & PMU_CAP_LBR_FMT; - if (vmx_pebs_supported()) + if (vmx_pebs_supported()) { perf_cap |= host_perf_cap & PERF_CAP_PEBS_MASK; + if (vmx_pt_mode_is_host_guest()) + perf_cap |= host_perf_cap & PERF_CAP_PEBS_OUTPUT_PT; + } return perf_cap; } -- 2.31.1