Re: [PATCH v10 08/12] xen: add /buildinfo/config entry to hypervisor filesystem

2020-06-02 Thread Jürgen Groß

On 02.06.20 11:03, Andrew Cooper wrote:

On 19/05/2020 08:21, Juergen Gross wrote:

diff --git a/xen/common/Makefile b/xen/common/Makefile
index bf7d0e25a3..3d61239fbf 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 @@ obj-$(CONFIG_UBSAN) += ubsan/
  
  obj-$(CONFIG_NEEDS_LIBELF) += libelf/

  obj-$(CONFIG_HAS_DEVICE_TREE) += libfdt/
+
+config.gz: ../.config
+   gzip -c $< >$@


I had to disable HYPFS in the XenServer build.  Inside RPM, this fails with


Disabling CONFIG_HYPFS_CONFIG should work, too.



make[3]: *** No rule to make target `../.config', needed by
`config.gz'.  Stop.
make[3]: *** Waiting for unfinished jobs

This needs to be an expression involving $(KCONFIG_CONFIG) because
.config is only the default, and it surely needs a $(XEN_ROOT) in there?

Will send a patch.

Oh, in fact I'll send two patches, as I guess pv-shim doesn't want to
have CONFIG_HYPFS set.


Juergen



Re: [PATCH v10 08/12] xen: add /buildinfo/config entry to hypervisor filesystem

2020-06-02 Thread Andrew Cooper
On 19/05/2020 08:21, Juergen Gross wrote:
> diff --git a/xen/common/Makefile b/xen/common/Makefile
> index bf7d0e25a3..3d61239fbf 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 @@ obj-$(CONFIG_UBSAN) += ubsan/
>  
>  obj-$(CONFIG_NEEDS_LIBELF) += libelf/
>  obj-$(CONFIG_HAS_DEVICE_TREE) += libfdt/
> +
> +config.gz: ../.config
> + gzip -c $< >$@

I had to disable HYPFS in the XenServer build.  Inside RPM, this fails with

make[3]: *** No rule to make target `../.config', needed by
`config.gz'.  Stop.
make[3]: *** Waiting for unfinished jobs

This needs to be an expression involving $(KCONFIG_CONFIG) because
.config is only the default, and it surely needs a $(XEN_ROOT) in there?

~Andrew



[PATCH v10 08/12] xen: add /buildinfo/config entry to hypervisor filesystem

2020-05-19 Thread Juergen Gross
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 
Reviewed-by: Jan Beulich 
---
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)

V7:
- update doc (Jan Beulich)
- use "rm -f" in Makefile (Jan Beulich)

V8:
- add dependency top CONFIG_HYPFS
- use macro for definition of leaf (Jan Beulich)

V9:
- adjust type of xen_config_data (Jan Beulich)

Signed-off-by: Juergen Gross 
---
 .gitignore   |  2 ++
 docs/misc/hypfs-paths.pandoc |  4 
 xen/common/Kconfig   | 11 +++
 xen/common/Makefile  | 12 
 xen/common/kernel.c  | 11 +++
 xen/include/xen/kernel.h |  3 +++
 6 files changed, 43 insertions(+)

diff --git a/.gitignore b/.gitignore
index 6171b3b43f..b8bdb25040 100644
--- a/.gitignore
+++ b/.gitignore
@@ -298,6 +298,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 d730caf394..9a76bc383b 100644
--- a/docs/misc/hypfs-paths.pandoc
+++ b/docs/misc/hypfs-paths.pandoc
@@ -135,6 +135,10 @@ Information about the compile domain.
 
 The compiler used to build Xen.
 
+ /buildinfo/config = STRING [CONFIG_HYPFS_CONFIG]
+
+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 e768ea36b2..065f2ee454 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -127,6 +127,17 @@ config HYPFS
 
  If unsure, say Y.
 
+config HYPFS_CONFIG
+   bool "Provide hypervisor .config via hypfs entry"
+   default y
+   depends on HYPFS
+   ---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 KEXEC
bool "kexec support"
default y
diff --git a/xen/common/Makefile b/xen/common/Makefile
index bf7d0e25a3..3d61239fbf 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 @@ obj-$(CONFIG_UBSAN) += ubsan/
 
 obj-$(CONFIG_NEEDS_LIBELF) += libelf/
 obj-$(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 -f config_data.S config.gz 2>/dev/null
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index db7bd23fcb..f464fe02ed 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -390,6 +390,10 @@ 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 HYPFS_STRING_INIT(config, "config");
+#endif
+
 static int __init buildinfo_init(void)
 {
 hypfs_add_dir(_root, , true);
@@ -415,6 +419,13 @@ static int __init buildinfo_init(void)
 hypfs_add_leaf(, , true);
 hypfs_add_leaf(, , true);
 
+#ifdef CONFIG_HYPFS_CONFIG
+config.e.encoding = XEN_HYPFS_ENC_GZIP;
+config.e.size = xen_config_data_size;
+config.content = xen_config_data;
+hypfs_add_leaf(, , true);
+#endif
+
 return 0;
 }
 __initcall(buildinfo_init);
diff --git a/xen/include/xen/kernel.h b/xen/include/xen/kernel.h
index 548b64da9f..8cd142032d 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 */
 
-- 
2.26.1