Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1975663pxb; Fri, 5 Mar 2021 04:34:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzK8F6mZxZe02IQdk9ek0d6PXbmeaiQ3eSCmrhIUgyGhRiIc3yNSiEriLgzvXeRyin3DoP X-Received: by 2002:a17:906:8614:: with SMTP id o20mr1963505ejx.386.1614947660274; Fri, 05 Mar 2021 04:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947660; cv=none; d=google.com; s=arc-20160816; b=wjHI3CSFt6KWas6gk0514RaMAkRjJhp/h3H9EcAqSgrZJ6HG/W0KuSR2prkwEP/RJq fgOMDGiDk+U0Td1e9grflaYPVWG9EqOvu2FKglUDwRQSf3zf1qe02tzv3nFSMPWTHbFU o0aXUbj+PX2ty5TgQf08vtwAYv6qWQ/hWuUR4uWHEc9ns5d0mQMFbO8m2U0lugp4XQMc 9vNiY8XfTx621xti8SizSACy3DS26De/5yLHHA5XyIjT8ODvJqrV1Fjj8NDMV2kSZJ+y MO6uKHrMj1gJ/h7gAls/c1Y2lX5TSsrM7U9bClVTxIeltM7S4eD3Vp25OXQkOSgu/Px/ Fp3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0Go4bU+zG2Id+mVYygN7ZjIdfFK54jPhBbsfmV41oBE=; b=u75ge0bmzgDssTo0vHYU0viYqoifhYupD81Q9oC4ubgrrzv+WV6brGS3pTsFTyelJj wgiiijzH3S6MvILXNmVxm2ydMgSiisPWoQyyAUbvdFG/5VWGRn2b39X3F4XzffWia5eH NEO+R3uIb4VQkmmxSfzO44Wu3gqBMtJEYeHW78N7RpeITBRfIypM/gLD8LF++t4YB8XB jUFQwgw32F3VJBAMpTWFF1v7v7m6yI3DREmfqGaUvaMndIkPOsX6tmSOuhlOqG0TBLBS ly/h0kDO0ECNek9quBuVBgLb6CmDofoncOueAYJhsx3MgjiRpqe1VfmVUAM33FwFw+xb DfmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tHi41UVq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq23si1189983ejb.498.2021.03.05.04.33.55; Fri, 05 Mar 2021 04:34:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tHi41UVq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231169AbhCEMaP (ORCPT + 99 others); Fri, 5 Mar 2021 07:30:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:39240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbhCEM3s (ORCPT ); Fri, 5 Mar 2021 07:29:48 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3B0F865013; Fri, 5 Mar 2021 12:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947387; bh=kCqfsKVOdvUUjOZS5SshL+wSWQWwHicqWJSj0RFLn/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tHi41UVqXLgn/h4xxupLPSTYj1bQWWHl/hrdeAGI2KnD9CMI36hnXS/FZ6dXlnFBO UvBctNbdSqnbbJXS5VFfFtqV+lM0IrdMYcktC72sc4wDz/aWKxBBCznv1sBTz1jf5A SmCoc+uaYgRJ82gF2KeCmK1iNoiI1Fu/cG/mERT4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Vyukov , Alexandre Ghiti , Palmer Dabbelt Subject: [PATCH 5.10 017/102] riscv: Get rid of MAX_EARLY_MAPPING_SIZE Date: Fri, 5 Mar 2021 13:20:36 +0100 Message-Id: <20210305120904.123324088@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120903.276489876@linuxfoundation.org> References: <20210305120903.276489876@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandre Ghiti commit 0f02de4481da684aad6589aed0ea47bd1ab391c9 upstream. At early boot stage, we have a whole PGDIR to map the kernel, so there is no need to restrict the early mapping size to 128MB. Removing this define also allows us to simplify some compile time logic. This fixes large kernel mappings with a size greater than 128MB, as it is the case for syzbot kernels whose size was just ~130MB. Note that on rv64, for now, we are then limited to PGDIR size for early mapping as we can't use PGD mappingsĀ (see [1]). That should be enough given the relative small size of syzbot kernels compared to PGDIR_SIZE which is 1GB. [1] https://lore.kernel.org/lkml/20200603153608.30056-1-alex@ghiti.fr/ Reported-by: Dmitry Vyukov Signed-off-by: Alexandre Ghiti Tested-by: Dmitry Vyukov Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- arch/riscv/mm/init.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -222,8 +222,6 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __pag pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss; pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss; -#define MAX_EARLY_MAPPING_SIZE SZ_128M - pgd_t early_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot) @@ -298,13 +296,7 @@ static void __init create_pte_mapping(pt pmd_t trampoline_pmd[PTRS_PER_PMD] __page_aligned_bss; pmd_t fixmap_pmd[PTRS_PER_PMD] __page_aligned_bss; - -#if MAX_EARLY_MAPPING_SIZE < PGDIR_SIZE -#define NUM_EARLY_PMDS 1UL -#else -#define NUM_EARLY_PMDS (1UL + MAX_EARLY_MAPPING_SIZE / PGDIR_SIZE) -#endif -pmd_t early_pmd[PTRS_PER_PMD * NUM_EARLY_PMDS] __initdata __aligned(PAGE_SIZE); +pmd_t early_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE); pmd_t early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE); static pmd_t *__init get_pmd_virt_early(phys_addr_t pa) @@ -326,11 +318,9 @@ static pmd_t *get_pmd_virt_late(phys_add static phys_addr_t __init alloc_pmd_early(uintptr_t va) { - uintptr_t pmd_num; + BUG_ON((va - PAGE_OFFSET) >> PGDIR_SHIFT); - pmd_num = (va - PAGE_OFFSET) >> PGDIR_SHIFT; - BUG_ON(pmd_num >= NUM_EARLY_PMDS); - return (uintptr_t)&early_pmd[pmd_num * PTRS_PER_PMD]; + return (uintptr_t)early_pmd; } static phys_addr_t __init alloc_pmd_fixmap(uintptr_t va) @@ -448,7 +438,7 @@ asmlinkage void __init setup_vm(uintptr_ uintptr_t va, pa, end_va; uintptr_t load_pa = (uintptr_t)(&_start); uintptr_t load_sz = (uintptr_t)(&_end) - load_pa; - uintptr_t map_size = best_map_size(load_pa, MAX_EARLY_MAPPING_SIZE); + uintptr_t map_size; #ifndef __PAGETABLE_PMD_FOLDED pmd_t fix_bmap_spmd, fix_bmap_epmd; #endif @@ -460,12 +450,11 @@ asmlinkage void __init setup_vm(uintptr_ * Enforce boot alignment requirements of RV32 and * RV64 by only allowing PMD or PGD mappings. */ - BUG_ON(map_size == PAGE_SIZE); + map_size = PMD_SIZE; /* Sanity check alignment and size */ BUG_ON((PAGE_OFFSET % PGDIR_SIZE) != 0); BUG_ON((load_pa % map_size) != 0); - BUG_ON(load_sz > MAX_EARLY_MAPPING_SIZE); pt_ops.alloc_pte = alloc_pte_early; pt_ops.get_pte_virt = get_pte_virt_early;