[PATCH v10 07/12] xen: provide version information in hypfs

Juergen Gross posted 12 patches 5 years, 8 months ago
Maintainers: Jan Beulich <jbeulich@suse.com>, "Roger Pau Monné" <roger.pau@citrix.com>, Kevin Tian <kevin.tian@intel.com>, Jun Nakajima <jun.nakajima@intel.com>, Andrew Cooper <andrew.cooper3@citrix.com>, Daniel De Graaf <dgdegra@tycho.nsa.gov>, Anthony PERARD <anthony.perard@citrix.com>, Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>, Wei Liu <wl@xen.org>, Ian Jackson <ian.jackson@eu.citrix.com>, Julien Grall <julien@xen.org>, Stefano Stabellini <sstabellini@kernel.org>, George Dunlap <george.dunlap@citrix.com>
[PATCH v10 07/12] xen: provide version information in hypfs
Posted by Juergen Gross 5 years, 8 months ago
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>
---
V3:
- new patch

V4:
- add __read_mostly annotations (Jan Beulich)

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

diff --git a/docs/misc/hypfs-paths.pandoc b/docs/misc/hypfs-paths.pandoc
index 39539fa1b5..d730caf394 100644
--- a/docs/misc/hypfs-paths.pandoc
+++ b/docs/misc/hypfs-paths.pandoc
@@ -105,3 +105,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 572e3fc07d..db7bd23fcb 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,52 @@ void __init do_initcalls(void)
         (*call)();
 }
 
+#ifdef CONFIG_HYPFS
+static unsigned int __read_mostly major_version;
+static unsigned int __read_mostly 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_reference(&changeset, xen_changeset());
+    hypfs_add_leaf(&buildinfo, &changeset, true);
+
+    hypfs_add_dir(&buildinfo, &compileinfo, true);
+    hypfs_string_set_reference(&compiler, xen_compiler());
+    hypfs_string_set_reference(&compile_by, xen_compile_by());
+    hypfs_string_set_reference(&compile_date, xen_compile_date());
+    hypfs_string_set_reference(&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_reference(&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);
+#endif
+
 # define DO(fn) long do_##fn
 
 #endif
-- 
2.26.1


Re: [PATCH v10 07/12] xen: provide version information in hypfs
Posted by Jan Beulich 5 years, 8 months ago
On 19.05.2020 09:21, Juergen Gross wrote:
> @@ -373,6 +374,52 @@ void __init do_initcalls(void)
>          (*call)();
>  }
>  
> +#ifdef CONFIG_HYPFS
> +static unsigned int __read_mostly major_version;
> +static unsigned int __read_mostly 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);

These two lines fail to build with gcc 4.1 ("unknown field 'content'
specified in initializer"), which I've deliberately tried as a last
minute post-commit, pre-push check. I therefore reverted this change
before pushing.

Paul, Jürgen - please advise how to proceed, considering today's
deadline. I'd accept pushing the rest of the series, if a fix for
the issue will then still be permitted in later. Otherwise I'd have
to wait for a fixed (incremental) version.

Jan

Re: [PATCH v10 07/12] xen: provide version information in hypfs
Posted by Jürgen Groß 5 years, 8 months ago
On 29.05.20 10:34, Jan Beulich wrote:
> On 19.05.2020 09:21, Juergen Gross wrote:
>> @@ -373,6 +374,52 @@ void __init do_initcalls(void)
>>           (*call)();
>>   }
>>   
>> +#ifdef CONFIG_HYPFS
>> +static unsigned int __read_mostly major_version;
>> +static unsigned int __read_mostly 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);
> 
> These two lines fail to build with gcc 4.1 ("unknown field 'content'
> specified in initializer"), which I've deliberately tried as a last
> minute post-commit, pre-push check. I therefore reverted this change
> before pushing.
> 
> Paul, Jürgen - please advise how to proceed, considering today's
> deadline. I'd accept pushing the rest of the series, if a fix for
> the issue will then still be permitted in later. Otherwise I'd have
> to wait for a fixed (incremental) version

The attached patch should fix this problem (assuming the anonymous
union is to blame).

Could you verify that, please?

In case the patch is fine, I'll resend the rest of the series with
that patch included, as there are adaptions in later patches needed.


Juergen
Re: [PATCH v10 07/12] xen: provide version information in hypfs
Posted by Jan Beulich 5 years, 8 months ago
On 29.05.2020 11:19, Jürgen Groß wrote:
> On 29.05.20 10:34, Jan Beulich wrote:
>> On 19.05.2020 09:21, Juergen Gross wrote:
>>> @@ -373,6 +374,52 @@ void __init do_initcalls(void)
>>>           (*call)();
>>>   }
>>>   
>>> +#ifdef CONFIG_HYPFS
>>> +static unsigned int __read_mostly major_version;
>>> +static unsigned int __read_mostly 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);
>>
>> These two lines fail to build with gcc 4.1 ("unknown field 'content'
>> specified in initializer"), which I've deliberately tried as a last
>> minute post-commit, pre-push check. I therefore reverted this change
>> before pushing.
>>
>> Paul, Jürgen - please advise how to proceed, considering today's
>> deadline. I'd accept pushing the rest of the series, if a fix for
>> the issue will then still be permitted in later. Otherwise I'd have
>> to wait for a fixed (incremental) version
> 
> The attached patch should fix this problem (assuming the anonymous
> union is to blame).
> 
> Could you verify that, please?

Reviewed-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Jan Beulich <jbeulich@suse.com>

> In case the patch is fine, I'll resend the rest of the series with
> that patch included, as there are adaptions in later patches needed.

No need to, if you trust me to have made the right changes - I've
also verified the rest of the series builds fine there.

Jan

Re: [PATCH v10 07/12] xen: provide version information in hypfs
Posted by Jürgen Groß 5 years, 8 months ago
On 29.05.20 11:53, Jan Beulich wrote:
> On 29.05.2020 11:19, Jürgen Groß wrote:
>> On 29.05.20 10:34, Jan Beulich wrote:
>>> On 19.05.2020 09:21, Juergen Gross wrote:
>>>> @@ -373,6 +374,52 @@ void __init do_initcalls(void)
>>>>            (*call)();
>>>>    }
>>>>    
>>>> +#ifdef CONFIG_HYPFS
>>>> +static unsigned int __read_mostly major_version;
>>>> +static unsigned int __read_mostly 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);
>>>
>>> These two lines fail to build with gcc 4.1 ("unknown field 'content'
>>> specified in initializer"), which I've deliberately tried as a last
>>> minute post-commit, pre-push check. I therefore reverted this change
>>> before pushing.
>>>
>>> Paul, Jürgen - please advise how to proceed, considering today's
>>> deadline. I'd accept pushing the rest of the series, if a fix for
>>> the issue will then still be permitted in later. Otherwise I'd have
>>> to wait for a fixed (incremental) version
>>
>> The attached patch should fix this problem (assuming the anonymous
>> union is to blame).
>>
>> Could you verify that, please?
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> Tested-by: Jan Beulich <jbeulich@suse.com>
> 
>> In case the patch is fine, I'll resend the rest of the series with
>> that patch included, as there are adaptions in later patches needed.
> 
> No need to, if you trust me to have made the right changes - I've
> also verified the rest of the series builds fine there.

Thanks, of course I trust you. :-)


Juergen