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

Re: [RFC v1 5/5] xen/arm: add SCI mediator support for DomUs


  • To: Julien Grall <julien@xxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Wed, 22 Dec 2021 12:34:05 +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=arcselector9901; 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=LzWaDTH8bnvmgvfKbi45wbovi24gKodr03kYy2JAS34=; b=lV3kB38u0WLMDzszGpLr2KQhOvdURg0pYiUkyRsuxFdCvAXUbEDFc/0oaPgY8ie6rR2+jJ1HXARuoEUzYW7wCqqDMQOAc8/iLJszqTfj3waSlIXMHyb6WSAXMRIMnWDov53VuqxobzJnS5FAJwzVyf866RgHiLcF6K05QmfBscUzf2ZMtF7kn8Kk0xddhsSGUCujREEVn/CRjiLCtNdF4E32KEeN/HNg8cLivruhw85X17x1DRJhwl6nGVJmyLZqAT0imX5wHUuKh8EBPT9tJl/iIMQHzum++/dGOfauBYzoh1C7VsXRmY+XaRSf5a6b8W2Rm/mYfg8J+Y3EjW5MDA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BgzNASCzHrXbmWru/kzmePPg628VpEbTOyH0ue4DRPcGR5XdWc61ju6hI8DvcyGA/OWLwjiTR3rau0IRxY81l3WGSdJ8ibKdCTIgc/AWHJrfKaceXjBfdym7Su97J41KL6hLd9u0UFiuJ9+XuPMYr1sLzOVGLO/tIDgSvS26GDRAj25/q6yXd6xm1XpngrlB7K6gsg+sTkGmB7SWpVGCGzXaFf5bpJ78I0xD6DuIwxOjjMrPnPXYjhcRciyGlJtM/KFQ/uGGTm8fxt8ThYo/me8jLClnpWLll8bzymuu1vDoT26yn6UrkEd9Ad9GkY+d5DLUj6rOmZ25RSqEkbNzfw==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>, Oleksandr <olekstysh@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Wed, 22 Dec 2021 12:34:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHX8M3LNgat3drmYUW4ty+W1/SkP6w0P2iAgAJeh4CABnNRgIAAc5MAgADFCgCAAB3ugIAABU0AgAAFZQA=
  • Thread-topic: [RFC v1 5/5] xen/arm: add SCI mediator support for DomUs


Julien Grall <julien@xxxxxxx> writes:

> Hi,
>
> On 22/12/2021 12:17, Volodymyr Babchuk wrote:
>> Julien Grall <julien@xxxxxxx> writes:
>>> On 21/12/2021 22:39, Stefano Stabellini wrote:
>>>> On Tue, 21 Dec 2021, Anthony PERARD wrote:
>>>>> On Fri, Dec 17, 2021 at 12:15:25PM +0000, Oleksii Moisieiev wrote:
>>>>>>> On 14.12.21 11:34, Oleksii Moisieiev wrote:
>>>>>>>> @@ -1817,17 +1858,24 @@ static void libxl__add_dtdevs(libxl__egc *egc, 
>>>>>>>> libxl__ao *ao, uint32_t domid,
>>>>>>>>     {
>>>>>>>>         AO_GC;
>>>>>>>>         libxl__ao_device *aodev = libxl__multidev_prepare(multidev);
>>>>>>>> -    int i, rc = 0;
>>>>>>>> +    int i, rc = 0, rc_sci = 0;
>>>>>>>>         for (i = 0; i < d_config->num_dtdevs; i++) {
>>>>>>>>             const libxl_device_dtdev *dtdev = &d_config->dtdevs[i];
>>>>>>>>             LOGD(DEBUG, domid, "Assign device \"%s\" to domain", 
>>>>>>>> dtdev->path);
>>>>>>>>             rc = xc_assign_dt_device(CTX->xch, domid, dtdev->path);
>>>>>>>> -        if (rc < 0) {
>>>>>>>> -            LOGD(ERROR, domid, "xc_assign_dtdevice failed: %d", rc);
>>>>>>>> +        rc_sci = xc_domain_add_sci_device(CTX->xch, domid, 
>>>>>>>> dtdev->path);
>>>>>>>> +
>>>>>>>> +        if ((rc < 0) && (rc_sci < 0)) {
>>>>>>>> +            LOGD(ERROR, domid, "xc_assign_dt_device failed: %d; "
>>>>>>>> +                 "xc_domain_add_sci_device failed: %d",
>>>>>>>> +                 rc, rc_sci);
>>>>>>>>                 goto out;
>>>>>>>>             }
>>>>>>>> +
>>>>>>>> +        if (rc)
>>>>>>>> +            rc = rc_sci;
>>>>>>>
>>>>>>>
>>>>>>> If I get this code right, it sounds like the dom.cfg's dtdev property is
>>>>>>> reused to describe sci devices as well, but the libxl__add_dtdevs() 
>>>>>>> does not
>>>>>>> (and can not) differentiate them. So it has no option but to send two
>>>>>>> domctls for each device in dtdevs[] hoping to at least one domctl to
>>>>>>> succeeded. Or I really missed something?
>>>>>>>
>>>>>>> It feels to me that:
>>>>>>>    - either new dom.cfg's property could be introduced (scidev?) to 
>>>>>>> describe
>>>>>>> sci devices together with new parsing logic/management code, so you 
>>>>>>> will end
>>>>>>> up having new libxl__add_scidevs() to invoke XEN_DOMCTL_add_sci_device,
>>>>>>> so no mixing things.
>>>>>>>    - or indeed dtdev logic could be *completely* reused including 
>>>>>>> extending
>>>>>>> XEN_DOMCTL_assign_device to cover your use-case, although sounds 
>>>>>>> generic, it
>>>>>>> is used to describe devices for the passthrough (to configure an IOMMU 
>>>>>>> for
>>>>>>> the device), in that case you wouldn't need an extra
>>>>>>> XEN_DOMCTL_add_sci_device introduced by current patch.
>>>> I realize I did my review before reading Oleksandr's comments. I
>>>> fully
>>>> agree with his feedback. Having seen how difficult is for users to setup
>>>> a domU configuration correctly today, I would advise to try to reuse the
>>>> existing dtdev property instead of adding yet one new property to make
>>>> the life of our users easier.
>>>>
>>>>
>>>>>>> Personally I would use the first option as I am not sure that second 
>>>>>>> option
>>>>>>> is conceptually correct && possible. I would leave this for the 
>>>>>>> maintainers
>>>>>>> to clarify.
>>>>>>>
>>>>>>
>>>>>> Thank you for the point. I agree that reusing XEN_DOMCTL_assign_device
>>>>>> seems not to be conceptually correct. Introducing new dom.cfg property
>>>>>> seems to be the only way to avoid extra Domctl calls.
>>>>>> I will handle this in v2 if there will be no complains from Maintainers.
>>>>>
>>>>> I don't know if there will be a complains in v2 or not :-), but using
>>>>> something different from dtdev sound good.
>>>>>
>>>>> If I understand correctly, dtdev seems to be about passing through an
>>>>> existing device to a guest, and this new sci device seems to be about 
>>>>> having Xen
>>>>> "emulating" an sci device which the guest will use. So introducing
>>>>> something new (scidev or other name) sounds good.
>>>> Users already have to provide 4 properties (dtdev, iomem, irqs,
>>>> device_tree) to setup device assignment. I think that making it 5
>>>> properties would not be a step forward :-)
>>>
>>> IIRC, in the past, we discussed to fetch the information directly from
>>> the partial device-tree. Maybe this discussion needs to be revived?
>>>
>>> Although, this is a separate topic from this series.
>>>
>>>> To me dtdev and XEN_DOMCTL_assign_device are appropriate because
>>>> they
>>>> signify device assignment of one or more devices. We are not adding any
>>>> additional "meaning" to them. It is just that we'll automatically detect
>>>> and generate any SCMI configurations based on the list of assigned
>>>> devices. Because if SCMI is enabled and a device is assigned to the
>>>> guest, then I think we want to add the device to the SCMI list of
>>>> devices automatically.
>>>
>>> I am OK with re-using dtdev/XEN_DOMCTL_assign_device however there is
>>> a pitfall with that approach.
>>>
>>> At the moment, they are only used for device protected by the
>>> IOMMU. If the device is not protected by the IOMMU then it will return
>>> an error.
>> IIRC there was a change, that allowed to assign device without a
>> IOMMU. At
>> least we discussed this internally.
>
> I am not aware of any upstream. Do you have a pointer if there is any
> public discussion?

No, this is the first public discussion on this topic.

>
>>>
>>> Now, with your approach we may have a device that is not protected by
>>> the IOMMU but require to a SCMI configuration.
>> You need to protect only DMA-capable devices.
>
> Xen doesn't know if the device is DMA-capable or not. So...
>

But it knows if there is a iommus=<> node present for the device.

>> 
>>> I don't think it would be sensible to just return "succeed" here
>>> because technically you are asking to assign a non-protected
>>> device. But at the same time, it would prevent a user to assign a
>>> non-DMA capable device.
>>>
>>> So how do you suggest to approach this?
>> Well, in my head assign_device ideally should do the following:
>> 1. Assign IOMMU if it is configured for the device
>
> ... with this approach you are at the risk to let the user passthrough
> a device that cannot be protected.
>
>> 2. Assign SCMI access rights
>> (Not related to this patch series, but...)
>> 3. Assign IRQs
>> 4. Assign IO memory ranges.
>> Points 3. and 4. would allow us to not provide additional irq=[] and
>> iomem=[] entries in a guest config.
>
> That could only work if your guest is using the same layout as the
> host.

Agreed. But in my experience, in most cases this is the true. We worked
with Renesas and IMX hardware and in both cases iomems were
mapped 1:1.

> Otherwise, there is a risk it will clash with other parts of the
> memory layout.
>

> Today, guests started via the toolstack is only using a virtual
> layout, so you would first need to add support to use the host memory
> layout.

I can't say for all the possible configurations in the wild, but I'm
assuming that in most cases it will be fine to use 1:1 mapping. For
those more exotic cases it would be possible to implement some
configuration option like iomem_map=[mfn:gfn].

As Stefano pointed, right now user needs to provide 3 configuration
options to pass a device to a guest: dt_dev, irq, iomem. But in fact,
Xen is already knowing about irq and iomem from device tree.


-- 
Volodymyr Babchuk at EPAM

 


Rackspace

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