Message ID | 20200226124705.29212-9-jgross@suse.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Add hypervisor sysfs-like support | expand |
On 26.02.2020 13:47, Juergen Gross wrote: > Add the /buildinfo/config entry to the hypervisor filesystem. This > entry contains the .config file used to build the hypervisor. > > Signed-off-by: Juergen Gross <jgross@suse.com> > --- > V3: > - store data in gzip format > - use binfile mechanism to create data file > - move code to kernel.c > > V6: > - add config item for the /buildinfo/config (Jan Beulich) > - make config related variables const in kernel.h (Jan Beulich) > --- > .gitignore | 2 ++ > docs/misc/hypfs-paths.pandoc | 4 ++++ > xen/common/Kconfig | 10 ++++++++++ > xen/common/Makefile | 12 ++++++++++++ > xen/common/kernel.c | 15 +++++++++++++++ > xen/include/xen/kernel.h | 3 +++ > 6 files changed, 46 insertions(+) > > diff --git a/.gitignore b/.gitignore > index fd5610718d..bc8e053ccb 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -297,6 +297,8 @@ xen/arch/*/efi/boot.c > xen/arch/*/efi/compat.c > xen/arch/*/efi/efi.h > xen/arch/*/efi/runtime.c > +xen/common/config_data.S > +xen/common/config.gz > xen/include/headers*.chk > xen/include/asm > xen/include/asm-*/asm-offsets.h > diff --git a/docs/misc/hypfs-paths.pandoc b/docs/misc/hypfs-paths.pandoc > index e392feff27..1faebcccbc 100644 > --- a/docs/misc/hypfs-paths.pandoc > +++ b/docs/misc/hypfs-paths.pandoc > @@ -133,6 +133,10 @@ Information about the compile domain. > > The compiler used to build Xen. > > +#### /buildinfo/config = STRING > + > +The contents of the `xen/.config` file at the time of the hypervisor build. Perhaps add "..., if enabled at build time"? > --- a/xen/common/Makefile > +++ b/xen/common/Makefile > @@ -1,6 +1,7 @@ > obj-$(CONFIG_ARGO) += argo.o > obj-y += bitmap.o > obj-y += bsearch.o > +obj-$(CONFIG_HYPFS_CONFIG) += config_data.o > obj-$(CONFIG_CORE_PARKING) += core_parking.o > obj-y += cpu.o > obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o > @@ -73,3 +74,14 @@ subdir-$(CONFIG_UBSAN) += ubsan > > subdir-$(CONFIG_NEEDS_LIBELF) += libelf > subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt > + > +config.gz: ../.config I think this wants to use $(KCONFIG_CONFIG) now. > + gzip -c $< >$@ We'll want to make sure to switch this to $(if_changed ...) once available (by Anthony's series). > +config_data.o: config.gz Is this really needed? You need to add config.gz as a dependency ... > +config_data.S: $(XEN_ROOT)/xen/tools/binfile ... here anyway afaict, and then preferably use ... > + $(XEN_ROOT)/xen/tools/binfile $@ config.gz xen_config_data ... $< here. > +clean:: > + rm config_data.S config.gz 2>/dev/null || true Instead of the "|| true" elsewhere we use "rm -f". Jan
On 04.03.20 11:49, Jan Beulich wrote: > On 26.02.2020 13:47, Juergen Gross wrote: >> Add the /buildinfo/config entry to the hypervisor filesystem. This >> entry contains the .config file used to build the hypervisor. >> >> Signed-off-by: Juergen Gross <jgross@suse.com> >> --- >> V3: >> - store data in gzip format >> - use binfile mechanism to create data file >> - move code to kernel.c >> >> V6: >> - add config item for the /buildinfo/config (Jan Beulich) >> - make config related variables const in kernel.h (Jan Beulich) >> --- >> .gitignore | 2 ++ >> docs/misc/hypfs-paths.pandoc | 4 ++++ >> xen/common/Kconfig | 10 ++++++++++ >> xen/common/Makefile | 12 ++++++++++++ >> xen/common/kernel.c | 15 +++++++++++++++ >> xen/include/xen/kernel.h | 3 +++ >> 6 files changed, 46 insertions(+) >> >> diff --git a/.gitignore b/.gitignore >> index fd5610718d..bc8e053ccb 100644 >> --- a/.gitignore >> +++ b/.gitignore >> @@ -297,6 +297,8 @@ xen/arch/*/efi/boot.c >> xen/arch/*/efi/compat.c >> xen/arch/*/efi/efi.h >> xen/arch/*/efi/runtime.c >> +xen/common/config_data.S >> +xen/common/config.gz >> xen/include/headers*.chk >> xen/include/asm >> xen/include/asm-*/asm-offsets.h >> diff --git a/docs/misc/hypfs-paths.pandoc b/docs/misc/hypfs-paths.pandoc >> index e392feff27..1faebcccbc 100644 >> --- a/docs/misc/hypfs-paths.pandoc >> +++ b/docs/misc/hypfs-paths.pandoc >> @@ -133,6 +133,10 @@ Information about the compile domain. >> >> The compiler used to build Xen. >> >> +#### /buildinfo/config = STRING >> + >> +The contents of the `xen/.config` file at the time of the hypervisor build. > > Perhaps add "..., if enabled at build time"? Yes. > >> --- a/xen/common/Makefile >> +++ b/xen/common/Makefile >> @@ -1,6 +1,7 @@ >> obj-$(CONFIG_ARGO) += argo.o >> obj-y += bitmap.o >> obj-y += bsearch.o >> +obj-$(CONFIG_HYPFS_CONFIG) += config_data.o >> obj-$(CONFIG_CORE_PARKING) += core_parking.o >> obj-y += cpu.o >> obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o >> @@ -73,3 +74,14 @@ subdir-$(CONFIG_UBSAN) += ubsan >> >> subdir-$(CONFIG_NEEDS_LIBELF) += libelf >> subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt >> + >> +config.gz: ../.config > > I think this wants to use $(KCONFIG_CONFIG) now. Okay. > >> + gzip -c $< >$@ > > We'll want to make sure to switch this to $(if_changed ...) once > available (by Anthony's series). Yes. > >> +config_data.o: config.gz > > Is this really needed? You need to add config.gz as a > dependency ... > >> +config_data.S: $(XEN_ROOT)/xen/tools/binfile > > ... here anyway afaict, and then preferably use ... Why? config_data.S will look always the same, even if config.gz has changed. It is just the name of the file which will be put into the generated source, not its contents. Its the .o file which wants to be built again if config.gz changes, not the .S file. > >> + $(XEN_ROOT)/xen/tools/binfile $@ config.gz xen_config_data > > ... $< here. > >> +clean:: >> + rm config_data.S config.gz 2>/dev/null || true > > Instead of the "|| true" elsewhere we use "rm -f". Okay. Juergen
On 04.03.2020 13:06, Jürgen Groß wrote: > On 04.03.20 11:49, Jan Beulich wrote: >> On 26.02.2020 13:47, Juergen Gross wrote: >>> +config_data.o: config.gz >> >> Is this really needed? You need to add config.gz as a >> dependency ... >> >>> +config_data.S: $(XEN_ROOT)/xen/tools/binfile >> >> ... here anyway afaict, and then preferably use ... > > Why? config_data.S will look always the same, even if config.gz has > changed. It is just the name of the file which will be put into the > generated source, not its contents. Its the .o file which wants to > be built again if config.gz changes, not the .S file. Oh, right, I forgot this uses the .include directive. Jan
diff --git a/.gitignore b/.gitignore index fd5610718d..bc8e053ccb 100644 --- a/.gitignore +++ b/.gitignore @@ -297,6 +297,8 @@ xen/arch/*/efi/boot.c xen/arch/*/efi/compat.c xen/arch/*/efi/efi.h xen/arch/*/efi/runtime.c +xen/common/config_data.S +xen/common/config.gz xen/include/headers*.chk xen/include/asm xen/include/asm-*/asm-offsets.h diff --git a/docs/misc/hypfs-paths.pandoc b/docs/misc/hypfs-paths.pandoc index e392feff27..1faebcccbc 100644 --- a/docs/misc/hypfs-paths.pandoc +++ b/docs/misc/hypfs-paths.pandoc @@ -133,6 +133,10 @@ Information about the compile domain. The compiler used to build Xen. +#### /buildinfo/config = STRING + +The contents of the `xen/.config` file at the time of the hypervisor build. + #### /buildinfo/version/ A directory containing version information of the hypervisor. diff --git a/xen/common/Kconfig b/xen/common/Kconfig index a6914fcae9..c3303c8dfe 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -353,6 +353,16 @@ config DOM0_MEM Leave empty if you are not sure what to specify. +config HYPFS_CONFIG + bool "Provide hypervisor .config via hypfs entry" + default y + ---help--- + When enabled the contents of the .config file used to build the + hypervisor are provided via the hypfs entry /buildinfo/config. + + Disable this option in case you want to spare some memory or you + want to hide the .config contents from dom0. + config TRACEBUFFER bool "Enable tracing infrastructure" if EXPERT = "y" default y diff --git a/xen/common/Makefile b/xen/common/Makefile index 3a2c1ae690..100babc446 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -1,6 +1,7 @@ obj-$(CONFIG_ARGO) += argo.o obj-y += bitmap.o obj-y += bsearch.o +obj-$(CONFIG_HYPFS_CONFIG) += config_data.o obj-$(CONFIG_CORE_PARKING) += core_parking.o obj-y += cpu.o obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o @@ -73,3 +74,14 @@ subdir-$(CONFIG_UBSAN) += ubsan subdir-$(CONFIG_NEEDS_LIBELF) += libelf subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt + +config.gz: ../.config + gzip -c $< >$@ + +config_data.o: config.gz + +config_data.S: $(XEN_ROOT)/xen/tools/binfile + $(XEN_ROOT)/xen/tools/binfile $@ config.gz xen_config_data + +clean:: + rm config_data.S config.gz 2>/dev/null || true diff --git a/xen/common/kernel.c b/xen/common/kernel.c index da6e4b4444..4b7bc28afb 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -389,6 +389,16 @@ static HYPFS_STRING_INIT(compile_date, "compile_date"); static HYPFS_STRING_INIT(compile_domain, "compile_domain"); static HYPFS_STRING_INIT(extra, "extra"); +#ifdef CONFIG_HYPFS_CONFIG +static struct hypfs_entry_leaf config = { + .e.type = XEN_HYPFS_TYPE_STRING, + .e.encoding = XEN_HYPFS_ENC_GZIP, + .e.name = "config", + .e.read = hypfs_read_leaf, + .content = &xen_config_data +}; +#endif + static int __init buildinfo_init(void) { hypfs_add_dir(&hypfs_root, &buildinfo, true); @@ -414,6 +424,11 @@ static int __init buildinfo_init(void) hypfs_add_leaf(&version, &major, true); hypfs_add_leaf(&version, &minor, true); +#ifdef CONFIG_HYPFS_CONFIG + config.e.size = xen_config_data_size; + hypfs_add_leaf(&buildinfo, &config, true); +#endif + return 0; } __initcall(buildinfo_init); diff --git a/xen/include/xen/kernel.h b/xen/include/xen/kernel.h index 548b64da9f..02e3281f52 100644 --- a/xen/include/xen/kernel.h +++ b/xen/include/xen/kernel.h @@ -100,5 +100,8 @@ extern enum system_state { bool_t is_active_kernel_text(unsigned long addr); +extern const char xen_config_data; +extern const unsigned int xen_config_data_size; + #endif /* _LINUX_KERNEL_H */
Add the /buildinfo/config entry to the hypervisor filesystem. This entry contains the .config file used to build the hypervisor. Signed-off-by: Juergen Gross <jgross@suse.com> --- V3: - store data in gzip format - use binfile mechanism to create data file - move code to kernel.c V6: - add config item for the /buildinfo/config (Jan Beulich) - make config related variables const in kernel.h (Jan Beulich) --- .gitignore | 2 ++ docs/misc/hypfs-paths.pandoc | 4 ++++ xen/common/Kconfig | 10 ++++++++++ xen/common/Makefile | 12 ++++++++++++ xen/common/kernel.c | 15 +++++++++++++++ xen/include/xen/kernel.h | 3 +++ 6 files changed, 46 insertions(+)