From 5ad68edd000685c016c45e344470f2c1867b8e39 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Thu, 16 Nov 2017 20:40:17 +0000 Subject: [PATCH] Linux 4.12, buildroot 2017.08, Ubuntu 17.10. 17.10 failed with a similar message to: http://patchwork.ozlabs.org/patch/772848/ but applying that patch did not solve it, apparently there were fixes already on later versions of the tracked package. Update .gitmodules to ignore patches we apply to Buildroot. --- .gitmodules | 4 +- README.md | 5 +- build | 1 - ...t-of-stage1flex-when-host-has-glibc-.patch | 141 ++++++++++++++++++ buildroot_patches/README.md | 2 + getting-started.md | 2 +- maintainers.md | 27 ++++ 7 files changed, 175 insertions(+), 7 deletions(-) create mode 100644 buildroot_patches/0001-flex-Fix-segfault-of-stage1flex-when-host-has-glibc-.patch create mode 100644 maintainers.md diff --git a/.gitmodules b/.gitmodules index 8117d50..70c8843 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,10 @@ [submodule "buildroot"] path = buildroot url = https://github.com/buildroot/buildroot - shallow = true + ignore = dirty [submodule "qemu"] path = qemu url = https://github.com/cirosantilli/qemu - shallow = true [submodule "linux"] path = linux url = https://github.com/cirosantilli/linux - shallow = true diff --git a/README.md b/README.md index ac0c375..279d782 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Linux Kernel Module Cheat -Run one command, get a QEMU Buildroot BusyBox virtual machine built from source with several minimal Linux kernel 4.9 module development example tutorials with GDB and KGDB debug and minimal QEMU educational models. Tested in x86, ARM and MIPS guests, Ubuntu 14.04 - 17.04 hosts. +Run one command, get a QEMU Buildroot BusyBox virtual machine built from source with several minimal Linux kernel 4.12 module development example tutorials with GDB and KGDB debug and minimal QEMU educational models. "Tested" in x86, ARM and MIPS guests, latest Ubuntu release host. ![](screenshot.png) @@ -21,4 +21,5 @@ Run one command, get a QEMU Buildroot BusyBox virtual machine built from source 1. [GEM5](gem5.md) 1. Conversation 1. [kmod](kmod.md) -1. [Bibliography](bibliography.md) + 1. [Maintainers](maintainers.md) + 1. [Bibliography](bibliography.md) diff --git a/build b/build index 943e4d5..b7c8356 100755 --- a/build +++ b/build @@ -73,4 +73,3 @@ time \ $extra_targets \ all \ ; -cd .. diff --git a/buildroot_patches/0001-flex-Fix-segfault-of-stage1flex-when-host-has-glibc-.patch b/buildroot_patches/0001-flex-Fix-segfault-of-stage1flex-when-host-has-glibc-.patch new file mode 100644 index 0000000..aa37df2 --- /dev/null +++ b/buildroot_patches/0001-flex-Fix-segfault-of-stage1flex-when-host-has-glibc-.patch @@ -0,0 +1,141 @@ +From c128c5f3c79b31d89256ffbc5c650ba613d3d52b Mon Sep 17 00:00:00 2001 +From: Adrian Perez de Castro +Date: Wed, 13 Sep 2017 17:35:24 +0300 +Subject: [PATCH] flex: Fix segfault of stage1flex when host has glibc 2.26 or + newer + +When the host uses glibc 2.26 or newer, Flex will try to use the +newly-introduced reallocarray() function, but as it would not define +_GNU_SOURCE a segmentation fault would occur later on due to the +compiler assumming that the function is implicitly defined. + +This issue manifests itself due to a crash of "stage1flex" during the +Flex bootstrap: + + ./stage1flex -o stage1scan.c ./scan.l + make[2]: *** [Makefile:1725: stage1scan.c] Segmentation fault (core dumped) + +This imports the patch from the upstream Git repository, and adds flags +in the .mk file to rebuild the Autotools scripts and support files. Due +to the latter, the patch to disable the documentation is changed so it +modifies the .am file instead. + +Signed-off-by: Adrian Perez de Castro +[Arnout: + - Add Adrian's Sob and upstream ref to new patch; + - Keep patch 1 as patch 1; + - Keep Vicente as author of path 1; + - Add reason for autoreconf in a comment.] +Signed-off-by: Arnout Vandecappelle (Essensium/Mind) +--- + package/flex/0001-flex-disable-documentation.patch | 22 ++++++++++---- + ...-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch | 35 ++++++++++++++++++++++ + package/flex/flex.mk | 6 ++++ + 3 files changed, 58 insertions(+), 5 deletions(-) + create mode 100644 package/flex/0002-build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch + +diff --git a/package/flex/0001-flex-disable-documentation.patch b/package/flex/0001-flex-disable-documentation.patch +index 68bec128ee..b017b41385 100644 +--- a/package/flex/0001-flex-disable-documentation.patch ++++ b/package/flex/0001-flex-disable-documentation.patch +@@ -1,4 +1,7 @@ +-flex: disable documentation ++From a98443c6a72d5821d4e0152311e5c3eb4cdff25c Mon Sep 17 00:00:00 2001 ++From: Vicente Olivert Riera ++Date: Wed, 13 Sep 2017 17:26:48 +0300 ++Subject: [PATCH] flex: disable documentation + + Since we prevent the flex binary to be built, we also need to prevent + the documentation to be built, otherwise it will fail like this: +@@ -9,11 +12,17 @@ make[2]: *** No rule to make target '../src/flex', needed by 'flex.1'. + Stop. + + Signed-off-by: Vicente Olivert Riera ++[Adrian: patch Makefile.am instead of Makefile.in] ++Signed-off-by: Adrian Perez de Castro ++--- ++ Makefile.am | 1 - ++ 1 file changed, 1 deletion(-) + +-diff -rup a/Makefile.in b/Makefile.in +---- a/Makefile.in 2017-05-06 15:49:09.000000000 +0100 +-+++ b/Makefile.in 2017-05-10 14:35:20.152794902 +0100 +-@@ -450,7 +450,6 @@ EXTRA_DIST = \ ++diff --git a/Makefile.am b/Makefile.am ++index 638c549..9db3420 100644 ++--- a/Makefile.am +++++ b/Makefile.am ++@@ -43,7 +43,6 @@ EXTRA_DIST = \ + + SUBDIRS = \ + src \ +@@ -21,3 +30,6 @@ diff -rup a/Makefile.in b/Makefile.in + examples \ + po \ + tests \ ++-- ++2.14.1 ++ +diff --git a/package/flex/0002-build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch b/package/flex/0002-build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch +new file mode 100644 +index 0000000000..06747a36e1 +--- /dev/null ++++ b/package/flex/0002-build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch +@@ -0,0 +1,35 @@ ++From ffa886a580929f26fd5e5a40c9c5334955c48553 Mon Sep 17 00:00:00 2001 ++From: Explorer09 ++Date: Mon, 4 Sep 2017 10:47:33 +0800 ++Subject: [PATCH] build: AC_USE_SYSTEM_EXTENSIONS in configure.ac. ++ ++This would, e.g. define _GNU_SOURCE in config.h, enabling the ++reallocarray() prototype in glibc 2.26+ on Linux systems with that ++version of glibc. ++ ++Fixes #241. ++ ++Backported from: 24fd0551333e7eded87b64dd36062da3df2f6380 ++Signed-off-by: Adrian Perez de Castro ++--- ++ configure.ac | 2 ++ ++ 1 file changed, 2 insertions(+) ++ ++diff --git a/configure.ac b/configure.ac ++index 55e774b..c879fe1 100644 ++--- a/configure.ac +++++ b/configure.ac ++@@ -25,8 +25,10 @@ ++ # autoconf requirements and initialization ++ ++ AC_INIT([the fast lexical analyser generator],[2.6.4],[flex-help@lists.sourceforge.net],[flex]) +++AC_PREREQ([2.60]) ++ AC_CONFIG_SRCDIR([src/scan.l]) ++ AC_CONFIG_AUX_DIR([build-aux]) +++AC_USE_SYSTEM_EXTENSIONS ++ LT_INIT ++ AM_INIT_AUTOMAKE([1.11.3 -Wno-portability foreign check-news std-options dist-lzip parallel-tests subdir-objects]) ++ AC_CONFIG_HEADER([src/config.h]) ++-- ++2.14.1 ++ +diff --git a/package/flex/flex.mk b/package/flex/flex.mk +index 0196624e9a..aeac4ada87 100644 +--- a/package/flex/flex.mk ++++ b/package/flex/flex.mk +@@ -10,8 +10,14 @@ FLEX_INSTALL_STAGING = YES + FLEX_LICENSE = FLEX + FLEX_LICENSE_FILES = COPYING + FLEX_DEPENDENCIES = $(TARGET_NLS_DEPENDENCIES) host-m4 ++ ++# 0001-flex-disable-documentation.patch ++# 0002-build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch ++FLEX_AUTORECONF = YES ++FLEX_GETTEXTIZE = YES + FLEX_CONF_ENV = ac_cv_path_M4=/usr/bin/m4 \ + ac_cv_func_reallocarray=no ++ + HOST_FLEX_DEPENDENCIES = host-m4 + + define FLEX_DISABLE_PROGRAM +-- +2.14.1 + diff --git a/buildroot_patches/README.md b/buildroot_patches/README.md index 7ed36c2..22dc485 100644 --- a/buildroot_patches/README.md +++ b/buildroot_patches/README.md @@ -5,3 +5,5 @@ Every `.patch` file in this directory gets applied to Buildroot before anything Ideally, this directory should be empty, and we should use only built-in Buildroot configuration mechanisms. But alas, life is sometimes not ideal. + +We will use those patches only for things which could / have already been upstreamed. The patches will then be removed once we are able to rebase. Educational patches that we might want to do on QEMU will be done by forking the QEMU repo on our submodule. The difference is that it is a bit easier to remove the patches after upstreaming than to squash them out on rebase. diff --git a/getting-started.md b/getting-started.md index 66b8f82..b81e099 100644 --- a/getting-started.md +++ b/getting-started.md @@ -215,7 +215,7 @@ Scripts under `/etc/init.d` are run by `/etc/init.d/rcS`, which gets called by t ## Kernel version -We use Buildroot's default kernel version with small educational patches on top, you can confirm it after build with: +We try to use the latest possible kernel version: grep BR2_LINUX_KERNEL_VERSION buildroot/output.*~/.config diff --git a/maintainers.md b/maintainers.md new file mode 100644 index 0000000..1b0c87a --- /dev/null +++ b/maintainers.md @@ -0,0 +1,27 @@ +# Maintainers + +## How to update the Linux kernel version? + +TODO I can only do it "easily" if the kernel headers are supported, check `buildroot/package/linux-headers/Config.in.host` to see if `BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_12` is there. Once you've found a supported version: + + cd linux + git rebase --onto v4.12 v4.9.6 + # git rebase --onto + +And on `buildroot_config_fragment` edit: + + BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.12" + BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_12=y + +## How to add new Buildroot options? + + cd buildroot/output.x86_64~ + make menuconfig + +Hit `/` and search for the settings. + +Save and quit. + + diff .config.olg .config + +Copy and paste the diff additions to `buildroot_config_fragment`.