Received: by 10.192.165.148 with SMTP id m20csp2800871imm; Mon, 7 May 2018 01:07:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqwA7GIyXw8PfjxieXrPJOAEU3jlvymaeJNx/7aD9E1jl56neg7yPuRdFixoSqUUZt0I4ka X-Received: by 2002:a17:902:a702:: with SMTP id w2-v6mr17323534plq.8.1525680432482; Mon, 07 May 2018 01:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525680432; cv=none; d=google.com; s=arc-20160816; b=uodmCR3grtDP/RvJXIyDQbXb5/5PewdhBUn6cYEovorQi9TnIQtgpvPQwJlX4vZXKG TwY2l9jjGWaBsyzo8FCTj4kN290hZyxSCN7z3GXKJGkPvzb/dSjfJbOVFg3bIwj721rU kerHrjrmVumD/38vXjZSp5l4I8hc2KUpirT62UdcVdCh0HKBDv3v41eH02lhmdjhA/Te yh+9eSFdHwqZ3RB18CsxsFsyUHTxoM7/wYImD9rtAlGetJ7nYPx+/cpvVmvDQZHDILs3 p+TM0Iu8fr8eln4xDcAwUtDBmYD3DPWBWhsYZYw1iveRRg/aZBZOyyP6oFGeXcgcBvOW mK6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=6Y6+buP8Xvd35GgXogyGO1+V8bdXswWKbVijEGwn06o=; b=Jcoqx6P+n8b/PYhauogJvP71DVgsLtfhqeD0mpEMi2xlW5Dv3FaIayz6/ERQxLCl5q rCylmzeakqiwbmg9JxbyGkfev+jsZzkVMxAH7stOTdRD0Sx3TCovMx5K0vj5b9xvyihr 5fKg2gcSgA1pl0vWLCcc+V3bfG6Nybo3UDZZpjVYQjTLnc73RvOD/WttyTQey8N9Rjis BkukVa2EDo79AI6/13a9lzmbKLmGDNrUSUN/6I2ZdYQcryacJ0+Z0vyFdk7RUyTW9P6P jVZSqwrk7BscdVh7LXpGBB/cODDEyuMJ0/mxOXqFGPfx/Nhb6OJmTQfXqnscPQxxpyac UzPw== 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 j7-v6si21486869plt.356.2018.05.07.01.06.58; Mon, 07 May 2018 01:07:12 -0700 (PDT) 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 S1752022AbeEGIGn (ORCPT + 99 others); Mon, 7 May 2018 04:06:43 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:45768 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751937AbeEGIGk (ORCPT ); Mon, 7 May 2018 04:06:40 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A89E6245F6A91; Mon, 7 May 2018 16:06:35 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.361.1; Mon, 7 May 2018 16:06:31 +0800 Subject: Re: [PATCH v2 1/2] PCI ACPI: Avoid panic when PCI IO resource's size is not page aligned To: "Rafael J. Wysocki" References: <1522480343-37669-1-git-send-email-xieyisheng1@huawei.com> <3699960.UXjPS91TgB@aspire.rjw.lan> CC: , , , , , , , , , , Lorenzo Pieralisi , Sudeep Holla , Hanjun Guo From: Yisheng Xie Message-ID: Date: Mon, 7 May 2018 16:06:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <3699960.UXjPS91TgB@aspire.rjw.lan> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/5/1 17:28, Rafael J. Wysocki wrote: >> drivers/acpi/pci_root.c | 2 +- >> > 1 file changed, 1 insertion(+), 1 deletion(-) >> > >> > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c >> > index 6fc204a..b758ca3 100644 >> > --- a/drivers/acpi/pci_root.c >> > +++ b/drivers/acpi/pci_root.c >> > @@ -746,7 +746,7 @@ static void acpi_pci_root_remap_iospace(struct resource_entry *entry) >> > goto err; >> > >> > res->start = port; >> > - res->end = port + length - 1; >> > + res->end = PAGE_ALIGN(port + length) - 1; > Shouldn't pci_remap_iospace() sanitize its arguments instead? Yeah, I thought that pci_remap_iospace() will be called at many place, and presently I had not seen any problem at other place except acpi_pci_root_remap_iospace(). Anyway, sanitize arguments in pci_remap_iospace() can resolve the problem more thoroughly, but should more common, right? Therefore, is the follow change ok from your point of view? diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e597655..8607298 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3527,6 +3527,9 @@ int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr) if (res->end > IO_SPACE_LIMIT) return -EINVAL; + if (!PAGE_ALIGNED(vaddr) || !PAGE_ALIGNED(resource_size(res))) + return -EINVAL; + return ioremap_page_range(vaddr, vaddr + resource_size(res), phys_addr, pgprot_device(PAGE_KERNEL)); #else Thanks Yisheng > >> > entry->offset = port - pci_addr; >> > >> > if (pci_remap_iospace(res, cpu_addr) < 0)