From mboxrd@z Thu Jan 1 00:00:00 1970 From: Felix Schmoll Subject: Re: [GSoC] GSoC Introduction : Fuzzing Xen hypercall interface Date: Wed, 29 Mar 2017 16:24:15 +0200 Message-ID: References: <20170322112107.2tkxz6b3kd5emwjf@citrix.com> <20170324125608.imozb5dt42sbhkgz@citrix.com> <20170326130435.t6ncmasbn766d6tg@citrix.com> <9F9E8099-DD6C-4CCA-BF4E-29759006C0C2@gmail.com> <20170328115439.jbm3qq2jdvnsm36e@citrix.com> <20170329104118.g2gj6grorjptfsve@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7155586305927180612==" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctEXC-0006cl-Jk for xen-devel@lists.xenproject.org; Wed, 29 Mar 2017 14:25:14 +0000 Received: by mail-it0-f51.google.com with SMTP id y18so154011244itc.0 for ; Wed, 29 Mar 2017 07:25:12 -0700 (PDT) In-Reply-To: <20170329104118.g2gj6grorjptfsve@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Wei Liu Cc: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org --===============7155586305927180612== Content-Type: multipart/alternative; boundary=001a114387b6297c89054bdf57a4 --001a114387b6297c89054bdf57a4 Content-Type: text/plain; charset=UTF-8 Hi, here the final patch for the domain_id: diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 2d97d36c38..1e152c8a07 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -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); diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index 72e6242417..37b11e41a9 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -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) { diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 614501f761..eddb264f2d 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -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 diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index e7238ce293..3d541e01e1 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -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) }; diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c index e30181817a..184741bf16 100644 --- a/xen/arch/x86/hypercall.c +++ b/xen/arch/x86/hypercall.c @@ -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), }; diff --git a/xen/arch/x86/pv/hypercall.c b/xen/arch/x86/pv/hypercall.c index 9d29d2f088..f12314b5ca 100644 --- a/xen/arch/x86/pv/hypercall.c +++ b/xen/arch/x86/pv/hypercall.c @@ -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), }; diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 84618715dc..5107aacd06 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -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; diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index 91ba8bb48e..4ad62aa01b 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -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 /* custom hypercall */ /* Architecture-specific hypercall definitions. */ #define __HYPERVISOR_arch_0 48 diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h index cc99aea57d..5c7bc6233e 100644 --- a/xen/include/xen/hypercall.h +++ b/xen/include/xen/hypercall.h @@ -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, Felix 2017-03-29 12:41 GMT+02:00 Wei Liu : > On Wed, Mar 29, 2017 at 07:52:47AM +0200, Felix Schmoll wrote: > > > > > > Yes. That would be good. > > > > > > > I'm free every afternoon this week (German time, I suppose you're in > > Europe), so just let me know at least three hours in advance when you're > > free > > to have a chat. > > > > I can do 4-5pm today and tomorrow. Please join #xendevel on freenode. > > Wei. > --001a114387b6297c89054bdf57a4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

here the final patch for the domain= _id:

