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

TOMOYO Linux Cross Reference
Linux/Documentation/arch/x86/x86_64/fred.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 .. SPDX-License-Identifier: GPL-2.0
  2 
  3 =========================================
  4 Flexible Return and Event Delivery (FRED)
  5 =========================================
  6 
  7 Overview
  8 ========
  9 
 10 The FRED architecture defines simple new transitions that change
 11 privilege level (ring transitions). The FRED architecture was
 12 designed with the following goals:
 13 
 14 1) Improve overall performance and response time by replacing event
 15    delivery through the interrupt descriptor table (IDT event
 16    delivery) and event return by the IRET instruction with lower
 17    latency transitions.
 18 
 19 2) Improve software robustness by ensuring that event delivery
 20    establishes the full supervisor context and that event return
 21    establishes the full user context.
 22 
 23 The new transitions defined by the FRED architecture are FRED event
 24 delivery and, for returning from events, two FRED return instructions.
 25 FRED event delivery can effect a transition from ring 3 to ring 0, but
 26 it is used also to deliver events incident to ring 0. One FRED
 27 instruction (ERETU) effects a return from ring 0 to ring 3, while the
 28 other (ERETS) returns while remaining in ring 0. Collectively, FRED
 29 event delivery and the FRED return instructions are FRED transitions.
 30 
 31 In addition to these transitions, the FRED architecture defines a new
 32 instruction (LKGS) for managing the state of the GS segment register.
 33 The LKGS instruction can be used by 64-bit operating systems that do
 34 not use the new FRED transitions.
 35 
 36 Furthermore, the FRED architecture is easy to extend for future CPU
 37 architectures.
 38 
 39 Software based event dispatching
 40 ================================
 41 
 42 FRED operates differently from IDT in terms of event handling. Instead
 43 of directly dispatching an event to its handler based on the event
 44 vector, FRED requires the software to dispatch an event to its handler
 45 based on both the event's type and vector. Therefore, an event dispatch
 46 framework must be implemented to facilitate the event-to-handler
 47 dispatch process. The FRED event dispatch framework takes control
 48 once an event is delivered, and employs a two-level dispatch.
 49 
 50 The first level dispatching is event type based, and the second level
 51 dispatching is event vector based.
 52 
 53 Full supervisor/user context
 54 ============================
 55 
 56 FRED event delivery atomically save and restore full supervisor/user
 57 context upon event delivery and return. Thus it avoids the problem of
 58 transient states due to %cr2 and/or %dr6, and it is no longer needed
 59 to handle all the ugly corner cases caused by half baked entry states.
 60 
 61 FRED allows explicit unblock of NMI with new event return instructions
 62 ERETS/ERETU, avoiding the mess caused by IRET which unconditionally
 63 unblocks NMI, e.g., when an exception happens during NMI handling.
 64 
 65 FRED always restores the full value of %rsp, thus ESPFIX is no longer
 66 needed when FRED is enabled.
 67 
 68 LKGS
 69 ====
 70 
 71 LKGS behaves like the MOV to GS instruction except that it loads the
 72 base address into the IA32_KERNEL_GS_BASE MSR instead of the GS
 73 segment’s descriptor cache. With LKGS, it ends up with avoiding
 74 mucking with kernel GS, i.e., an operating system can always operate
 75 with its own GS base address.
 76 
 77 Because FRED event delivery from ring 3 and ERETU both swap the value
 78 of the GS base address and that of the IA32_KERNEL_GS_BASE MSR, plus
 79 the introduction of LKGS instruction, the SWAPGS instruction is no
 80 longer needed when FRED is enabled, thus is disallowed (#UD).
 81 
 82 Stack levels
 83 ============
 84 
 85 4 stack levels 0~3 are introduced to replace the nonreentrant IST for
 86 event handling, and each stack level should be configured to use a
 87 dedicated stack.
 88 
 89 The current stack level could be unchanged or go higher upon FRED
 90 event delivery. If unchanged, the CPU keeps using the current event
 91 stack. If higher, the CPU switches to a new event stack specified by
 92 the MSR of the new stack level, i.e., MSR_IA32_FRED_RSP[123].
 93 
 94 Only execution of a FRED return instruction ERET[US], could lower the
 95 current stack level, causing the CPU to switch back to the stack it was
 96 on before a previous event delivery that promoted the stack level.

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