History

KVM: TDX: Handle TDG.VP.VMCALL<GetQuote>

Handle TDVMCALL for GetQuote to generate a TD-Quote. GetQuote is a doorbell-like interface used by TDX guests to request VMM to generate a TD-Quote signed by a service hosting TD-Quoting Enclave operating on the host. A TDX guest passes a TD Report (TDREPORT_STRUCT) in a shared-memory area as parameter. Host VMM can access it and queue the operation for a service hosting TD-Quoting enclave. When completed, the Quote is returned via the same shared-memory area. KVM only checks the GPA from the TDX guest has the shared-bit set and drops the shared-bit before exiting to userspace to avoid bleeding the shared-bit into KVM's exit ABI. KVM forwards the request to userspace VMM (e.g. QEMU) and userspace VMM queues the operation asynchronously. KVM sets the return code according to the 'ret' field set by userspace to notify the TDX guest whether the request has been queued successfully or not. When the request has been queued successfully, the TDX guest can poll the status field in the shared-memory area to check whether the Quote generation is completed or not. When completed, the generated Quote is returned via the same buffer. Add KVM_EXIT_TDX as a new exit reason to userspace. Userspace is required to handle the KVM exit reason as the initial support for TDX, by reentering KVM to ensure that the TDVMCALL is complete. While at it, add a note that KVM_EXIT_HYPERCALL also requires reentry with KVM_RUN.

Binbin Wu committed 1 year ago

Commit cf207ea1 parent b5aafcb3 files · +97 −1Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/kvm.h+17−0
@@ -178,6 +178,7 @@ struct kvm_xen_exit { · 177 unmodified lines
178#define KVM_EXIT_NOTIFY 37178#define KVM_EXIT_NOTIFY 37
179#define KVM_EXIT_LOONGARCH_IOCSR 38179#define KVM_EXIT_LOONGARCH_IOCSR 38
180#define KVM_EXIT_MEMORY_FAULT 39180#define KVM_EXIT_MEMORY_FAULT 39
181#define KVM_EXIT_TDX 40
181 182
182/* For KVM_EXIT_INTERNAL_ERROR */183/* For KVM_EXIT_INTERNAL_ERROR */
183/* Emulate instruction failed. */184/* Emulate instruction failed. */
@@ -447,6 +448,22 @@ struct kvm_run { · 263 unmodified lines
447 __u64 gpa;448 __u64 gpa;
448 __u64 size;449 __u64 size;
449 } memory_fault;450 } memory_fault;
451 /* KVM_EXIT_TDX */
452 struct {
453 __u64 flags;
454 __u64 nr;
455 union {
456 struct {
457 __u64 ret;
458 __u64 data[5];
459 } unknown;
460 struct {
461 __u64 ret;
462 __u64 gpa;
463 __u64 size;
464 } get_quote;
465 };
466 } tdx;
450 /* Fix the size of the union. */467 /* Fix the size of the union. */
451 char padding[256];468 char padding[256];
452 };469 };