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

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

Open
penguinjeff opened this issue Dec 16, 2023 · 7 comments

Comments

@penguinjeff
Copy link

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
Copy link
Owner

flohoff commented Dec 18, 2023

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
Copy link
Author

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

@flohoff
Copy link
Owner

flohoff commented Dec 19, 2023

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
Copy link

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
Copy link
Owner

flohoff commented Jul 5, 2024

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
Copy link

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
Copy link
Owner

flohoff commented Jul 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants