Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1860072rwb; Fri, 19 Aug 2022 10:34:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR7/JRuK8XClQgur3d6vGSm3tRlmuq+jkPKhO/EHC3xocq6u6e73R1rZr0ba+z1sCKFtrrf4 X-Received: by 2002:a17:902:a502:b0:172:5f2a:9e35 with SMTP id s2-20020a170902a50200b001725f2a9e35mr8419814plq.79.1660930488943; Fri, 19 Aug 2022 10:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930488; cv=none; d=google.com; s=arc-20160816; b=SoI8pZi/Uh18mLf1pEme11/aROMIGWfSC6WWqD7sFmnpfD+PkBJYCsebvneGAymXhC vh+gfQzXWiJe5oNOYP1wjm4vjy1D0OEwVNqmzFhn6Lo2eywfYscpFh8Fde0lgeimaJI8 us9z5faZeOYQd5iRqVzhnD6w6Qe6o7sXDkaiWvc2CaRdC6i5A16LzndqYTQrHPWE2hh0 XgYirSaf56j1brk4CSr/78WtnOfOYMqBn5+Qxtsg9NQaIS/26+vfYdEs5Sq/5EQqEWme FAM0jDmiPbuRFla7FEeU41OgiJjeIiHGDjEOdgmoxa4nJwK7ZwG7xgd4d2zdYujaeoGS nhnQ== 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=J5g5RpMErNV0u3/VPeJmJgHqMwVCG8sfCaqppMCZUC8=; b=FDb+4tcUS3FLF8QBgqg1thA+Xn/92Vv6Qw8xEYmckpLid7HpDE24Mrg8x6BaOGUxn2 BqKDovqOji/gKHl0gngcQnpA6Ec7A24bdrc8fPsH4IHonJTHxfhpTscz2QEkYvx/YyWp RwuyJne/VULNrg3/qfu/b8Z8kN1fapGvUAzvYX7n3fHDeGucTsicHgd8XuQE7mTYmvyD 3k9IRlQt+ywo0z4mSpR7c1p66JsjHv4wYEsGao8YYnX4g2ExnOsqBX9Q4S/6L2NA1z/8 0tfGAmglfl7Ybcqba8FkJRVA2sYX7ErTVhG2FEZyF5W8dJyJODt+WXw/j1H5/YXV+aPO ESYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LRzOQ3Tj; 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 70-20020a621849000000b0052acc972ec6si3682119pfy.62.2022.08.19.10.34.37; Fri, 19 Aug 2022 10:34:48 -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=LRzOQ3Tj; 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 S1350633AbiHSQw0 (ORCPT + 99 others); Fri, 19 Aug 2022 12:52:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354397AbiHSQuw (ORCPT ); Fri, 19 Aug 2022 12:50:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A42305F6D; Fri, 19 Aug 2022 09:13:49 -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 F2782B8281D; Fri, 19 Aug 2022 16:13:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 292EDC433D6; Fri, 19 Aug 2022 16:13:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925584; bh=dOoWnsvMMVAssrMgIJ0fbTL79FfYAb3Cj9CXtb/C70U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LRzOQ3Tjv9v96M5n4WUEQWYQWqCsaVXTbbHGMsECOLs4jCSmNZ0mQs2UoBnzK+kfl Zy/e4fZxckBrtpbIXpiP19Sqx+CxUIa9Bik+CchuXMqoIt//puznlSpKF1ZMp1stMn qB1Xp6kMdhY8Rwclo3svgARXxoKXJZ2Q4Eijbw8E= 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.10 508/545] KVM: VMX: Mark all PERF_GLOBAL_(OVF)_CTRL bits reserved if theres no vPMU Date: Fri, 19 Aug 2022 17:44:38 +0200 Message-Id: <20220819153852.218541464@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 ea5a7056fdfd..e73378b6f10c 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -335,6 +335,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