Re: [RFC PATCH 15/15] virt: tdx-guest: Accept default DMAR entry during PCI driver attach

From: Jason Gunthorpe

Date: Mon Oct 26 2026 - 08:13:28 EST


On Mon, Oct 26, 2026 at 03:49:30PM +0800, Xiaoyao Li wrote:

> > +static int tdx_devsec_enable_dma(struct pci_dev *pdev)
> > +{
> > + int ret = tdx_mcall_dmar_accept(pci_dev_id(pdev), 0);
>
> after going through the series, I have a basic question on guest function_id.
>
> Per TDX connect API spec, TDG.DMAR.ACCEPT, TDG.DMAR.RELEASE,
> TDG.TDI.MMIO.ACCEPT, TDG.TDI.RD and TDG.TDI.START all require guest function_id
> as input parameter. However, the guest function_id is specified by the host VMM
> on TDH.TDI.CREATE.
>
> So how can the guest ensure pci_dev_id(pdev) is the value that will be specified
> by the host VMM?

It is not supposed to matter.

The VM sees a device composed of a bunch of stuff: a BDF, some memory
ranges, IRQs, etc.

It locks the device and then it has to query TDX module to confirm
that the memory, etc are all part of the same device. Mismatching is a
bad failure.

If the VMM is messing with things so the function_id is mismatched
then the guest will detect it and fail validating the memory ranges.

Jason