Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2925044rwb; Mon, 15 Aug 2022 14:10:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ICy71TSTfUrz5gBVwj8mwS/qz4hIDgvTUYxGDv3sv2a1XyDCzZInNWTAB7D4KHatvX7PB X-Received: by 2002:aa7:d5c8:0:b0:442:b0c5:1fba with SMTP id d8-20020aa7d5c8000000b00442b0c51fbamr16061534eds.237.1660597802085; Mon, 15 Aug 2022 14:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597802; cv=none; d=google.com; s=arc-20160816; b=xyIJqvM+hlPcPajjriaUUlEf733VS7grdwcVl0rbEYWOygrlboVGTfHN9lM8ZS4E/Z Cy6E6o6VXeYyL5WI5mLqihYjUcgnk2GJF4AuRuWtOOyOe/4lvRMGtk85M1UR0nLoKaen YUxqsNJ8kpMrM16T9R0OoO8wu1eR3NieNCrvRo39fmYxd6t2zJwOgDxr5Xhg01KPO7iv TOvc8FycXOoCWneE2AcY86MF9gSzkMJJPpKky6MlOn3Bkm4KTsxRAuEv2Z/+OzeLcyY7 Ode5MM3nYcYLiqg4Bt2gisLvyBGY720e8cB7W0KYLF/YsX0zqpmZW8AkSXRN+PY8YtjV OAGA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pc5/epxzldoH5cA+uCf0TiJuyqVeZ/bpF78PRJZzyNc=; b=P8ewPfZ7acI6PsJ/4ujxZfitJU9Vq5MK8p1FXrarys0BTssyh1iGRizcD7I+Jw6yvY tMQ1IyPUsNuuTRCFmjbKSzEzQTwJlOXtFqJahSkScwVpA9dovUqeak8Vnw7wqWPQsQ0N c2fv+Gdmd5lq/9nzgJ2+W21kn3/CuBJu2vMpKbOcibJcR3MbUwt9NFwtdhJNDZ4QG/jQ ci7DdFku+OuUYrnQo/nctzQuEkyGOWP65J1rYGOvGaqV4dHdxLVLRXiNkNVBwd1LICMJ jZgDgcW5tJlsHEVVWJV+u7yBWul57HOGCeOGwNnX8hSqMK+efqFGwWZVv4Dfy3Aw6aJW 1gMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tr2Wcezs; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb30-20020a1709071c9e00b00718c7b4cbeasi7140255ejc.991.2022.08.15.14.09.36; Mon, 15 Aug 2022 14:10:02 -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=@linuxfoundation.org header.s=korg header.b=tr2Wcezs; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240654AbiHOT75 (ORCPT + 99 others); Mon, 15 Aug 2022 15:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345778AbiHOT6s (ORCPT ); Mon, 15 Aug 2022 15:58:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A3A7969F; Mon, 15 Aug 2022 11:53:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 21381B810A1; Mon, 15 Aug 2022 18:53:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55E58C433D6; Mon, 15 Aug 2022 18:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589584; bh=9jS12HDIWC0T9azvy4cCObcvIYGFP6TeIXYbDNOHqdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tr2WcezsiqjsC1vb2Fcir6NyEbrZ4djtBTy3k3cJVx4I2n+U3BO+vxtRPOKaoovlt GO4zvlyriDWCxLB2r5xQ5CZej15MaYr0cGO7qgM7/sYK7ai+sY/qyJFY2Tc6CkPvAI BSuIP2W2OPNd+gRhet48lc91ZCi/kFJMUno7HC6g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 733/779] KVM: VMX: Mark all PERF_GLOBAL_(OVF)_CTRL bits reserved if theres no vPMU Date: Mon, 15 Aug 2022 20:06:17 +0200 Message-Id: <20220815180408.784807511@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: Sean Christopherson [ Upstream commit 93255bf92939d948bc86d81c6bb70bb0fecc5db1 ] Mark all MSR_CORE_PERF_GLOBAL_CTRL and MSR_CORE_PERF_GLOBAL_OVF_CTRL bits as reserved if there is no guest vPMU. The nVMX VM-Entry consistency checks do not check for a valid vPMU prior to consuming the masks via kvm_valid_perf_global_ctrl(), i.e. may incorrectly allow a non-zero mask to be loaded via VM-Enter or VM-Exit (well, attempted to be loaded, the actual MSR load will be rejected by intel_is_valid_msr()). Fixes: f5132b01386b ("KVM: Expose a version 2 architectural PMU to a guests") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20220722224409.1336532-3-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx/pmu_intel.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index 9aee082deee9..c66edf93e4a8 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -481,6 +481,8 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) pmu->version = 0; pmu->reserved_bits = 0xffffffff00200000ull; pmu->raw_event_mask = X86_RAW_EVENT_MASK; + pmu->global_ctrl_mask = ~0ull; + pmu->global_ovf_ctrl_mask = ~0ull; pmu->fixed_ctr_ctrl_mask = ~0ull; entry = kvm_find_cpuid_entry(vcpu, 0xa, 0); -- 2.35.1