Open KZYSAKYM opened 4 years ago
I fixed the following build error by the following patch.
fixed error
before
make -C /lib/modules/5.9.0-2parrot1-amd64/build M=/home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem
AR /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/built-in.a
CC [M] /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.o
/home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.c: In function 'kmem_init':
/home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.c:61:51: error: passing argument 4 of 'proc_create' from incompatible pointer type [-Werror=incompatible-pointer-types]
61 | proc_create("dtrace_kmem", S_IFREG | 0400, NULL, &proc_kmem);
| ^~~~~~~~~~
| |
| struct file_operations *
In file included from /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.c:16:
/usr/src/linux-headers-5.9.0-2parrot1-common/include/linux/proc_fs.h:107:122: note: expected 'const struct proc_ops *' but argument is of type 'struct file_operations *'
107 | mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops);
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
cc1: some warnings being treated as errors make[3]: [/usr/src/linux-headers-5.9.0-2parrot1-common/scripts/Makefile.build:288: /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.o] Error 1 make[2]: [/usr/src/linux-headers-5.9.0-2parrot1-common/Makefile:1796: /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem] Error 2
- after
symlink ../../driver-kmem/Makefile build-5.9.0-2parrot1-amd64/driver-kmem/Makefile symlink ../../driver-kmem/dtrace_kmem.c build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.c Executing: /home/builder/dtrace/tools/make-me make -C /lib/modules/5.9.0-2parrot1-amd64/build M=/home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem AR /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/built-in.a CC [M] /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.o MODPOST /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/Module.symvers WARNING: modpost: missing MODULE_LICENSE() in /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.o CC [M] /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.mod.o LD [M] /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.ko
- patch
From 80c32588c6ccf7bedce1af9fed39512513f46468 Mon Sep 17 00:00:00 2001 From: KZYSAKYM akiyama.kazuyoshi.64w@gmail.com Date: Sun, 22 Nov 2020 14:51:55 +0900 Subject: [PATCH] update driver-kmem for Linux Kernel v5.6.0+
Due to changing the interface of proc_create
from v5.6.0,
the dtrace_kmem driver could not be built on Linux Kernel v5.6.0+.
This api changing is origined from the following commit of the kernel.
commit d56c0d45f0e27f814e87a1676b6bdccccbc252e9 Author: Alexey Dobriyan adobriyan@gmail.com Date: Mon Feb 3 17:37:14 2020 -0800
proc: decouple proc from VFS with "struct proc_ops"
Currently core /proc code uses "struct file_operations" for custom hooks,
however, VFS doesn't directly call them. Every time VFS expands
file_operations hook set, /proc code bloats for no reason.
Introduce "struct proc_ops" which contains only those hooks which /proc
allows to call into (open, release, read, write, ioctl, mmap, poll). It
doesn't contain module pointer as well.
Save ~184 bytes per usage:
add/remove: 26/26 grow/shrink: 1/4 up/down: 1922/-6674 (-4752)
Function old new delta
sysvipc_proc_ops - 72 +72
...
config_gz_proc_ops - 72 +72
proc_get_inode 289 339 +50
proc_reg_get_unmapped_area 110 107 -3
close_pdeo 227 224 -3
proc_reg_open 289 284 -5
proc_create_data 60 53 -7
rt_cpu_seq_fops 256 - -256
...
default_affinity_proc_fops 256 - -256
Total: Before=5430095, After=5425343, chg -0.09%
Link: http://lkml.kernel.org/r/20191225172228.GA13378@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
So, the compile switch between v5.6.0+ or not is added.
driver-kmem/dtrace_kmem.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/driver-kmem/dtrace_kmem.c b/driver-kmem/dtrace_kmem.c index 3b63c7d..92cf97e 100644 --- a/driver-kmem/dtrace_kmem.c +++ b/driver-kmem/dtrace_kmem.c @@ -18,6 +18,7 @@
+#include <linux/version.h>
/**/ / Module interface to the kernel. / @@ -50,11 +51,18 @@ kmem_read(struct file fp, char __user buf, size_t len, loff_t *off) return len; }
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) +static struct proc_ops proc_kmem = {
.proc_read = kmem_read, +}; +#else static struct file_operations proc_kmem = { .owner = THIS_MODULE, .open = kmem_open, .read = kmem_read, }; +#endif
static int __init kmem_init(void) { -- 2.28.0
Since proc_create
is also used in driver/
(e.g. driver/dtrace_linux.c
), there are other parts that should be fixed.
But, I could not try to fix them due to the error related to dwarf.
/tmp/builder.dwarf.c: In function ‘main’:
/tmp/builder.dwarf.c:5:2: warning: implicit declaration of function ‘dwarf_loclist’ [-Wimplicit-function-declaration]
5 | dwarf_loclist();
| ^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccICNWEi.o: in function `main':
builder.dwarf.c:(.text+0x1f): undefined reference to `dwarf_loclist'
collect2: error: ld returned 1 exit status
Failed to find stub_execve
Use of uninitialized value $old_rsp in concatenation (.) or string at tools/mkport.pl line 144.
old_rsp=
We cannot find old_rsp or per_cpu__old_rsp in your kernel.
Additionally, it looks like /proc/kcore is broken on your kernel,
meaning we cannot poke to find this variable, which helps identify
kernel thread offsets.
FATAL ERROR: cannot find old_rsp
FATAL ERROR: build.pl aborting
make: *** [makefile:67: all] Error 25
(related issue is https://github.com/dtrace4linux/linux/issues/129)
I tried to build dtrace on kernel v5.9 distributed by ParrotOS.
proc_create
is different between v4 and v5.This changing was done in the following commit.
This appears in v5.6-rc1.