Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp121231lqn; Thu, 11 Apr 2024 16:26:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVSKwgf2sN2mPYGBPRDVESLem4VItPoJDULWXyM4LYBostGcrpJ8KS9zRFedJi9HD003hJhZsdyFC662O/xpdf2wiQjYa/kjFS17VhrQA== X-Google-Smtp-Source: AGHT+IH8+vXIliSf1LFdOqaUdmWII/xChMiWnUQFkMMqK+T/ZhBsW3WhBqbHiVijHjk1OYf1OI/R X-Received: by 2002:a50:931b:0:b0:56d:f5ff:83ab with SMTP id m27-20020a50931b000000b0056df5ff83abmr738175eda.39.1712877970927; Thu, 11 Apr 2024 16:26:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712877970; cv=pass; d=google.com; s=arc-20160816; b=CgEP/709vQrCqy5unYDhJVzjjSj2uakH0BxLKgrcL+uoHhjTvZd1DbLysCYICpVPSB AeTQBagDElOSTw3IU3Y4UlaliyxWmOz9JDDOjNXXP7bDj/VXJieVB5/PIjUNpOrUdPGD LcxGP0vGEnzgv95pzl089BY8hyaf6Fk8zXLuA3unjMHvnH3Acr3NMobYnBlMS/nX6Jjy uSXvUDKRCbi1rEG07D2TdCvIoMNFZTJdXkui6KGI8uKk39+R0FauPVHQdWT1iy/4NGC+ 2fkJ0J5MNAa6Wtpfmk6EwjV64Ga6A1zM9MmIn4OnVeE/EH55H8MVTSyGCSHmJRQW7hNd TCjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=0SBa5EsG+dA7Im52unjbubbrECIOknLW2YGglXB1T+g=; fh=6jlt1d9pHQ4PByaZeT6JIlUyoOKg6dcftCdfM7FOEFA=; b=K3gaIe3/gKkN1XWXmLyE1aiYRmEtu1O6s0xYhVFufeGpUXdxv5xHg61aXQR/1j2/qo cbG7lQ29QMgFCYsADobrjW2DaeGNSnS9f9urXjxwvCMhrhQ6CZ+j4lM20WqVqRTExzp9 ijOFZ/iZhK+7+2xWcewkNBS9SHr6g8pW7TgVsMKiQFaVnVVncBJg8Gh58eqoArlilIsJ E9msLlzPEXrxSISD308tKAxwD2itQDvAVG4X+KVQH6XX4RMu8EtTAliBlB++Zo+3cb9q mqGzB2JMVFHy7ixttP7DsKlyMZZJfuXHI3+0juvve0OU4d6MQBLXEMkkZO1uNpkOiutk hupg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RQIFsRtN; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-141711-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141711-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h3-20020a056402280300b0056e31dbe4f3si1173679ede.154.2024.04.11.16.26.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 16:26:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141711-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RQIFsRtN; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-141711-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141711-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7DE1B1F2330C for ; Thu, 11 Apr 2024 23:26:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B43D481DA; Thu, 11 Apr 2024 23:25:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RQIFsRtN" Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 826572C68F for ; Thu, 11 Apr 2024 23:25:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712877958; cv=none; b=uZ7PAl8lc4pOYiOZFSOGOCrZ8MTyAFVjelEcA8064vz0Bcqsu+KoA2X6aaEl4yuvq2JIdlhb1FDzWQ+Lqc56bpR9QYtxkyR3knbsT/x9qj4jEEEuTlFE4ueSMzJa464bxsrTXnw9njpuAT/LKTK3KP2SLgO/iZ1yJGvumrnkf8o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712877958; c=relaxed/simple; bh=Vi/2xASu1BxKX4lM8VAO/Am54CJvEJC5TgkBtmp5PPU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=MeaTo85ZU0OTwab2+QQOHs7lhdtGV/arCvNSPlqg4IPT8YPsiloObSHbkdpF4GpoqhJIDk1xXjaXOVWxTA7gJJ4/6u89J6rbeza3ukcQRXBizxThwJQW5PnpWonZOK04jHOG4PCvzHyGbADoNldo0OtQE7cT1775ers5jy0gbLM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RQIFsRtN; arc=none smtp.client-ip=209.85.215.202 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=flex--seanjc.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-5dbddee3694so174281a12.1 for ; Thu, 11 Apr 2024 16:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712877957; x=1713482757; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=0SBa5EsG+dA7Im52unjbubbrECIOknLW2YGglXB1T+g=; b=RQIFsRtNGlt/nv43uQ8oG7WM8XsQcUmp6US2Q1cx5SJirloCYhW1seAa6lacop/zZw ni/cL7981m5LRY7s5f8KmpFcuQoft17ps7gG1Rc5A22Hr3SUkzcHQ212kpXmvLH9mEhH R7ol6zYep7hLbCj1HHdXYAO2YqH7d3hNOy7PBSdaWGYo2ww1txKgs02Vtkp6Wk59MrVd D4zETNN8gKEvHGeZP1hqOcISuNrKNrRHs+rBww4o1pS1pAc3/VIG9Rlglp7OLrmT7POg DfdIkv9x49DRoBP4w0y27JRisYLZ8C0gDCDjdUtaroBcCCYzkjFgjTrhQdUWbwnxfGRE bbbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712877957; x=1713482757; 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=0SBa5EsG+dA7Im52unjbubbrECIOknLW2YGglXB1T+g=; b=EFlKZuWSWIFfLQNtYwW4mIAqelkpoOKrPlegIesQapKsYJ1OGsMnqnPSMXNl0ZQR0Z aXacAXm2rUEbHJSKqx4Jd3TpIyUrkRs+SAuRzcK/mxtT+rZYj6xkHNYig16gXRcXnxJF J9RZqgnImHazWSIhaU0sO1oj2A8Mzvai5ClT8hDJSZQDLbq8cVSbo7saU8oPoJOJbUdo bwY0dpqkEOOS67t6WIKyEKJXUnjiv8c9GnKuIGBuNpG3RjUZPb4pOmfcsMgWzimocq1Y WOiCPj6PTyuhhCUtggsOY0yXNhHw3gw5W0CrZzx2esKkrczA9ATc2QHa270hIBSrRj4s mEqw== X-Forwarded-Encrypted: i=1; AJvYcCWNpc7UlLo3X/dfpFVRK6ZHvWiEwYNWcXFP1mYloOjyr8a6fd6zgux+WjbewkjP2qgXjPwoIE5TiqJkkjJnnGpLNPwgUvn5XI0bind7 X-Gm-Message-State: AOJu0YzaUr+ZST3iJr+cA1dvXkVhuPpw3JFhVzr4qjvzus5nCvomSYv9 cb6n0FnO2AR2SdHVMVNLzbsvuKf5BAbfMlmzg17vDZRMdYTn5RHop0S+g0Z6lU45hY2/0509A2N Ncg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:d70a:0:b0:5f4:36ab:acad with SMTP id d10-20020a63d70a000000b005f436abacadmr19603pgg.5.1712877956702; Thu, 11 Apr 2024 16:25:56 -0700 (PDT) Date: Thu, 11 Apr 2024 16:25:55 -0700 In-Reply-To: <20240126085444.324918-1-xiong.y.zhang@linux.intel.com> 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> Message-ID: Subject: Re: [RFC PATCH 00/41] KVM: x86/pmu: Introduce passthrough vPM From: Sean Christopherson To: Xiong Zhang Cc: pbonzini@redhat.com, peterz@infradead.org, mizhang@google.com, 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="us-ascii" 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 event > 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 PMU > 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 scares me. Nice! I haven't spent much time thinking about whether or not the overall implementation correct/optimal, i.e. I mostly just reviewed the mechanics. I'll make sure to spend a bit more time on that for the next RFC. Please be sure to rebase to kvm-x86/next for the next RFC, there are a few patches that will change quite a bit.