From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 80890C4167B for ; Thu, 30 Nov 2023 13:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:In-Reply-To: Date:From:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=mmH9Dx8Luo6PFqGhzN1uMHKxxZyowtSs98njJhea86s=; b=wK8oxZAC0X+EIe HE2dKlY25ijfvQralyZpIgJIkm+zaD4rw+pn935sLoXr6D0Wm+E/IysKisUT7FsMkr+pDONCndHyQ IBpA5TpoA0Lu0q30xRlfobrAeWAjPRHO2lh3xkViv3yY2ov2DkKcaBJjx/YWqxzIjT8Jy3HzRfkuZ I8VJ9Z9RnsPptYi1qH7a7MOMQz5Rv7R0Csg9z8hIVO5ebAuTjYgSdl6vIRbkU5A14sCGzc8S/M1Pk /63AQ+MJghqv0wTXKN1CfbS4FoBrK0hJrUi2JpW4G+jv3UMqB5Vps5PnzjeefvgAy3f8fPU9bc64F jl++Yqzkc0vIY15WLbJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8hJd-00AzPM-06; Thu, 30 Nov 2023 13:42:53 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8hJX-00AzLx-0m for linux-arm-kernel@lists.infradead.org; Thu, 30 Nov 2023 13:42:49 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 38A78CE23BD; Thu, 30 Nov 2023 13:42:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31A9EC433C7; Thu, 30 Nov 2023 13:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1701351764; bh=J8BVDyKjg2QZUP6y4X1RN6xj+QyPXxvNyALmGqrw/mM=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=kJMApKvpv6J6n4t+3YrQjzNgWB4eyBvEgm6mVvYIqzEIt+cwziQOGrV2P2RueQ7aU 8e5GCZBZpnwVSI9FTJRKZOP1stG4/I+fKvhezE3hU1valvX2YexX4S963TCcN4VvjZ mMBgLAjINJbh4uSAS4hpnzNLS3mwbU7RcX6N2YsQ= Subject: Patch "arm64: cpufeature: Extract capped perfmon fields" has been added to the 4.19-stable tree To: andrew.murray@arm.com,gregkh@linuxfoundation.org,kvmarm@lists.linux.dev,linux-arm-kernel@lists.infradead.org,mark.rutland@arm.com,sashal@kernel.org,suzuki.poulose@arm.com,wanghaibin.wang@huawei.com,will@kernel.org,yuzenghui@huawei.com Cc: From: Date: Thu, 30 Nov 2023 13:42:29 +0000 In-Reply-To: <20231128074633.646-2-yuzenghui@huawei.com> Message-ID: <2023113028-eel-departed-fdbf@gregkh> MIME-Version: 1.0 X-stable: commit X-Patchwork-Hint: ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231130_054247_650094_1D9FDCD1 X-CRM114-Status: GOOD ( 16.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is a note to let you know that I've just added the patch titled arm64: cpufeature: Extract capped perfmon fields to the 4.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: arm64-cpufeature-extract-capped-perfmon-fields.patch and it can be found in the queue-4.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From stable+bounces-2863-greg=kroah.com@vger.kernel.org Tue Nov 28 07:47:05 2023 From: Zenghui Yu Date: Tue, 28 Nov 2023 15:46:32 +0800 Subject: arm64: cpufeature: Extract capped perfmon fields To: , , Cc: , , , , , , , Zenghui Yu Message-ID: <20231128074633.646-2-yuzenghui@huawei.com> From: Andrew Murray commit 8e35aa642ee4dab01b16cc4b2df59d1936f3b3c2 upstream. When emulating ID registers there is often a need to cap the version bits of a feature such that the guest will not use features that the host is not aware of. For example, when KVM mediates access to the PMU by emulating register accesses. Let's add a helper that extracts a performance monitors ID field and caps the version to a given value. Fields that identify the version of the Performance Monitors Extension do not follow the standard ID scheme, and instead follow the scheme described in ARM DDI 0487E.a page D13-2825 "Alternative ID scheme used for the Performance Monitors Extension version". The value 0xF means an IMPLEMENTATION DEFINED PMU is present, and values 0x0-OxE can be treated the same as an unsigned field with 0x0 meaning no PMU is present. Signed-off-by: Andrew Murray Reviewed-by: Suzuki K Poulose [Mark: rework to handle perfmon fields] Signed-off-by: Mark Rutland Signed-off-by: Will Deacon Signed-off-by: Zenghui Yu Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/cpufeature.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -422,6 +422,29 @@ cpuid_feature_extract_unsigned_field(u64 return cpuid_feature_extract_unsigned_field_width(features, field, 4); } +/* + * Fields that identify the version of the Performance Monitors Extension do + * not follow the standard ID scheme. See ARM DDI 0487E.a page D13-2825, + * "Alternative ID scheme used for the Performance Monitors Extension version". + */ +static inline u64 __attribute_const__ +cpuid_feature_cap_perfmon_field(u64 features, int field, u64 cap) +{ + u64 val = cpuid_feature_extract_unsigned_field(features, field); + u64 mask = GENMASK_ULL(field + 3, field); + + /* Treat IMPLEMENTATION DEFINED functionality as unimplemented */ + if (val == 0xf) + val = 0; + + if (val > cap) { + features &= ~mask; + features |= (cap << field) & mask; + } + + return features; +} + static inline u64 arm64_ftr_mask(const struct arm64_ftr_bits *ftrp) { return (u64)GENMASK(ftrp->shift + ftrp->width - 1, ftrp->shift); Patches currently in stable-queue which might be from kroah.com@vger.kernel.org are queue-4.19/arm64-cpufeature-extract-capped-perfmon-fields.patch queue-4.19/kvm-arm64-limit-pmu-version-to-pmuv3-for-armv8.1.patch _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel