Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3133701rwb; Mon, 15 Aug 2022 19:00:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR5+IqxyBQlpPRYkoYr+hhXTwMA2IfTxcbSBlplVcUVeEG3bphmGXYAjFnFoqJmDeYL4Hpxr X-Received: by 2002:a63:ba17:0:b0:41c:c1c4:bb9e with SMTP id k23-20020a63ba17000000b0041cc1c4bb9emr16296473pgf.531.1660615203220; Mon, 15 Aug 2022 19:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660615203; cv=none; d=google.com; s=arc-20160816; b=nEpYFoDqgoyb64Jgu+bbzz0gSks2dlHXEr2C3JsAj3yr7SAPP/5Qlq6zyIT2YPS0/w 8r7g0CjHKROLdWP6AoW+rnK6IMwHsYj7Ax+aNafGtpSkIUOlmpQyp38zG3+ibxhx7fLH 0xzyIPsUWIBmRjSL0DOFw5qFyDztxeQpxsy+DdEJcg67T6mi+vITsbQZs9wYHA/0+fWs aLJGnwsn5/KlinIluW1v6QPy07PPyowwLxQs+RtRcODQCz15wiy5tEkqQ8hZ/mJ+DKOw wTSlFHOuIbQzJSiW/QiStY4Q0807nVeLkJHfJJA/9xIxETi7/ivD0rjgcP52WNAZK2TI JxAw== 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=OpVk+NtU00HHHmFLhpdCcYDY8p7ZanCKm7bNVxqjlHc=; b=D59Q6+O+beyzsWxoOtN+aHFZkFTLgiIp/QUnVGyQ9UyLrBOwedXIdlO46FKcAEcvR1 eC1XwlDLGoSa6xOOGU3gYYG1i972Id0RmrWQbkDJl5qFpdAFKSTCoo8ZdwGO30xesQSR bZd+mymDRda6YBogR3VbguSWxRFRS745Gb+69ynlyteoZSe3hHDPojueyDH4T+k44/gs w2F2leXRSXqUwH/+oBxf6HZ6cFwQBl3ufE/Du0mtOsEpea/Ky9wM4qrA2E8z7sy7sypi Sj0W0PmuBpwLT1nWGcsaN0tUV2cklPUHML+k0NbPuGSvuRTxFCfqRTemMGppD009eUAB D9dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i3v26fyH; 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 nv7-20020a17090b1b4700b001f2e4b44c23si17444856pjb.177.2022.08.15.18.59.49; Mon, 15 Aug 2022 19:00:03 -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=i3v26fyH; 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 S1348923AbiHPBCZ (ORCPT + 99 others); Mon, 15 Aug 2022 21:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346801AbiHPA5A (ORCPT ); Mon, 15 Aug 2022 20:57:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D0A519F493; Mon, 15 Aug 2022 13:48:36 -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 43BBBB811AF; Mon, 15 Aug 2022 20:48:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B804C433D6; Mon, 15 Aug 2022 20:48:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596513; bh=tnjJvLEswQo6RcWTfnHoUS6qGMU4zJyz3mK2OgwSR8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i3v26fyHUFx/cgkfHvAVnaY5+wZhh+RFEfDfiGTKL62oo8v2Ogy1Kf5BFREMUZQzD bQP+mezud/zV3TWQOAArlQ2MyT4+MY8U8KKaYwxDZj19zBPDnIwCzDqDhS9DCn1pVT 8oPLruct0apW5yDrNBa+/clEIRbCosa2JygA8zU0= 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.19 1103/1157] KVM: VMX: Mark all PERF_GLOBAL_(OVF)_CTRL bits reserved if theres no vPMU Date: Mon, 15 Aug 2022 20:07:39 +0200 Message-Id: <20220815180524.379116481@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 7e72022a00aa..2696b16f9283 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