From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00CE0C07E95 for ; Tue, 20 Jul 2021 02:52:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4C7D61002 for ; Tue, 20 Jul 2021 02:52:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237844AbhGTCL0 (ORCPT ); Mon, 19 Jul 2021 22:11:26 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:7395 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229936AbhGTCEF (ORCPT ); Mon, 19 Jul 2021 22:04:05 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GTNHn3dPpz7wx2; Tue, 20 Jul 2021 10:40:53 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 20 Jul 2021 10:44:31 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 20 Jul 2021 10:44:31 +0800 From: Kefeng Wang To: Catalin Marinas , Will Deacon , Andrey Ryabinin , Andrey Konovalov , Dmitry Vyukov CC: , , , , Kefeng Wang Subject: [PATCH v2 1/3] vmalloc: Choose a better start address in vm_area_register_early() Date: Tue, 20 Jul 2021 10:51:03 +0800 Message-ID: <20210720025105.103680-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210720025105.103680-1-wangkefeng.wang@huawei.com> References: <20210720025105.103680-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are some fixed locations in the vmalloc area be reserved in ARM(see iotable_init()) and ARM64(see map_kernel()), but for pcpu_page_first_chunk(), it calls vm_area_register_early() and choose VMALLOC_START as the start address of vmap area which could be conflicted with above address, then could trigger a BUG_ON in vm_area_add_early(). Let's choose the end of existing address range in vmlist as the start address instead of VMALLOC_START to avoid the BUG_ON. Signed-off-by: Kefeng Wang --- mm/vmalloc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d5cd52805149..a98cf97f032f 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2238,12 +2238,14 @@ void __init vm_area_add_early(struct vm_struct *vm) */ void __init vm_area_register_early(struct vm_struct *vm, size_t align) { - static size_t vm_init_off __initdata; + unsigned long vm_start = VMALLOC_START; + struct vm_struct *tmp; unsigned long addr; - addr = ALIGN(VMALLOC_START + vm_init_off, align); - vm_init_off = PFN_ALIGN(addr + vm->size) - VMALLOC_START; + for (tmp = vmlist; tmp; tmp = tmp->next) + vm_start = (unsigned long)tmp->addr + tmp->size; + addr = ALIGN(vm_start, align); vm->addr = (void *)addr; vm_area_add_early(vm); -- 2.26.2