qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: "Duan, Zhenzhong" <zhenzhong.duan@intel.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"nicolinc@nvidia.com" <nicolinc@nvidia.com>,
	"joao.m.martins@oracle.com" <joao.m.martins@oracle.com>,
	"eric.auger@redhat.com" <eric.auger@redhat.com>,
	"peterx@redhat.com" <peterx@redhat.com>,
	"jasowang@redhat.com" <jasowang@redhat.com>,
	"Tian, Kevin" <kevin.tian@intel.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>,
	"Sun, Yi Y" <yi.y.sun@intel.com>,
	"Peng, Chao P" <chao.p.peng@intel.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Kasireddy, Vivek" <vivek.kasireddy@intel.com>,
	"lersek@redhat.com" <lersek@redhat.com>
Subject: Re: [PATCH v6 01/21] backends/iommufd: Introduce the iommufd object
Date: Fri, 17 Nov 2023 13:56:53 +0100	[thread overview]
Message-ID: <811b1ee6-6f1e-4cca-a503-46c9a87cf851@redhat.com> (raw)
In-Reply-To: <SJ0PR11MB6744B1B91C890A9A1B81E89792B7A@SJ0PR11MB6744.namprd11.prod.outlook.com>

On 11/17/23 12:39, Duan, Zhenzhong wrote:
> Hi Cédric,
> 
>> -----Original Message-----
>> From: Cédric Le Goater <clg@redhat.com>
>> Sent: Friday, November 17, 2023 7:10 PM
>> Subject: Re: [PATCH v6 01/21] backends/iommufd: Introduce the iommufd object
>>
>> Hello,
>>
>>> +int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_t ioas_id,
>> hwaddr iova,
>>> +                            ram_addr_t size, void *vaddr, bool readonly)
>>> +{
>>> +    int ret, fd = be->fd;
>>> +    struct iommu_ioas_map map = {
>>> +        .size = sizeof(map),
>>> +        .flags = IOMMU_IOAS_MAP_READABLE |
>>> +                 IOMMU_IOAS_MAP_FIXED_IOVA,
>>> +        .ioas_id = ioas_id,
>>> +        .__reserved = 0,
>>> +        .user_va = (uintptr_t)vaddr,
>>> +        .iova = iova,
>>> +        .length = size,
>>> +    };
>>> +
>>> +    if (!readonly) {
>>> +        map.flags |= IOMMU_IOAS_MAP_WRITEABLE;
>>> +    }
>>> +
>>> +    ret = ioctl(fd, IOMMU_IOAS_MAP, &map);
>>> +    trace_iommufd_backend_map_dma(fd, ioas_id, iova, size,
>>> +                                  vaddr, readonly, ret);
>>> +    if (ret) {
>>> +        ret = -errno;
>>> +        error_report("IOMMU_IOAS_MAP failed: %m");
>>> +    }
>>> +    return ret;
>>> +}
>>
>> When using a UEFI guest, QEMU reports errors when mapping regions
>> in the top PCI space :
>>
>>    iommufd_backend_map_dma  iommufd=10 ioas=2 iova=0x380000001000
>> size=0x3000 addr=0x7fce2c28b000 readonly=0 (-1)
>>    qemu-system-x86_64: IOMMU_IOAS_MAP failed: Invalid argument
>>    qemu-system-x86_64: vfio_container_dma_map(0x55a21b03a150,
>> 0x380000001000, 0x3000, 0x7fce2c28b000) = -22 (Invalid argument)
>>
>>    iommufd_backend_map_dma  iommufd=10 ioas=2 iova=0x380000004000
>> size=0x4000 addr=0x7fce2c980000 readonly=0 (-1)
>>    qemu-system-x86_64: IOMMU_IOAS_MAP failed: Invalid argument
>>    qemu-system-x86_64: vfio_container_dma_map(0x55a21b03a150,
>> 0x380000004000, 0x4000, 0x7fce2c980000) = -22 (Invalid argument)
>>
>> This is because IOMMUFD reserved IOVAs areas are :
>>
>>   [ fee00000 - feefffff ]
>>   [ 8000000000 - ffffffffffffffff ] (39 bits address space)
>>
>> which were allocated when the device was initially attached.
>> The topology is basic. Something is wrong.
> 	
> Thanks for your report. This looks a hardware limit of
> host IOMMU address width(39) < guest physical address width.
>
  > A similar issue with a fix submitted below, ccing related people.
