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 AB6EFC07CA9 for ; Thu, 30 Nov 2023 13:43:29 +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=q6B8GaDhTH8xrWGpef5MrY4JTkmTA7J7FTuFS/313j8=; b=svK3oKieyx2Je7 okjigWkofnsyC9NGPJSCqN9pWD3ST/yFRCs6euU58reOFiCo+vocuy9CkONjSqu6/huh4QOQVq0zv c9X0RkkYMiSwlwq2WhOE7mwHE/AibFMsY0bRS5sLsOiosUrlPLpc0/7+BS9ohyN9WNs9peyEVxYUs C6hsyzSZ9zJriheJ6wY9LeZLxlnD/JQJv0tflsmhpeSDuH0A1/a1hfrxPqrGWFwTUyQqbOhFofOJ5 0LWKhp5mnn8py3hI4pRuPx/FShKg0y/ikcyBcxiMON3cTyReLEi6cfYfV93D7gHaCtY9fQmHZf+ai vh/IgsmNAuztcTU3dM/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8hJo-00AzUY-2H; Thu, 30 Nov 2023 13:43:04 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8hJg-00AzR3-21 for linux-arm-kernel@lists.infradead.org; Thu, 30 Nov 2023 13:42:58 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 39422B84452; Thu, 30 Nov 2023 13:42:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A3A7C433CA; Thu, 30 Nov 2023 13:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1701351774; bh=50B8ImhgoUGNb+dUNsqUimewe4oID5dKKZxerHWS8q8=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=F7cNcvi/GBNx5iX5sX8mkOT2f6AiOBehG4MVs08l3v4Et6gmEHUGAxzAstB9T9G1k qdpLBM0rW5+J2znaIRQGoxWM+7wuGrCFBIY+QCfw88wpncmKxD2xPrpnLaJM575Lp9 abAi3113SLNsCNsvLcGr9DgaL7hC2aOM03L26SrE= Subject: Patch "arm64: cpufeature: Extract capped perfmon fields" has been added to the 5.4-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:41 +0000 In-Reply-To: <20231128115725.964-2-yuzenghui@huawei.com> Message-ID: <2023113041-circle-rebuttal-198c@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_054256_963317_C100A129 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 5.4-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-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From stable+bounces-2888-greg=kroah.com@vger.kernel.org Tue Nov 28 11:57:47 2023 From: Zenghui Yu Date: Tue, 28 Nov 2023 19:57:24 +0800 Subject: arm64: cpufeature: Extract capped perfmon fields To: , , Cc: , , , , , , , Zenghui Yu Message-ID: <20231128115725.964-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 @@ -449,6 +449,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-5.4/arm64-cpufeature-extract-capped-perfmon-fields.patch queue-5.4/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