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 002DACA0EE8 for ; Sun, 14 Sep 2025 20:28:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OWMH7QKFrmOpM3PC2q24WTKS7xGZo6kSzJtOAukfP24=; b=SDOE1u2M3Gfgl5pHHZ8H86VhT+ bYgevvR92aH+KDyWLevNmGuPKVpaoC+oUi+pqJj2V129i2f5IfdD71zrnQ0InXWeN0O3y1DQamdJF C0aRB85EHJ/WbvzvFV1XnrmVudSIl1UZZ1nwgLR3oy8E9MbV2682/WNwZ27CImNZuMqG2hvfgTW7k Iu/UlKsZNgoq6H3ZTOpglTb9VXkeHYyCHUbFU3YLfrMKYMD4pG0bJo/cOFJo6qVOeGGCn29gjUzvX gOBNoXdbgQGvqf6Y9DEEkBS61G6F+8lDUNX/601mZ2I+Qx6TU9w9pOGY8vL1GqmcYa6Wr9VWlOmFd QZam5fpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uxtKN-000000029Fk-0dNh; Sun, 14 Sep 2025 20:28:03 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uxtKL-000000029FS-2Sm2 for linux-arm-kernel@lists.infradead.org; Sun, 14 Sep 2025 20:28:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 8EE7C601AA; Sun, 14 Sep 2025 20:28:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1D97C4CEF0; Sun, 14 Sep 2025 20:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757881679; bh=D0n5ETJv3R8O+fczQgdPp8EqHieV5Ctrcdn9KrkWRvw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=I7A+ekkFx+MmNjmDBQ0/KTElBERoYXwPeRTCLw4lLb6/DXdWxSWu5bXicPO0Obz7T 9sIYTiTC6Znl6EdSXH/w86jAyWRE0yDOpFNz21ofxAbWdNi7PAnl/qHgLqUURJqOLk G13O9a44Deh6CbSPRWdyQ2FOij1zVuCyBJ5RXuLdXC30lORs6vBSCOpY+pYcOetscs MvdlQMuDEpFAGmITJ50TbaxBOtXBM6VGpkJsA6hTP6NKxCZ0UKYYEpzF5Rnl1LBO/N Gk/tj7Rim9T3DwlvaI2GoPY3WmCIdP+lcmQYnU+xrUhXqHtZVJK/XH1EasFhRzZxk+ D80BVzfZMPP7Q== Received: from sofa.misterjones.org ([185.219.108.64] helo=lobster-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uxtKH-00000006Ar2-1oaU; Sun, 14 Sep 2025 20:27:57 +0000 Date: Sun, 14 Sep 2025 21:27:57 +0100 Message-ID: <878qigzsmq.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: Jinqian Yang , yuzenghui@huawei.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, liuyonglong@huawei.com, wangzhou1@hisilicon.com Subject: Re: [PATCH v3 1/2] KVM: arm64: Make ID_AA64MMFR1_EL1.{HCX, TWED} writable from userspace In-Reply-To: References: <20250911114621.3724469-1-yangjinqian1@huawei.com> <20250911114621.3724469-2-yangjinqian1@huawei.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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) 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: oliver.upton@linux.dev, yangjinqian1@huawei.com, yuzenghui@huawei.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, liuyonglong@huawei.com, wangzhou1@hisilicon.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 12 Sep 2025 22:51:58 +0100, Oliver Upton wrote: > > Hi Jinqian, > > On Thu, Sep 11, 2025 at 07:46:20PM +0800, Jinqian Yang wrote: > > Allow userspace to downgrade {HCX, TWED} in ID_AA64MMFR1_EL1. Userspace can > > only change the value from high to low. > > > > Signed-off-by: Jinqian Yang > > --- > > arch/arm64/kvm/sys_regs.c | 2 -- > > 1 file changed, 2 deletions(-) > > > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > > index 82ffb3b3b3cf..db49beb8804e 100644 > > --- a/arch/arm64/kvm/sys_regs.c > > +++ b/arch/arm64/kvm/sys_regs.c > > @@ -3002,8 +3002,6 @@ static const struct sys_reg_desc sys_reg_descs[] = { > > ~(ID_AA64MMFR0_EL1_RES0 | > > ID_AA64MMFR0_EL1_ASIDBITS)), > > ID_WRITABLE(ID_AA64MMFR1_EL1, ~(ID_AA64MMFR1_EL1_RES0 | > > - ID_AA64MMFR1_EL1_HCX | > > - ID_AA64MMFR1_EL1_TWED | > > ID_AA64MMFR1_EL1_XNX | > > ID_AA64MMFR1_EL1_VH | > > ID_AA64MMFR1_EL1_VMIDBits)), > > I still have a bone to pick with Marc regarding the NV implications of > this :) Attaching conversation below. Although for non-nested this LGTM. > > On Tue, Sep 09, 2025 at 11:10:28AM +0100, Marc Zyngier wrote: > > My concern here is the transitive implications of FEAT_HCX being > > disabled: a quick look shows about 20 features that depend on > > FEAT_HCX, and we don't really track this. I can probably generate the > > dependency graph, but that's not going to be small. Or very useful. > > > > However, we should be able to let FEAT_HCX being disabled without > > problem if the downgrading is limited to non-EL2 VMs. Same thing for > > FEAT_VHE. > > > > What do you think? > > So I'm a bit worried about making fields sometimes-writable, it creates > a very confusing UAPI behavior. On top of that, our writable masks are > currently static. > > What if we treat the entire register as RES0 in this case? It seems to > be consistent with all the underlying bits / features being NI. A > mis-described VM isn't long for this world anyway (e.g. FEAT_SCTLR2 && !FEAT_HCX) > and in that case I'd prefer an approach that keeps the KVM code as > simple as possible. I've pushed out a branch implementing this[1], though it hasn't had much testing yet. I'll post it once I've convinced myself that this is sane enough. M. [1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/el2-res0 -- Jazz isn't dead. It just smells funny.