> https://lists.gnu.org/archive/html/qemu-devel/2023-11/msg02937.html
> It looks the fix will not work for hotplug.
> 
> Or below qemu cmdline may help:
> "-cpu host,host-phys-bits-limit=39"

Not that much. The IOMMU_IOAS_MAP failure becomes a "Bad address".

Thanks,

C.





  reply	other threads:[~2023-11-17 12:57 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14 10:09 [PATCH v6 00/21] vfio: Adopt iommufd Zhenzhong Duan
2023-11-14 10:09 ` [PATCH v6 01/21] backends/iommufd: Introduce the iommufd object Zhenzhong Duan
2023-11-14 13:28   ` Cédric Le Goater
2023-11-15  4:06     ` Duan, Zhenzhong
2023-11-15  8:15       ` Cédric Le Goater
2023-11-15 12:52   ` Eric Auger
2023-11-16  4:04     ` Duan, Zhenzhong
2023-11-16  8:32       ` Eric Auger
2023-11-16  8:47         ` Duan, Zhenzhong
2023-11-17 11:09   ` Cédric Le Goater
2023-11-17 11:39     ` Duan, Zhenzhong
2023-11-17 12:56       ` Cédric Le Goater [this message]
2023-11-17 13:29       ` Eric Auger
2023-11-17 13:56         ` Cédric Le Goater
2023-11-20  3:06           ` Duan, Zhenzhong
2023-11-20  8:24             ` Cédric Le Goater
2023-11-20 10:07               ` Duan, Zhenzhong
2023-11-20 17:08                 ` Cédric Le Goater
2023-11-21  3:26                   ` Duan, Zhenzhong
2023-11-21  8:05                     ` Cédric Le Goater
2023-11-21  8:39                       ` Duan, Zhenzhong
2023-11-14 10:09 ` [PATCH v6 02/21] util/char_dev: Add open_cdev() Zhenzhong Duan
2023-11-14 13:29   ` Cédric Le Goater
2023-11-15 13:23   ` Eric Auger
2023-11-14 10:09 ` [PATCH v6 03/21] vfio/common: return early if space isn't empty Zhenzhong Duan
2023-11-14 13:29   ` Cédric Le Goater
2023-11-15 13:28   ` Eric Auger
2023-11-14 10:09 ` [PATCH v6 04/21] vfio/iommufd: Implement the iommufd backend Zhenzhong Duan
2023-11-14 13:36   ` Cédric Le Goater
2023-11-14 10:09 ` [PATCH v6 05/21] vfio/iommufd: Relax assert check for " Zhenzhong Duan
2023-11-15 13:56   ` Eric Auger
2023-11-14 10:09 ` [PATCH v6 06/21] vfio/iommufd: Add support for iova_ranges and pgsizes Zhenzhong Duan
2023-11-14 13:46   ` Cédric Le Goater
2023-11-15  2:36     ` Duan, Zhenzhong
2023-11-15 16:25     ` Eric Auger
2023-11-14 10:09 ` [PATCH v6 07/21] vfio/pci: Extract out a helper vfio_pci_get_pci_hot_reset_info Zhenzhong Duan
2023-11-15 17:00   ` Eric Auger
2023-11-14 10:09 ` [PATCH v6 08/21] vfio/pci: Introduce a vfio pci hot reset interface Zhenzhong Duan
2023-11-14 13:51   ` Cédric Le Goater
2023-11-15  2:55     ` Duan, Zhenzhong
2023-11-15 17:54   ` Eric Auger
2023-11-14 10:09 ` [PATCH v6 09/21] vfio/iommufd: Enable pci hot reset through iommufd cdev interface Zhenzhong Duan
2023-11-17 13:53   ` Eric Auger
2023-11-20  4:15     ` Duan, Zhenzhong
2023-11-14 10:09 ` [PATCH v6 10/21] vfio/pci: Allow the selection of a given iommu backend Zhenzhong Duan
2023-11-14 13:57   ` Cédric Le Goater
2023-11-14 10:09 ` [PATCH v6 11/21] vfio/pci: Make vfio cdev pre-openable by passing a file handle Zhenzhong Duan
2023-11-14 14:08   ` Cédric Le Goater
2023-11-15 12:09   ` Philippe Mathieu-Daudé
2023-11-15 13:05     ` Cédric Le Goater
2023-11-16  2:15       ` Duan, Zhenzhong
2023-11-16  7:25         ` Cédric Le Goater
2023-11-16  7:43           ` Duan, Zhenzhong
2023-11-14 10:09 ` [PATCH v6 12/21] vfio/platform: Allow the selection of a given iommu backend Zhenzhong Duan
2023-11-14 14:03   ` Cédric Le Goater
2023-11-17 14:55   ` Eric Auger
2023-11-14 10:09 ` [PATCH v6 13/21] vfio/platform: Make vfio cdev pre-openable by passing a file handle Zhenzhong Duan
2023-11-14 14:22   ` Cédric Le Goater
2023-11-14 10:09 ` [PATCH v6 14/21] vfio/ap: Allow the selection of a given iommu backend Zhenzhong Duan
2023-11-14 14:03   ` Cédric Le Goater
2023-11-14 10:09 ` [PATCH v6 15/21] vfio/ap: Make vfio cdev pre-openable by passing a file handle Zhenzhong Duan
2023-11-14 14:04   ` Cédric Le Goater
2023-11-14 10:09 ` [PATCH v6 16/21] vfio/ccw: Allow the selection of a given iommu backend Zhenzhong Duan
2023-11-14 14:04   ` Cédric Le Goater
2023-11-15 18:45   ` Eric Farman
2023-11-14 10:09 ` [PATCH v6 17/21] vfio/ccw: Make vfio cdev pre-openable by passing a file handle Zhenzhong Duan
2023-11-14 14:04   ` Cédric Le Goater
2023-11-15 18:46   ` Eric Farman
2023-11-14 10:09 ` [PATCH v6 18/21] vfio: Make VFIOContainerBase poiner parameter const in VFIOIOMMUOps callbacks Zhenzhong Duan
2023-11-14 14:05   ` Cédric Le Goater
2023-11-17 14:58   ` Eric Auger
2023-11-14 10:09 ` [PATCH v6 19/21] hw/arm: Activate IOMMUFD for virt machines Zhenzhong Duan
2023-11-16  9:17   ` Eric Auger
2023-11-14 10:09 ` [PATCH v6 20/21] kconfig: Activate IOMMUFD for s390x machines Zhenzhong Duan
2023-11-15 18:47   ` Eric Farman
2023-11-14 10:09 ` [PATCH v6 21/21] hw/i386: Activate IOMMUFD for q35 machines Zhenzhong Duan
2023-11-16  9:17   ` Eric Auger
2023-11-14 14:51 ` [PATCH v6 00/21] vfio: Adopt iommufd Cédric Le Goater
2023-11-15  4:16   ` Duan, Zhenzhong
2023-11-20  9:15 ` Eric Auger
2023-11-20 10:09   ` Duan, Zhenzhong
2023-11-20 11:22     ` Eric Auger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=811b1ee6-6f1e-4cca-a503-46c9a87cf851@redhat.com \
    --to=clg@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=chao.p.peng@intel.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=eric.auger@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=joao.m.martins@oracle.com \
    --cc=kevin.tian@intel.com \
    --cc=kraxel@redhat.com \
    --cc=lersek@redhat.com \
    --cc=nicolinc@nvidia.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vivek.kasireddy@intel.com \
    --cc=yi.l.liu@intel.com \
    --cc=yi.y.sun@intel.com \
    --cc=zhenzhong.duan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).