On Sun, 2023-05-14 at 00:23 -0700, Kuppuswamy Sathyanarayanan wrote: > In TDX guest, the attestation process is used to verify the TDX guest > trustworthiness to other entities before provisioning secrets to the > guest. The First step in the attestation process is TDREPORT > generation, which involves getting the guest measurement data in the > format of TDREPORT, which is further used to validate the authenticity > of the TDX guest. TDREPORT by design is integrity-protected and can > only be verified on the local machine. > > To support remote verification of the TDREPORT (in a SGX-based > attestation), the TDREPORT needs to be sent to the SGX Quoting Enclave > (QE) to convert it to a remote verifiable Quote. SGX QE by design can > only run outside of the TDX guest (i.e. in a host process or in a > normal VM) and guest can use communication channels like vsock or > TCP/IP to send the TDREPORT to the QE. But for security concerns, the > TDX guest may not support these communication channels. To handle such > cases, TDX defines a GetQuote hypercall which can be used by the guest > to request the host VMM to communicate with the SGX QE. 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 an attestation agent > to submit GetQuote requests from the user space using GetQuote > hypercall. > > Since GetQuote is an asynchronous request hypercall, VMM will use the > callback interrupt vector configured by the 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 a large enough memory 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 reserves a fixed chunk of memory for GetQuote > requests, such one-time allocation is preferable to the alternative > choice of repeatedly allocating/freeing the shared buffer in the > TDX_CMD_GET_QUOTE IOCTL handler, which will damage the direct map > (because the sharing/unsharing process modifies the direct map). This > allocation model is similar to that used by the AMD SEV guest driver. > > Since the Quote generation process is not time-critical or frequently > used, the current version does not support parallel GetQuote requests. > > Reviewed-by: Tony Luck <tony.luck@xxxxxxxxx> > Reviewed-by: Andi Kleen <ak@xxxxxxxxxxxxxxx> > Reviewed-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx> > Reviewed-by: Erdem Aktas <erdemaktas@xxxxxxxxxx> > Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> > Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx> > Acked-by: Kai Huang <kai.huang@xxxxxxxxx>