diff --git a/tools/libxc/include/xenctrl= .h b/tools/libxc/include/xenctrl.h
index 2d97d36c38..1e152c8a07 1= 00644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/l= ibxc/include/xenctrl.h
@@ -1569,6 +1569,7 @@ int xc_domctl(xc_int= erface *xch, struct xen_domctl *domctl);
=C2=A0int xc_sysctl(xc_i= nterface *xch, struct xen_sysctl *sysctl);
=C2=A0
=C2= =A0int xc_version(xc_interface *xch, int cmd, void *arg);
+int xc= _domid(xc_interface *xch);
=C2=A0
=C2=A0int xc_flask_op= (xc_interface *xch, xen_flask_op_t *op);
=C2=A0
diff --= git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
index 7= 2e6242417..37b11e41a9 100644
--- a/tools/libxc/xc_private.c
=
+++ b/tools/libxc/xc_private.c
@@ -530,6 +530,12 @@ int xc_v= ersion(xc_interface *xch, int cmd, void *arg)
=C2=A0 =C2=A0 =C2= =A0return rc;
=C2=A0}
=C2=A0
+int xc_domid(xc= _interface *xch)
+{
+ =C2=A0 =C2=A0return xencall0(xch-= >xcall, __HYPERVISOR_domain_id);
+}
+
+
=C2=A0unsigned long xc_make_page_below_4G(
=C2=A0 =C2=A0 = =C2=A0xc_interface *xch, uint32_t domid, unsigned long mfn)
=C2= =A0{
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 614501f761..eddb264f2d 100644
--- a/xen/arch/arm/tra= ps.c
+++ b/xen/arch/arm/traps.c
@@ -1297,6 +1297,7 @@ s= tatic arm_hypercall_t arm_hypercall_table[] =3D {
=C2=A0 =C2=A0 = =C2=A0HYPERCALL(platform_op, 1),
=C2=A0 =C2=A0 =C2=A0HYPERCALL_AR= M(vcpu_op, 3),
=C2=A0 =C2=A0 =C2=A0HYPERCALL(vm_assist, 2),
=
+ =C2=A0 =C2=A0HYPERCALL(domain_id, 0),
=C2=A0};
= =C2=A0
=C2=A0#ifndef NDEBUG
diff --git a/xen/arch/x86/h= vm/hypercall.c b/xen/arch/x86/hvm/hypercall.c
index e7238ce293..3= d541e01e1 100644
--- a/xen/arch/x86/hvm/hypercall.c
+++= b/xen/arch/x86/hvm/hypercall.c
@@ -132,6 +132,7 @@ static const = hypercall_table_t hvm_hypercall_table[] =3D {
=C2=A0 =C2=A0 =C2= =A0COMPAT_CALL(mmuext_op),
=C2=A0 =C2=A0 =C2=A0HYPERCALL(xenpmu_o= p),
=C2=A0 =C2=A0 =C2=A0COMPAT_CALL(dm_op),
+ =C2=A0 = =C2=A0HYPERCALL(domain_id),
=C2=A0 =C2=A0 =C2=A0HYPERCALL(arch_1)=
=C2=A0};
=C2=A0
diff --git a/xen/arch/x86/hy= percall.c b/xen/arch/x86/hypercall.c
index e30181817a..184741bf16= 100644
--- a/xen/arch/x86/hypercall.c
+++ b/xen/arch/x= 86/hypercall.c
@@ -67,6 +67,7 @@ const hypercall_args_t hypercall= _args_table[NR_hypercalls] =3D
=C2=A0 =C2=A0 =C2=A0ARGS(tmem_op, = 1),
=C2=A0 =C2=A0 =C2=A0ARGS(xenpmu_op, 2),
=C2=A0 =C2= =A0 =C2=A0ARGS(dm_op, 3),
+ =C2=A0 =C2=A0ARGS(domain_id, 0),
=C2=A0 =C2=A0 =C2=A0ARGS(mca, 1),
=C2=A0 =C2=A0 =C2=A0ARGS(= arch_1, 1),
=C2=A0};
diff --git a/xen/arch/x86/pv/hyper= call.c b/xen/arch/x86/pv/hypercall.c
index 9d29d2f088..f12314b5ca= 100644
--- a/xen/arch/x86/pv/hypercall.c
+++ b/xen/arc= h/x86/pv/hypercall.c
@@ -79,6 +79,7 @@ static const hypercall_tab= le_t pv_hypercall_table[] =3D {
=C2=A0#endif
=C2=A0 =C2= =A0 =C2=A0HYPERCALL(xenpmu_op),
=C2=A0 =C2=A0 =C2=A0COMPAT_CALL(d= m_op),
+ =C2=A0 =C2=A0HYPERCALL(domain_id),
=C2=A0 =C2= =A0 =C2=A0HYPERCALL(mca),
=C2=A0 =C2=A0 =C2=A0HYPERCALL(arch_1),<= /div>
=C2=A0};
diff --git a/xen/common/kernel.c b/xen/common/= kernel.c
index 84618715dc..5107aacd06 100644
--- a/xen/= common/kernel.c
+++ b/xen/common/kernel.c
@@ -431,6 +43= 1,12 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
=C2=A0 =C2=A0 =C2=A0return -ENOSYS;
=C2=A0}
=C2=A0
+DO(domain_id)(void)
+{
+ =C2=A0 =C2=A0struct d= omain *d =3D current->domain;
+ =C2=A0 =C2=A0return d->doma= in_id;
+}
+
=C2=A0DO(nmi_op)(unsigned int cmd= , XEN_GUEST_HANDLE_PARAM(void) arg)
=C2=A0{
=C2=A0 =C2= =A0 =C2=A0struct xennmi_callback cb;
diff --git a/xen/include/pub= lic/xen.h b/xen/include/public/xen.h
index 91ba8bb48e..4ad62aa01b= 100644
--- a/xen/include/public/xen.h
+++ b/xen/includ= e/public/xen.h
@@ -121,6 +121,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ul= ong_t);
=C2=A0#define __HYPERVISOR_xc_reserved_op =C2=A0 =C2=A0 = =C2=A0 39 /* reserved for XenClient */
=C2=A0#define __HYPERVISOR= _xenpmu_op =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A040
=C2=A0#def= ine __HYPERVISOR_dm_op =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A041
+#define __HYPERVISOR_domain_id =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A042 /* custom hypercall */=C2=A0
=C2=A0
= =C2=A0/* Architecture-specific hypercall definitions. */
=C2=A0#d= efine __HYPERVISOR_arch_0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = 48
diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hyp= ercall.h
index cc99aea57d..5c7bc6233e 100644
--- a/xen/= include/xen/hypercall.h
+++ b/xen/include/xen/hypercall.h
@@ -83,6 +83,9 @@ do_xen_version(
=C2=A0 =C2=A0 =C2=A0XEN_GUES= T_HANDLE_PARAM(void) arg);
=C2=A0
=C2=A0extern long
+do_domain_id(void);
+
+extern long
= =C2=A0do_console_io(
=C2=A0 =C2=A0 =C2=A0int cmd,
=C2= =A0 =C2=A0 =C2=A0int count,

Felix

2017-03-29 12:41= GMT+02:00 Wei Liu <wei.liu2@citrix.com>:
On Wed, Mar 29, 2017 at 07:52:47AM +0200= , Felix Schmoll wrote:
> >
> > Yes. That would be good.
> >
>
> I'm free every afternoon this week (German time, I suppose you'= ;re in
> Europe), so just let me know at least three hours in advance when you&= #39;re
> free
> to have a chat.
>

I can do 4-5pm today and tomorrow. Please join #xendevel on freenode= .

Wei.

--001a114387b6297c89054bdf57a4-- --===============7155586305927180612== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============7155586305927180612==--