Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6766703imu; Mon, 3 Dec 2018 02:25:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/WF3+iFlT3wkj5ly+Zr/khb/8Oqcj9pQ13ZX9JVg9Z2rAA5m6emyUz8AlZ+ZAoBFoVtB4Lg X-Received: by 2002:a63:fd0a:: with SMTP id d10mr12959780pgh.164.1543832716222; Mon, 03 Dec 2018 02:25:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543832716; cv=none; d=google.com; s=arc-20160816; b=R+XWwwJsq11g2W++hd8JI1EpEyeLNos+48e2e4Xc2i9HChMu9TUC2UHaICgDdTofwP 8mZuHeessM7GNP0pYbBsYIFWtBl3xFIWcyocpk8fx51TUJ3rRH26Tru9zpLK9kLxw7v/ 81GtPhFGah51Ymr2cgZCqOZAHICch0UhEVl4V8Kda3MNhsvrw8NzsY+/shnSwt7go+Rx rLEZ+j0rQx59MKMsAmb7wZ/zJgIBPWF2GsYwWhRLxi1M3DlXyjg3fnFR4dmiePYwx5dD iHv3nVYPiK31W+kUCxXKcVgx0JpHfysKKzisD+svhWtcmNr1EKfqgHjJv42XlRRgqcl4 Xceg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=2QIxFR+DmwUaAgUR0R+hBT4RX/YFLT3bep3NXXWTEvk=; b=i6q9+7IcUF1WzlGFACQ56O5TiMg8QGdRK2YV2XVd57uTFAVmkhziXAsk72ZZnYvMwy c5Tu7r2PF1OiTOcSDofdMwG4AZLoUU7N2q4JxIBcJKMFTEeIaoZKbhibh+0ubgc5sWOb O/OWb8Zfh/yLn/4t96F5pDIIlFmwrv51/jK+AaGJ1HN8cN6m3AElwY+fTNB5qIJeJ8zI hiJN+EH5Ep60LdYYIL3R05rZaXsXyHEe3xIyJ3TWJbwZ73xt+I4GdJEup+5LGO9L7jXx 27Z/TY6ca7egBHRNDAlKEBmqskXKwrhLbC2GThV7MWLn9G5FpET4YbRy1m/rCu1YUVvY 59HQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k125si3521685pfc.21.2018.12.03.02.25.01; Mon, 03 Dec 2018 02:25:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726224AbeLCKXe (ORCPT + 99 others); Mon, 3 Dec 2018 05:23:34 -0500 Received: from mail5.windriver.com ([192.103.53.11]:58574 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbeLCKXe (ORCPT ); Mon, 3 Dec 2018 05:23:34 -0500 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id wB3AKP5h027153 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Mon, 3 Dec 2018 02:20:56 -0800 Received: from [128.224.162.162] (128.224.162.162) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 3 Dec 2018 02:20:20 -0800 Subject: Re: [PATCH] kernel/dma: Fix panic caused by passing swiotlb to command line To: Konrad Rzeszutek Wilk CC: , , , , , References: <1537154831-447363-1-git-send-email-zhe.he@windriver.com> <20181022192921.GA20677@dhcp-10-175-29-12.vpn.oracle.com> <87ee40fa-7a01-4d4c-7fa3-81aafc93e14f@windriver.com> <5fa82cb9-bd32-8a3f-ddca-053f544e2883@windriver.com> <20181202123032.GA3166@localhost.localdomain> From: He Zhe Message-ID: Date: Mon, 3 Dec 2018 18:20:16 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181202123032.GA3166@localhost.localdomain> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [128.224.162.162] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/12/2 20:30, Konrad Rzeszutek Wilk wrote: > On Tue, Oct 30, 2018 at 07:06:10PM +0800, He Zhe wrote: >> >> On 2018/10/23 19:14, He Zhe wrote: >>> On 2018/10/23 03:29, Konrad Rzeszutek Wilk wrote: >>>> On Sat, Sep 22, 2018 at 08:56:58PM +0800, He Zhe wrote: >>>>> May I have your input? >>>> Alternatively would it make more sense for it to assume some default >>>> value? >>> Maybe, but the original code has no default value and I have no idea >>> what default value is proper here. >> Can anyone give some suggestions? Though I'd prefer to do nothing when >> no option is provided. > One provided the paramter for a reason. I would just do a small one, say > 4MB. OK. Thanks, I'll send v2. Zhe >> Thanks, >> Zhe >> >>> Zhe >>> >>>>> Thanks, >>>>> Zhe >>>>> >>>>> On 2018年09月17日 11:27, zhe.he@windriver.com wrote: >>>>>> From: He Zhe >>>>>> >>>>>> setup_io_tlb_npages does not check input argument before passing it >>>>>> to isdigit. The argument would be a NULL pointer if "swiotlb", without >>>>>> its value, is set in command line and thus causes the following panic. >>>>>> >>>>>> PANIC: early exception 0xe3 IP 10:ffffffffbb9b8e9f error 0 cr2 0x0 >>>>>> [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.0-rc3-yocto-standard+ #9 >>>>>> [ 0.000000] RIP: 0010:setup_io_tlb_npages+0xf/0x95 >>>>>> ... >>>>>> [ 0.000000] Call Trace: >>>>>> [ 0.000000] do_early_param+0x57/0x8e >>>>>> [ 0.000000] parse_args+0x208/0x320 >>>>>> [ 0.000000] ? rdinit_setup+0x30/0x30 >>>>>> [ 0.000000] parse_early_options+0x29/0x2d >>>>>> [ 0.000000] ? rdinit_setup+0x30/0x30 >>>>>> [ 0.000000] parse_early_param+0x36/0x4d >>>>>> [ 0.000000] setup_arch+0x336/0x99e >>>>>> [ 0.000000] start_kernel+0x6f/0x4e6 >>>>>> [ 0.000000] x86_64_start_reservations+0x24/0x26 >>>>>> [ 0.000000] x86_64_start_kernel+0x6f/0x72 >>>>>> [ 0.000000] secondary_startup_64+0xa4/0xb0 >>>>>> >>>>>> This patch adds a check to prevent the panic. >>>>>> >>>>>> Signed-off-by: He Zhe >>>>>> Cc: stable@vger.kernel.org >>>>>> Cc: konrad.wilk@oracle.com >>>>>> Cc: hch@lst.de >>>>>> Cc: m.szyprowski@samsung.com >>>>>> Cc: robin.murphy@arm.com >>>>>> --- >>>>>> kernel/dma/swiotlb.c | 5 +++++ >>>>>> 1 file changed, 5 insertions(+) >>>>>> >>>>>> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c >>>>>> index 4f8a6db..46fc34e 100644 >>>>>> --- a/kernel/dma/swiotlb.c >>>>>> +++ b/kernel/dma/swiotlb.c >>>>>> @@ -109,6 +109,11 @@ static int late_alloc; >>>>>> static int __init >>>>>> setup_io_tlb_npages(char *str) >>>>>> { >>>>>> + if (!str) { >>>>>> + pr_err("Config string not provided\n"); >>>>>> + return -EINVAL; >>>>>> + } >>>>>> + >>>>>> if (isdigit(*str)) { >>>>>> io_tlb_nslabs = simple_strtoul(str, &str, 0); >>>>>> /* avoid tail segment of size < IO_TLB_SEGSIZE */ >>>>> _______________________________________________ >>>>> iommu mailing list >>>>> iommu@lists.linux-foundation.org >>>>> https://lists.linuxfoundation.org/mailman/listinfo/iommu