From: sashiko-bot@kernel.org
To: "Suzuki K Poulose" <suzuki.poulose@arm.com>
Cc: kvm@vger.kernel.org, "Marc Zyngier" <maz@kernel.org>,
"Oliver Upton" <oupton@kernel.org>,
kvmarm@lists.linux.dev
Subject: Re: [PATCH v20 8/9] firmware: arm_rmm: Add wrappers for Realm related RMI commands
Date: Tue, 29 Sep 2026 22:29:36 +0000 [thread overview]
Message-ID: <20260929222936.8344F1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929221623.1342076-9-suzuki.poulose@arm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] arm_rmm: Range-based RMI wrappers drop progress indicator on error, risking GPF
- [High] arm_rmm: SRO cancellation flow aborts prematurely, leaving SRO dangling
--
commit 206f9f5530d9fa5eb129cd6fc6e598e72857683a
Author: Steven Price <steven.price@arm.com>
firmware: arm_rmm: Add wrappers for Realm related RMI commands
This commit introduces static inline wrappers for executing Realm
Management Interface (RMI) commands. These wrappers call into lower-level
SMC execution functions to manage Realm guests.
> diff --git a/include/linux/arm-rmi-cmds.h b/include/linux/arm-rmi-cmds.h
> index 5d005054f3c6c..4f0d6a8006a4a 100644
> --- a/include/linux/arm-rmi-cmds.h
> +++ b/include/linux/arm-rmi-cmds.h
> @@ -104,4 +104,464 @@ static inline bool is_rmi_available(void)
> }
> #endif /* CONFIG_ARM_RMM_RMI */
>
> +
> +/**
> + * rmi_rtt_data_map_init() - Create a mapping at protected IPA, copying contents
> + * from a given non-secure source granule.
> + * @rd: PA of the RD
> + * @data: PA of the target granule mapped in the guest
> + * @ipa: IPA at which the granule @data will be mapped in the guest
> + * @src: PA of the source granule with contents
> + * @flags: RMI_MEASURE_CONTENT if the contents should be measured
> + *
> + * Create a mapping from Protected IPA space to conventional memory, copying
> + * contents from a Non-secure Granule provided by the caller.
> + *
> + * Return: 0 on success, positive RMI result code or negative Linux error code
> + */
> +static inline long rmi_rtt_data_map_init(unsigned long rd, unsigned long data,
> + unsigned long ipa, unsigned long src,
> + unsigned long flags)
> +{
> + struct arm_smccc_1_2_regs regs = {
> + SMC_RMI_RTT_DATA_MAP_INIT, rd, data, ipa, src, flags
> + };
> +
> + return rmi_sro_execute(®s);
[Severity: High]
Does the SRO cancellation flow in the underlying rmi_sro_execute() and
rmi_sro_memxfer_execute() abort prematurely when returning to these wrappers?
In rmi_sro_execute(), the cancellation path does this:
rmi_op_cancel(sro_handle, regs);
cancelled = true;
According to the RMM specification, SMC_RMI_OP_CANCEL returns RMI_SUCCESS when
accepted. Since RMI_SUCCESS is 0, the loop condition in rmi_sro_execute():
while (RMI_RESULT_STATUS(regs->a0) == RMI_INCOMPLETE)
evaluates to false. This breaks out of the loop and skips the mandatory
RMI_OP_CONTINUE calls needed to fully unwind the SRO.
Similarly, in rmi_sro_memxfer_execute(), there is an explicit assertion:
if (WARN_ON_ONCE(RMI_RESULT_STATUS(regs->a0) != RMI_INCOMPLETE))
return ret;
which immediately aborts when rmi_op_cancel() correctly returns RMI_SUCCESS.
Can this leave SRO operations permanently in the CANCELLING state within the
RMM, leading to resource leaks and preventing realms from being properly
destroyed?
[ ... ]
> +static inline long rmi_rtt_data_unmap(unsigned long rd,
> + unsigned long base,
> + unsigned long top,
> + unsigned long flags,
> + unsigned long oaddr,
> + unsigned long *out_top,
> + unsigned long *out_range,
> + unsigned long *out_count)
> +{
> + struct arm_smccc_1_2_regs regs = {
> + SMC_RMI_RTT_DATA_UNMAP, rd, base, top, flags, oaddr
> + };
> + long ret;
> +
> + ret = rmi_sro_execute(®s);
> +
> + if (ret != RMI_SUCCESS)
> + return ret;
> +
> + if (out_top)
> + *out_top = regs.a1;
[Severity: Critical]
If a range-based RMI SRO executes partially and returns an error (such as
RMI_ERROR_INPUT), the architecture specifies that the address of the first
unprocessed granule is returned in regs.a1.
Does this wrapper drop the Top progress marker on failure?
By only populating out_top when ret == RMI_SUCCESS (or by returning early on
failure as seen here), callers might evaluate their progress as zero on
partial failure.
In paths like rmi_delegate_range(), this unpopulated out_top causes out_phys
to evaluate to the start address, which bypasses rmi_undelegate_range().
Could this lead to leaking partially processed granules to the allocator,
causing Granule Protection Faults (GPF) when the host accesses them later?
The same pattern appears in rmi_rtt_data_map(), rmi_rtt_unprot_map(),
rmi_rtt_unprot_unmap(), and rmi_granule_range_delegate().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260929221623.1342076-1-suzuki.poulose@arm.com?part=8
next prev parent reply other threads:[~2026-09-29 22:29 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 22:16 [PATCH v20 0/9] firmware: arm_rmm: Add RMM v2.0 base RMI support Suzuki K Poulose
2026-09-29 22:16 ` [PATCH v20 1/9] firmware: arm_rmm: Add SMC definitions for calling the RMM Suzuki K Poulose
2026-09-30 9:51 ` Catalin Marinas
2026-09-29 22:16 ` [PATCH v20 2/9] firmware: arm_rmm: Check for RMI support at init Suzuki K Poulose
2026-09-29 22:28 ` sashiko-bot
2026-09-30 8:18 ` Suzuki K Poulose
2026-09-30 11:02 ` Catalin Marinas
2026-10-01 6:03 ` Suzuki K Poulose
2026-10-01 8:17 ` Suzuki K Poulose
2026-09-29 22:16 ` [PATCH v20 3/9] firmware: arm_rmm: Configure the RMM with the host's page size Suzuki K Poulose
2026-09-30 11:10 ` Catalin Marinas
2026-09-29 22:16 ` [PATCH v20 4/9] firmware: arm_rmm: Add support for SRO Suzuki K Poulose
2026-09-29 22:30 ` sashiko-bot
2026-09-30 8:45 ` Suzuki K Poulose
2026-09-30 8:46 ` Suzuki K Poulose
2026-09-30 13:15 ` Catalin Marinas
2026-09-30 13:48 ` Suzuki K Poulose
2026-09-29 22:16 ` [PATCH v20 5/9] firmware: arm_rmm: Activate the RMM Suzuki K Poulose
2026-09-30 13:20 ` Catalin Marinas
2026-09-29 22:16 ` [PATCH v20 6/9] firmware: arm_rmm: Ensure the RMM has GPT entries for memory Suzuki K Poulose
2026-09-30 13:39 ` Catalin Marinas
2026-09-30 14:44 ` Sudeep Holla
2026-09-30 15:55 ` Suzuki K Poulose
2026-10-01 8:31 ` Sudeep Holla
2026-09-29 22:16 ` [PATCH v20 7/9] arm64: Block hibernate and kexec while RMM is active Suzuki K Poulose
2026-09-29 22:26 ` sashiko-bot
2026-09-30 9:12 ` Suzuki K Poulose
2026-09-30 15:15 ` Catalin Marinas
2026-09-30 16:06 ` Jonathan Cameron
2026-09-29 22:16 ` [PATCH v20 8/9] firmware: arm_rmm: Add wrappers for Realm related RMI commands Suzuki K Poulose
2026-09-29 22:29 ` sashiko-bot [this message]
2026-09-30 11:12 ` Suzuki K Poulose
2026-09-30 15:51 ` Catalin Marinas
2026-09-29 22:16 ` [PATCH v20 9/9] firmware: arm_rmm: hotplug: Skip memory added to ZONE_MOVABLE Suzuki K Poulose
2026-09-30 12:22 ` David Hildenbrand (Arm)
2026-09-30 12:47 ` Suzuki K Poulose
2026-09-30 15:53 ` Catalin Marinas
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=20260929222936.8344F1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=suzuki.poulose@arm.com \
/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