From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org, Oliver Upton <oupton@kernel.org>,
Marc Zyngier <maz@kernel.org>,
kvmarm@lists.linux.dev
Subject: Re: [PATCH v17 7/7] firmware: arm_rmm: Add wrappers for Realm related RMI commands
Date: Mon, 7 Sep 2026 13:20:47 +0100 [thread overview]
Message-ID: <8ac9a39f-d54a-4a97-b44d-aeaad944f374@arm.com> (raw)
In-Reply-To: <20260907101022.DDDFD1F00A3A@smtp.kernel.org>
On 07/09/2026 11:10, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] RMI wrapper functions silently discard output registers on SMC call errors, preventing error recovery and leaking memory.
> --
>
> commit a6c85c25d264d328a0bb8014d88418e614ccef39
> Author: Steven Price <steven.price@arm.com>
>
> firmware: arm_rmm: Add wrappers for Realm related RMI commands
>
> Introduce wrappers for the RMI functions needed for creating and managing
> realm guests. This will be used by the KVM to manage the Realms.
>
>> diff --git a/include/linux/arm-rmi-cmds.h b/include/linux/arm-rmi-cmds.h
>> --- a/include/linux/arm-rmi-cmds.h
>> +++ b/include/linux/arm-rmi-cmds.h
>
> [ ... ]
>
>> +static inline long rmi_rtt_data_map(unsigned long rd,
> [ ... ]
>> +{
> [ ... ]
>> + ret = rmi_sro_execute(®s);
>> +
>> + if (ret == RMI_SUCCESS && out_top)
>> + *out_top = regs.a1;
>
> [Severity: High]
> If the RMM returns an error like RMI_ERROR_RTT partway through, does this
> discard the intermediate progress in regs.a1 by gating it on RMI_SUCCESS?
>
> If out_top is lost, it seems KVM wouldn't know where the operation stopped,
> making proper error recovery or partial mapping cleanup impossible.
>
> [ ... ]
>
>> +static inline long rmi_rtt_data_unmap(unsigned long rd,
> [ ... ]
>> +{
> [ ... ]
>> + ret = rmi_sro_execute(®s);
>> +
>> + if (ret == RMI_SUCCESS) {
>> + if (out_top)
>> + *out_top = regs.a1;
>> + if (out_range)
>> + *out_range = regs.a2;
>> + if (out_count)
>> + *out_count = regs.a3;
>> + }
>
> [Severity: High]
> Can this lead to a leak of physical pages?
>
> When an error occurs (e.g., RMI_ERROR_RTT due to state conflicts), the RMM
> populates the output registers with the number of successfully unmapped
> pages. Because this is gated behind RMI_SUCCESS, losing out_count means KVM
> loses track of how many physical pages were written to the output address
> list.
>
The output parameters are only valid when the result is RMI_SUCCESS as
described by the success conditions.
> [ ... ]
>
>> +static inline long rmi_rtt_destroy(unsigned long rd,
> [ ... ]
>> +{
> [ ... ]
>> + long ret = rmi_sro_execute(®s);
>> +
>> + if (ret == RMI_SUCCESS) {
>> + if (out_rtt)
>> + *out_rtt = regs.a1;
>> + if (out_top)
>> + *out_top = regs.a2;
>> + }
>
> [Severity: High]
> Does discarding these outputs on error prevent diagnosing the destruction
> failure?
>
> If an RMI_ERROR_RTT occurs, the live IPA location is returned in the output
> registers, but it looks like it gets dropped here since the return code is
> not RMI_SUCCESS.
No, the RMM only returns the out_top when the error is RMI_SUCCESS.
>
> [ ... ]
>
>> +static inline long rmi_rtt_unprot_unmap(unsigned long rd,
> [ ... ]
>> +{
> [ ... ]
>> + long ret = rmi_sro_execute(®s);
>> +
>> + if (ret == RMI_SUCCESS) {
>> + if (out_top)
>> + *out_top = regs.a1;
>> + if (out_range)
>> + *out_range = regs.a2;
>> + if (out_count)
>> + *out_count = regs.a3;
>> + }
>
> [Severity: High]
> Similar to the data unmap wrapper above, does dropping out_count on a
> non-success return code leak physical pages for unprotected memory?
>
Same here.
Suzuki
next prev parent reply other threads:[~2026-09-07 12:20 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 9:59 [PATCH v17 0/7] firmware: arm_rmm: Add RMM v2.0 base RMI support Suzuki K Poulose
2026-09-07 9:59 ` [PATCH v17 1/7] firmware: arm_rmm: Add SMC definitions for calling the RMM Suzuki K Poulose
2026-09-08 6:19 ` Gavin Shan
2026-09-08 10:37 ` Suzuki K Poulose
2026-09-08 22:41 ` Gavin Shan
2026-09-09 8:39 ` Suzuki K Poulose
2026-09-10 9:47 ` Gavin Shan
2026-09-10 9:54 ` Suzuki K Poulose
2026-09-07 9:59 ` [PATCH v17 2/7] firmware: arm_rmm: Check for RMI support at init Suzuki K Poulose
2026-09-08 6:46 ` Gavin Shan
2026-09-08 9:49 ` Suzuki K Poulose
2026-09-07 9:59 ` [PATCH v17 3/7] firmware: arm_rmm: Configure the RMM with the host's page size Suzuki K Poulose
2026-09-07 10:14 ` sashiko-bot
2026-09-07 12:02 ` Suzuki K Poulose
2026-09-07 22:40 ` Gavin Shan
2026-09-08 9:58 ` Suzuki K Poulose
2026-09-08 7:04 ` Gavin Shan
2026-09-08 8:00 ` Kohei Enju
2026-09-08 10:59 ` Gavin Shan
2026-09-09 2:01 ` Kohei Enju
2026-09-08 10:43 ` Suzuki K Poulose
2026-09-07 9:59 ` [PATCH v17 4/7] firmware: arm_rmm: Add support for SRO Suzuki K Poulose
2026-09-07 10:14 ` sashiko-bot
2026-09-08 22:10 ` Suzuki K Poulose
2026-09-09 4:10 ` Gavin Shan
2026-09-10 9:51 ` Suzuki K Poulose
2026-09-07 9:59 ` [PATCH v17 5/7] firmware: arm_rmm: Activate the RMM Suzuki K Poulose
2026-09-07 10:17 ` sashiko-bot
2026-09-07 16:16 ` Suzuki K Poulose
2026-09-09 4:29 ` Gavin Shan
2026-09-09 8:25 ` Suzuki K Poulose
2026-09-07 9:59 ` [PATCH v17 6/7] firmware: arm_rmm: Ensure the RMM has GPT entries for memory Suzuki K Poulose
2026-09-09 6:40 ` Gavin Shan
2026-09-09 8:33 ` Suzuki K Poulose
2026-09-07 9:59 ` [PATCH v17 7/7] firmware: arm_rmm: Add wrappers for Realm related RMI commands Suzuki K Poulose
2026-09-07 10:10 ` sashiko-bot
2026-09-07 12:20 ` Suzuki K Poulose [this message]
2026-09-09 7:15 ` Gavin Shan
2026-09-09 8:55 ` Suzuki K Poulose
2026-09-08 4:09 ` [PATCH v17 0/7] firmware: arm_rmm: Add RMM v2.0 base RMI support Kohei Enju
2026-09-08 5:46 ` Suzuki K Poulose
2026-09-08 7:30 ` Kohei Enju
2026-09-09 10:52 ` Gavin Shan
2026-09-10 4:51 ` Kohei Enju
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=8ac9a39f-d54a-4a97-b44d-aeaad944f374@arm.com \
--to=suzuki.poulose@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