From: Alexey Kardashevskiy <aik@amd.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
"Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>
Cc: linux-coco@lists.linux.dev, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Jason Gunthorpe <jgg@ziepe.ca>,
Bjorn Helgaas <helgaas@kernel.org>,
Joerg Roedel <joro@8bytes.org>,
Jonathan Cameron <jic23@kernel.org>,
Kevin Tian <kevin.tian@intel.com>,
Nicolin Chen <nicolinc@nvidia.com>,
Samuel Ortiz <sameo@rivosinc.com>,
Steven Price <steven.price@arm.com>,
Suzuki K Poulose <Suzuki.Poulose@arm.com>,
Will Deacon <will@kernel.org>,
Xu Yilun <yilun.xu@linux.intel.com>,
Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [RFC PATCH v6 09/11] iommufd: Add the vdevice TSM request ioctl
Date: Thu, 22 Oct 2026 18:16:04 +1100 [thread overview]
Message-ID: <d9304f91-2371-460b-8616-15a4f96c5674@amd.com> (raw)
In-Reply-To: <179027891417.104879.282447770434616733.b4-review@b4>
On 25/9/26 05:41, Jason Gunthorpe wrote:
>> [ ... 95 lines skipped ... ]
>> +static bool iommufd_vdevice_tsm_req_arch_valid(u32 tvm_arch)
>> +{
>> + switch (tvm_arch) {
>> + case IOMMU_VDEVICE_TSM_TVM_ARCH_CCA:
>> + case IOMMU_VDEVICE_TSM_TVM_ARCH_SEV:
>> + case IOMMU_VDEVICE_TSM_TVM_ARCH_TDX:
>> + return true;
>> + default:
>> + return false;
>> + }
>> +}
>
> Generally speaking we should not do things like this, the viommu
> object should declare what it supports if we want to have validation
> on the iommufd side.
>
>> [ ... 140 lines skipped ... ]
>> +#ifdef CONFIG_TSM
>> +/**
>> + * struct tsm_guest_req_info - parameters for a guest-initiated TSM request
>> + * @op: operation for the guest-initiated request
>> + * @tvm_arch: guest TVM architecture
>> + * @req: request data buffer filled by guest
>> + * @req_len: the size of @req filled by guest
>> + * @resp: response data buffer filled by host
>> + * @resp_len: the size of @resp buffer filled by guest
>> + */
>> +struct tsm_guest_req_info {
>> + enum iommu_vdevice_tsm_guest_req_op op;
>> + enum iommu_vdevice_tsm_guest_tvm_arch tvm_arch;
>> + sockptr_t req;
>> + size_t req_len;
>> + sockptr_t resp;
>> + size_t resp_len;
>> +};
>
> Why is this struct in tsm land?
>
> I'm not seeing why the iommufd interface should be locked to tsm, as I
> said other viommus need this kind of command channel too. Can't we
> have a general one?
>
> Why would it ever not be tied to userspace pointers? I don't want
> an in kernel user ever using this kind of struct?
This mimics the TSM's pci_tsm_guest_req() API which it is a kernel component we did not want to hardcode to use userspace pointers as it does not have uAPI. Makes no sense in tsm_guest_req_info though.
>> [ ... 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.
This is a guest request to the PSP which does control T=1, the HV is forwarding it and does some extra stuff while there. Probably could be decoupled and go to a separate ioctl().
The HV does not control DMA, it is for configuring DTE in a specific way - the domainid becomes reserved (and its sDTE counterpart starts working) and some other DTE bits have to match whatever the PSP writes to sDTE ("I" == IOTLB enable) and probably more.
And then, yeah, "something something RMP" == cut 2MB mappings if corresponding RMP is not 2MB.
Thanks,
>
>> + * @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.
>
>> [ ... 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
>
--
Alexey
next prev parent reply other threads:[~2026-10-22 7:16 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 14:01 [RFC PATCH v6 00/11] iommufd: Infrastructure for vIOMMU creation for confidential guests and guest TSM requests Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 01/11] vfio: cache KVM VM file references instead of raw struct kvm pointers Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-30 7:19 ` Aneesh Kumar K.V
2026-09-17 14:01 ` [RFC PATCH v6 02/11] vfio: cdev: Reject duplicate bind before updating KVM file Aneesh Kumar K.V (Arm)
2026-09-24 7:53 ` Tian, Kevin
2026-09-25 5:49 ` Aneesh Kumar K.V
2026-09-17 14:01 ` [RFC PATCH v6 03/11] iommufd/device: Associate KVM file pointer with iommufd_device Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 04/11] iommufd/viommu: Keep a reference to the KVM file Aneesh Kumar K.V (Arm)
2026-09-30 13:28 ` Vasant Hegde
2026-10-02 5:26 ` Aneesh Kumar K.V
2026-09-17 14:01 ` [RFC PATCH v6 05/11] iommu: Add a helper to validate a vIOMMU parent Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 5:48 ` Aneesh Kumar K.V
2026-09-25 12:23 ` Jason Gunthorpe
2026-09-28 10:36 ` Aneesh Kumar K.V
2026-09-28 12:11 ` Jason Gunthorpe
2026-09-28 15:39 ` Aneesh Kumar K.V
2026-09-28 16:17 ` Jason Gunthorpe
2026-09-28 18:08 ` Jacob Pan
2026-09-28 18:20 ` Jason Gunthorpe
2026-09-28 22:24 ` Jacob Pan
2026-09-28 23:03 ` Jason Gunthorpe
2026-09-29 5:55 ` Jacob Pan
2026-09-29 12:30 ` Jason Gunthorpe
2026-09-29 23:15 ` Jacob Pan
2026-09-29 23:30 ` Jason Gunthorpe
2026-09-17 14:01 ` [RFC PATCH v6 06/11] iommu: Add a helper to query vIOMMU hardware parameters Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 5:59 ` Aneesh Kumar K.V
2026-09-25 12:29 ` Jason Gunthorpe
2026-09-17 14:01 ` [RFC PATCH v6 07/11] coco: tsm: Expose active-user lifetime references Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 08/11] iommufd: Add vIOMMU provider support Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 6:08 ` Aneesh Kumar K.V
2026-09-25 12:39 ` Jason Gunthorpe
2026-09-28 3:41 ` Tian, Kevin
2026-09-29 6:14 ` Aneesh Kumar K.V
2026-09-29 12:17 ` Jason Gunthorpe
2026-09-29 12:45 ` Aneesh Kumar K.V
2026-09-29 13:06 ` Jason Gunthorpe
2026-09-29 15:58 ` Aneesh Kumar K.V
2026-09-29 19:10 ` Jason Gunthorpe
2026-09-28 10:51 ` Aneesh Kumar K.V
2026-09-17 14:01 ` [RFC PATCH v6 09/11] iommufd: Add the vdevice TSM request ioctl Aneesh Kumar K.V (Arm)
2026-09-18 13:09 ` Alexey Kardashevskiy
2026-09-18 13:13 ` Jason Gunthorpe
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-30 8:03 ` Aneesh Kumar K.V
2026-09-30 13:26 ` Vasant Hegde
2026-09-30 14:03 ` Jason Gunthorpe
2026-09-30 14:08 ` Jason Gunthorpe
2026-10-22 7:16 ` Alexey Kardashevskiy [this message]
2026-09-17 14:01 ` [RFC PATCH v6 10/11] PCI/TSM: Remove the legacy guest request interface Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 11/11] PCI/TSM: Add reference-counted contexts for vdevice providers Aneesh Kumar K.V (Arm)
2026-09-24 8:17 ` Tian, Kevin
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 8:15 ` Aneesh Kumar K.V
2026-09-28 18:47 ` Sonang Patel
2026-09-28 23:08 ` Jason Gunthorpe
2026-10-02 6:14 ` Aneesh Kumar K.V
2026-10-02 13:06 ` Jason Gunthorpe
2026-09-17 14:17 ` [RFC PATCH v6 00/11] iommufd: Infrastructure for vIOMMU creation for confidential guests and guest TSM requests Aneesh Kumar K.V
2026-09-24 7:48 ` Tian, Kevin
2026-09-24 19:20 ` Jason Gunthorpe
2026-09-28 3:35 ` Tian, Kevin
2026-09-28 13:08 ` Jason Gunthorpe
2026-09-25 8:29 ` Aneesh Kumar K.V
2026-09-28 3:41 ` Tian, Kevin
2026-09-28 3:55 ` Tian, Kevin
2026-09-24 19:09 ` Jason Gunthorpe
2026-09-25 6:46 ` Aneesh Kumar K.V
2026-09-25 12:45 ` Jason Gunthorpe
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=d9304f91-2371-460b-8616-15a4f96c5674@amd.com \
--to=aik@amd.com \
--cc=Suzuki.Poulose@arm.com \
--cc=aneesh.kumar@kernel.org \
--cc=helgaas@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=jgg@ziepe.ca \
--cc=jic23@kernel.org \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=pbonzini@redhat.com \
--cc=sameo@rivosinc.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=steven.price@arm.com \
--cc=will@kernel.org \
--cc=yilun.xu@linux.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
all inboxes | Powered by JetHome®