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 705EDCD4F3D for ; Thu, 21 May 2026 14:53:39 +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-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Juk66Sz35VNxc/6Jlyv3GV4OkJUfAwENoRGJOWGzSFY=; b=IqcyzRpjzDjj0xq+zELYUzsbg2 /mnwzxDG6tvAGC1KBiS4RDjreFL5EZtQzI2pqaoN1pSTzJ5EWY7AKu0sz4Dod4O52UGFd8hunw+Hl osruFA25lE6C6DLXp3MKhCv+m4w3IP4sHK9XgBWT6ZbYau/WwZHgtGEOYdOOuDk6j1BzrQ4SnMjLi onmAHLDqjk/OaDc+88y+uanzhzGzdNZEEe1tEqPsLb+ys76TrFFmnlosf346cTu0YaPMRwS58xfzX 6ZITrCYm8Y70px43/vodJjgG0xY+LpSOkOO3Z7D0kuD8/4s0FSgC98umyQHfUlFXZArbZzpmqhsOl kpbLahxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ4m7-00000008A23-3D4H; Thu, 21 May 2026 14:53:27 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ4m6-00000008A0r-17de for linux-arm-kernel@bombadil.infradead.org; Thu, 21 May 2026 14:53:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=Juk66Sz35VNxc/6Jlyv3GV4OkJUfAwENoRGJOWGzSFY=; b=bwv5CIIfdpvTt+m9pCgfSHUqcg ZchrJ1ZZk9pKdQJymij5nD4b/fOtB500adZWQEnQs+roTLW7UB8WxTL8QFlYRXQqhrtX/H1h04jIW J4PfFjiEY23NPmxCBCMVTRa9VdJrEDxXDkNIe0SSl+UVTdIRX8iMqUDOFTUarP8FCnKV7qYPGgiol Fo1U7cvmGTgrVqCQ7O28bIojaVXK/Nf2xj9//koy1KAmfdm3qqFUJv+IxOxO805pCekPJt3CwQc31 kJ51UPVF3rfD+FTu0FvuiPZkACwVGqceY8WVjXZwV+7Y/HKB/D91bIttcHyt5zWq1t4qOFia23Al6 mn3QYUqw==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ4m2-00000002A8Q-1XH9 for linux-arm-kernel@lists.infradead.org; Thu, 21 May 2026 14:53:24 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E1B0B3AEC; Thu, 21 May 2026 07:53:14 -0700 (PDT) Received: from [10.57.22.108] (unknown [10.57.22.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A5E9B3F85F; Thu, 21 May 2026 07:53:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1779375200; bh=3Z31DGiiKxp5n0Ca0LQiOFBY3d8tuirIjtCjZrB4whg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=p2hKMPO2BFpLvMd5O6Z2ApC9Y/J7Rjghz9A1PMS3sklCCxLKzm/F3xmW9mqzqVA2Q DlBijEnuK1PG3+xt0m3TohT84x2FZ/NKtJ9jqA5QikxWGuUDZDVfgNno1MRtjgl37h R+p/IOEzU9BnKAmmL3ouK8VbMWX2cUkA8tnJ4lYw= Message-ID: <318df626-9af1-4db2-90db-d7e0aef4c7ff@arm.com> Date: Thu, 21 May 2026 15:53:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v14 07/44] arm64: RMI: Configure the RMM with the host's page size Content-Language: en-GB To: Marc Zyngier , Steven Price Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Catalin Marinas , Will Deacon , James Morse , Oliver Upton , 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 References: <20260513131757.116630-1-steven.price@arm.com> <20260513131757.116630-8-steven.price@arm.com> <86a4tsx536.wl-maz@kernel.org> From: Suzuki K Poulose In-Reply-To: <86a4tsx536.wl-maz@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260521_155323_105604_F5DB86A3 X-CRM114-Status: GOOD ( 22.86 ) 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 21/05/2026 14:30, Marc Zyngier wrote: > 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? It always remains in the NS world. We relay some information in the NS PAS page, which the RMM consumes. The checks are performed on the values consumed by the RMM. Kind regards Suzuki > >> + >> + 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. >