From patchwork Wed Aug 16 12:52:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 9903729 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 4F0196038C for ; Wed, 16 Aug 2017 12:55:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40CF5289CD for ; Wed, 16 Aug 2017 12:55:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35F4B289DD; Wed, 16 Aug 2017 12:55:25 +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 E350F289E0 for ; Wed, 16 Aug 2017 12:55:23 +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 1dhxpI-0002z4-FP; Wed, 16 Aug 2017 12:53:36 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhxpG-0002tx-Fo for xen-devel@lists.xenproject.org; Wed, 16 Aug 2017 12:53:34 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 28/56-02176-D4044995; Wed, 16 Aug 2017 12:53:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVyuP0Ov66Pw5R Ig6O7+Cy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy1vWeYC5bLVkw62cjUwHhapIuRk0NCwEji 7cR/TF2MXBxCAscYJbr7ZjKBJNgEVCU2XD/FCmKLCChJ3Fs1GSzOLOAq0fB7KVhcWCBXonnfF 7A4C1D9nJYL7CA2r4CJxPHPL1khFshLdByYzAJicwLFJ284BmYLCRhLbO9pZJ/AyL2AkWEVo0 ZxalFZapGukYFeUlFmekZJbmJmjq6hgalebmpxcWJ6ak5iUrFecn7uJkagf+sZGBh3MDbO9jv EKMnBpCTKG6Q1JVKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBK+YHVBOsCg1PbUiLTMHGGgwaQkO HiUR3jRboDRvcUFibnFmOkTqFKMux6sJ/78xCbHk5eelSonzZoLMEAApyijNgxsBC/pLjLJSw ryMDAwMQjwFqUW5mSWo8q8YxTkYlYR5w+2BpvBk5pXAbXoFdAQT0BFX2ieBHFGSiJCSamA0ja 2ZNmvb8vvfn5oFckzr4582Pda4zH7tbMb9uT5f47d+V/rizvM/ySg4TOKwSdsU7ysuUWb75sR 8bDt1tHAG98vmfzk/nmYvXLRY4VOIyarKI6dljpw5Ol8oy2Uff/Xig3YqpQ6CVuGcPpbXbmio caxpmXT8csh3Kdcnc5gc2JfGdL60O6OuxFKckWioxVxUnAgAk9hYdnUCAAA= X-Env-Sender: jgross@suse.com X-Msg-Ref: server-9.tower-206.messagelabs.com!1502888012!107634304!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 35513 invoked from network); 16 Aug 2017 12:53:32 -0000 Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by server-9.tower-206.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 16 Aug 2017 12:53:32 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D41D5AE57 for ; Wed, 16 Aug 2017 12:52:31 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 16 Aug 2017 14:52:00 +0200 Message-Id: <20170816125219.5255-34-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 , Jan Beulich Subject: [Xen-devel] [PATCH v3 33/52] xen/drivers/passthrough/iommu.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/drivers/passthrough/iommu.c to indicate whether the parameter value was parsed successfully. Cc: Jan Beulich Signed-off-by: Juergen Gross --- V3: - dont modify option value in parsing function --- xen/drivers/passthrough/iommu.c | 52 +++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 5e81813942..fcf40d334c 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -21,7 +21,7 @@ #include #include -static void parse_iommu_param(char *s); +static int parse_iommu_param(const char *s); static void iommu_dump_p2m_table(unsigned char key); unsigned int __read_mostly iommu_dev_iotlb_timeout = 1000; @@ -78,10 +78,10 @@ DEFINE_SPINLOCK(iommu_pt_cleanup_lock); PAGE_LIST_HEAD(iommu_pt_cleanup_list); static struct tasklet iommu_pt_cleanup_tasklet; -static void __init parse_iommu_param(char *s) +static int __init parse_iommu_param(const char *s) { - char *ss; - int val; + const char *ss; + int val, b, rc = 0; do { val = !!strncmp(s, "no-", 3); @@ -89,44 +89,50 @@ static void __init parse_iommu_param(char *s) s += 3; ss = strchr(s, ','); - if ( ss ) - *ss = '\0'; - - if ( !parse_bool(s) ) - iommu_enable = 0; - else if ( !strcmp(s, "force") || !strcmp(s, "required") ) + if ( !ss ) + ss = strchr(s, '\0'); + + b = parse_bool(s); + if ( b >= 0 ) + iommu_enable = b; + else if ( !strncmp(s, "force", ss - s) || + !strncmp(s, "required", ss - s) ) force_iommu = val; - else if ( !strcmp(s, "workaround_bios_bug") ) + else if ( !strncmp(s, "workaround_bios_bug", ss - s) ) iommu_workaround_bios_bug = val; - else if ( !strcmp(s, "igfx") ) + else if ( !strncmp(s, "igfx", ss - s) ) iommu_igfx = val; - else if ( !strcmp(s, "verbose") ) + else if ( !strncmp(s, "verbose", ss - s) ) iommu_verbose = val; - else if ( !strcmp(s, "snoop") ) + else if ( !strncmp(s, "snoop", ss - s) ) iommu_snoop = val; - else if ( !strcmp(s, "qinval") ) + else if ( !strncmp(s, "qinval", ss - s) ) iommu_qinval = val; - else if ( !strcmp(s, "intremap") ) + else if ( !strncmp(s, "intremap", ss - s) ) iommu_intremap = val; - else if ( !strcmp(s, "intpost") ) + else if ( !strncmp(s, "intpost", ss - s) ) iommu_intpost = val; - else if ( !strcmp(s, "debug") ) + else if ( !strncmp(s, "debug", ss - s) ) { iommu_debug = val; if ( val ) iommu_verbose = 1; } - else if ( !strcmp(s, "amd-iommu-perdev-intremap") ) + else if ( !strncmp(s, "amd-iommu-perdev-intremap", ss - s) ) amd_iommu_perdev_intremap = val; - else if ( !strcmp(s, "dom0-passthrough") ) + else if ( !strncmp(s, "dom0-passthrough", ss - s) ) iommu_passthrough = val; - else if ( !strcmp(s, "dom0-strict") ) + else if ( !strncmp(s, "dom0-strict", ss - s) ) iommu_dom0_strict = val; - else if ( !strcmp(s, "sharept") ) + else if ( !strncmp(s, "sharept", ss - s) ) iommu_hap_pt_share = val; + else + rc = -EINVAL; s = ss + 1; - } while ( ss ); + } while ( *ss ); + + return rc; } int iommu_domain_init(struct domain *d)