flohoff / amifldrv

AMI BIOS Aptio kernel flash driver
23 stars 8 forks source link

When building against newer kernels error: assignment of read-only member ‘vm_flags’ #3

Open penguinjeff opened 11 months ago

penguinjeff commented 11 months ago

I am trying to build amifldrv on Fedora 39. I finally after much frustration downloaded and compiled the kernels as talked about in the afulnx documentation. They fail to mention that I need to download the source from your project bunt sice I get an error saying could not find amifldrv I assume I need to compile this driver as well. So I downloaded your driver and tried to compile it and get the error mentioned in the title

make -C /lib/modules/6.6.6-200.fc39.x86_64/build M=/root/github/amifldrv modules make[1]: Entering directory '/root/rpmbuild/BUILD/kernel-6.6.6/linux-6.6.6-200.fc39.x86_64' CC [M] /root/github/amifldrv/amifldrv.o /root/github/amifldrv/amifldrv.c: In function ‘AMI_chrdrv_mmap’: /root/github/amifldrv/amifldrv.c:357:23: error: assignment of read-only member ‘vm_flags’ 357 | vma->vm_flags |= VM_LOCKED; | ^~ /root/github/amifldrv/amifldrv.c: In function ‘AMI_chrdrv_compat_ioctl’: /root/github/amifldrv/amifldrv.c:273:25: warning: ignoring return value of ‘copy_from_user’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 273 | copy_from_user((void ) &arg_kernel_space, (void ) arg, | ^~~~~~~~~~~~ 274 | sizeof(AMIFL_alloc_params)); | ~~~~~~~ /root/github/amifldrv/amifldrv.c: In function ‘AMI_chrdrv_ioctl’: /root/github/amifldrv/amifldrv.c:303:25: warning: ignoring return value of ‘copy_from_user’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 303 | copy_from_user((void ) &arg_kernel_space, (void ) arg, | ^~~~~~~~~~~~ 304 | sizeof(AMIFL_alloc_params)); | ~~~~~~~ /root/github/amifldrv/amifldrv.c:311:25: warning: ignoring return value of ‘copy_to_user’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 311 | copy_to_user((void ) arg, (void ) &arg_kernel_space, | ^~~~~~~~~~~~~~ 312 | sizeof(AMIFL_alloc_params)); | ~~~~~~~ /root/github/amifldrv/amifldrv.c:321:25: warning: ignoring return value of ‘copy_from_user’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 321 | copy_from_user((void ) &arg_kernel_space, (void ) arg, | ^~~~~~~~~~~~ 322 | sizeof(AMIFL_alloc_params)); | ~~~~~~~ make[3]: [scripts/Makefile.build:243: /root/github/amifldrv/amifldrv.o] Error 1 make[2]: [/root/rpmbuild/BUILD/kernel-6.6.6/linux-6.6.6-200.fc39.x86_64/Makefile:1931: /root/github/amifldrv] Error 2 make[1]: [Makefile:246: __sub-make] Error 2 make[1]: Leaving directory '/root/rpmbuild/BUILD/kernel-6.6.6/linux-6.6.6-200.fc39.x86_64' make: [Makefile:8: default] Error 2

flohoff commented 11 months ago

I only forked the stuff to get it to work with a 64 bit userspace. For flashing a kernel module is needed and thats HEAVILY kernel version dependend. So most like you will need into the changes for the kernel for the last years and update the modules code.

I am not using that code for a long time now and i have no clue of what use it is. I guess it would be much easier to create an old image to just flash the machine.

You might want to try to look through the forks - maybe they updated the code meanwhile.

penguinjeff commented 11 months ago

Sorry frustration is not with you it is with MSI and them not documenting what needs to be done to run their program.

flohoff commented 11 months ago

No worries - I know - the whole flashing issue with MSI is broken. They should contribute to the fwupd/fwupgrade stuff and make it possible.

And hiding a kernel module as source within a binary and compiling it on the fly is just broken.

Flo

JoeMGomes commented 4 months ago

If anyone still comes across this issue, the solution to this specific problem is something like this.

        //vma->vm_flags |= VM_LOCKED;  
    vm_flags_set(vma, VM_LOCKED);

Source: https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1910545.html

flohoff commented 4 months ago

If anyone still comes across this issue, the solution to this specific problem is something like this.

        //vma->vm_flags |= VM_LOCKED;  
  vm_flags_set(vma, VM_LOCKED);

Source: https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1910545.html

I guess that could be done with an ifdef vm_flags_set or based on the kernel version?

I am actually astonished people still use this. The devices in need of this software are now mostly likely 20+ years or what devices do we talk about?

Flo

JoeMGomes commented 4 months ago

AMI used to have the AFULNX utility for flashing the BIOS via Linux (worked until about Ubuntu Bionic approx) but they stopped maintaining it (only windows and DOS are available now). Decompiling the afulnx i came across this file and am trying to get it to work for more recent kernels for a work project. Flashing AMI BIOS via Linux would be a HUGE thing but it seems like a thing of the past...

flohoff commented 4 months ago

Are that current machines/hardware or is that legacy? I was running on pretty legacy hardware by the time i extracted that and i was under the impression that newer stuff would be supported. Probably with UEFI Firmware Capsules.