Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4908652iob; Mon, 9 May 2022 04:38:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJGGzvq47nM+3nYK50RfdfjNBtOGEGiqHza4iM2ldiqpbvSbcve1Lchq5aNuin7IdGcf9Z X-Received: by 2002:a63:610a:0:b0:3c5:a1f9:c556 with SMTP id v10-20020a63610a000000b003c5a1f9c556mr13106906pgb.366.1652096291494; Mon, 09 May 2022 04:38:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652096291; cv=none; d=google.com; s=arc-20160816; b=xqGivEVSp/AreAUHKGb8UdSaWsueXuJqEtIoLUhJA8wtaPkwOIeO0YNnP2FFjtve9G Sm0CeGjJHjWrgD5sz2r2Z8RJG4rai52BrrzWNNBTx/lxNwZeUQv+fEPc9gKiLhlMbdoN w1wR8KSQtWofY1rXJvIW0cNnY4dB/dbr2VMcoD0+JhOFZb0pvM/zjIhN0DQlyUIOHPlM w3Csu/vDk+QL2rgAz8mxXoQLE1LS3yQ4iJZyF2qG8WNckYLae+w8+KcvmvtKnk5AlWGZ XY4wZcwSz/H56yClgr/jwI5Y9rFVAU7y4hRPqkaMM3Z4GS89xMHbqBLmkfrKp/O1pJSh 2BQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/KscUgSu+DlH4SnTOHon3YcfRcvIy3eZGU1H9dQC07w=; b=CydifpIJxplwWPvf72sIAdrIjyClY58uaLTf59eeAaEgI/F0uOn7c7f/IOiAE8K7Ua qCEjzP7b/eBRo9C/cQ7jxhhBtgsvX8H/u9v/XHlWtMnGRwa4IrzqKIDnaQ3xXPW0PzLH v6Q6iEHVrNgb6skA9r0vSwjO7MV0A0rCFvkfbHmiW9yAd2y0Vb9JRhkMo9CAlkSv+Cup EzGltjg5HeelrnYWuAP5xEtlTvvG2QRmLvnc7WcmDGeMtZXixgYVad6bTka2DcXxdHes cI18hQGcLDnMDXZsZGWjTnuRCgAdjO3QuBYv9nB9wts73rPhBmLf9f5bhBqHY/eO0j7C bd/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NuD79QXP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l8-20020a170902f68800b0015d1f1c9235si12791595plg.561.2022.05.09.04.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 04:38:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NuD79QXP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CD10F2CFE99; Mon, 9 May 2022 03:41:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233875AbiEIK1m (ORCPT + 99 others); Mon, 9 May 2022 06:27:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232838AbiEIK1I (ORCPT ); Mon, 9 May 2022 06:27:08 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 739A028E4D3; Mon, 9 May 2022 03:22:20 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id i1so13408249plg.7; Mon, 09 May 2022 03:22:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/KscUgSu+DlH4SnTOHon3YcfRcvIy3eZGU1H9dQC07w=; b=NuD79QXPiIDpamCnzpVgpF+Z/rwFjNUgkt28orvyyqiYCcOtiCjLll4jMZJR7GAu+F Sig9HeJSUbTwYmIgdm6QeKXqgdERJF4zvuQO8QhwEILcdTR7HsN6GDN54FmUrUOfcxgA 8Gr6KSfVMOjg/UsrJ6zhu62iy2Ljkmz6zzBzM2IJKOdo6uNgtAqSOxSEtzxa3HaQxWjn R2CGWN4rUKM6fxWIqMyhNJAtf7SoWme89hid/X0T/5xfIgtBNDJpgJ1CIhFvpXfmKa36 Kq0LHenY+FDdat1OVt5mALL/tHhJ4tO5mp05nCbGhlXYtDtYjYS2HhyHdM7vtHLHYCyU Ll5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/KscUgSu+DlH4SnTOHon3YcfRcvIy3eZGU1H9dQC07w=; b=eet9jghre2RhvvlLDiA+cpa/UVe1k1O0VKXwE6rFSBkIKMNO/d2Gn2GgVPw16HByxB 0+DvAyTVpazvFRd1LnFguCPsd1lRJ/sUtgwCIhenprzt0uZbt6AZXvf+KDToxvAVD/0Z LqigS61MWV9rIpChIQnFRZAENHcxRZ2j8x55i63AaLhJMgHGWNI4w63yby0wgkm0LrM4 SDFmy+P6XjxYWqJLVrRq5WrAsc2XkGtP2hhTVFKa8PtDbVui8vRD6oDH9hdZhQmDAb// 4K9fIpC9ODpxvaFDL3TINm7KQeBMkR4Pw1366vt9TV7FT08zEdkS3MM+2OcbGp/YcDlQ vpJg== X-Gm-Message-State: AOAM532TTn0t7PUWYoymouSGU61KNoMjIWmqOB1dwz5Cx8fkUKFglwYa 7GaH3rbpRW7AZn2S6hTGb+FyzLhnCft6SA== X-Received: by 2002:a17:90a:408f:b0:1d1:d1ba:2abb with SMTP id l15-20020a17090a408f00b001d1d1ba2abbmr25819382pjg.152.1652091739545; Mon, 09 May 2022 03:22:19 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.83]) by smtp.gmail.com with ESMTPSA id p17-20020a170902b09100b0015ee985a54csm6688891plr.56.2022.05.09.03.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 03:22:19 -0700 (PDT) From: Like Xu X-Google-Original-From: Like Xu To: Paolo Bonzini Cc: Jim Mattson , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] KVM: x86/pmu: Don't pre-set the pmu->global_ctrl when refreshing Date: Mon, 9 May 2022 18:22:03 +0800 Message-Id: <20220509102204.62389-2-likexu@tencent.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220509102204.62389-1-likexu@tencent.com> References: <20220509102204.62389-1-likexu@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Like Xu Assigning a value to pmu->global_ctrl just to set the value of pmu->global_ctrl_mask in a more readable way leaves a side effect of not conforming to the specification. The global_ctrl is reset to zero on Power up and Reset but keeps unchanged on INIT, like an ordinary MSR. Signed-off-by: Like Xu --- arch/x86/kvm/vmx/pmu_intel.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index cff03baf8921..4d6cc95bc770 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -525,9 +525,8 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) setup_fixed_pmc_eventsel(pmu); } - pmu->global_ctrl = ((1ull << pmu->nr_arch_gp_counters) - 1) | + pmu->global_ctrl_mask = ~((1ull << pmu->nr_arch_gp_counters) - 1) | (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED); - pmu->global_ctrl_mask = ~pmu->global_ctrl; pmu->global_ovf_ctrl_mask = pmu->global_ctrl_mask & ~(MSR_CORE_PERF_GLOBAL_OVF_CTRL_OVF_BUF | MSR_CORE_PERF_GLOBAL_OVF_CTRL_COND_CHGD); -- 2.36.1