From patchwork Wed Aug 16 12:51:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 9903693 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 78B0C6038C for ; Wed, 16 Aug 2017 12:55:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A928289E0 for ; Wed, 16 Aug 2017 12:55:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F5DE289E1; Wed, 16 Aug 2017 12:55:06 +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 02027289CD for ; Wed, 16 Aug 2017 12:55:06 +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 1dhxpF-0002rq-3u; Wed, 16 Aug 2017 12:53:33 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhxpD-0002op-GW for xen-devel@lists.xenproject.org; Wed, 16 Aug 2017 12:53:31 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id D0/2D-01729-A4044995; Wed, 16 Aug 2017 12:53:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRWlGSWpSXmKPExsVyuP0Ov66Xw5R Ig1s9PBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aLq8oF/YoVn2Y0sDcw3hXvYuTkkBAwkng7 8R9TFyMXh5DAQkaJqYtXsYAk2ARUJTZcP8UKYosIKEncWzUZqIiDg1nAX+LjDm2QsLBAgsSGp 3fZQWwWoPI1F9aClfMKmEjsn3yTHWK+vETHgclgIzmB4pM3HAOzhQSMJbb3NLJPYORewMiwil GjOLWoLLVI19BML6koMz2jJDcxM0fX0MBULze1uDgxPTUnMalYLzk/dxMj0LcMQLCDcer7uEO MkhxMSqK8QVpTIoX4kvJTKjMSizPii0pzUosPMcpwcChJ8EraA+UEi1LTUyvSMnOAQQaTluDg URLhTbMFSvMWFyTmFmemQ6ROMepyvJrw/xuTEEtefl6qlDhvph1QkQBIUUZpHtwIWMBfYpSVE uZlBDpKiKcgtSg3swRV/hWjOAejkjDvbJApPJl5JXCbXgEdwQR0xJX2SSBHlCQipKQaGO32Oz 0TtevRvaLzXiLypN2hdO+Azp7mzV2btp9Xsf69vuGXh6dB65q56SnsAUxFS/6vt+aXrRCJMZF 1/RgTnNxWse+BM4PKtU/+fM23/s4LmdAUdfhbI0+bXrOQ/aukqYeVDk9jzuqx7ivde0Fhh2co w/+sWg/e5tyfMltf5mlss4+x+nhSiaU4I9FQi7moOBEAlPu+1HMCAAA= X-Env-Sender: jgross@suse.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1502888010!86915271!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19161 invoked from network); 16 Aug 2017 12:53:30 -0000 Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by server-2.tower-206.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 16 Aug 2017 12:53:30 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BE811AEB8; Wed, 16 Aug 2017 12:52:29 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 16 Aug 2017 14:51:53 +0200 Message-Id: <20170816125219.5255-27-jgross@suse.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170816125219.5255-1-jgross@suse.com> References: <20170816125219.5255-1-jgross@suse.com> Cc: Juergen Gross , Andrew Cooper Subject: [Xen-devel] [PATCH v3 26/52] xen/common/kexec.c: let custom parameter parsing routines return errno 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 Modify the custom parameter parsing routines in: xen/common/kexec.c to indicate whether the parameter value was parsed successfully. Cc: Andrew Cooper Signed-off-by: Juergen Gross Acked-by: Wei Liu --- xen/common/kexec.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/xen/common/kexec.c b/xen/common/kexec.c index a52c30ba1e..fcc68bd4d8 100644 --- a/xen/common/kexec.c +++ b/xen/common/kexec.c @@ -102,9 +102,10 @@ static void *crash_heap_current = NULL, *crash_heap_end = NULL; * < and below are synonyomous, the latter being useful for grub2 systems * which would otherwise require escaping of the < option */ -static void __init parse_crashkernel(const char *str) +static int __init parse_crashkernel(const char *str) { const char *cur; + int rc = 0; if ( strchr(str, ':' ) ) { @@ -116,6 +117,7 @@ static void __init parse_crashkernel(const char *str) printk(XENLOG_WARNING "crashkernel: too many ranges\n"); cur = NULL; str = strpbrk(str, "@,<"); + rc = -EINVAL; break; } @@ -126,6 +128,7 @@ static void __init parse_crashkernel(const char *str) if ( *str != '-' ) { printk(XENLOG_WARNING "crashkernel: '-' expected\n"); + rc = -EINVAL; break; } @@ -137,6 +140,7 @@ static void __init parse_crashkernel(const char *str) if ( ranges[idx].end <= ranges[idx].start ) { printk(XENLOG_WARNING "crashkernel: end <= start\n"); + rc = -EINVAL; break; } } @@ -146,6 +150,7 @@ static void __init parse_crashkernel(const char *str) if ( *str != ':' ) { printk(XENLOG_WARNING "crashkernel: ':' expected\n"); + rc = -EINVAL; break; } @@ -169,10 +174,18 @@ static void __init parse_crashkernel(const char *str) else if ( !strncmp(str, ",below=", 7) ) kexec_crash_area_limit = parse_size_and_unit(cur = str + 7, &str); else + { printk(XENLOG_WARNING "crashkernel: '%s' ignored\n", str); + rc = -EINVAL; + } } if ( cur && cur == str ) + { printk(XENLOG_WARNING "crashkernel: memory value expected\n"); + rc = -EINVAL; + } + + return rc; } custom_param("crashkernel", parse_crashkernel); @@ -186,7 +199,7 @@ custom_param("crashkernel", parse_crashkernel); * - all will allocate additional structures such as domain and vcpu structs * low so the crash kernel can perform an extended analysis of state. */ -static void __init parse_low_crashinfo(const char * str) +static int __init parse_low_crashinfo(const char *str) { if ( !strlen(str) ) @@ -202,7 +215,10 @@ static void __init parse_low_crashinfo(const char * str) { printk("Unknown low_crashinfo parameter '%s'. Defaulting to min.\n", str); low_crashinfo_mode = LOW_CRASHINFO_MIN; + return -EINVAL; } + + return 0; } custom_param("low_crashinfo", parse_low_crashinfo); @@ -212,19 +228,25 @@ custom_param("low_crashinfo", parse_low_crashinfo); * * will be rounded down to the nearest power of two. Defaults to 64G */ -static void __init parse_crashinfo_maxaddr(const char * str) +static int __init parse_crashinfo_maxaddr(const char *str) { u64 addr; + const char *q; /* if low_crashinfo_mode is unset, default to min. */ if ( low_crashinfo_mode == LOW_CRASHINFO_INVALID ) low_crashinfo_mode = LOW_CRASHINFO_MIN; - if ( (addr = parse_size_and_unit(str, NULL)) ) + if ( (addr = parse_size_and_unit(str, &q)) ) crashinfo_maxaddr = addr; else + { printk("Unable to parse crashinfo_maxaddr. Defaulting to %"PRIpaddr"\n", crashinfo_maxaddr); + return -EINVAL; + } + + return *q ? -EINVAL : 0; } custom_param("crashinfo_maxaddr", parse_crashinfo_maxaddr);