diff --git a/projects/kernel-config/Dockerfile b/projects/kernel-config/Dockerfile index 346a29443..e6f8a6d70 100644 --- a/projects/kernel-config/Dockerfile +++ b/projects/kernel-config/Dockerfile @@ -23,7 +23,14 @@ RUN set -e && for patch in /patches/*.patch; do \ patch -p1 < "$patch"; \ done -RUN /config/makeconfig.sh ${ARCH} ${KERNEL_SERIES} +RUN \ + if [ -n "${DEBUG}" ]; then dbg=kernel_config.debug; else dbg=; fi && \ + /config/makeconfig.sh \ + kernel_config.base \ + "kernel_config.${ARCH}" \ + "kernel_config.${ARCH}.${KERNEL_SERIES}" \ + "kernel_config.${KERNEL_SERIES}" \ + "$dbg" RUN /config/check-kernel-config.sh /linux/.config RUN mkdir /out diff --git a/projects/kernel-config/Makefile b/projects/kernel-config/Makefile index a06c6be66..710c72007 100644 --- a/projects/kernel-config/Makefile +++ b/projects/kernel-config/Makefile @@ -12,7 +12,7 @@ HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}') # Name on Hub IMAGE:=kernel -ARCH?=$(shell if [ "$$(arch)" = "x86_64" ]]; then echo x86; else $$(arch); fi) +ARCH?=x86_64 .PHONY: check tag push sign # Targets: diff --git a/projects/kernel-config/README.md b/projects/kernel-config/README.md new file mode 100644 index 000000000..84b5567b2 --- /dev/null +++ b/projects/kernel-config/README.md @@ -0,0 +1,38 @@ +## kernel config project + +The intent of the kernel config project is to demonstrate a better way to +handle kernel config. Specifically: + +* support for arch and version specific config +* make diffs as readable as possible +* ensure that all of our config settings are kept after oldconfig + +We achieve the goals by: + +* having version-specific config in separate files, which are automatically + merged +* only keeping track of visible symbols, only keeping track of a delta from + defconfig, and keeping symbols sorted alphabetically +* checking after a `make oldconfig` in the kernel, that all of our symbols are + set as we want them to be + +The bulk of this work happens in makeconfig.sh, which merges the configs (and +checks that the resulting config is okay). + +One important piece is generating a kernel config for a new version. There are +a few cases: + +* A new kconfig symbol is introduced that we want to set a non-default value + of: in this case, we introduce a new `kernel_config.${VERSION}` file, and set + the value to what we want to set it to +* A config symbol that was no-default before become the default: in this case, + we would move the non-default setting to version specific files for all of + the other versions, and not set anything for this new kernel, since what we + want is now the default. +* A symbol we want to set is removed (or renamed), similar to the above, we + simply move the old symbol name to version specific files for older kernels + and put the new symbol name (if it exists) in the new version specific file + +When dropping support for an old kernel version, we just delete that version +specific file, and promote any option that is present in all other versions to +the common config file. diff --git a/projects/kernel-config/kernel_config.debug b/projects/kernel-config/kernel_config.debug index 00e73d577..7149bb31f 100644 --- a/projects/kernel-config/kernel_config.debug +++ b/projects/kernel-config/kernel_config.debug @@ -24,3 +24,4 @@ CONFIG_KGDB_SERIAL_CONSOLE=y CONFIG_KGDBOC=y CONFIG_DEBUG_RODATA_TEST=y CONFIG_DEBUG_WX=y +# CONFIG_PANIC_ON_OOPS is not set diff --git a/projects/kernel-config/kernel_config.x86 b/projects/kernel-config/kernel_config.x86_64 similarity index 100% rename from projects/kernel-config/kernel_config.x86 rename to projects/kernel-config/kernel_config.x86_64 diff --git a/projects/kernel-config/kernel_config.x86.4.10.x b/projects/kernel-config/kernel_config.x86_64.4.10.x similarity index 100% rename from projects/kernel-config/kernel_config.x86.4.10.x rename to projects/kernel-config/kernel_config.x86_64.4.10.x diff --git a/projects/kernel-config/kernel_config.x86.4.9.x b/projects/kernel-config/kernel_config.x86_64.4.9.x similarity index 100% rename from projects/kernel-config/kernel_config.x86.4.9.x rename to projects/kernel-config/kernel_config.x86_64.4.9.x diff --git a/projects/kernel-config/makeconfig.sh b/projects/kernel-config/makeconfig.sh index 98e675133..671d15a08 100755 --- a/projects/kernel-config/makeconfig.sh +++ b/projects/kernel-config/makeconfig.sh @@ -2,10 +2,6 @@ set -e -ARCH=$1 -KERNEL_SERIES=$2 -DEBUG=$3 - cd /linux && make defconfig function merge_config() @@ -32,15 +28,9 @@ function merge_config() cd /linux && make defconfig && make oldconfig -merge_config "/config/kernel_config.base" -merge_config "/config/kernel_config.${ARCH}" -merge_config "/config/kernel_config.${KERNEL_SERIES}" -merge_config "/config/kernel_config.${ARCH}.${KERNEL_SERIES}" - -if [ -n "${DEBUG}" ]; then - sed -i sed -i 's/CONFIG_PANIC_ON_OOPS=y/# CONFIG_PANIC_ON_OOPS is not set/' /linux/arch/x86/configs/x86_64_defconfig - append_config "/config/kernel_config.debug" -fi +for config in "$@"; do + merge_config "$config" +done cd /linux && make oldconfig @@ -51,7 +41,9 @@ function check_config() if [ ! -f "$1" ]; then return; fi while read line; do - if [ -n "${DEBUG}" ] && [ "$line" == "CONFIG_PANIC_ON_OOPS=y" ]; then continue; fi + # CONFIG_PANIC_ON_OOPS is special, and set both ways, depending on + # whether DEBUG is set or not. + if [ "$line" == *"CONFIG_PANIC_ON_OOPS"* ]; then continue; fi value="$(grep "^${line}$" /linux/.config || true)" # It's okay to for the merging script to have simply not listed values we @@ -67,10 +59,6 @@ function check_config() done < $1 } -check_config "/config/kernel_config.base" -check_config "/config/kernel_config.${ARCH}" -check_config "/config/kernel_config.${KERNEL_SERIES}" -check_config "/config/kernel_config.${ARCH}.${KERNEL_SERIES}" -if [ -n "${DEBUG}" ]; then - check_config "/config/kernel_config.debug" -fi +for config in "$@"; do + check_config "$config" +done