Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5485346pxb; Wed, 26 Jan 2022 13:09:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJznuTEAZeXF37ZgR6v3aCjkXIK85zfoTeMKD4VJebCa4y8T7o9HgNaNwox7j6sUKdfhlfS4 X-Received: by 2002:a17:902:8a97:: with SMTP id p23mr586128plo.26.1643231363730; Wed, 26 Jan 2022 13:09:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643231363; cv=none; d=google.com; s=arc-20160816; b=C/Yva+UzFY3HutPv3z4FpuIUHznlTtOD19wMcCaJFQxMhEx95dzNX47m3SHhSaDrKq Miagf/Vr3MkEJ1tmwOX1qSEYNlqe6vrqXoWQsmxMm/PD2ZVtN/0TQQF7zFTFRgdnJZ/y 0JHyF+vFnU/7eNBWHd1P0e/4jWbSILPJc8GwB0b/86+MF1fsSVUat0T82krxb9Sb9xaq pgalZiDMRb+DsX0IioNcxShjCrwtWQ8V0IRqedbJcvoxnmUwTCpa+rVwj25mLahSA8Ow m4Q4VgAA4+8IdM56TZPijebm2j/R7FAdbGsi333aaUyxjzbutnkAo7ZchttaxtJ4aSMM nFOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:references:cc:to:from:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=DcnfjljfiqT/xzEtLh/gjs1otCHVMxLp1a++I/N+BGI=; b=OErRfBtsrQ8aKiQO0pjJriGf5MPh/khYxOeTAQUnHtMPYPcjvi1qK8lh4RC3z0rFrh 04Talku+jsGxDG2Zz5CZorDSGjyui1W74EguWeOMucB3NUMHdB/IZJIQ8oGKkWrx429z L8wqWMNTHqP4L+/KfvUfRzCgqev/0wBVdxlNb2hGJw4os1uDZlnCh9oIOIbUHagJfdmt 9oFIqZPdE2q9EilcZwzcZpzO336GbdYDwS3fW0jHe8l8PITooFX1ZfDFQwi6KwlYhACE zpLULX2Z3FhysvxFZKCc9tk0/jXTZIs4XXrD9E2kDjCxIQushUixDgd5r9MFEq6bMQ31 5Pnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d1p3iRYP; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mu4si4408592pjb.68.2022.01.26.13.09.11; Wed, 26 Jan 2022 13:09:23 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d1p3iRYP; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240641AbiAZLW0 (ORCPT + 99 others); Wed, 26 Jan 2022 06:22:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233637AbiAZLWY (ORCPT ); Wed, 26 Jan 2022 06:22:24 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FFF4C06161C; Wed, 26 Jan 2022 03:22:24 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id o11so5698192pjf.0; Wed, 26 Jan 2022 03:22:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:organization:in-reply-to :content-transfer-encoding; bh=DcnfjljfiqT/xzEtLh/gjs1otCHVMxLp1a++I/N+BGI=; b=d1p3iRYPM8vmqp3/IVyo6DDwd3kc8DiV6zqmaaoP4XAIol010Nr/mu5uAldEZ2fMpC gyb+bIyvbGtdcToddIWr9wTAv2bH+lOCMJRjUqj5a7VfvE5xTZBxfJEw/bv78wX23jyx gMknGBoAxKOY8LUsSW0xgLt0Z2JaFOaQ3WZgCEXA8mfvpTmyJFpvOMuN9hDlz8ZXaqOh SpDIekpqadb2pS/NijyOqc4Pk0szBMqGSAMVQ06HPmHyW2gveW4o8Npejwgu9y9oik4r 4XAremChBh+pdn03CHnCk3IuHOUd+z7/BEwU6w2RZ6lT6/1eXIaBZeX68icfVrpP2QMl 2bpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:organization:in-reply-to :content-transfer-encoding; bh=DcnfjljfiqT/xzEtLh/gjs1otCHVMxLp1a++I/N+BGI=; b=7kQYMKVwTEBCZF1mqaneKHSoMigHODVdPFF/1OgDU9bNwGkMGhCRGB9AsS+bv24NaB hASjPC778lAwP5mpZ3YT6xyjQo2m7Zkpxun7QIGrb7M3cNdlX+7ME1la10ZdmJWb65Ad zt4xz+y6AVGg+oez+iViAXmo2hTnk76AtH2DUtkvpVcLPICCA3k5JnR1WrkehilEZBlr fhPlZAfBvGi7lZL5F9gaH0mkVBzIer3HcZvE0mU5U8LBN6ztGBSV8PTId8niGXFHYQGL NFk50a1FXK7WsgsA+/yf6N1cwPW1yc7sTU92btSgnhm4/7GElEDDUh1sKU1lfl3kVLPK 6l3w== X-Gm-Message-State: AOAM531LZtU/+DGPBQhn5JC10MroUTl7KLBSKOtXO7ewissTAiFdAPtF dc/mBTB7vG+iEEwTWmsnL2s= X-Received: by 2002:a17:902:7c82:b0:14a:e210:f2d6 with SMTP id y2-20020a1709027c8200b0014ae210f2d6mr22844433pll.74.1643196143651; Wed, 26 Jan 2022 03:22:23 -0800 (PST) Received: from [192.168.255.10] ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id h9sm1903196pfi.54.2022.01.26.03.22.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Jan 2022 03:22:23 -0800 (PST) Message-ID: <626806ff-7cd0-a6b4-c2f1-933d0a1924a2@gmail.com> Date: Wed, 26 Jan 2022 19:22:13 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH kvm/queue v2 0/3] KVM: x86/pmu: Fix out-of-date AMD amd_event_mapping[] Content-Language: en-US From: Like Xu To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, "Bangoria, Ravikumar" , Ananth Narayan , Jim Mattson References: <20220117085307.93030-1-likexu@tencent.com> Organization: Tencent In-Reply-To: <20220117085307.93030-1-likexu@tencent.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cc AMD folks and ping for any comments. On 17/1/2022 4:53 pm, Like Xu wrote: > The current amd_event_mapping[] named "amd_perfmon_event_map" is only > valid for "K7 and later, up to and including Family 16h" but for AMD > "Family 17h and later", it needs amd_f17h_perfmon_event_mapp[] . > > It's proposed to fix it in a more generic approach: > - decouple the available_event_types from the CPUID 0x0A.EBX bit vector; > - alway get the right perfmon_event_map[] form the hoser perf interface; > - dynamically populate {inte|amd}_event_mapping[] during hardware setup; > > v1 -> v2 Changelog: > - Drop some merged patches and one misunderstood patch; > - Rename bitmap name from "avail_cpuid_events" to "avail_perf_hw_ids"; > - Fix kernel test robot() compiler warning; > > Previous: > https://lore.kernel.org/kvm/20211112095139.21775-1-likexu@tencent.com/ > > Like Xu (3): > KVM: x86/pmu: Replace pmu->available_event_types with a new BITMAP > perf: x86/core: Add interface to query perfmon_event_map[] directly > KVM: x86/pmu: Setup the {inte|amd}_event_mapping[] when hardware_setup > > arch/x86/events/core.c | 9 ++++ > arch/x86/include/asm/kvm_host.h | 2 +- > arch/x86/include/asm/perf_event.h | 2 + > arch/x86/kvm/pmu.c | 25 ++++++++++- > arch/x86/kvm/pmu.h | 2 + > arch/x86/kvm/svm/pmu.c | 23 ++-------- > arch/x86/kvm/vmx/pmu_intel.c | 72 ++++++++++++++++++++----------- > arch/x86/kvm/x86.c | 1 + > 8 files changed, 89 insertions(+), 47 deletions(-) >