mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
XENVER_build_id/libxc: Provide ld-embedded build-id
If the hypervisor was built with build-ids we can expose the build-id value to the toolstack (if it is not built with it will just return -ENODATA). This is a priviligied operation so only the controlling stack is able to request this. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Jan Beulich <jbeulich@suse.com> Release-acked-by: Wei Liu <wei.liu2@citrix.com>
This commit is contained in:
1 parent
b1ea652c74
commit
460d24188d
7 files changed
+77
-1
No files matched your search
@@ -82,6 +82,7 @@ allow dom0_t xen_t:xen2 {
|
||||
allow dom0_t xen_t:version {
|
||||
xen_extraversion xen_compile_info xen_capabilities
|
||||
xen_changeset xen_pagesize xen_guest_handle xen_commandline
|
||||
xen_build_id
|
||||
};
|
||||
|
||||
allow dom0_t xen_t:mmu memorymap;
|
||||
|
||||
@@ -495,6 +495,13 @@ int xc_version(xc_interface *xch, int cmd, void *arg)
|
||||
case XENVER_commandline:
|
||||
sz = sizeof(xen_commandline_t);
|
||||
break;
|
||||
case XENVER_build_id:
|
||||
{
|
||||
xen_build_id_t *build_id = (xen_build_id_t *)arg;
|
||||
sz = sizeof(*build_id) + build_id->len;
|
||||
HYPERCALL_BOUNCE_SET_DIR(arg, XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ERROR("xc_version: unknown command %d\n", cmd);
|
||||
return -EINVAL;
|
||||
|
||||
@@ -196,6 +196,17 @@ enum {
|
||||
*/
|
||||
#define HYPERCALL_BOUNCE_SET_SIZE(_buf, _sz) do { (HYPERCALL_BUFFER(_buf))->sz = _sz; } while (0)
|
||||
|
||||
/*
|
||||
* Change the direction.
|
||||
*
|
||||
* Can only be used if the bounce_pre/bounce_post commands have
|
||||
* not been used.
|
||||
*/
|
||||
#define HYPERCALL_BOUNCE_SET_DIR(_buf, _dir) do { if ((HYPERCALL_BUFFER(_buf))->hbuf) \
|
||||
assert(1); \
|
||||
(HYPERCALL_BUFFER(_buf))->dir = _dir; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Initialise and free hypercall safe memory. Takes care of any required
|
||||
* copying.
|
||||
|
||||
@@ -376,6 +376,42 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENOSYS;
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
|
||||
#include "xen.h"
|
||||
|
||||
/* NB. All ops return zero on success, except XENVER_{version,pagesize} */
|
||||
/* NB. All ops return zero on success, except XENVER_{version,pagesize}
|
||||
* XENVER_{version,pagesize,build_id} */
|
||||
|
||||
/* arg == NULL; returns major:minor (16:16). */
|
||||
#define XENVER_version 0
|
||||
@@ -87,6 +88,21 @@ typedef struct xen_feature_info xen_feature_info_t;
|
||||
#define XENVER_commandline 9
|
||||
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.
|
||||
*/
|
||||
#define XENVER_build_id 10
|
||||
struct xen_build_id {
|
||||
uint32_t len; /* IN: size of buf[]. */
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
unsigned char buf[];
|
||||
#elif defined(__GNUC__)
|
||||
unsigned char buf[1]; /* OUT: Variable length buffer with build_id. */
|
||||
#endif
|
||||
};
|
||||
typedef struct xen_build_id xen_build_id_t;
|
||||
|
||||
#endif /* __XEN_PUBLIC_VERSION_H__ */
|
||||
|
||||
/*
|
||||
|
||||
@@ -1663,6 +1663,9 @@ static int flask_xen_version (uint32_t op)
|
||||
case XENVER_commandline:
|
||||
return avc_has_perm(dsid, SECINITSID_XEN, SECCLASS_VERSION,
|
||||
VERSION__XEN_COMMANDLINE, NULL);
|
||||
case XENVER_build_id:
|
||||
return avc_has_perm(dsid, SECINITSID_XEN, SECCLASS_VERSION,
|
||||
VERSION__XEN_BUILD_ID, NULL);
|
||||
default:
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
@@ -525,4 +525,6 @@ class version
|
||||
xen_guest_handle
|
||||
# Xen command line.
|
||||
xen_commandline
|
||||
# Xen build id
|
||||
xen_build_id
|
||||
}
|
||||