Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel hacking on NixOS? #14721

Closed
lukego opened this issue Apr 15, 2016 · 8 comments
Closed

Kernel hacking on NixOS? #14721

lukego opened this issue Apr 15, 2016 · 8 comments
Labels
0.kind: question Requests for a specific question to be answered 6.topic: kernel The Linux kernel

Comments

@lukego
Copy link
Contributor

lukego commented Apr 15, 2016

This is a NixOS newbie question.

I would like to make some experimental changes to the Linux mlx4 module on my NixOS machine. I am looking for an edit-compile-run workflow where I would build and load (insmod) the module. It is important that this would happen directly on the host and not inside a VM.

Can anybody please tell me how to do this? I am hoping that I can do something like nix-build ... && insmod .../mlx4.ko but I am not sure how to connect those dots :).

@joachifm joachifm added the 0.kind: question Requests for a specific question to be answered label Apr 15, 2016
@cleverca22
Copy link
Contributor

nix-shell on the kernel package, run unpackPhase to unpack it, and then find the kernel config somewhere and build as usual, then edit+make+insmod in a loop, and once your changes are working, you can make an override against the kernel and supply a patch so nix can rereate the changes automaticaly

@domenkozar
Copy link
Member

Here is what I have so far:

$ nix-shell -A linuxPackages.kernel
$ unpackPhase
$ cd linux-4.4.6/
$ echo $configurePhase
runHook preConfigure ln -sv /nix/store/6gg85hq4ccd2s1r9y6iyk61vblya8mw3-linux-config-4.4.6 $buildRoot/.config make $makeFlags "${makeFlagsArray[@]}" oldconfig runHook postConfigure # Note: we can get rid of this once http://permalink.gmane.org/gmane.linux.kbuild.devel/13800 is merged. buildFlagsArray+=("KBUILD_BUILD_TIMESTAMP=$(date -u -d @$SOURCE_DATE_EPOCH)")
$ exec $configurePhase
bash: exec: runHook: not found

@domenkozar
Copy link
Member

If I manually run cp /nix/store/6gg85hq4ccd2s1r9y6iyk61vblya8mw3-linux-config-4.4.6 .config, I can then execute make.

@domenkozar
Copy link
Member

domenkozar commented Apr 16, 2016

Or to just build those modules:

make modules M=drivers/net/ethernet/mellanox/
sudo insmod drivers/net/ethernet/mellanox//mlx4/mlx4_en.ko

However, I get an error:

insmod: ERROR: could not insert module drivers/net/ethernet/mellanox//mlx4/mlx4_en.ko: Invalid module format

And in dmesg:

[232201.652452] mlx4_en: no symbol version for module_layout

@domenkozar
Copy link
Member

Aha, I'm also missing Module.symvers

@domenkozar domenkozar added the 6.topic: kernel The Linux kernel label Apr 16, 2016
@dezgeg
Copy link
Contributor

dezgeg commented Apr 16, 2016

Module.symvers comes from the kernel dev package. You need to do something like make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build M=$(pwd)/drivers/net/ethernet/mellanox modules

Also no messing with .config should be needed with that.

Also, I didn't actually test the above ;)

@lukego
Copy link
Contributor Author

lukego commented Apr 19, 2016

Thanks for the tips!

@lukego lukego closed this as completed Apr 19, 2016
@domenkozar
Copy link
Member

domenkozar commented May 20, 2016

I've pushed some documentation on this for future me: 2d6d731

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: question Requests for a specific question to be answered 6.topic: kernel The Linux kernel
Projects
None yet
Development

No branches or pull requests

5 participants