Closed Dunedan closed 3 years ago
Which operating system is this? Did you use the same compiler(version) to compile the modue that was used to compile the kernel?
Also try a make clean
This is from running on an up-to-date Debian/unstable with the Debian provided kernel.
I don't know which compiler version was used for compiling the kernel and is used when building the module, however I'd assume they're the same, as Debian/unstable is pretty frozen since a while in preparation for the next Debian release. If you can point me to how to figure out which compiler versions are used, I'd be happy to provide this information though.
make clean
doesn't help unfortunately.
You should be able to see the kernels compiler in the kernel config file. cat /boot/config-$(uname -r)
All right. Appears to be the same version:
$ cat /boot/config-$(uname -r) | grep "CONFIG_CC_VERSION_TEXT"
CONFIG_CC_VERSION_TEXT="gcc-10 (Debian 10.2.1-6) 10.2.1 20210110"
$ gcc --version
gcc (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I tested it on a blank Debian unstable box and it worked fine there.
Do you have any MAKEFLAGS
, CFLAGS
etc defined?
Try running make clean; make V=1
Do you have any
MAKEFLAGS
,CFLAGS
etc defined?
Not that I'm aware of. I neither modified the Makefile, nor are they defined as environment variables:
$ echo $MAKEFLAGS
$ echo $CFLAGS
Try running make clean; make V=1
As expected that doesn't work, but here is the additional output:
$ LANG= make clean; make V=1
make -C /lib/modules/`uname -r`/build M=$PWD clean
make[1]: Entering directory '/usr/src/linux-headers-5.10.0-6-amd64'
make[1]: Leaving directory '/usr/src/linux-headers-5.10.0-6-amd64'
make -C /lib/modules/`uname -r`/build M=$PWD modules
make[1]: Verzeichnis „/usr/src/linux-headers-5.10.0-6-amd64“ wird betreten
make -C /usr/src/linux-headers-5.10.0-6-amd64 -f /usr/src/linux-headers-5.10.0-6-common/Makefile modules
test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \
echo >&2; \
echo >&2 " ERROR: Kernel configuration is invalid."; \
echo >&2 " include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo >&2 ; \
/bin/false)
make -f /usr/src/linux-headers-5.10.0-6-common/scripts/Makefile.build obj=/some/dir/linux-gigabyte-wmi-driver \
single-build= \
need-builtin=1 need-modorder=1
gcc-10 -Wp,-MMD,/some/dir/linux-gigabyte-wmi-driver/.gigabyte-wmi.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/10/include -I/usr/src/linux-headers-5.10.0-6-common/arch/x86/include -I./arch/x86/include/generated -I/usr/src/linux-headers-5.10.0-6-common/include -I./include -I/usr/src/linux-headers-5.10.0-6-common/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.10.0-6-common/include/uapi -I./include/generated/uapi -include /usr/src/linux-headers-5.10.0-6-common/include/linux/kconfig.h -include /usr/src/linux-headers-5.10.0-6-common/include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=/usr/src/linux-headers-5.10.0-6-common/= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -g -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -DMODULE -DKBUILD_BASENAME='"gigabyte_wmi"' -DKBUILD_MODNAME='"gigabyte_wmi"' -c -o /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi.o /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi.c
./tools/objtool/objtool orc generate --module --no-fp --retpoline --uaccess /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi.o
if objdump -h /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi.o | grep -q __ksymtab; then gcc-10 -E -D__GENKSYMS__ -Wp,-MMD,/some/dir/linux-gigabyte-wmi-driver/.gigabyte-wmi.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/10/include -I/usr/src/linux-headers-5.10.0-6-common/arch/x86/include -I./arch/x86/include/generated -I/usr/src/linux-headers-5.10.0-6-common/include -I./include -I/usr/src/linux-headers-5.10.0-6-common/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.10.0-6-common/include/uapi -I./include/generated/uapi -include /usr/src/linux-headers-5.10.0-6-common/include/linux/kconfig.h -include /usr/src/linux-headers-5.10.0-6-common/include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=/usr/src/linux-headers-5.10.0-6-common/= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -g -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -DMODULE -DKBUILD_BASENAME='"gigabyte_wmi"' -DKBUILD_MODNAME='"gigabyte_wmi"' /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi.c | scripts/genksyms/genksyms -r /dev/null > /some/dir/linux-gigabyte-wmi-driver/.tmp_gigabyte-wmi.ver; ld -m elf_x86_64 -r -o /some/dir/linux-gigabyte-wmi-driver/.tmp_gigabyte-wmi.o /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi.o -T /some/dir/linux-gigabyte-wmi-driver/.tmp_gigabyte-wmi.ver; mv -f /some/dir/linux-gigabyte-wmi-driver/.tmp_gigabyte-wmi.o /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi.o; rm -f /some/dir/linux-gigabyte-wmi-driver/.tmp_gigabyte-wmi.ver; fi
{ echo /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi.o; echo; } > /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi.mod
{ echo /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi.ko; :; } | awk '!x[$0]++' - > /some/dir/linux-gigabyte-wmi-driver/modules.order
make -f /usr/src/linux-headers-5.10.0-6-common/scripts/Makefile.modpost
sed 's/ko$/o/' /some/dir/linux-gigabyte-wmi-driver/modules.order | scripts/mod/modpost -m -o /some/dir/linux-gigabyte-wmi-driver/Module.symvers -e -i Module.symvers -T -
FATAL: modpost: /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi: sizeof(struct wmi_device_id)=44 is not a modulo of the size of section __mod_wmi__<identifier>_device_table=96.
Fix definition of struct wmi_device_id in mod_devicetable.h
make[3]: *** [/usr/src/linux-headers-5.10.0-6-common/scripts/Makefile.modpost:124: /some/dir/linux-gigabyte-wmi-driver/Module.symvers] Fehler 1
make[2]: *** [/usr/src/linux-headers-5.10.0-6-common/Makefile:1726: modules] Fehler 2
make[1]: *** [/usr/src/linux-headers-5.10.0-6-common/Makefile:185: __sub-make] Fehler 2
make[1]: Verzeichnis „/usr/src/linux-headers-5.10.0-6-amd64“ wird verlassen
make: *** [Makefile:12: modules] Fehler 2
Looks the same as on my box. What is the output of:
objdump -x gigabyte-wmi.o |grep __mod_wmi__
pahole gigabyte-wmi.o -C wmi_device_id
(install the dwarves
package)
Here you go:
$ objdump -x gigabyte-wmi.o | grep __mod_wmi__
0000000000000000 g O .rodata 0000000000000060 __mod_wmi__gigabyte_wmi_id_table_device_table
$ pahole gigabyte-wmi.o -C wmi_device_id
struct wmi_device_id {
const const char guid_string[37]; /* 0 37 */
/* XXX 3 bytes hole, try to pack */
const void * context; /* 40 8 */
/* size: 48, cachelines: 1, members: 2 */
/* sum members: 45, holes: 1, sum holes: 3 */
/* last cacheline: 48 bytes */
};
This all looks fine.
grep wmi /lib/modules/$(uname -r)/build/scripts/mod/devicetable-offsets.h
It seems Debian does not ship this file.
I have one more guess. Maybe for some reason the 32 bit modpost is being executed.
sed 's/ko$/o/' /somedir/linux-gigabyte-wmi-driver/modules.order | strace -o /tmp/x /lib/modules/5.10.0-6-amd64/build/scripts/mod/modpost -m -o /somedir/linux-gigabyte-wmi-driver/Module.symvers -e -i Module.symvers -T -
grep execve /tmp/x
In the module source directory:
file *
I had to remove the -i Module.symvers
from the modpost
command as there wasn't a Module.symvers
file, but I guess that's fine. The outputs are:
$ sed 's/ko$/o/' /some/dir/linux-gigabyte-wmi-driver/modules.order | strace -o /tmp/x /lib/modules/5.10.0-6-amd64/build/scripts/mod/modpost -m -o /some/dir/linux-gigabyte-wmi-driver/Module.symvers -e -T -
FATAL: modpost: /some/dir/linux-gigabyte-wmi-driver/gigabyte-wmi: sizeof(struct wmi_device_id)=44 is not a modulo of the size of section __mod_wmi__<identifier>_device_table=96.
Fix definition of struct wmi_device_id in mod_devicetable.h
$ grep execve /tmp/x
execve("/lib/modules/5.10.0-6-amd64/build/scripts/mod/modpost", ["/lib/modules/5.10.0-6-amd64/buil"..., "-m", "-o", "/some/dir/lin"..., "-e", "-T", "-"], 0x7ffda4b50b80 /* 52 vars */) = 0
execve("/lib/modules/5.10.0-6-amd64/build/scripts/mod/modpost.real-lsb-64", ["/lib/modules/5.10.0-6-amd64/buil"..., "-m", "-o", "/some/dir/lin"..., "-e", "-T", "-", "/some/dir/lin"...], 0xfff76114 /* 52 vars */) = 0
$ file *
acpi_tables: directory
gigabyte-wmi.c: C source, UTF-8 Unicode text
gigabyte-wmi.mod: ASCII text
gigabyte-wmi.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
Makefile: ASCII text
modules.order: ASCII text
README.md: ASCII text
ssdt8.dat: symbolic link to acpi_tables/x570-I-aorus-pro-wifi-1.0/F33g/ssdt8.dat
ssdt8.dsl: symbolic link to acpi_tables/x570-I-aorus-pro-wifi-1.0/F33g/ssdt8.dsl
Found it!
A bit of searching lead me to the following page where somebody had a similar problem: https://debianforum.de/forum/viewtopic.php?t=151617
Turns out the reason for the problem there was the same reason as for my problem: Instead of the amd64 version of linux-kbuild-5.10` I had the i386 version installed (no idea why). Installing the amd64 version fixed the issue.
Good :-)
Thanks for your help debugging this!
I tried building the driver to contribute a usage report for a Gigabyte B550I AORUS PRO AX, but run into the following error:
Any idea what's wrong there?