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

TOMOYO Linux Cross Reference
Linux/arch/x86/include/asm/fred.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 /*
  3  * Macros for Flexible Return and Event Delivery (FRED)
  4  */
  5 
  6 #ifndef ASM_X86_FRED_H
  7 #define ASM_X86_FRED_H
  8 
  9 #include <linux/const.h>
 10 
 11 #include <asm/asm.h>
 12 #include <asm/trapnr.h>
 13 
 14 /*
 15  * FRED event return instruction opcodes for ERET{S,U}; supported in
 16  * binutils >= 2.41.
 17  */
 18 #define ERETS                   _ASM_BYTES(0xf2,0x0f,0x01,0xca)
 19 #define ERETU                   _ASM_BYTES(0xf3,0x0f,0x01,0xca)
 20 
 21 /*
 22  * RSP is aligned to a 64-byte boundary before used to push a new stack frame
 23  */
 24 #define FRED_STACK_FRAME_RSP_MASK       _AT(unsigned long, (~0x3f))
 25 
 26 /*
 27  * Used for the return address for call emulation during code patching,
 28  * and measured in 64-byte cache lines.
 29  */
 30 #define FRED_CONFIG_REDZONE_AMOUNT      1
 31 #define FRED_CONFIG_REDZONE             (_AT(unsigned long, FRED_CONFIG_REDZONE_AMOUNT) << 6)
 32 #define FRED_CONFIG_INT_STKLVL(l)       (_AT(unsigned long, l) << 9)
 33 #define FRED_CONFIG_ENTRYPOINT(p)       _AT(unsigned long, (p))
 34 
 35 #ifndef __ASSEMBLY__
 36 
 37 #ifdef CONFIG_X86_FRED
 38 #include <linux/kernel.h>
 39 
 40 #include <asm/ptrace.h>
 41 
 42 struct fred_info {
 43         /* Event data: CR2, DR6, ... */
 44         unsigned long edata;
 45         unsigned long resv;
 46 };
 47 
 48 /* Full format of the FRED stack frame */
 49 struct fred_frame {
 50         struct pt_regs   regs;
 51         struct fred_info info;
 52 };
 53 
 54 static __always_inline struct fred_info *fred_info(struct pt_regs *regs)
 55 {
 56         return &container_of(regs, struct fred_frame, regs)->info;
 57 }
 58 
 59 static __always_inline unsigned long fred_event_data(struct pt_regs *regs)
 60 {
 61         return fred_info(regs)->edata;
 62 }
 63 
 64 void asm_fred_entrypoint_user(void);
 65 void asm_fred_entrypoint_kernel(void);
 66 void asm_fred_entry_from_kvm(struct fred_ss);
 67 
 68 __visible void fred_entry_from_user(struct pt_regs *regs);
 69 __visible void fred_entry_from_kernel(struct pt_regs *regs);
 70 __visible void __fred_entry_from_kvm(struct pt_regs *regs);
 71 
 72 /* Can be called from noinstr code, thus __always_inline */
 73 static __always_inline void fred_entry_from_kvm(unsigned int type, unsigned int vector)
 74 {
 75         struct fred_ss ss = {
 76                 .ss     =__KERNEL_DS,
 77                 .type   = type,
 78                 .vector = vector,
 79                 .nmi    = type == EVENT_TYPE_NMI,
 80                 .lm     = 1,
 81         };
 82 
 83         asm_fred_entry_from_kvm(ss);
 84 }
 85 
 86 void cpu_init_fred_exceptions(void);
 87 void fred_complete_exception_setup(void);
 88 
 89 #else /* CONFIG_X86_FRED */
 90 static __always_inline unsigned long fred_event_data(struct pt_regs *regs) { return 0; }
 91 static inline void cpu_init_fred_exceptions(void) { }
 92 static inline void fred_complete_exception_setup(void) { }
 93 static __always_inline void fred_entry_from_kvm(unsigned int type, unsigned int vector) { }
 94 #endif /* CONFIG_X86_FRED */
 95 #endif /* !__ASSEMBLY__ */
 96 
 97 #endif /* ASM_X86_FRED_H */
 98 

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