Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp498957rdb; Fri, 26 Jan 2024 02:00:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfSt1md66zTV/6JKlXJ5tfhAv8FGYlJzN0w2T4HEmMORM73KwL2AeIRGyiX8pLJnQhhf+Y X-Received: by 2002:ac8:5c95:0:b0:42a:3a77:c018 with SMTP id r21-20020ac85c95000000b0042a3a77c018mr1236732qta.10.1706263234127; Fri, 26 Jan 2024 02:00:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706263234; cv=pass; d=google.com; s=arc-20160816; b=QfsNE467t8xPnRi+X23Ct5FnrSjdED7hDjhcjnpPigBKPlPnrN92yyBH5djSE+R49s PAroYZUbrAhgUFypo/Qc0pnBqw/fqbcZoYJi2CVLlYEhxWNDXxY5/vovN5FksvZX7HS/ aNS2BViM/9UeqsVL6XyDHQ9K9VK2N5olrUWIHnpo1u9sp03xLxDjR5iV1wE7kdpXaQ7/ n2PmWTEwe63QUX906GHxQ0nwELw4TeY8C2/zMmpTtB27+KgGJbmCV51oemNGA6wch8wx bKnOEWBwBymzC2z7KBuh4E6bYc7gWWS8w3YZzRFNlnrX4oO1uql26ITf6ktyC662XwE5 YA7g== 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=hZX19x01c6XMjtpMsE5+cMNYi5KLgElfKVjAEyJkuSg=; fh=fKQXo0qMcal6BogvSG9bxyWEWsAUcPVWLMmdMql1Nx4=; b=Gzquq27XUqn3qdgFq5bejax0r7yKaizjhGsvoITQxBXRVe3UykjIWZYANEITsWMcZK IGvxw9NHCgZN+J85k4r9/ceuU4P469qabkISQ8YL5Piu7L78rwxTeDFJo85FxqlagRvy UwGybr4o5O6jxGVsumVOqLI4WoL7dk2xE1r8IPNb35grBZfdZ4eghzNli6tzG/tuHZG1 Dpw/fO6y+tFN9+ukdR9kBLegtLXbk92MoywkmNiQIsARFIjaTJTSj60ir1cRIpB11ltH Ajs4GXGS0S4AEeSoZkS0/P9Oty6MQcCm2WG9Ox1FimVgz0wL4C89WbbbALtasIw9q5dt Z31Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bLdBu+8T; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39847-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39847-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p3-20020ac84083000000b0042a7e1df3c5si614144qtl.573.2024.01.26.02.00.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 02:00:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39847-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=@intel.com header.s=Intel header.b=bLdBu+8T; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39847-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39847-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 8B47C1C2B52A for ; Fri, 26 Jan 2024 09:43:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B85914AD08; Fri, 26 Jan 2024 08:57:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bLdBu+8T" 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 AE61A14AD05; Fri, 26 Jan 2024 08:57:52 +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=1706259474; cv=none; b=KROIeOWe3+MgedjtTftI9xA6c8joSFz1eBGO1oPR+rye7TF8fG2Jqn3ABBrk66hHEo6X+ZV6ks4LXWFVhGixknd6XCpf0LGI7phfUgdpMZkMQGEqE+vm4PkALI8MS+DDCrbCW4JdVXqoOmpvtqkvwB4soRMYoBiY9Bz/oSbUDx8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706259474; c=relaxed/simple; bh=vcN0M4Um3O96u875lU4oYcgL4lwYn/C625MrP4JrFdg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a6QR4cs4cwVnrX9SCW/csMvohA4COYINCXv6lXE/IKhQBpmX00RBhXml0KzH8TMyTTHYFQtRL0ikez+h6FtqjgmtcM4rsGcJ9bNhcscQ6VgYmZyj2uSHSO4kSD4JKemFoRF0sG8Ldjdr1iG0nxWjnw9D5DsRjpKo8Kb75PZyVmk= 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=bLdBu+8T; 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=1706259473; x=1737795473; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vcN0M4Um3O96u875lU4oYcgL4lwYn/C625MrP4JrFdg=; b=bLdBu+8TQPuf8H33P+FFoN2EbjgpDFieAqHCuJGnkztMbTNfDGTf5JfR bJFRb9JNd7ccc+xFw79t4ZO8zMWBxiWG8browrgxio0TX8gWwKIphD5Ph ZdSEb0pZpScDiDL3YR3bjek7obABeXKOOOgnEJulxN8G2OzaQgbKm5G6d UB0o26t2J4Vlk66dTgro6QS0pYOdnQ5j/Jir2fCh/a+/HpI/pXwv0+Pky ma3cIQXaNJCUsrb2DS4nMT/u/JGT1QPCtRq1kx19hIWttUSR0/pv9ttZC /xkLm9EuejL38OqDreshuLa5R8ise4ZtaPLS074g5keOKv/1tFxrf/YxS A==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="9792757" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="9792757" 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:57:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="930310275" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="930310275" 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:47 -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 27/41] KVM: x86/pmu: Clear PERF_METRICS MSR for guest Date: Fri, 26 Jan 2024 16:54:30 +0800 Message-Id: <20240126085444.324918-28-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: Dapeng Mi Since perf topdown metrics feature is not supported yet, clear PERF_METRICS MSR for guest. Signed-off-by: Dapeng Mi --- arch/x86/kvm/vmx/pmu_intel.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index 4b4da7f17895..ad0434646a29 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -916,6 +916,10 @@ static void intel_restore_pmu_context(struct kvm_vcpu *vcpu) */ for (i = pmu->nr_arch_fixed_counters; i < kvm_pmu_cap.num_counters_fixed; i++) wrmsrl(MSR_CORE_PERF_FIXED_CTR0 + i, 0); + + /* Clear PERF_METRICS MSR since guest topdown metrics is not supported yet. */ + if (kvm_caps.host_perf_cap & PMU_CAP_PERF_METRICS) + wrmsrl(MSR_PERF_METRICS, 0); } struct kvm_pmu_ops intel_pmu_ops __initdata = { -- 2.34.1