From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org, Oliver Upton <oupton@kernel.org>,
kvmarm@lists.linux.dev, Marc Zyngier <maz@kernel.org>
Subject: Re: [PATCH v18 1/7] firmware: arm_rmm: Add SMC definitions for calling the RMM
Date: Sat, 12 Sep 2026 10:04:00 +0100 [thread overview]
Message-ID: <a50e377b-4ba0-4d08-8176-e5003d44223c@arm.com> (raw)
In-Reply-To: <20260912084556.2B68E1F00893@smtp.kernel.org>
On 12/09/2026 09:45, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] Usage of GENMASK and BIT macros for 64-bit masks causes Undefined Behavior on 32-bit architectures
RMM is only supported for ARM64. But, given this is a header file, I
could fix them to ULL
Cheers
Suzuki
> --
>
> commit cfdd0e3f2fb70671ab2dbb64f06ca56946732456
> Author: Steven Price <steven.price@arm.com>
>
> firmware: arm_rmm: Add SMC definitions for calling the RMM
>
> This commit introduces SMC definitions for calling the Realm Management Monitor
> (RMM) from the host. The definitions are based on the ARM RMM specification
> version 2.0-bet3.
>
> Link: https://developer.arm.com/documentation/den0137/2-0bet3/
>
>> diff --git a/include/linux/arm-smccc-rmi.h b/include/linux/arm-smccc-rmi.h
>> new file mode 100644
>> index 0000000000000..214d6228dfc22
>> --- /dev/null
>> +++ b/include/linux/arm-smccc-rmi.h
>
> [ ... ]
>
>> +#define RMI_ADDR_TYPE_NONE 0
>> +#define RMI_ADDR_TYPE_SINGLE 1
>> +#define RMI_ADDR_TYPE_LIST 2
>> +
>> +#define RMI_ADDR_RANGE_STATE_MASK GENMASK(63, 62)
>> +#define RMI_ADDR_RANGE_ADDR_MASK GENMASK(51, PAGE_SHIFT)
>
> [Severity: Low]
> Can the use of GENMASK for bit positions >= 32 cause undefined behavior on
> 32-bit architectures?
>
> The GENMASK macro evaluates to unsigned long, which is 32 bits wide on 32-bit
> architectures. Shifting by 32 or more results in truncation or an
> out-of-bounds shift.
>
> Would it be better to use GENMASK_ULL here for these 64-bit masks?
>
>> +#define RMI_ADDR_RANGE_COUNT_MASK GENMASK(PAGE_SHIFT - 1, 2)
>> +#define RMI_ADDR_RANGE_BLOCK_SIZE_MASK GENMASK(1, 0)
>
> [ ... ]
>
>> +enum rmi_ripas {
>> + RMI_EMPTY = 0,
>> + RMI_RAM = 1,
>> + RMI_DESTROYED = 2,
>> + RMI_DEV = 3,
>> +};
>> +
>> +#define RMI_NO_MEASURE_CONTENT 0
>> +#define RMI_MEASURE_CONTENT 1
>> +
>> +#define RMI_FEATURE_REGISTER_0_S2OASZ GENMASK(40, 33)
>> +#define RMI_FEATURE_REGISTER_0_L0GPT_BLOCK_DELEGATE BIT(32)
>
> [Severity: Low]
> Similarly, will this GENMASK and BIT usage trigger the same undefined behavior
> when evaluated as unsigned long? Using GENMASK_ULL and BIT_ULL might avoid this.
>
>> +#define RMI_FEATURE_REGISTER_0_PMU_NUM_CTRS GENMASK(31, 27)
>> +#define RMI_FEATURE_REGISTER_0_PMU BIT(26)
>
> [ ... ]
>
>> +#define RMI_FEATURE_REGISTER_3_RTT_S2AP_INDIRECT BIT(6)
>> +#define RMI_FEATURE_REGISTER_3_RTT_PLANE GENMASK(5, 4)
>> +#define RMI_FEATURE_REGISTER_3_MAX_NUM_AUX_PLANES GENMASK(3, 0)
>> +
>> +#define RMI_FEATURE_REGISTER_4_MEC_COUNT GENMASK(63, 0)
>
> [Severity: Low]
> Could GENMASK_ULL(63, 0) be used here as well?
>
>> +
>> +#define RMI_MEM_CATEGORY_CONVENTIONAL 0
>> +#define RMI_MEM_CATEGORY_DEV_NCOH 1
>
next prev parent reply other threads:[~2026-09-12 9:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 8:36 [PATCH v18 0/7] firmware: arm_rmm: Add RMM v2.0 base RMI support Suzuki K Poulose
2026-09-12 8:36 ` [PATCH v18 1/7] firmware: arm_rmm: Add SMC definitions for calling the RMM Suzuki K Poulose
2026-09-12 8:45 ` sashiko-bot
2026-09-12 9:04 ` Suzuki K Poulose [this message]
2026-09-12 8:36 ` [PATCH v18 2/7] firmware: arm_rmm: Check for RMI support at init Suzuki K Poulose
2026-09-12 8:36 ` [PATCH v18 3/7] firmware: arm_rmm: Configure the RMM with the host's page size Suzuki K Poulose
2026-09-12 8:36 ` [PATCH v18 4/7] firmware: arm_rmm: Add support for SRO Suzuki K Poulose
2026-09-12 8:48 ` sashiko-bot
2026-09-12 10:28 ` Suzuki K Poulose
2026-09-12 8:36 ` [PATCH v18 5/7] firmware: arm_rmm: Activate the RMM Suzuki K Poulose
2026-09-12 8:36 ` [PATCH v18 6/7] firmware: arm_rmm: Ensure the RMM has GPT entries for memory Suzuki K Poulose
2026-09-12 8:46 ` sashiko-bot
2026-09-13 6:59 ` Suzuki K Poulose
2026-09-12 8:36 ` [PATCH v18 7/7] firmware: arm_rmm: Add wrappers for Realm related RMI commands Suzuki K Poulose
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=a50e377b-4ba0-4d08-8176-e5003d44223c@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