Re: [RFC PATCH v2 15/15] misc/arm-cla: Add vfio-mdev user interface
From: Linus Walleij
Date: Wed Nov 25 2026 - 07:43:22 EST
Hi Ryan, Jean-Philippe,
this patch series now moves into the virtualization stratosphere where
my knowledge doesn't even reach the level of "a little knowledge
is dangerous", people versed with virtualization need to review this.
A few general remarks though:
On Thu, Oct 15, 2026 at 4:27 PM Ryan Roberts <ryan.roberts@xxxxxxx> wrote:
> From: Jean-Philippe Brucker <jpb@xxxxxxxxxx>
>
> Implement an interface to assign CLA devices to KVM guests. To creates a
> CLA instance:
>
> uuid=$(uuidgen)
> echo $uuid > /sys/class/mdev_bus/<pdev>/mdev_supported_types/arm-cla-pl1/create
> cla_cpu=$(< /sys/bus/mdev/devices/$uuid/cpu)
>
> This creates a user interface in /dev/vfio: a VFIO group in
> /dev/vfio/<n>, discoverable by reading the symlink
> /sys/bus/mdev/devices/$uuid/iommu_group. Although CLA does not use an
> IOMMU, VFIO relies on IOMMU groups as an assignable unit. Here they
> correspond to CLA domains, whose devices communicate through a private
> bus.
>
> The CLA device gets assigned exclusively to the first VMM that opens the
> VFIO group and device. To launch a VM with a CLA attached to vCPU #4,
> with kvmtool:
>
> lkvm run -k Image --console virtio -c 8
> --vfio-platform $uuid,type=arm-cla,vcpu=4
> --vcpu-affinity 4=$cla_cpu # Bind vCPU 4 to the CLA's CPU
>
> Opens the group, gets the device fd, mmaps the frame, and launches the
> guest. The given vCPU thread is pinned to the CLA's CPU.
>
> Pinning vCPUs is not guaranteed. If the host decides to power off the
> CPUs with assigned CLAs, the guest application can't access the assigned
> device anymore. It would now access a RAZ/WI memory region.
>
> For DMA, because the TLB entries tagged with VMID+ASID are shared
> between CPU and accelerator, we pin the VMID. The stage 2 page tables
> are shared between CPU and CLA. CLA reports DMA page faults directly to
> the user, who performs the access from the CPU to handle both stage 1
> and stage 2 faults.
>
> Signed-off-by: Jean-Philippe Brucker <jpb@xxxxxxxxxx>
I understand the patch as this:
The CLA register window of the CLA attached to one certain CPU
can be exposed to a virtual machine by way of VFIO, that is, this
virtual machine can see that memory as if was its own.
This makes me ask the following questions:
1. Is the intended user of that VFIO window a kernel driver or
"some userspace mockery", i.e. a plain old userspace driver just
using the hardware from userspace. This is something I have
seen in code trees from the likes of SpaceX, where VFIO is
used for antenna array hardware and handled with userspace
drivers (and the userspace driver
is run with realtime priorities for high responsivity usecases).
The use case matters for the design of the VFIO exposure,
because if in-kernel users of the same hardware from the
host can be expected this could become less than elegant.
I don't know for sure, it may make perfect sense if the user
is some userspace process doing some computation I need
not worry my head about.
2.The affinity story again: certainly this VM must be pinned to
the CPU exposing the CLA and the VM will see *one* CPU
in its world, or this would never work, right? We are not doing
any multicore virtualized machines because then you would
need each to expose a different VFIO window for each CPU?
(I think I saw the kvm usecase only allowing for one instance,
no domains, so I guess yes.)
I don't know how much VMs migrate on a running system.
But if a "normal" VFIO window pertains to the "normal"
physical address space I suppose this is not a problem, you
can move the VM to another CPU and everything else
remains the same. But not so with CLA! So how do you
intend to impose this restriction?
Yours,
Linus Walleij