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 869F0CD4F3D for ; Thu, 21 May 2026 13:30:49 +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=AUsiEO8XSxSdf1ckEUAcitkd8wAftPJDNELGvlWw98Y=; b=nJ+IU9EbSj/hqiTXeV/vsuDukh xusuldKDjExxFJFTrH6sdchJB3e79Gz0vUb4jzZeyEufhGuXKnIj6b/8xcCF4LhfBCIlUPIhopZSH ig+m9HWhKnzGZniD+BWm9WFiJDyUx3S/lkG7Lj9Fc6GCiDaWNfsulCUNlyClOWK+Y0Wu4n8Z2/B4x OUmkcONw7R/XikQMxusHZ2VhCPnyUO1yf1Sg3MuAc8aNKtx0SuErWAS0ksZ3tlr8eVMiSBx8bGR4A v8o2xfiLSnSIWJ66wAD0lMSmCR/6lsA06goN/h0UePEZBbK/oMjvdtRLRdm+2eFfRxTWVIpnQfAlM ic9FMAyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ3U2-00000007tnj-0heJ; Thu, 21 May 2026 13:30:42 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ3U1-00000007tnS-00Ne for linux-arm-kernel@lists.infradead.org; Thu, 21 May 2026 13:30:41 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 1FE266021D; Thu, 21 May 2026 13:30:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6DC71F000E9; Thu, 21 May 2026 13:30:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779370239; bh=AUsiEO8XSxSdf1ckEUAcitkd8wAftPJDNELGvlWw98Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=Gk2D4M3z2ZHFpy+s2j8iwm/otZXz7Ct24tF2vfnGXYxJbCWYsyBPMtFSytNwg+olJ LPkdC9AFmotm8vh7Dws5HrsR0Y+XrfLxnZ7w89niq+UtHKtexytSzO8lehqRZcwA3v EjOUe7qW13jcnmE3RHQOV2rjQgY9am844deKBRKsEKBJP9lGZZCQzigTOIJ5aCX8i8 023r33GF+pjk/A4mxpP9DrhIMAtQPR8t462EBcnG5IfMeCk3/zdRe8ikmBJOdTYNC1 T8JLfehxLm5R9HshwcfRyaWAU6zSkgB0QQ9/QyS1VW2D9uWwjDPMiiQzA98iOj424L x0T6Yb28X+Yow== 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.98.2) (envelope-from ) id 1wQ3Tx-00000004q63-37EP; Thu, 21 May 2026 13:30:37 +0000 Date: Thu, 21 May 2026 14:30:37 +0100 Message-ID: <86a4tsx536.wl-maz@kernel.org> From: Marc Zyngier To: Steven Price Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Catalin Marinas , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" , Emi Kisanuki , Vishal Annapurve , WeiLin.Chang@arm.com, Lorenzo.Pieralisi2@arm.com Subject: Re: [PATCH v14 07/44] arm64: RMI: Configure the RMM with the host's page size In-Reply-To: <20260513131757.116630-8-steven.price@arm.com> References: <20260513131757.116630-1-steven.price@arm.com> <20260513131757.116630-8-steven.price@arm.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: steven.price@arm.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, catalin.marinas@arm.com, will@kernel.org, james.morse@arm.com, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, joey.gouly@arm.com, alexandru.elisei@arm.com, christoffer.dall@arm.com, tabba@google.com, linux-coco@lists.linux.dev, gankulkarni@os.amperecomputing.com, gshan@redhat.com, sdonthineni@nvidia.com, alpergun@google.com, aneesh.kumar@kernel.org, fj0570is@fujitsu.com, vannapurve@google.com, WeiLin.Chang@arm.com, Lorenzo.Pieralisi2@arm.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 Wed, 13 May 2026 14:17:15 +0100, Steven Price wrote: > > RMM v2.0 brings the ability to set the RMM's granule size. Check the > feature registers and configure the RMM so that it matches the host's > page size. This means that operations can be done with a granulatity > equal to PAGE_SIZE. > > Signed-off-by: Steven Price > --- > Changes since v13: > * Moved out of KVM. > --- > arch/arm64/kernel/rmi.c | 42 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 42 insertions(+) > > diff --git a/arch/arm64/kernel/rmi.c b/arch/arm64/kernel/rmi.c > index 99c1ccc35c11..a14ead5dedda 100644 > --- a/arch/arm64/kernel/rmi.c > +++ b/arch/arm64/kernel/rmi.c > @@ -49,6 +49,45 @@ static int rmi_check_version(void) > return 0; > } > > +static int rmi_configure(void) > +{ > + struct rmm_config *config __free(free_page) = NULL; > + unsigned long ret; > + > + config = (struct rmm_config *)get_zeroed_page(GFP_KERNEL); > + if (!config) > + return -ENOMEM; This is the sort of buggy construct that is highlighted in include/linux/cleanup.h: initialising the object for cleanup with NULL, and only later assigning the expected value. It may not matter here, but it will catch you (or more probably me) in the future. > + > + switch (PAGE_SIZE) { > + case SZ_4K: > + config->rmi_granule_size = RMI_GRANULE_SIZE_4KB; > + break; > + case SZ_16K: > + config->rmi_granule_size = RMI_GRANULE_SIZE_16KB; > + break; > + case SZ_64K: > + config->rmi_granule_size = RMI_GRANULE_SIZE_64KB; > + break; > + default: > + pr_err("Unsupported PAGE_SIZE for RMM\n"); Do you really anticipate PAGE_SIZE being any other value? This is 100% dead code. If you want to be extra cautious, have a BUILD_BUg_ON(). > + return -EINVAL; > + } > + > + ret = rmi_rmm_config_set(virt_to_phys(config)); > + if (ret) { > + pr_err("RMM config set failed\n"); > + return -EINVAL; > + } What is the live cycle of the page when the call succeeds? Is it switched back to the NS PAS and allowed to be freed? > + > + ret = rmi_rmm_activate(); > + if (ret) { > + pr_err("RMM activate failed\n"); > + return -ENXIO; > + } > + > + return 0; > +} > + > static int __init arm64_init_rmi(void) > { > /* Continue without realm support if we can't agree on a version */ > @@ -60,6 +99,9 @@ static int __init arm64_init_rmi(void) > if (WARN_ON(rmi_features(1, &rmm_feat_reg1))) > return 0; > > + if (rmi_configure()) > + return 0; > + > return 0; > } > subsys_initcall(arm64_init_rmi); Thanks, M. -- Without deviation from the norm, progress is not possible.