From patchwork Wed Mar 22 08:47:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Schmoll X-Patchwork-Id: 9638305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EB5F46020B for ; Wed, 22 Mar 2017 08:49:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E112527F81 for ; Wed, 22 Mar 2017 08:49:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5B5A281F9; Wed, 22 Mar 2017 08:49:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D8ED527F81 for ; Wed, 22 Mar 2017 08:49:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqbvD-0002xU-Js; Wed, 22 Mar 2017 08:47:11 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqbvC-0002xO-E2 for xen-devel@lists.xenproject.org; Wed, 22 Mar 2017 08:47:10 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 75/96-23940-D0A32D85; Wed, 22 Mar 2017 08:47:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRWlGSWpSXmKPExsVyMfT+QV0eq0s RBlc+qVt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmXVsQUHOxhrGiY+4SxgXF6XRcjF4eQwAxG iY+L2tlBHBaBBlaJrat3MoE4EgJzWCVOTzwMlOEEcnIk9m5ZwQhhl0jse3aCCcTmFRCUODnzC UsXIwfQKC+Jqy+ZQcKcApYSm04/ZYPY8JdJYvPcC2C9bAIGErNXXgQrYhFQlbiwpo0NYk6AxP zLu8FqhAXcJZZf7wazRQQUJR68vMkKYjMLKEnsP3uNEcL2kjgzZRnbBEaBWUjOmIUkNQvoJGY BdYn184QgwmoSt7ddZYewtSWWLXzNvICRdRWjRnFqUVlqka6hoV5SUWZ6RkluYmaOrqGBsV5u anFxYnpqTmJSsV5yfu4mRmBAMwDBDsbVv50OMUpyMCmJ8rorX4oQ4kvKT6nMSCzOiC8qzUktP sQow8GhJMF7zgIoJ1iUmp5akZaZA4wtmLQEB4+SCO9XkDRvcUFibnFmOkTqFKMlx4NTu94wcc yZvRtIfuo//IZJiCUvPy9VSpyX3RKoQQCkIaM0D24cLP4vMcpKCfMyAh0oxFOQWpSbWYIq/4p RnINRSZiXC2QKT2ZeCdzWV0AHMQEdVLbnAshBJYkIKakGRpM1gQFih6dvc1h6RuLFhOV7px/k 71//Jzy72oU3csIFO0G5isZulakPWd3TS9mNs5aw2+z7PHkpo+pD1vXMD5YeLegOO6C/ZunfI 9WCtQyNMp1WxUveuT3e7luwYyfrEceHfjJ2W69waAR8Luzcu355yddqyWfLn1oqsFkcE1PObc yT37Z0ohJLcUaioRZzUXEiAIel4gj6AgAA X-Env-Sender: eggi.innovations@gmail.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1490172427!79772190!1 X-Originating-IP: [209.85.223.193] X-SpamReason: No, hits=0.4 required=7.0 tests=HTML_30_40,HTML_MESSAGE, RCVD_BY_IP X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41374 invoked from network); 22 Mar 2017 08:47:08 -0000 Received: from mail-io0-f193.google.com (HELO mail-io0-f193.google.com) (209.85.223.193) by server-2.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Mar 2017 08:47:08 -0000 Received: by mail-io0-f193.google.com with SMTP id n76so9619166ioe.1 for ; Wed, 22 Mar 2017 01:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=hXHbXL1CxartdYgJJvgwtzf+iJxu/7h6PRUmW7uY3OY=; b=a2/EeeoW0+yvf0CLOA6w9WFxTQBpLyAG9rbVcA83gDD76w/sGrlqxrmEfih+wQ1fRX ZYoHYJVEK/cQGVuDpjci56/CJTABvpkFjV8+UzIJtvY5y6phcyLcu7bHg4Q+c4zDdKin baiWZiU3p7KLk9lpf/5/dWAJkXH9gAKWqjFxbcQRSGYdyP13YoigzCrdxUD7gvtrTzaJ pK4zyz6o+MNHU0Q+DK93+/rh0LnlnuSS07kNUYgmxm8/Uw2VBA6i0Zndi5xo4p51TaPz KND0LvWvvp8X0LDpK/rc2mEsyfZMv2KSpVzrlgFQIhmmb5c5+rS1qSQoLJcFym7YiUUN WUbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=hXHbXL1CxartdYgJJvgwtzf+iJxu/7h6PRUmW7uY3OY=; b=XBjTG9dJQqgRzQAkaS9lwGFAWpMRmaw6WjCulhGBnYZldEuvVj0dXajpzMC5bxXd5e bpmwsqAsOaPoIDBwF5GlIFu4f/XiTMnWyj8JFUZKFZ5aQBvNj80RfXo5oFWjG5g+q/nU CS9JdKZaiHEVTzARbdhnmLddhvjbLEKDjLehi8b2YnDpE4xFWSeKINxW8h5q66/9IA/k 9018PVOdYXs7D1MCw05PDgua8vg1tSjSFjNVra3MX7e6PCV44+C5dZ9Kbdq3gPF95Wpx q2OSMKBAPkH2wWTEcFPTNoycVAbipM5Xr/4DZKVLcWqgcoYeFauvMXpCHhaHILfQJhGx q3FQ== X-Gm-Message-State: AFeK/H0wICtjIsNB+piddhngi4194QS4SYrmKwWttUh9j9psyowZ1I/oy9oBwe7haPvI3m3OxpcWItXyul1zkw== X-Received: by 10.107.171.67 with SMTP id u64mr19113540ioe.102.1490172426945; Wed, 22 Mar 2017 01:47:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.19.28 with HTTP; Wed, 22 Mar 2017 01:47:06 -0700 (PDT) In-Reply-To: <20170321161442.tpjjtecv6qmsgmev@citrix.com> References: <2C3140B8-9B96-44F8-A4EA-CDBC07479379@gmail.com> <20170313111439.abjbrw5hyu4eda7y@citrix.com> <20170316162731.l4hzdjky34vsgjkc@citrix.com> <20170321161324.hmsnybth3ktjbzpk@citrix.com> <20170321161442.tpjjtecv6qmsgmev@citrix.com> From: Felix Schmoll Date: Wed, 22 Mar 2017 09:47:06 +0100 Message-ID: To: Wei Liu Cc: xen-devel@lists.xenproject.org Subject: Re: [Xen-devel] [GSoC] GSoC Introduction : Fuzzing Xen hypercall interface X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 2017-03-21 17:14 GMT+01:00 Wei Liu : > On Tue, Mar 21, 2017 at 04:13:24PM +0000, Wei Liu wrote: > > On Mon, Mar 20, 2017 at 09:12:54AM +0100, Felix Schmoll wrote: > > [...] > > > From 7e50f50b2a1e95cbc813354d68c71315d4d1394b Mon Sep 17 00:00:00 2001 > > > From: Felix Schmoll > > > Date: Thu, 16 Mar 2017 07:11:00 +0100 > > > Subject: [PATCH 1/2] First idea on domain_id-hypercall implementation > > > > > > --- > > > xen/arch/x86/hypercall.c | 1 + > > > xen/common/kernel.c | 6 ++++++ > > > xen/include/public/xen.h | 1 + > > > xen/include/xen/hypercall.h | 5 +++++ > > > 4 files changed, 13 insertions(+) > > > > > > diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c > > > index e30181817a..caf8565809 100644 > > > --- a/xen/arch/x86/hypercall.c > > > +++ b/xen/arch/x86/hypercall.c > > > @@ -69,6 +69,7 @@ const hypercall_args_t > > > hypercall_args_table[NR_hypercalls] = > > > ARGS(dm_op, 3), > > > ARGS(mca, 1), > > > ARGS(arch_1, 1), > > > + ARGS(domain_id, 2), > > > }; > > > > > > > I know now. > > > > You did add your hypercall to pv/hypercall.c and hvm/hypercall.c. > > "didn't" > I also noticed that, but it still doesn't work. Here is what I last tried (I removed the unused arguments and made it a little simpler), relative to "staging": diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 2d97d36c38..1e152c8a07 100644 I wasn't sure if to modify Config.mk or Rules.mk for the CFLAGS variable, so I went with the latter since it was in the subfolder. Felix --- 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..7677520290 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -125,6 +125,7 @@ static const hypercall_table_t hvm_hypercall_table[] = { HYPERCALL(hvm_op), HYPERCALL(sysctl), HYPERCALL(domctl), + HYPERCALL(domain_id), #ifdef CONFIG_TMEM HYPERCALL(tmem_op), #endif diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c index e30181817a..b68d0aef40 100644 --- a/xen/arch/x86/hypercall.c +++ b/xen/arch/x86/hypercall.c @@ -45,6 +45,7 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] = COMP(set_timer_op, 1, 2), ARGS(event_channel_op_compat, 1), ARGS(xen_version, 2), + ARGS(domain_id, 0), ARGS(console_io, 3), ARGS(physdev_op_compat, 1), ARGS(grant_table_op, 3), diff --git a/xen/arch/x86/pv/hypercall.c b/xen/arch/x86/pv/hypercall.c index 9d29d2f088..1e67eb3312 100644 --- a/xen/arch/x86/pv/hypercall.c +++ b/xen/arch/x86/pv/hypercall.c @@ -50,6 +50,7 @@ static const hypercall_table_t pv_hypercall_table[] = { COMPAT_CALL(set_timer_op), HYPERCALL(event_channel_op_compat), COMPAT_CALL(xen_version), + HYPERCALL(domain_id), HYPERCALL(console_io), COMPAT_CALL(physdev_op_compat), COMPAT_CALL(grant_table_op), 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, Here is also the patch for the second subtask: diff --git a/xen/Rules.mk b/xen/Rules.mk index 77bcd44922..254cc4381e 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -46,6 +46,7 @@ else CFLAGS += -O2 -fomit-frame-pointer endif +CFLAGS += -fsanitize-coverage=trace-pc CFLAGS += -nostdinc -fno-builtin -fno-common CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith CFLAGS += -pipe -g -D__XEN__ -include $(BASEDIR)/include/xen/config.h diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 84618715dc..77b22effb3 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -238,6 +238,8 @@ void __init do_initcalls(void) # define DO(fn) long do_##fn +void __sanitizer_cov_trace_pc(void) { return; } + #endif /* diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h index cc99aea57d..12517b5e90 100644 --- a/xen/include/xen/hypercall.h +++ b/xen/include/xen/hypercall.h @@ -19,6 +19,8 @@ #include #include +extern void __sanitizer_cov_trace_pc(void); + extern long do_sched_op( int cmd,