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 4C59ACD5BAF for ; Thu, 21 May 2026 22:37:02 +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=ZN6PmRWB1mzgzHKDnocJ7gQXcrIehimjvbS4LaNBAp8=; b=4I0qFD37PpG0caZXBGMg1O9dkM WycqV5IuJbEBXgQvHDT+5JEKmWgHvJqB9I1N0Mu0b26ig4dpll4pXzKn4qh87DtkP3WXYSKqtn6NM /Lt2PbVMjwWlEYQXTww1w1fhIrCTu2hwtWv0bmEg9O4GtPtOISrINbr5hNIAnSbev+RoRRdGL6aw+ IZztXMN4sGv1r+BGRTRHP5xkUqfyCF8BxhBHcQ4MBMoQgwrNWdfdh21uDXjXuxUxaQz5sFg1w3RJI l/GTsOyO2NnBTX0dgbI7i63JjCWxerrqDl2u0Bd5TjbzVVCx8/PpXy3CP0KSblcaF7gN6bDwrS/Q5 cljH1dzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQC0b-00000009Exj-01KD; Thu, 21 May 2026 22:36:53 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQC0Y-00000009ExD-3O6R for linux-arm-kernel@lists.infradead.org; Thu, 21 May 2026 22:36:52 +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 28EA32A31; Thu, 21 May 2026 15:36:43 -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 987C33F85F; Thu, 21 May 2026 15:36:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1779403008; bh=iWi+rVGWRaT+t7ioXWfrl6ICbml7cqaQG7eYSudc3vY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=W+Ic6z9S90OLpjZazd5fKEp50HHCNAKpeQz+VTrRIXEpk4ThW57c4RECTEvQzpM0L /7385wq1ns9VH98WBApu5y2aaAivObGeC6hPIhcsCe3/bkbQemX93kPACTaB1UyWRj Kzn8TtmAYaIsSEdZDnTq4ji6CZ4a9xbP1tUw8Tsc= Message-ID: <2f5fec66-979a-4302-aa39-03ee8d9c82da@arm.com> Date: Thu, 21 May 2026 23:36:38 +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: Gavin Shan , Steven Price , kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Catalin Marinas , Marc Zyngier , 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 , 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> <45a953a8-6edc-45c3-b5bd-17f14397ab89@redhat.com> From: Suzuki K Poulose In-Reply-To: <45a953a8-6edc-45c3-b5bd-17f14397ab89@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260521_153651_017200_102B1576 X-CRM114-Status: GOOD ( 25.84 ) 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 01:51, Gavin Shan wrote: > Hi Steven, > > On 5/13/26 11:17 PM, 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; >> + >> +    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"); >> +        return -EINVAL; >> +    } >> + >> +    ret = rmi_rmm_config_set(virt_to_phys(config)); >> +    if (ret) { >> +        pr_err("RMM config set failed\n"); >> +        return -EINVAL; >> +    } >> + > > Looking at branch 'topics/rmm-v2.0-poc_2' of RMM implementation, the > granule size > is fixed to be 4KB at present. I'm not sure if I have looked into > correct RMM > implementation, but 'topics/rmm-v2.0-poc_2' is recommended one in the cover > letter. > You are right. The tf-RMM only supports 4KB. The policy at the KVM host is to set the Linux PAGE_SIZE for the GRANULE_SIZE (at least for now). If the RMM doesn't support the PAGE_SIZE, we don't support the RMM. > Besides, there has checks in the handler of the RMI command to make sure > that > struct rmm_config::tracking_region_size to be 1GB, indicated by zero. It > maybe > worthy to set it before call to rmi_rmm_config_set(). > >     config.tracking_region_size = 0; /* 1GB */ Thanks, this explicit initialisation is missing, though in effect the value is 0'd. Also, we can't really say 1GB here, because the driver should work for an RMM capable of 64K. So, instead, may be we could : /* See the definition of RMM_GRANULE_TRACKING_SIZE */ config.tracking_region_size = 0; Suzuki >     ret = rmi_rmm_config_set(virt_to_phys(config)); > > >> +    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, > Gavin >