From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 143D8256E for ; Fri, 20 Jan 2023 14:18:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B616BC433D2; Fri, 20 Jan 2023 14:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674224302; bh=n6D353jXNQ8pY03yfreES71sj4DU3nnlWLNjK9I9tVY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DDXM9QWcUaRxKuTL/wbQkC4Wx8kOqtT0DiA9Ysj2PoEUEnB/NoZqYKfIgdZP08R8t /sBL4NYhaizklKJINXmh82KL8aYwxPIke3B5bOtJ9233kw1h60XUCL9YpvZyn1q8ay K8JmtZrL0mFCPWXV2zxN5PeGxG0bCYJ0z5vsPJJ+DfP7aBKpfErcxv5u6L3DdD4UEv gt1zUwQ8wEf8D3Yb0aUUSN7Fd3/zelDSn6OID+BoWTd03wPZRxN+yXx9UkS7JY7IyU PTqKOckrvlCTwgpo9XmylLmgH6xNcoKa4LMglkWX4/a8pwHM5dOh2U8rnWGmE7Vze/ c+jvHEkdcfZ8g== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIsDk-003Qx9-5q; Fri, 20 Jan 2023 14:18:20 +0000 Date: Fri, 20 Jan 2023 14:18:19 +0000 Message-ID: <86lelxmgr8.wl-maz@kernel.org> From: Marc Zyngier To: Reiji Watanabe Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Zenghui Yu , Suzuki K Poulose , Paolo Bonzini , Ricardo Koller , Oliver Upton , Jing Zhang , Raghavendra Rao Anata Subject: Re: [PATCH v2 4/8] KVM: arm64: PMU: Disallow userspace to set PMCR.N greater than the host value In-Reply-To: <20230117013542.371944-5-reijiw@google.com> References: <20230117013542.371944-1-reijiw@google.com> <20230117013542.371944-5-reijiw@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: reijiw@google.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, alexandru.elisei@arm.com, yuzenghui@huawei.com, suzuki.poulose@arm.com, pbonzini@redhat.com, ricarkol@google.com, oliver.upton@linux.dev, jingzhangos@google.com, rananta@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Tue, 17 Jan 2023 01:35:38 +0000, Reiji Watanabe wrote: > > Currently, KVM allows userspace to set PMCR_EL0 to any values > with KVM_SET_ONE_REG for a vCPU with PMUv3 configured. > > Disallow userspace to set PMCR_EL0.N to a value that is greater > than the host value (KVM_SET_ONE_REG will fail), as KVM doesn't > support more event counters than the host HW implements. > Although this is an ABI change, this change only affects > userspace setting PMCR_EL0.N to a larger value than the host. > As accesses to unadvertised event counters indices is CONSTRAINED > UNPREDICTABLE behavior, and PMCR_EL0.N was reset to the host value > on every vCPU reset before this series, I can't think of any > use case where a user space would do that. > > Also, ignore writes to read-only bits that are cleared on vCPU reset, > and RES{0,1} bits (including writable bits that KVM doesn't support > yet), as those bits shouldn't be modified (at least with > the current KVM). > > Signed-off-by: Reiji Watanabe Reviewed-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible. 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 DE46CC25B4E for ; Fri, 20 Jan 2023 14:19:51 +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:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JSPeaj3DW3RxsWlsT3iblhZoKHeEQt6ChnMrwlX8u0s=; b=fLMCfMxqyhwUc+ Lnkx5h5SV/WHBdDfj1X/03rVeEy4UaadEfCPY8307wNIjvQbfO1yDzYzfIB1COlNJo/wxVCE6AZlK tHk5adjbg/ptKGiXAJkTUT4sm8weZrLdiYvP2y0PE3U0BZB4vlaSA8OBzpvDgV75qSRnQpVq+gZEK +9SSLGaurF+Zos8VnAyWt8Ln9c69ltL4sqzFuTQsQkjMj5VosIuitZj/F58p2JUBV76m7titEAYXD 5RdHFiI4B3Q/s8dN0xCL1LXwZEVjaqIGJqQ9ndqvrvKCuPHaoBYDedSUPZevEJq3mqcXVXktHfL8Z nWcharC2JIk1AJjXXV8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIsE8-00AfGX-8u; Fri, 20 Jan 2023 14:18:44 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIsDv-00AfB5-Sh for linux-arm-kernel@lists.infradead.org; Fri, 20 Jan 2023 14:18:33 +0000 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 sin.source.kernel.org (Postfix) with ESMTPS id 7340DCE28B6; Fri, 20 Jan 2023 14:18:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B616BC433D2; Fri, 20 Jan 2023 14:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674224302; bh=n6D353jXNQ8pY03yfreES71sj4DU3nnlWLNjK9I9tVY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DDXM9QWcUaRxKuTL/wbQkC4Wx8kOqtT0DiA9Ysj2PoEUEnB/NoZqYKfIgdZP08R8t /sBL4NYhaizklKJINXmh82KL8aYwxPIke3B5bOtJ9233kw1h60XUCL9YpvZyn1q8ay K8JmtZrL0mFCPWXV2zxN5PeGxG0bCYJ0z5vsPJJ+DfP7aBKpfErcxv5u6L3DdD4UEv gt1zUwQ8wEf8D3Yb0aUUSN7Fd3/zelDSn6OID+BoWTd03wPZRxN+yXx9UkS7JY7IyU PTqKOckrvlCTwgpo9XmylLmgH6xNcoKa4LMglkWX4/a8pwHM5dOh2U8rnWGmE7Vze/ c+jvHEkdcfZ8g== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIsDk-003Qx9-5q; Fri, 20 Jan 2023 14:18:20 +0000 Date: Fri, 20 Jan 2023 14:18:19 +0000 Message-ID: <86lelxmgr8.wl-maz@kernel.org> From: Marc Zyngier To: Reiji Watanabe Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Zenghui Yu , Suzuki K Poulose , Paolo Bonzini , Ricardo Koller , Oliver Upton , Jing Zhang , Raghavendra Rao Anata Subject: Re: [PATCH v2 4/8] KVM: arm64: PMU: Disallow userspace to set PMCR.N greater than the host value In-Reply-To: <20230117013542.371944-5-reijiw@google.com> References: <20230117013542.371944-1-reijiw@google.com> <20230117013542.371944-5-reijiw@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: reijiw@google.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, alexandru.elisei@arm.com, yuzenghui@huawei.com, suzuki.poulose@arm.com, pbonzini@redhat.com, ricarkol@google.com, oliver.upton@linux.dev, jingzhangos@google.com, rananta@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230120_061832_367678_C273A32C X-CRM114-Status: GOOD ( 19.36 ) 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 On Tue, 17 Jan 2023 01:35:38 +0000, Reiji Watanabe wrote: > > Currently, KVM allows userspace to set PMCR_EL0 to any values > with KVM_SET_ONE_REG for a vCPU with PMUv3 configured. > > Disallow userspace to set PMCR_EL0.N to a value that is greater > than the host value (KVM_SET_ONE_REG will fail), as KVM doesn't > support more event counters than the host HW implements. > Although this is an ABI change, this change only affects > userspace setting PMCR_EL0.N to a larger value than the host. > As accesses to unadvertised event counters indices is CONSTRAINED > UNPREDICTABLE behavior, and PMCR_EL0.N was reset to the host value > on every vCPU reset before this series, I can't think of any > use case where a user space would do that. > > Also, ignore writes to read-only bits that are cleared on vCPU reset, > and RES{0,1} bits (including writable bits that KVM doesn't support > yet), as those bits shouldn't be modified (at least with > the current KVM). > > Signed-off-by: Reiji Watanabe Reviewed-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel