qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 RESEND 3/3] IOMMU: enable intel_iommu map and


From: Peter Xu
Subject: Re: [Qemu-devel] [PATCH v4 RESEND 3/3] IOMMU: enable intel_iommu map and unmap notifiers
Date: Thu, 20 Oct 2016 15:28:18 +0800
User-agent: Mutt/1.5.24 (2015-08-30)

On Mon, Oct 17, 2016 at 06:44:24PM +0300, Aviv B.D wrote:

[...]

> @@ -2000,8 +2065,10 @@ static void vtd_iommu_notify_flag_changed(MemoryRegion 
> *iommu,
>                                            IOMMUNotifierFlag new)
>  {
>      VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
> +    IntelIOMMUState *s = vtd_as->iommu_state;
> +    IntelIOMMUNotifierNode *node = NULL;
>  
> -    if (new & IOMMU_NOTIFIER_MAP) {
> +    if (!s->cache_mode_enabled && new & IOMMU_NOTIFIER_MAP) {
>          error_report("Device at bus %s addr %02x.%d requires iommu "
>                       "notifier which is currently not supported by "
>                       "intel-iommu emulation",

Here after the patch works, we can modify the warning message into
something like:

"We need to set cache_mode=1 for intel-iommu to enable device
assignment with IOMMU protection."

> @@ -2009,6 +2076,27 @@ static void vtd_iommu_notify_flag_changed(MemoryRegion 
> *iommu,
>                       PCI_FUNC(vtd_as->devfn));
>          exit(1);
>      }
> +
> +    /* Add new ndoe if no mapping was exising before this call */
> +    if (old == IOMMU_NOTIFIER_NONE) {
> +        node = g_malloc0(sizeof(*node));
> +        node->vtd_as = vtd_as;
> +        node->notifier_flag = new;
> +        QLIST_INSERT_HEAD(&s->notifiers_list, node, next);
> +        return;
> +    }
> +
> +    /* update notifier node with new flags */
> +    QLIST_FOREACH(node, &s->notifiers_list, next) {

Though in this case it is safe, I would still suggest we use
QLIST_FOREACH_SAFE here.

> +        if (node->vtd_as == vtd_as) {
> +            if (new == IOMMU_NOTIFIER_NONE) {
> +                QLIST_REMOVE(node, next);

Memory leak here?

Thanks,

-- peterx



reply via email to

[Prev in Thread] Current Thread [Next in Thread]