From cc7d80be13929fa0e146848e813837e339d5891f Mon Sep 17 00:00:00 2001 From: Riyaz Faizullabhoy Date: Tue, 21 Mar 2017 09:59:40 -0700 Subject: [PATCH] wireguard: include Dockerfile and kernel debug config for build Signed-off-by: Riyaz Faizullabhoy --- .../wireguard/kernel-wireguard/Dockerfile | 53 +++++++++++++++++++ .../kernel-wireguard/kernel_config.debug | 26 +++++++++ 2 files changed, 79 insertions(+) create mode 100644 projects/wireguard/kernel-wireguard/Dockerfile create mode 100644 projects/wireguard/kernel-wireguard/kernel_config.debug diff --git a/projects/wireguard/kernel-wireguard/Dockerfile b/projects/wireguard/kernel-wireguard/Dockerfile new file mode 100644 index 000000000..3372f38e6 --- /dev/null +++ b/projects/wireguard/kernel-wireguard/Dockerfile @@ -0,0 +1,53 @@ +FROM mobylinux/alpine-build-kernel:0e893fbf6fa7638d2f23354de03ea11017bb8065@sha256:3ef3f9d11f0802b759dbd9c43a7706cf0ec37263c99ae90e2b10c29ea85739fa + +ARG KERNEL_VERSION +ARG DEBUG=0 + +ENV KERNEL_SOURCE=https://www.kernel.org/pub/linux/kernel/v4.x/linux-${KERNEL_VERSION}.tar.xz + +RUN curl -fsSL -o linux-${KERNEL_VERSION}.tar.xz ${KERNEL_SOURCE} + +RUN cat linux-${KERNEL_VERSION}.tar.xz | tar --absolute-names -xJ && mv /linux-${KERNEL_VERSION} /linux + +COPY kernel_config /linux/arch/x86/configs/x86_64_defconfig +COPY kernel_config.debug /linux/debug_config + +RUN if [ $DEBUG -ne "0" ]; then \ + sed -i 's/CONFIG_PANIC_ON_OOPS=y/# CONFIG_PANIC_ON_OOPS is not set/' /linux/arch/x86/configs/x86_64_defconfig; \ + cat /linux/debug_config >> /linux/arch/x86/configs/x86_64_defconfig; \ + fi + +# Apply local patches +COPY patches-4.9 /patches +RUN cd /linux && \ + set -e && for patch in /patches/*.patch; do \ + echo "Applying $patch"; \ + patch -p1 < "$patch"; \ + done + +RUN cd /linux && \ + make defconfig && \ + make oldconfig && \ + make -j "$(getconf _NPROCESSORS_ONLN)" KCFLAGS="-fno-pie" +RUN cd /linux && \ + make INSTALL_MOD_PATH=/tmp/kernel-modules modules_install && \ + ( DVER=$(basename $(find /tmp/kernel-modules/lib/modules/ -mindepth 1 -maxdepth 1)) && \ + cd /tmp/kernel-modules/lib/modules/$DVER && \ + rm build source && \ + ln -s /usr/src/linux-headers-$DVER build ) && \ + mkdir -p /tmp/kernel-headers/usr && \ + make INSTALL_HDR_PATH=/tmp/kernel-headers/usr headers_install && \ + ( cd /tmp/kernel-headers && tar cf /kernel-headers.tar usr ) && \ + ( cd /tmp/kernel-modules && tar cf /kernel-modules.tar lib ) && \ + cp vmlinux arch/x86_64/boot/bzImage / + +RUN DVER=$(basename $(find /tmp/kernel-modules/lib/modules/ -mindepth 1 -maxdepth 1)) && \ + dir=/tmp/usr/src/linux-headers-$DVER && \ + mkdir -p $dir && \ + cp /linux/.config $dir && \ + cd /linux && \ + cp -a include "$dir" && \ + mkdir -p "$dir"/arch/x86 && cp -a arch/x86/include "$dir"/arch/x86/ && \ + ( cd /tmp && tar cf /kernel-dev.tar usr/src ) + +RUN printf "KERNEL_SOURCE=${KERNEL_SOURCE}\n" > /kernel-source-info diff --git a/projects/wireguard/kernel-wireguard/kernel_config.debug b/projects/wireguard/kernel-wireguard/kernel_config.debug new file mode 100644 index 000000000..17b14daca --- /dev/null +++ b/projects/wireguard/kernel-wireguard/kernel_config.debug @@ -0,0 +1,26 @@ + + +## MOBY DEBUG OPTIONS ## + +CONFIG_LOCKDEP=y +CONFIG_FRAME_POINTER=y +CONFIG_LOCKUP_DETECTOR=y +CONFIG_DETECT_HUNG_TASK=y +CONFIG_DEBUG_TIMEKEEPING=y +CONFIG_DEBUG_RT_MUTEXES=y +CONFIG_DEBUG_SPINLOCK=y +CONFIG_DEBUG_MUTEXES=y +CONFIG_DEBUG_WW_MUTEX_SLOWPATH=y +CONFIG_DEBUG_LOCK_ALLOC=y +CONFIG_PROVE_LOCKING=y +CONFIG_LOCK_STAT=y +CONFIG_DEBUG_ATOMIC_SLEEP=y +CONFIG_DEBUG_LIST=y +CONFIG_DEBUG_NOTIFIERS=y +CONFIG_PROVE_RCU=y +CONFIG_RCU_TRACE=y +CONFIG_KGDB=y +CONFIG_KGDB_SERIAL_CONSOLE=y +CONFIG_KGDBOC=y +CONFIG_DEBUG_RODATA_TEST=y +CONFIG_DEBUG_WX=y