From patchwork Tue May 23 08:15:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 97881 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1980124vqo; Tue, 23 May 2023 01:26:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lWgdZFqnIsXqI1NnE1DBoCL81hVeZA6V6aMw/oBjtguUTcpgxvm91/CMBI5YwVudk26bl X-Received: by 2002:a17:90a:cb14:b0:253:726c:d6e6 with SMTP id z20-20020a17090acb1400b00253726cd6e6mr12160471pjt.3.1684830401284; Tue, 23 May 2023 01:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684830401; cv=none; d=google.com; s=arc-20160816; b=JfST9xFSa0MUAOEWMPb6gk7pYXkIlkVU1g9+1oy/NSNsTquVioLjbgmOmbc9kLG2Vi lNtQXoIcKjwMP78y/KQkg+HRRptkJkBTRhsTuv6P+eN08fnbrZ4AiLBZWNrLnqwbszum deK5Y9GzwoEf0ukv1nk9phNefgQid+N3K8gu+gTtyEWjrL0uhDj7HThl5M0pz7gZgJ0e Puh9MjenSxrl5cKRHvQBN8yQpnfI/PORWfQPBQnOVaIoGlDyD1NLpCYBlc+dD191bKHf tCUurSkYFS0v6bPHfiBcN/zAlqtcrA6zZOYDfRYxeSqpRYB0C3TQfHhPqQyhOxbdzWgp 79uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=iSC48ejrFN1szNw+99ZFEvTjXIrUUeq57tpcf9Ujqnc=; b=sN9+PsWnmFxCQVMg4UvMPvjcCYP7Ed9zsZ1my7FTtG9qShj07a1f1MghMkCZVcnioJ rc2lChtwbLgZ2w8VZiJjMPvFStUDGg70K0R4mAJvLaKUtHWUzX5CMJ1SD5+kqz9HHk55 JoJwHcBesgc+uNIJWKGlAUtanFloKqyOxEVhO6AJsMpR2Mn52FF8068yDL+0KZJ5eZ01 kJ/ZoS9kkbAEgJMPB+2K8pKMmCtVg7jEL1lzaL8pLn49mzwfbc+u67QXML/Q/6UZpmk6 cvqaw+6SOmXE7Ee7/f+IVf0EawXoeHbr1iRhoFBOrVDCLr+4tA/W/Ob8TVmrvNFqB7YZ DyuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FJLmWUMQ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=0PNorpVb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mv22-20020a17090b199600b0024e22853a90si5926099pjb.170.2023.05.23.01.26.29; Tue, 23 May 2023 01:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FJLmWUMQ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=0PNorpVb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236081AbjEWISa (ORCPT + 99 others); Tue, 23 May 2023 04:18:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235753AbjEWIRv (ORCPT ); Tue, 23 May 2023 04:17:51 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C75BFE; Tue, 23 May 2023 01:15:51 -0700 (PDT) Date: Tue, 23 May 2023 08:15:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684829747; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iSC48ejrFN1szNw+99ZFEvTjXIrUUeq57tpcf9Ujqnc=; b=FJLmWUMQoaYV6Vt2wS1axS4sZink+fnW1KTOFU8edXwGOCxlilZ/gFCxJjbW1IpQDTnfJT AKhWWyB5NfPoI9W0767/Hoqsyre2Y/4jtghqaxaELd+QBil3aI6fhrkEG+xs+7qWuEdE41 AF8FO9oFAldHMBT80hcMDphaqWYIA6Y48TaXkUZAtnJPMiRNyf0zchJJofQeSBe28MjKHV e5OvABbiqZe2Wv9PNTdSvrJnYdXYMT0fNYG1OvTuduo2wquI3loiRQgit2kAtVaFl0RJPX g10j/DsasxkZ2CTfM+oVwbcrgYu4rPJeKB7j5q7k9PzDk8SA0RnBp5pi2PN5rA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684829747; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iSC48ejrFN1szNw+99ZFEvTjXIrUUeq57tpcf9Ujqnc=; b=0PNorpVbfhzsbmJjRDYluqjwmmcZBkOOMpOzAnJBu/83r0+iRXkRP8mBFCAs3fEuWYEtfy IMNiw0DDZTq9gHDA== From: "tip-bot2 for Like Xu" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf/x86/intel: Save/restore cpuc->active_pebs_data_cfg when using guest PEBS Cc: Like Xu , "Peter Zijlstra (Intel)" , Kan Liang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230517133808.67885-1-likexu@tencent.com> References: <20230517133808.67885-1-likexu@tencent.com> MIME-Version: 1.0 Message-ID: <168482974681.404.11952331540708115887.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766150359382566396?= X-GMAIL-MSGID: =?utf-8?q?1766672723069198769?= The following commit has been merged into the perf/urgent branch of tip: Commit-ID: 3c845304d2d723f20d5b91fef5d133ff94825d76 Gitweb: https://git.kernel.org/tip/3c845304d2d723f20d5b91fef5d133ff94825d76 Author: Like Xu AuthorDate: Wed, 17 May 2023 21:38:08 +08:00 Committer: Peter Zijlstra CommitterDate: Tue, 23 May 2023 10:01:13 +02:00 perf/x86/intel: Save/restore cpuc->active_pebs_data_cfg when using guest PEBS After commit b752ea0c28e3 ("perf/x86/intel/ds: Flush PEBS DS when changing PEBS_DATA_CFG"), the cpuc->pebs_data_cfg may save some bits that are not supported by real hardware, such as PEBS_UPDATE_DS_SW. This would cause the VMX hardware MSR switching mechanism to save/restore invalid values for PEBS_DATA_CFG MSR, thus crashing the host when PEBS is used for guest. Fix it by using the active host value from cpuc->active_pebs_data_cfg. Fixes: b752ea0c28e3 ("perf/x86/intel/ds: Flush PEBS DS when changing PEBS_DATA_CFG") Signed-off-by: Like Xu Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Kan Liang Link: https://lore.kernel.org/r/20230517133808.67885-1-likexu@tencent.com --- arch/x86/events/intel/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 070cc4e..89b9c1c 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -4074,7 +4074,7 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) if (x86_pmu.intel_cap.pebs_baseline) { arr[(*nr)++] = (struct perf_guest_switch_msr){ .msr = MSR_PEBS_DATA_CFG, - .host = cpuc->pebs_data_cfg, + .host = cpuc->active_pebs_data_cfg, .guest = kvm_pmu->pebs_data_cfg, }; }