[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v8 1/5] xen/domctl: chain SCI handling before IOMMU in assign_device domctl


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>
  • Date: Mon, 26 Jan 2026 14:31:01 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zneMmoVMj1X1i3l98nRNSZVy0dfs74YhMs6wew+SDrc=; b=FU0qACP68eJVTLxjREhh6dK/tZPQNVdrGi/xfPVCfot1F0lx6DDtlvbD2BUsJxwk49PmoO1v0pU5AirXCdChhmfeRZc5m8RZI3czh4BbiZpIYgDBUVmDULX761+qgTVc1YGhTVwuiIvnksi4i//Ic9yOhgztLJaP4LmIbyl94bVF9dBcfnpE9g4xMv4Dp4medDC2e03SBIggEvSqJpa1niqWD564zOcUC/+2ThxWpKGT5MfJSYd5InxYlchUlqM5/mtT/kF4GT6GnlJyCcpQsBHg4qMEP2+bMcbPKXXD0C9KMufV/1RIaC2ht1FjBok30cKf/EVvAjqsYMDChgfNoA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Oc9xzUZvDl+O3xQhyYCCWMGqUt/VRMthQmWlM7NzsIkrbrEj+9kr4DNjwJoSq5s/VaF4nNK1aIEe46qPkJJAh03UG6qwvKAgc8uKvoyVBHscGlbk6wJT6vJ2XIhewfa6ZZl8LSszUef/uYj6HRjqy7fyq6H3DcKacsdAnp6b34RdZVzF+BiIVGlphy7CesHXTOsOTaRVrHHKXIPMDcb/20h8tGM1mCBkD2FNTYmxqKG9n4aG490BrcuG92EILeziAhEiXRFQ2oxihDgcx27tYeoZX6HfVNBYK6YTJ9xk5u+Z7szYD5CPVM7LxYfRNooch33vVckgyfuc4tzgL5LXRw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Grygorii Strashko <grygorii_strashko@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 26 Jan 2026 14:31:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHciwXk/uoXY0zPp0qUEySvGl6zVLVd0bMAgAZ1k4CAAAIlgIAAQWcA
  • Thread-topic: [PATCH v8 1/5] xen/domctl: chain SCI handling before IOMMU in assign_device domctl


On 26/01/2026 12:37, Jan Beulich wrote:
> On 26.01.2026 11:29, Oleksii Moisieiev wrote:
>> Hi Jan,
>> Thank you for your comments.
>>
>> On 22/01/2026 09:51, Jan Beulich wrote:
>>> On 21.01.2026 19:43, Oleksii Moisieiev wrote:
>>>> --- a/xen/arch/arm/firmware/sci.c
>>>> +++ b/xen/arch/arm/firmware/sci.c
>>>> @@ -126,6 +126,41 @@ int sci_assign_dt_device(struct domain *d, struct 
>>>> dt_device_node *dev)
>>>>        return 0;
>>>>    }
>>>>    
>>>> +int sci_do_domctl(struct xen_domctl *domctl, struct domain *d,
>>>> +                  XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>>>> +{
>>>> +    struct dt_device_node *dev;
>>>> +    int ret = 0;
>>>> +
>>>> +    switch ( domctl->cmd )
>>>> +    {
>>>> +    case XEN_DOMCTL_assign_device:
>>>> +        ret = -ENXIO;
>>>> +        if ( domctl->u.assign_device.dev != XEN_DOMCTL_DEV_DT )
>>>> +            break;
>>>> +
>>>> +        if ( !cur_mediator )
>>>> +            break;
>>>> +
>>>> +        if ( !cur_mediator->assign_dt_device )
>>>> +            break;
>>>> +
>>>> +        ret = dt_find_node_by_gpath(domctl->u.assign_device.u.dt.path,
>>>> +                                    domctl->u.assign_device.u.dt.size, 
>>>> &dev);
>>>> +        if ( ret )
>>>> +            return ret;
>>>> +
>>>> +        ret = sci_assign_dt_device(d, dev);
>>>> +
>>>> +        break;
>>>> +    default:
>>> Nit: Blank line above here please.
>>>
>>>> @@ -274,7 +277,7 @@ static bool is_stable_domctl(uint32_t cmd)
>>>>    
>>>>    long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>>>>    {
>>>> -    long ret = 0;
>>>> +    long ret = 0, ret1 = 0;
>>> This initializer isn't really needed, with ...
>>>
>>>> @@ -833,7 +836,28 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
>>>> u_domctl)
>>>>        case XEN_DOMCTL_test_assign_device:
>>>>        case XEN_DOMCTL_deassign_device:
>>>>        case XEN_DOMCTL_get_device_group:
>>>> +        /*
>>>> +         * Chain SCI DT handling ahead of the IOMMU path so an SCI 
>>>> mediator
>>>> +         * can authorise access-controlled DT devices. Unhandled cases 
>>>> report
>>>> +         * -ENXIO, which is ignored.
>>>> +         */
>>>> +        ret1 = -ENXIO;
>>> ... this, is it? In fact, why not use -ENXIO as initializer?
>>>
>>>> +    #if IS_ENABLED(CONFIG_ARM_SCI)
>>>> +        ret1 = sci_do_domctl(op, d, u_domctl);
>>>> +    #endif
>>> Why the indentation of the pre-processor directives? At the very least the 
>>> #-es
>>> want to be in the first column, but I see no reason for the indentation at 
>>> all.
>>>
>>>>            ret = iommu_do_domctl(op, d, u_domctl);
>>>> +        if ( ret < 0 )
>>>> +            return ret;
>>> You can't simply return here, as we may be holding an RCU lock on the 
>>> domain.
>>>
>>>> +        /*
>>>> +         * If IOMMU processing was successful, check for SCI processing 
>>>> return
>>>> +         * code and if it failed then overwrite the return code to 
>>>> propagate
>>>> +         * SCI failure back to caller.
>>>> +         */
>>>> +        if ( ret1 != -ENXIO && ret1 < 0 )
>>>> +            ret = ret1;
>>> So if IOMMU processing was successful and because of SCI you return an error
>>> here, why would the IOMMU part not need undoing? Or to ask differently, if
>>> SCI said "no", why even try the IOMMU operation?
>>>
>>> Jan
>> My intention was to preserve the original behavior as much as possible.
>> This means that if the SCI assign operation returns an error, we still
>> attempt the IOMMU assignment, but filter the return code and ultimately
>> return the SCI error if the IOMMU assignment was successful.
>> However, in this scenario, we would still return an error from
>> the domctl call, which could lead to unexpected results.
>>
>> I agree with your point.
>>
>> With your suggestion, the code becomes much cleaner:
>>
>> #if IS_ENABLED(CONFIG_ARM_SCI)
>>           ret = sci_do_domctl(op, d, u_domctl);
>>           if ( ret < 0 && ret != -ENXIO )
>>               break;
>> #endif
>>
>>           ret = iommu_do_domctl(op, d, u_domctl);
>>           break;
>>
>> What do you think about this approach?
> Yes. Just to double-check though: There's nothing that needs undoing after
> a successful sci_do_domctl() when the subsequent iommu_do_domctl() failed?
Just rechecked. for multiagent (apart from parameters check) is sends SCMI
request to the firmware. So I don't see anything that should be undone 
in case
of error.
> One other remark: No IS_ENABLED() please in pre-processor directives. It
> wants to be #ifdef there. IS_ENABLED() is for use in if().
Will fix.
> Jan

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.