From patchwork Wed Oct 18 14:03:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 10014791 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 B557D603FF for ; Wed, 18 Oct 2017 14:07:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA78C28BDB for ; Wed, 18 Oct 2017 14:07:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F58828BEA; Wed, 18 Oct 2017 14:07:26 +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 519D128BDB for ; Wed, 18 Oct 2017 14:07:26 +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 1e4oyG-0007st-GE; Wed, 18 Oct 2017 14:05:20 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4oyF-0007sD-Fj for xen-devel@lists.xen.org; Wed, 18 Oct 2017 14:05:19 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 2E/02-16147-E9F57E95; Wed, 18 Oct 2017 14:05:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsXitHSDve7s+Oe RBpdnsFks+biYxYHR4+ju30wBjFGsmXlJ+RUJrBl/b25mLmiRqJj4s5exgXGrUBcjJ4eEgL/E 2ZcPmEFsNgEDiVuXvoPZIgLqEqc7LrJ2MXJxMAu8ZpK4fe4dE0hCWMBG4sWjCWBFLAKqEsd/9 IPZvAJ2ElN7Z7NBDJWT2HNxBjuIzSlgLzG7rR/MFgKqWXNtJhuErSbxdvkZFoheQYmTM5+A2c wCEhIHX7xgnsDIOwtJahaS1AJGplWMGsWpRWWpRbpGZnpJRZnpGSW5iZk5uoYGxnq5qcXFiem pOYlJxXrJ+bmbGIHhU8/AwLiDsWGv3yFGSQ4mJVFe3QPPIoX4kvJTKjMSizPii0pzUosPMcpw cChJ8C6Oex4pJFiUmp5akZaZAwxkmLQEB4+SCO/3WKA0b3FBYm5xZjpE6hSjLkfHzbt/mIRY8 vLzUqXEeZtAZgiAFGWU5sGNgEXVJUZZKWFeRgYGBiGegtSi3MwSVPlXjOIcjErCvCUgU3gy80 rgNr0COoIJ6Ih1Tk9AjihJREhJNTBar//JvllhTmutJlP1zo3/ZrmZRvbXrd2VNOnfPga9LL7 rUSxSilHK/mHO+kw3X/ZtFDVeup5d8+t6mRNa6h71/F9D93x01t+4TElCOsNhHdvvxeEmPdNu f+I7c3H5xJ+HmT+xTjGZpuFUeOfS/8Vf5SRf9UScv/v0HNN/Tq5T+6UPTKtP/a2ixFKckWiox VxUnAgAZHigaqUCAAA= X-Env-Sender: prvs=457f25213=ross.lagerwall@citrix.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1508335512!106807622!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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14937 invoked from network); 18 Oct 2017 14:05:14 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-15.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 18 Oct 2017 14:05:14 -0000 X-IronPort-AV: E=Sophos;i="5.43,397,1503360000"; d="scan'208";a="454799340" From: Ross Lagerwall To: Xen-devel Date: Wed, 18 Oct 2017 15:03:36 +0100 Message-ID: <20171018140339.13888-3-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171018140339.13888-1-ross.lagerwall@citrix.com> References: <20171018140339.13888-1-ross.lagerwall@citrix.com> MIME-Version: 1.0 Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Ross Lagerwall , Jan Beulich Subject: [Xen-devel] [PATCH v1 2/5] xen: Provide XEN_DMOP_add_to_physmap 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 Provide XEN_DMOP_add_to_physmap, a limited version of XENMEM_add_to_physmap to allow a deprivileged QEMU to move VRAM when a guest programs its BAR. It is equivalent to XENMEM_add_to_physmap with space == XENMAPSPACE_gmfn. Signed-off-by: Ross Lagerwall --- xen/arch/x86/hvm/dm.c | 17 +++++++++++++++++ xen/include/public/hvm/dm_op.h | 14 ++++++++++++++ xen/include/xlat.lst | 1 + 3 files changed, 32 insertions(+) diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c index 32ade95..432a863 100644 --- a/xen/arch/x86/hvm/dm.c +++ b/xen/arch/x86/hvm/dm.c @@ -640,6 +640,22 @@ static int dm_op(const struct dmop_args *op_args) break; } + case XEN_DMOP_add_to_physmap: + { + const struct xen_dm_op_add_to_physmap *data = + &op.u.add_to_physmap; + struct xen_add_to_physmap xatp = { + .domid = op_args->domid, + .space = XENMAPSPACE_gmfn, + .idx = data->idx, + .gpfn = data->gpfn, + }; + + rc = xenmem_add_to_physmap(d, &xatp, + XENMEM_add_to_physmap >> MEMOP_EXTENT_SHIFT); + break; + } + default: rc = -EOPNOTSUPP; break; @@ -669,6 +685,7 @@ CHECK_dm_op_set_mem_type; CHECK_dm_op_inject_event; CHECK_dm_op_inject_msi; CHECK_dm_op_remote_shutdown; +CHECK_dm_op_add_to_physmap; int compat_dm_op(domid_t domid, unsigned int nr_bufs, diff --git a/xen/include/public/hvm/dm_op.h b/xen/include/public/hvm/dm_op.h index e173085..88aace7 100644 --- a/xen/include/public/hvm/dm_op.h +++ b/xen/include/public/hvm/dm_op.h @@ -368,6 +368,19 @@ struct xen_dm_op_remote_shutdown { /* (Other reason values are not blocked) */ }; +/* + * XEN_DMOP_add_to_physmap : Sets the GPFN at which a particular page appears + * in the specified guest's pseudophysical address + * space. Identical to XENMEM_add_to_physmap with + * space == XENMAPSPACE_gmfn. + */ +#define XEN_DMOP_add_to_physmap 17 + +struct xen_dm_op_add_to_physmap { + uint64_aligned_t idx; /* Index into GMFN space. */ + uint64_aligned_t gpfn; /* GPFN in domid where the GMFN should appear. */ +}; + struct xen_dm_op { uint32_t op; uint32_t pad; @@ -389,6 +402,7 @@ struct xen_dm_op { struct xen_dm_op_map_mem_type_to_ioreq_server map_mem_type_to_ioreq_server; struct xen_dm_op_remote_shutdown remote_shutdown; + struct xen_dm_op_add_to_physmap add_to_physmap; } u; }; diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst index 4346cbe..d40bac6 100644 --- a/xen/include/xlat.lst +++ b/xen/include/xlat.lst @@ -57,6 +57,7 @@ ? grant_entry_v2 grant_table.h ? gnttab_swap_grant_ref grant_table.h ! dm_op_buf hvm/dm_op.h +? dm_op_add_to_physmap hvm/dm_op.h ? dm_op_create_ioreq_server hvm/dm_op.h ? dm_op_destroy_ioreq_server hvm/dm_op.h ? dm_op_get_ioreq_server_info hvm/dm_op.h