summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kernel/common-config.nix
diff options
context:
space:
mode:
authorNicholas Sielicki <nix@opensource.nslick.com>2023-09-17 23:14:09 -0500
committerNicholas Sielicki <nix@opensource.nslick.com>2023-09-17 23:14:09 -0500
commitb9495de12eb949fd9d0ca3ebb9c9b862f2f6f786 (patch)
treec0113c944ebc4d6ba6cfb79830d22b238c906fb3 /pkgs/os-specific/linux/kernel/common-config.nix
parente3f328b0de306cc15bdd5a0c5a55e0ea1ca11b4a (diff)
downloadnixpkgs-b9495de12eb949fd9d0ca3ebb9c9b862f2f6f786.tar
nixpkgs-b9495de12eb949fd9d0ca3ebb9c9b862f2f6f786.tar.gz
nixpkgs-b9495de12eb949fd9d0ca3ebb9c9b862f2f6f786.tar.bz2
nixpkgs-b9495de12eb949fd9d0ca3ebb9c9b862f2f6f786.tar.lz
nixpkgs-b9495de12eb949fd9d0ca3ebb9c9b862f2f6f786.tar.xz
nixpkgs-b9495de12eb949fd9d0ca3ebb9c9b862f2f6f786.tar.zst
nixpkgs-b9495de12eb949fd9d0ca3ebb9c9b862f2f6f786.zip
kernel/common-config: arm: configure alignment traps
under armv7l, config.gz already had CONFIG_ALIGNMENT_TRAP=y, but
explicitly enable it and provide some context for the option.

under aarch64, on kernels that are new enough to support it, specify
CONFIG_COMPAT_ALIGNMENT_FIXUPS=y to attempt to resolve alignment
faults identically to how they are handled under 32-bit kernels. This
minimizes the potential for aarch32 userspace to behave differently
under an aarch64 kernel.
Diffstat (limited to 'pkgs/os-specific/linux/kernel/common-config.nix')
-rw-r--r--pkgs/os-specific/linux/kernel/common-config.nix22
1 files changed, 22 insertions, 0 deletions
diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix
index 2e558267736..b4d4d11772f 100644
--- a/pkgs/os-specific/linux/kernel/common-config.nix
+++ b/pkgs/os-specific/linux/kernel/common-config.nix
@@ -1071,6 +1071,28 @@ let
       # Keeping it a built-in ensures it will be used if possible.
       FB_SIMPLE = yes;
 
+      # https://docs.kernel.org/arch/arm/mem_alignment.html
+      # tldr:
+      #  when buggy userspace code emits illegal misaligned LDM, STM,
+      #  LDRD and STRDs, the instructions trap, are caught, and then
+      #  are emulated by the kernel.
+      #
+      #  This is the default on armv7l, anyway, but it is explicitly
+      #  enabled here for the sake of providing context for the
+      #  aarch64 compat option which follows.
+      ALIGNMENT_TRAP = mkIf (stdenv.hostPlatform.system == "armv7l-linux") yes;
+
+      # https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220701135322.3025321-1-ardb@kernel.org/
+      # tldr:
+      #  when encountering alignment faults under aarch64, this option
+      #  makes the kernel attempt to handle the fault by doing the
+      #  same style of misaligned emulation that is performed under
+      #  armv7l (see above option).
+      #
+      #  This minimizes the potential for aarch32 userspace to behave
+      #  differently when run under aarch64 kernels compared to when
+      #  it is run under an aarch32 kernel.
+      COMPAT_ALIGNMENT_FIXUPS = mkIf (stdenv.hostPlatform.system == "aarch64-linux") (whenAtLeast "6.1" yes);
     } // optionalAttrs (versionAtLeast version "5.4" && (stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "aarch64-linux")) {
       # Required for various hardware features on Chrome OS devices
       CHROME_PLATFORMS = yes;