1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_SHARED_TDX_H
3 #define _ASM_X86_SHARED_TDX_H
5 #include <linux/bits.h>
6 #include <linux/types.h>
8 #define TDX_HYPERCALL_STANDARD 0
10 #define TDX_CPUID_LEAF_ID 0x21
11 #define TDX_IDENT "IntelTDX "
13 /* TDX module Call Leaf IDs */
14 #define TDX_GET_INFO 1
15 #define TDX_GET_VEINFO 3
16 #define TDX_GET_REPORT 4
17 #define TDX_ACCEPT_PAGE 6
20 /* TDCS fields. To be used by TDG.VM.WR and TDG.VM.RD module calls */
21 #define TDCS_NOTIFY_ENABLES 0x9100000000000010
23 /* TDX hypercall Leaf IDs */
24 #define TDVMCALL_MAP_GPA 0x10001
25 #define TDVMCALL_REPORT_FATAL_ERROR 0x10003
30 * Used in __tdx_hypercall() to pass down and get back registers' values of
31 * the TDCALL instruction when requesting services from the VMM.
33 * This is a software only structure and not part of the TDX module/VMM ABI.
35 struct tdx_hypercall_args {
50 /* Used to request services from the VMM */
51 u64 __tdx_hypercall(struct tdx_hypercall_args *args);
52 u64 __tdx_hypercall_ret(struct tdx_hypercall_args *args);
55 * Wrapper for standard use of __tdx_hypercall with no output aside from
58 static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, u64 r15)
60 struct tdx_hypercall_args args = {
61 .r10 = TDX_HYPERCALL_STANDARD,
69 return __tdx_hypercall(&args);
73 /* Called from __tdx_hypercall() for unrecoverable failure */
74 void __tdx_hypercall_failed(void);
77 * Used in __tdx_module_call() to gather the output registers' values of the
78 * TDCALL instruction when requesting services from the TDX module. This is a
79 * software only structure and not part of the TDX module/VMM ABI
81 struct tdx_module_output {
90 /* Used to communicate with the TDX module */
91 u64 __tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9,
92 struct tdx_module_output *out);
94 bool tdx_accept_memory(phys_addr_t start, phys_addr_t end);
96 #endif /* !__ASSEMBLY__ */
97 #endif /* _ASM_X86_SHARED_TDX_H */