0001
0002
0003 #ifndef _ASM_X86_TDX_H
0004 #define _ASM_X86_TDX_H
0005
0006 #include <linux/init.h>
0007 #include <linux/bits.h>
0008 #include <asm/ptrace.h>
0009 #include <asm/shared/tdx.h>
0010
0011
0012
0013
0014
0015
0016
0017 #define TDX_ERROR _BITUL(63)
0018 #define TDX_SW_ERROR (TDX_ERROR | GENMASK_ULL(47, 40))
0019 #define TDX_SEAMCALL_VMFAILINVALID (TDX_SW_ERROR | _UL(0xFFFF0000))
0020
0021 #ifndef __ASSEMBLY__
0022
0023
0024
0025
0026
0027
0028
0029 struct tdx_module_output {
0030 u64 rcx;
0031 u64 rdx;
0032 u64 r8;
0033 u64 r9;
0034 u64 r10;
0035 u64 r11;
0036 };
0037
0038
0039
0040
0041
0042
0043 struct ve_info {
0044 u64 exit_reason;
0045 u64 exit_qual;
0046
0047 u64 gla;
0048
0049 u64 gpa;
0050 u32 instr_len;
0051 u32 instr_info;
0052 };
0053
0054 #ifdef CONFIG_INTEL_TDX_GUEST
0055
0056 void __init tdx_early_init(void);
0057
0058
0059 u64 __tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9,
0060 struct tdx_module_output *out);
0061
0062 void tdx_get_ve_info(struct ve_info *ve);
0063
0064 bool tdx_handle_virt_exception(struct pt_regs *regs, struct ve_info *ve);
0065
0066 void tdx_safe_halt(void);
0067
0068 bool tdx_early_handle_ve(struct pt_regs *regs);
0069
0070 #else
0071
0072 static inline void tdx_early_init(void) { };
0073 static inline void tdx_safe_halt(void) { };
0074
0075 static inline bool tdx_early_handle_ve(struct pt_regs *regs) { return false; }
0076
0077 #endif
0078
0079 #if defined(CONFIG_KVM_GUEST) && defined(CONFIG_INTEL_TDX_GUEST)
0080 long tdx_kvm_hypercall(unsigned int nr, unsigned long p1, unsigned long p2,
0081 unsigned long p3, unsigned long p4);
0082 #else
0083 static inline long tdx_kvm_hypercall(unsigned int nr, unsigned long p1,
0084 unsigned long p2, unsigned long p3,
0085 unsigned long p4)
0086 {
0087 return -ENODEV;
0088 }
0089 #endif
0090 #endif
0091 #endif