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

TOMOYO Linux Cross Reference
Linux/arch/x86/kernel/fred.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 #include <linux/kernel.h>
  3 
  4 #include <asm/desc.h>
  5 #include <asm/fred.h>
  6 #include <asm/tlbflush.h>
  7 #include <asm/traps.h>
  8 
  9 /* #DB in the kernel would imply the use of a kernel debugger. */
 10 #define FRED_DB_STACK_LEVEL             1UL
 11 #define FRED_NMI_STACK_LEVEL            2UL
 12 #define FRED_MC_STACK_LEVEL             2UL
 13 /*
 14  * #DF is the highest level because a #DF means "something went wrong
 15  * *while delivering an exception*." The number of cases for which that
 16  * can happen with FRED is drastically reduced and basically amounts to
 17  * "the stack you pointed me to is broken." Thus, always change stacks
 18  * on #DF, which means it should be at the highest level.
 19  */
 20 #define FRED_DF_STACK_LEVEL             3UL
 21 
 22 #define FRED_STKLVL(vector, lvl)        ((lvl) << (2 * (vector)))
 23 
 24 void cpu_init_fred_exceptions(void)
 25 {
 26         /* When FRED is enabled by default, remove this log message */
 27         pr_info("Initialize FRED on CPU%d\n", smp_processor_id());
 28 
 29         wrmsrl(MSR_IA32_FRED_CONFIG,
 30                /* Reserve for CALL emulation */
 31                FRED_CONFIG_REDZONE |
 32                FRED_CONFIG_INT_STKLVL(0) |
 33                FRED_CONFIG_ENTRYPOINT(asm_fred_entrypoint_user));
 34 
 35         /*
 36          * The purpose of separate stacks for NMI, #DB and #MC *in the kernel*
 37          * (remember that user space faults are always taken on stack level 0)
 38          * is to avoid overflowing the kernel stack.
 39          */
 40         wrmsrl(MSR_IA32_FRED_STKLVLS,
 41                FRED_STKLVL(X86_TRAP_DB,  FRED_DB_STACK_LEVEL) |
 42                FRED_STKLVL(X86_TRAP_NMI, FRED_NMI_STACK_LEVEL) |
 43                FRED_STKLVL(X86_TRAP_MC,  FRED_MC_STACK_LEVEL) |
 44                FRED_STKLVL(X86_TRAP_DF,  FRED_DF_STACK_LEVEL));
 45 
 46         /* The FRED equivalents to IST stacks... */
 47         wrmsrl(MSR_IA32_FRED_RSP1, __this_cpu_ist_top_va(DB));
 48         wrmsrl(MSR_IA32_FRED_RSP2, __this_cpu_ist_top_va(NMI));
 49         wrmsrl(MSR_IA32_FRED_RSP3, __this_cpu_ist_top_va(DF));
 50 
 51         /* Enable FRED */
 52         cr4_set_bits(X86_CR4_FRED);
 53         /* Any further IDT use is a bug */
 54         idt_invalidate();
 55 
 56         /* Use int $0x80 for 32-bit system calls in FRED mode */
 57         setup_clear_cpu_cap(X86_FEATURE_SYSENTER32);
 58         setup_clear_cpu_cap(X86_FEATURE_SYSCALL32);
 59 }
 60 

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