From: Jonathan Cameron via <qemu-arm@nongnu.org>
To: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
Cc: "qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
Nicolin Chen <nicolinc@nvidia.com>,
Nathan Chen <nathanc@nvidia.com>, Matt Ochs <mochs@nvidia.com>,
Jiandi An <jan@nvidia.com>, Jason Gunthorpe <jgg@nvidia.com>,
"zhangfei.gao@linaro.org" <zhangfei.gao@linaro.org>,
"zhenzhong.duan@intel.com" <zhenzhong.duan@intel.com>,
Krishnakant Jaju <kjaju@nvidia.com>
Subject: Re: [PATCH v7 3/5] hw/arm/smmuv3-accel: Allocate vEVENTQ for accelerated SMMUv3 devices
Date: Tue, 24 Feb 2026 16:02:55 +0000 [thread overview]
Message-ID: <20260224160255.000076e6@huawei.com> (raw)
In-Reply-To: <CH3PR12MB754814ECFD29951EFB571585AB74A@CH3PR12MB7548.namprd12.prod.outlook.com>
On Tue, 24 Feb 2026 15:18:00 +0000
Shameer Kolothum Thodi <skolothumtho@nvidia.com> wrote:
> > -----Original Message-----
> > From: Jonathan Cameron <jonathan.cameron@huawei.com>
> > Sent: 24 February 2026 15:02
> > To: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
> > Cc: qemu-arm@nongnu.org; qemu-devel@nongnu.org;
> > eric.auger@redhat.com; peter.maydell@linaro.org; Nicolin Chen
> > <nicolinc@nvidia.com>; Nathan Chen <nathanc@nvidia.com>; Matt Ochs
> > <mochs@nvidia.com>; Jiandi An <jan@nvidia.com>; Jason Gunthorpe
> > <jgg@nvidia.com>; zhangfei.gao@linaro.org; zhenzhong.duan@intel.com;
> > Krishnakant Jaju <kjaju@nvidia.com>
> > Subject: Re: [PATCH v7 3/5] hw/arm/smmuv3-accel: Allocate vEVENTQ for
> > accelerated SMMUv3 devices
> >
> > External email: Use caution opening links or attachments
> >
> >
> > On Tue, 24 Feb 2026 14:41:08 +0000
> > Shameer Kolothum Thodi <skolothumtho@nvidia.com> wrote:
> >
> > > > -----Original Message-----
> > > > From: Jonathan Cameron <jonathan.cameron@huawei.com>
> > > > Sent: 24 February 2026 14:29
> > > > To: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
> > > > Cc: qemu-arm@nongnu.org; qemu-devel@nongnu.org;
> > > > eric.auger@redhat.com; peter.maydell@linaro.org; Nicolin Chen
> > > > <nicolinc@nvidia.com>; Nathan Chen <nathanc@nvidia.com>; Matt Ochs
> > > > <mochs@nvidia.com>; Jiandi An <jan@nvidia.com>; Jason Gunthorpe
> > > > <jgg@nvidia.com>; zhangfei.gao@linaro.org; zhenzhong.duan@intel.com;
> > > > Krishnakant Jaju <kjaju@nvidia.com>
> > > > Subject: Re: [PATCH v7 3/5] hw/arm/smmuv3-accel: Allocate vEVENTQ for
> > > > accelerated SMMUv3 devices
> > > >
> > > > External email: Use caution opening links or attachments
> > > >
> > > >
> > > > On Thu, 19 Feb 2026 09:01:01 +0000
> > > > Shameer Kolothum <skolothumtho@nvidia.com> wrote:
> > > >
> > > > > From: Nicolin Chen <nicolinc@nvidia.com>
> > > > >
> > > > > When the guest enables the Event Queue and a vIOMMU is present,
> > > > > allocate a vEVENTQ object so that host-side events related to the
> > > > > vIOMMU can be received and propagated back to the guest.
> > > > >
> > > > > For cold-plugged devices using SMMUv3 acceleration, the vIOMMU is
> > > > > created before the guest boots. In this case, the vEVENTQ is allocated
> > > > > when the guest writes to SMMU_CR0 and sets EVENTQEN = 1.
> > > > >
> > > > > If no cold-plugged device exists at boot (i.e. no vIOMMU initially),
> > > > > the vEVENTQ is allocated when a vIOMMU is created, i.e. during the
> > > > > first device hot-plug.
> > > >
> > > > Why do it differently?
> > >
> > > This is because a vEVENTQ must be associated with a vIOMMU, and
> > > iommufd_backend_alloc_veventq() requires a valid viommu_id.
> > >
> > > A vIOMMU is only created once at least one vfio-pci device is
> > > attached. If the VM boots without any cold-plugged devices, no
> > > vIOMMU exists at that point.
> > >
> > > In that case, the vIOMMU is created during the first device
> > > hot-plug, so we allocate the vEVENTQ at that time instead.
> > >
> > > So, the difference in behaviour simply follows when the vIOMMU
> > > becomes available.
> > >
> > > Hope that is clear now.
> > Ok. So maybe this is just a description thing that was confusing me.
> > The key to my mental model is that both conditions must be met. That
> > is SMMU_CR0 has EVENTQEN = 1 set and there is a VFIO device present.
> > They happen in different orders in the two cases?
>
> Yes. And EVENTQEN is set by Guest ARM SMMUv3 driver probe time.
>
> >
> > What guarantees we don't get a hotplug event before the guest has
> > set EVENTQEN = 1?
>
> vEVENTQ needs two things:
>
> 1) The guest must set EVENTQEN=1.
> 2) A vIOMMU must already exist (which happens when a VFIO device is attached).
>
> EVENTQEN=1 is set by the guest when the SMMUv3 driver probes.
>
> These two things can happen in either order.
>
> In the cold-plug case, the vIOMMU already exists before the guest driver
> probes. So when the guest sets EVENTQEN=1 during driver probe, we
> allocate the vEVENTQ at that time.
>
> In the hot-plug-first case, the first VFIO hotplug creates the vIOMMU,
> possibly before the guest has loaded the SMMUv3 driver. In that case,
> we wait until the guest sets EVENTQEN=1 during driver probe, and then
> allocate the vEVENTQ.
>
> So we do not depend on ordering. We just check that both conditions
> are true, and allocate when the second one becomes true.
Perfect. That explanation works for me. If you respin maybe start
the explanation with the full conditions that must be met, then break
down why they occur in different orders in the cold and hotplug
(after we reach a particular point in guest boot) cases.
Jonathan
>
> Thanks,
> Shameer
>
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron via qemu development <qemu-devel@nongnu.org>
To: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
Cc: "qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
Nicolin Chen <nicolinc@nvidia.com>,
Nathan Chen <nathanc@nvidia.com>, Matt Ochs <mochs@nvidia.com>,
Jiandi An <jan@nvidia.com>, Jason Gunthorpe <jgg@nvidia.com>,
"zhangfei.gao@linaro.org" <zhangfei.gao@linaro.org>,
"zhenzhong.duan@intel.com" <zhenzhong.duan@intel.com>,
Krishnakant Jaju <kjaju@nvidia.com>
Subject: Re: [PATCH v7 3/5] hw/arm/smmuv3-accel: Allocate vEVENTQ for accelerated SMMUv3 devices
Date: Tue, 24 Feb 2026 16:02:55 +0000 [thread overview]
Message-ID: <20260224160255.000076e6@huawei.com> (raw)
In-Reply-To: <CH3PR12MB754814ECFD29951EFB571585AB74A@CH3PR12MB7548.namprd12.prod.outlook.com>
On Tue, 24 Feb 2026 15:18:00 +0000
Shameer Kolothum Thodi <skolothumtho@nvidia.com> wrote:
> > -----Original Message-----
> > From: Jonathan Cameron <jonathan.cameron@huawei.com>
> > Sent: 24 February 2026 15:02
> > To: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
> > Cc: qemu-arm@nongnu.org; qemu-devel@nongnu.org;
> > eric.auger@redhat.com; peter.maydell@linaro.org; Nicolin Chen
> > <nicolinc@nvidia.com>; Nathan Chen <nathanc@nvidia.com>; Matt Ochs
> > <mochs@nvidia.com>; Jiandi An <jan@nvidia.com>; Jason Gunthorpe
> > <jgg@nvidia.com>; zhangfei.gao@linaro.org; zhenzhong.duan@intel.com;
> > Krishnakant Jaju <kjaju@nvidia.com>
> > Subject: Re: [PATCH v7 3/5] hw/arm/smmuv3-accel: Allocate vEVENTQ for
> > accelerated SMMUv3 devices
> >
> > External email: Use caution opening links or attachments
> >
> >
> > On Tue, 24 Feb 2026 14:41:08 +0000
> > Shameer Kolothum Thodi <skolothumtho@nvidia.com> wrote:
> >
> > > > -----Original Message-----
> > > > From: Jonathan Cameron <jonathan.cameron@huawei.com>
> > > > Sent: 24 February 2026 14:29
> > > > To: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
> > > > Cc: qemu-arm@nongnu.org; qemu-devel@nongnu.org;
> > > > eric.auger@redhat.com; peter.maydell@linaro.org; Nicolin Chen
> > > > <nicolinc@nvidia.com>; Nathan Chen <nathanc@nvidia.com>; Matt Ochs
> > > > <mochs@nvidia.com>; Jiandi An <jan@nvidia.com>; Jason Gunthorpe
> > > > <jgg@nvidia.com>; zhangfei.gao@linaro.org; zhenzhong.duan@intel.com;
> > > > Krishnakant Jaju <kjaju@nvidia.com>
> > > > Subject: Re: [PATCH v7 3/5] hw/arm/smmuv3-accel: Allocate vEVENTQ for
> > > > accelerated SMMUv3 devices
> > > >
> > > > External email: Use caution opening links or attachments
> > > >
> > > >
> > > > On Thu, 19 Feb 2026 09:01:01 +0000
> > > > Shameer Kolothum <skolothumtho@nvidia.com> wrote:
> > > >
> > > > > From: Nicolin Chen <nicolinc@nvidia.com>
> > > > >
> > > > > When the guest enables the Event Queue and a vIOMMU is present,
> > > > > allocate a vEVENTQ object so that host-side events related to the
> > > > > vIOMMU can be received and propagated back to the guest.
> > > > >
> > > > > For cold-plugged devices using SMMUv3 acceleration, the vIOMMU is
> > > > > created before the guest boots. In this case, the vEVENTQ is allocated
> > > > > when the guest writes to SMMU_CR0 and sets EVENTQEN = 1.
> > > > >
> > > > > If no cold-plugged device exists at boot (i.e. no vIOMMU initially),
> > > > > the vEVENTQ is allocated when a vIOMMU is created, i.e. during the
> > > > > first device hot-plug.
> > > >
> > > > Why do it differently?
> > >
> > > This is because a vEVENTQ must be associated with a vIOMMU, and
> > > iommufd_backend_alloc_veventq() requires a valid viommu_id.
> > >
> > > A vIOMMU is only created once at least one vfio-pci device is
> > > attached. If the VM boots without any cold-plugged devices, no
> > > vIOMMU exists at that point.
> > >
> > > In that case, the vIOMMU is created during the first device
> > > hot-plug, so we allocate the vEVENTQ at that time instead.
> > >
> > > So, the difference in behaviour simply follows when the vIOMMU
> > > becomes available.
> > >
> > > Hope that is clear now.
> > Ok. So maybe this is just a description thing that was confusing me.
> > The key to my mental model is that both conditions must be met. That
> > is SMMU_CR0 has EVENTQEN = 1 set and there is a VFIO device present.
> > They happen in different orders in the two cases?
>
> Yes. And EVENTQEN is set by Guest ARM SMMUv3 driver probe time.
>
> >
> > What guarantees we don't get a hotplug event before the guest has
> > set EVENTQEN = 1?
>
> vEVENTQ needs two things:
>
> 1) The guest must set EVENTQEN=1.
> 2) A vIOMMU must already exist (which happens when a VFIO device is attached).
>
> EVENTQEN=1 is set by the guest when the SMMUv3 driver probes.
>
> These two things can happen in either order.
>
> In the cold-plug case, the vIOMMU already exists before the guest driver
> probes. So when the guest sets EVENTQEN=1 during driver probe, we
> allocate the vEVENTQ at that time.
>
> In the hot-plug-first case, the first VFIO hotplug creates the vIOMMU,
> possibly before the guest has loaded the SMMUv3 driver. In that case,
> we wait until the guest sets EVENTQEN=1 during driver probe, and then
> allocate the vEVENTQ.
>
> So we do not depend on ordering. We just check that both conditions
> are true, and allocate when the second one becomes true.
Perfect. That explanation works for me. If you respin maybe start
the explanation with the full conditions that must be met, then break
down why they occur in different orders in the cold and hotplug
(after we reach a particular point in guest boot) cases.
Jonathan
>
> Thanks,
> Shameer
>
next prev parent reply other threads:[~2026-02-24 16:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 9:00 [PATCH v7 0/5] vEVENTQ support for accelerated SMMUv3 devices Shameer Kolothum
2026-02-19 9:00 ` [PATCH v7 1/5] backends/iommufd: Introduce iommufd_backend_alloc_veventq Shameer Kolothum
2026-02-24 14:09 ` Jonathan Cameron via
2026-02-24 14:09 ` Jonathan Cameron via qemu development
2026-02-19 9:01 ` [PATCH v7 2/5] hw/arm/smmuv3-accel: Add viommu free helper Shameer Kolothum
2026-02-24 14:13 ` Jonathan Cameron via
2026-02-24 14:13 ` Jonathan Cameron via qemu development
2026-02-24 14:45 ` Shameer Kolothum Thodi
2026-02-19 9:01 ` [PATCH v7 3/5] hw/arm/smmuv3-accel: Allocate vEVENTQ for accelerated SMMUv3 devices Shameer Kolothum
2026-02-24 14:28 ` Jonathan Cameron via
2026-02-24 14:28 ` Jonathan Cameron via qemu development
2026-02-24 14:41 ` Shameer Kolothum Thodi
2026-02-24 15:01 ` Jonathan Cameron via
2026-02-24 15:01 ` Jonathan Cameron via qemu development
2026-02-24 15:18 ` Shameer Kolothum Thodi
2026-02-24 16:02 ` Jonathan Cameron via [this message]
2026-02-24 16:02 ` Jonathan Cameron via qemu development
2026-02-19 9:01 ` [PATCH v7 4/5] hw/arm/smmuv3: Introduce a helper function for event propagation Shameer Kolothum
2026-02-24 14:30 ` Jonathan Cameron via
2026-02-24 14:30 ` Jonathan Cameron via qemu development
2026-02-19 9:01 ` [PATCH v7 5/5] hw/arm/smmuv3-accel: Read and propagate host vIOMMU events Shameer Kolothum
2026-02-24 14:33 ` Jonathan Cameron via
2026-02-24 14:33 ` Jonathan Cameron via qemu development
2026-02-24 13:52 ` [PATCH v7 0/5] vEVENTQ support for accelerated SMMUv3 devices 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=20260224160255.000076e6@huawei.com \
--to=qemu-arm@nongnu.org \
--cc=eric.auger@redhat.com \
--cc=jan@nvidia.com \
--cc=jgg@nvidia.com \
--cc=jonathan.cameron@huawei.com \
--cc=kjaju@nvidia.com \
--cc=mochs@nvidia.com \
--cc=nathanc@nvidia.com \
--cc=nicolinc@nvidia.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=skolothumtho@nvidia.com \
--cc=zhangfei.gao@linaro.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.