diff mbox series

[v3,7/9] xen: provide version information in hypfs

Message ID 20200121084330.18309-8-jgross@suse.com (mailing list archive)
State Superseded
Headers show
Series Add hypervisor sysfs-like support | expand

Commit Message

Jürgen Groß Jan. 21, 2020, 8:43 a.m. UTC
Provide version and compile information in /buildinfo/ node of the
Xen hypervisor file system. As this information is accessible by dom0
only no additional security problem arises.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- new patch
---
 docs/misc/hypfs-paths.pandoc | 45 ++++++++++++++++++++++++++++++++++++++++++++
 xen/common/kernel.c          | 45 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)

Comments

Jan Beulich Feb. 3, 2020, 5:02 p.m. UTC | #1
On 21.01.2020 09:43, Juergen Gross wrote:
> Provide version and compile information in /buildinfo/ node of the
> Xen hypervisor file system. As this information is accessible by dom0
> only no additional security problem arises.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
with on suggestion:

> @@ -373,6 +374,50 @@ void __init do_initcalls(void)
>          (*call)();
>  }
>  
> +static unsigned int major_version;
> +static unsigned int minor_version;
> +
> +static HYPFS_DIR_INIT(buildinfo, "buildinfo");
> +static HYPFS_DIR_INIT(compileinfo, "compileinfo");
> +static HYPFS_DIR_INIT(version, "version");
> +static HYPFS_UINT_INIT(major, "major", major_version);
> +static HYPFS_UINT_INIT(minor, "minor", minor_version);
> +static HYPFS_STRING_INIT(changeset, "changeset");
> +static HYPFS_STRING_INIT(compiler, "compiler");
> +static HYPFS_STRING_INIT(compile_by, "compile_by");
> +static HYPFS_STRING_INIT(compile_date, "compile_date");
> +static HYPFS_STRING_INIT(compile_domain, "compile_domain");
> +static HYPFS_STRING_INIT(extra, "extra");

Please consider making all of the above __read_mostly.

Jan
Jürgen Groß Feb. 4, 2020, 6:44 a.m. UTC | #2
On 03.02.20 18:02, Jan Beulich wrote:
> On 21.01.2020 09:43, Juergen Gross wrote:
>> Provide version and compile information in /buildinfo/ node of the
>> Xen hypervisor file system. As this information is accessible by dom0
>> only no additional security problem arises.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> with on suggestion:
> 
>> @@ -373,6 +374,50 @@ void __init do_initcalls(void)
>>           (*call)();
>>   }
>>   
>> +static unsigned int major_version;
>> +static unsigned int minor_version;
>> +
>> +static HYPFS_DIR_INIT(buildinfo, "buildinfo");
>> +static HYPFS_DIR_INIT(compileinfo, "compileinfo");
>> +static HYPFS_DIR_INIT(version, "version");
>> +static HYPFS_UINT_INIT(major, "major", major_version);
>> +static HYPFS_UINT_INIT(minor, "minor", minor_version);
>> +static HYPFS_STRING_INIT(changeset, "changeset");
>> +static HYPFS_STRING_INIT(compiler, "compiler");
>> +static HYPFS_STRING_INIT(compile_by, "compile_by");
>> +static HYPFS_STRING_INIT(compile_date, "compile_date");
>> +static HYPFS_STRING_INIT(compile_domain, "compile_domain");
>> +static HYPFS_STRING_INIT(extra, "extra");
> 
> Please consider making all of the above __read_mostly.

Okay.


Juergen
diff mbox series

Patch

diff --git a/docs/misc/hypfs-paths.pandoc b/docs/misc/hypfs-paths.pandoc
index 67de8d2cf8..1f63c5c13e 100644
--- a/docs/misc/hypfs-paths.pandoc
+++ b/docs/misc/hypfs-paths.pandoc
@@ -93,3 +93,48 @@  A populated Xen hypervisor file system might look like the following example:
 #### /
 
 The root of the hypervisor file system.
+
+#### /buildinfo/
+
+A directory containing static information generated while building the
+hypervisor.
+
+#### /buildinfo/changeset = STRING
+
+Git commit of the hypervisor.
+
+#### /buildinfo/compileinfo/
+
+A directory containing information about compilation of Xen.
+
+#### /buildinfo/compileinfo/compile_by = STRING
+
+Information who compiled the hypervisor.
+
+#### /buildinfo/compileinfo/compile_date = STRING
+
+Date of the hypervisor compilation.
+
+#### /buildinfo/compileinfo/compile_domain = STRING
+
+Information about the compile domain.
+
+#### /buildinfo/compileinfo/compiler = STRING
+
+The compiler used to build Xen.
+
+#### /buildinfo/version/
+
+A directory containing version information of the hypervisor.
+
+#### /buildinfo/version/extra = STRING
+
+Extra version information.
+
+#### /buildinfo/version/major = INTEGER
+
+The major version of Xen.
+
+#### /buildinfo/version/minor = INTEGER
+
+The minor version of Xen.
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 22941cec94..3186fd59c2 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -13,6 +13,7 @@ 
 #include <xen/paging.h>
 #include <xen/guest_access.h>
 #include <xen/hypercall.h>
+#include <xen/hypfs.h>
 #include <xsm/xsm.h>
 #include <asm/current.h>
 #include <public/version.h>
@@ -373,6 +374,50 @@  void __init do_initcalls(void)
         (*call)();
 }
 
+static unsigned int major_version;
+static unsigned int minor_version;
+
+static HYPFS_DIR_INIT(buildinfo, "buildinfo");
+static HYPFS_DIR_INIT(compileinfo, "compileinfo");
+static HYPFS_DIR_INIT(version, "version");
+static HYPFS_UINT_INIT(major, "major", major_version);
+static HYPFS_UINT_INIT(minor, "minor", minor_version);
+static HYPFS_STRING_INIT(changeset, "changeset");
+static HYPFS_STRING_INIT(compiler, "compiler");
+static HYPFS_STRING_INIT(compile_by, "compile_by");
+static HYPFS_STRING_INIT(compile_date, "compile_date");
+static HYPFS_STRING_INIT(compile_domain, "compile_domain");
+static HYPFS_STRING_INIT(extra, "extra");
+
+static int __init buildinfo_init(void)
+{
+    hypfs_add_dir(&hypfs_root, &buildinfo, true);
+
+    hypfs_string_set(&changeset, xen_changeset());
+    hypfs_add_leaf(&buildinfo, &changeset, true);
+
+    hypfs_add_dir(&buildinfo, &compileinfo, true);
+    hypfs_string_set(&compiler, xen_compiler());
+    hypfs_string_set(&compile_by, xen_compile_by());
+    hypfs_string_set(&compile_date, xen_compile_date());
+    hypfs_string_set(&compile_domain, xen_compile_domain());
+    hypfs_add_leaf(&compileinfo, &compiler, true);
+    hypfs_add_leaf(&compileinfo, &compile_by, true);
+    hypfs_add_leaf(&compileinfo, &compile_date, true);
+    hypfs_add_leaf(&compileinfo, &compile_domain, true);
+
+    major_version = xen_major_version();
+    minor_version = xen_minor_version();
+    hypfs_add_dir(&buildinfo, &version, true);
+    hypfs_string_set(&extra, xen_extra_version());
+    hypfs_add_leaf(&version, &extra, true);
+    hypfs_add_leaf(&version, &major, true);
+    hypfs_add_leaf(&version, &minor, true);
+
+    return 0;
+}
+__initcall(buildinfo_init);
+
 # define DO(fn) long do_##fn
 
 #endif