On Wed, Apr 12, 2023 at 8:42 PM Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx> wrote: > > In TDX guest, the second stage in attestation process is to send the > TDREPORT to QE/QGS to generate the TD Quote. For platforms that does > not support communication channels like vsock or TCP/IP, implement > support to get TD Quote using hypercall. GetQuote hypercall can be used > by the TD guest to request VMM facilitate the Quote generation via > QE/QGS. More details about GetQuote hypercall can be found in TDX > Guest-Host Communication Interface (GHCI) for Intel TDX 1.0, section > titled "TDG.VP.VMCALL<GetQuote>". > > Add support for TDX_CMD_GET_QUOTE IOCTL to allow attestation agent > submit GetQuote requests from the user space using GetQuote hypercall. > > Since GetQuote is an asynchronous request hypercall, VMM will use > callback interrupt vector configured by SetupEventNotifyInterrupt > hypercall to notify the guest about Quote generation completion or > failure. So register an IRQ handler for it. > > GetQuote TDVMCALL requires TD guest pass a 4K aligned shared buffer > with TDREPORT data as input, which is further used by the VMM to copy > the TD Quote result after successful Quote generation. To create the > shared buffer, allocate the required memory using alloc_pages() and > mark it shared using set_memory_decrypted() in tdx_guest_init(). This > buffer will be re-used for GetQuote requests in TDX_CMD_GET_QUOTE > IOCTL handler. > > Although this method will reserve a fixed chunk of memory for > GetQuote requests during the init time, it is preferable to the > alternative choice of allocating/freeing the shared buffer in the > TDX_CMD_GET_QUOTE IOCTL handler, which will damage the direct map. Thanks Sathyanarayanan for the work. The patch looks good. Reserving a fixed chunk of memory for GetQuote makes sense to me. And just want to re-emphasize that the TDVMCALL approach is important for many use cases that cannot depend on virtio/vsock.