From: Jason Gunthorpe <jgg@nvidia.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>
Cc: iommu@lists.linux.dev, Alex Williamson <alex@shazbot.org>,
Alexey Kardashevskiy <aik@amd.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Jacob Pan <jacob.pan@linux.microsoft.com>,
Joerg Roedel <joro@8bytes.org>,
Jonathan Cameron <jic23@kernel.org>,
Jonathan Hunter <jonathanh@nvidia.com>,
Kevin Tian <kevin.tian@intel.com>,
Krishna Reddy <vdumpa@nvidia.com>, Lukas Wunner <lukas@wunner.de>,
Nicolin Chen <nicolinc@nvidia.com>,
Robin Murphy <robin.murphy@arm.com>,
Samuel Ortiz <sameo@rivosinc.com>,
Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
Steven Price <steven.price@arm.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Thierry Reding <thierry.reding@kernel.org>,
Vasant Hegde <vasant.hegde@amd.com>,
Will Deacon <will@kernel.org>,
Xu Yilun <yilun.xu@linux.intel.com>,
kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v7 10/16] iommufd: Add the vdevice TSM request ioctl
Date: Thu, 29 Oct 2026 10:01:17 -0300 [thread overview]
Message-ID: <20261029130117.GH3040767@nvidia.com> (raw)
In-Reply-To: <yq5a1p98c0f5.fsf@kernel.org>
On Thu, Oct 29, 2026 at 03:07:34PM +0530, Aneesh Kumar K.V wrote:
> Jason Gunthorpe <jgg@nvidia.com> writes:
>
> >> [ ... 300 lines skipped ... ]
> >> +/**
> >> + * enum iommu_vdevice_tsm_guest_req_op - Guest TSM request operations
> >> + * @TSM_REQ_VALIDATE_MMIO: Validate and map a guest MMIO range for the trusted
> >> + * device.
> >> + * @TSM_REQ_SET_TDI_STATE: Transition the trusted device to the unlocked,
> >> + * locked, or running state.
> >> + * @TSM_REQ_SEV_ENABLE_DMA: Enable DMA for an SEV device.
> >> + * @TSM_REQ_SEV_DISABLE_DMA: Disable DMA for an SEV device.
> >> + * @TSM_REQ_READ_OBJECT: Read bytes from a device object, such as a certificate,
> >> + * measurement, or interface report.
> >> + * @TSM_REQ_REGEN_OBJECT: Regenerate a device object, such as a measurement or
> >> + * interface report.
> >> + * @TSM_REQ_OBJECT_INFO: Query the size of a device object.
> >> + * @TSM_REQ_MAX: One past the last request operation; not a command.
> >> + *
> >> + * The request payload and response format depend on the TVM architecture.
> >> + */
> >> +enum iommu_vdevice_tsm_guest_req_op {
> >> + TSM_REQ_VALIDATE_MMIO = 1,
> >> + TSM_REQ_SET_TDI_STATE,
> >> + TSM_REQ_SEV_ENABLE_DMA,
> >> + TSM_REQ_SEV_DISABLE_DMA,
> >> + TSM_REQ_READ_OBJECT,
> >> + TSM_REQ_REGEN_OBJECT,
> >> + TSM_REQ_OBJECT_INFO,
> >> + TSM_REQ_MAX,
> >> +};
> >
> > This is still no where close to being well defined enough.
> >
> > Everything here must tie back to defined spec references, listed in
> > the comments.
> >
> > I cannot guess what data is passed over any of these APIs, how things
> > like "REGEN_OBJECT" select which object to regen, or what the format
> > of those objects even is. The formats of req/resp are never specified.
> >
>
> The request and response payload formats are specific to each CoCo
> backend. Since iommufd treats the payloads as opaque and does not
> validate their contents, what would documenting those formats here
> achieve?
Well if thats the case then no, this is entirely inappropriate.
iommufd requires every single struct to be documented and
described. We do not do undocumented opaque structs into drivers.
So figure out exactly what needs to flow here, give it driver specific
names for driver specific content and document everything.
This should be done patch by patch as the drivers implement their
stuff.
If the data passed is different then it gets a different enum
value. No sharing enum values for different structs because the
drivers are different.
You can say things like 'the content of the RHI message defined in
XYZ' as operations.
> The limited validation is intended to prevent this from becoming a
> general-purpose multiplexer ioctl.
But we need that for other viommu use cases..
> It restricts the ioctl to a defined set of guest-initiated
> operations that the host forwards to the
> firmware. The path is essentially:
>
> guest -> vmexit -> VMM -> iommufd ioctl -> TSM backend -> firmware
Yeah, I'm not adverse to this, so long as it is fully documented and
understandable how each system call maps to both the guest and
firmware interfaces it is supporting.
> > The comment for this should probably be *enormous*. Every arch should
> > explain what they do on every one of these ops, and it should be
> > identical if it is structured like this.
> >
>
> That would require documenting a significant amount of backend-specific
> detail in iommufd. Could we instead require each TSM backend's
> guest_request callback to document its request and response formats?
It needs to be in this header, that is the standard.
> > My guesses with no information
> > 1) VALIDATE_MMIO why would the hypervisor ever need this? Guest
> > validates MMIO through secure communication to the secure world.
> >
>
> With VFIO PCI BARs backed by guest_memfd, the VMM can validate that the
> IPA and PA values provided by the guest belong to the VFIO device.
Why? Who cares? It isn't a trusted validation, and there is a RSI that
duplicates this?
> We previously also used this operation to ask the CoCo TSM backend
> to map the device memory (the BAR regions). I have removed this
> operation from the latest series because that responsibility is now
> split between the VMM and guest_memfd. TDX and SNP still need to be
> updated accordingly.
Right, it should happen automatically as part of lock.
> > 2) TDI_STATE I thought at least RMM did this with an RSI?
>
> CCA uses RHI. The RHI reaches the VMM, which issues the ioctl to
> complete the request.
And then the seq numbers check that this went through OK?
> > 3) ENABLE/DISABLE DMA, see #1, must not be done by hypervisor
> > See my reply to Alexey:
> > https://lore.kernel.org/linux-iommu/20261022123058.GC3008132@nvidia.com/
> >
> > 4) READ/REGEN/INFO, what are the objects? What format are they in? How
> > do you select them?
>
> These objects are cached by the hypervisor. For CCA, they include the
> certificate, measurement, interface report, and VCA. They are read in
> response to guest requests. The requests reach the VMM through an
> RHI, and the VMM issues the ioctl to read the requested object. REGEN
> refreshes the objects/evidence at the guest's request.
> > Does this overlap with attestation subsystem? Should attestation
> > subsystem be used to access the SPDM related data?
> >
>
>
> I had hoped we could use it, but I could not find an easy way to
> integrate the two. We need a simple way to read these evidence objects
> into userspace. I am not yet sure whether evidence-get can be used for
> that, since it does more than simply read the objects; it also updates
> evidence.generation, among other things.
It should not do that, the generation has to follow the locked state,
not the evidence collection.. See my remark to Dave
I think the bigger issue was it had to use the VDEV flavour not the
PDEV flavor of RMM commands, and it isn't obvious how we switch from
PDEV to VDEV mode on the hypervisor..
> > I think this is probably a fine generic API, it should probably not be
> > "TSM request" so that the other viommu people can reuse the transport.
> >
> > I would probably try to stick to exactly like the other APIs do with a
> > single enum. Two enums for op/arch is saying already that the ops are
> > not well defined.
> >
> > So maybe strip this patch out to have no tsm stuff, define no ops and
> > just give a command transport into the viommu driver?
> >
>
> Are you suggesting one ioctl per each guest request ops?
One 'u32 op'
Jason
next prev parent reply other threads:[~2026-10-29 13:01 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 5:59 [PATCH v7 00/16] iommufd: vIOMMUs and TSM guest requests for confidential guests Aneesh Kumar K.V (Arm)
2026-10-08 5:59 ` [PATCH v7 01/16] KVM: Introduce file_to_kvm_<arch>() infrastructure Aneesh Kumar K.V (Arm)
2026-10-08 6:11 ` sashiko-bot
2026-10-08 5:59 ` [PATCH v7 02/16] KVM: Add file back-pointer to struct kvm Aneesh Kumar K.V (Arm)
2026-10-08 6:16 ` sashiko-bot
2026-10-08 5:59 ` [PATCH v7 03/16] KVM: x86: Use file_to_kvm_x86() in SEV Aneesh Kumar K.V (Arm)
2026-10-08 6:07 ` sashiko-bot
2026-10-08 5:59 ` [PATCH v7 04/16] KVM/vfio: Use file-based reference counting for KVM Aneesh Kumar K.V (Arm)
2026-10-08 6:27 ` sashiko-bot
2026-10-08 5:59 ` [PATCH v7 05/16] KVM: Restrict kvm_get_kvm/kvm_put_kvm export to internal KVM modules Aneesh Kumar K.V (Arm)
2026-10-08 6:08 ` sashiko-bot
2026-10-08 5:59 ` [PATCH v7 06/16] KVM: Remove unused file_is_kvm Aneesh Kumar K.V (Arm)
2026-10-08 6:06 ` sashiko-bot
2026-10-08 5:59 ` [PATCH v7 07/16] iommufd/device: Associate KVM file pointer with iommufd_device Aneesh Kumar K.V (Arm)
2026-10-08 6:20 ` sashiko-bot
2026-10-08 5:59 ` [PATCH v7 08/16] iommufd/viommu: Keep a reference to the KVM file Aneesh Kumar K.V (Arm)
2026-10-08 6:10 ` sashiko-bot
2026-10-14 17:59 ` Jacob Pan
2026-10-29 6:26 ` Aneesh Kumar K.V
2026-10-28 19:07 ` Jason Gunthorpe
2026-10-08 5:59 ` [PATCH v7 09/16] tsm: Remove the device from lookup before PCI teardown Aneesh Kumar K.V (Arm)
2026-10-08 6:15 ` sashiko-bot
2026-10-12 9:14 ` Aneesh Kumar K.V
2026-10-12 13:01 ` Jason Gunthorpe
2026-10-13 8:49 ` Aneesh Kumar K.V
2026-10-13 11:57 ` Jason Gunthorpe
2026-10-29 4:22 ` Xu Yilun
2026-10-28 19:07 ` Jason Gunthorpe
2026-10-29 6:56 ` Aneesh Kumar K.V
2026-10-08 5:59 ` [PATCH v7 10/16] iommufd: Add the vdevice TSM request ioctl Aneesh Kumar K.V (Arm)
2026-10-08 6:10 ` sashiko-bot
2026-10-28 19:07 ` Jason Gunthorpe
2026-10-29 9:37 ` Aneesh Kumar K.V
2026-10-29 13:01 ` Jason Gunthorpe [this message]
2026-10-08 5:59 ` [PATCH v7 11/16] PCI/TSM: Remove the legacy guest request interface Aneesh Kumar K.V (Arm)
2026-10-08 6:11 ` sashiko-bot
2026-10-28 19:07 ` Jason Gunthorpe
2026-10-08 5:59 ` [PATCH v7 12/16] PCI/TSM: Add vIOMMU-bound contexts for vdevices Aneesh Kumar K.V (Arm)
2026-10-08 6:18 ` sashiko-bot
2026-10-28 19:07 ` Jason Gunthorpe
2026-10-08 5:59 ` [PATCH v7 13/16] iommufd/viommu: Select vIOMMU operations before allocation Aneesh Kumar K.V (Arm)
2026-10-08 6:27 ` sashiko-bot
2026-10-12 9:37 ` Aneesh Kumar K.V
2026-10-12 13:05 ` Jason Gunthorpe
2026-10-13 9:11 ` Aneesh Kumar K.V
2026-10-13 12:33 ` Jason Gunthorpe
2026-10-28 19:07 ` Jason Gunthorpe
2026-10-29 8:21 ` Aneesh Kumar K.V
2026-10-29 12:43 ` Jason Gunthorpe
2026-10-08 5:59 ` [PATCH v7 14/16] iommufd/viommu: Allow PCI TSM backends to provide vIOMMU operations Aneesh Kumar K.V (Arm)
2026-10-08 6:19 ` sashiko-bot
2026-10-12 9:55 ` Aneesh Kumar K.V
2026-10-28 19:07 ` Jason Gunthorpe
2026-10-08 5:59 ` [PATCH v7 15/16] iommufd: Allow vIOMMUs without a parent HWPT Aneesh Kumar K.V (Arm)
2026-10-08 6:24 ` sashiko-bot
2026-10-28 19:07 ` Jason Gunthorpe
2026-10-08 5:59 ` [PATCH v7 16/16] PCI/TSM: wait for vdevice contexts before removing a DSM Aneesh Kumar K.V (Arm)
2026-10-08 6:25 ` sashiko-bot
2026-10-12 20:34 ` Bjorn Helgaas
2026-10-28 19:07 ` 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=20261029130117.GH3040767@nvidia.com \
--to=jgg@nvidia.com \
--cc=aik@amd.com \
--cc=alex@shazbot.org \
--cc=aneesh.kumar@kernel.org \
--cc=bhelgaas@google.com \
--cc=catalin.marinas@arm.com \
--cc=iommu@lists.linux.dev \
--cc=jacob.pan@linux.microsoft.com \
--cc=jic23@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=sameo@rivosinc.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=steven.price@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=suzuki.poulose@arm.com \
--cc=thierry.reding@kernel.org \
--cc=vasant.hegde@amd.com \
--cc=vdumpa@nvidia.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