~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/include/asm/shared/tdx.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 TDG_VP_VMCALL                   0
 15 #define TDG_VP_INFO                     1
 16 #define TDG_VP_VEINFO_GET               3
 17 #define TDG_MR_REPORT                   4
 18 #define TDG_MEM_PAGE_ACCEPT             6
 19 #define TDG_VM_WR                       8
 20 
 21 /* TDCS fields. To be used by TDG.VM.WR and TDG.VM.RD module calls */
 22 #define TDCS_NOTIFY_ENABLES             0x9100000000000010
 23 
 24 /* TDX hypercall Leaf IDs */
 25 #define TDVMCALL_MAP_GPA                0x10001
 26 #define TDVMCALL_GET_QUOTE              0x10002
 27 #define TDVMCALL_REPORT_FATAL_ERROR     0x10003
 28 
 29 #define TDVMCALL_STATUS_RETRY           1
 30 
 31 /*
 32  * Bitmasks of exposed registers (with VMM).
 33  */
 34 #define TDX_RDX         BIT(2)
 35 #define TDX_RBX         BIT(3)
 36 #define TDX_RSI         BIT(6)
 37 #define TDX_RDI         BIT(7)
 38 #define TDX_R8          BIT(8)
 39 #define TDX_R9          BIT(9)
 40 #define TDX_R10         BIT(10)
 41 #define TDX_R11         BIT(11)
 42 #define TDX_R12         BIT(12)
 43 #define TDX_R13         BIT(13)
 44 #define TDX_R14         BIT(14)
 45 #define TDX_R15         BIT(15)
 46 
 47 /*
 48  * These registers are clobbered to hold arguments for each
 49  * TDVMCALL. They are safe to expose to the VMM.
 50  * Each bit in this mask represents a register ID. Bit field
 51  * details can be found in TDX GHCI specification, section
 52  * titled "TDCALL [TDG.VP.VMCALL] leaf".
 53  */
 54 #define TDVMCALL_EXPOSE_REGS_MASK       \
 55         (TDX_RDX | TDX_RBX | TDX_RSI | TDX_RDI | TDX_R8  | TDX_R9  | \
 56          TDX_R10 | TDX_R11 | TDX_R12 | TDX_R13 | TDX_R14 | TDX_R15)
 57 
 58 /* TDX supported page sizes from the TDX module ABI. */
 59 #define TDX_PS_4K       0
 60 #define TDX_PS_2M       1
 61 #define TDX_PS_1G       2
 62 #define TDX_PS_NR       (TDX_PS_1G + 1)
 63 
 64 #ifndef __ASSEMBLY__
 65 
 66 #include <linux/compiler_attributes.h>
 67 
 68 /*
 69  * Used in __tdcall*() to gather the input/output registers' values of the
 70  * TDCALL instruction when requesting services from the TDX module. This is a
 71  * software only structure and not part of the TDX module/VMM ABI
 72  */
 73 struct tdx_module_args {
 74         /* callee-clobbered */
 75         u64 rcx;
 76         u64 rdx;
 77         u64 r8;
 78         u64 r9;
 79         /* extra callee-clobbered */
 80         u64 r10;
 81         u64 r11;
 82         /* callee-saved + rdi/rsi */
 83         u64 r12;
 84         u64 r13;
 85         u64 r14;
 86         u64 r15;
 87         u64 rbx;
 88         u64 rdi;
 89         u64 rsi;
 90 };
 91 
 92 /* Used to communicate with the TDX module */
 93 u64 __tdcall(u64 fn, struct tdx_module_args *args);
 94 u64 __tdcall_ret(u64 fn, struct tdx_module_args *args);
 95 u64 __tdcall_saved_ret(u64 fn, struct tdx_module_args *args);
 96 
 97 /* Used to request services from the VMM */
 98 u64 __tdx_hypercall(struct tdx_module_args *args);
 99 
100 /*
101  * Wrapper for standard use of __tdx_hypercall with no output aside from
102  * return code.
103  */
104 static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, u64 r15)
105 {
106         struct tdx_module_args args = {
107                 .r10 = TDX_HYPERCALL_STANDARD,
108                 .r11 = fn,
109                 .r12 = r12,
110                 .r13 = r13,
111                 .r14 = r14,
112                 .r15 = r15,
113         };
114 
115         return __tdx_hypercall(&args);
116 }
117 
118 
119 /* Called from __tdx_hypercall() for unrecoverable failure */
120 void __noreturn __tdx_hypercall_failed(void);
121 
122 bool tdx_accept_memory(phys_addr_t start, phys_addr_t end);
123 
124 /*
125  * The TDG.VP.VMCALL-Instruction-execution sub-functions are defined
126  * independently from but are currently matched 1:1 with VMX EXIT_REASONs.
127  * Reusing the KVM EXIT_REASON macros makes it easier to connect the host and
128  * guest sides of these calls.
129  */
130 static __always_inline u64 hcall_func(u64 exit_reason)
131 {
132         return exit_reason;
133 }
134 
135 #endif /* !__ASSEMBLY__ */
136 #endif /* _ASM_X86_SHARED_TDX_H */
137 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php