Implement new hypercall to return domain id
PATCH 1/1 Implement new hypercall to return domain id
Minimal implementation of a new hypercall that returns the domain id of the invoking domain with adjustments in libxc.
--- tools/libxc/include/xenctrl.h | 1 + tools/libxc/xc_private.c | 6 ++++++ xen/arch/arm/traps.c | 1 + xen/arch/x86/hvm/hypercall.c | 1 + xen/arch/x86/hypercall.c | 1 + xen/arch/x86/pv/hypercall.c | 1 + xen/common/kernel.c | 6 ++++++ xen/include/public/xen.h | 1 + xen/include/xen/hypercall.h | 3 +++ 9 files changed, 21 insertions(+)
tools/libxc/include/xenctrl.h +1 -0
@@ -1569,6 +1569,7 @@ int xc_domctl(xc_interface *xch, struct xen_domctl *domctl);int xc_sysctl (xc_interface *xch,struct xen_sysctl *sysctl);int xc_version (xc_interface *xch,int cmd,void *arg); +int xc_domid (xc_interface *xch);int xc_flask_op (xc_interface *xch,xen_flask_op_t *op);
tools/libxc/xc_private.c +6 -0
@@ -530,6 +530,12 @@ int xc_version(xc_interface *xch, int cmd, void *arg)return rc; } +int xc_domid (xc_interface *xch) +{ +return xencall0 (xch->xcall, __HYPERVISOR_domain_id); +} + +unsigned long xc_make_page_below_4G (xc_interface *xch,uint32_t domid,unsigned long mfn) {
xen/arch/arm/traps.c +1 -0
@@ -1297,6 +1297,7 @@ static arm_hypercall_t arm_hypercall_table[] = {HYPERCALL (platform_op,1 ),HYPERCALL_ARM (vcpu_op,3 ),HYPERCALL (vm_assist,2 ), + HYPERCALL(domain_id, 0), };#ifndef NDEBUG
xen/arch/x86/hvm/hypercall.c +1 -0
@@ -132,6 +132,7 @@ static const hypercall_table_t hvm_hypercall_table[] = {COMPAT_CALL (mmuext_op),HYPERCALL (xenpmu_op),COMPAT_CALL (dm_op), +HYPERCALL (domain_id), HYPERCALL(arch_1) };
xen/arch/x86/hypercall.c +1 -0
@@ -67,6 +67,7 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] =ARGS (tmem_op,1 ),ARGS (xenpmu_op,2 ),ARGS (dm_op,3 ), +ARGS (domain_id,0 ),ARGS (mca,1 ), ARGS(arch_1, 1), };
xen/arch/x86/pv/hypercall.c +1 -0
@@ -79,6 +79,7 @@ static const hypercall_table_t pv_hypercall_table[] = {#endif HYPERCALL (xenpmu_op),COMPAT_CALL (dm_op), +HYPERCALL (domain_id),HYPERCALL (mca), HYPERCALL(arch_1), };
xen/common/kernel.c +6 -0
@@ -431,6 +431,12 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)return -ENOSYS ; } +DO (domain_id)(void ) +{ +struct domain *d = current->domain; +return d->domain_id; +} +DO (nmi_op)(unsigned int cmd,XEN_GUEST_HANDLE_PARAM (void ) arg) {struct xennmi_callback cb;
xen/include/public/xen.h +1 -0
@@ -121,6 +121,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);#define __HYPERVISOR_xc_reserved_op 39/* reserved for XenClient */ #define __HYPERVISOR_xenpmu_op 40#define __HYPERVISOR_dm_op 41 +#define __HYPERVISOR_domain_id 42/* Architecture-specific hypercall definitions. */ #define __HYPERVISOR_arch_0 48
xen/include/xen/hypercall.h +3 -0
@@ -83,6 +83,9 @@ do_xen_version( XEN_GUEST_HANDLE_PARAM(void) arg);extern long +do_domain_id (void ); + +extern long do_console_io( int cmd, int count,
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
For all other people who happen to see this patch: this isn't meant to be applied.
Cc Juergen as well.
Quoted 3 lines · Felix Schmoll
Minimal implementation of a new hypercall that returns the domain id of the invoking domain with adjustments in libxc.
I think this patch looks good.
If you feel like it, a more advanced challenge would be to pass a userspace buffer down to Xen and have the hypervisor write something back. Some new APIs are needed but there is plenty of examples in libxc.
You don't have to do it, and you don't need to post patch. It's just something you might be interested in trying in case you have time.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel