Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp726717pxb; Tue, 2 Feb 2021 16:51:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxbP6QZSmsno/+oaOsYGD5dkp/jUphqT524ti0Mf4SAxzBEPgCcE05mhbi10MVhSSyI643O X-Received: by 2002:aa7:c88a:: with SMTP id p10mr668127eds.204.1612313466956; Tue, 02 Feb 2021 16:51:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313466; cv=none; d=google.com; s=arc-20160816; b=ZVUok+gSQwhqqW4rLre8wKyppcHFdIyzDS9rki5dsYIPo/OPH9FBfIFa62zpAYwwgc 04+yWmbWuURWCl8sCrQKv4tPYrwCeProU8Vckb8Ug45uQwsexA2bvr2/Q1teQb/Nrvsm lxAgTkc+LfBtlNjd1dhsU1NxYAJ1E1oCJAfRSwPvRNzL/+KcPtSSdhDGPe/zv8kTjnwY W7h8/UNCKr9ipaUT7EWOrBphrFHk4TuN6VPLwCGIT3mKfn+wcnBlZXA0ZZfsvAcboFum Yb4aAagUl8fYl4SiTHZmuexcfSxgaHalD+G4MbzuBgVP46tc7pSWNfimNZG0T8ZdSRII ZQ3g== 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=jjO3W+yluxFKUeebmR7td3wl1nYs6XeBI4drTPaj1zo=; b=WNSq+hJD7HUXozGgw0mvBvIycn73xAvu5VDFR/mU8rFO0TIzir4i+ka+8aQTGoZqdz kEVtvtrAldChms8iHwfCIgMu0qfxthVEuO+AACIyK+dlB7BVMMUFCyjq6PufQZs0ZKDr RkLjR2NjuUoZofJ/dJfnnazXQIXLtjX/LrNy/4tYVdSFXuClPv9z2LBiQuxBS26h+IMn WLCfcioFcBDImnww8vmnC7Ha0nLv3FNRWQX6r2Vhl+8r17fM1XfAOHKpNk8BKnnNwXPx TVntjth8l/YOzHQ6H8eAa4xLwmG+oCjd/v92+Rg8A/I3xQO5KY+7Y7G6K64FsiLg/WjE J08g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p+B69C0b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si228261eds.116.2021.02.02.16.50.42; Tue, 02 Feb 2021 16:51:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p+B69C0b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232768AbhBBUCS (ORCPT + 99 others); Tue, 2 Feb 2021 15:02:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:36548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232953AbhBBNrW (ORCPT ); Tue, 2 Feb 2021 08:47:22 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3413064F94; Tue, 2 Feb 2021 13:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273309; bh=WwJUMvfJcEuTYVj7En++z0rTVSt7vyOWTEyPOIwWW28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p+B69C0bFlGFp6qpJUwDNl0cL1+qf3f9fTIbRszo9TTxaB1oq3vlwEhOoljxCz9IG etNr6OiqlMLXzOC3BMz3lGMcO9VwktUsyEA74WmU8LgrafXCYV7mSGUlDGE6LrxLbi 0QKnzX+lEOudh6uUYemXUF7Btjc8IB3DEdK2cnNI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier Subject: [PATCH 5.10 041/142] KVM: arm64: Filter out v8.1+ events on v8.0 HW Date: Tue, 2 Feb 2021 14:36:44 +0100 Message-Id: <20210202132959.413917011@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit 9529aaa056edc76b3a41df616c71117ebe11e049 upstream. When running on v8.0 HW, make sure we don't try to advertise events in the 0x4000-0x403f range. Cc: stable@vger.kernel.org Fixes: 88865beca9062 ("KVM: arm64: Mask out filtered events in PCMEID{0,1}_EL1") Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20210121105636.1478491-1-maz@kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/pmu-emul.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/arch/arm64/kvm/pmu-emul.c +++ b/arch/arm64/kvm/pmu-emul.c @@ -788,7 +788,7 @@ u64 kvm_pmu_get_pmceid(struct kvm_vcpu * { unsigned long *bmap = vcpu->kvm->arch.pmu_filter; u64 val, mask = 0; - int base, i; + int base, i, nr_events; if (!pmceid1) { val = read_sysreg(pmceid0_el0); @@ -801,13 +801,17 @@ u64 kvm_pmu_get_pmceid(struct kvm_vcpu * if (!bmap) return val; + nr_events = kvm_pmu_event_mask(vcpu->kvm) + 1; + for (i = 0; i < 32; i += 8) { u64 byte; byte = bitmap_get_value8(bmap, base + i); mask |= byte << i; - byte = bitmap_get_value8(bmap, 0x4000 + base + i); - mask |= byte << (32 + i); + if (nr_events >= (0x4000 + base + 32)) { + byte = bitmap_get_value8(bmap, 0x4000 + base + i); + mask |= byte << (32 + i); + } } return val & mask;