Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3087951rwb; Mon, 15 Aug 2022 17:50:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR5cN/G+OM6v5wOxuz1TGyMeC3bJo6wgqKtrjKzCXAWRANSeozqFC3ESbM0JBcnL+LcE0B9M X-Received: by 2002:a17:90b:1907:b0:1f3:d6:985c with SMTP id mp7-20020a17090b190700b001f300d6985cmr21651335pjb.46.1660611007317; Mon, 15 Aug 2022 17:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611007; cv=none; d=google.com; s=arc-20160816; b=uD+msfI4ZQFOKS+GIO93Xn+fMMxoUtcK0gaM0dfygX5y08mvHMuO1lBVOx38tZmJwu 2xJvx4WUb+pEqVAeyHKhGhz6cWTYa8UBiZ4z/XH5IEYyjaEI+Z5s2PxIFQR2WAwyqNzW khv3uSNr0HlMYGAKkaqT5E/r7irfW/ikBET4f7azdYbXo9kvXTiRzFp+GI2T4bd5sEjd JPkVSN5+mgysTAgoTKc1xPv8gBw7a4hrM1vQvvm3be4GFsgtp8gwsyAeTMU2OL79kQ1L zdbfNBz2GBkClGRb7doJxIn2/Hhbf90xd3J7za2/zelZVDNgCXcGHuyr2OO8yIFhm4Pk OnEQ== 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=/gZmJm5bJ1J7Ja4T/eKk2auwdG+0547mGD+JQNkdGuQ=; b=zKzxMCiIgKL0rJzde1inp2GELsRYYwNywoyNJKwsLDMO6bnrKFJ9ZZeq49MFSDR8hJ PoYME+OnZyWNc5YfQ/HHrThp8Y2wUfFMTp7DEEyYCSzy4kJUuffvLNNRFqB4Y323VAZp /s/MJfyweZGNBAn09ndDCzJsUJ2hBdNdIlqKVHhk3CJp+rchkpz0wpx5Bf5EDBcuhKch EsO5gb+RMuh37rhYuA5PhN0xtNDEWaEkURuUV72NgqrfmzPAnbZWedhi8k6L65wltvKp Regg88wgDFhDpAPndW0Va32wpnvQoHpl4NeQNJQVvSthRlIinjW/C/HDVtWgNLAUDpBk B7zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dBrpIkvF; 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 k7-20020a170902c40700b001677fa2026asi14223142plk.609.2022.08.15.17.49.57; Mon, 15 Aug 2022 17:50:07 -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=dBrpIkvF; 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 S1353652AbiHOXcK (ORCPT + 99 others); Mon, 15 Aug 2022 19:32:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343945AbiHOX0K (ORCPT ); Mon, 15 Aug 2022 19:26:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BFD8474EF; Mon, 15 Aug 2022 13:06:24 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 27E406069E; Mon, 15 Aug 2022 20:06:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E4CBC433C1; Mon, 15 Aug 2022 20:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593983; bh=kHv0r+d23SoO64trFnjf9d24zrqlp/NQZLqRYFXhOkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dBrpIkvF+ertWXwm//w4waRgLMbddceBeQJgIKz0qhCBYUGmVMzB735QX4jujJ5FI pPFHPazyrl2j5+pzXFDO58FCt6QMGoBntUvOo+EGjU70f57FYmJMBvyqSGLLaRXjp5 wHVWDDWkcjG7dKEHN6eRLeasM/QCiJwjQTfYChs4= 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.18 1038/1095] KVM: VMX: Mark all PERF_GLOBAL_(OVF)_CTRL bits reserved if theres no vPMU Date: Mon, 15 Aug 2022 20:07:17 +0200 Message-Id: <20220815180512.038537874@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 040d598622e3..cd2d0454f8b0 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -488,6 +488,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