AndiWeiss / alx-wol

dkms for atheros alx ethernet driver wol patch
23 stars 4 forks source link

Failed patching kernel 6.8.4 #13

Closed alvarocurt closed 2 months ago

alvarocurt commented 2 months ago

First of all congratulations for this repo. It worked flawlessly so far with Ubuntu 22.04

As the driver can fit any distro for the latest release, I wanted to repurpose rpuse the machine as a Proxmox Server with the latest version (kernel version 6.8.4-3-pve), but unfortunately , it fails failed during install. Running the install.sh scripts gives the following error

root@pve:/opt/alx-wol# ./install.sh
Sign command: /lib/modules/6.8.4-3-pve/build/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub
Debian.sh: can't detect the kernel creator
extract_kversion.sh: wasn't able to get kernel version
#### kernel was compiled with gcc 12.2.0 ####
#### using /usr/bin/x86_64-linux-gnu-gcc-12 to compile module ####
Creating symlink /var/lib/dkms/alx-wol/2.1/source -> /usr/src/alx-wol-2.1

Running the pre_build script:
cat: /var/lib/dkms/alx-wol/2.1/build/../6.8.4-3-pve/kernel_version: No such file or directory
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/plain/drivers/net/ethernet/atheros/alx?h=v:
2024-05-22 22:06:33 ERROR 404: Not found.
fetch_kernelparts.sh failed

Building module:
Cleaning build area...(bad exit status: 2)
make -j8 KERNELRELEASE=6.8.4-3-pve -j4 KERNELRELEASE=6.8.4-3-pve -C /lib/modules/6.8.4-3-pve/build M=/var/lib/dkms/alx-wol/2.1/build HOSTCC=/usr/bin/x86_64-linux-gnu-gcc-12 CC=/usr/bin/x86_64-linux-gnu-gcc-12...(bad exit status: 2)
Error! Bad return status for module build on kernel: 6.8.4-3-pve (x86_64)
Consult /var/lib/dkms/alx-wol/2.1/build/make.log for more information.
#### FAILED installation of alx-wol version 2.1 ####

The log /var/lib/dkms/alx-wol/2.1/build/make.log says:

DKMS make.log for alx-wol-2.1 for kernel 6.8.4-3-pve (x86_64)
Wed May 22 10:06:33 PM CEST 2024
make: Entering directory '/usr/src/linux-headers-6.8.4-3-pve'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (Debian 12.2.0-14) 12.2.0
  You are using:           x86_64-linux-gnu-gcc-12 (Debian 12.2.0-14) 12.2.0
scripts/Makefile.build:41: /var/lib/dkms/alx-wol/2.1/build/alx/Makefile: No such file or directory
make[3]: *** No rule to make target '/var/lib/dkms/alx-wol/2.1/build/alx/Makefile'.  Stop.
make[2]: *** [scripts/Makefile.build:481: /var/lib/dkms/alx-wol/2.1/build/alx] Error 2
make[1]: *** [/usr/src/linux-headers-6.8.4-3-pve/Makefile:1926: /var/lib/dkms/alx-wol/2.1/build] Error 2
make: *** [Makefile:240: __sub-make] Error 2
make: Leaving directory '/usr/src/linux-headers-6.8.4-3-pve'

It seems like dkms failed pulling the original driver files from https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/plain/drivers/net/ethernet/atheros/alx?h=v: being those last characters the problem. Regarding the log, the directory /var/lib/dkms/alx-wol/2.1/build/alx/ is empty so there's no Makefile there.

I have no prior experience debugging modules/kernels so I honestly don't know if the problem lays in this repo or the dkms tool.

AndiWeiss commented 2 months ago

Hi there, thank you very much for your report. The failure is not related to the kernel patching itself. The problem happens because the scripting isn't able to detect the kernel version of your system. Is there a possibility to download different kernels of the Proxmox distribution? I need the version string of them to be able to extract all required information. Kind regards Andreas Weiß

alvarocurt commented 2 months ago

Sure, kernels for proxmox try to follow Ubuntu LTS releases, and the latest one tries to mimic Ubuntu 24.04's v6.8 kernel https://forum.proxmox.com/threads/opt-in-linux-6-8-kernel-for-proxmox-ve-8-available-on-test-no-subscription.144557/

