Subject: Re: [PATCH v14 07/44] arm64: RMI: Configure the RMM with the host's page size

From: Suzuki K Poulose <[email-masked]>
Date: Thu, 21 May 2026 23:36:38 +0100

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 <[email-masked]>
>> ---
>> 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
>