Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1663549

[PATCH v3 4/4] xen: add sysfs node for hypervisor build id

From Juergen Gross <jgross@suse.com>
Newsgroups linux.kernel
Subject [PATCH v3 4/4] xen: add sysfs node for hypervisor build id
Date 2017-06-12 16:30 +0200
Message-ID <tRyvU-3dT-23@gated-at.bofh.it> (permalink)
References <tRyvU-3dT-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 Documentation/ABI/testing/sysfs-hypervisor-xen | 11 +++++++++-
 drivers/xen/sys-hypervisor.c                   | 29 ++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

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 @@
 What:		/sys/hypervisor/guest_type
-Date:		May 2017
+Date:		June 2017
 KernelVersion:	4.13
 Contact:	xen-devel@lists.xenproject.org
 Description:	If running under Xen:
@@ -32,3 +32,12 @@ Description:	If running under Xen:
 		Describes Xen PMU features (as an integer). A set bit indicates
 		that the corresponding feature is enabled. See
 		include/xen/interface/xenpmu.h for available features
+
+What:		/sys/hypervisor/properties/buildid
+Date:		June 2017
+KernelVersion:	4.13
+Contact:	xen-devel@lists.xenproject.org
+Description:	If running under Xen:
+		Build id of the hypervisor, needed for hypervisor live patching.
+		Might return "<denied>" in case of special security settings
+		in the hypervisor.
diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c
index d641e9970d5d..92307636ed54 100644
--- a/drivers/xen/sys-hypervisor.c
+++ b/drivers/xen/sys-hypervisor.c
@@ -339,12 +339,41 @@ static ssize_t features_show(struct hyp_sysfs_attr *attr, char *buffer)
 
 HYPERVISOR_ATTR_RO(features);
 
+static ssize_t buildid_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+	ssize_t ret;
+	struct xen_build_id dummy;
+	struct xen_build_id *buildid;
+
+	dummy.len = 0;
+	ret = HYPERVISOR_xen_version(XENVER_get_features, &dummy);
+	if (ret < 0) {
+		if (ret == -EPERM)
+			ret = sprintf(buffer, "<denied>");
+		return ret;
+	}
+
+	buildid = kmalloc(sizeof(*buildid) + dummy.len, GFP_KERNEL);
+	if (!buildid)
+		return -ENOMEM;
+
+	ret = HYPERVISOR_xen_version(XENVER_get_features, buildid);
+	if (ret > 0)
+		ret = sprintf(buffer, "%s", buildid->buf);
+	kfree(buildid);
+
+	return ret;
+}
+
+HYPERVISOR_ATTR_RO(buildid);
+
 static struct attribute *xen_properties_attrs[] = {
 	&capabilities_attr.attr,
 	&changeset_attr.attr,
 	&virtual_start_attr.attr,
 	&pagesize_attr.attr,
 	&features_attr.attr,
+	&buildid_attr.attr,
 	NULL
 };
 
-- 
2.12.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 0/4] xen: add xen sysfs nodes Juergen Gross <jgross@suse.com> - 2017-06-12 16:30 +0200
  [PATCH v3 1/4] doc,xen: document hypervisor sysfs nodes for xen Juergen Gross <jgross@suse.com> - 2017-06-12 16:30 +0200
    Re: [PATCH v3 1/4] doc,xen: document hypervisor sysfs nodes for xen Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2017-06-14 16:50 +0200
      Re: [PATCH v3 1/4] doc,xen: document hypervisor sysfs nodes for  xen Stefano Stabellini <sstabellini@kernel.org> - 2017-06-14 21:10 +0200
  [PATCH v3 4/4] xen: add sysfs node for hypervisor build id Juergen Gross <jgross@suse.com> - 2017-06-12 16:30 +0200
    Re: [PATCH v3 4/4] xen: add sysfs node for hypervisor build id Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2017-06-14 17:10 +0200
      Re: [PATCH v3 4/4] xen: add sysfs node for hypervisor build id Juergen Gross <jgross@suse.com> - 2017-06-14 17:10 +0200
  [PATCH v3 3/4] xen: sync include/xen/interface/version.h Juergen Gross <jgross@suse.com> - 2017-06-12 16:30 +0200
    Re: [PATCH v3 3/4] xen: sync include/xen/interface/version.h Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2017-06-14 17:00 +0200

csiph-web