-
Notifications
You must be signed in to change notification settings - Fork 31
Include <linux/vmalloc.h> explicitly on x86
#6
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
Conversation
|
I would like to ask @rota1001 to review and check the connection with sysprog21/kxo#1 |
|
I am using $ uname -r
6.11.0-21-genericAttempting to build without including /home/eric/linux2025/simrupt/simrupt.c: In function ‘simrupt_init’:
/home/eric/linux2025/simrupt/simrupt.c:359:20: error: implicit declaration of function ‘vmalloc’; did you mean ‘kmalloc’? [-Werror=implicit-function-declaration]
359 | fast_buf.buf = vmalloc(PAGE_SIZE);
| ^~~~~~~
| kmalloc
/home/eric/linux2025/simrupt/simrupt.c:359:18: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
359 | fast_buf.buf = vmalloc(PAGE_SIZE);
| ^
/home/eric/linux2025/simrupt/simrupt.c:370:9: error: implicit declaration of function ‘vfree’; did you mean ‘kvfree’? [-Werror=implicit-function-declaration]
370 | vfree(fast_buf.buf);
| ^~~~~
| kvfree
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:244: /home/eric/linux2025/simrupt/simrupt.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.11.0-21-generic/Makefile:1932: /home/eric/linux2025/simrupt] Error 2
make[1]: *** [Makefile:224: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.11.0-21-generic'
make: *** [Makefile:9: all] Error 2 |
|
The The same issue regarding implicit declaration of vmalloc() can also be seen in this Stack Overflow discussion. Therefore, I believe both simrupt and kxo should explicitly include |
|
@jserv I've reviewed this change, and it looks like the same problem as what has been memtioned in sysprog21/kxo#1. Moreover, this change works for my environment ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Append Tested-by: Chisheng Chen <johnny1001s000602@gmail.com> to acknowledge the review from @rota1001
|
This patch also fixes sysprog21/kxo#1, which I have tested on my Due to git commit message guidelines (72-character line limit), I've included the relevant kernel commit links here separately for reference:
|
|
See if the following statements were correct:
Per @rota1001 reported, the affected kernel version is at least v6.11, and the above seems to be confusing. Clarify it. |
<linux/vmalloc.h> explicitly on x86
Clarify the following message: |
Commit 1f059dfdf5d1 ("mm/vmalloc: Add empty <asm/vmalloc.h> headers
and use them from <linux/vmalloc.h>") restructured kernel header
dependencies since kernel v5.6-rc1, necessitating explicit inclusion
of <linux/vmalloc.h> on x86 architectures.
This ensures compatibility across kernel versions and prevents build
errors due to implicit declarations on kernels since v5.6-rc1.
Tested-by: Chisheng Chen <johnny1001s000602@gmail.com>
Co-authored-by: Po-Ying Chiu <charlie910417@gmail.com>
|
Thank @EricccTaiwan for contributing! |
Newer kernel versions (>= 5.4) require explicitly including <linux/vmalloc.h> to use vmalloc() and vfree(). Older kernels might have included it implicitly through other headers, but this is no longer the case. Without this include, builds fail with implicit function declaration errors on recent kernels such as 6.11. Ref: sysprog21/simrupt#6

Newer kernel versions (>= 5.4) require explicitly including <linux/vmalloc.h> to use vmalloc() and vfree(). Older kernels might have included this implicitly through other headers, but this is no longer the case.
Without this include, builds will fail with implicit function declaration errors on recent kernels such as 6.11.