Despite that, I don't know what do you mean by "version string" of the kernels. You can find them all at http://download.proxmox.com/debian/pve/dists/bookworm/pve-no-subscription/binary-amd64/ following naming proxmox-kernel-* I'm sorry If I wasn't helpful

AndiWeiss commented 2 months ago

I'll take a look for it. Shouldn't be a big thing ...

AndiWeiss commented 2 months ago

I started porting and have a problem with Proxmox.

Most things should be fine now, but I can't test it because of a Proxmox limitation.

Can you please check if your installation contains the linux headers for your kernel?

Please post the result of ls -d /usr/src/linux-headers*

On my clean installation dkms is non-functional because of missing linux headers. And that's from my point of view an issue of the Proxmox system, not of dkms or alx-wol ...

Kind regards Andreas Weiß

PS: I used the Proxmox Virtual Environment. I fear that the matching debian packages are hidden in the Proxmox Enterprise server where I don't have access as I don't use Proxmox ...

alvarocurt commented 2 months ago

Sure

ls -lahd /usr/src/linux-headers*
drwxr-xr-x  4 root root  138 May 22 20:52 /usr/src/linux-headers-6.1.0-21-amd64
drwxr-xr-x  4 root root   77 May 22 20:52 /usr/src/linux-headers-6.1.0-21-common
drwxr-xr-x 25 root root 4.0K May 22 21:21 /usr/src/linux-headers-6.8.4-3-pve

But I have to remark I installed some header packages that might not be required

root@pve:~# dpkg -l |grep -i headers
ii  libltdl-dev:amd64                    2.4.7-5                             amd64        System independent dlopen wrapper for GNU libtool (headers)
ii  linux-headers-6.1.0-21-amd64         6.1.90-1                            amd64        Header files for Linux 6.1.0-21-amd64
ii  linux-headers-6.1.0-21-common        6.1.90-1                            all          Common header files for Linux 6.1.0-21
ii  linux-headers-amd64                  6.1.90-1                            amd64        Header files for Linux amd64 configuration (meta-package)
ii  linux-libc-dev:amd64                 6.1.90-1                            amd64        Linux support headers for userspace development
ii  proxmox-default-headers              1.1.0                               all          Default Proxmox Kernel Headers
ii  proxmox-headers-6.8                  6.8.4-3                             all          Latest Proxmox Kernel Headers
ii  proxmox-headers-6.8.4-3-pve          6.8.4-3                             amd64        Proxmox Kernel Headers
ii  pve-headers                          8.2.0                               all          Default Proxmox Kernel Headers (transitional package)

I think you might need to install the proxmox-default-headers package to get the kernel headers. The linux-headers-* packages seem to stop since kernel version 6.1.0

AndiWeiss commented 2 months ago

In principle I have alx-wol running on Proxmox now.

BUT:

There is an issue in the dependencies of the Proxmox packages. When installing dkms the linux headers for the current running kernel have to be installed. But they aren't.

After execution of apt install proxmox-headers-$(uname -r) these headers are available. Installation of alx-wol works fine then.

BUT:

With apt get upgrade, when installing a new kernel, the required headers again are not installed and dkms skips the module compilation because of the missing headers.

This is an issue in Proxmox, not in alx-wol.

I prepared a version locally but as long as I don't have a comment from the Proxmox guys I think it's better not to publish it.

If you want to get the version asap I'll push it on a feature branch ...

alvarocurt commented 2 months ago

Hmm I see.. Thanks for the useful insights. I thought proxmox-default-headers was inteligent enough to add dependencies to the most recent headers. (I edited last comment, i previously recommended to only install proxmox-headers-6.8.4-3-pve ).

I'll keep it in mind next time I update the kernel, so yeah, you can push it to a separate branch Kind regards

AndiWeiss commented 2 months ago

My point is: All other distributions I know do install the required headers when you install dkms. You need not take care for that - without the matching headers dkms can't compile any module.

But I'll give it another try. Maybe one installation before installing dkms is enough.

Nevertheless in my eyes this is a weakness of Proxmox.

Kind regards AndiWeiss

AndiWeiss commented 2 months ago

You can take a look into branch proxmox. This works fine as long as you take care that the matching linux headers are installed. I don't know if this is automatically done with installing proxmox-default-headers.

Additionally this package is not available in the standard installation. You have to either have a subscription or add the no-subscription url (deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription) to your /etc/apt/sources.list.

USE IT ON YOUR OWN RISK!

alvarocurt commented 2 months ago

Good evening @AndiWeiss , I'm sorry I couldn't test the branch before, I had some busy weeks. But now this weekend I got around it. During installation (./install.sh) I'm getting the following output

alx.ko:
Running module version sanity check.
  - Original module
  - Installation
    - Installing to /lib/modules/6.8.4-3-pve/updates/dkms/

Running the post_install script:
insmod: ERROR: could not insert module /lib/modules/6.8.4-3-pve/updates/dkms/alx.ko: Key was rejected by service
update-initramfs: Generating /boot/initrd.img-8.8.4-3-pve
Running hook script 'zz-proxmox-boot'..
Re-executing '/etc/kernel/postinst.d/zz-proxmox-boot' in new private mount namespace..
No /etc/kernel/proxmox-boot-uuids found, skipping ESP sync.
depmod...
#### installation of alx-wol version 2.1.1 succeeded ####

After that, the Network Card stops being detected (not even listed in ip link) With lspci -v I see that the NIC does not have a "Kernel driver in use:" line, and with lsmod I see that the alx driver isn't automatically being loaded into the kernel.

It seems like there is an error there. Running modprobe -v alx gives the following output

insmod /lib/modules/6.8.4-3-pve/updates/dkms/alx.ko
modprobe: ERROR: could not insert 'alx': Key was rejected by service

From what I could research, looks like the module can't be loaded in the kernel if secure boot is enabled, the module wasn't correctly signed. I also gather from the output that the module was signed with the /lib/modules/6.8.4-3-pve/build/scripts/sign-file command, and with /var/lib/dkms/mok.key as both signing key and public certificate. Maybe the script should use /var/lib/dkms/mok.pub instead as the public certificate? It probably is an error from Proxmox's kernel side but I though this problem as something worth noting.

Note: My machine stopped having any connectivity during the process, so the outputs shown have been manually typed. I apologize for any possible typo. I had two ways of recovering my machine's connectivity:

AndiWeiss commented 2 months ago

Hi there, just as information if something like that goes wrong again: The original module is not deleted by alx-wol, it's still there. So you can - in the case that the kernel can't load the self compiled one - the original one with 'insmod'. You just have to give insmod the full path to the original kernel module. After that connectivity is back again and you can regularly remove the dkms again. I don't remember the path in proxmox, in Ubuntu 22.04 it is: /usr/modules/$(uname -r)/kernel/drivers/net/ethernet/atheros/alx/alx.ko In Ubuntu 23.x and 24.x the module is compressed and the file extension has changed.

You view is correct, there is a problem with the image signature. To be honest: up to now I didn't try secure boot, neither with proxmox nor with any other distribution. I'll take a look on it - the board I have with the atheros chip is rather old, I have to check if secure boot is working fine on it. Sorry for inconvenience ...

alvarocurt commented 2 months ago

Perfect, thank you for to the fast response. I imagine the image signature fix will be an small change. PD: In Proxmox the full path is /lib/modules/6.8.4-3-pve/kernel/drivers/net/ethernet/atheros/alx/alx.ko. The file command states that the file is "ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), BuildID[sha1]=ae1478d4fcd0a4bdc8e98f258ad457981152605e, not stripped", so looks like it isn't compressed either.

AndiWeiss commented 2 months ago

One question in advance: Did you checkout the Machine Owner Key part on this page? https://pve.proxmox.com/wiki/Secure_Boot_Setup

You need the MOK to tell the system to accept the own compiled module. Here is written how this has to be configured.

Kind regards AndiWeiss

alvarocurt commented 2 months ago

Well, It actually worked. After running mokutil --import /var/lib/dkms/mok.pub I can finally use alx-wol with secure boot. Thanks!!!

AndiWeiss commented 2 months ago

Thank you very much for your positive reply.

Edelf commented 1 month ago

@AndiWeiss sorry for commenting on a closed issue but:

I just tested your proxmox branch on my laptop run proxmox 6.8.4-3-pve and it worked! Thank you so much.

AndiWeiss commented 1 month ago

@Edelf Thank you very much for the positive comment.