cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

tdx.h (2302B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2/* Copyright (C) 2021-2022 Intel Corporation */
      3#ifndef _ASM_X86_TDX_H
      4#define _ASM_X86_TDX_H
      5
      6#include <linux/init.h>
      7#include <linux/bits.h>
      8#include <asm/ptrace.h>
      9#include <asm/shared/tdx.h>
     10
     11/*
     12 * SW-defined error codes.
     13 *
     14 * Bits 47:40 == 0xFF indicate Reserved status code class that never used by
     15 * TDX module.
     16 */
     17#define TDX_ERROR			_BITUL(63)
     18#define TDX_SW_ERROR			(TDX_ERROR | GENMASK_ULL(47, 40))
     19#define TDX_SEAMCALL_VMFAILINVALID	(TDX_SW_ERROR | _UL(0xFFFF0000))
     20
     21#ifndef __ASSEMBLY__
     22
     23/*
     24 * Used to gather the output registers values of the TDCALL and SEAMCALL
     25 * instructions when requesting services from the TDX module.
     26 *
     27 * This is a software only structure and not part of the TDX module/VMM ABI.
     28 */
     29struct tdx_module_output {
     30	u64 rcx;
     31	u64 rdx;
     32	u64 r8;
     33	u64 r9;
     34	u64 r10;
     35	u64 r11;
     36};
     37
     38/*
     39 * Used by the #VE exception handler to gather the #VE exception
     40 * info from the TDX module. This is a software only structure
     41 * and not part of the TDX module/VMM ABI.
     42 */
     43struct ve_info {
     44	u64 exit_reason;
     45	u64 exit_qual;
     46	/* Guest Linear (virtual) Address */
     47	u64 gla;
     48	/* Guest Physical Address */
     49	u64 gpa;
     50	u32 instr_len;
     51	u32 instr_info;
     52};
     53
     54#ifdef CONFIG_INTEL_TDX_GUEST
     55
     56void __init tdx_early_init(void);
     57
     58/* Used to communicate with the TDX module */
     59u64 __tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9,
     60		      struct tdx_module_output *out);
     61
     62void tdx_get_ve_info(struct ve_info *ve);
     63
     64bool tdx_handle_virt_exception(struct pt_regs *regs, struct ve_info *ve);
     65
     66void tdx_safe_halt(void);
     67
     68bool tdx_early_handle_ve(struct pt_regs *regs);
     69
     70#else
     71
     72static inline void tdx_early_init(void) { };
     73static inline void tdx_safe_halt(void) { };
     74
     75static inline bool tdx_early_handle_ve(struct pt_regs *regs) { return false; }
     76
     77#endif /* CONFIG_INTEL_TDX_GUEST */
     78
     79#if defined(CONFIG_KVM_GUEST) && defined(CONFIG_INTEL_TDX_GUEST)
     80long tdx_kvm_hypercall(unsigned int nr, unsigned long p1, unsigned long p2,
     81		       unsigned long p3, unsigned long p4);
     82#else
     83static inline long tdx_kvm_hypercall(unsigned int nr, unsigned long p1,
     84				     unsigned long p2, unsigned long p3,
     85				     unsigned long p4)
     86{
     87	return -ENODEV;
     88}
     89#endif /* CONFIG_INTEL_TDX_GUEST && CONFIG_KVM_GUEST */
     90#endif /* !__ASSEMBLY__ */
     91#endif /* _ASM_X86_TDX_H */