1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 3 #ifndef QEMU_I386_TDX_QUOTE_GENERATOR_H 4 #define QEMU_I386_TDX_QUOTE_GENERATOR_H 5 6 #include "qom/object_interfaces.h" 7 #include "io/channel-socket.h" 8 #include "exec/hwaddr.h" 9 10 #define TDX_GET_QUOTE_STRUCTURE_VERSION 1ULL 11 12 #define TDX_VP_GET_QUOTE_SUCCESS 0ULL 13 #define TDX_VP_GET_QUOTE_IN_FLIGHT (-1ULL) 14 #define TDX_VP_GET_QUOTE_ERROR 0x8000000000000000ULL 15 #define TDX_VP_GET_QUOTE_QGS_UNAVAILABLE 0x8000000000000001ULL 16 17 /* Limit to avoid resource starvation. */ 18 #define TDX_GET_QUOTE_MAX_BUF_LEN (128 * 1024) 19 #define TDX_MAX_GET_QUOTE_REQUEST 16 20 21 #define TDX_GET_QUOTE_HDR_SIZE 24 22 23 /* Format of pages shared with guest. */ 24 struct tdx_get_quote_header { 25 /* Format version: must be 1 in little endian. */ 26 uint64_t structure_version; 27 28 /* 29 * GetQuote status code in little endian: 30 * Guest must set error_code to 0 to avoid information leak. 31 * Qemu sets this before interrupting guest. 32 */ 33 uint64_t error_code; 34 35 /* 36 * in-message size in little endian: The message will follow this header. 37 * The in-message will be send to QGS. 38 */ 39 uint32_t in_len; 40 41 /* 42 * out-message size in little endian: 43 * On request, out_len must be zero to avoid information leak. 44 * On return, message size from QGS. Qemu overwrites this field. 45 * The message will follows this header. The in-message is overwritten. 46 */ 47 uint32_t out_len; 48 49 /* 50 * Message buffer follows. 51 * Guest sets message that will be send to QGS. If out_len > in_len, guest 52 * should zero remaining buffer to avoid information leak. 53 * Qemu overwrites this buffer with a message returned from QGS. 54 */ 55 }; 56 57 typedef struct TdxGenerateQuoteTask { 58 hwaddr buf_gpa; 59 hwaddr payload_gpa; 60 uint64_t payload_len; 61 62 char *send_data; 63 uint64_t send_data_size; 64 uint64_t send_data_sent; 65 66 char *receive_buf; 67 uint64_t receive_buf_received; 68 69 uint64_t status_code; 70 struct tdx_get_quote_header hdr; 71 72 QIOChannelSocket *sioc; 73 guint watch; 74 QEMUTimer timer; 75 76 void (*completion)(struct TdxGenerateQuoteTask *task); 77 void *opaque; 78 } TdxGenerateQuoteTask; 79 80 void tdx_generate_quote(TdxGenerateQuoteTask *task, SocketAddress *qg_sock_addr); 81 82 #endif /* QEMU_I386_TDX_QUOTE_GENERATOR_H */ 83