From patchwork Mon Oct 23 09:05:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 10022189 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 03FC5603D7 for ; Mon, 23 Oct 2017 09:07:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC9AB2880C for ; Mon, 23 Oct 2017 09:07:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1C6328812; Mon, 23 Oct 2017 09:07:31 +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 D6AFD2880C for ; Mon, 23 Oct 2017 09:07:30 +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 1e6Yfg-0007JV-3x; Mon, 23 Oct 2017 09:05:20 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e6Yfe-0007J3-SU for xen-devel@lists.xen.org; Mon, 23 Oct 2017 09:05:18 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 45/30-31244-EC0BDE95; Mon, 23 Oct 2017 09:05:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsXitHRDpO7ZDW8 jDTZ9N7ZY8nExiwOjx9Hdv5kCGKNYM/OS8isSWDO2ntrCXvBfvGJa+3q2BsY3Ql2MnBwSAv4S 949cZgex2QQMJG5d+s4MYosIyEqs7poDFOfiYBZ4zSRx+9w7JpCEsICTROvXZ2wgNouAqsS8g 71gzbwCthKHzn1hhxgqJ7Hn4gwwm1PATuLZ3+WsILYQUM2eXT9YIGw1ibfLz7BA9ApKnJz5BM xmFpCQOPjiBfMERt5ZSFKzkKQWMDKtYlQvTi0qSy3StdRLKspMzyjJTczM0TU0MNPLTS0uTkx PzUlMKtZLzs/dxAgMHgYg2MF4d1PAIUZJDiYlUd7fOW8jhfiS8lMqMxKLM+KLSnNSiw8xynBw KEnwPlkPlBMsSk1PrUjLzAGGMUxagoNHSYR3Kkiat7ggMbc4Mx0idYpRl6Pj5t0/TEIsefl5q VLivO9BigRAijJK8+BGwGLqEqOslDAvI9BRQjwFqUW5mSWo8q8YxTkYlYR574NM4cnMK4Hb9A roCCagI2Tt34AcUZKIkJJqYGRIbO36XeqcGD6fK/gj92flieJTCniED62Njef2vLhwd7eja9l JpbtP59nbs+3Z+M784LH3aX17Ygo7umJ+HLn3bOZe9Qs/drMySIu/3bl14o7vl8I7n/puns5b /zw5sfqB9zr++KwLSgeL/u3c9aFko8CtyK2SLXnTNv75eObp5TV9QjrnzVOVWIozEg21mIuKE wFJ4jp5pAIAAA== X-Env-Sender: prvs=462d8fd40=ross.lagerwall@citrix.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1508749515!81107749!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43803 invoked from network); 23 Oct 2017 09:05:17 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-11.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 23 Oct 2017 09:05:17 -0000 X-IronPort-AV: E=Sophos;i="5.43,422,1503360000"; d="scan'208";a="447622357" From: Ross Lagerwall To: Date: Mon, 23 Oct 2017 10:05:07 +0100 Message-ID: <20171023090509.4338-4-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171023090509.4338-1-ross.lagerwall@citrix.com> References: <20171023090509.4338-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 v2 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr 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_pin_memory_cacheattr to allow a deprivileged QEMU to pin the caching type of RAM after moving the VRAM. It is equivalent to XEN_DOMCTL_pin_memory_cacheattr. Signed-off-by: Ross Lagerwall Reviewed-by: Paul Durrant Reviewed-by: Jan Beulich --- Changed in v2: * Check pad is 0. xen/arch/x86/hvm/dm.c | 18 ++++++++++++++++++ xen/include/public/hvm/dm_op.h | 14 ++++++++++++++ xen/include/xlat.lst | 1 + 3 files changed, 33 insertions(+) diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c index 0027567..42d02cc 100644 --- a/xen/arch/x86/hvm/dm.c +++ b/xen/arch/x86/hvm/dm.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -670,6 +671,22 @@ static int dm_op(const struct dmop_args *op_args) break; } + case XEN_DMOP_pin_memory_cacheattr: + { + const struct xen_dm_op_pin_memory_cacheattr *data = + &op.u.pin_memory_cacheattr; + + if ( data->pad ) + { + rc = -EINVAL; + break; + } + + rc = hvm_set_mem_pinned_cacheattr(d, data->start, data->end, + data->type); + break; + } + default: rc = -EOPNOTSUPP; break; @@ -700,6 +717,7 @@ CHECK_dm_op_inject_event; CHECK_dm_op_inject_msi; CHECK_dm_op_remote_shutdown; CHECK_dm_op_add_to_physmap; +CHECK_dm_op_pin_memory_cacheattr; 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 f685110..f9c86b8 100644 --- a/xen/include/public/hvm/dm_op.h +++ b/xen/include/public/hvm/dm_op.h @@ -384,6 +384,19 @@ struct xen_dm_op_add_to_physmap { uint64_aligned_t gpfn; /* Starting GPFN where the GMFNs should appear. */ }; +/* + * XEN_DMOP_pin_memory_cacheattr : Pin caching type of RAM space. + * Identical to XEN_DOMCTL_pin_mem_cacheattr. + */ +#define XEN_DMOP_pin_memory_cacheattr 18 + +struct xen_dm_op_pin_memory_cacheattr { + uint64_aligned_t start; /* Start gfn. */ + uint64_aligned_t end; /* End gfn. */ + uint32_t type; /* XEN_DOMCTL_MEM_CACHEATTR_* */ + uint32_t pad; +}; + struct xen_dm_op { uint32_t op; uint32_t pad; @@ -406,6 +419,7 @@ struct xen_dm_op { map_mem_type_to_ioreq_server; struct xen_dm_op_remote_shutdown remote_shutdown; struct xen_dm_op_add_to_physmap add_to_physmap; + struct xen_dm_op_pin_memory_cacheattr pin_memory_cacheattr; } u; }; diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst index d40bac6..fffb308 100644 --- a/xen/include/xlat.lst +++ b/xen/include/xlat.lst @@ -65,6 +65,7 @@ ? dm_op_inject_msi hvm/dm_op.h ? dm_op_ioreq_server_range hvm/dm_op.h ? dm_op_modified_memory hvm/dm_op.h +? dm_op_pin_memory_cacheattr hvm/dm_op.h ? dm_op_remote_shutdown hvm/dm_op.h ? dm_op_set_ioreq_server_state hvm/dm_op.h ? dm_op_set_isa_irq_level hvm/dm_op.h