Re: [PATCH v4 3/3] coco: guest: arm64: Query host IPA-change alignment via RHI

Suzuki K Poulose
2026-04-28T15:23:03Z

On 28/04/2026 14:49, Marc Zyngier wrote:
> On Tue, 28 Apr 2026 13:49:46 +0100,
> Aneesh Kumar K.V <aneesh.kumar@kernel.org> wrote:
>>
>> Marc Zyngier <maz@kernel.org> writes:
>>
>>> On Mon, 27 Apr 2026 07:31:08 +0100,
>>> "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org> wrote:
>>>>
>>>> Add the Realm Host Interface support needed to query host configuration
>>>> from a Realm guest. Define the RHI hostconf SMCs, add rsi_host_call(), and
>>>> use them during Realm initialization to retrieve the host IPA-change
>>>> alignment size.
>>>
>>> I don't understand what "IPA-change" means. What you are after is the
>>> host's sharing granule size.
>>>
>>
>> This is part of the RHI specification, and the call is named
>> RHI_HOSTCONF_GET_IPA_CHANGE_ALIGNMENT. The intent is to determine the
>> alignment requirements for changing IPA attributes (protected vs.
>> unprotected IPA
>
> This really is a terrible name. Why the 'change' part? It doesn't
> change, it is a constant.

Agreed, it was supposed to mean IPA_STATE_CHANGE.

>
> Oh well...
>
> [...]
>

...

>>>> +unsigned long rhi_get_ipa_change_alignment(void)
>>>> +{
>>>> + long ret;
>>>> + unsigned long ipa_change_align;
>>>> +
>>>> + hyp_pagesize_rhicall.imm = 0;
>>>> + hyp_pagesize_rhicall.gprs[0] = RHI_HOSTCONF_VERSION;
>>>> + ret = rsi_host_call(lm_alias(&hyp_pagesize_rhicall));
>>>> + if (ret != RSI_SUCCESS)
>>>> + goto err_out;
>>>> +
>>>> + if (hyp_pagesize_rhicall.gprs[0] != RHI_HOSTCONF_VER_1_0)
>>>> + goto err_out;
>>>> +
>>>> + hyp_pagesize_rhicall.imm = 0;
>>>> + hyp_pagesize_rhicall.gprs[0] = RHI_HOSTCONF_FEATURES;
>>>> + ret = rsi_host_call(lm_alias(&hyp_pagesize_rhicall));
>>>> + if (ret != RSI_SUCCESS)
>>>> + goto err_out;
>>>> +
>>>> + if (!(hyp_pagesize_rhicall.gprs[0] & __RHI_HOSTCONF_GET_IPA_CHANGE_ALIGNMENT))
>>>> + goto err_out;
>>>> +
>>>> + hyp_pagesize_rhicall.imm = 0;
>>>> + hyp_pagesize_rhicall.gprs[0] = RHI_HOSTCONF_GET_IPA_CHANGE_ALIGNMENT;
>>>> + ret = rsi_host_call(lm_alias(&hyp_pagesize_rhicall));
>>>> + if (ret != RSI_SUCCESS)
>>>> + goto err_out;
>>>> +
>>>> + ipa_change_align = hyp_pagesize_rhicall.gprs[0];
>>>> + /* This error needs special handling in the caller */
>>>> + if (ipa_change_align & (SZ_4K - 1))
>>>> + return 0;
>>>> +
>>>> + return ipa_change_align;
>>>> +
>>>> +err_out:
>>>> + /*
>>>> + * For failure condition assume host is built with 4K page size
>>>> + * and hence ipa change alignment can be guest PAGE_SIZE.
>>>> + */
>>>> + return PAGE_SIZE;
>>>> +}
>>>
>>> Why can't this be part of rsi.c? This is an RSI call, and it should be
>>> part of the RSI initialisation.
>>>
>>
>> This is an RHI call as per the specification, hence it has been added to
>> rhi.c.
>
> News flash: this is the Linux kernel, not an ARM spec. We organise
> things based on the logical use, not on the TLA associated with it.
>
> And RHI is implemented in terms of RSI. In rsi.c it goes. We don't
> need this pointless proliferation of helper files that only result in
> equally pointless global symbols.

RHI (Realm Host Interface) is not really the same as RSI. The former is
a service mechanism for Realms with the "Non-secure Hypervisor". And
this single call is just one of the services. There are further more
services that will eventually come up (e.g., Device Assignment, Boot
Sync Protocol, Firmware Activity Log etc).

RSI (to be precise, RSI_HOST_CALL) is the transport to talk to the Host,
as that is the only way for the Realm to reach the Host. So, tbh, it
does make sense to keep this in rhic ?

Suzuki