Տsphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget*/translations/zh_CN/virt/kvm/x86/intel-tdxmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/zh_TW/virt/kvm/x86/intel-tdxmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/it_IT/virt/kvm/x86/intel-tdxmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/ja_JP/virt/kvm/x86/intel-tdxmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/ko_KR/virt/kvm/x86/intel-tdxmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/sp_SP/virt/kvm/x86/intel-tdxmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhD/var/lib/git/docbuild/linux/Documentation/virt/kvm/x86/intel-tdx.rsthKubhsection)}(hhh](htitle)}(h#Intel Trust Domain Extensions (TDX)h]h#Intel Trust Domain Extensions (TDX)}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hOverviewh]hOverview}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hXIntel's Trust Domain Extensions (TDX) protect confidential guest VMs from the host and physical attacks. A CPU-attested software module called 'the TDX module' runs inside a new CPU isolated range to provide the functionalities to manage and run protected VMs, a.k.a, TDX guests or TDs.h]hX%Intel’s Trust Domain Extensions (TDX) protect confidential guest VMs from the host and physical attacks. A CPU-attested software module called ‘the TDX module’ runs inside a new CPU isolated range to provide the functionalities to manage and run protected VMs, a.k.a, TDX guests or TDs.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hKPlease refer to [1] for the whitepaper, specifications and other resources.h]hKPlease refer to [1] for the whitepaper, specifications and other resources.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hXThis documentation describes TDX-specific KVM ABIs. The TDX module needs to be initialized before it can be used by KVM to run any TDX guests. The host core-kernel provides the support of initializing the TDX module, which is described in the Documentation/arch/x86/tdx.rst.h]hXThis documentation describes TDX-specific KVM ABIs. The TDX module needs to be initialized before it can be used by KVM to run any TDX guests. The host core-kernel provides the support of initializing the TDX module, which is described in the Documentation/arch/x86/tdx.rst.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubeh}(h]overviewah ]h"]overviewah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hAPI descriptionh]hAPI description}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hKVM_MEMORY_ENCRYPT_OPh]hKVM_MEMORY_ENCRYPT_OP}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh field_list)}(hhh]hfield)}(hhh](h field_name)}(hTypeh]hType}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1j:hj7hhhKubh field_body)}(hvm ioctl, vcpu ioctl h]h)}(hvm ioctl, vcpu ioctlh]hvm ioctl, vcpu ioctl}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjLubah}(h]h ]h"]h$]h&]uh1jJhj7ubeh}(h]h ]h"]h$]h&]uh1j5hhhKhj2hhubah}(h]h ]h"]h$]h&]uh1j0hjhhhhhKubh)}(htFor TDX operations, KVM_MEMORY_ENCRYPT_OP is re-purposed to be generic ioctl with TDX specific sub-ioctl() commands.h]htFor TDX operations, KVM_MEMORY_ENCRYPT_OP is re-purposed to be generic ioctl with TDX specific sub-ioctl() commands.}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh literal_block)}(hX,/* Trust Domain Extensions sub-ioctl() commands. */ enum kvm_tdx_cmd_id { KVM_TDX_CAPABILITIES = 0, KVM_TDX_INIT_VM, KVM_TDX_INIT_VCPU, KVM_TDX_INIT_MEM_REGION, KVM_TDX_FINALIZE_VM, KVM_TDX_GET_CPUID, KVM_TDX_CMD_NR_MAX, }; struct kvm_tdx_cmd { /* enum kvm_tdx_cmd_id */ __u32 id; /* flags for sub-command. If sub-command doesn't use this, set zero. */ __u32 flags; /* * data for each sub-command. An immediate or a pointer to the actual * data in process virtual address. If sub-command doesn't use it, * set zero. */ __u64 data; /* * Auxiliary error code. The sub-command may return TDX SEAMCALL * status code in addition to -Exxx. */ __u64 hw_error; };h]hX,/* Trust Domain Extensions sub-ioctl() commands. */ enum kvm_tdx_cmd_id { KVM_TDX_CAPABILITIES = 0, KVM_TDX_INIT_VM, KVM_TDX_INIT_VCPU, KVM_TDX_INIT_MEM_REGION, KVM_TDX_FINALIZE_VM, KVM_TDX_GET_CPUID, KVM_TDX_CMD_NR_MAX, }; struct kvm_tdx_cmd { /* enum kvm_tdx_cmd_id */ __u32 id; /* flags for sub-command. If sub-command doesn't use this, set zero. */ __u32 flags; /* * data for each sub-command. An immediate or a pointer to the actual * data in process virtual address. If sub-command doesn't use it, * set zero. */ __u64 data; /* * Auxiliary error code. The sub-command may return TDX SEAMCALL * status code in addition to -Exxx. */ __u64 hw_error; };}hjsbah}(h]h ]h"]h$]h&]hhuh1j~hhhK!hjhhubeh}(h]kvm-memory-encrypt-opah ]h"]kvm_memory_encrypt_opah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hKVM_TDX_CAPABILITIESh]hKVM_TDX_CAPABILITIES}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK@ubj1)}(hhh](j6)}(hhh](j;)}(hTypeh]hType}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(hvm ioctlh]h)}(hjh]hvm ioctl}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKAhjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKAhjhhubj6)}(hhh](j;)}(hReturnsh]hReturns}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(h0 on success, <0 on error h]h)}(h0 on success, <0 on errorh]h0 on success, <0 on error}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKBhjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKBhjhhubeh}(h]h ]h"]h$]h&]uh1j0hjhhhhhKAubh)}(hReturn the TDX capabilities that current KVM supports with the specific TDX module loaded in the system. It reports what features/capabilities are allowed to be configured to the TDX guest.h]hReturn the TDX capabilities that current KVM supports with the specific TDX module loaded in the system. It reports what features/capabilities are allowed to be configured to the TDX guest.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKDhjhhubh bullet_list)}(hhh](h list_item)}(hid: KVM_TDX_CAPABILITIESh]h)}(hj$h]hid: KVM_TDX_CAPABILITIES}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKHhj"ubah}(h]h ]h"]h$]h&]uh1j hjhhhhhNubj!)}(hflags: must be 0h]h)}(hj;h]hflags: must be 0}(hj=hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKIhj9ubah}(h]h ]h"]h$]h&]uh1j hjhhhhhNubj!)}(h,data: pointer to struct kvm_tdx_capabilitiesh]h)}(hjRh]h,data: pointer to struct kvm_tdx_capabilities}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKJhjPubah}(h]h ]h"]h$]h&]uh1j hjhhhhhNubj!)}(hhw_error: must be 0 h]h)}(hhw_error: must be 0h]hhw_error: must be 0}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKKhjgubah}(h]h ]h"]h$]h&]uh1j hjhhhhhNubeh}(h]h ]h"]h$]h&]bullet-uh1jhhhKHhjhhubj)}(hX\struct kvm_tdx_capabilities { __u64 supported_attrs; __u64 supported_xfam; /* TDG.VP.VMCALL hypercalls executed in kernel and forwarded to * userspace, respectively */ __u64 kernel_tdvmcallinfo_1_r11; __u64 user_tdvmcallinfo_1_r11; /* TDG.VP.VMCALL instruction executions subfunctions executed in kernel * and forwarded to userspace, respectively */ __u64 kernel_tdvmcallinfo_1_r12; __u64 user_tdvmcallinfo_1_r12; __u64 reserved[250]; /* Configurable CPUID bits for userspace */ struct kvm_cpuid2 cpuid; };h]hX\struct kvm_tdx_capabilities { __u64 supported_attrs; __u64 supported_xfam; /* TDG.VP.VMCALL hypercalls executed in kernel and forwarded to * userspace, respectively */ __u64 kernel_tdvmcallinfo_1_r11; __u64 user_tdvmcallinfo_1_r11; /* TDG.VP.VMCALL instruction executions subfunctions executed in kernel * and forwarded to userspace, respectively */ __u64 kernel_tdvmcallinfo_1_r12; __u64 user_tdvmcallinfo_1_r12; __u64 reserved[250]; /* Configurable CPUID bits for userspace */ struct kvm_cpuid2 cpuid; };}hjsbah}(h]h ]h"]h$]h&]hhuh1j~hhhKOhjhhubeh}(h]kvm-tdx-capabilitiesah ]h"]kvm_tdx_capabilitiesah$]h&]uh1hhjhhhhhK@ubh)}(hhh](h)}(hKVM_TDX_INIT_VMh]hKVM_TDX_INIT_VM}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKgubj1)}(hhh](j6)}(hhh](j;)}(hTypeh]hType}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(hvm ioctlh]h)}(hjh]hvm ioctl}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKhhjhhubj6)}(hhh](j;)}(hReturnsh]hReturns}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(h0 on success, <0 on error h]h)}(h0 on success, <0 on errorh]h0 on success, <0 on error}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKihjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKihjhhubeh}(h]h ]h"]h$]h&]uh1j0hjhhhhhKhubh)}(hsPerform TDX specific VM initialization. This needs to be called after KVM_CREATE_VM and before creating any VCPUs.h]hsPerform TDX specific VM initialization. This needs to be called after KVM_CREATE_VM and before creating any VCPUs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKkhjhhubj)}(hhh](j!)}(hid: KVM_TDX_INIT_VMh]h)}(hj'h]hid: KVM_TDX_INIT_VM}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKnhj%ubah}(h]h ]h"]h$]h&]uh1j hj"hhhhhNubj!)}(hflags: must be 0h]h)}(hj>h]hflags: must be 0}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKohj<ubah}(h]h ]h"]h$]h&]uh1j hj"hhhhhNubj!)}(h'data: pointer to struct kvm_tdx_init_vmh]h)}(hjUh]h'data: pointer to struct kvm_tdx_init_vm}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKphjSubah}(h]h ]h"]h$]h&]uh1j hj"hhhhhNubj!)}(hhw_error: must be 0 h]h)}(hhw_error: must be 0h]hhw_error: must be 0}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKqhjjubah}(h]h ]h"]h$]h&]uh1j hj"hhhhhNubeh}(h]h ]h"]h$]h&]jjuh1jhhhKnhjhhubj)}(hXstruct kvm_tdx_init_vm { __u64 attributes; __u64 xfam; __u64 mrconfigid[6]; /* sha384 digest */ __u64 mrowner[6]; /* sha384 digest */ __u64 mrownerconfig[6]; /* sha384 digest */ /* The total space for TD_PARAMS before the CPUIDs is 256 bytes */ __u64 reserved[12]; /* * Call KVM_TDX_INIT_VM before vcpu creation, thus before * KVM_SET_CPUID2. * This configuration supersedes KVM_SET_CPUID2s for VCPUs because the * TDX module directly virtualizes those CPUIDs without VMM. The user * space VMM, e.g. qemu, should make KVM_SET_CPUID2 consistent with * those values. If it doesn't, KVM may have wrong idea of vCPUIDs of * the guest, and KVM may wrongly emulate CPUIDs or MSRs that the TDX * module doesn't virtualize. */ struct kvm_cpuid2 cpuid; };h]hXstruct kvm_tdx_init_vm { __u64 attributes; __u64 xfam; __u64 mrconfigid[6]; /* sha384 digest */ __u64 mrowner[6]; /* sha384 digest */ __u64 mrownerconfig[6]; /* sha384 digest */ /* The total space for TD_PARAMS before the CPUIDs is 256 bytes */ __u64 reserved[12]; /* * Call KVM_TDX_INIT_VM before vcpu creation, thus before * KVM_SET_CPUID2. * This configuration supersedes KVM_SET_CPUID2s for VCPUs because the * TDX module directly virtualizes those CPUIDs without VMM. The user * space VMM, e.g. qemu, should make KVM_SET_CPUID2 consistent with * those values. If it doesn't, KVM may have wrong idea of vCPUIDs of * the guest, and KVM may wrongly emulate CPUIDs or MSRs that the TDX * module doesn't virtualize. */ struct kvm_cpuid2 cpuid; };}hjsbah}(h]h ]h"]h$]h&]hhuh1j~hhhKuhjhhubeh}(h]kvm-tdx-init-vmah ]h"]kvm_tdx_init_vmah$]h&]uh1hhjhhhhhKgubh)}(hhh](h)}(hKVM_TDX_INIT_VCPUh]hKVM_TDX_INIT_VCPU}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubj1)}(hhh](j6)}(hhh](j;)}(hTypeh]hType}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(h vcpu ioctlh]h)}(hjh]h vcpu ioctl}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKhjhhubj6)}(hhh](j;)}(hReturnsh]hReturns}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(h0 on success, <0 on error h]h)}(h0 on success, <0 on errorh]h0 on success, <0 on error}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKhjhhubeh}(h]h ]h"]h$]h&]uh1j0hjhhhhhKubh)}(h)Perform TDX specific VCPU initialization.h]h)Perform TDX specific VCPU initialization.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hhh](j!)}(hid: KVM_TDX_INIT_VCPUh]h)}(hj(h]hid: KVM_TDX_INIT_VCPU}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj&ubah}(h]h ]h"]h$]h&]uh1j hj#hhhhhNubj!)}(hflags: must be 0h]h)}(hj?h]hflags: must be 0}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj=ubah}(h]h ]h"]h$]h&]uh1j hj#hhhhhNubj!)}(h,data: initial value of the guest TD VCPU RCXh]h)}(hjVh]h,data: initial value of the guest TD VCPU RCX}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjTubah}(h]h ]h"]h$]h&]uh1j hj#hhhhhNubj!)}(hhw_error: must be 0 h]h)}(hhw_error: must be 0h]hhw_error: must be 0}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjkubah}(h]h ]h"]h$]h&]uh1j hj#hhhhhNubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhjhhubeh}(h]kvm-tdx-init-vcpuah ]h"]kvm_tdx_init_vcpuah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hKVM_TDX_INIT_MEM_REGIONh]hKVM_TDX_INIT_MEM_REGION}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubj1)}(hhh](j6)}(hhh](j;)}(hTypeh]hType}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(h vcpu ioctlh]h)}(hjh]h vcpu ioctl}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKhjhhubj6)}(hhh](j;)}(hReturnsh]hReturns}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(h0 on success, <0 on error h]h)}(h0 on success, <0 on errorh]h0 on success, <0 on error}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKhjhhubeh}(h]h ]h"]h$]h&]uh1j0hjhhhhhKubh)}(hpInitialize @nr_pages TDX guest private memory starting from @gpa with userspace provided data from @source_addr.h]hpInitialize @nr_pages TDX guest private memory starting from @gpa with userspace provided data from @source_addr.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hNote, before calling this sub command, memory attribute of the range [gpa, gpa + nr_pages] needs to be private. Userspace can use KVM_SET_MEMORY_ATTRIBUTES to set the attribute.h]hNote, before calling this sub command, memory attribute of the range [gpa, gpa + nr_pages] needs to be private. Userspace can use KVM_SET_MEMORY_ATTRIBUTES to set the attribute.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hPIf KVM_TDX_MEASURE_MEMORY_REGION flag is specified, it also extends measurement.h]hPIf KVM_TDX_MEASURE_MEMORY_REGION flag is specified, it also extends measurement.}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hhh](j!)}(hid: KVM_TDX_INIT_MEM_REGIONh]h)}(hj7h]hid: KVM_TDX_INIT_MEM_REGION}(hj9hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj5ubah}(h]h ]h"]h$]h&]uh1j hj2hhhhhNubj!)}(h>flags: currently only KVM_TDX_MEASURE_MEMORY_REGION is definedh]h)}(hjNh]h>flags: currently only KVM_TDX_MEASURE_MEMORY_REGION is defined}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjLubah}(h]h ]h"]h$]h&]uh1j hj2hhhhhNubj!)}(h/data: pointer to struct kvm_tdx_init_mem_regionh]h)}(hjeh]h/data: pointer to struct kvm_tdx_init_mem_region}(hjghhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjcubah}(h]h ]h"]h$]h&]uh1j hj2hhhhhNubj!)}(hhw_error: must be 0 h]h)}(hhw_error: must be 0h]hhw_error: must be 0}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjzubah}(h]h ]h"]h$]h&]uh1j hj2hhhhhNubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhjhhubj)}(h#define KVM_TDX_MEASURE_MEMORY_REGION (1UL << 0) struct kvm_tdx_init_mem_region { __u64 source_addr; __u64 gpa; __u64 nr_pages; };h]h#define KVM_TDX_MEASURE_MEMORY_REGION (1UL << 0) struct kvm_tdx_init_mem_region { __u64 source_addr; __u64 gpa; __u64 nr_pages; };}hjsbah}(h]h ]h"]h$]h&]hhuh1j~hhhKhjhhubeh}(h]kvm-tdx-init-mem-regionah ]h"]kvm_tdx_init_mem_regionah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hKVM_TDX_FINALIZE_VMh]hKVM_TDX_FINALIZE_VM}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubj1)}(hhh](j6)}(hhh](j;)}(hTypeh]hType}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(hvm ioctlh]h)}(hjh]hvm ioctl}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKhjhhubj6)}(hhh](j;)}(hReturnsh]hReturns}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(h0 on success, <0 on error h]h)}(h0 on success, <0 on errorh]h0 on success, <0 on error}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKhjhhubeh}(h]h ]h"]h$]h&]uh1j0hjhhhhhKubh)}(hIComplete measurement of the initial TD contents and mark it ready to run.h]hIComplete measurement of the initial TD contents and mark it ready to run.}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hhh](j!)}(hid: KVM_TDX_FINALIZE_VMh]h)}(hj8h]hid: KVM_TDX_FINALIZE_VM}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj6ubah}(h]h ]h"]h$]h&]uh1j hj3hhhhhNubj!)}(hflags: must be 0h]h)}(hjOh]hflags: must be 0}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubah}(h]h ]h"]h$]h&]uh1j hj3hhhhhNubj!)}(hdata: must be 0h]h)}(hjfh]hdata: must be 0}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjdubah}(h]h ]h"]h$]h&]uh1j hj3hhhhhNubj!)}(hhw_error: must be 0 h]h)}(hhw_error: must be 0h]hhw_error: must be 0}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj{ubah}(h]h ]h"]h$]h&]uh1j hj3hhhhhNubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhjhhubeh}(h]kvm-tdx-finalize-vmah ]h"]kvm_tdx_finalize_vmah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hKVM_TDX_GET_CPUIDh]hKVM_TDX_GET_CPUID}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubj1)}(hhh](j6)}(hhh](j;)}(hTypeh]hType}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(h vcpu ioctlh]h)}(hjh]h vcpu ioctl}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKhjhhubj6)}(hhh](j;)}(hReturnsh]hReturns}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjhhhKubjK)}(h0 on success, <0 on error h]h)}(h0 on success, <0 on errorh]h0 on success, <0 on error}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j5hhhKhjhhubeh}(h]h ]h"]h$]h&]uh1j0hjhhhhhKubh)}(hGet the CPUID values that the TDX module virtualizes for the TD guest. When it returns -E2BIG, the user space should allocate a larger buffer and retry. The minimum buffer size is updated in the nent field of the struct kvm_cpuid2.h]hGet the CPUID values that the TDX module virtualizes for the TD guest. When it returns -E2BIG, the user space should allocate a larger buffer and retry. The minimum buffer size is updated in the nent field of the struct kvm_cpuid2.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hhh](j!)}(hid: KVM_TDX_GET_CPUIDh]h)}(hj+h]hid: KVM_TDX_GET_CPUID}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj)ubah}(h]h ]h"]h$]h&]uh1j hj&hhhhhNubj!)}(hflags: must be 0h]h)}(hjBh]hflags: must be 0}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj@ubah}(h]h ]h"]h$]h&]uh1j hj&hhhhhNubj!)}(h+data: pointer to struct kvm_cpuid2 (in/out)h]h)}(hjYh]h+data: pointer to struct kvm_cpuid2 (in/out)}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjWubah}(h]h ]h"]h$]h&]uh1j hj&hhhhhNubj!)}(hhw_error: must be 0 (out) h]h)}(hhw_error: must be 0 (out)h]hhw_error: must be 0 (out)}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjnubah}(h]h ]h"]h$]h&]uh1j hj&hhhhhNubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhjhhubj)}(hX3struct kvm_cpuid2 { __u32 nent; __u32 padding; struct kvm_cpuid_entry2 entries[0]; }; struct kvm_cpuid_entry2 { __u32 function; __u32 index; __u32 flags; __u32 eax; __u32 ebx; __u32 ecx; __u32 edx; __u32 padding[3]; };h]hX3struct kvm_cpuid2 { __u32 nent; __u32 padding; struct kvm_cpuid_entry2 entries[0]; }; struct kvm_cpuid_entry2 { __u32 function; __u32 index; __u32 flags; __u32 eax; __u32 ebx; __u32 ecx; __u32 edx; __u32 padding[3]; };}hjsbah}(h]h ]h"]h$]h&]hhuh1j~hhhKhjhhubeh}(h]kvm-tdx-get-cpuidah ]h"]kvm_tdx_get_cpuidah$]h&]uh1hhjhhhhhKubeh}(h]api-descriptionah ]h"]api descriptionah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hKVM TDX creation flowh]hKVM TDX creation flow}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hhIn addition to the standard KVM flow, new TDX ioctls need to be called. The control flow is as follows:h]hhIn addition to the standard KVM flow, new TDX ioctls need to be called. The control flow is as follows:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubhenumerated_list)}(hhh](j!)}(hvCheck system wide capability * KVM_CAP_VM_TYPES: Check if VM type is supported and if KVM_X86_TDX_VM is supported. h](h)}(hCheck system wide capabilityh]hCheck system wide capability}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hhh]j!)}(hTKVM_CAP_VM_TYPES: Check if VM type is supported and if KVM_X86_TDX_VM is supported. h]h)}(hSKVM_CAP_VM_TYPES: Check if VM type is supported and if KVM_X86_TDX_VM is supported.h]hSKVM_CAP_VM_TYPES: Check if VM type is supported and if KVM_X86_TDX_VM is supported.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubah}(h]h ]h"]h$]h&]j*uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1j hjhhhNhNubj!)}(hXCreate VM * KVM_CREATE_VM * KVM_TDX_CAPABILITIES: Query TDX capabilities for creating TDX guests. * KVM_CHECK_EXTENSION(KVM_CAP_MAX_VCPUS): Query maximum VCPUs the TD can support at VM level (TDX has its own limitation on this). * KVM_SET_TSC_KHZ: Configure TD's TSC frequency if a different TSC frequency than host is desired. This is Optional. * KVM_TDX_INIT_VM: Pass TDX specific VM parameters. h](h)}(h Create VMh]h Create VM}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hhh](j!)}(h KVM_CREATE_VMh]h)}(hjh]h KVM_CREATE_VM}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubj!)}(hEKVM_TDX_CAPABILITIES: Query TDX capabilities for creating TDX guests.h]h)}(hj6h]hEKVM_TDX_CAPABILITIES: Query TDX capabilities for creating TDX guests.}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj4ubah}(h]h ]h"]h$]h&]uh1j hjubj!)}(hKVM_CHECK_EXTENSION(KVM_CAP_MAX_VCPUS): Query maximum VCPUs the TD can support at VM level (TDX has its own limitation on this).h]h)}(hKVM_CHECK_EXTENSION(KVM_CAP_MAX_VCPUS): Query maximum VCPUs the TD can support at VM level (TDX has its own limitation on this).h]hKVM_CHECK_EXTENSION(KVM_CAP_MAX_VCPUS): Query maximum VCPUs the TD can support at VM level (TDX has its own limitation on this).}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjKubah}(h]h ]h"]h$]h&]uh1j hjubj!)}(hsKVM_SET_TSC_KHZ: Configure TD's TSC frequency if a different TSC frequency than host is desired. This is Optional.h]h)}(hsKVM_SET_TSC_KHZ: Configure TD's TSC frequency if a different TSC frequency than host is desired. This is Optional.h]huKVM_SET_TSC_KHZ: Configure TD’s TSC frequency if a different TSC frequency than host is desired. This is Optional.}(hjghhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjcubah}(h]h ]h"]h$]h&]uh1j hjubj!)}(h2KVM_TDX_INIT_VM: Pass TDX specific VM parameters. h]h)}(h1KVM_TDX_INIT_VM: Pass TDX specific VM parameters.h]h1KVM_TDX_INIT_VM: Pass TDX specific VM parameters.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj{ubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1j hjhhhNhNubj!)}(hCreate VCPU * KVM_CREATE_VCPU * KVM_TDX_INIT_VCPU: Pass TDX specific VCPU parameters. * KVM_SET_CPUID2: Configure TD's CPUIDs. * KVM_SET_MSRS: Configure TD's MSRs. h](h)}(h Create VCPUh]h Create VCPU}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hhh](j!)}(hKVM_CREATE_VCPUh]h)}(hjh]hKVM_CREATE_VCPU}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubj!)}(h5KVM_TDX_INIT_VCPU: Pass TDX specific VCPU parameters.h]h)}(hjh]h5KVM_TDX_INIT_VCPU: Pass TDX specific VCPU parameters.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubj!)}(h&KVM_SET_CPUID2: Configure TD's CPUIDs.h]h)}(hjh]h(KVM_SET_CPUID2: Configure TD’s CPUIDs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubj!)}(h#KVM_SET_MSRS: Configure TD's MSRs. h]h)}(h"KVM_SET_MSRS: Configure TD's MSRs.h]h$KVM_SET_MSRS: Configure TD’s MSRs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1j hjhhhNhNubj!)}(hInitialize initial guest memory * Prepare content of initial guest memory. * KVM_TDX_INIT_MEM_REGION: Add initial guest memory. * KVM_TDX_FINALIZE_VM: Finalize the measurement of the TDX guest. h](h)}(hInitialize initial guest memoryh]hInitialize initial guest memory}(hj! hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubj)}(hhh](j!)}(h(Prepare content of initial guest memory.h]h)}(hj4 h]h(Prepare content of initial guest memory.}(hj6 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj2 ubah}(h]h ]h"]h$]h&]uh1j hj/ ubj!)}(h2KVM_TDX_INIT_MEM_REGION: Add initial guest memory.h]h)}(hjK h]h2KVM_TDX_INIT_MEM_REGION: Add initial guest memory.}(hjM hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjI ubah}(h]h ]h"]h$]h&]uh1j hj/ ubj!)}(h@KVM_TDX_FINALIZE_VM: Finalize the measurement of the TDX guest. h]h)}(h?KVM_TDX_FINALIZE_VM: Finalize the measurement of the TDX guest.h]h?KVM_TDX_FINALIZE_VM: Finalize the measurement of the TDX guest.}(hjd hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj` ubah}(h]h ]h"]h$]h&]uh1j hj/ ubeh}(h]h ]h"]h$]h&]jjuh1jhhhMhj ubeh}(h]h ]h"]h$]h&]uh1j hjhhhNhNubj!)}(h Run VCPU h]h)}(hRun VCPUh]hRun VCPU}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j hjhhhhhNubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix.uh1jhjhhhhhKubeh}(h]kvm-tdx-creation-flowah ]h"]kvm tdx creation flowah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Referencesh]h References}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhM ubh)}(hbhttps://www.intel.com/content/www/us/en/developer/tools/trust-domain-extensions/documentation.htmlh]h reference)}(hj h]hbhttps://www.intel.com/content/www/us/en/developer/tools/trust-domain-extensions/documentation.html}(hj hhhNhNubah}(h]h ]h"]h$]h&]refurij uh1j hj ubah}(h]h ]h"]h$]h&]uh1hhhhM hj hhubeh}(h] referencesah ]h"] referencesah$]h&]uh1hhhhhhhhM ubeh}(h]!intel-trust-domain-extensions-tdxah ]h"]#intel trust domain extensions (tdx)ah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(j j j jjjjjjjjjjjjjjjjjj j j j u nametypes}(j j jjjjjjjjj j uh}(j hjhjjjjjjjjjjjjjjjjj jj j u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.