The Linux compatibility code is converting the version number (e.g. 2.6.32) in two different ways and then comparing the results. The linux_map_osrel() function converted MAJOR.MINOR.PATCH similar to what FreeBSD does natively. I.e. where major=v0, minor=v1, and patch=v2 v = v0 * 1000000 + v1 * 1000 + v2; The LINUX_KERNVER() macro, on the other hand, converted the value with bit shifts. I.e. where major=a, minor=b, and patch=c v = (((a) << 16) + ((b) << 8) + (c))
Fix up for review https://reviews.freebsd.org/D15952
The latter is "correct" in that it will match the numeric versions Linux uses internally.
Aha, top-level Linux Makefile emits the KERNEL_VERSION macro into a header.
A commit references this bug: Author: chuck Date: Fri Jun 22 00:02:04 UTC 2018 New revision: 335515 URL: https://svnweb.freebsd.org/changeset/base/335515 Log: Fix the Linux kernel version number calculation The Linux compatibility code was converting the version number (e.g. 2.6.32) in two different ways and then comparing the results. The linux_map_osrel() function converted MAJOR.MINOR.PATCH similar to what FreeBSD does natively. I.e. where major=v0, minor=v1, and patch=v2 v = v0 * 1000000 + v1 * 1000 + v2; The LINUX_KERNVER() macro, on the other hand, converted the value with bit shifts. I.e. where major=a, minor=b, and patch=c v = (((a) << 16) + ((b) << 8) + (c)) The Linux kernel uses the later format via the KERNEL_VERSION() macro in include/generated/uapi/linux/version.h Fix is to use the LINUX_KERNVER() macro in linux_map_osrel() as well as in the .trans_osrel functions. PR: 229209 Reviewed by: emaste, cem, imp (mentor) Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15952 Changes: head/sys/amd64/linux/linux_sysvec.c head/sys/amd64/linux32/linux32_sysvec.c head/sys/compat/linux/linux_mib.c head/sys/i386/linux/linux_sysvec.c
Do we want to MFC this change?
I'm fine with MFC'ing this as it can stand on its own. Bug it was mainly done to support a fix to the linprocfs stat (https://reviews.freebsd.org/D15858) entry.
OK - I'm largely indifferent to the MFC, just noticed that this PR wasn't closed after the commit.
OK, that's my bad. Closing as this has been committed.
A commit references this bug: Author: dchagin Date: Sun Apr 28 14:08:06 UTC 2019 New revision: 346835 URL: https://svnweb.freebsd.org/changeset/base/346835 Log: MFC r335515 (by chuck@): Fix the Linux kernel version number calculation The Linux compatibility code was converting the version number (e.g. 2.6.32) in two different ways and then comparing the results. The linux_map_osrel() function converted MAJOR.MINOR.PATCH similar to what FreeBSD does natively. I.e. where major=v0, minor=v1, and patch=v2 v = v0 * 1000000 + v1 * 1000 + v2; The LINUX_KERNVER() macro, on the other hand, converted the value with bit shifts. I.e. where major=a, minor=b, and patch=c v = (((a) << 16) + ((b) << 8) + (c)) The Linux kernel uses the later format via the KERNEL_VERSION() macro in include/generated/uapi/linux/version.h Fix is to use the LINUX_KERNVER() macro in linux_map_osrel() as well as in the .trans_osrel functions. PR: 229209 Changes: _U stable/11/ stable/11/sys/amd64/linux/linux_sysvec.c stable/11/sys/amd64/linux32/linux32_sysvec.c stable/11/sys/compat/linux/linux_mib.c stable/11/sys/i386/linux/linux_sysvec.c