Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5831616iob; Tue, 10 May 2022 04:54:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfaAHQOQo9HAwU4GkNUG+7qMnDMcIwomSEPr2Ynxx4SDJjy5Zxda7CTQHbpewSXJbVw5bO X-Received: by 2002:a17:903:41c3:b0:15e:b690:bedc with SMTP id u3-20020a17090341c300b0015eb690bedcmr20600786ple.161.1652183690303; Tue, 10 May 2022 04:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652183690; cv=none; d=google.com; s=arc-20160816; b=bcsgbn8hO4xur9GktleLujeBg9iKReh/ruLDIALN4yNt7Pz+iCU+jZ2Pm1FfXHn4MP xB5blMU7Eig1dGr1YkE+ak1gsB5KDmjDSbQm3fgpo8eSJL9ugGoy8JUFAa8x5SUzgWs9 LbZ6VakgWeGf7S7Kw4U38rLrcmDdki0RP7Y8QlEgVWtvHFpSyFqnvAU+AXs6P2Oq+tM7 I+RmAi2PZHCBxZGT9MkT7mWoKco3TvuvUV0cI7Q6+De/ucmvsYB+5Vp2Q3hhQWyJPZbj j3lVf3SMcVhjT13HjLhTTU8LJDY5aElJ88ySS+czTuA2ZF2TqaXIm8PT52N5xJsb6njt avOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=sKl5pNCwJXU7WqvT/LDmg67nZYMXHrw3gGTNE00KDiM=; b=tFtpdiJEROsG1m8d/gGWKsPD7kAP8IGUReJSoK2bfWOnnzrpmshZGA2PHALlVHMFij G97vXyYHXL4YjcuSMcveh19t160s3oS5Aym+lyiTEDYSynOJr/9rGY0lkfp7Ouqqsvdn W8rX44oQD2rVjmeeLCYI33Bjdq68gut8EB3ejLb0sqQu76hXp8Qft4hlbyj59OJE07K4 3B1eHPdKHYGdGQDYaVmNvMbBUAxfFia2XcgVEtZ/fl4rMbTccg9Is0A1Hhh5nzsbRUBh O0my7PnODqfPvZs4OVFfC6qS1wQYh8LhvY8vrZjghKgSV+jxv84EobyGsOJp8hRP7UqL maZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YePOexK8; 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=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rj9-20020a17090b3e8900b001c6a8e39741si2850633pjb.138.2022.05.10.04.54.34; Tue, 10 May 2022 04:54:50 -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=@gmail.com header.s=20210112 header.b=YePOexK8; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236289AbiEJEl5 (ORCPT + 99 others); Tue, 10 May 2022 00:41:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232590AbiEJEly (ORCPT ); Tue, 10 May 2022 00:41:54 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF8A975214; Mon, 9 May 2022 21:37:58 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id v10so13672436pgl.11; Mon, 09 May 2022 21:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=sKl5pNCwJXU7WqvT/LDmg67nZYMXHrw3gGTNE00KDiM=; b=YePOexK84CQ26EIabu9A5b/dbFhTTZfpTaQ9ubxq1XtqEoLg3vJG5MoS27rmCWDTos QdVx/dA4Gn6rzw8xAYF+fnnaO2t00OFrbbLXBrEVi5toVKZ0x8MFvY8LMcKaeOjy+LlY txxRSWSM/8MSlK4nm2MEXKXNESUA7m9BiT7HbEzuKSA5m4YEUvGIS+QeBI50gKpaP33d 9SLIk8stQK7Gu2mytwvcrQY4TrI8je+YG+dXa0CL0YRwg92qBJu43lC2Mc6Gbs5o+WMe Jv+wl1g0+xdRzyFJZcUpjhNH2bv9IdKSj872B0vVOF4t0pc6WAl5JmaM3MliwGo5uGqw f0SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=sKl5pNCwJXU7WqvT/LDmg67nZYMXHrw3gGTNE00KDiM=; b=uIi5Fjb8wAP6TX2cpsstYm4DyYAe0ZMJ+HRJkP/eMegGBzK1Kh+OhDjaI8Jt+8MsnD Cw+hextevFtn7gNz/6HlXGGfeJIhUymyfq2QLfeyLlgjKYEKhw90pQsfLneMPTVsnoq3 1qUS0Maya1gtMZ/glgU8UkJMJCylSnDdQum2tRAaT82VACJwhHZ58TaAlKU9eNh95XRP 526G6x+RbineqAvJ3YRm9Rnj7EfVoLatb+PgLeT5LXiPVztzrFaJrHThcH8w6fIy71dz FQrsmJQt5K3J/bMjo+OhvcBm+zgTx09SJubZlP265C5RerBpNHuqFYTQ6NI0JyATnLad tVvQ== X-Gm-Message-State: AOAM531eyalcVEIuRmSDUJvZkEsNQ3crCChCDpH4gahUMfDiyM77uudT NDzvLVmKaaEbjurdKH/cOWg= X-Received: by 2002:a63:3e44:0:b0:3c3:dabd:eb03 with SMTP id l65-20020a633e44000000b003c3dabdeb03mr15260729pga.15.1652157478224; Mon, 09 May 2022 21:37:58 -0700 (PDT) Received: from [192.168.255.10] ([203.205.141.83]) by smtp.gmail.com with ESMTPSA id 67-20020a621946000000b0050dc7628190sm9570550pfz.106.2022.05.09.21.37.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 May 2022 21:37:57 -0700 (PDT) Message-ID: Date: Tue, 10 May 2022 12:37:53 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH V2 2/3] KVM: x86/pmu: Don't pre-set the pmu->global_ctrl when refreshing Content-Language: en-US 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 References: <20220509102204.62389-1-likexu@tencent.com> <20220509102204.62389-2-likexu@tencent.com> In-Reply-To: <20220509102204.62389-2-likexu@tencent.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 value is reset to zero on Power up and Reset but keeps unchanged on INIT, like an ordinary MSR. Signed-off-by: Like Xu --- v1 -> v2 Changelog: - Explicitly add parentheses around;  arch/x86/kvm/vmx/pmu_intel.c | 5 ++---  1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index cff03baf8921..7945e97db0af 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) | -        (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED); -    pmu->global_ctrl_mask = ~pmu->global_ctrl; +    pmu->global_ctrl_mask = ~(((1ull << pmu->nr_arch_gp_counters) - 1) | +        (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED));      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