x86/tdx: Add unaccepted memory support
[linux-2.6-microblaze.git] / 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
4
5 #include <linux/bits.h>
6 #include <linux/types.h>
7
8 #define TDX_HYPERCALL_STANDARD  0
9
10 #define TDX_CPUID_LEAF_ID       0x21
11 #define TDX_IDENT               "IntelTDX    "
12
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
18 #define TDX_WR                          8
19
20 /* TDCS fields. To be used by TDG.VM.WR and TDG.VM.RD module calls */
21 #define TDCS_NOTIFY_ENABLES             0x9100000000000010
22
23 /* TDX hypercall Leaf IDs */
24 #define TDVMCALL_MAP_GPA                0x10001
25 #define TDVMCALL_REPORT_FATAL_ERROR     0x10003
26
27 #ifndef __ASSEMBLY__
28
29 /*
30  * Used in __tdx_hypercall() to pass down and get back registers' values of
31  * the TDCALL instruction when requesting services from the VMM.
32  *
33  * This is a software only structure and not part of the TDX module/VMM ABI.
34  */
35 struct tdx_hypercall_args {
36         u64 r8;
37         u64 r9;
38         u64 r10;
39         u64 r11;
40         u64 r12;
41         u64 r13;
42         u64 r14;
43         u64 r15;
44         u64 rdi;
45         u64 rsi;
46         u64 rbx;
47         u64 rdx;
48 };
49
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);
53
54 /*
55  * Wrapper for standard use of __tdx_hypercall with no output aside from
56  * return code.
57  */
58 static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, u64 r15)
59 {
60         struct tdx_hypercall_args args = {
61                 .r10 = TDX_HYPERCALL_STANDARD,
62                 .r11 = fn,
63                 .r12 = r12,
64                 .r13 = r13,
65                 .r14 = r14,
66                 .r15 = r15,
67         };
68
69         return __tdx_hypercall(&args);
70 }
71
72
73 /* Called from __tdx_hypercall() for unrecoverable failure */
74 void __tdx_hypercall_failed(void);
75
76 /*
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
80  */
81 struct tdx_module_output {
82         u64 rcx;
83         u64 rdx;
84         u64 r8;
85         u64 r9;
86         u64 r10;
87         u64 r11;
88 };
89
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);
93
94 bool tdx_accept_memory(phys_addr_t start, phys_addr_t end);
95
96 #endif /* !__ASSEMBLY__ */
97 #endif /* _ASM_X86_SHARED_TDX_H */