* [PATCH v2] arm64: rsi: Correct type of realm_config::hash_algo
@ 2026-10-14 2:43 Kohei Enju
2026-10-14 9:53 ` Catalin Marinas
2026-10-14 11:27 ` Catalin Marinas
0 siblings, 2 replies; 4+ messages in thread
From: Kohei Enju @ 2026-10-14 2:43 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland
Cc: linux-arm-kernel, linux-kernel, Suzuki K Poulose, Sami Mujawar,
Steven Price, Aneesh Kumar K.V (Arm), Kohei Enju
The RMM specification defines RsiHashAlgorithm as an 8-bit type, but
realm_config::hash_algo is currently declared as unsigned long.
There are currently no upstream users of this field, so the mismatch
does not cause an observable issue today. However, a proposed series
adding support for Realm measurement registers uses this field and
exposes a bug caused by the incorrect type.
Change hash_algo to u8 to match the RMM specification while preserving
the size and layout of struct realm_config.
Link: https://lore.kernel.org/all/20260413084957.327661-4-sami.mujawar@arm.com/
Signed-off-by: Kohei Enju <enju.kohei@fujitsu.com>
---
Changes in v2:
- Drop the inner union and padding around hash_algo (Catalin)
- Link to v1: https://patch.msgid.link/20260929-cca-b4-rsi-fix-hash_algo-type-rebase-v1-1-6932cf0aa605@fujitsu.com
---
include/linux/arm-smccc-rsi.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/arm-smccc-rsi.h b/include/linux/arm-smccc-rsi.h
index fddb77986f70..cca881ddfdba 100644
--- a/include/linux/arm-smccc-rsi.h
+++ b/include/linux/arm-smccc-rsi.h
@@ -128,7 +128,7 @@ struct realm_config {
union {
struct {
unsigned long ipa_bits; /* Width of IPA in bits */
- unsigned long hash_algo; /* Hash algorithm */
+ u8 hash_algo; /* Hash algorithm */
};
u8 pad[0x200];
};
---
base-commit: de7b38167981bb92d8e4b2ad8ad9f151ce72a838
change-id: 20260929-cca-b4-rsi-fix-hash_algo-type-rebase-e341cd50d600
Best regards,
--
Kohei Enju <enju.kohei@fujitsu.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] arm64: rsi: Correct type of realm_config::hash_algo
2026-10-14 2:43 [PATCH v2] arm64: rsi: Correct type of realm_config::hash_algo Kohei Enju
@ 2026-10-14 9:53 ` Catalin Marinas
2026-10-14 10:13 ` Suzuki K Poulose
2026-10-14 11:27 ` Catalin Marinas
1 sibling, 1 reply; 4+ messages in thread
From: Catalin Marinas @ 2026-10-14 9:53 UTC (permalink / raw)
To: Kohei Enju
Cc: Will Deacon, Mark Rutland, linux-arm-kernel, linux-kernel,
Suzuki K Poulose, Sami Mujawar, Steven Price,
Aneesh Kumar K.V (Arm)
Thanks for respinning.
On Wed, Oct 14, 2026 at 11:43:23AM +0900, Kohei Enju wrote:
> The RMM specification defines RsiHashAlgorithm as an 8-bit type, but
> realm_config::hash_algo is currently declared as unsigned long.
>
> There are currently no upstream users of this field, so the mismatch
> does not cause an observable issue today. However, a proposed series
> adding support for Realm measurement registers uses this field and
> exposes a bug caused by the incorrect type.
It should be clear the bug is in the RMM implementation. The patch here
is more like defensive programming when the RMM doesn't honour the
interface and zero the unused bits. I can fix the text when applying.
> Change hash_algo to u8 to match the RMM specification while preserving
> the size and layout of struct realm_config.
>
> Link: https://lore.kernel.org/all/20260413084957.327661-4-sami.mujawar@arm.com/
> Signed-off-by: Kohei Enju <enju.kohei@fujitsu.com>
> ---
> Changes in v2:
> - Drop the inner union and padding around hash_algo (Catalin)
> - Link to v1: https://patch.msgid.link/20260929-cca-b4-rsi-fix-hash_algo-type-rebase-v1-1-6932cf0aa605@fujitsu.com
In theory we could add a fixes tag for reference but not worth cc
stable.
Fixes: b880a80011f5 ("arm64: rsi: Add RSI definitions")
> ---
> include/linux/arm-smccc-rsi.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/arm-smccc-rsi.h b/include/linux/arm-smccc-rsi.h
> index fddb77986f70..cca881ddfdba 100644
> --- a/include/linux/arm-smccc-rsi.h
> +++ b/include/linux/arm-smccc-rsi.h
> @@ -128,7 +128,7 @@ struct realm_config {
> union {
> struct {
> unsigned long ipa_bits; /* Width of IPA in bits */
> - unsigned long hash_algo; /* Hash algorithm */
> + u8 hash_algo; /* Hash algorithm */
> };
> u8 pad[0x200];
> };
Suzuki, are you ok with this patch?
As a separate patch, we need to add some static_assert() for the offsets
and the size of the realm_config structure. We do this in
arm-smccc-rmi.h already.
There's a similar realm_params structure in arm-smccc-rmi.h but,
IIUC, the hash_algo there is written by the kernel, so unsigned long is
fine.
--
Catalin
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] arm64: rsi: Correct type of realm_config::hash_algo
2026-10-14 9:53 ` Catalin Marinas
@ 2026-10-14 10:13 ` Suzuki K Poulose
0 siblings, 0 replies; 4+ messages in thread
From: Suzuki K Poulose @ 2026-10-14 10:13 UTC (permalink / raw)
To: Catalin Marinas, Kohei Enju
Cc: Will Deacon, Mark Rutland, linux-arm-kernel, linux-kernel,
Sami Mujawar, Steven Price, Aneesh Kumar K.V (Arm)
On 14/10/2026 10:53, Catalin Marinas wrote:
> Thanks for respinning.
>
> On Wed, Oct 14, 2026 at 11:43:23AM +0900, Kohei Enju wrote:
>> The RMM specification defines RsiHashAlgorithm as an 8-bit type, but
>> realm_config::hash_algo is currently declared as unsigned long.
>>
>> There are currently no upstream users of this field, so the mismatch
>> does not cause an observable issue today. However, a proposed series
>> adding support for Realm measurement registers uses this field and
>> exposes a bug caused by the incorrect type.
>
> It should be clear the bug is in the RMM implementation. The patch here
> is more like defensive programming when the RMM doesn't honour the
> interface and zero the unused bits. I can fix the text when applying.
>
>> Change hash_algo to u8 to match the RMM specification while preserving
>> the size and layout of struct realm_config.
>>
>> Link: https://lore.kernel.org/all/20260413084957.327661-4-sami.mujawar@arm.com/
>> Signed-off-by: Kohei Enju <enju.kohei@fujitsu.com>
>> ---
>> Changes in v2:
>> - Drop the inner union and padding around hash_algo (Catalin)
>> - Link to v1: https://patch.msgid.link/20260929-cca-b4-rsi-fix-hash_algo-type-rebase-v1-1-6932cf0aa605@fujitsu.com
>
> In theory we could add a fixes tag for reference but not worth cc
> stable.
>
> Fixes: b880a80011f5 ("arm64: rsi: Add RSI definitions")
>
>> ---
>> include/linux/arm-smccc-rsi.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/linux/arm-smccc-rsi.h b/include/linux/arm-smccc-rsi.h
>> index fddb77986f70..cca881ddfdba 100644
>> --- a/include/linux/arm-smccc-rsi.h
>> +++ b/include/linux/arm-smccc-rsi.h
>> @@ -128,7 +128,7 @@ struct realm_config {
>> union {
>> struct {
>> unsigned long ipa_bits; /* Width of IPA in bits */
>> - unsigned long hash_algo; /* Hash algorithm */
>> + u8 hash_algo; /* Hash algorithm */
>> };
>> u8 pad[0x200];
>> };
>
> Suzuki, are you ok with this patch?
Yep, looks good to me.
>
> As a separate patch, we need to add some static_assert() for the offsets
> and the size of the realm_config structure. We do this in
> arm-smccc-rmi.h already.
I was going to suggest that and possibly rename the "pad" to sizers. For
now this is fine, but would be good to do that when we add the newer
fields for RSI v2.0
>
> There's a similar realm_params structure in arm-smccc-rmi.h but,
> IIUC, the hash_algo there is written by the kernel, so unsigned long is
> fine.
Correct. It is an input to the RMM.
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Cheers
Suzuki>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] arm64: rsi: Correct type of realm_config::hash_algo
2026-10-14 2:43 [PATCH v2] arm64: rsi: Correct type of realm_config::hash_algo Kohei Enju
2026-10-14 9:53 ` Catalin Marinas
@ 2026-10-14 11:27 ` Catalin Marinas
1 sibling, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2026-10-14 11:27 UTC (permalink / raw)
To: Will Deacon, Mark Rutland, Kohei Enju
Cc: linux-arm-kernel, linux-kernel, Suzuki K Poulose, Sami Mujawar,
Steven Price, Aneesh Kumar K.V (Arm)
On Wed, 14 Oct 2026 11:43:23 +0900, Kohei Enju wrote:
> The RMM specification defines RsiHashAlgorithm as an 8-bit type, but
> realm_config::hash_algo is currently declared as unsigned long.
>
> There are currently no upstream users of this field, so the mismatch
> does not cause an observable issue today. However, a proposed series
> adding support for Realm measurement registers uses this field and
> exposes a bug caused by the incorrect type.
>
> [...]
Applied to arm64 (for-next/smccc-bus), thanks!
[1/1] arm64: rsi: Correct type of realm_config::hash_algo
https://git.kernel.org/arm64/c/c83237edf0ad
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-14 11:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14 2:43 [PATCH v2] arm64: rsi: Correct type of realm_config::hash_algo Kohei Enju
2026-10-14 9:53 ` Catalin Marinas
2026-10-14 10:13 ` Suzuki K Poulose
2026-10-14 11:27 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox