Re: [RFC PATCH v6 09/11] iommufd: Add the vdevice TSM request ioctl

From: Vasant Hegde

Date: Wed Sep 30 2026 - 10:06:00 EST


On 9/30/2026 1:33 PM, Aneesh Kumar K.V wrote:
> Jason Gunthorpe <jgg@xxxxxxxxxx> writes:
>

.../...

>
>>
>>> [ ... 34 lines skipped ... ]
>>> +/**
>>> + * enum iommu_vdevice_tsm_guest_req_op - operation for guest TSM requests
>>> + * @TSM_REQ_VALIDATE_MMIO: Validate MMIO for the TDI
>>> + * @TSM_REQ_SET_TDI_STATE: Set TDI state
>>> + * @TSM_REQ_SEV_ENABLE_DMA: Enable SEV DMA
>>
>> That seems wrong.. The hypervisor should not have control over T=1
>> DMA.
>>

(Still catching up with entire thread)

In case of AMD IOMMU, before allowing DMA from secure guest, we have to update
IOMMU host (nested) page table entry size to match the RMP table.

-Vasant

>
> This was added specifically for AMD SEV, which requires an IOMMU-side
> update to enable DMA.
>
>>
>>> + * @TSM_REQ_SEV_DISABLE_DMA: Disable SEV DMA
>>> + * @TSM_REQ_READ_OBJECT: Read a TSM object
>>> + * @TSM_REQ_REGEN_OBJECT: Regenerate a TSM object
>>> + * @TSM_REQ_OBJECT_INFO: Read TSM object information
>>> + */
>>
>> These operations will need alot more commentary. Use kdocs inside the
>> enum below to make that easier.
>>
>
>
> I will add kernel-doc comments for the operations used by CCA.
>
> We have gone through several iterations to identify the guest
> passthrough request facility we need. IIUC, both TDX and CCA give the
> hypervisor some control over the request type, while SEV-TIO is more
> opaque.
>
>
>>
>>> [ ... 10 lines skipped ... ]
>>> +/**
>>> + * struct iommu_vdevice_tsm_req - ioctl(IOMMU_VDEVICE_TSM_REQ)
>>> + * @size: sizeof(struct iommu_vdevice_tsm_req)
>>> + * @vdevice_id: vDevice ID the guest request is for
>>> + * @op: One of enum iommu_vdevice_tsm_guest_req_op
>>> + * @tvm_arch: One of enum iommu_vdevice_tsm_guest_tvm_arch
>>> + * @req_len: Size in bytes of the input payload at @req_uptr
>>> + * @resp_len: Size in bytes of the output buffer at @resp_uptr
>>> + * @req_uptr: Userspace pointer to the guest-provided request payload
>>> + * @resp_uptr: Userspace pointer to the guest response buffer
>>> + * @tsm_code: TSM-specific result code returned by the TSM implementation
>>> + *
>>> + * Forward a TSM request to the TSM bound vDevice. This is intended for
>>> + * guest TSM/TDISP message transport where the host kernel only marshals
>>> + * bytes between userspace and the TSM implementation.
>>> + *
>>> + * The request operation is guest initiated. The TSM backend validates
>>> + * @tvm_arch against its bound TVM architecture assumptions.
>>> + *
>>> + * The request payload is read from @req_uptr/@req_len. If a response is
>>> + * expected, userspace provides @resp_uptr/@resp_len as writable storage for
>>> + * response bytes returned by the TSM path.
>>> + *
>>> + * The ioctl is only suitable for commands and results that the host kernel
>>> + * has no use, the host is only facilitating guest to TSM communication.
>>> + */
>>> +struct iommu_vdevice_tsm_req {
>>> + __u32 size;
>>> + __u32 vdevice_id;
>>> + __u32 op;
>>> + __u32 tvm_arch;
>>> + __u32 req_len;
>>> + __u32 resp_len;
>>> + __aligned_u64 req_uptr;
>>> + __aligned_u64 resp_uptr;
>>> + __aligned_u64 tsm_code;
>>
>> out_tsm_code
>>
>
> That is required for SEV-TIO.
>
> -aneesh