diff options
author | Juergen Gross <jgross@suse.com> | 2017-06-14 13:23:52 -0400 |
---|---|---|
committer | Juergen Gross <jgross@suse.com> | 2017-06-15 02:50:37 -0400 |
commit | 84b7625728ea311ea35bdaa0eded53c1c56baeaa (patch) | |
tree | b20233014fc554e19b4dd2e3311631769c294005 | |
parent | a714c2865f154a353f5cc3c81aeb8d8065934157 (diff) |
xen: add sysfs node for hypervisor build id
For support of Xen hypervisor live patching the hypervisor build id is
needed. Add a node /sys/hypervisor/properties/buildid containing the
information.
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
-rw-r--r-- | Documentation/ABI/testing/sysfs-hypervisor-xen | 11 | ||||
-rw-r--r-- | drivers/xen/sys-hypervisor.c | 28 |
2 files changed, 38 insertions, 1 deletions
diff --git a/Documentation/ABI/testing/sysfs-hypervisor-xen b/Documentation/ABI/testing/sysfs-hypervisor-xen index c0edb3fdd6eb..53b7b2ea7515 100644 --- a/Documentation/ABI/testing/sysfs-hypervisor-xen +++ b/Documentation/ABI/testing/sysfs-hypervisor-xen | |||
@@ -1,5 +1,5 @@ | |||
1 | What: /sys/hypervisor/guest_type | 1 | What: /sys/hypervisor/guest_type |
2 | Date: May 2017 | 2 | Date: June 2017 |
3 | KernelVersion: 4.13 | 3 | KernelVersion: 4.13 |
4 | Contact: xen-devel@lists.xenproject.org | 4 | Contact: xen-devel@lists.xenproject.org |
5 | Description: If running under Xen: | 5 | Description: If running under Xen: |
@@ -32,3 +32,12 @@ Description: If running under Xen: | |||
32 | Describes Xen PMU features (as an integer). A set bit indicates | 32 | Describes Xen PMU features (as an integer). A set bit indicates |
33 | that the corresponding feature is enabled. See | 33 | that the corresponding feature is enabled. See |
34 | include/xen/interface/xenpmu.h for available features | 34 | include/xen/interface/xenpmu.h for available features |
35 | |||
36 | What: /sys/hypervisor/properties/buildid | ||
37 | Date: June 2017 | ||
38 | KernelVersion: 4.13 | ||
39 | Contact: xen-devel@lists.xenproject.org | ||
40 | Description: If running under Xen: | ||
41 | Build id of the hypervisor, needed for hypervisor live patching. | ||
42 | Might return "<denied>" in case of special security settings | ||
43 | in the hypervisor. | ||
diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c index 2f78f84a31e9..9d314bba7c4e 100644 --- a/drivers/xen/sys-hypervisor.c +++ b/drivers/xen/sys-hypervisor.c | |||
@@ -356,12 +356,40 @@ static ssize_t features_show(struct hyp_sysfs_attr *attr, char *buffer) | |||
356 | 356 | ||
357 | HYPERVISOR_ATTR_RO(features); | 357 | HYPERVISOR_ATTR_RO(features); |
358 | 358 | ||
359 | static ssize_t buildid_show(struct hyp_sysfs_attr *attr, char *buffer) | ||
360 | { | ||
361 | ssize_t ret; | ||
362 | struct xen_build_id *buildid; | ||
363 | |||
364 | ret = HYPERVISOR_xen_version(XENVER_build_id, NULL); | ||
365 | if (ret < 0) { | ||
366 | if (ret == -EPERM) | ||
367 | ret = sprintf(buffer, "<denied>"); | ||
368 | return ret; | ||
369 | } | ||
370 | |||
371 | buildid = kmalloc(sizeof(*buildid) + ret, GFP_KERNEL); | ||
372 | if (!buildid) | ||
373 | return -ENOMEM; | ||
374 | |||
375 | buildid->len = ret; | ||
376 | ret = HYPERVISOR_xen_version(XENVER_build_id, buildid); | ||
377 | if (ret > 0) | ||
378 | ret = sprintf(buffer, "%s", buildid->buf); | ||
379 | kfree(buildid); | ||
380 | |||
381 | return ret; | ||
382 | } | ||
383 | |||
384 | HYPERVISOR_ATTR_RO(buildid); | ||
385 | |||
359 | static struct attribute *xen_properties_attrs[] = { | 386 | static struct attribute *xen_properties_attrs[] = { |
360 | &capabilities_attr.attr, | 387 | &capabilities_attr.attr, |
361 | &changeset_attr.attr, | 388 | &changeset_attr.attr, |
362 | &virtual_start_attr.attr, | 389 | &virtual_start_attr.attr, |
363 | &pagesize_attr.attr, | 390 | &pagesize_attr.attr, |
364 | &features_attr.attr, | 391 | &features_attr.attr, |
392 | &buildid_attr.attr, | ||
365 | NULL | 393 | NULL |
366 | }; | 394 | }; |
367 | 395 | ||