Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp131364lqn; Thu, 11 Apr 2024 16:57:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWE2y4Un1lRBcynl5nDkXbhoXiGqRMbZ80uEPNlr06RhL89FIEB+1gk638l7aqVLPZP+N4ezxERLiNV9bcPmQup2yqs97klT7v+z5Aekg== X-Google-Smtp-Source: AGHT+IECd+Twm44o1jw3w6BgSAmTBVV+JZykks/x3P+G2g33aqN1ig5zNUalWxOK3cAswMMTgFQw X-Received: by 2002:ac8:7e93:0:b0:436:8930:8a42 with SMTP id w19-20020ac87e93000000b0043689308a42mr728276qtj.36.1712879868220; Thu, 11 Apr 2024 16:57:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712879868; cv=pass; d=google.com; s=arc-20160816; b=fEfXHQ+/6dk4I+xE3IorbKwsBuMB/gDuxbIhhz8l89yTrZO3/ol3ltKqvrGhfMOjp+ +5le8mRr+t4/20dw+GZ/7Owo/T94056VMGgZq+6lpvyhDlpXgpHwYUWV9IETzsx/RRWZ OP8oNNIg+NJ3yEKA68YQggo+SAXrGUPW7oqAi4e29290cwIS6lLJ45VUm9a8Wm4yKb8p jpCoiJnFlVziaMbHpYzgLxVttN/4LOb6GtJq+Kx2J6wRYCOznljllICBCiGpwlI2B/Wn /xv4Gt/ls0iXrH9nTiV3mWIeKB9j/LXo2cpogKtB/qg8/E/OFPLus7/CUZ5VeIEcd2qK 75NQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=oJmBil8hMiXltO9cI7CiQAcj05S/4ZhSQgUi9evlkRg=; fh=yL2AOBpkr37iwH5QoZcXsDiLpNd4qxwCZCq59GyxrJQ=; b=BczsRgr7ldZWPu1yJWJQwjfj2x6p41sj3AhgYhn2NjwmT4lnsL5uQtiLpTY9HsvE9u rzu516wU3bVHV/Py8X/SLxlBXUleNxM8E2lT7Ba0OyiK0nGTqC877hOofu3/jmSkTdpx /tZpODhQpMmHEc88E+X2goj6cfCZVgezmp0QTXJ7R4LO+zC196NIEGmmVAGjNsUumEZR mg6wexl0sJJ3kB1g9B/WyorZqfpFF/8leGpgXpM2Xuu+CJYvuz/vXTrxQTL70DCoPPdI 1E1lmk1aKv61vTHQUyxPYj/VwDqpuqKGSMr1z/24HyUDVcrtq4s+qJl/JfljAxEdJW4W lvLg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="nBcfZ/6G"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-141733-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141733-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v3-20020ac85783000000b0043659f36843si2679274qta.312.2024.04.11.16.57.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 16:57:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141733-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="nBcfZ/6G"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-141733-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141733-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A53B21C22476 for ; Thu, 11 Apr 2024 23:57:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E112E4D108; Thu, 11 Apr 2024 23:57:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nBcfZ/6G" Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6470C482ED for ; Thu, 11 Apr 2024 23:57:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712879842; cv=none; b=BP3cmrDYDG8u8jKGUza+eIUrSTCMbZw70QST/OhCWJmUmlnzY4SBfpcdtJBz8OMmqZXYXxxsga9l5SP3vJb+6/0hlIEDBcaROUfdJMUrGzMVCUmgrp9m2H+xdRwBqshzZwvob6kH6kWSCniAIEQVF32uF28vbFCU7grYb2GYgPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712879842; c=relaxed/simple; bh=QBuULRrtaRnnhZMlTYGm7HbOpsKwcgNmcTmfa5NNbhk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Ksl2taBKYLnS1MNZ2OBsXJJZiYKMCU2BXu4CtUUuUywGpq4T5IxyHXFDdiPHea+r9GvZjsCBdxErBY9GNtGQPGi2geepAjiZ71xf6yVeAgrlFxIyImYIqLgC4iOi5CBzcTZyAFbLYg+8Wk9TUHOp/KLrBwWo2kdtwOaTIwaAApk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=nBcfZ/6G; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a52176b2cb6so37188366b.2 for ; Thu, 11 Apr 2024 16:57:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712879839; x=1713484639; 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=oJmBil8hMiXltO9cI7CiQAcj05S/4ZhSQgUi9evlkRg=; b=nBcfZ/6GqVj1oFIKGAB5LLkuobcTZJYyuHkkDj4qZuYzcMfGVVmZPpthY8qqFpaoLL 6M8zvRpFNQmomfGPmZylhgw0I8OVFr7fhhk05EfTPh1yOFvtHoBGY9PtuRbnE6d3VF7B ez41A9tqjuUr01/44yKqNlVKmCqDAwuMd0a/iKPxxS4rWinQb5YuZxHAS8DDLc2f0G/E CVaYqhJNptp2PL1hPxe0aLc7c0LFZqikPGLd3fZssuYctL+rViUMY+0DdPOUU6FAA+tR 3lbweKMYZ2Wh2kTmfZQBLCQt21EBb4XUh1goIh7oWB3h+U20HhsRN23b1RW5J6Q0bWqa iFDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712879839; x=1713484639; 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=oJmBil8hMiXltO9cI7CiQAcj05S/4ZhSQgUi9evlkRg=; b=HI3wbf3dnczqLtf6rptKJsSc2CLbKkfp9aJSBjlse5ry4lkpMsUN7WUwMSNR2q1jct BmzVijPDgkaPVyKGwcGfOid7sG3GyP03FCoBdm60XyD+HupnDqBUrvHkqfdX8AcawJpu Or7pAe13lgI+tH7o+Vgx5uGUpYfqhfPz5yehiigAs6u5b89HuZDkfj4igtRjZaq7wAH4 WKuZ//4FJNiEFsPv7q2bq4AqO5eXQYckjtCCsjY9PH4JmKVn/CKUIgtkZ8nO5EoreaW2 7pInoFxOsKB68atsp0aPtYb7B9qHdWpTRavu0/mVy8fBfxIiZSKTMJatc9ek6qDf4IDN Oo5A== X-Forwarded-Encrypted: i=1; AJvYcCX3jj9R9FYzgvZz7oCJ4gFdjgLwct7/xBZadU11ze4y9ETRmGHG0hekFOMm5ep1A77nEZPeLmj9o3oaK5iLiE1wKEeLWTtiETvI5Z1+ X-Gm-Message-State: AOJu0Yz+hSB1vNZWAZkS5Dx8vo88Uqbi8ppvFUr8IBHUTfw0jSJUT20n RB0v0YtcaiC//MJjXwq8RJNqdlbrHNX5aRr21KnHbupBPgpejW0hGpfSdcy28PDupQsZZkNDJG9 +d7dTN6SzgsbEfgNOYoigXtGTAc9R3JLbn33M X-Received: by 2002:a17:906:3110:b0:a4e:21e0:2e6e with SMTP id 16-20020a170906311000b00a4e21e02e6emr588361ejx.5.1712879838488; Thu, 11 Apr 2024 16:57:18 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240126085444.324918-1-xiong.y.zhang@linux.intel.com> In-Reply-To: From: Mingwei Zhang Date: Thu, 11 Apr 2024 16:56:41 -0700 Message-ID: Subject: Re: [RFC PATCH 00/41] KVM: x86/pmu: Introduce passthrough vPM To: Sean Christopherson Cc: Xiong Zhang , pbonzini@redhat.com, peterz@infradead.org, kan.liang@intel.com, zhenyuw@linux.intel.com, dapeng1.mi@linux.intel.com, jmattson@google.com, kvm@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhiyuan.lv@intel.com, eranian@google.com, irogers@google.com, samantha.alt@intel.com, like.xu.linux@gmail.com, chao.gao@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Sean, On Thu, Apr 11, 2024 at 4:26=E2=80=AFPM Sean Christopherson wrote: > > On Fri, Jan 26, 2024, Xiong Zhang wrote: > > Dapeng Mi (4): > > x86: Introduce MSR_CORE_PERF_GLOBAL_STATUS_SET for passthrough PMU > > KVM: x86/pmu: Implement the save/restore of PMU state for Intel CPU > > KVM: x86/pmu: Introduce macro PMU_CAP_PERF_METRICS > > KVM: x86/pmu: Clear PERF_METRICS MSR for guest > > > > Kan Liang (2): > > perf: x86/intel: Support PERF_PMU_CAP_VPMU_PASSTHROUGH > > perf: Support guest enter/exit interfaces > > > > Mingwei Zhang (22): > > perf: core/x86: Forbid PMI handler when guest own PMU > > perf: core/x86: Plumb passthrough PMU capability from x86_pmu to > > x86_pmu_cap > > KVM: x86/pmu: Introduce enable_passthrough_pmu module parameter and > > propage to KVM instance > > KVM: x86/pmu: Plumb through passthrough PMU to vcpu for Intel CPUs > > KVM: x86/pmu: Add a helper to check if passthrough PMU is enabled > > KVM: x86/pmu: Allow RDPMC pass through > > KVM: x86/pmu: Create a function prototype to disable MSR interception > > KVM: x86/pmu: Implement pmu function for Intel CPU to disable MSR > > interception > > KVM: x86/pmu: Intercept full-width GP counter MSRs by checking with > > perf capabilities > > KVM: x86/pmu: Whitelist PMU MSRs for passthrough PMU > > KVM: x86/pmu: Introduce PMU operation prototypes for save/restore PMU > > context > > KVM: x86/pmu: Introduce function prototype for Intel CPU to > > save/restore PMU context > > KVM: x86/pmu: Zero out unexposed Counters/Selectors to avoid > > information leakage > > KVM: x86/pmu: Add host_perf_cap field in kvm_caps to record host PMU > > capability > > KVM: x86/pmu: Exclude existing vLBR logic from the passthrough PMU > > KVM: x86/pmu: Make check_pmu_event_filter() an exported function > > KVM: x86/pmu: Allow writing to event selector for GP counters if even= t > > is allowed > > KVM: x86/pmu: Allow writing to fixed counter selector if counter is > > exposed > > KVM: x86/pmu: Introduce PMU helper to increment counter > > KVM: x86/pmu: Implement emulated counter increment for passthrough PM= U > > KVM: x86/pmu: Separate passthrough PMU logic in set/get_msr() from > > non-passthrough vPMU > > KVM: nVMX: Add nested virtualization support for passthrough PMU > > > > Xiong Zhang (13): > > perf: Set exclude_guest onto nmi_watchdog > > perf: core/x86: Add support to register a new vector for PMI handling > > KVM: x86/pmu: Register PMI handler for passthrough PMU > > perf: x86: Add function to switch PMI handler > > perf/x86: Add interface to reflect virtual LVTPC_MASK bit onto HW > > KVM: x86/pmu: Add get virtual LVTPC_MASK bit function > > KVM: x86/pmu: Manage MSR interception for IA32_PERF_GLOBAL_CTRL > > KVM: x86/pmu: Switch IA32_PERF_GLOBAL_CTRL at VM boundary > > KVM: x86/pmu: Switch PMI handler at KVM context switch boundary > > KVM: x86/pmu: Call perf_guest_enter() at PMU context switch > > KVM: x86/pmu: Add support for PMU context switch at VM-exit/enter > > KVM: x86/pmu: Intercept EVENT_SELECT MSR > > KVM: x86/pmu: Intercept FIXED_CTR_CTRL MSR > > All done with this pass. Looks quite good, nothing on the KVM side scare= s me. Nice! yay! Thank you Sean for the review! > > I haven't spent much time thinking about whether or not the overall imple= mentation > correct/optimal, i.e. I mostly just reviewed the mechanics. I'll make su= re to > spend a bit more time on that for the next RFC. Yes, I am expecting the debate/discussion in PUCK after v2 is sent out. There should be room for optimization as well. > > Please be sure to rebase to kvm-x86/next for the next RFC, there are a fe= w patches > that will change quite a bit. Will do the rebase and all of the feedback will be taken and into updates in v2. In v2, we will incorporate passthrough vPMU with AMD support. Will do our best to get it in high quality. Thanks. -Mingwei