Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp529330rdb; Fri, 26 Jan 2024 03:10:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSCPzr+PoDWvzARieuLBDDMVcYVDydQ/gY+bbwk60XBmxiHFk7KPC/gS7jIRCeDVDzoQwT X-Received: by 2002:a05:6830:1d3:b0:6d8:74f5:dc38 with SMTP id r19-20020a05683001d300b006d874f5dc38mr1070729ota.9.1706267433637; Fri, 26 Jan 2024 03:10:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706267433; cv=pass; d=google.com; s=arc-20160816; b=Q26IKeKjTzkYro6Cv3RreU5YmUYpjInCSS3PwdC6vrayJFX5tjFKRE1mkGTuydzj6Y GuYa4v2blKHXvIROlMduQ0BGCtHtAKk2Ev3pPSc4oJtM+OQ1iyE6UD7rTKBfR7Prg3tO 4FSRKFWNm7r4aU4w1RuwSf/N/3AkmL6uL+vvoPU5TeEu3nNK5cJYpVTTUkRN1UGaA3Qf IFhREiD4kZJT85DbadSpgbzZTpCmxbblx6MzL1Pd8vGnV+3aXJCZv0MR00rYLVSXYEHo Z/EWt2CJ14FTkQuMykf9T6Fh5VxS8EXbwuQHypP/ALAOhKEWMbBNyvmuXrLSZMbdbjKm mlIQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FPnmg/gSW/jgXf0eXPR0T51iZpTbEAIJEOiUgUa+Cbc=; fh=fKQXo0qMcal6BogvSG9bxyWEWsAUcPVWLMmdMql1Nx4=; b=p78qTOsYlyVdaAEbnqPtgeQsdSI23Sdt0q1DIZXoGgc5lKCBmOMJvN/WcO0PDf//Nu 0mcYCnSG5o0O7gb5NlTE49ZBoC05sUPuHKtvyWAkDv1Knhq8T/iq6TKcdGh7Tx/K5vO3 NzKZ1cpKmYRuwMFiUeNvwyg5R9f9bKturdV5Zk116Ti+kAL+R8daHajJDCpao+Jd26R/ /M8Yxt7k/qG01IPNIwnHB9D/4Csem00V7KxTG2wKzJA1hTxKHWLszYizkExNOGaD3Bz1 5eqBzi1Gg5v4QW8/vLsaX5134NAnp9ZVfeOhM+Q5L9F/wtN+sI62AqOdO4S51Qs99KGb CrXg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=b7hqy1ko; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39849-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39849-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id iy11-20020a0562140f6b00b0068196745b05si1094509qvb.204.2024.01.26.03.10.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 03:10:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39849-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=b7hqy1ko; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39849-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39849-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 F12971C2BBAC for ; Fri, 26 Jan 2024 09:44:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DDF414C597; Fri, 26 Jan 2024 08:58:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="b7hqy1ko" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4648B14C585; Fri, 26 Jan 2024 08:58:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706259484; cv=none; b=CfvqVeceTiHtMA6rgSF4kUBTcSTgf8dlQhoGzi5mxcIF3aVHRMJvK3EY/lp/TXCSAYk3QscRTtiESb5MFceyTatxr0dvpyeUfCsswlzrMyaKZhqk/mat/cIEUmfWzpjXRp0h0Z27nktglDfgx97kSmyTnPgZMwoMMwMATjGBvLg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706259484; c=relaxed/simple; bh=Eomts/7yPf4NYVOQNKK9HqvKc0rom3Ij1FnDKzQqSyY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gbok3k2q0GhDMjFYala5PKUyX+A4vPZdNkktcX8CQRTOaPh2YXF0ZRH2cun5KYK40KpnAfPoVelZX9w0gVgDlXdSs6CIROMC/9jHc8vOkmtU0cS+etIay/xtJ1R8CPrzHim/+vPXrlPjsT11AcUivxQUfNsRQkCo/jV2+uTJCnI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=b7hqy1ko; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706259483; x=1737795483; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Eomts/7yPf4NYVOQNKK9HqvKc0rom3Ij1FnDKzQqSyY=; b=b7hqy1koJMii6q0kKycz9+3Fob03ZDcvTVmRBC1fBnH6gIkHZ0DtxIpp Kzez6LZVfbWdVFHpT4cj9cMOUoBvDzupleY9UAzdszp3zCcJ5E4CZhOSw oZTBVV0ngNWP0tVlnZzs78qfnlyZ/pdi+EZ+K5svYL64AJc36YcmCdYG8 YHwcBGDbAXx5bTva2GKwpKYC3S5NrOd69ifQye3yfQhKY0cuSilKKEqsc UA7tp27F2dRCckBS44JgOFjEUrdXgFDK6OjB5qUHPVeI/oorfAY6CxQMh cG9kd/NVKJLiy6q9hTtRJ6O6prFgyzDPr/6dBWW57iYbrv/jwPcZk9zuy A==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="9792800" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="9792800" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 00:58:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="930310337" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="930310337" Received: from yanli3-mobl.ccr.corp.intel.com (HELO xiongzha-desk1.ccr.corp.intel.com) ([10.254.213.178]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 00:57:58 -0800 From: Xiong Zhang To: seanjc@google.com, 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 Cc: 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, xiong.y.zhang@linux.intel.com Subject: [RFC PATCH 29/41] KVM: x86/pmu: Exclude existing vLBR logic from the passthrough PMU Date: Fri, 26 Jan 2024 16:54:32 +0800 Message-Id: <20240126085444.324918-30-xiong.y.zhang@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240126085444.324918-1-xiong.y.zhang@linux.intel.com> References: <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 Content-Transfer-Encoding: 8bit From: Mingwei Zhang Excluding existing vLBR logic from the passthrough PMU because the it does not support LBR related MSRs. So to avoid any side effect, do not call vLBR related code in both vcpu_enter_guest() and pmi injection function. Signed-off-by: Mingwei Zhang --- arch/x86/kvm/vmx/pmu_intel.c | 13 ++++++++----- arch/x86/kvm/vmx/vmx.c | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index ad0434646a29..9bbd5084a766 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -688,13 +688,16 @@ static void intel_pmu_legacy_freezing_lbrs_on_pmi(struct kvm_vcpu *vcpu) static void intel_pmu_deliver_pmi(struct kvm_vcpu *vcpu) { - u8 version = vcpu_to_pmu(vcpu)->version; + u8 version; - if (!intel_pmu_lbr_is_enabled(vcpu)) - return; + if (!is_passthrough_pmu_enabled(vcpu)) { + if (!intel_pmu_lbr_is_enabled(vcpu)) + return; - if (version > 1 && version < 4) - intel_pmu_legacy_freezing_lbrs_on_pmi(vcpu); + version = vcpu_to_pmu(vcpu)->version; + if (version > 1 && version < 4) + intel_pmu_legacy_freezing_lbrs_on_pmi(vcpu); + } } static void vmx_update_intercept_for_lbr_msrs(struct kvm_vcpu *vcpu, bool set) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index a9623351eafe..d28afa87be70 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7469,7 +7469,7 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu) pt_guest_enter(vmx); atomic_switch_perf_msrs(vmx); - if (intel_pmu_lbr_is_enabled(vcpu)) + if (!is_passthrough_pmu_enabled(&vmx->vcpu) && intel_pmu_lbr_is_enabled(vcpu)) vmx_passthrough_lbr_msrs(vcpu); if (enable_preemption_timer) -- 2.34.1