Received: by 10.192.165.156 with SMTP id m28csp419536imm; Thu, 19 Apr 2018 01:05:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx49d0/zSoKVk1AqlnuJZ2UvM0p8c/CbfTbF7SgwIIzooBy0wBCJpDXPZn0/pJrEEb469+YCj X-Received: by 2002:a17:902:a609:: with SMTP id u9-v6mr5230919plq.56.1524125114113; Thu, 19 Apr 2018 01:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524125114; cv=none; d=google.com; s=arc-20160816; b=k+ZlG85Wa28P1kXwFQ+IKJwXZ+qDOf6Y5dE9puXjze9hYDR9m+SZJNJxVbVstO8z9G sPnehTzS6XadlV+UYqTAHP3uUZlc49m0N+OZtQmhyfQK3Yg484frbdyNORF2mwlCipJU mAn2FJf/doTKWd3S8n91ABuio+Yk+6PIGKoHNu6Bu73ATf5HVxStk2b5Tu7jDgjWEsGh 9VchsHiz9aZL2JDThvRhvbGQZh09AeT6+FFa6q0p9pvwI2BxH6KJU2/Wurocftn7qLbb Gn0xgf41uST5GAfC+PKUC6rCyEhYevjT3f2dhwggZtENT9h96i3zjLvkeK7xI+h/xsT8 p6kA== 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=2LsTU4ZN5cY8m3FIFht1jnsF385fG+cQUCPw+7KmsCg=; b=0Ids4OSwrfExaeKo4E+UbOlaAKW2Is74zI39wLfduc/bKFMvkKPFk18FvYCcmsCkVL Pssaf6fG07RobBrTyfe1Z6KQ+otBJAvXWQ32RBlcv8NpTCQzH9tN0RNEuJ8ZseLzMp3B W2PAjSmsx1sMrc7/krpl4NpNxhqf4Fzt7PcPwbVHVL0kOzzU3FG2kQRV4TeNDw5PdCMg Nw48S2OlX40TmRa3MtQwESkMbFiFll3AAGfZAjEwhtpNTWA/Z52EpdlrBGRtG0VfS/Cn 4uDtq7V2lGcFyEJtXIQhPefGwRr67jHwP3ObJBk6IoPDLg8ZLgQuMNfhpet+fb/w3zx+ Tssw== 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 q21-v6si3069514pls.3.2018.04.19.01.05.00; Thu, 19 Apr 2018 01:05:14 -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 S1752715AbeDSIDg (ORCPT + 99 others); Thu, 19 Apr 2018 04:03:36 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:48008 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751345AbeDSIDa (ORCPT ); Thu, 19 Apr 2018 04:03:30 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 77F80ABAD35CD; Thu, 19 Apr 2018 16:03:26 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.361.1; Thu, 19 Apr 2018 16:03:20 +0800 Subject: Re: [PATCH v2 1/2] PCI ACPI: Avoid panic when PCI IO resource's size is not page aligned To: , , References: <1522480343-37669-1-git-send-email-xieyisheng1@huawei.com> CC: , , , , , , , From: Yisheng Xie Message-ID: Date: Thu, 19 Apr 2018 16:03:01 +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: <1522480343-37669-1-git-send-email-xieyisheng1@huawei.com> 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 Hi all, ping... Sorry to disturb, but any comment about this patchset? Thanks Yisheng On 2018/3/31 15:12, Yisheng Xie wrote: > Zhou reported a bug on Hisilicon arm64 D06 platform with 64KB page size: > > [ 2.470908] kernel BUG at lib/ioremap.c:72! > [ 2.475079] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP > [ 2.480551] Modules linked in: > [ 2.483594] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.16.0-rc7-00062-g0b41260-dirty #23 > [ 2.491756] Hardware name: Huawei D06/D06, BIOS Hisilicon D06 UEFI Nemo 2.0 RC0 - B120 03/23/2018 > [ 2.500614] pstate: 80c00009 (Nzcv daif +PAN +UAO) > [ 2.505395] pc : ioremap_page_range+0x268/0x36c > [ 2.509912] lr : pci_remap_iospace+0xe4/0x100 > [...] > [ 2.603733] Call trace: > [ 2.606168] ioremap_page_range+0x268/0x36c > [ 2.610337] pci_remap_iospace+0xe4/0x100 > [ 2.614334] acpi_pci_probe_root_resources+0x1d4/0x214 > [ 2.619460] pci_acpi_root_prepare_resources+0x18/0xa8 > [ 2.624585] acpi_pci_root_create+0x98/0x214 > [ 2.628843] pci_acpi_scan_root+0x124/0x20c > [ 2.633013] acpi_pci_root_add+0x224/0x494 > [ 2.637096] acpi_bus_attach+0xf8/0x200 > [ 2.640918] acpi_bus_attach+0x98/0x200 > [ 2.644740] acpi_bus_attach+0x98/0x200 > [ 2.648562] acpi_bus_scan+0x48/0x9c > [ 2.652125] acpi_scan_init+0x104/0x268 > [ 2.655948] acpi_init+0x308/0x374 > [ 2.659337] do_one_initcall+0x48/0x14c > [ 2.663160] kernel_init_freeable+0x19c/0x250 > [ 2.667504] kernel_init+0x10/0x100 > [ 2.670979] ret_from_fork+0x10/0x18 > > The cause is the size of PCI IO resource is 32KB, which is 4K aligned but > not 64KB aligned, however, ioremap_page_range() request the range as page > aligned or it will trigger a BUG_ON() on ioremap_pte_range() it calls, as > ioremap_pte_range increase the addr by PAGE_SIZE, which makes addr != end > until trigger BUG_ON, if its incoming end is not page aligned. More detail > trace is as following: > > ioremap_page_range > -> ioremap_p4d_range > -> ioremap_p4d_range > -> ioremap_pud_range > -> ioremap_pmd_range > -> ioremap_pte_range > > This patch fix the bug by align the size of PCI IO resource to PAGE_SIZE. > > Reported-by: Zhou Wang > Tested-by: Xiaojun Tan > Signed-off-by: Yisheng Xie > --- > I mark this as v2 for I have post a RFC version: > > https://lkml.org/lkml/2018/3/30/8 > > v2: > * Let the caller of ioremap_page_range() align the request by PAGE_SIZE - per Toshi > > Thanks > Yisheng > > 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; > entry->offset = port - pci_addr; > > if (pci_remap_iospace(res, cpu_addr) < 0) >