From patchwork Fri Oct 6 18:27:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 9990225 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 13FFE60247 for ; Fri, 6 Oct 2017 18:30:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A97C28A3A for ; Fri, 6 Oct 2017 18:30:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F399B28DAC; Fri, 6 Oct 2017 18:30:04 +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 6DB2428A3A for ; Fri, 6 Oct 2017 18:30:04 +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 1e0XLh-0000uo-P5; Fri, 06 Oct 2017 18:27:49 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0XLg-0000ub-NY for xen-devel@lists.xenproject.org; Fri, 06 Oct 2017 18:27:48 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 3F/4D-02045-32BC7D95; Fri, 06 Oct 2017 18:27:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprCIsWRWlGSWpSXmKPExsXitHSDva7y6eu RBme+iVh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmPPt5lKWgXr7j/ZitbA+M1oS5GTg4JAX+J 1vmv2UFsNgFdiaYtf9lAbBEBaYn+Oe1AcS4OZoH5TBKH5y1mBUkICzhINL9uZepi5OBgEVCRW PFHG8TkFfCUaL9fAzFSTuL88Z/MIDangJfEl/trwcYLAZXsWHuWGaRcSEBNYu76eJAwr4CgxM mZT1hAbGYBCYmDL14wT2DknYUkNQtJagEj0ypG9eLUorLUIl1LvaSizPSMktzEzBxdQwNjvdz U4uLE9NScxKRiveT83E2MwLCpZ2Bg3MH4+qfTIUZJDiYlUV6GE9cjhfiS8lMqMxKLM+KLSnNS iw8xynBwKEnwtpwEygkWpaanVqRl5gADGCYtwcGjJMJbA5LmLS5IzC3OTIdInWI05ji26fIfJ o6Om3f/MAmx5OXnpUqJ8zqDlAqAlGaU5sENgkXWJUZZKWFeRgYGBiGegtSi3MwSVPlXjOIcjE rCvN0gU3gy80rg9r0COoUJ6JQ5TVdATilJREhJNTBy1Py7MmGOh7Dm1z8cV0vfG/0L/Pf75LG lJS1hb3oMuf+JV1W/VH8kyZU/1+z2o/3VfnMV51z5ryo+raaqz9d2+rpr0fdjeFT2fJOrOf4t bb7pSeYpl0M3HxTdVvvkwfIHYct2ecUmzlvq0CH387N125vkzW55CrF8TE4RX+Kn+N6+9fLA9 UdMSizFGYmGWsxFxYkAgLbUyqcCAAA= X-Env-Sender: prvs=44560dde8=Ian.Jackson@citrix.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1507314461!109131161!2 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 19489 invoked from network); 6 Oct 2017 18:27:47 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-3.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 6 Oct 2017 18:27:47 -0000 X-IronPort-AV: E=Sophos;i="5.42,484,1500940800"; d="scan'208";a="450777167" From: Ian Jackson To: Date: Fri, 6 Oct 2017 19:27:18 +0100 Message-ID: <1507314444-30835-3-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1507314444-30835-1-git-send-email-ian.jackson@eu.citrix.com> References: <1507314444-30835-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Cc: Juergen Gross , Stefano Stabellini , Ian Jackson , Ross Lagerwall , Anthony PERARD , xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 2/8] xen: restrict: use xentoolcore_restrict_all 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 And insist that it works. Drop individual use of xendevicemodel_restrict and xenforeignmemory_restrict. These are not actually effective in this version of qemu, because qemu has a large number of fds open onto various Xen control devices. The restriction arrangements are still not right, because the restriction needs to be done very late - after qemu has opened all of its control fds. xentoolcore_restrict_all and xentoolcore.h are available in Xen 4.10 and later, only. Provide a compatibility stub. And drop the compatibility stubs for the old functions. Signed-off-by: Ian Jackson --- v2: Modify the compatibility code, too. Bump this patch ahead of "defer call to xen_restrict until running" Retain call to xentoolcore_restrict_all Signed-off-by: Ian Jackson --- include/hw/xen/xen_common.h | 46 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index 86c7f26..3f44a63 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -91,6 +91,16 @@ static inline void *xenforeignmemory_map2(xenforeignmemory_handle *h, return xenforeignmemory_map(h, dom, prot, pages, arr, err); } +static inline int xentoolcore_restrict_all(domid_t domid) +{ + errno = ENOTTY; + return -1; +} + +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 41000 */ + +#include + #endif #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 40900 @@ -218,20 +228,6 @@ static inline int xendevicemodel_set_mem_type( return xc_hvm_set_mem_type(dmod, domid, mem_type, first_pfn, nr); } -static inline int xendevicemodel_restrict( - xendevicemodel_handle *dmod, domid_t domid) -{ - errno = ENOTTY; - return -1; -} - -static inline int xenforeignmemory_restrict( - xenforeignmemory_handle *fmem, domid_t domid) -{ - errno = ENOTTY; - return -1; -} - #else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40900 */ #undef XC_WANT_COMPAT_DEVICEMODEL_API @@ -290,28 +286,8 @@ static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn, static inline int xen_restrict(domid_t domid) { int rc; - - /* Attempt to restrict devicemodel operations */ - rc = xendevicemodel_restrict(xen_dmod, domid); + rc = xentoolcore_restrict_all(domid); trace_xen_domid_restrict(rc ? errno : 0); - - if (rc < 0) { - /* - * If errno is ENOTTY then restriction is not implemented so - * there's no point in trying to restrict other types of - * operation, but it should not be treated as a failure. - */ - if (errno == ENOTTY) { - return 0; - } - - return rc; - } - - /* Restrict foreignmemory operations */ - rc = xenforeignmemory_restrict(xen_fmem, domid); - trace_xen_domid_restrict(rc ? errno : 0); - return rc; }