]> git.ipfire.org Git - thirdparty/linux.git/blob - arch/x86/include/asm/shared/tdx.h
virt: tdx-guest: Add Quote generation support using TSM_REPORTS
[thirdparty/linux.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_GET_QUOTE 0x10002
26 #define TDVMCALL_REPORT_FATAL_ERROR 0x10003
27
28 #ifndef __ASSEMBLY__
29
30 /*
31 * Used in __tdx_hypercall() to pass down and get back registers' values of
32 * the TDCALL instruction when requesting services from the VMM.
33 *
34 * This is a software only structure and not part of the TDX module/VMM ABI.
35 */
36 struct tdx_hypercall_args {
37 u64 r8;
38 u64 r9;
39 u64 r10;
40 u64 r11;
41 u64 r12;
42 u64 r13;
43 u64 r14;
44 u64 r15;
45 u64 rdi;
46 u64 rsi;
47 u64 rbx;
48 u64 rdx;
49 };
50
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);
54
55 /*
56 * Wrapper for standard use of __tdx_hypercall with no output aside from
57 * return code.
58 */
59 static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, u64 r15)
60 {
61 struct tdx_hypercall_args args = {
62 .r10 = TDX_HYPERCALL_STANDARD,
63 .r11 = fn,
64 .r12 = r12,
65 .r13 = r13,
66 .r14 = r14,
67 .r15 = r15,
68 };
69
70 return __tdx_hypercall(&args);
71 }
72
73
74 /* Called from __tdx_hypercall() for unrecoverable failure */
75 void __tdx_hypercall_failed(void);
76
77 /*
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
81 */
82 struct tdx_module_output {
83 u64 rcx;
84 u64 rdx;
85 u64 r8;
86 u64 r9;
87 u64 r10;
88 u64 r11;
89 };
90
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);
94
95 bool tdx_accept_memory(phys_addr_t start, phys_addr_t end);
96
97 /*
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.
102 */
103 static __always_inline u64 hcall_func(u64 exit_reason)
104 {
105 return exit_reason;
106 }
107
108 #endif /* !__ASSEMBLY__ */
109 #endif /* _ASM_X86_SHARED_TDX_H */