Re: [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote
From: Adrian Hunter
Date: Fri Dec 04 2026 - 16:44:41 EST
On 04/12/2026 20:18, Peter Fang wrote:
> +int tdx_quote_generate(struct tdx_td *td, u16 session_id,
> + struct page *report_page, u64 report_size,
> + struct page **quote_pages, u64 quote_buf_size,
> + u64 *quote_size, u64 *seamcall_err)
> +{
> + int num_quote_pages, num_nodes, ret = 0;
> + u64 *node_head, *node_entry;
> + u64 r;
> +
> + /*
> + * Pass the quote buffer to the TDX module as an HPA linked list. Each
> + * node holds 4KB page HPAs and the last entry points to the next node.
> + */
> + node_head = kmalloc(PAGE_SIZE, GFP_KERNEL);
> + if (!node_head)
> + return -ENOMEM;
> +
> + node_entry = node_head;
> + num_quote_pages = PFN_UP(quote_buf_size);
> + num_nodes = 1;
> +
> + /* Populate the linked list. Allocate new nodes as needed. */
> + for (int i = 0, pages = 0; pages < num_quote_pages;
> + i = (i + 1) % HPAS_PER_NODE) {
> + if (i == HPAS_PER_NODE - 1) {
> + u64 *new_node = kmalloc(PAGE_SIZE, GFP_KERNEL);
> +
> + if (!new_node) {
> + ret = -ENOMEM;
> + goto out_free_nodes;
> + }
> +
> + /* Write the 'next' pointer. */
> + node_entry[i] = __pa(new_node);
> + node_entry = new_node;
> + num_nodes++;
> + continue;
> + }
> +
> + node_entry[i] = page_to_phys(quote_pages[pages]);
> + pages++;
> + }
TDX HPA_LINKED_LIST format is used also by TDX Live Migration, so
it needs to be separate from quote functions.