Xen-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [Xen-devel] [PATCH lp-metadata 3/3] livepatch: Add metadata runtime retrieval mechanism
@ 2019-08-15 11:27 Pawel Wieczorkiewicz
  2019-08-16 12:44 ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Pawel Wieczorkiewicz @ 2019-08-15 11:27 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ross Lagerwall, Ian Jackson,
	Tim Deegan, mpohlack, wipawel, Julien Grall, Jan Beulich,
	xen-devel

Extend the livepatch list operation to fetch also payloads' metadata.
This is achieved by extending the sysctl list interface with 2 extra
guest handles:
* metadata     - an array of arbitrary size strings
* metadata_len - an array of metadata strings' lengths (uin32_t each)

Payloads' metadata is a string of arbitrary size and does not have an
upper bound limit. It may also vary in size between payloads.

In order to let the userland allocate enough space for the incoming
data add a metadata total size field to the list sysctl operation and
fill it with total size of all payloads' metadata.

Extend the libxc to handle the metadata back-to-back data transfers
as well as metadata length array data transfers.

The xen-livepatch userland tool is extended to always display the
metadata for each received module. The metadata is received with the
following format: key=value\0key=value\0...key=value\0. The format is
modified to the following one: key=value;key=value;...key=value.
The new format allows to easily parse the metadata for a given module
by a machine.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
---
 tools/libxc/include/xenctrl.h | 22 +++++++++++----
 tools/libxc/xc_misc.c         | 66 +++++++++++++++++++++++++++++++++++--------
 tools/misc/xen-livepatch.c    | 43 ++++++++++++++++++++++------
 xen/common/livepatch.c        | 22 +++++++++++----
 xen/include/public/sysctl.h   | 19 +++++++++----
 5 files changed, 134 insertions(+), 38 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index e0ebb586b6..7a3762f44e 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2561,7 +2561,7 @@ int xc_livepatch_get(xc_interface *xch,
 
 /*
  * Get a number of available payloads and get actual total size of
- * the payloads' name array.
+ * the payloads' name and metadata arrays.
  *
  * This functions is typically executed first before the xc_livepatch_list()
  * to obtain the sizes and correctly allocate all necessary data resources.
@@ -2572,13 +2572,16 @@ int xc_livepatch_get(xc_interface *xch,
  * will contain the hypercall error code value.
  */
 int xc_livepatch_list_get_sizes(xc_interface *xch, unsigned int *nr,
-                                uint64_t *name_total_size);
+                                uint64_t *name_total_size,
+                                uint64_t *metadata_total_size);
 
 /*
  * The heart of this function is to get an array of the following objects:
  *   - xen_livepatch_status_t: states and return codes of payloads
  *   - name: names of payloads
  *   - len: lengths of corresponding payloads' names
+ *   - metadata: payloads' metadata
+ *   - metadata_len: lengths of corresponding payloads' metadata
  *
  * However it is complex because it has to deal with the hypervisor
  * returning some of the requested data or data being stale
@@ -2591,12 +2594,13 @@ int xc_livepatch_list_get_sizes(xc_interface *xch, unsigned int *nr,
  *
  * It is expected that the caller of this function will first issue the
  * xc_livepatch_list_get_sizes() in order to obtain total sizes of names
- * as well as the current number of payload entries.
- * The total sizes are required and supplied via the 'name_total_size'
- * parameter.
+ * and all metadata as well as the current number of payload entries.
+ * The total sizes are required and supplied via the 'name_total_size' and
+ * 'metadata_total_size' parameters.
  *
  * The 'max' is to be provided by the caller with the maximum number of
- * entries that 'info', 'name', 'len' arrays can be filled up with.
+ * entries that 'info', 'name', 'len', 'metadata' and 'metadata_len' arrays
+ * can be filled up with.
  *
  * Each entry in the 'info' array is expected to be of xen_livepatch_status_t
  * structure size.
@@ -2605,6 +2609,10 @@ int xc_livepatch_list_get_sizes(xc_interface *xch, unsigned int *nr,
  *
  * Each entry in the 'len' array is expected to be of uint32_t size.
  *
+ * Each entry in the 'metadata' array may have an arbitrary size.
+ *
+ * Each entry in the 'metadata_len' array is expected to be of uint32_t size.
+ *
  * The return value is zero if the hypercall completed successfully.
  * Note that the return value is _not_ the amount of entries filled
  * out - that is saved in 'done'.
@@ -2619,6 +2627,8 @@ int xc_livepatch_list(xc_interface *xch, const unsigned int max,
                       struct xen_livepatch_status *info,
                       char *name, uint32_t *len,
                       const uint64_t name_total_size,
+                      char *metadata, uint32_t *metadata_len,
+                      const uint64_t metadata_total_size,
                       unsigned int *done, unsigned int *left);
 
 /*
diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
index d787f3f29f..618113011d 100644
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -663,7 +663,7 @@ int xc_livepatch_get(xc_interface *xch,
 
 /*
  * Get a number of available payloads and get actual total size of
- * the payloads' name array.
+ * the payloads' name and metadata arrays.
  *
  * This functions is typically executed first before the xc_livepatch_list()
  * to obtain the sizes and correctly allocate all necessary data resources.
@@ -674,12 +674,13 @@ int xc_livepatch_get(xc_interface *xch,
  * will contain the hypercall error code value.
  */
 int xc_livepatch_list_get_sizes(xc_interface *xch, unsigned int *nr,
-                                uint64_t *name_total_size)
+                                uint64_t *name_total_size,
+                                uint64_t *metadata_total_size)
 {
     DECLARE_SYSCTL;
     int rc;
 
-    if ( !nr || !name_total_size )
+    if ( !nr || !name_total_size || !metadata_total_size )
     {
         errno = EINVAL;
         return -1;
@@ -695,6 +696,7 @@ int xc_livepatch_list_get_sizes(xc_interface *xch, unsigned int *nr,
 
     *nr = sysctl.u.livepatch.u.list.nr;
     *name_total_size = sysctl.u.livepatch.u.list.name_total_size;
+    *metadata_total_size = sysctl.u.livepatch.u.list.metadata_total_size;
 
     return 0;
 }
@@ -704,6 +706,8 @@ int xc_livepatch_list_get_sizes(xc_interface *xch, unsigned int *nr,
  *   - xen_livepatch_status_t: states and return codes of payloads
  *   - name: names of payloads
  *   - len: lengths of corresponding payloads' names
+ *   - metadata: payloads' metadata
+ *   - metadata_len: lengths of corresponding payloads' metadata
  *
  * However it is complex because it has to deal with the hypervisor
  * returning some of the requested data or data being stale
@@ -716,12 +720,13 @@ int xc_livepatch_list_get_sizes(xc_interface *xch, unsigned int *nr,
  *
  * It is expected that the caller of this function will first issue the
  * xc_livepatch_list_get_sizes() in order to obtain total sizes of names
- * as well as the current number of payload entries.
- * The total sizes are required and supplied via the 'name_total_size'
- * parameter.
+ * and all metadata as well as the current number of payload entries.
+ * The total sizes are required and supplied via the 'name_total_size' and
+ * 'metadata_total_size' parameters.
  *
  * The 'max' is to be provided by the caller with the maximum number of
- * entries that 'info', 'name', 'len' arrays can be filled up with.
+ * entries that 'info', 'name', 'len', 'metadata' and 'metadata_len' arrays
+ * can be filled up with.
  *
  * Each entry in the 'info' array is expected to be of xen_livepatch_status_t
  * structure size.
@@ -730,6 +735,10 @@ int xc_livepatch_list_get_sizes(xc_interface *xch, unsigned int *nr,
  *
  * Each entry in the 'len' array is expected to be of uint32_t size.
  *
+ * Each entry in the 'metadata' array may have an arbitrary size.
+ *
+ * Each entry in the 'metadata_len' array is expected to be of uint32_t size.
+ *
  * The return value is zero if the hypercall completed successfully.
  * Note that the return value is _not_ the amount of entries filled
  * out - that is saved in 'done'.
@@ -744,6 +753,8 @@ int xc_livepatch_list(xc_interface *xch, const unsigned int max,
                       struct xen_livepatch_status *info,
                       char *name, uint32_t *len,
                       const uint64_t name_total_size,
+                      char *metadata, uint32_t *metadata_len,
+                      const uint64_t metadata_total_size,
                       unsigned int *done, unsigned int *left)
 {
     int rc;
@@ -752,19 +763,22 @@ int xc_livepatch_list(xc_interface *xch, const unsigned int max,
     DECLARE_HYPERCALL_BOUNCE(info, 0, XC_HYPERCALL_BUFFER_BOUNCE_OUT);
     DECLARE_HYPERCALL_BOUNCE(name, 0, XC_HYPERCALL_BUFFER_BOUNCE_OUT);
     DECLARE_HYPERCALL_BOUNCE(len, 0, XC_HYPERCALL_BUFFER_BOUNCE_OUT);
+    DECLARE_HYPERCALL_BOUNCE(metadata, 0, XC_HYPERCALL_BUFFER_BOUNCE_OUT);
+    DECLARE_HYPERCALL_BOUNCE(metadata_len, 0, XC_HYPERCALL_BUFFER_BOUNCE_OUT);
     uint32_t max_batch_sz, nr;
     uint32_t version = 0, retries = 0;
     uint32_t adjust = 0;
-    off_t name_off = 0;
-    uint64_t name_sz;
+    off_t name_off = 0, metadata_off = 0;
+    uint64_t name_sz, metadata_sz;
 
-    if ( !max || !info || !name || !len || !done || !left )
+    if ( !max || !info || !name || !len ||
+         !metadata || !metadata_len || !done || !left )
     {
         errno = EINVAL;
         return -1;
     }
 
-    if ( name_total_size == 0 )
+    if ( name_total_size == 0 || metadata_total_size == 0 )
     {
         errno = ENOENT;
         return -1;
@@ -777,10 +791,11 @@ int xc_livepatch_list(xc_interface *xch, const unsigned int max,
 
     max_batch_sz = max;
     name_sz = name_total_size;
+    metadata_sz = metadata_total_size;
     *done = 0;
     *left = 0;
     do {
-        uint64_t _name_sz;
+        uint64_t _name_sz, _metadata_sz;
 
         /*
          * The first time we go in this loop our 'max' may be bigger
@@ -803,10 +818,14 @@ int xc_livepatch_list(xc_interface *xch, const unsigned int max,
         HYPERCALL_BOUNCE_SET_SIZE(info, nr * sizeof(*info));
         HYPERCALL_BOUNCE_SET_SIZE(name, name_sz);
         HYPERCALL_BOUNCE_SET_SIZE(len, nr * sizeof(*len));
+        HYPERCALL_BOUNCE_SET_SIZE(metadata, metadata_sz);
+        HYPERCALL_BOUNCE_SET_SIZE(metadata_len, nr * sizeof(*metadata_len));
         /* Move the pointer to proper offset into 'info'. */
         (HYPERCALL_BUFFER(info))->ubuf = info + *done;
         (HYPERCALL_BUFFER(name))->ubuf = name + name_off;
         (HYPERCALL_BUFFER(len))->ubuf = len + *done;
+        (HYPERCALL_BUFFER(metadata))->ubuf = metadata + metadata_off;
+        (HYPERCALL_BUFFER(metadata_len))->ubuf = metadata_len + *done;
         /* Allocate memory. */
         rc = xc_hypercall_bounce_pre(xch, info);
         if ( rc )
@@ -820,9 +839,19 @@ int xc_livepatch_list(xc_interface *xch, const unsigned int max,
         if ( rc )
             break;
 
+        rc = xc_hypercall_bounce_pre(xch, metadata);
+        if ( rc )
+            break;
+
+        rc = xc_hypercall_bounce_pre(xch, metadata_len);
+        if ( rc )
+            break;
+
         set_xen_guest_handle(sysctl.u.livepatch.u.list.status, info);
         set_xen_guest_handle(sysctl.u.livepatch.u.list.name, name);
         set_xen_guest_handle(sysctl.u.livepatch.u.list.len, len);
+        set_xen_guest_handle(sysctl.u.livepatch.u.list.metadata, metadata);
+        set_xen_guest_handle(sysctl.u.livepatch.u.list.metadata_len, metadata_len);
 
         rc = do_sysctl(xch, &sysctl);
         /*
@@ -839,6 +868,8 @@ int xc_livepatch_list(xc_interface *xch, const unsigned int max,
             xc_hypercall_bounce_post(xch, info);
             xc_hypercall_bounce_post(xch, name);
             xc_hypercall_bounce_post(xch, len);
+            xc_hypercall_bounce_post(xch, metadata);
+            xc_hypercall_bounce_post(xch, metadata_len);
             continue;
         }
         else if ( rc < 0 ) /* For all other errors we bail out. */
@@ -863,6 +894,8 @@ int xc_livepatch_list(xc_interface *xch, const unsigned int max,
             xc_hypercall_bounce_post(xch, info);
             xc_hypercall_bounce_post(xch, name);
             xc_hypercall_bounce_post(xch, len);
+            xc_hypercall_bounce_post(xch, metadata);
+            xc_hypercall_bounce_post(xch, metadata_len);
             continue;
         }
 
@@ -875,17 +908,24 @@ int xc_livepatch_list(xc_interface *xch, const unsigned int max,
         }
         *left = sysctl.u.livepatch.u.list.nr; /* Total remaining count. */
         _name_sz = sysctl.u.livepatch.u.list.name_total_size; /* Total received name size. */
+        _metadata_sz = sysctl.u.livepatch.u.list.metadata_total_size; /* Total received metadata size. */
         /* Copy only up 'rc' of data' - we could add 'min(rc,nr) if desired. */
         HYPERCALL_BOUNCE_SET_SIZE(info, (rc * sizeof(*info)));
         HYPERCALL_BOUNCE_SET_SIZE(name, _name_sz);
         HYPERCALL_BOUNCE_SET_SIZE(len, (rc * sizeof(*len)));
+        HYPERCALL_BOUNCE_SET_SIZE(metadata, _metadata_sz);
+        HYPERCALL_BOUNCE_SET_SIZE(metadata_len, (rc * sizeof(*metadata_len)));
         /* Bounce the data and free the bounce buffer. */
         xc_hypercall_bounce_post(xch, info);
         xc_hypercall_bounce_post(xch, name);
         xc_hypercall_bounce_post(xch, len);
+        xc_hypercall_bounce_post(xch, metadata);
+        xc_hypercall_bounce_post(xch, metadata_len);
 
         name_sz -= _name_sz;
         name_off += _name_sz;
+        metadata_sz -= _metadata_sz;
+        metadata_off += _metadata_sz;
 
         /* And update how many elements of info we have copied into. */
         *done += rc;
@@ -898,6 +938,8 @@ int xc_livepatch_list(xc_interface *xch, const unsigned int max,
         xc_hypercall_bounce_post(xch, len);
         xc_hypercall_bounce_post(xch, name);
         xc_hypercall_bounce_post(xch, info);
+        xc_hypercall_bounce_post(xch, metadata);
+        xc_hypercall_bounce_post(xch, metadata_len);
     }
 
     return rc > 0 ? 0 : rc;
diff --git a/tools/misc/xen-livepatch.c b/tools/misc/xen-livepatch.c
index 8ac3d567fc..61d4950001 100644
--- a/tools/misc/xen-livepatch.c
+++ b/tools/misc/xen-livepatch.c
@@ -69,9 +69,11 @@ static int list_func(int argc, char *argv[])
     unsigned int nr, done, left, i;
     xen_livepatch_status_t *info = NULL;
     char *name = NULL;
+    char *metadata = NULL;
     uint32_t *len = NULL;
-    uint64_t name_total_size;
-    off_t name_off;
+    uint32_t *metadata_len = NULL;
+    uint64_t name_total_size, metadata_total_size;
+    off_t name_off, metadata_off;
     int rc = ENOMEM;
 
     if ( argc )
@@ -81,7 +83,7 @@ static int list_func(int argc, char *argv[])
     }
     done = left = 0;
 
-    rc = xc_livepatch_list_get_sizes(xch, &nr, &name_total_size);
+    rc = xc_livepatch_list_get_sizes(xch, &nr, &name_total_size, &metadata_total_size);
     if ( rc )
     {
         rc = errno;
@@ -109,12 +111,23 @@ static int list_func(int argc, char *argv[])
     if ( !len )
         goto error_len;
 
+    metadata = malloc(metadata_total_size * sizeof(*metadata));
+    if ( !metadata )
+        goto error_metadata;
+
+    metadata_len = malloc(nr * sizeof(*metadata_len));
+    if ( !metadata_len )
+        goto error_metadata_len;
+
     memset(info, 'A', nr * sizeof(*info));
     memset(name, 'B', name_total_size * sizeof(*name));
     memset(len, 'C', nr * sizeof(*len));
-    name_off = 0;
+    memset(metadata, 'D', metadata_total_size * sizeof(*metadata));
+    memset(metadata_len, 'E', nr * sizeof(*metadata_len));
+    name_off = metadata_off = 0;
 
-    rc = xc_livepatch_list(xch, nr, 0, info, name, len, name_total_size, &done, &left);
+    rc = xc_livepatch_list(xch, nr, 0, info, name, len, name_total_size,
+                           metadata, metadata_len, metadata_total_size, &done, &left);
     if ( rc || done != nr || left > 0)
     {
         rc = errno;
@@ -124,23 +137,35 @@ static int list_func(int argc, char *argv[])
         goto error;
     }
 
-    fprintf(stdout," ID                                     | status\n"
-                   "----------------------------------------+------------\n");
+    fprintf(stdout," ID                                     | status     | metadata\n"
+                   "----------------------------------------+------------+---------------\n");
 
     for ( i = 0; i < done; i++ )
     {
+        unsigned int j;
         char *name_str = name + name_off;
+        char *metadata_str = metadata + metadata_off;
 
         printf("%-40.*s| %s", len[i], name_str, state2str(info[i].state));
         if ( info[i].rc )
-            printf(" (%d, %s)\n", -info[i].rc, strerror(-info[i].rc));
+            printf(" (%d, %s)    | ", -info[i].rc, strerror(-info[i].rc));
         else
-            puts("");
+            printf("    | ");
+
+        /* Replace all '\0' with semi-colons. */
+        for ( j = 0; j < metadata_len[i] - 1; j++ )
+            metadata_str[j] = (metadata_str[j] ?: ';');
+        printf("%.*s\n", metadata_len[i], metadata_str);
 
         name_off += len[i];
+        metadata_off += metadata_len[i];
     }
 
 error:
+    free(metadata_len);
+error_metadata_len:
+    free(metadata);
+error_metadata:
     free(len);
 error_len:
     free(name);
diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index f486cb3021..49a76f1029 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -1163,7 +1163,8 @@ static int livepatch_list(struct xen_sysctl_livepatch_list *list)
 
     if ( list->nr &&
          (!guest_handle_okay(list->status, list->nr) ||
-          !guest_handle_okay(list->len, list->nr)) )
+          !guest_handle_okay(list->len, list->nr) ||
+          !guest_handle_okay(list->metadata_len, list->nr)) )
         return -EINVAL;
 
     spin_lock(&payload_lock);
@@ -1174,13 +1175,14 @@ static int livepatch_list(struct xen_sysctl_livepatch_list *list)
     }
 
     list->name_total_size = 0;
+    list->metadata_total_size = 0;
     if ( list->nr )
     {
-        uint64_t name_offset = 0;
+        uint64_t name_offset = 0, metadata_offset = 0;
 
         list_for_each_entry( data, &payload_list, list )
         {
-            uint32_t name_len;
+            uint32_t name_len, metadata_len;
 
             if ( list->idx > i++ )
                 continue;
@@ -1191,8 +1193,13 @@ static int livepatch_list(struct xen_sysctl_livepatch_list *list)
             name_len = strlen(data->name) + 1;
             list->name_total_size += name_len;
 
+            metadata_len = data->metadata.len;
+            list->metadata_total_size += metadata_len;
+
             if ( !guest_handle_subrange_okay(list->name, name_offset,
-                                             name_offset + name_len - 1) )
+                                             name_offset + name_len - 1) ||
+                 !guest_handle_subrange_okay(list->metadata, metadata_offset,
+                                             metadata_offset + metadata_len - 1) )
             {
                 rc = -EINVAL;
                 break;
@@ -1202,7 +1209,10 @@ static int livepatch_list(struct xen_sysctl_livepatch_list *list)
             if ( __copy_to_guest_offset(list->name, name_offset,
                                         data->name, name_len) ||
                 __copy_to_guest_offset(list->len, idx, &name_len, 1) ||
-                __copy_to_guest_offset(list->status, idx, &status, 1) )
+                __copy_to_guest_offset(list->status, idx, &status, 1) ||
+                __copy_to_guest_offset(list->metadata, metadata_offset,
+                                       data->metadata.data, metadata_len) ||
+                __copy_to_guest_offset(list->metadata_len, idx, &metadata_len, 1) )
             {
                 rc = -EFAULT;
                 break;
@@ -1210,6 +1220,7 @@ static int livepatch_list(struct xen_sysctl_livepatch_list *list)
 
             idx++;
             name_offset += name_len;
+            metadata_offset += metadata_len;
 
             if ( (idx >= list->nr) || hypercall_preempt_check() )
                 break;
@@ -1220,6 +1231,7 @@ static int livepatch_list(struct xen_sysctl_livepatch_list *list)
         list_for_each_entry( data, &payload_list, list )
         {
             list->name_total_size += strlen(data->name) + 1;
+            list->metadata_total_size += data->metadata.len;
         }
     }
     list->nr = payload_cnt - i; /* Remaining amount. */
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index b86804b7a6..e4c8f4fe63 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -921,16 +921,17 @@ struct xen_sysctl_livepatch_get {
 };
 
 /*
- * Retrieve an array of abbreviated status and names of payloads that are
- * loaded in the hypervisor.
+ * Retrieve an array of abbreviated status, names and metadata of payloads that
+ * are loaded in the hypervisor.
  *
  * If the hypercall returns an positive number, it is the number (up to `nr`)
  * of the payloads returned, along with `nr` updated with the number of remaining
  * payloads, `version` updated (it may be the same across hypercalls. If it varies
- * the data is stale and further calls could fail) and the name_total_size
- * containing total size of transfered data for the array.
- * The `status`, `name`, `len` are updated at their designed index value (`idx`)
- * with the returned value of data.
+ * the data is stale and further calls could fail), `name_total_size` and
+ * `metadata_total_size` containing total sizes of transfered data for both the
+ * arrays.
+ * The `status`, `name`, `len`, `metadata` and `metadata_len` are updated at their
+ * designed index value (`idx`) with the returned value of data.
  *
  * If the hypercall returns E2BIG the `nr` is too big and should be
  * lowered. The upper limit of `nr` is left to the implemention.
@@ -954,6 +955,7 @@ struct xen_sysctl_livepatch_list {
                                                OUT: How many payloads left. */
     uint32_t pad;                           /* IN: Must be zero. */
     uint64_t name_total_size;               /* OUT: Total size of all transfer names */
+    uint64_t metadata_total_size;           /* OUT: Total size of all transfer metadata */
     XEN_GUEST_HANDLE_64(xen_livepatch_status_t) status;  /* OUT. Must have enough
                                                space allocate for nr of them. */
     XEN_GUEST_HANDLE_64(char) name;         /* OUT: Array of names. Each member
@@ -962,6 +964,11 @@ struct xen_sysctl_livepatch_list {
                                                nr of them. */
     XEN_GUEST_HANDLE_64(uint32) len;        /* OUT: Array of lengths of name's.
                                                Must have nr of them. */
+    XEN_GUEST_HANDLE_64(char) metadata;     /* OUT: Array of metadata strings. Each
+                                               member may have an arbitrary length.
+                                               Must have nr of them. */
+    XEN_GUEST_HANDLE_64(uint32) metadata_len;  /* OUT: Array of lengths of metadata's.
+                                                  Must have nr of them. */
 };
 
 /*
-- 
2.16.5




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879




_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xen-devel] [PATCH lp-metadata 3/3] livepatch: Add metadata runtime retrieval mechanism
  2019-08-15 11:27 [Xen-devel] [PATCH lp-metadata 3/3] livepatch: Add metadata runtime retrieval mechanism Pawel Wieczorkiewicz
@ 2019-08-16 12:44 ` Wei Liu
  2019-08-16 12:54   ` Wieczorkiewicz, Pawel
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2019-08-16 12:44 UTC (permalink / raw)
  To: Pawel Wieczorkiewicz
  Cc: Tim Deegan, Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, xen-devel, mpohlack,
	Ross Lagerwall, Julien Grall, Jan Beulich, xen-devel

On Thu, Aug 15, 2019 at 11:27:50AM +0000, Pawel Wieczorkiewicz wrote:
> Extend the livepatch list operation to fetch also payloads' metadata.
> This is achieved by extending the sysctl list interface with 2 extra
> guest handles:
> * metadata     - an array of arbitrary size strings
> * metadata_len - an array of metadata strings' lengths (uin32_t each)
> 
> Payloads' metadata is a string of arbitrary size and does not have an
> upper bound limit. It may also vary in size between payloads.
> 
> In order to let the userland allocate enough space for the incoming
> data add a metadata total size field to the list sysctl operation and
> fill it with total size of all payloads' metadata.
> 
> Extend the libxc to handle the metadata back-to-back data transfers
> as well as metadata length array data transfers.
> 
> The xen-livepatch userland tool is extended to always display the
> metadata for each received module. The metadata is received with the
> following format: key=value\0key=value\0...key=value\0. The format is
> modified to the following one: key=value;key=value;...key=value.
> The new format allows to easily parse the metadata for a given module
> by a machine.
> 
> Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
> Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
> Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
> Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
> ---
>  tools/libxc/include/xenctrl.h | 22 +++++++++++----
>  tools/libxc/xc_misc.c         | 66 +++++++++++++++++++++++++++++++++++--------
>  tools/misc/xen-livepatch.c    | 43 ++++++++++++++++++++++------
>  xen/common/livepatch.c        | 22 +++++++++++----
>  xen/include/public/sysctl.h   | 19 +++++++++----

Mostly look good. One comment below...

> diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
> index b86804b7a6..e4c8f4fe63 100644
> --- a/xen/include/public/sysctl.h
> +++ b/xen/include/public/sysctl.h

If it hasn't been done for this release already, changing sysctl interface requires
bumping the version number in this header.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xen-devel] [PATCH lp-metadata 3/3] livepatch: Add metadata runtime retrieval mechanism
  2019-08-16 12:44 ` Wei Liu
@ 2019-08-16 12:54   ` Wieczorkiewicz, Pawel
  2019-08-16 12:56     ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Wieczorkiewicz, Pawel @ 2019-08-16 12:54 UTC (permalink / raw)
  To: Wei Liu
  Cc: Tim Deegan, Stefano Stabellini, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ross Lagerwall, Ian Jackson,
	xen-devel, Pohlack, Martin, Wieczorkiewicz, Pawel, Julien Grall,
	Jan Beulich, xen-devel

[-- Attachment #1.1.1: Type: text/plain, Size: 1477 bytes --]


> On 16. Aug 2019, at 14:44, Wei Liu <wl@xen.org> wrote:
> 
> On Thu, Aug 15, 2019 at 11:27:50AM +0000, Pawel Wieczorkiewicz wrote:
>> Extend the livepatch list operation to fetch also payloads' metadata.
>> This is achieved by extending the sysctl list interface with 2 extra
>> guest handles:
>> * metadata     - an array of arbitrary size strings
>> * metadata_len - an array of metadata strings' lengths (uin32_t each)

…snip...

>> Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
>> Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
>> Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
>> Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
>> ---
>> tools/libxc/include/xenctrl.h | 22 +++++++++++----
>> tools/libxc/xc_misc.c         | 66 +++++++++++++++++++++++++++++++++++--------
>> tools/misc/xen-livepatch.c    | 43 ++++++++++++++++++++++------
>> xen/common/livepatch.c        | 22 +++++++++++----
>> xen/include/public/sysctl.h   | 19 +++++++++----
> 
> Mostly look good. One comment below...
> 
>> diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
>> index b86804b7a6..e4c8f4fe63 100644
>> --- a/xen/include/public/sysctl.h
>> +++ b/xen/include/public/sysctl.h
> 
> If it hasn't been done for this release already, changing sysctl interface requires
> bumping the version number in this header.
> 

ACK. Will do (also for earlier patches…).

> Wei.

Best Regards,
Pawel Wieczorkiewicz

[-- Attachment #1.1.2: Type: text/html, Size: 8605 bytes --]

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 16. Aug 2019, at 14:44, Wei Liu &lt;<a href="mailto:wl@xen.org" class="">wl@xen.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">On Thu, Aug 15, 2019 at 11:27:50AM +0000, Pawel Wieczorkiewicz wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Extend the livepatch list operation to fetch also payloads' metadata.<br class="">This is achieved by extending the sysctl list interface with 2 extra<br class="">guest handles:<br class="">* metadata &nbsp;&nbsp;&nbsp;&nbsp;- an array of arbitrary size strings<br class="">* metadata_len - an array of metadata strings' lengths (uin32_t each)<br class=""></blockquote></div></blockquote><div><br class=""></div><div>…snip...</div><br class=""><blockquote type="cite" class=""><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Signed-off-by: Pawel Wieczorkiewicz &lt;<a href="mailto:wipawel@amazon.de" class="">wipawel@amazon.de</a>&gt;<br class="">Reviewed-by: Andra-Irina Paraschiv &lt;<a href="mailto:andraprs@amazon.com" class="">andraprs@amazon.com</a>&gt;<br class="">Reviewed-by: Martin Pohlack &lt;<a href="mailto:mpohlack@amazon.de" class="">mpohlack@amazon.de</a>&gt;<br class="">Reviewed-by: Norbert Manthey &lt;<a href="mailto:nmanthey@amazon.de" class="">nmanthey@amazon.de</a>&gt;<br class="">---<br class="">tools/libxc/include/xenctrl.h | 22 +++++++++++----<br class="">tools/libxc/xc_misc.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 66 +++++++++++++++++++++++++++++++++++--------<br class="">tools/misc/xen-livepatch.c &nbsp;&nbsp;&nbsp;| 43 ++++++++++++++++++++++------<br class="">xen/common/livepatch.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 22 +++++++++++----<br class="">xen/include/public/sysctl.h &nbsp;&nbsp;| 19 +++++++++----<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Mostly look good. One comment below...</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h<br class="">index b86804b7a6..e4c8f4fe63 100644<br class="">--- a/xen/include/public/sysctl.h<br class="">+++ b/xen/include/public/sysctl.h<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">If it hasn't been done for this release already, changing sysctl interface requires</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">bumping the version number in this header.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote><div><br class=""></div><div>ACK. Will do (also for earlier patches…).</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Wei.</span></div></blockquote></div><br class=""><div class=""><div class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">Best Regards,<br class="">Pawel Wieczorkiewicz</div></div></div></div></body></html>

[-- Attachment #1.2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2.1: Type: text/plain, Size: 236 bytes --]




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879



[-- Attachment #2.2: Type: text/html, Size: 276 bytes --]

<br><br><br>Amazon Development Center Germany GmbH
<br>Krausenstr. 38
<br>10117 Berlin
<br>Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich
<br>Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
<br>Sitz: Berlin
<br>Ust-ID: DE 289 237 879
<br><br><br>

[-- Attachment #3: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xen-devel] [PATCH lp-metadata 3/3] livepatch: Add metadata runtime retrieval mechanism
  2019-08-16 12:54   ` Wieczorkiewicz, Pawel
@ 2019-08-16 12:56     ` Wei Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2019-08-16 12:56 UTC (permalink / raw)
  To: Wieczorkiewicz, Pawel
  Cc: Tim Deegan, Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, xen-devel, Pohlack,
	Martin, Ross Lagerwall, Julien Grall, Jan Beulich, xen-devel

On Fri, Aug 16, 2019 at 12:54:12PM +0000, Wieczorkiewicz, Pawel wrote:
> 
> > On 16. Aug 2019, at 14:44, Wei Liu <wl@xen.org> wrote:
> > 
> > On Thu, Aug 15, 2019 at 11:27:50AM +0000, Pawel Wieczorkiewicz wrote:
> >> Extend the livepatch list operation to fetch also payloads' metadata.
> >> This is achieved by extending the sysctl list interface with 2 extra
> >> guest handles:
> >> * metadata     - an array of arbitrary size strings
> >> * metadata_len - an array of metadata strings' lengths (uin32_t each)
> 
> …snip...
> 
> >> Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
> >> Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
> >> Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
> >> Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
> >> ---
> >> tools/libxc/include/xenctrl.h | 22 +++++++++++----
> >> tools/libxc/xc_misc.c         | 66 +++++++++++++++++++++++++++++++++++--------
> >> tools/misc/xen-livepatch.c    | 43 ++++++++++++++++++++++------
> >> xen/common/livepatch.c        | 22 +++++++++++----
> >> xen/include/public/sysctl.h   | 19 +++++++++----
> > 
> > Mostly look good. One comment below...
> > 
> >> diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
> >> index b86804b7a6..e4c8f4fe63 100644
> >> --- a/xen/include/public/sysctl.h
> >> +++ b/xen/include/public/sysctl.h
> > 
> > If it hasn't been done for this release already, changing sysctl interface requires
> > bumping the version number in this header.
> > 
> 
> ACK. Will do (also for earlier patches…).
> 

We only need to do it once per release. :-)

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-15 11:27 [Xen-devel] [PATCH lp-metadata 3/3] livepatch: Add metadata runtime retrieval mechanism Pawel Wieczorkiewicz
2019-08-16 12:44 ` Wei Liu
2019-08-16 12:54   ` Wieczorkiewicz, Pawel
2019-08-16 12:56     ` Wei Liu

Xen-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/xen-devel/0 xen-devel/git/0.git
	git clone --mirror https://lore.kernel.org/xen-devel/1 xen-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 xen-devel xen-devel/ https://lore.kernel.org/xen-devel \
		xen-devel@lists.xenproject.org xen-devel@archiver.kernel.org
	public-inbox-index xen-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.xenproject.lists.xen-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox