]>
git.ipfire.org Git - thirdparty/linux.git/blob - arch/x86/include/asm/shared/tdx.h
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_GET_QUOTE 0x10002
26 #define TDVMCALL_REPORT_FATAL_ERROR 0x10003
31 * Used in __tdx_hypercall() to pass down and get back registers' values of
32 * the TDCALL instruction when requesting services from the VMM.
34 * This is a software only structure and not part of the TDX module/VMM ABI.
36 struct tdx_hypercall_args
{
51 /* Used to request services from the VMM */
52 u64
__tdx_hypercall(struct tdx_hypercall_args
*args
);
53 u64
__tdx_hypercall_ret(struct tdx_hypercall_args
*args
);
56 * Wrapper for standard use of __tdx_hypercall with no output aside from
59 static inline u64
_tdx_hypercall(u64 fn
, u64 r12
, u64 r13
, u64 r14
, u64 r15
)
61 struct tdx_hypercall_args args
= {
62 .r10
= TDX_HYPERCALL_STANDARD
,
70 return __tdx_hypercall(&args
);
74 /* Called from __tdx_hypercall() for unrecoverable failure */
75 void __tdx_hypercall_failed(void);
78 * Used in __tdx_module_call() to gather the output registers' values of the
79 * TDCALL instruction when requesting services from the TDX module. This is a
80 * software only structure and not part of the TDX module/VMM ABI
82 struct tdx_module_output
{
91 /* Used to communicate with the TDX module */
92 u64
__tdx_module_call(u64 fn
, u64 rcx
, u64 rdx
, u64 r8
, u64 r9
,
93 struct tdx_module_output
*out
);
95 bool tdx_accept_memory(phys_addr_t start
, phys_addr_t end
);
98 * The TDG.VP.VMCALL-Instruction-execution sub-functions are defined
99 * independently from but are currently matched 1:1 with VMX EXIT_REASONs.
100 * Reusing the KVM EXIT_REASON macros makes it easier to connect the host and
101 * guest sides of these calls.
103 static __always_inline u64
hcall_func(u64 exit_reason
)
108 #endif /* !__ASSEMBLY__ */
109 #endif /* _ASM_X86_SHARED_TDX_H */