From patchwork Sat Oct 29 08:59:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 9403523 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 6A38260587 for ; Sat, 29 Oct 2016 09:03:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BD5F2A4BF for ; Sat, 29 Oct 2016 09:03:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 508F12A512; Sat, 29 Oct 2016 09:03:44 +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 E47902A4BF for ; Sat, 29 Oct 2016 09:03:43 +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 1c0PUx-0001re-Q6; Sat, 29 Oct 2016 09:00:19 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c0PUx-0001rY-7v for xen-devel@lists.xenproject.org; Sat, 29 Oct 2016 09:00:19 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id D8/D7-18083-22564185; Sat, 29 Oct 2016 09:00:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRWlGSWpSXmKPExsXitHSDva5Sqki EwcbfLBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bD+fvsBf/EKnaubWRuYHwr0MXIySEh4C8x f/p6dhCbTUBH4uLcnWwgtohArMS6xqtMXYxcHMwC+xklTi3vYwJJCAsES3ycehqsgUVAVaLj6 iewBl4BF4lbj9eyQQzVlXh47jdrFyMHB6eAq0TfIlWQsBBQSeP3B6wQ5YISJ2c+YQGxmQU0JV q3/2aHsOUlmrfOZoaoV5Ton/cAaiS3xO3TU5knMPLPQtI+C0n7LCTtCxiZVzFqFKcWlaUW6Ro a6yUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBAYhAxDsYPyyLOAQoyQHk5Io77cv whFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHinJotECAkWpaanVqRl5gDjASYtwcGjJMLbB5LmL S5IzC3OTIdInWJUlBLnzQFJCIAkMkrz4NpgMXiJUVZKmJcR6BAhnoLUotzMElT5V4ziHIxKwr znQKbwZOaVwE1/BbSYCWjx9HQBkMUliQgpqQbGWa/SPu/uvaN5flXOUev/i4KClSyCJx765cf i2OMhVHflR/1M1pof26Qlnd6eiBVWm+0opPKv7ZLLJvurs1PXyRV4R5+SfJmqoNjuws9esOD8 Gg3vw8t+G58MsCyzYbrCwfYwc0rfpSO3LnXlbdh4LHR76iTm/6yLnxp6PXGy//5rVUup4X4eJ ZbijERDLeai4kQA48W7EbwCAAA= X-Env-Sender: prvs=103fc987f=roger.pau@citrix.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1477731615!32644329!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.0.13; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51962 invoked from network); 29 Oct 2016 09:00:17 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-5.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 29 Oct 2016 09:00:17 -0000 X-IronPort-AV: E=Sophos;i="5.31,414,1473120000"; d="scan'208";a="395329327" From: Roger Pau Monne To: , , Date: Sat, 29 Oct 2016 10:59:48 +0200 Message-ID: <1477731601-10926-3-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) In-Reply-To: <1477731601-10926-1-git-send-email-roger.pau@citrix.com> References: <1477731601-10926-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: George Dunlap , Andrew Cooper , Tim Deegan , Jan Beulich , Roger Pau Monne Subject: [Xen-devel] [PATCH v3.1 02/15] xen/x86: fix return value of *_set_allocation functions 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 Return should be an int. Signed-off-by: Roger Pau Monné Acked-by: George Dunlap Acked-by: Tim Deegan --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Cc: Tim Deegan --- Changes since v2: - Also fix the callers to treat the return value as an int. - Don't convert the pages parameter to unsigned long. --- xen/arch/x86/mm/hap/hap.c | 8 +++----- xen/arch/x86/mm/shadow/common.c | 12 +++++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index 3218fa2..f099e94 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -334,7 +334,7 @@ hap_get_allocation(struct domain *d) /* Set the pool of pages to the required number of pages. * Returns 0 for success, non-zero for failure. */ -static unsigned int +static int hap_set_allocation(struct domain *d, unsigned int pages, int *preempted) { struct page_info *pg; @@ -468,14 +468,12 @@ int hap_enable(struct domain *d, u32 mode) old_pages = d->arch.paging.hap.total_pages; if ( old_pages == 0 ) { - unsigned int r; paging_lock(d); - r = hap_set_allocation(d, 256, NULL); - if ( r != 0 ) + rv = hap_set_allocation(d, 256, NULL); + if ( rv != 0 ) { hap_set_allocation(d, 0, NULL); paging_unlock(d); - rv = -ENOMEM; goto out; } paging_unlock(d); diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index 21607bf..065bdc7 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -1613,9 +1613,9 @@ shadow_free_p2m_page(struct domain *d, struct page_info *pg) * Input will be rounded up to at least shadow_min_acceptable_pages(), * plus space for the p2m table. * Returns 0 for success, non-zero for failure. */ -static unsigned int sh_set_allocation(struct domain *d, - unsigned int pages, - int *preempted) +static int sh_set_allocation(struct domain *d, + unsigned int pages, + int *preempted) { struct page_info *sp; unsigned int lower_bound; @@ -3151,13 +3151,11 @@ int shadow_enable(struct domain *d, u32 mode) old_pages = d->arch.paging.shadow.total_pages; if ( old_pages == 0 ) { - unsigned int r; paging_lock(d); - r = sh_set_allocation(d, 1024, NULL); /* Use at least 4MB */ - if ( r != 0 ) + rv = sh_set_allocation(d, 1024, NULL); /* Use at least 4MB */ + if ( rv != 0 ) { sh_set_allocation(d, 0, NULL); - rv = -ENOMEM; goto out_locked; } paging_unlock(d);