Extract configuration from kernel
Subsystems (9)
PATCH 1/1 Extract configuration from kernel
I am including a patch for 2.5.50 that allows a user to embed kernel configuration in the kernel and retrieve it later either from a running kernel or from the kernel image file. This is an enhancement to Randy's patch that was discussed on LKML before and is part of -ac series kernels.
This patch provides three choices for embedding kernel configuration:
1. Include configuration in running kernel image. This adds to the footprint of the running kernel but allows configuration to be retrieved using "cat /proc/ikconfig/config".
2. Include configuration in kernel image file but not in the running kernel. This adds to the kernel image file size but not the footprint of running kernel. Configuration can be extracted from kernel image file using scripts/extract-ikconfig. This script is in principle the same as what Randy had written originally. I have made it little more robust and structured it to accomodate more than just x86 architecture.
3. Not include kernel configuration in the running kernel or kernel image file.
With these three choices, users can make the appropriate tradeoff. This feature is especially useful for support folks who need to know the kernel configuration for a customer's kernel with fairly high degree of confidence that they are getting the right configuration. This feature is turned off in the default configuration.
Linus, please apply.
--
Khalid
====================================================================
Khalid Aziz Linux and Open Source Lab
(970)898-9214 Hewlett-Packard
[email protected] Fort Collins, CO
---------CUT HERE-------------CUT HERE--------------CUT HERE-----------------
arch/alpha/defconfig +2 -0
@@ -19,6 +19,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/arm/defconfig +2 -0
@@ -80,6 +80,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_NWFPE=y CONFIG_KCORE_ELF=y # CONFIG_KCORE_AOUT is not set
arch/cris/defconfig +2 -0
@@ -17,6 +17,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set # CONFIG_SYSCTL is not set +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_BINFMT_ELF=y # CONFIG_ETRAX_KGDB is not set # CONFIG_ETRAX_WATCHDOG is not set
arch/i386/defconfig +2 -0
@@ -19,6 +19,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/ia64/defconfig +2 -0
@@ -14,6 +14,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/m68k/defconfig +2 -0
@@ -42,6 +42,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_KCORE_ELF=y # CONFIG_KCORE_AOUT is not set CONFIG_BINFMT_AOUT=y
arch/mips/defconfig +2 -0
@@ -93,6 +93,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Memory Technology Devices (MTD)
arch/mips64/defconfig +3 -0
@@ -56,6 +56,9 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set + CONFIG_BINFMT_ELF=y CONFIG_MIPS32_COMPAT=y CONFIG_BINFMT_ELF32=y
arch/ppc/defconfig +2 -0
@@ -64,6 +64,8 @@ CONFIG_PCI=y CONFIG_NET=y CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_KCORE_ELF=y
arch/ppc64/defconfig +2 -0
@@ -20,6 +20,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/s390/defconfig +2 -0
@@ -20,6 +20,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/s390x/defconfig +2 -0
@@ -20,6 +20,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/sh/defconfig +2 -0
@@ -45,6 +45,8 @@ # CONFIG_SYSVIPC is not set # CONFIG_BSD_PROCESS_ACCT is not set # CONFIG_SYSCTL is not set +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_KCORE_ELF=y # CONFIG_KCORE_AOUT is not set CONFIG_BINFMT_ELF=y
arch/sparc/defconfig +2 -0
@@ -17,6 +17,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/sparc64/defconfig +2 -0
@@ -14,6 +14,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/um/defconfig +2 -0
@@ -20,6 +20,8 @@ CONFIG_SYSVIPC=y CONFIG_BSD_PROCESS_ACCT=y CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_BINFMT_AOUT=y CONFIG_BINFMT_ELF=y CONFIG_BINFMT_MISC=y
arch/x86_64/defconfig +2 -0
@@ -24,6 +24,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
init/Kconfig +25 -0
@@ -98,6 +98,31 @@ building a kernel for install/rescue disks or your system is very limited in memory. +config IKCONFIG + bool "Kernel .config support" + ---help--- + This option enables the complete Linux kernel ".config" file + contents, information on compiler used to build the kernel, + kernel running when this kernel was built and kernel version + from Makefile to be saved in kernel. It provides documentation + of which kernel options are used in a running kernel or in an + on-disk kernel. This information can be extracted from the kernel + image file with the script scripts/extract-ikconfig and used as + input to rebuild the current kernel or to build another kernel. + It can also be extracted from a running kernel by reading + /proc/ikconfig/config and /proc/ikconfig/built_with, if enabled. + /proc/ikconfig/config will list the configuration that was used + to build the kernel and /proc/ikconfig/built_with will list + information on the compiler and host machine that was used to + build the kernel. + +config IKCONFIG_PROC + bool "Enable access to .config through /proc/ikconfig" + depends on IKCONFIG + ---help--- + This option enables access to kernel configuration file and build + information through /proc/ikconfig. + endmenu
kernel/Makefile +12 -0
@@ -21,6 +21,11 @@ obj-$(CONFIG_CPU_FREQ) += cpufreq.o obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend.o +obj-$(CONFIG_IKCONFIG) += configs.o + +# files to be removed upon make clean +clean-files := ikconfig.h + ifneq ($(CONFIG_IA64),y) # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
@@ -32,3 +37,10 @@ endif include $(TOPDIR)/Rules.make + +$(obj)/ikconfig.h: $(TOPDIR)/scripts/mkconfigs $(TOPDIR)/.config $(TOPDIR)/Makefile + $(CONFIG_SHELL) $(TOPDIR)/scripts/mkconfigs $(TOPDIR)/.config $(TOPDIR)/Makefile > $(obj)/ikconfig.h + +$(obj)/configs.o: $(obj)/ikconfig.h $(obj)/configs.c \ + $(TOPDIR)/include/linux/version.h \ + $(TOPDIR)/include/linux/compile.h
kernel/configs.c +206 -0
206 lines not on this page · raw message
scripts/extract-ikconfig +101 -0
101 lines not on this page · raw message
scripts/mkconfigs +81 -0
81 lines not on this page · raw message
In article <[email protected]>,
Khalid Aziz <[email protected]> wrote:
| I am including a patch for 2.5.50 that allows a user to embed kernel | configuration in the kernel and retrieve it later either from a running | kernel or from the kernel image file. This is an enhancement to Randy's | patch that was discussed on LKML before and is part of -ac series | kernels. | | This patch provides three choices for embedding kernel configuration: | | 1. Include configuration in running kernel image. This adds to the | footprint of the running kernel but allows configuration to be retrieved | using "cat /proc/ikconfig/config". | | 2. Include configuration in kernel image file but not in the running | kernel. This adds to the kernel image file size but not the footprint of | running kernel. Configuration can be extracted from kernel image file | using scripts/extract-ikconfig. This script is in principle the same as | what Randy had written originally. I have made it little more robust and | structured it to accomodate more than just x86 architecture. | | 3. Not include kernel configuration in the running kernel or kernel | image file.
I would suggest that making (2) available as a module would be useful, assuming that at some point 2.5 will have working module capability again. With a bit of tweaking you could make the kernel loader pull it in if a process accessed the file, I guess.
Signature · 3 lines
bill davidsen <[email protected]> CTO, TMR Associates, Inc Doing interesting things with little computers since 1979.
Quoted 8 lines · bill davidsen
| 2. Include configuration in kernel image file but not in the running | kernel. This adds to the kernel image file size but not the footprint of | running kernel. Configuration can be extracted from kernel image file | using scripts/extract-ikconfig. This script is in principle the same as | what Randy had written originally. I have made it little more robust and | structured it to accomodate more than just x86 architecture.
Quoted 4 lines
I would suggest that making (2) available as a module would be useful, assuming that at some point 2.5 will have working module capability again. With a bit of tweaking you could make the kernel loader pull it in if a process accessed the file, I guess.
It is trivial to make (2) available as a module but it has been debated that having configuration information available as module does not make the job of keeping a reliable source of kernel configuration any easier than just keeping a copy of config file in, say, /lib/modules directory. If you can ensure you always have the right module file available for the running kernel, you can also ensure you always have the right config file available for the kernel.
--
Khalid
====================================================================
Khalid Aziz Linux and Open Source Lab
(970)898-9214 Hewlett-Packard
[email protected] Fort Collins, CO
"The Linux kernel is subject to relentless development"
- Alessandro Rubini
Quoted 14 lines · Khalid Aziz
Quoted 8 lines · bill davidsen
| 2. Include configuration in kernel image file but not in the running | kernel. This adds to the kernel image file size but not the footprint of | running kernel. Configuration can be extracted from kernel image file | using scripts/extract-ikconfig. This script is in principle the same as | what Randy had written originally. I have made it little more robust and | structured it to accomodate more than just x86 architecture.Quoted 4 lines
I would suggest that making (2) available as a module would be useful, assuming that at some point 2.5 will have working module capability again. With a bit of tweaking you could make the kernel loader pull it in if a process accessed the file, I guess.
Quoted 7 lines
It is trivial to make (2) available as a module but it has been debated that having configuration information available as module does not make the job of keeping a reliable source of kernel configuration any easier than just keeping a copy of config file in, say,
/lib/modulesdirectory. If you can ensure you always have the right module file available for the running kernel, you can also ensure you always have the right config file available for the kernel.
All true, I just find having the config in the same location for all kernels (in say /proc/config) is more convenient than having to resolve the kernel name from another file or do /lib/modules/$(uname -r)/config from a script. The kernel knows who it is, all others have to ask. It's just one less step a program would have to take, not a major problem.
Signature · 3 lines
bill davidsen <[email protected]> CTO, TMR Associates, Inc Doing interesting things with little computers since 1979.