Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7F10F3ED4C for ; Sat, 11 Apr 2026 12:45:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wBXiC-0000Il-Po; Sat, 11 Apr 2026 08:45:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wBXi7-0000IM-KH for qemu-arm@nongnu.org; Sat, 11 Apr 2026 08:45:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wBXi4-0008SL-Q7 for qemu-arm@nongnu.org; Sat, 11 Apr 2026 08:45:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775911509; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=0aRqr3po4WOK1m08Li+al0O+0Tw0h8UEodzOvUAIx5g=; b=NCSsHmWIEfvcSMwZnCV40AeZolOzQJtt8aJfNDPH2RvPVuCmMMZ4pmHIoUNzS76CLS5To5 x/ubyY2b1f8pYVZmThRVZd2pmcJZXUApEu7Ir5lcKzjYctYNRc8kBB3/STBUUkk/PTvU9k tzGRD5V+lGJJYDGZjQXI1GyG83AeTeo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-552-Tkpt5eOgMVW2wiqNYYrdKw-1; Sat, 11 Apr 2026 08:45:08 -0400 X-MC-Unique: Tkpt5eOgMVW2wiqNYYrdKw-1 X-Mimecast-MFC-AGG-ID: Tkpt5eOgMVW2wiqNYYrdKw_1775911507 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-488be33b7a6so17455895e9.0 for ; Sat, 11 Apr 2026 05:45:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775911507; x=1776516307; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0aRqr3po4WOK1m08Li+al0O+0Tw0h8UEodzOvUAIx5g=; b=mmJpeBFLqlzKK+m4pEZmGxZgCzolDLD/fNiEeKN6YVogz9XY4W1MGv0rek23okG3dn zvYS7MjdXBShYtuEPiFtY49BOwOEm6ELvTb3zA9P6PGE/tzCYJX0mRXU3bk9fT+TVPYF TXVXhzz1JPHfT1P2peI+qF/eBkoifyt8JIAuYVFBm3PrDvwjaaXDuulJQKxU1+Gslhv7 iRjEVzkjq0gAEmRfwYGaT0aXuATwEGGXINdFWNAwS6mAFMq3/LXapG5SjRMMuqkHOv9N NHZvgGcwxjQKrHo7JqhVk08fRC4cw8mZCvBUuHQn4agpJfnnZJDRkA5ix+8k/wG0rnEj xOlA== X-Forwarded-Encrypted: i=1; AJvYcCUMqcKqxvvPrZ0v88Hgbv/1l+6p76+OFqyoxcoOXUV4ql6AanF8zkkP38JZMpaUqcnA2556psFv9g==@nongnu.org X-Gm-Message-State: AOJu0YzCXQT1Wo/DnZFv5pNNv4a/4nonH7R/OPeLYNS+Nq3YGmj8SRK9 K5dMRHsiHoXOHycne6+MK7xjS0SP+p8tilHIElSUK1Zab0/XQP0I2CZf1M5RSPhv5ZH1OuQruE3 I7ENikm1T+iLrB3cduRv5F82AorCSiSxQZ9ekWHFfg9knYWd1iSm7CA== X-Gm-Gg: AeBDies4yDaOscqwL9z5239r2dye/mR2cgNFlKVGxvZNx36I4heEBUPN87/+WavjejL GFBTVwUqjy3hdGdCYhfopRG3y7JeL9Pqb26NYui948Vn2uvaevkrAVAX5Jx1vhb515evO3C5JL7 xPkG4diisl6LMM541yG+8eNdTZWS0hvWBHidQrjWKN9fyDEJWYQB5ZYKeLPlb5SWFFkIQGkOvwg ck8Vdj5DEveOD0phQ/DpYjU/XBWmu210JLvw2xaKYhaPnp5JIDVOaVtoiESzIkSVr9cW/MSWYTT nJYJ/AAJNVBW2nyPWMuPHrEZn3ErYu9KxhiDsKtAXTs3gYBCdnpHlet+sZz3qg+LDFd1COvpp1+ +cR2oXbXZkhrJqHRFY3c1sU2ljWGozedE5HvyowLKvzGiDRyIsX6Vcn4ciPn6 X-Received: by 2002:a05:600c:8709:b0:485:4135:5c92 with SMTP id 5b1f17b1804b1-488d66580e3mr94092165e9.0.1775911507042; Sat, 11 Apr 2026 05:45:07 -0700 (PDT) X-Received: by 2002:a05:600c:8709:b0:485:4135:5c92 with SMTP id 5b1f17b1804b1-488d66580e3mr94091625e9.0.1775911506480; Sat, 11 Apr 2026 05:45:06 -0700 (PDT) Received: from ?IPV6:2a01:e0a:280:24f0:9db0:474c:ff43:9f5c? ([2a01:e0a:280:24f0:9db0:474c:ff43:9f5c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488d67e7e45sm67933355e9.9.2026.04.11.05.45.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Apr 2026 05:45:05 -0700 (PDT) Message-ID: <9481a1c3-0dec-482f-97ac-ad513af99f9b@redhat.com> Date: Sat, 11 Apr 2026 14:45:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 04/11] vfio/pci: Add ats property and mask ATS cap when not exposed To: Nathan Chen , qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Yi Liu , Eric Auger , Zhenzhong Duan , Peter Maydell , Marcel Apfelbaum , =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , Zhao Liu , Alex Williamson , Shameer Kolothum , Matt Ochs , Nicolin Chen References: <20260401010231.4166776-1-nathanc@nvidia.com> <20260401010231.4166776-5-nathanc@nvidia.com> <084d5550-c471-4d5b-8e2b-d2529a77cde8@redhat.com> From: =?UTF-8?Q?C=C3=A9dric_Le_Goater?= Autocrypt: addr=clg@redhat.com; keydata= xsFNBFu8o3UBEADP+oJVJaWm5vzZa/iLgpBAuzxSmNYhURZH+guITvSySk30YWfLYGBWQgeo 8NzNXBY3cH7JX3/a0jzmhDc0U61qFxVgrPqs1PQOjp7yRSFuDAnjtRqNvWkvlnRWLFq4+U5t yzYe4SFMjFb6Oc0xkQmaK2flmiJNnnxPttYwKBPd98WfXMmjwAv7QfwW+OL3VlTPADgzkcqj 53bfZ4VblAQrq6Ctbtu7JuUGAxSIL3XqeQlAwwLTfFGrmpY7MroE7n9Rl+hy/kuIrb/TO8n0 ZxYXvvhT7OmRKvbYuc5Jze6o7op/bJHlufY+AquYQ4dPxjPPVUT/DLiUYJ3oVBWFYNbzfOrV RxEwNuRbycttMiZWxgflsQoHF06q/2l4ttS3zsV4TDZudMq0TbCH/uJFPFsbHUN91qwwaN/+ gy1j7o6aWMz+Ib3O9dK2M/j/O/Ube95mdCqN4N/uSnDlca3YDEWrV9jO1mUS/ndOkjxa34ia 70FjwiSQAsyIwqbRO3CGmiOJqDa9qNvd2TJgAaS2WCw/TlBALjVQ7AyoPEoBPj31K74Wc4GS Rm+FSch32ei61yFu6ACdZ12i5Edt+To+hkElzjt6db/UgRUeKfzlMB7PodK7o8NBD8outJGS tsL2GRX24QvvBuusJdMiLGpNz3uqyqwzC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p4PlsZVMNjvPAnr5TEBgHkk54HQRhhwcYv1T2QumQ izDiU6iOrUzBThaMhZO3i927SG2DwWDVzZltKrCMD1aMPvb3NU8FOYRhNmIFR3fcalYr+9gD uVKe8BVz4atMOoktmt0GWTOC8P4= In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5cSKtT2j4g9UpradJu6GMT_Iw2aUBMn6O9eR-vS0fqM_1775911507 X-Mimecast-Originator: redhat.com Content-Language: en-US, fr Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org On 4/11/26 03:52, Nathan Chen wrote: > > Hi Cédric, > On 4/10/2026 2:09 PM, Cédric Le Goater wrote: >> Hello Nathan, >> >> On 4/1/26 03:02, Nathan Chen wrote: >>> From: Nathan Chen >>> >>> Add an "ats" OnOffAuto property to vfio-pci. When the device has an ATS >>> extended capability in config space but we should not expose it (ats=off, >>> or ats=auto and kernel reports IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED), mask >>> the capability so the guest does not see it. >>> >>> This aligns with the kernel's per-device effective ATS reporting and >>> allows omitting ATS capability when the vIOMMU has ats=off. >>> >>> Suggested-by: Shameer Kolothum >>> Signed-off-by: Nathan Chen >> >> This looks like a standalone VFIO change that could be sent independently. >> Could you please rebase on vfio-next [*] ? There are a few conflicting >> changes in this branch. >> >> [*] https://github.com/legoater/qemu/commits/vfio-next >> >> You will need to add a compat machine property too. This is a guest-visible >> ABI change. A separate patch would be preferred. >> > Yes, I will separate this out and rebase on vfio-next, with the compat machine property added. > >>> --- >>>   backends/iommufd.c                 | 15 +++++++ >>>   hw/vfio/pci.c                      | 63 ++++++++++++++++++++++++++++++ >>>   hw/vfio/pci.h                      |  1 + >>>   include/system/host_iommu_device.h | 10 +++++ >>>   4 files changed, 89 insertions(+) >>> >>> diff --git a/backends/iommufd.c b/backends/iommufd.c >>> index e1fee16acf..52cb060454 100644 >>> --- a/backends/iommufd.c >>> +++ b/backends/iommufd.c >>> @@ -22,6 +22,13 @@ >>>   #include "hw/vfio/vfio-device.h" >>>   #include >>>   #include >>> +/* >>> + * Until kernel UAPI is synced via scripts; >>> + * matches include/uapi/linux/iommufd.h >>> + */ >>> +#ifndef IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED >>> +#define IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED (1 << 3) >>> +#endif >> >> This definition is introduced by : >> >> https://lore.kernel.org/all/20260303150348.233997-1- skolothumtho@nvidia.com/ >> >> It should reach Linux v7.1 since it is in linux-next. Anyhow, until then, >> please isolate this change in a temporary patch updating linux-headers/ >> > Ok, I will separate it out. >>>   static const char *iommufd_fd_name(IOMMUFDBackend *be) >>>   { >>> @@ -573,6 +580,13 @@ static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **errp) >>>       } >>>   } >>> +static bool hiod_iommufd_support_ats(HostIOMMUDevice *hiod) >>> +{ >>> +    HostIOMMUDeviceCaps *caps = &hiod->caps; >>> + >>> +    return !(caps->hw_caps & IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED); >>> +} >>> + >>>   static bool hiod_iommufd_get_pasid_info(HostIOMMUDevice *hiod, >>>                                           PasidInfo *pasid_info) >>>   { >>> @@ -595,6 +609,7 @@ static void hiod_iommufd_class_init(ObjectClass *oc, const void *data) >>>       hioc->get_cap = hiod_iommufd_get_cap; >>>       hioc->get_pasid_info = hiod_iommufd_get_pasid_info; >>> +    hioc->support_ats = hiod_iommufd_support_ats; >>>   }; >>>   static const TypeInfo types[] = { >>> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c >>> index 1945751ffd..2d408e1d9a 100644 >>> --- a/hw/vfio/pci.c >>> +++ b/hw/vfio/pci.c >>> @@ -49,6 +49,10 @@ >>>   #include "system/iommufd.h" >>>   #include "vfio-migration-internal.h" >>>   #include "vfio-helpers.h" >>> +#ifdef CONFIG_IOMMUFD >>> +#include "system/host_iommu_device.h" >>> +#include "linux/iommufd.h" >>> +#endif >> These includes are not necessary. > Got it, I will remove these. I see that system/host_iommu_device.h is included in system/iommufd.h already. And linux/iommufd.h was leftover from a previous revision. > >> >>>   /* Protected by BQL */ >>>   static KVMRouteChange vfio_route_change; >>> @@ -2550,10 +2554,53 @@ static bool vfio_pci_synthesize_pasid_cap(VFIOPCIDevice *vdev, Error **errp) >>>       return true; >>>   } >>> +/* >>> + * Determine whether ATS capability should be advertised for @vdev, based on >>> + * whether it was enabled on the command line and whether it is supported >>> + * according to the kernel's IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED bit. >>> + * >>> + * Store whether ATS capability should be advertised in @ats_need. >>> + * >>> + * Return false if kernel enables IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED >>> + * and ATS is effectively unsupported. >>> + */ >>> +static bool vfio_pci_ats_requested_and_supported(VFIOPCIDevice *vdev, >>> +                                                 bool *ats_need, Error **errp) >> >> May be rename 'ats_need' to 'ats' or 'ats_needed' >> > Ok, I will rename this to ats_needed. >>> +{ >>> +    HostIOMMUDevice *hiod = vdev->vbasedev.hiod; >>> +    HostIOMMUDeviceClass *hiodc; >>> +    bool ats_supported; >>> + >>> +    if (vdev->ats == ON_OFF_AUTO_OFF) { >>> +        *ats_need = false; >>> +        return true; >>> +    } >>> + >>> +    *ats_need = true; >>> +    if (!hiod) { >>> +        return true; >>> +    } >>> +    hiodc = HOST_IOMMU_DEVICE_GET_CLASS(hiod); >>> +    if (!hiodc || !hiodc->support_ats) { >>> +        return true; >>> +    } >>> + >>> +    ats_supported = hiodc->support_ats(hiod); >>> +    if (vdev->ats == ON_OFF_AUTO_ON && !ats_supported) { >>> +        error_setg(errp, "vfio: ATS requested but not supported by kernel"); >> >> hmm, I wonder if we shouldn't fail to realize the device and stop the VM >> in this case (ats requested + no support). > Agreed. I can move the vfio_pci_ats_requested_and_supported() call to vfio_pci_add_capabilities() so we can propagate the Error **, and then pass ats_needed as a new input arg to vfio_add_ext_cap. Would that be alright? >> >>> +        *ats_need = false; >>> +        return false; >>> +    } >>> + >>> +    *ats_need = ats_supported; >>> +    return true; >>> +} >>> + >>>   static void vfio_add_ext_cap(VFIOPCIDevice *vdev) >>>   { >>>       PCIDevice *pdev = PCI_DEVICE(vdev); >>>       bool pasid_cap_added = false; >>> +    bool ats_needed = false; >>>       Error *err = NULL; >>>       uint32_t header; >>>       uint16_t cap_id, next, size; >>> @@ -2603,6 +2650,11 @@ static void vfio_add_ext_cap(VFIOPCIDevice *vdev) >>>       pci_set_long(pdev->wmask + PCI_CONFIG_SPACE_SIZE, 0); >>>       pci_set_long(vdev->emulated_config_bits + PCI_CONFIG_SPACE_SIZE, ~0); >>> +    if (!vfio_pci_ats_requested_and_supported(vdev, &ats_needed, &err)) { >>> +        error_report_err(err); >>> +       err = NULL; >> >> indent error >> > Thanks, will fix this. >>> +    } >>> + >>>       for (next = PCI_CONFIG_SPACE_SIZE; next; >>>            next = PCI_EXT_CAP_NEXT(pci_get_long(config + next))) { >>>           header = pci_get_long(config + next); >>> @@ -2640,6 +2692,16 @@ static void vfio_add_ext_cap(VFIOPCIDevice *vdev) >>>           case PCI_EXT_CAP_ID_PASID: >>>               pasid_cap_added = true; >>>               /* fallthrough */ >> >> This change is coupling the PASID and ATS capabilities. Is this intended ? >> > This was not intentional, I will add a pcie_add_capability() call and break for the PASID case. >> >>> +        case PCI_EXT_CAP_ID_ATS: >>> +            /* >>> +             * If ATS is requested and supported according to the kernel, add >>> +             * the ATS capability. If not supported according to the kernel or >>> +             * disabled on the qemu command line, omit the ATS cap. >>> +             */ >>> +            if (ats_needed) { >>> +                pcie_add_capability(pdev, cap_id, cap_ver, next, size); >>> +            } >>> +            break; >>>           default: >>>               pcie_add_capability(pdev, cap_id, cap_ver, next, size); >>>           } >>> @@ -3819,6 +3881,7 @@ static const Property vfio_pci_properties[] = { >>>   #ifdef CONFIG_IOMMUFD >>>       DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd, >>>                        TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *), >>> +    DEFINE_PROP_ON_OFF_AUTO("ats", VFIOPCIDevice, ats, ON_OFF_AUTO_AUTO), >> >> conflicts with vfio-next >> > Ok, will take a look and rebase on vfio-next. when you rebase, please put the "ats" property at the end of the list and update accordingly vfio_pci_class_init(). Thanks, C. >>>   #endif >>>       DEFINE_PROP_BOOL("skip-vsc-check", VFIOPCIDevice, skip_vsc_check, true), >>>       DEFINE_PROP_UINT16("x-vpasid-cap-offset", VFIOPCIDevice, >>> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h >>> index d6495d7f29..514a9197ce 100644 >>> --- a/hw/vfio/pci.h >>> +++ b/hw/vfio/pci.h >>> @@ -191,6 +191,7 @@ struct VFIOPCIDevice { >>>       VFIODisplay *dpy; >>>       Notifier irqchip_change_notifier; >>>       VFIOPCICPR cpr; >>> +    OnOffAuto ats; >>>   }; >>>   /* Use uin32_t for vendor & device so PCI_ANY_ID expands and cannot match hw */ >>> diff --git a/include/system/host_iommu_device.h b/include/system/ host_iommu_device.h >>> index f000301583..44c56e87bb 100644 >>> --- a/include/system/host_iommu_device.h >>> +++ b/include/system/host_iommu_device.h >> >> Please add to your .git/config : >> >> [diff] >>      orderFile = /path/to/qemu/scripts/git.orderfile >> >> > Ok, I will add this for the next refresh. >>> @@ -133,6 +133,16 @@ struct HostIOMMUDeviceClass { >>>        * Returns: true on success, false on failure. >>>        */ >>>       bool (*get_pasid_info)(HostIOMMUDevice *hiod, PasidInfo *pasid_info); >>> +    /** >>> +     *  @support_ats: Return whether ATS is supported for the device >>> +     *  associated with @hiod host IOMMU device, checking if the >>> +     *  IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED capability bit is set. >>> +     * >>> +     *  @hiod: handle to the host IOMMU device >>> +     * >>> +     *  Returns: true on success, false on failure >> >>   "Returns: true if ATS is supported, false otherwise" >> > Ok, I will make this more clear. >>> +     */ >>> +    bool (*support_ats)(HostIOMMUDevice *hiod); >>>   }; >>>   /* >> >> >> I would split this patch in 4 parts : >> >> - linux-headers/ v7.1 update >> - support_ats() handler introduction and iommufd implementation >> - "ats" property addition >> - compat property fixup > Got it, thanks for the guidance on organizing the split. I will send separately from this series. > > Thanks, > Nathan >