Skip to content

Commit d4cab20

Browse files
Raito BezariusMic92
Raito Bezarius
authored andcommitted
zfs: add option to restore kernel_neon for linux 6.2 support on aarch64
Introduced in torvalds/linux@aaeca98 with the usual disdain for ZFS. We have been there in the past with <https://www.phoronix.com/news/NixOS-Linux-5.0-ZFS-FPU-Drop> / NixOS#61076. This fixes ZFS on aarch64 until the next breakage. See openzfs/zfs#14555 for original upstream issue.
1 parent 0b62a46 commit d4cab20

File tree

3 files changed

+60
-11
lines changed

3 files changed

+60
-11
lines changed

nixos/modules/tasks/filesystems/zfs.nix

+44-3
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,30 @@ in
323323
Defaults to 0, which waits forever.
324324
'';
325325
};
326+
327+
removeLinuxDRM = lib.mkOption {
328+
type = types.bool;
329+
default = false;
330+
description = lib.mdDoc ''
331+
Linux 6.2 dropped some kernel symbols required on aarch64 required by zfs.
332+
Enabling this option will bring them back to allow this kernel version.
333+
Note that in some jurisdictions this may be illegal as it might be considered
334+
removing copyright protection from the code.
335+
See https://www.ifross.org/?q=en/artikel/ongoing-dispute-over-value-exportsymbolgpl-function for further information.
336+
337+
If configure your kernel package with `zfs.latestCompatibleLinuxPackages`, you will need to also pass removeLinuxDRM to that package like this:
338+
339+
```
340+
{ pkgs, ... }: {
341+
boot.kernelPackages = (pkgs.zfs.override {
342+
removeLinuxDRM = pkgs.hostPlatform.isAarch64;
343+
}).latestCompatibleLinuxPackages;
344+
345+
boot.zfs.removeLinuxDRM = true;
346+
}
347+
```
348+
'';
349+
};
326350
};
327351

328352
services.zfs.autoSnapshot = {
@@ -532,11 +556,13 @@ in
532556
# https://github.com/NixOS/nixpkgs/issues/106093
533557
kernelParams = lib.optionals (!config.boot.zfs.allowHibernation) [ "nohibernate" ];
534558

535-
extraModulePackages = [
536-
(if config.boot.zfs.enableUnstable then
559+
extraModulePackages = let
560+
kernelPkg = if config.boot.zfs.enableUnstable then
537561
config.boot.kernelPackages.zfsUnstable
538562
else
539-
config.boot.kernelPackages.zfs)
563+
config.boot.kernelPackages.zfs;
564+
in [
565+
(kernelPkg.override { inherit (cfgZfs) removeLinuxDRM; })
540566
];
541567
};
542568

@@ -654,6 +680,21 @@ in
654680
services.udev.packages = [ cfgZfs.package ]; # to hook zvol naming, etc.
655681
systemd.packages = [ cfgZfs.package ];
656682

683+
# Export kernel_neon_* symbols again.
684+
# This change is necessary until ZFS figures out a solution
685+
# with upstream or in their build system to fill the gap for
686+
# this symbol.
687+
# In the meantime, we restore what was once a working piece of code
688+
# in the kernel.
689+
boot.kernelPatches = lib.optional (cfgZfs.removeLinuxDRM && pkgs.stdenv.hostPlatform.system == "aarch64-linux") {
690+
name = "export-neon-symbols-as-gpl";
691+
patch = pkgs.fetchpatch {
692+
url = "https://github.com/torvalds/linux/commit/aaeca98456431a8d9382ecf48ac4843e252c07b3.patch";
693+
hash = "sha256-L2g4G1tlWPIi/QRckMuHDcdWBcKpObSWSRTvbHRIwIk=";
694+
revert = true;
695+
};
696+
};
697+
657698
systemd.services = let
658699
createImportService' = pool: createImportService {
659700
inherit pool;

pkgs/os-specific/linux/zfs/stable.nix

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
, kernel ? null
33
, stdenv
44
, linuxKernel
5+
, removeLinuxDRM ? false
56
, ...
67
} @ args:
78

@@ -11,10 +12,13 @@ in
1112
callPackage ./generic.nix args {
1213
# check the release notes for compatible kernels
1314
kernelCompatible =
14-
if stdenv'.isx86_64
15+
if stdenv'.isx86_64 || removeLinuxDRM
1516
then kernel.kernelOlder "6.4"
1617
else kernel.kernelOlder "6.2";
17-
latestCompatibleLinuxPackages = linuxKernel.packages.linux_6_3;
18+
latestCompatibleLinuxPackages = if stdenv'.isx86_64 || removeLinuxDRM then
19+
linuxKernel.packages.linux_6_3
20+
else
21+
linuxKernel.packages.linux_6_1;
1822

1923
# this package should point to the latest release.
2024
version = "2.1.12";

pkgs/os-specific/linux/zfs/unstable.nix

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
, kernel ? null
33
, stdenv
44
, linuxKernel
5+
, removeLinuxDRM ? false
56
, ...
67
} @ args:
78

@@ -13,19 +14,22 @@ callPackage ./generic.nix args {
1314
# NOTE:
1415
# zfs-2.1.9<=x<=2.1.10 is broken with aarch64-linux-6.2
1516
# for future releases, please delete this condition.
16-
kernelCompatible = if stdenv'.isx86_64
17-
then kernel.kernelOlder "6.3"
17+
kernelCompatible = if stdenv'.isx86_64 || removeLinuxDRM
18+
then kernel.kernelOlder "6.4"
1819
else kernel.kernelOlder "6.2";
19-
latestCompatibleLinuxPackages = linuxKernel.packages.linux_6_1;
20+
21+
latestCompatibleLinuxPackages = if stdenv'.isx86_64 || removeLinuxDRM then
22+
linuxKernel.packages.linux_6_3
23+
else
24+
linuxKernel.packages.linux_6_1;
2025

2126
# this package should point to a version / git revision compatible with the latest kernel release
2227
# IMPORTANT: Always use a tagged release candidate or commits from the
2328
# zfs-<version>-staging branch, because this is tested by the OpenZFS
2429
# maintainers.
25-
version = "2.1.12-staging-2023-04-18";
26-
rev = "e25f9131d679692704c11dc0c1df6d4585b70c35";
30+
version = "2.1.12";
2731

28-
sha256 = "tJLwyqUj1l5F0WKZDeMGrEFa8fc/axKqm31xtN51a5M=";
32+
sha256 = "eYUR5d4gpTrlFu6j1uL83DWL9uPGgAUDRdSEb73V5i4=";
2933

3034
isUnstable = true;
3135
}

0 commit comments

Comments
 (0)