[PATCH] tooling: Check kernel version before building

8 views
Skip to first unread message

voy...@gmail.com

unread,
Nov 9, 2015, 10:42:31 AM11/9/15
to jailho...@googlegroups.com, Jan Kiszka, Dmitry Voytik
From: Dmitry Voytik <dmitry...@huawei.com>

Check if used kernel version is >= kern_need, fail to build
otherwise. Print warning if used kernel version is < kern_recommend.

Signed-off-by: Dmitry Voytik <dmitry...@huawei.com>
---
Makefile | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/Makefile b/Makefile
index 6d597af..6801781 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,19 @@ include scripts/include.mk
# out-of-tree build for our kernel-module, firmware and inmates
KDIR ?= /lib/modules/`uname -r`/build

+# Check kernel version
+kern_need := 3.14
+kern_recommend := 3.19
+kern_used := $(lastword $(shell grep '^VERSION = ' $(KDIR)/Makefile)\
+ ).$(lastword $(shell grep '^PATCHLEVEL = ' $(KDIR)/Makefile))
+ifneq ($(kern_need), $(firstword $(sort $(kern_used) $(kern_need))))
+$(error Linux kernel version must be >= $(kern_need). Yours is $(kern_used))
+endif
+ifneq ($(kern_recommend), $(firstword $(sort $(kern_used) $(kern_recommend))))
+$(warning Your kernel (v$(kern_used)) is too old.\
+ Recommended version is $(kern_recommend))
+endif
+
INSTALL_MOD_PATH ?= $(DESTDIR)
export INSTALL_MOD_PATH

--
2.1.0

Jan Kiszka

unread,
Nov 9, 2015, 11:09:31 AM11/9/15
to voy...@gmail.com, jailho...@googlegroups.com, Dmitry Voytik
On 2015-11-09 16:42, voy...@gmail.com wrote:
> From: Dmitry Voytik <dmitry...@huawei.com>
>
> Check if used kernel version is >= kern_need, fail to build
> otherwise. Print warning if used kernel version is < kern_recommend.
>
> Signed-off-by: Dmitry Voytik <dmitry...@huawei.com>
> ---
> Makefile | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 6d597af..6801781 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -25,6 +25,19 @@ include scripts/include.mk
> # out-of-tree build for our kernel-module, firmware and inmates
> KDIR ?= /lib/modules/`uname -r`/build
>
> +# Check kernel version
> +kern_need := 3.14

Strictly spoken, this is with CONFIG_PCI only. But I'm inclined to
ignore this and require 3.14. We can then clean up a view wrappers along
that line.

> +kern_recommend := 3.19

Where does this number come from?

Jan

> +kern_used := $(lastword $(shell grep '^VERSION = ' $(KDIR)/Makefile)\
> + ).$(lastword $(shell grep '^PATCHLEVEL = ' $(KDIR)/Makefile))
> +ifneq ($(kern_need), $(firstword $(sort $(kern_used) $(kern_need))))
> +$(error Linux kernel version must be >= $(kern_need). Yours is $(kern_used))
> +endif
> +ifneq ($(kern_recommend), $(firstword $(sort $(kern_used) $(kern_recommend))))
> +$(warning Your kernel (v$(kern_used)) is too old.\
> + Recommended version is $(kern_recommend))
> +endif
> +
> INSTALL_MOD_PATH ?= $(DESTDIR)
> export INSTALL_MOD_PATH
>
>

--
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux

Henning Schild

unread,
Nov 9, 2015, 11:14:10 AM11/9/15
to voy...@gmail.com, jailho...@googlegroups.com, Jan Kiszka, Dmitry Voytik
Good idea, after the "pci.o Error" thread i also thought something like
that could be useful.

On Mon, 9 Nov 2015 16:42:19 +0100
<voy...@gmail.com> wrote:

> From: Dmitry Voytik <dmitry...@huawei.com>
>
> Check if used kernel version is >= kern_need, fail to build
> otherwise. Print warning if used kernel version is < kern_recommend.
>
> Signed-off-by: Dmitry Voytik <dmitry...@huawei.com>
> ---
> Makefile | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 6d597af..6801781 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -25,6 +25,19 @@ include scripts/include.mk
> # out-of-tree build for our kernel-module, firmware and inmates
> KDIR ?= /lib/modules/`uname -r`/build
>
> +# Check kernel version
> +kern_need := 3.14

That should be true for x86_64 intel. But i guess that depends on the
arch.

> +kern_recommend := 3.19
> +kern_used := $(lastword $(shell grep '^VERSION = ' $(KDIR)/Makefile)\
> + ).$(lastword $(shell grep '^PATCHLEVEL = '

Here i would recommend "make -C $(KDIR) kernelversion".

Dmitry Voytik

unread,
Nov 9, 2015, 11:19:33 AM11/9/15
to Jan Kiszka, Jailhouse, Dmitry Voytik
Hi Jan,

On Mon, Nov 9, 2015 at 5:09 PM, Jan Kiszka <jan.k...@siemens.com> wrote:
> On 2015-11-09 16:42, voy...@gmail.com wrote:
>> From: Dmitry Voytik <dmitry...@huawei.com>
>>
>> Check if used kernel version is >= kern_need, fail to build
>> otherwise. Print warning if used kernel version is < kern_recommend.
>>
>> Signed-off-by: Dmitry Voytik <dmitry...@huawei.com>
>> ---
>> Makefile | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/Makefile b/Makefile
>> index 6d597af..6801781 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -25,6 +25,19 @@ include scripts/include.mk
>> # out-of-tree build for our kernel-module, firmware and inmates
>> KDIR ?= /lib/modules/`uname -r`/build
>>
>> +# Check kernel version
>> +kern_need := 3.14
>
> Strictly spoken, this is with CONFIG_PCI only. But I'm inclined to
> ignore this and require 3.14. We can then clean up a view wrappers along
> that line.
>
>> +kern_recommend := 3.19
>
> Where does this number come from?

This is from README.md, "Setup on Banana Pi ARM board", line 275.
Maybe it is better to distinguish requirements for each arch?

> Jan
>
>> +kern_used := $(lastword $(shell grep '^VERSION = ' $(KDIR)/Makefile)\
>> + ).$(lastword $(shell grep '^PATCHLEVEL = ' $(KDIR)/Makefile))
>> +ifneq ($(kern_need), $(firstword $(sort $(kern_used) $(kern_need))))
>> +$(error Linux kernel version must be >= $(kern_need). Yours is $(kern_used))
>> +endif
>> +ifneq ($(kern_recommend), $(firstword $(sort $(kern_used) $(kern_recommend))))
>> +$(warning Your kernel (v$(kern_used)) is too old.\
>> + Recommended version is $(kern_recommend))
>> +endif
>> +
>> INSTALL_MOD_PATH ?= $(DESTDIR)
>> export INSTALL_MOD_PATH
>>
>>
>
> --
> Siemens AG, Corporate Technology, CT RTC ITP SES-DE
> Corporate Competence Center Embedded Linux



--
Best Regards,
Dmitry Voytik.
voy...@gmail.com

Dmitry Voytik

unread,
Nov 9, 2015, 11:21:55 AM11/9/15
to Henning Schild, Jailhouse, Jan Kiszka, Dmitry Voytik
Good idea. Thanks. I'll redo the patch.

>> $(KDIR)/Makefile)) +ifneq ($(kern_need), $(firstword $(sort
>> $(kern_used) $(kern_need)))) +$(error Linux kernel version must be >=
>> $(kern_need). Yours is $(kern_used)) +endif
>> +ifneq ($(kern_recommend), $(firstword $(sort $(kern_used)
>> $(kern_recommend)))) +$(warning Your kernel (v$(kern_used)) is too
>> old.\
>> + Recommended version is $(kern_recommend))
>> +endif
>> +
>> INSTALL_MOD_PATH ?= $(DESTDIR)
>> export INSTALL_MOD_PATH
>>
>



Jan Kiszka

unread,
Nov 9, 2015, 11:24:05 AM11/9/15
to Dmitry Voytik, Jailhouse, Dmitry Voytik
Right, but that's even a board-specific dependency. Let's focus here on
driver-related aspects, or these recommendations will quickly explode.

Jan

Henning Schild

unread,
Nov 9, 2015, 11:39:03 AM11/9/15
to Dmitry Voytik, Jan Kiszka, Jailhouse, Dmitry Voytik
Such an error sounds pretty definitive and might discourage people
that for some reason have to use an older kernel. "backporting" should
actually be really simple in most cases. So the message should tell
people to please upgrade or contact us for support of older kernels.

Henning

voy...@gmail.com

unread,
Nov 9, 2015, 12:48:33 PM11/9/15
to jailho...@googlegroups.com, Jan Kiszka, Dmitry Voytik
From: Dmitry Voytik <dmitry...@huawei.com>

Check if used kernel version is >= kern_$(ARCH)_need, fail to build
otherwise.

Signed-off-by: Dmitry Voytik <dmitry...@huawei.com>
---
Makefile | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/Makefile b/Makefile
index 6d597af..f69d04c 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,17 @@ include scripts/include.mk
# out-of-tree build for our kernel-module, firmware and inmates
KDIR ?= /lib/modules/`uname -r`/build

+# Check kernel version
+kern_x86_need := 3.14
+kern_arm_need := 3.19
+
+kused := $(shell make -s -C $(KDIR) kernelversion)
+kneed := $(kern_$(ARCH)_need)
+ifneq ($(kneed), $(firstword $(shell echo -e "$(kused)\n$(kneed)"| sort -V)))
+$(error Your kernel (v$(kused)) is too old.\
+ Minimal required version is $(kneed))
+endif
+
INSTALL_MOD_PATH ?= $(DESTDIR)
export INSTALL_MOD_PATH

--
2.1.0

Jan Kiszka

unread,
Nov 9, 2015, 12:50:20 PM11/9/15
to voy...@gmail.com, jailho...@googlegroups.com, Dmitry Voytik
On 2015-11-09 18:48, voy...@gmail.com wrote:
> From: Dmitry Voytik <dmitry...@huawei.com>
>
> Check if used kernel version is >= kern_$(ARCH)_need, fail to build
> otherwise.

"Let's focus here on driver-related aspects, or these recommendations
will quickly explode."

Jetson TK1 won't run on 3.19, e.g.

Jan

Dmitry Voytik

unread,
Nov 10, 2015, 7:17:52 AM11/10/15
to Jan Kiszka, Jailhouse, Dmitry Voytik
On Mon, Nov 9, 2015 at 6:50 PM, Jan Kiszka <jan.k...@siemens.com> wrote:
> On 2015-11-09 18:48, voy...@gmail.com wrote:
>> From: Dmitry Voytik <dmitry...@huawei.com>
>>
>> Check if used kernel version is >= kern_$(ARCH)_need, fail to build
>> otherwise.
>
> "Let's focus here on driver-related aspects, or these recommendations
> will quickly explode."

I am thinking to check against MACH_xxx in
hypervisor/arch/arm/Makefile. Does it make sense for you?

> Jetson TK1 won't run on 3.19, e.g.

It seems that tegra support is broken in Jailhouse. Kernel doesn't
have MACH_TEGRA124, but has ARCH_TEGRA_124_SOC.

Jan Kiszka

unread,
Nov 10, 2015, 7:35:04 AM11/10/15
to Dmitry Voytik, Jailhouse, Dmitry Voytik
On 2015-11-10 13:17, Dmitry Voytik wrote:
> On Mon, Nov 9, 2015 at 6:50 PM, Jan Kiszka <jan.k...@siemens.com> wrote:
>> On 2015-11-09 18:48, voy...@gmail.com wrote:
>>> From: Dmitry Voytik <dmitry...@huawei.com>
>>>
>>> Check if used kernel version is >= kern_$(ARCH)_need, fail to build
>>> otherwise.
>>
>> "Let's focus here on driver-related aspects, or these recommendations
>> will quickly explode."
>
> I am thinking to check against MACH_xxx in
> hypervisor/arch/arm/Makefile. Does it make sense for you?

Not right now, that's why I wrote the above recommendation to encode
only the driver's kernel version dependencies.

>
>> Jetson TK1 won't run on 3.19, e.g.
>
> It seems that tegra support is broken in Jailhouse. Kernel doesn't
> have MACH_TEGRA124, but has ARCH_TEGRA_124_SOC.

MACH_xxx is Jailhouse-internal and has no direct dependency on the
kernel config.

Jan
Reply all
Reply to author
Forward
0 new messages