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

TOMOYO Linux Cross Reference
Linux/arch/x86/boot/compressed/tdx.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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 
  3 #include "../cpuflags.h"
  4 #include "../string.h"
  5 #include "../io.h"
  6 #include "error.h"
  7 
  8 #include <vdso/limits.h>
  9 #include <uapi/asm/vmx.h>
 10 
 11 #include <asm/shared/tdx.h>
 12 
 13 /* Called from __tdx_hypercall() for unrecoverable failure */
 14 void __tdx_hypercall_failed(void)
 15 {
 16         error("TDVMCALL failed. TDX module bug?");
 17 }
 18 
 19 static inline unsigned int tdx_io_in(int size, u16 port)
 20 {
 21         struct tdx_module_args args = {
 22                 .r10 = TDX_HYPERCALL_STANDARD,
 23                 .r11 = hcall_func(EXIT_REASON_IO_INSTRUCTION),
 24                 .r12 = size,
 25                 .r13 = 0,
 26                 .r14 = port,
 27         };
 28 
 29         if (__tdx_hypercall(&args))
 30                 return UINT_MAX;
 31 
 32         return args.r11;
 33 }
 34 
 35 static inline void tdx_io_out(int size, u16 port, u32 value)
 36 {
 37         struct tdx_module_args args = {
 38                 .r10 = TDX_HYPERCALL_STANDARD,
 39                 .r11 = hcall_func(EXIT_REASON_IO_INSTRUCTION),
 40                 .r12 = size,
 41                 .r13 = 1,
 42                 .r14 = port,
 43                 .r15 = value,
 44         };
 45 
 46         __tdx_hypercall(&args);
 47 }
 48 
 49 static inline u8 tdx_inb(u16 port)
 50 {
 51         return tdx_io_in(1, port);
 52 }
 53 
 54 static inline void tdx_outb(u8 value, u16 port)
 55 {
 56         tdx_io_out(1, port, value);
 57 }
 58 
 59 static inline void tdx_outw(u16 value, u16 port)
 60 {
 61         tdx_io_out(2, port, value);
 62 }
 63 
 64 void early_tdx_detect(void)
 65 {
 66         u32 eax, sig[3];
 67 
 68         cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, &sig[0], &sig[2],  &sig[1]);
 69 
 70         if (memcmp(TDX_IDENT, sig, sizeof(sig)))
 71                 return;
 72 
 73         /* Use hypercalls instead of I/O instructions */
 74         pio_ops.f_inb  = tdx_inb;
 75         pio_ops.f_outb = tdx_outb;
 76         pio_ops.f_outw = tdx_outw;
 77 }
 78 

~ [ 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