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

TOMOYO Linux Cross Reference
Linux/Documentation/arch/arm/mem_alignment.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 ================
  2 Memory alignment
  3 ================
  4 
  5 Too many problems popped up because of unnoticed misaligned memory access in
  6 kernel code lately.  Therefore the alignment fixup is now unconditionally
  7 configured in for SA11x0 based targets.  According to Alan Cox, this is a
  8 bad idea to configure it out, but Russell King has some good reasons for
  9 doing so on some f***ed up ARM architectures like the EBSA110.  However
 10 this is not the case on many design I'm aware of, like all SA11x0 based
 11 ones.
 12 
 13 Of course this is a bad idea to rely on the alignment trap to perform
 14 unaligned memory access in general.  If those access are predictable, you
 15 are better to use the macros provided by include/linux/unaligned.h.  The
 16 alignment trap can fixup misaligned access for the exception cases, but at
 17 a high performance cost.  It better be rare.
 18 
 19 Now for user space applications, it is possible to configure the alignment
 20 trap to SIGBUS any code performing unaligned access (good for debugging bad
 21 code), or even fixup the access by software like for kernel code.  The later
 22 mode isn't recommended for performance reasons (just think about the
 23 floating point emulation that works about the same way).  Fix your code
 24 instead!
 25 
 26 Please note that randomly changing the behaviour without good thought is
 27 real bad - it changes the behaviour of all unaligned instructions in user
 28 space, and might cause programs to fail unexpectedly.
 29 
 30 To change the alignment trap behavior, simply echo a number into
 31 /proc/cpu/alignment.  The number is made up from various bits:
 32 
 33 ===             ========================================================
 34 bit             behavior when set
 35 ===             ========================================================
 36 0               A user process performing an unaligned memory access
 37                 will cause the kernel to print a message indicating
 38                 process name, pid, pc, instruction, address, and the
 39                 fault code.
 40 
 41 1               The kernel will attempt to fix up the user process
 42                 performing the unaligned access.  This is of course
 43                 slow (think about the floating point emulator) and
 44                 not recommended for production use.
 45 
 46 2               The kernel will send a SIGBUS signal to the user process
 47                 performing the unaligned access.
 48 ===             ========================================================
 49 
 50 Note that not all combinations are supported - only values 0 through 5.
 51 (6 and 7 don't make sense).
 52 
 53 For example, the following will turn on the warnings, but without
 54 fixing up or sending SIGBUS signals::
 55 
 56         echo 1 > /proc/cpu/alignment
 57 
 58 You can also read the content of the same file to get statistical
 59 information on unaligned access occurrences plus the current mode of
 60 operation for user space code.
 61 
 62 
 63 Nicolas Pitre, Mar 13, 2001.  Modified Russell King, Nov 30, 2001.

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