Merge pull request #255804 from sielicki/kernel-arm-alignment-compat

kernel/common-config: arm: configure alignment traps

authored by

K900 and committed by
GitHub
43c8fb93 e00c6064

+22
+22
pkgs/os-specific/linux/kernel/common-config.nix
··· 1007 # Keeping it a built-in ensures it will be used if possible. 1008 FB_SIMPLE = yes; 1009 1010 } // optionalAttrs (versionAtLeast version "5.4" && (stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "aarch64-linux")) { 1011 # Required for various hardware features on Chrome OS devices 1012 CHROME_PLATFORMS = yes;
··· 1007 # Keeping it a built-in ensures it will be used if possible. 1008 FB_SIMPLE = yes; 1009 1010 + # https://docs.kernel.org/arch/arm/mem_alignment.html 1011 + # tldr: 1012 + # when buggy userspace code emits illegal misaligned LDM, STM, 1013 + # LDRD and STRDs, the instructions trap, are caught, and then 1014 + # are emulated by the kernel. 1015 + # 1016 + # This is the default on armv7l, anyway, but it is explicitly 1017 + # enabled here for the sake of providing context for the 1018 + # aarch64 compat option which follows. 1019 + ALIGNMENT_TRAP = mkIf (stdenv.hostPlatform.system == "armv7l-linux") yes; 1020 + 1021 + # https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220701135322.3025321-1-ardb@kernel.org/ 1022 + # tldr: 1023 + # when encountering alignment faults under aarch64, this option 1024 + # makes the kernel attempt to handle the fault by doing the 1025 + # same style of misaligned emulation that is performed under 1026 + # armv7l (see above option). 1027 + # 1028 + # This minimizes the potential for aarch32 userspace to behave 1029 + # differently when run under aarch64 kernels compared to when 1030 + # it is run under an aarch32 kernel. 1031 + COMPAT_ALIGNMENT_FIXUPS = mkIf (stdenv.hostPlatform.system == "aarch64-linux") (whenAtLeast "6.1" yes); 1032 } // optionalAttrs (versionAtLeast version "5.4" && (stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "aarch64-linux")) { 1033 # Required for various hardware features on Chrome OS devices 1034 CHROME_PLATFORMS = yes;