From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: sashiko-reviews@lists.linux.dev
Cc: Oliver Upton <oupton@kernel.org>,
kvm@vger.kernel.org, Marc Zyngier <maz@kernel.org>,
kvmarm@lists.linux.dev
Subject: Re: [PATCH v17 5/7] firmware: arm_rmm: Activate the RMM
Date: Mon, 7 Sep 2026 17:16:17 +0100 [thread overview]
Message-ID: <66090600-8206-4573-a031-af50ec9a3618@arm.com> (raw)
In-Reply-To: <20260907101737.856E11F00A3A@smtp.kernel.org>
On 07/09/2026 11:17, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The macro `rmi_sro_memxfer_cmd` uses a large compound literal to initialize the SRO state, forcing the compiler to allocate a ~2.2KB temporary object on the stack.
> --
>
> commit c773f8f03d602782404ec2f0103977a8f86f3b3e
> Author: Steven Price <steven.price@arm.com>
>
> firmware: arm_rmm: Activate the RMM
>
> Activate the RMM after the basic configuration. This is a memory transferring,
> stateful operation.
>
>> diff --git a/drivers/firmware/arm_rmm/rmi.c b/drivers/firmware/arm_rmm/rmi.c
>> index 42c973c3a98bb..d969c8738efde 100644
>> --- a/drivers/firmware/arm_rmm/rmi.c
>> +++ b/drivers/firmware/arm_rmm/rmi.c
> [ ... ]
>> @@ -656,7 +657,19 @@ static int __init arm64_init_rmi(void)
>> if (ret)
>> return ret;
>>
>> - return 0;
>> + /* Activate the RMM */
>> + sro = kmalloc_obj(*sro);
>> + if (!sro)
>> + return -ENOMEM;
>> +
>> + ret = rmi_rmm_activate(sro);
>
> [Severity: Medium]
> Does expanding rmi_rmm_activate() here cause stack frame bloat in
> arm64_init_rmi()?
>
> Looking at include/linux/arm-rmi-cmds.h, rmi_rmm_activate() calls the
> rmi_sro_memxfer_cmd() macro, which evaluates a large compound literal:
>
> *__sro = (struct rmi_sro_state){ .regs = {__VA_ARGS__} };
>
> This forces the compiler to allocate a ~2.2KB temporary object on the stack
> before copying it to the heap object, which defeats the purpose of the
> explicit heap allocation above. Does this risk exceeding the typical
> CONFIG_FRAME_WARN threshold of 2048 bytes on arm64 and lead to build
> warnings?
I have switched to using memset() to initialise the sro and then
initialize the regs from the __VA_ARGS__
diff --git a/include/linux/arm-rmi-cmds.h b/include/linux/arm-rmi-cmds.h
index 47c31808b8a7e..1e4dd02124ebd 100644
--- a/include/linux/arm-rmi-cmds.h
+++ b/include/linux/arm-rmi-cmds.h
@@ -8,6 +8,7 @@
#include <linux/arm-smccc-rmi.h>
#include <linux/bug.h>
+#include <linux/string.h>
#include <linux/types.h>
#define RMI_MAX_ADDR_LIST 256
@@ -43,7 +44,8 @@ long rmi_sro_execute(struct arm_smccc_1_2_regs *regs);
#define rmi_sro_memxfer_cmd(sro, gfp, ...) ({ \
struct rmi_sro_state *__sro = (sro); \
- *__sro = (struct rmi_sro_state){ .regs = {__VA_ARGS__} }; \
+ memset(__sro, 0, sizeof(*__sro)); \
+ __sro->regs = (struct arm_smccc_1_2_regs){ __VA_ARGS__ }; \
long __ret = rmi_sro_memxfer_execute(__sro, gfp); \
rmi_sro_free(__sro); \
__ret; \
Cheers
Suzuki
>
>> + if (ret) {
>> + pr_err("RMM activate failed\n");
>> + ret = ret < 0 ? ret : -ENXIO;
>> + }
>> +
>> + kfree(sro);
>> + return ret;
>> }
>
next prev parent reply other threads:[~2026-09-07 16:16 UTC|newest]
Thread overview: 45+ 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-11 15:29 ` 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 [this message]
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
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=66090600-8206-4573-a031-af50ec9a3618@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