From: Steven Price <steven.price@arm.com>
To: sashiko-reviews@lists.linux.dev
Cc: Oliver Upton <oupton@kernel.org>,
kvm@vger.kernel.org, kvmarm@lists.linux.dev,
Marc Zyngier <maz@kernel.org>
Subject: Re: [PATCH 6/6] firmware: arm_rmm: Ensure the RMM has GPT entries for memory
Date: Mon, 20 Jul 2026 16:03:11 +0100 [thread overview]
Message-ID: <f63c0275-1c26-49dd-a046-459728de6a39@arm.com> (raw)
In-Reply-To: <20260715154738.5339F1F000E9@smtp.kernel.org>
On 15/07/2026 16:47, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
> - [Medium] Host-side memory allocation failures are incorrectly parsed as RMI firmware errors.
> - [Low] Empty or sub-page memblock regions are expanded into 1GB GPT allocations.
> - [Low] Missing trailing newline in success message.
> --
>
> --- Patch [6]: [PATCH 6/6] firmware: arm_rmm: Ensure the RMM has GPT entries for memory ---
> commit dfe33cca468028175b080bbcfc671eba1604716c
> Author: Steven Price <steven.price@arm.com>
>
> firmware: arm_rmm: Ensure the RMM has GPT entries for memory
>
> This commit configures RMM memory tracking to ensure DRAM regions are
> tracked at FINE granularity. It statically allocates tracking granules and
> creates Level 1 GPT tables for these regions when needed.
>
>> diff --git a/drivers/firmware/arm_rmm/rmi.c b/drivers/firmware/arm_rmm/rmi.c
>> index 6a9f61760fd77..d0c083bdf251f 100644
>> --- a/drivers/firmware/arm_rmm/rmi.c
>> +++ b/drivers/firmware/arm_rmm/rmi.c
>
> [ ... ]
>
>> @@ -604,6 +606,89 @@ static int rmi_configure(void)
>> return 0;
>> }
>>
>> +/*
>> + * Make sure the area is tracked by RMM at FINE granularity.
>> + * We do not support changing the tracking yet.
>> + */
>
> [ ... ]
>
>> +static int rmi_create_gpts(phys_addr_t start, phys_addr_t end)
>> +{
>> + struct rmi_sro_state *sro;
>> + unsigned long l0gpt_sz;
>> +
>> + sro = kmalloc_obj(*sro, GFP_KERNEL);
>> + if (!sro)
>> + return -ENOMEM;
>> +
>> + l0gpt_sz = 1UL << (30 + FIELD_GET(RMI_FEATURE_REGISTER_1_L0GPTSZ,
>> + rmi_feat_reg(1)));
>> + start = ALIGN_DOWN(start, l0gpt_sz);
>> + end = ALIGN(end, l0gpt_sz);
>
> [Severity: Low]
> If a memblock region is smaller than a page or misaligned, is it possible
> for the initial start physical address to be greater than or equal to end?
I don't understand how start >= end would work. That seems like a very
broken memblock.
> If so, applying ALIGN_DOWN() to start and ALIGN() to end could force
> start < end to evaluate to true for an originally empty region. Could this
> cause the loop to inadvertently execute and allocate an L1 GPT table for a
> 1GB block that contains no full pages?
A misaligned/small memblock would be very weird. But we'd still want a
L1 GPT table to cover it.
>> +
>> + while (start < end) {
>> + int ret = rmi_gpt_l1_create(start, sro, GFP_KERNEL);
>> +
>> + /*
>> + * Make sure the L1 GPT tables are created for the region.
>> + * RMI_ERROR_GPT indicates the L1 table already exists.
>> + */
>> + if (ret != RMI_SUCCESS && RMI_RETURN_STATUS(ret) != RMI_ERROR_GPT) {
>
> [Severity: Medium]
> Since rmi_gpt_l1_create() can return a standard negative POSIX error code
> like -ENOMEM from a host page allocation failure, does passing it to
> RMI_RETURN_STATUS(ret) misinterpret the error?
Note that rmi_gpt_l1_create() only returns "a standard negative POSIX
error code" in the WARN_ON path. In the more usual case of out-of-memory
then the operation is cancelled and the results of the cancelled
operation is returned.
> For -ENOMEM (-12), the macro extracts the lower bits (244), which won't
> match RMI_ERROR_GPT. Could this result in printing a misleading "GPT Level1
> table missing" error when the real issue is an out-of-memory condition in
> the host kernel?
Yes, although this is only after the WARN. I'm not sure it's really
worth fixing the error message for this corner case.
>> + pr_err("GPT Level1 table missing for %llx\n", start);
>> + kfree(sro);
>> + return -ENOMEM;
>> + }
>> + start += l0gpt_sz;
>> + }
>> +
>> + kfree(sro);
>> + return 0;
>> +}
>
> [ ... ]
>
>> @@ -621,6 +706,13 @@ static int __init arm64_init_rmi(void)
>> if (ret)
>> return ret;
>>
>> + ret = rmi_init_metadata();
>> + if (ret)
>> + return ret;
>> +
>> + arm64_rmi_is_available = true;
>> + pr_info("RMI configured");
>
> [Severity: Low]
> This isn't a bug, but should this include a trailing newline ("\n") to
> prevent subsequent kernel logs from being appended to the same line?
This is actually a bug - yes that newline is missing.
>> +
>> return 0;
>> }
>>
>
prev parent reply other threads:[~2026-07-20 15:03 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 14:27 [PATCH 0/6] firmware: arm_rmm: Add RMM v2.0 support Steven Price
2026-07-15 14:27 ` [PATCH 1/6] firmware: arm_rmm: Add SMC definitions for calling the RMM Steven Price
2026-07-15 14:38 ` sashiko-bot
2026-07-16 10:59 ` Steven Price
2026-07-23 7:11 ` Kohei Enju
2026-07-29 16:02 ` Steven Price
2026-07-15 14:27 ` [PATCH 2/6] firmware: arm_rmm: Add wrappers for direct RMI calls Steven Price
2026-07-15 14:49 ` sashiko-bot
2026-07-16 14:28 ` Steven Price
2026-08-06 11:53 ` Will Deacon
2026-08-17 14:56 ` Steven Price
2026-07-15 14:27 ` [PATCH 3/6] firmware: arm_rmm: Check for RMI support at init Steven Price
2026-07-15 15:06 ` sashiko-bot
2026-07-16 14:28 ` Steven Price
2026-07-31 10:46 ` Suzuki K Poulose
2026-07-15 14:27 ` [PATCH 4/6] firmware: arm_rmm: Configure the RMM with the host's page size Steven Price
2026-07-15 15:18 ` sashiko-bot
2026-07-16 15:41 ` Steven Price
2026-07-31 13:21 ` Suzuki K Poulose
2026-07-15 14:27 ` [PATCH 5/6] firmware: arm_rmm: Add support for SRO Steven Price
2026-07-15 15:29 ` sashiko-bot
2026-07-16 16:04 ` Steven Price
2026-07-31 18:25 ` Suzuki K Poulose
2026-07-15 14:27 ` [PATCH 6/6] firmware: arm_rmm: Ensure the RMM has GPT entries for memory Steven Price
2026-07-15 15:47 ` sashiko-bot
2026-07-20 15:03 ` Steven Price [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f63c0275-1c26-49dd-a046-459728de6a39@arm.com \
--to=steven.price@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox