Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1622850rwd; Thu, 25 May 2023 15:43:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Qgqhbfuwx5fcMqNBISXM08/K27DaO83LIOd80tjcvDOFhX1B+CDMriovIpHpyO9Ei8yuE X-Received: by 2002:a17:90b:1094:b0:255:3b09:6ef5 with SMTP id gj20-20020a17090b109400b002553b096ef5mr164792pjb.44.1685054583742; Thu, 25 May 2023 15:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685054583; cv=none; d=google.com; s=arc-20160816; b=k0LjMiowzZD9fYX3zPC3O9Z3jauxWqGhVPVhSalCVR7RXxuNHV8Cc33v/VWmgxLCul ePThGQjcEMuTEkjbcWKmzKR+YLdsLUThqDrRmPWk9isZ5uxCmbtjeoQQGfU6hMC9YYBk +M1NWYoI2+dK+6ASE3DAY0K5mtEWK85OkUyhtx1drC1bcLm8eAfGBgvGHwQZOrRArywZ EDZBZVSoIrF8wPPVpylRlj3joZOHf/fhaYKRnD+QjTo9fe2kz2KveFbqH2vTtSdL736c BSL2Gyyjy8iI5iEaWtLgUbZqr3oZ7sNTN3YBSmAEKxs0qcCU3Ru3DcRHdaDU9WihkpVX e5dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=Tpe07KW4MlBzxlGn7n37Z+ZqlMCf6ry7/JhPxHNLhGc=; b=B9P4GHfZhKi4MpCRzUZ+sO0YnCC9TOvWc216ro0prliKCYNRst9B9oKlszKQLzdOpv nCQVgiRuhz7wqQ8O8Fd3I5cCm+du/47D/4Spwz+LKRNGsvuJcGUaX8X6ULBpOZ1IrZFE DNmtGubeAKXQAO14Jxf2VmKqNqGpNXBg4MOtZNYOo3KlpD/s9x991O+lhTbwKG8YbffD 5kBaG1y8D6sh6cjTET0u14VA92BCHf8NuE81Gj6EaEKS1j3jCA2upgNaG5EavaUZtdLR QptKI0hIIRKYlh7DRFtsEvJ8/u77JZh17mUVXEHN/I3BA0sFR83sgMveWJpaLPsOP1mj PAXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=gnIqfD78; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz24-20020a17090b0ed800b0024e2c5e3a4asi2498905pjb.132.2023.05.25.15.42.51; Thu, 25 May 2023 15:43:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=gnIqfD78; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241563AbjEYWaQ (ORCPT + 99 others); Thu, 25 May 2023 18:30:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231964AbjEYWaO (ORCPT ); Thu, 25 May 2023 18:30:14 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BEFA189 for ; Thu, 25 May 2023 15:30:13 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bacfa4eefebso412265276.0 for ; Thu, 25 May 2023 15:30:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685053812; x=1687645812; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Tpe07KW4MlBzxlGn7n37Z+ZqlMCf6ry7/JhPxHNLhGc=; b=gnIqfD78xjJBrl22JS5xn0bJm2eRs9S14W4Wng9ZmN/KRqAlYoQCuuH4TE99W8J0Gw DqJTar/YTthPR0dQielI1FOXVatroR8HUJuyf+cuNIIxNech7uODHv0p8Rzqq304rN4v sZzHeaLXRJQ+32bQ8wm/EDFDhmOzwzoPHYf8Ii381bdvMLoWClbe+59CLtJmE+43626j 2NulVW9L0ULrslMvVfoO5v8PHnvaaxbEjYq9SEnxNW6qg8LvT3/FJcdb4a0cmKIxPt00 hlLUHZv6s2N42FO7nOEg3vvryPM+OO6YjcCIl3fy6jbjMCoQSEjzb3ex13zRiIkaYEFY OOZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685053812; x=1687645812; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Tpe07KW4MlBzxlGn7n37Z+ZqlMCf6ry7/JhPxHNLhGc=; b=ianGZL7RfrJlQACnifApIPclk2c7BUti2pn1HY0gUDe/sKXO+zBmD6ec7xjviNZh1M 9jVdSiwQZ+t7lse0rXDRCAMkhv6t7i/kYjkBMsE7LuNIRx8QZJTNsqg1muxsLiB7CbUa 8zBnIKLRmPdr2pCSuq2S1Ye5gCsRKYtNBiljKdgBzUITTATc2rHOFSCgpiRU72oDEu0X a98a8NcpTA40aYnildmHrFtedvZJe/VnWYw9FiMgLbNHBBU8HUcL3EVjRlvNw05A1T8S QXl3Nb+OWdDGWzjkVywx4yqaGLEoD1ImxCEy1tImt+fFvwdJuq9coUkll/qzC0cLWX0h On5Q== X-Gm-Message-State: AC+VfDwkc31kxWT56ALE8kW/I2x/AvN7Qoh1XAvva79K/bV9yXz4tSO2 D+nUA1Kw4k+3W4oq7+8A1UBlDXfYLkI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:5485:0:b0:ba7:3724:37dc with SMTP id i127-20020a255485000000b00ba7372437dcmr2251497ybb.13.1685053812610; Thu, 25 May 2023 15:30:12 -0700 (PDT) Date: Thu, 25 May 2023 15:30:11 -0700 In-Reply-To: <2d7f7f80-278d-9fcf-cfc4-c433e95d9842@gmail.com> Mime-Version: 1.0 References: <20230427095333.35038-1-abusse@amazon.com> <2d7f7f80-278d-9fcf-cfc4-c433e95d9842@gmail.com> Message-ID: Subject: Re: [PATCH 0/2] KVM support for Intel PMU v5 fixed function PMC bitmap From: Sean Christopherson To: Like Xu Cc: Anselm Busse , dwmw@amazon.co.uk, hborghor@amazon.de, sironi@amazon.de, Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 16, 2023, Like Xu wrote: > On 27/4/2023 5:53 pm, Anselm Busse wrote: > > Starting with v5, the Intel PMU allows to indicate the available fixed > > function PMCs not only through CPUID.0AH.EDX[4:0] but also through a > > bit mask in CPUID.0AH.ECX. According to the SDM the OS can consider a > > fix function PMC i supported for: > > > > CPUID.0AH.ECX[i] || (CPUID.0AH.EDX[4:0] > i) > > Yes, this feature is attractive for virtualization scenarios, and it gives > flexibility to control which fixed counters are available or not in the > virtual machine. > > However, currently KVM/x86 also supports Intel PMU V2, so I would expect > that we will review the enablement code for v3 and v4 first. Looking at v3, I think we probably want to skip straight to v5. I don't see a sane way for KVM to emulate/virtualize AnyThread, which comes in v3 without a separate CPUID feature flag. The SDM even calls out that it'd be a mess to deal with in a virtualized environment. v5 introduces a CPUID bit to allow deprecating AnyThread, i.e. would give KVM the ability to advertise a sane vPMU model to userspace. Amusingly, KVM advertises "edx.split.anythread_deprecated = 1" for v1+, so maybe we don't even need to do any enabling? At glance, I don't see any other changes in v3 that require KVM support. v4 looks to be an entirely different story than v3 though. So I agree with Like that we need to enable v3 and v4 before advertising support for v5. And KVM *does* need to actually advertise v5. Emulating the fixed counter bitmap without a way to tell userspace about the functionality will create a mess. TL;DR: If y'all want the shiny features in v5, please enable v3 and v4 first. I'm totally fine taking a series to go all the way to v5 (might even be preferred due to the AnyThread crud), but I don't want to advertise v5 without supporting the required v3/v4 features. > Ref: https://lore.kernel.org/kvm/CALMp9eQVnk8gkOpX5AHhaCr8-5Fe=qNuX8PUP1Gv2H5FSYmHSw@mail.gmail.com/ I agree 100% with Jim, the bitmask stuff is firmly v5+.