From patchwork Wed Sep 28 09:42:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9353667 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 150156077A for ; Wed, 28 Sep 2016 09:45:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0494A29478 for ; Wed, 28 Sep 2016 09:45:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA5C52947C; Wed, 28 Sep 2016 09:45:01 +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, UNPARSEABLE_RELAY 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 6737329478 for ; Wed, 28 Sep 2016 09:45:01 +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 1bpBO9-0000F2-1z; Wed, 28 Sep 2016 09:42:53 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpBO7-000066-1k for xen-devel@lists.xenproject.org; Wed, 28 Sep 2016 09:42:51 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id 97/ED-03778-A909BE75; Wed, 28 Sep 2016 09:42:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsUyZ7p8oO60Ca/ DDV4/M7L4vmUykwOjx+EPV1gCGKNYM/OS8isSWDO2//zFVLBWoKJnXitbA2MLbxcjJ4eQQAeT xKLTAl2MXED2N0aJyx9uMUM4Gxkl+k99YoNwJjBKbNg6laWLkYODTcBE4s0qR5BuEQFTie0TT 7KA1DALTGOU+HTqCBNIQlggXuLV20vsIDaLgKrEvrdvmUFsXgF3iZY1T5lB5kgIyEs8u10PYn IChe8f9oU4yE3ie8NjFhBbQsBYom9WH8sERr4FjAyrGNWLU4vKUot0LfWSijLTM0pyEzNzdA0 NTPVyU4uLE9NTcxKTivWS83M3MQKDhAEIdjCubXU+xCjJwaQkyrs5/HW4EF9SfkplRmJxRnxR aU5q8SFGGQ4OJQlehX6gnGBRanpqRVpmDjBcYdISHDxKIryRIGne4oLE3OLMdIjUKUZFKXHe4 31ACQGQREZpHlwbLEYuMcpKCfMyAh0ixFOQWpSbWYIq/4pRnINRSZg3E2Q8T2ZeCdz0V0CLmY AWLz3xAmRxSSJCSqqBUS9O+MxsgcgjmwX7gk1+WCaz749XY7hUe2St9rezbX6HXlrbbqubYKx 2+JNI17kLtSrJ57+42XvIKqoX/+Z50/L4ZL9/90dB3Tk3/hg7HvkbeaFYsnlWY5LAopNsOzVs DlxYElDO0ac2eROTzVV2luANImI79xRdyPgetFNO1T9Up9zGS+GUEktxRqKhFnNRcSIA8bCKA 4wCAAA= X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-14.tower-206.messagelabs.com!1475055765!25561846!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41336 invoked from network); 28 Sep 2016 09:42:46 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-14.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Sep 2016 09:42:46 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8S9gfdd020998 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Sep 2016 09:42:42 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8S9gfOR009351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Sep 2016 09:42:41 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8S9gf8p018590; Wed, 28 Sep 2016 09:42:41 GMT Received: from localhost.localdomain.com (/209.6.196.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Sep 2016 02:42:41 -0700 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org Date: Wed, 28 Sep 2016 05:42:23 -0400 Message-Id: <1475055746-22401-10-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1475055746-22401-1-git-send-email-konrad.wilk@oracle.com> References: <1475055746-22401-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: Wei Liu , Ian Jackson , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v1 09/12] tmem: Check version and maxpools when XEN_SYSCTL_TMEM_SET_CLIENT_INFO 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP is called. If they are different from what the hypervisor can support we will get the appropiate errors. Signed-off-by: Konrad Rzeszutek Wilk Acked-by: Wei Liu --- Cc: Ian Jackson Cc: Wei Liu v1: First submission. --- tools/libxc/xc_tmem.c | 1 - xen/common/tmem_control.c | 6 ++++++ xen/include/public/sysctl.h | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/libxc/xc_tmem.c b/tools/libxc/xc_tmem.c index cb0dfa1..7873674 100644 --- a/tools/libxc/xc_tmem.c +++ b/tools/libxc/xc_tmem.c @@ -383,7 +383,6 @@ int xc_tmem_restore(xc_interface *xch, int dom, int io_fd) if ( read_exact(io_fd, &info, sizeof(info)) ) return -1; - /* FIXME check here to ensure no version mismatch or maxpools mismatch */ if ( xc_tmem_control(xch,0,XEN_SYSCTL_TMEM_OP_RESTORE_BEGIN,dom,0,0,NULL) < 0 ) return -1; diff --git a/xen/common/tmem_control.c b/xen/common/tmem_control.c index 942d4c9..6f1de9d 100644 --- a/xen/common/tmem_control.c +++ b/xen/common/tmem_control.c @@ -270,6 +270,12 @@ static int __tmemc_set_var(struct client *client, if ( copy_from_guest(&info, buf, 1) ) return -EFAULT; + if ( info.version != TMEM_SPEC_VERSION ) + return -EOPNOTSUPP; + + if ( info.maxpools > MAX_POOLS_PER_DOMAIN ) + return -ERANGE; + if ( info.weight != client->info.weight ) { old_weight = client->info.weight; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 52898a7..36e2fd8 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -787,8 +787,9 @@ struct tmem_handle { * during migration. */ struct tmem_client { - uint32_t version; - uint32_t maxpools; + uint32_t version; /* If mismatched we will get XEN_ENOSPC. */ + uint32_t maxpools; /* If greater than what hypervisor supports, will get + XEN_ERANGE. */ union { /* See TMEM_CLIENT_[COMPRESS,FROZEN] */ uint32_t raw; struct {