[PATCH] lib: utils/mpxy: bind channel access to owning domain
Rahul Pathak
rahul.pathak at oss.qualcomm.com
Fri Jul 3 04:19:39 PDT 2026
On Mon, Jun 29, 2026 at 11:47 PM Pawandeep Oza
<pawandeep.oza at oss.qualcomm.com> wrote:
>
> From: Oza Pawandeep <pawandeep.oza at oss.qualcomm.com>
>
> The MPXY framework currently stores registered channels in a global
> list and exposes them to all callers. However, the intended model is
> that each channel is assigned to a single supervisor domain at boot and
> remains owned by that domain for its lifetime.
>
> Introduce fixed owner-domain tracking in struct sbi_mpxy_channel and
> make channel lookup and enumeration domain-aware. A channel is now
> visible only when accessed from its owning domain. Also require the
> owner to be set before channel registration.
>
> This allows MPXY to support systems where the same hart may be reused by
> multiple domains while keeping channel ownership and visibility fixed to
> the domain that owns the service.
>
> Signed-off-by: Oza Pawandeep <pawandeep.oza at oss.qualcomm.com>
>
> diff --git a/include/sbi/sbi_mpxy.h b/include/sbi/sbi_mpxy.h
> index 9da2791e..e7b28527 100644
> --- a/include/sbi/sbi_mpxy.h
> +++ b/include/sbi/sbi_mpxy.h
> @@ -13,6 +13,7 @@
> #include <sbi/sbi_list.h>
>
> struct sbi_scratch;
> +struct sbi_domain;
>
> #define SBI_MPXY_MSGPROTO_VERSION(Major, Minor) ((Major << 16) | Minor)
>
> @@ -91,12 +92,13 @@ struct sbi_mpxy_channel_attrs {
> /* Events State Control */
> u32 eventsstate_ctrl;
> };
> -
> /** A Message proxy channel accessible through SBI interface */
> struct sbi_mpxy_channel {
> /** List head to a set of channels */
> struct sbi_dlist head;
> u32 channel_id;
> +
> + struct sbi_domain *owner_domain;
> struct sbi_mpxy_channel_attrs attrs;
>
> /**
> @@ -181,5 +183,4 @@ int sbi_mpxy_send_message(u32 channel_id, u8 msg_id,
> /** Get Message proxy notification events */
> int sbi_mpxy_get_notification_events(u32 channel_id,
> unsigned long *events_len);
> -
> #endif
> diff --git a/lib/sbi/sbi_mpxy.c b/lib/sbi/sbi_mpxy.c
> index ff5c6ab6..08e10dca 100644
> --- a/lib/sbi/sbi_mpxy.c
> +++ b/lib/sbi/sbi_mpxy.c
> @@ -145,14 +145,23 @@ static inline bool mpxy_is_std_attr(u32 attr_id)
> return (attr_id >> 31) ? false : true;
> }
>
> +static inline bool mpxy_channel_visible(struct sbi_mpxy_channel *channel,
> + struct sbi_domain *dom)
> +{
> + return channel->owner_domain == dom;
> +}
> +
> /** Find channel_id in registered channels list */
> -static struct sbi_mpxy_channel *mpxy_find_channel(u32 channel_id)
> +static struct sbi_mpxy_channel *mpxy_find_channel(u32 channel_id,
> + struct sbi_domain *dom)
> {
> struct sbi_mpxy_channel *channel;
>
> - sbi_list_for_each_entry(channel, &mpxy_channel_list, head)
> - if (channel->channel_id == channel_id)
> + sbi_list_for_each_entry(channel, &mpxy_channel_list, head) {
> + if (channel->channel_id == channel_id &&
> + mpxy_channel_visible(channel, dom))
> return channel;
> + }
>
> return NULL;
> }
> @@ -222,9 +231,12 @@ static void mpxy_std_attrs_init(struct sbi_mpxy_channel *channel)
> int sbi_mpxy_register_channel(struct sbi_mpxy_channel *channel)
> {
> if (!channel)
> + return SBI_EINVAL;
> +
> + if (!channel->owner_domain)
> return SBI_EINVAL;
>
> - if (mpxy_find_channel(channel->channel_id))
> + if (mpxy_find_channel(channel->channel_id, channel->owner_domain))
> return SBI_EALREADY;
>
> /* Initialize channel specific attributes */
> @@ -397,12 +409,15 @@ int sbi_mpxy_get_channel_ids(u32 start_index)
> struct sbi_mpxy_channel *channel;
> u32 channels_count = 0;
> u32 *shmem_base;
> + struct sbi_domain *dom = sbi_domain_thishart_ptr();
>
> if (!mpxy_shmem_enabled(ms))
> return SBI_ERR_NO_SHMEM;
>
> - sbi_list_for_each_entry(channel, &mpxy_channel_list, head)
> - channels_count += 1;
> + sbi_list_for_each_entry(channel, &mpxy_channel_list, head) {
> + if (mpxy_channel_visible(channel, dom))
> + channels_count += 1;
> + }
>
> if (start_index > channels_count)
> return SBI_ERR_INVALID_PARAM;
> @@ -420,6 +435,9 @@ int sbi_mpxy_get_channel_ids(u32 start_index)
>
> // Iterate over the list of channels to get the channel ids.
> sbi_list_for_each_entry(channel, &mpxy_channel_list, head) {
> + if (!mpxy_channel_visible(channel, sbi_domain_thishart_ptr()))
NIT: You can use dom here also instead of sbi_domain_thishart_ptr()
> + continue;
> +
>
Question: Now a domain may have all the channels owned and another may have
none, since MPXY extension will be registered anyways,
sbi_probe_extension(SBI_EXT_MPXY)
will return a present for the domain which does not own any channels.
Is this intended?
Thanks
Rahul
More information about the opensbi
mailing list