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 4606B1549E for ; Thu, 17 Aug 2023 15:53:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6A9BC433C8; Thu, 17 Aug 2023 15:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692287589; bh=ePXnfxRXUddVzI3u0tJHF8AuA23aR9K0higvYkyBCvQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UQtZQAlJ4JGiz4IhxhQb5YLJwnWQHCzW0Rl159gwLZNzqAGw7OCbZg0ZaEjdbr5mE leUuNax9c9s55u1mkv91DXirYSyuZbq4w8ezDYYThf8LEH4gc/oIeYFTLCVaoDLgSG stkVYgf3PiQnKUvJgm6FsEvomy0GZxHD+DpCyLCLizE0AzLL6VGt+xhSwLTvJkqzIS egP7xl9qEaueEzT7Q1jSleh97QSbJgrHNtRZMWhV29aN+Dm55ciQtbGgZB9L1t9OuR 6eiZiIZ8MubHbZrBbfyBhpuxoX858pFVLtxRifxoN0GakjGykGta+xYRUZiV05AXGJ mCZWB0Jhn6UFA== 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 1qWfJ5-005j6p-FM; Thu, 17 Aug 2023 16:53:07 +0100 Date: Thu, 17 Aug 2023 16:53:07 +0100 Message-ID: <86pm3lfyxo.wl-maz@kernel.org> From: Marc Zyngier To: Jing Zhang Cc: KVM , KVMARM , ARMLinux , Oliver Upton , Will Deacon , Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , Fuad Tabba , Reiji Watanabe , Raghavendra Rao Ananta , Suraj Jitindar Singh , Cornelia Huck Subject: Re: [PATCH v8 07/11] KVM: arm64: Enable writable for ID_AA64PFR0_EL1 In-Reply-To: <20230807162210.2528230-8-jingzhangos@google.com> References: <20230807162210.2528230-1-jingzhangos@google.com> <20230807162210.2528230-8-jingzhangos@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: jingzhangos@google.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev, will@kernel.org, pbonzini@redhat.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, tabba@google.com, reijiw@google.com, rananta@google.com, surajjs@amazon.com, cohuck@redhat.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 07 Aug 2023 17:22:05 +0100, Jing Zhang wrote: > > All valid fields in ID_AA64PFR0_EL1 are writable from usrespace > with this change. userspace > > Signed-off-by: Jing Zhang > --- > arch/arm64/kvm/sys_regs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 879004fd37e5..392613bec560 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -2041,7 +2041,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { > .get_user = get_id_reg, > .set_user = set_id_reg, > .reset = read_sanitised_id_aa64pfr0_el1, > - .val = ID_AA64PFR0_EL1_CSV2_MASK | ID_AA64PFR0_EL1_CSV3_MASK, }, > + .val = GENMASK(63, 0), }, > ID_SANITISED(ID_AA64PFR1_EL1), > ID_UNALLOCATED(4,2), > ID_UNALLOCATED(4,3), Same remark as the previous patch. What makes it legal to make *everything* writable? For example, we don't expose the AMU. And yet you are telling userspace "sure, go ahead". Userspace will then try and restore *something*, and will eventually crap itself because the kernel won't allow it. Why do we bother describing the writable fields if userspace can't write to them? 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 E75F5C3DA46 for ; Thu, 17 Aug 2023 15:53:42 +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=GQMB9BbetWIjolujWolLl2da3vElfA4K0cOjCbzw4Kc=; b=ZuIge4SRSM/Bth ocCRDGh9PIX2XlfPpL05OEwtoUcJBoJ2AAls0O7P74mjCWMuvd/INAtEsVKqJq1biSF5XsyWwTJH4 d6RBMPDp9GxY1JHtBHXQmpFU0wXFXvhoUSv0RT0AigW38SQ5JH/Mo3+F+YM51YPI6Im0JR3vBSU3s QScghA2XBuIWlv0BkBE7MBIAs2dutZhPn9bOz6FjRfjPVe2lu/hQJeUCN59zcQE1O17FXaYPhKeUj t8HKyl1mnKRfPlRa2W0c9gmrZL0ORAmZxOKPMUSOd/1nAJplNqKgLZC5h5alvdjqysODIY0/xERoO 0yrz85y423APBtSKYdqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWfJD-006j1u-2d; Thu, 17 Aug 2023 15:53:15 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWfJ9-006j1a-1L for linux-arm-kernel@lists.infradead.org; Thu, 17 Aug 2023 15:53:12 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6AC21636EB; Thu, 17 Aug 2023 15:53:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6A9BC433C8; Thu, 17 Aug 2023 15:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692287589; bh=ePXnfxRXUddVzI3u0tJHF8AuA23aR9K0higvYkyBCvQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UQtZQAlJ4JGiz4IhxhQb5YLJwnWQHCzW0Rl159gwLZNzqAGw7OCbZg0ZaEjdbr5mE leUuNax9c9s55u1mkv91DXirYSyuZbq4w8ezDYYThf8LEH4gc/oIeYFTLCVaoDLgSG stkVYgf3PiQnKUvJgm6FsEvomy0GZxHD+DpCyLCLizE0AzLL6VGt+xhSwLTvJkqzIS egP7xl9qEaueEzT7Q1jSleh97QSbJgrHNtRZMWhV29aN+Dm55ciQtbGgZB9L1t9OuR 6eiZiIZ8MubHbZrBbfyBhpuxoX858pFVLtxRifxoN0GakjGykGta+xYRUZiV05AXGJ mCZWB0Jhn6UFA== 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 1qWfJ5-005j6p-FM; Thu, 17 Aug 2023 16:53:07 +0100 Date: Thu, 17 Aug 2023 16:53:07 +0100 Message-ID: <86pm3lfyxo.wl-maz@kernel.org> From: Marc Zyngier To: Jing Zhang Cc: KVM , KVMARM , ARMLinux , Oliver Upton , Will Deacon , Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , Fuad Tabba , Reiji Watanabe , Raghavendra Rao Ananta , Suraj Jitindar Singh , Cornelia Huck Subject: Re: [PATCH v8 07/11] KVM: arm64: Enable writable for ID_AA64PFR0_EL1 In-Reply-To: <20230807162210.2528230-8-jingzhangos@google.com> References: <20230807162210.2528230-1-jingzhangos@google.com> <20230807162210.2528230-8-jingzhangos@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: jingzhangos@google.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev, will@kernel.org, pbonzini@redhat.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, tabba@google.com, reijiw@google.com, rananta@google.com, surajjs@amazon.com, cohuck@redhat.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-20230817_085311_544900_F3E07850 X-CRM114-Status: GOOD ( 20.15 ) 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 Mon, 07 Aug 2023 17:22:05 +0100, Jing Zhang wrote: > > All valid fields in ID_AA64PFR0_EL1 are writable from usrespace > with this change. userspace > > Signed-off-by: Jing Zhang > --- > arch/arm64/kvm/sys_regs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 879004fd37e5..392613bec560 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -2041,7 +2041,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { > .get_user = get_id_reg, > .set_user = set_id_reg, > .reset = read_sanitised_id_aa64pfr0_el1, > - .val = ID_AA64PFR0_EL1_CSV2_MASK | ID_AA64PFR0_EL1_CSV3_MASK, }, > + .val = GENMASK(63, 0), }, > ID_SANITISED(ID_AA64PFR1_EL1), > ID_UNALLOCATED(4,2), > ID_UNALLOCATED(4,3), Same remark as the previous patch. What makes it legal to make *everything* writable? For example, we don't expose the AMU. And yet you are telling userspace "sure, go ahead". Userspace will then try and restore *something*, and will eventually crap itself because the kernel won't allow it. Why do we bother describing the writable fields if userspace can't write to them? 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