CoCo: Use MMIO-based protocols (instead of vmcalls) for guest-host talk
Hi all,
This is to discuss the use of MMIO-based protocols for generic guest-host communication, e.g., getting a TSM report, delivering TDISP requests...
Note this is not formal proposals that have been agreed internally, just to start the conversation and gather feedback.
Background & Problem
====================
In CoCo world, many vCPU operations are handled by VMM via firmware-based vmcalls(GHCI/GHCB). The scope also extends to system operations like page attribute conversion & system event reporting. KVM handles these requests.
Later, people tend to use this vmcall mechanism as a generic communication
channel: guest exchanges some requests with userspace VMM/firmware on the channel. KVM doesn't actually handle these requests.
So KVM needs to interpret each vendor's vmcall opcode to find out which request needs to be parsed by KVM, which passes through to userspace/firmware. KVM also would like to define every request exiting to userspace via KVM uAPI instead of punting all vendor defined register states to userspace [1]. It is a maintenance burden that KVM doesn't act on these pass-through requests but needs continuous changes to relay them according to vendor SPEC.
TSM report(Quote) are the existing ones that use vmcalls to exchange attestation blobs with the firmware, see SVM_VMGEXIT_(EXT)_GUEST_REQUEST for AMD and TDVMCALL_GET_QUOTE for Intel. Trusted I/O are the upcoming ones, SVM_VMGEXIT_SEV_TIO_OP for AMD [2] and TDVMCALL_TDCM for Intel [3].
[1]: https://lore.kernel.org/kvm/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://lore.kernel.org/all/[email protected]/
BTW, more background for Trusted I/O requests: A guest exchanges TDISP-related requests/responses with the host to move an untrusted assigned device(TDI) into a trusted state. These requests include: TDI state transition (LOCK -> RUN -> UNLOCK); getting TDI attestation blobs; even some platform-specific requests, e.g., AMD has some requests to let the firmware verify that the MMIO/DMA mapping are set up as required and finally enable Trusted DMA. These Trusted I/O requests don't require KVM action, but need host driver (vendor TSM driver) mediation. For example, TDISP messages go through PCIe DOE mailbox, but the firmware can't control the device directly, the TSM driver relays the message.
New Direction
=============
Actually KVM doesn't need to be involved.
In last KVM forum, Sean mentions if we could use emulated MMIO to exit to userspace VMM and carry these request blobs ([1] also mentioned this approach). It seems we would need to define some virtual device. The guest writes the request into a shared buffer and triggers the VMM handler by an MMIO access.
Some research has been done before, mainly leveraging the virtio-vsock. The main concern was that virtio is too complex, and some VMMs, guests and guest boot phases can't support it. So we are looking for a lightweight MMIO-based protocol.
Some ideas:
==========
- Option 1:
- An lightweight virtio-mmio like device, enumerated by ACPI or Device tree. It supports all "guest requests" that GHCI/GHCB now has: Each vCPU can issue guest requests in parallel via its shared page.
- Concerns:
- The definition of the device is vague, the architectures decides which requests go through it. No clear definition.
- To mimic the nature of vmcalls which executes on per vCPU basis. A device should have per vCPU interfaces, seems weird.
- Option 2:
- Narrow the scope to Trusted-I/O. A virtual PCIe capability (a DVSEC) for TDISP capable devices which forwards the TDISP state transition/attestation request to the userspace VMM/firmware, so the scope of carried requests are naturally affined to the device
- One PCI config register receives a shared communication page (GPA).
- Another config register for the doorbell.
- Concerns:
- No support to other features like TSM report. Keep on using vmcall or
make a dedicated MMIO device for it?
Thanks for your time.
On Fri, 2026-12-04 at 15:32 +0800, Xu Yilun wrote:
I was initially pretty excited about this, for the reason of getting to skip adding KVM support for each new type of data that needs to be shuffled to userspace. But I've started to wonder if it actually makes sense once you apply it to the specific cases.
Quoted 4 lines
Some ideas:
==========
- Option 1:
Quoted 9 lines
- An lightweight virtio-mmio like device, enumerated by ACPI or Device tree. It supports all "guest requests" that GHCI/GHCB now has: Each vCPU can issue
guest requests in parallel via its shared page.
- Concerns:
- The definition of the device is vague, the architectures decides which requests go through it. No clear definition.
- To mimic the nature of vmcalls which executes on per vCPU basis. A device should have per vCPU interfaces, seems weird.
The nice thing about this is we could put all future GHCI calls that go to userspace in it too. However, what goes to userspace and what is handled within KVM is a KVM specific detail. Where as GHCI is supposed to be a cross-VMM interface.
Quoted 12 lines
- Option 2:
- Narrow the scope to Trusted-I/O. A virtual PCIe capability (a DVSEC) for TDISP capable devices which forwards the TDISP state transition/attestation request to the userspace VMM/firmware, so the scope of carried requests are naturally affined to the device
- One PCI config register receives a shared communication page (GPA).
- Another config register for the doorbell.
- Concerns:
- No support to other features like TSM report. Keep on using vmcall or make a dedicated MMIO device for it?
For option 2, then this doesn't become a generic GHCI mechanism for the future.
But on the point of what to do about trusted IO GHCI calls. Today some GHCI calls are handled by the kernel and some are morphed into KVM exits. Either to existing exits or new TDX specific ones.
The TDX TDCM GHCI calls closely mirror the standard TDISP operations. IIUC SNP has a special exit type, with a shared GPA. There is a clear text header in the payload involved in these VM exits, which also mirrors the standard TDISP operations.
We expect these will need to be passed to userspace too? So at least on the SNP side, these will either need to go out with one big KVM exit type, or morphed into 7-8 individual exits. Since the specific TDISP operation is embedded in the data in the shared memory, it probably ends up looking like one big exit.
So we might have the case where KVM has an exit type for this already. The matching SNP and TDX calls could be nudged to match, and use the same exit type or routing that SNP ends up needing to add. (I think the formats are pretty close already?) Then they share something like a KVM_EXIT_TIO.
But this would leave the generic problem still open.
Quoted 5 lines · Rick P
We expect these will need to be passed to userspace too? So at least on the SNP side, these will either need to go out with one big KVM exit type, or morphed into 7-8 individual exits. Since the specific TDISP operation is embedded in the data in the shared memory, it probably ends up looking like one big exit.
Yeah, all the GHCI mechanisms related to tdisp should go out to userspace, the VMM has to relay them back into the kernel on a different uAPI that is tied to the vdevice.
KVM doesn't have enough information to forward these on its own and we don't want to teach kvm about the vfio devices, or how the VMM has layed out the vPCI bus and so on.
I feel like everyone has already set their guest side specifications, so it is unlikely at this point we can just say we don't support those in a Linux hypervisor. So a new method is just going to be added along side the old ones without making things in aggregate simpler.
The time for standards was ages ago when all could have got together and made a Guest/VMM message channel with some standard messages on it for every implementation. That would have been tremendously helpful to the industry and greatly sped up upstreaming all of this.
Oh well.
Jason
Quoted 21 lines · Jason Gunthorpe
Quoted 5 lines · Rick P
We expect these will need to be passed to userspace too? So at least on the SNP side, these will either need to go out with one big KVM exit type, or morphed into 7-8 individual exits. Since the specific TDISP operation is embedded in the data in the shared memory, it probably ends up looking like one big exit.
Yeah, all the GHCI mechanisms related to tdisp should go out to userspace, the VMM has to relay them back into the kernel on a different uAPI that is tied to the vdevice.
KVM doesn't have enough information to forward these on its own and we don't want to teach kvm about the vfio devices, or how the VMM has layed out the vPCI bus and so on.
I feel like everyone has already set their guest side specifications, so it is unlikely at this point we can just say we don't support those in a Linux hypervisor. So a new method is just going to be added along side the old ones without making things in aggregate simpler.
Quoted 4 lines
The time for standards was ages ago when all could have got together and made a Guest/VMM message channel with some standard messages on it for every implementation. That would have been tremendously helpful to the industry and greatly sped up upstreaming all of this.
We are looking at this from the perspective that there can still be time to tweak TDX's GHCI interface to make it easier for KVM. If KVM is to eventually serve these calls, we need to get agreement before the guest can be called done. Sean raised some issues around the direction of the GHCI. So we need to get something that will be accepted eventually.