Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp652069rdb; Tue, 31 Oct 2023 20:05:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE03OysVwHyQAMTzsKjPOeE2ur3NmCI13+nFcrOOYE61AIf4jxzjQnPSic1t0v0VaqOdqVF X-Received: by 2002:a17:902:d512:b0:1cc:4b1b:2759 with SMTP id b18-20020a170902d51200b001cc4b1b2759mr7778767plg.63.1698807930932; Tue, 31 Oct 2023 20:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698807930; cv=none; d=google.com; s=arc-20160816; b=NhXE/3lWXvh/s7ntUC9ecQe7u+NyZR8PpMLOO2dw4UnrCSpsd8iqbF/0VAtWFmKPkC DqnL6p5nwoq425LV0Pka/7aDEtXu1zAiZpUfA0549p4PUp6LQzosIvW9ccygkg1X4kdq W/tJLe1hTq2hRFZEBMPwrZmwW8JiouxCJfykxMij3o/ejPY/Y7IC25lp1YEus0nZJ65t iOVGcJGTk+CnLnUcKqRRAZq/hLXSZ9PeC/+DD4VST91EZeN2ByncZ+XwF3aodbSSvtLv mMlK2+xJRy9Jzghk7zVK7oFsWwBbd7DKEwFCmHSDnJBEe2Z9+GKsZmZ1NVS6eKbP6AUl D86A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=9N2UA9dR/oUEBgRu3zdeV9HEhaEPwCrVnYcXhdTWnNc=; fh=2iwOqREzqY+fY8pVTIpA6jfkig3cUVeXtc1tNu6Wad0=; b=gok9Lhyk+iFyWYWEqbHIJ6w2JVpXZjiRLPygKZMzWdk1S/bay92n3+qKUZGiQZizBP JVVYpRU55CbF7QcCtzw8lLJCL+zWAGBBhJ2g0rBd+SUMv+Eog3hvvnjj8mPZ1YV5wB0O Qlxt/en7baxEhWMLVktuXR3difMo1GB82MaH5Py0UhaTtjNgHKZVsR3Rwnu8GiZnbMvH UO3a7IYnJHNtSJ9tP0QvHbkYb7gBMsAgafWa3eHLahisfuG4dSKhSei4fWAdCb045+Tt VwycZoswUNc07XRjsommAXHhG5r2VeIUzCzqDNEXwVSHmr+Gh2IZcBuPn1tYekoPMkRx p0Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CzRkdDNL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id e10-20020a17090301ca00b001c1e4f9c63esi2205737plh.491.2023.10.31.20.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 20:05:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CzRkdDNL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9DCE7807E8B6; Tue, 31 Oct 2023 20:05:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376300AbjKADFG (ORCPT + 99 others); Tue, 31 Oct 2023 23:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345437AbjKADFF (ORCPT ); Tue, 31 Oct 2023 23:05:05 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 847E4A4 for ; Tue, 31 Oct 2023 20:05:02 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-54357417e81so7108a12.0 for ; Tue, 31 Oct 2023 20:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698807901; x=1699412701; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9N2UA9dR/oUEBgRu3zdeV9HEhaEPwCrVnYcXhdTWnNc=; b=CzRkdDNLwVf8a0C/3qEEfONTclZx+Us/aYW8ttUBJqYzhPFbi5kGsFoyVTBxmpcTRz H+PU4NuLjitGtzj+LAlxqEeK3/WSMOi08/0ORvug+pxn8NH5J38YWDdtfeLRPKt14YW8 JbYiAXa0FdvqqkcmJa1P5YO/4QoWnfXIdhtc7sYkGbSVrX27Bvbwh8PDURY5EzoRNKYN gDZu/eMcXGnv26ttjPITIWQNTr4nnxBGd63dYU8QnIW97skjvZevcFaxhjCqnDrFjyD0 EtsIELn4Sv7pnh4tS90bFgJqYCW6irEPY2zDLXbrv88IlnES0+whnLz5IsjvvNd776LC qAJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698807901; x=1699412701; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9N2UA9dR/oUEBgRu3zdeV9HEhaEPwCrVnYcXhdTWnNc=; b=OTDJyGdZDAYXLydmRwpFFId+ifwAJN2rm4ueKVID1nC4XFNZIP7S9X+t4nXtNuuWcd xEsy1ZkuNWEVYgABuOsodHsLeEwRsAfIuE0/sS5XbZhA1VQg05CTurmPoooTO36/Kscq bUQZ3VUxStzTr7lT5ifklwVKhOjoxNtAYADMQwRPIlywlpj6eE5dkwu8bmsG9fFkoPpA 8ZhKqSJuiT+bokOWnbu2sOjZfTxbfxsZBe9ay8HOiHkmkrAo9mvj2TrOcavQclGp0rwN lR1zMwncmZUJUbjrztk5PnUFJfYoGvG5uidYMOYhQAtDtUQrI+RP/KiaVZg6l2bW1OCJ rzFw== X-Gm-Message-State: AOJu0Ywf+QSsadOhOHbQlc++KkfT5L35ukJnSdF5F1l20i2Esm1yrpsC 1fB4e1IUFBEIKxDjNDna84FmpW+NoPVpWXv5UQEVKg== X-Received: by 2002:a05:6402:1943:b0:543:74af:dfee with SMTP id f3-20020a056402194300b0054374afdfeemr195528edz.5.1698807900776; Tue, 31 Oct 2023 20:05:00 -0700 (PDT) MIME-Version: 1.0 References: <20231031090613.2872700-1-dapeng1.mi@linux.intel.com> <20231031090613.2872700-2-dapeng1.mi@linux.intel.com> In-Reply-To: From: Jim Mattson Date: Tue, 31 Oct 2023 20:04:45 -0700 Message-ID: Subject: Re: [Patch 1/2] KVM: x86/pmu: Add Intel CPUID-hinted TopDown slots event To: "Mi, Dapeng" Cc: Sean Christopherson , Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Zhenyu Wang , Zhang Xiong , Mingwei Zhang , Like Xu , Dapeng Mi , Like Xu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 31 Oct 2023 20:05:28 -0700 (PDT) On Tue, Oct 31, 2023 at 6:59=E2=80=AFPM Mi, Dapeng wrote: > > On 11/1/2023 2:22 AM, Jim Mattson wrote: > > On Tue, Oct 31, 2023 at 1:58=E2=80=AFAM Dapeng Mi wrote: > >> This patch adds support for the architectural topdown slots event whic= h > >> is hinted by CPUID.0AH.EBX. > > Can't a guest already program an event selector to count event select > > 0xa4, unit mask 1, unless the event is prohibited by > > KVM_SET_PMU_EVENT_FILTER? > > Actually defining this new slots arch event is to do the sanity check > for supported arch-events which is enumerated by CPUID.0AH.EBX. > Currently vPMU would check if the arch event from guest is supported by > KVM. If not, it would be rejected just like intel_hw_event_available() > shows. > > If we don't add the slots event in the intel_arch_events[] array, guest > may program the slots event and pass the sanity check of KVM on a > platform which actually doesn't support slots event and program the > event on a real GP counter and got an invalid count. This is not correct. On physical hardware, it is possible to program a GP counter with the event selector and unit mask of the slots event whether or not the platform supports it. Isn't KVM wrong to disallow something that a physical CPU allows? > > > > AFAICT, this change just enables event filtering based on > > CPUID.0AH:EBX[bit 7] (though it's not clear to me why two independent > > mechanisms are necessary for event filtering). > > > IMO, these are two different things. this change is just to enable the > supported arch events check for slot events, the event filtering is > another thing. How is clearing CPUID.0AH:EBX[bit 7] any different from putting {event select 0xa4, unit mask 1} in a deny list with the PMU event filter?