From patchwork Thu Apr 20 17:59:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jennifer Herbert X-Patchwork-Id: 9691077 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 E94986037F for ; Thu, 20 Apr 2017 18:02:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF2EF28479 for ; Thu, 20 Apr 2017 18:02:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D166B284F1; Thu, 20 Apr 2017 18:02:42 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 6CAA128479 for ; Thu, 20 Apr 2017 18:02:42 +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 1d1GNB-0004oa-IU; Thu, 20 Apr 2017 18:00:05 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1GNA-0004gI-Ej for xen-devel@lists.xen.org; Thu, 20 Apr 2017 18:00:04 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id 04/69-03587-327F8F85; Thu, 20 Apr 2017 18:00:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRWlGSWpSXmKPExsXitHSDva7y9x8 RBnfnCFgs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBmXP+xkLHiiWPGpw7OBsVeyi5GTQ0LAX6L1 ahMbiM0moCzRO/E1M4gtIqAucbrjImsXIxcHs8BZRonLD3eDJYQFoiWOznrIBGKzCKhKLH15h 7GLkYODV8BL4uUpHoiZchLnj/8EKxcS0JDoP3ifFcTmFRCUODnzCQuIzSwgIXHwxQvmCYzcs5 CkZiFJLWBkWsWoXpxaVJZapGukl1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kRGAg MQLCDcdlfp0OMkhxMSqK8anN/RAjxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4D33FSgnWJSanlqR lpkDDEmYtAQHj5II7xWQNG9xQWJucWY6ROoUo6KUOO87kIQASCKjNA+uDRYHlxhlpYR5GYEOE eIpSC3KzSxBlX/FKM7BqCTMq/MNaApPZl4J3PRXQIuZgBaf9QNbXJKIkJJqYJym7jLtTNdvNf NWqYSVJYob1BOnXnogOfN4aNDLkNovmxW322vOuskx882UwDUmIb+it2pkv9J9477nev2Nro7 i7v9bD8d/6LuudSZN2qrnhaDI2Y2+FzcHzZys5DBnRuj8zaVaeUc3MTbPe/pY2fjijecfuLhm qdjP19V1+GCbInrq4NwlbBFKLMUZiYZazEXFiQDH1l4mfgIAAA== X-Env-Sender: prvs=276ecb9c3=jennifer.herbert@citrix.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1492711201!60081923!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64263 invoked from network); 20 Apr 2017 18:00:02 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-16.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 20 Apr 2017 18:00:02 -0000 X-IronPort-AV: E=Sophos;i="5.37,225,1488844800"; d="scan'208";a="428870009" From: To: Xen-devel Date: Thu, 20 Apr 2017 17:59:46 +0000 Message-ID: <1492711189-2857-1-git-send-email-jennifer.herbert@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Cc: Andrew Cooper , Julien Grall , Paul Durrant , Jennifer Herbert , Jan Beulich Subject: [Xen-devel] [PATCH 1/4] hvm/dmop: Box dmop_args rather than passing multiple parameters around 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 From: Jennifer Herbert No functional change. Signed-off-by: Jennifer Herbert Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Reviewed-by: Paul Durrant --- CC: Paul Durrant CC: Andrew Cooper CC: Jan Beulich CC: Julien Grall --- xen/arch/x86/hvm/dm.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c index d72b7bd..fb4bcec 100644 --- a/xen/arch/x86/hvm/dm.c +++ b/xen/arch/x86/hvm/dm.c @@ -25,6 +25,13 @@ #include +struct dmop_args { + domid_t domid; + unsigned int nr_bufs; + /* Reserve enough buf elements for all current hypercalls. */ + struct xen_dm_op_buf buf[2]; +}; + static bool copy_buf_from_guest(const xen_dm_op_buf_t bufs[], unsigned int nr_bufs, void *dst, unsigned int idx, size_t dst_size) @@ -287,16 +294,14 @@ static int inject_event(struct domain *d, return 0; } -static int dm_op(domid_t domid, - unsigned int nr_bufs, - xen_dm_op_buf_t bufs[]) +static int dm_op(struct dmop_args *op_args) { struct domain *d; struct xen_dm_op op; bool const_op = true; long rc; - rc = rcu_lock_remote_domain_by_id(domid, &d); + rc = rcu_lock_remote_domain_by_id(op_args->domid, &d); if ( rc ) return rc; @@ -307,7 +312,7 @@ static int dm_op(domid_t domid, if ( rc ) goto out; - if ( !copy_buf_from_guest(bufs, nr_bufs, &op, 0, sizeof(op)) ) + if ( !copy_buf_from_guest(&op_args->buf[0], op_args->nr_bufs, &op, 0, sizeof(op)) ) { rc = -EFAULT; goto out; @@ -466,10 +471,10 @@ static int dm_op(domid_t domid, if ( data->pad ) break; - if ( nr_bufs < 2 ) + if ( op_args->nr_bufs < 2 ) break; - rc = track_dirty_vram(d, data->first_pfn, data->nr, &bufs[1]); + rc = track_dirty_vram(d, data->first_pfn, data->nr, &op_args->buf[1]); break; } @@ -564,7 +569,7 @@ static int dm_op(domid_t domid, if ( (!rc || rc == -ERESTART) && !const_op && - !copy_buf_to_guest(bufs, nr_bufs, 0, &op, sizeof(op)) ) + !copy_buf_to_guest(&op_args->buf[0], op_args->nr_bufs, 0, &op, sizeof(op)) ) rc = -EFAULT; out: @@ -587,20 +592,21 @@ CHECK_dm_op_set_mem_type; CHECK_dm_op_inject_event; CHECK_dm_op_inject_msi; -#define MAX_NR_BUFS 2 - int compat_dm_op(domid_t domid, unsigned int nr_bufs, XEN_GUEST_HANDLE_PARAM(void) bufs) { - struct xen_dm_op_buf nat[MAX_NR_BUFS]; + struct dmop_args args; unsigned int i; int rc; - if ( nr_bufs > MAX_NR_BUFS ) + if ( nr_bufs > ARRAY_SIZE(args.buf) ) return -E2BIG; - for ( i = 0; i < nr_bufs; i++ ) + args.domid = domid; + args.nr_bufs = nr_bufs; + + for ( i = 0; i < args.nr_bufs; i++ ) { struct compat_dm_op_buf cmp; @@ -610,12 +616,12 @@ int compat_dm_op(domid_t domid, #define XLAT_dm_op_buf_HNDL_h(_d_, _s_) \ guest_from_compat_handle((_d_)->h, (_s_)->h) - XLAT_dm_op_buf(&nat[i], &cmp); + XLAT_dm_op_buf(&args.buf[i], &cmp); #undef XLAT_dm_op_buf_HNDL_h } - rc = dm_op(domid, nr_bufs, nat); + rc = dm_op(&args); if ( rc == -ERESTART ) rc = hypercall_create_continuation(__HYPERVISOR_dm_op, "iih", @@ -628,16 +634,19 @@ long do_dm_op(domid_t domid, unsigned int nr_bufs, XEN_GUEST_HANDLE_PARAM(xen_dm_op_buf_t) bufs) { - struct xen_dm_op_buf nat[MAX_NR_BUFS]; + struct dmop_args args; int rc; - if ( nr_bufs > MAX_NR_BUFS ) + if ( nr_bufs > ARRAY_SIZE(args.buf) ) return -E2BIG; - if ( copy_from_guest_offset(nat, bufs, 0, nr_bufs) ) + args.domid = domid; + args.nr_bufs = nr_bufs; + + if ( copy_from_guest_offset(&args.buf[0], bufs, 0, args.nr_bufs) ) return -EFAULT; - rc = dm_op(domid, nr_bufs, nat); + rc = dm_op(&args); if ( rc == -ERESTART ) rc = hypercall_create_continuation(__HYPERVISOR_dm_op, "iih",