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

Re: [RFC PATCH v4 5/8] xen/domctl: extend XEN_DOMCTL_assign_device to handle not only iommu


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>, "jbeulich@xxxxxxxx" <jbeulich@xxxxxxxx>, "roger.pau@xxxxxxxxxx" <roger.pau@xxxxxxxxxx>
  • From: Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>
  • Date: Tue, 24 Jun 2025 08:42:54 +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=Y6AqxD5ErG783J2e0aZ8UpWyddV+VlzDQvc5JJ1As78=; b=kPsgLfupNe9tH0e7iuKG1ZeWBRJBrXXwkyaiBmQ1EZ+SEU70oYjIamMw3gbX6+hLxvulY89HzUAi8kZcpvaZaRG3W7q8wG+O35uKZEZN1cWoDNx1vlck7SyCZHZO89FWsa8CCeldf+1PwKpa5hAdjqJz902P5kw1zXFOy4Z4iMyXP+qSsWxUfWlmZArAn1K4I28nKTgEgzDowJ2M0oruoebzo5e7SUw8+DzmNYQIKc6o/gfoELMqG4T5FOF87PJlf78jrX/HJFGNFXaqZPUxRFfMePTiElvCFX/oMGfnXzZrYIkGXX8SraOybBPx4qsY6hJv8YrVrZLOejJ262W1zw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Iit312uP3MRbcbgxjaRS2P/TpxaPgzg1TkpUuTieGJbLd6Xg0eNPXGJQg8f5MoHJ65tFtRvrPbUcNZcjQG+D/GEBhyngqqrHQVormhTrfIVP56Bb1pQ8kNiImnGQFoFWepIvlhj5NbyXYy6KDpQeWGYo18T6VO9Qm4DX3JkDanD2SvA+SYPXUs4lSfbkEcXAV+p6pSIxHKAdk4sy58B84lndAofodcrfcGF8r31VgpdphJEODn2wbGyHTa1oq+nlTr9FoVhAqAfkf8goWxe1F0YgZQL7Z7rfJKfjed9KgOmfJsCrBbRe56m2BtXpz18fV22fsfXjtMuYRoolR5oGug==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, 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>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Grygorii Strashko <grygorii_strashko@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Tue, 24 Jun 2025 08:43:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHbyNXPDXt2FT3RV02cltfdm/Dd7rPdzmiAgCG+LgCACKrsAIACoXoAgAUPLACAAk4fgA==
  • Thread-topic: [RFC PATCH v4 5/8] xen/domctl: extend XEN_DOMCTL_assign_device to handle not only iommu

Adding Roger and Jan to the conversation.

Please see below.

On 23/06/2025 00:30, Stefano Stabellini wrote:
> On Thu, 19 Jun 2025, Oleksii Moisieiev wrote:
>> On 18/06/2025 03:04, Stefano Stabellini wrote:
>>> On Thu, 12 Jun 2025, Oleksii Moisieiev wrote:
>>>> Hi Stefano,
>>>>
>>>> I'm very sorry for a long silence. Please see my answers below:
>>>>
>>>> On 22/05/2025 03:25, Stefano Stabellini wrote:
>>>>> On Mon, 19 May 2025, Oleksii Moisieiev wrote:
>>>>>> From: Grygorii Strashko<grygorii_strashko@xxxxxxxx>
>>>>>>
>>>>>> Add chained handling of assigned DT devices to support access-controller
>>>>>> functionality through SCI framework, so DT device assign request can be
>>>>>> passed to FW for processing and enabling VM access to requested device
>>>>>> (for example, device power management through FW interface like SCMI).
>>>>>>
>>>>>> The SCI access-controller DT device processing is chained after IOMMU
>>>>>> processing and expected to be executed for any DT device regardless of 
>>>>>> its
>>>>>> protection by IOMMU (or if IOMMU is disabled).
>>>>>>
>>>>>> This allows to pass not only IOMMU protected DT device through
>>>>>> xl.cfg:"dtdev" property for processing:
>>>>>>
>>>>>> dtdev = [
>>>>>>        "/soc/video@e6ef0000", <- IOMMU protected device
>>>>>>        "/soc/i2c@e6508000", <- not IOMMU protected device
>>>>>> ]
>>>>>>
>>>>>> The change is done in two parts:
>>>>>> 1) update iommu_do_dt_domctl() to check for dt_device_is_protected() and
>>>>>> not fail if DT device is not protected by IOMMU
>>>>>> 2) add chained call to sci_do_domctl() in do_domctl()
>>>>>>
>>>>>> Signed-off-by: Grygorii Strashko<grygorii_strashko@xxxxxxxx>
>>>>>> Signed-off-by: Oleksii Moisieiev<oleksii_moisieiev@xxxxxxxx>
>>>>>> ---
>>>>>>
>>>>>>
>>>>>>
>>>>>>     xen/arch/arm/firmware/sci.c             | 37 
>>>>>> +++++++++++++++++++++++++
>>>>>>     xen/arch/arm/include/asm/firmware/sci.h | 14 ++++++++++
>>>>>>     xen/common/domctl.c                     | 19 +++++++++++++
>>>>>>     xen/drivers/passthrough/device_tree.c   |  6 ++++
>>>>>>     4 files changed, 76 insertions(+)
>>>>>>
>>>>>> diff --git a/xen/arch/arm/firmware/sci.c b/xen/arch/arm/firmware/sci.c
>>>>>> index e1522e10e2..8efd541c4f 100644
>>>>>> --- a/xen/arch/arm/firmware/sci.c
>>>>>> +++ b/xen/arch/arm/firmware/sci.c
>>>>>> @@ -126,6 +126,43 @@ 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 = -EOPNOTSUPP;
>>>>> Are you sure -EOPNOTSUPP is the right error code for the 3 checks below?
>>>> The -EOPNOTSUPP code is used because this is part of a chained call after
>>>> iommu_do_domctl, as stated in xen/common/domctl.c:859. The
>>>> XEN_DOMCTL_assign_device
>>>> call is expected to handle any DT device, regardless of whether the DT
>>>> device is
>>>> protected by an IOMMU or if the IOMMU is disabled.
>>>> The following cases are considered:
>>>>
>>>> 1. IOMMU Protected Device (Success)
>>>>
>>>> If the device is protected by the IOMMU and iommu_do_domctl returns 0,
>>>> we continue
>>>> processing the DT device by calling sci_do_domctl.
>>>>
>>>> 2. IOMMU Disabled (-EOPNOTSUPP from iommu_do_domctl)
>>>>
>>>> If iommu_do_domctl returns -EOPNOTSUPP, indicating that the IOMMU is
>>>> disabled,
>>>> we still proceed to call sci_do_domctl.
>>> OK this makes sense.  I think it is OK to have a special error code to
>>> say "the IOMMU is disabled" but I don't know if it is a good idea to try
>>> to use -EOPNOTSUPP for that. -EOPNOTSUPP could mean a hypervisor
>>> configuration with domctl disabled, for instance.
>>>
>>> It might be wiser to use a different error code. Maybe ENOENT?
>>>
>> I see that in the following commit:
>>
>> 71e617a6b8 (use is_iommu_enabled() where appropriate..., 2019-09-17)
>>
>> -ENOSYS return code was changed to -EOPNOTSUPP in iommu_do_domctl.
>>
>> It's not clear to me why this was done from the commit description.
>>
>> Maybe we should add commit author?
> Roger and Jan might know

 


Rackspace

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