|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] xen/version: Fold build_id handling into xenver_varbuf_op()
commit 8eed14bf9d6517726e6998fd8f55a5528ed7dab5
Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Tue Jan 3 19:06:43 2023 +0000
Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Dec 20 22:44:42 2024 +0000
xen/version: Fold build_id handling into xenver_varbuf_op()
struct xen_build_id and struct xen_varbuf are identical from an ABI point of
view, so XENVER_build_id can reuse xenver_varbuf_op() rather than having
it's
own almost identical copy of the logic.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xen/common/kernel.c | 49 +++++++++++++-------------------------------
xen/include/public/version.h | 5 ++++-
2 files changed, 18 insertions(+), 36 deletions(-)
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index eb7122b74f..9e17e22a19 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -509,9 +509,22 @@ static long xenver_varbuf_op(int cmd,
XEN_GUEST_HANDLE_PARAM(void) arg)
struct xen_varbuf user_str;
const char *str = NULL;
size_t sz;
+ int rc;
switch ( cmd )
{
+ case XENVER_build_id:
+ {
+ unsigned int local_sz;
+
+ rc = xen_build_id((const void **)&str, &local_sz);
+ if ( rc )
+ return rc;
+
+ sz = local_sz;
+ goto have_len;
+ }
+
case XENVER_extraversion2:
str = xen_extra_version();
break;
@@ -535,6 +548,7 @@ static long xenver_varbuf_op(int cmd,
XEN_GUEST_HANDLE_PARAM(void) arg)
sz = strlen(str);
+ have_len:
if ( sz > KB(64) ) /* Arbitrary limit. Avoid long-running operations. */
return -E2BIG;
@@ -738,41 +752,6 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void)
arg)
}
case XENVER_build_id:
- {
- xen_build_id_t build_id;
- unsigned int sz;
- int rc;
- const void *p;
-
- if ( deny )
- return -EPERM;
-
- /* Only return size. */
- if ( !guest_handle_is_null(arg) )
- {
- if ( copy_from_guest(&build_id, arg, 1) )
- return -EFAULT;
-
- if ( build_id.len == 0 )
- return -EINVAL;
- }
-
- rc = xen_build_id(&p, &sz);
- if ( rc )
- return rc;
-
- if ( guest_handle_is_null(arg) )
- return sz;
-
- if ( sz > build_id.len )
- return -ENOBUFS;
-
- if ( copy_to_guest_offset(arg, offsetof(xen_build_id_t, buf), p, sz) )
- return -EFAULT;
-
- return sz;
- }
-
case XENVER_extraversion2:
case XENVER_capabilities2:
case XENVER_changeset2:
diff --git a/xen/include/public/version.h b/xen/include/public/version.h
index 0dd6bbcb43..1022604daa 100644
--- a/xen/include/public/version.h
+++ b/xen/include/public/version.h
@@ -124,8 +124,10 @@ typedef char xen_commandline_t[1024];
/*
* Return value is the number of bytes written, or XEN_Exx on error.
* Calling with empty parameter returns the size of build_id.
+ *
+ * Note: structure only kept for backwards compatibility. Xen operates in
+ * terms of xen_varbuf_t.
*/
-#define XENVER_build_id 10
struct xen_build_id {
uint32_t len; /* IN: size of buf[]. */
unsigned char buf[XEN_FLEX_ARRAY_DIM];
@@ -164,6 +166,7 @@ typedef struct xen_varbuf xen_varbuf_t;
* effect. e.g. Xen has no control over the formatting used for the command
* line.
*/
+#define XENVER_build_id 10
#define XENVER_extraversion2 11
#define XENVER_capabilities2 12
#define XENVER_changeset2 13
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |