Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1340931pxv; Fri, 23 Jul 2021 06:08:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpB7wFWAON2iawzlPIFCpJP2zf+ecjOAv3cQb4qrTgJb+ojKufLHT6CTCdL3WP2ldb5ilW X-Received: by 2002:a50:bb07:: with SMTP id y7mr1514278ede.214.1627045691787; Fri, 23 Jul 2021 06:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627045691; cv=none; d=google.com; s=arc-20160816; b=tGlIaSbyyQQjea11+bKv3sAVhR7c9PkySfPR4+AebtVNK9dieMy++DDFkItGYTao9Z btBEyT2X7JJ6ZQpNQI4v3I4GStMVmrD/vdVGZHTYyhlI9ZFK9dAdXwUePxX3ZNPPRp1e QBmWkZv+1/lo065nxi2Ogy6o8cWGznDrji8sLK9xFgdPkhCrOqQNvjI8Zp0K4ijHJnhc ZUgm46ISAHSCObMECOdt0XOJt4LylJogrnYIfnmifWr6NFV2D54wJuYM2GhMU5/e9akI UVwi7fPvB06TTo7/Eyp29viwgQ/21r+y1h5fRKE+6vLgw9J+PhIOhqbHuXUe5abQgbWH UocA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=B6Zap8e+74wKaBFtjBJiRBW5WomgF5+GZojWHF7Qxy0=; b=jSA3sOAC/EQk5e+Qz0xWnhFHKaymsKgzAp+SGN593AA+r3TYi7hb9FZupLDK/V34p/ +HasgBl4kIHv/RjFN15X9TGHBTKP5Yl1iukn/vXD5woEZtMhDHY+Y3jzcj0wTdmeCbu4 cIfAi0QLb6kVv6iikfmi0sUlW7nhgdR3nTNqXhTeeQTYZp4k8dD4/Hrp19cR6nrZuZhe FwLtsGDrIKP7wTO8HoMdZ2l8NWbckkw01Sk3o2XvIqbVzo+mrvcKdfMm9JhxpU/F7gPY E4JO8ZxvmPEGfEl0QAobYY/24s/p7sTMrAXPD4jhI1Mpr/flv35iRzGXbUPuFQKPTLQH ldWg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si33140501eds.528.2021.07.23.06.07.47; Fri, 23 Jul 2021 06:08:11 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235127AbhGWMXK (ORCPT + 99 others); Fri, 23 Jul 2021 08:23:10 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:64241 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234853AbhGWMXJ (ORCPT ); Fri, 23 Jul 2021 08:23:09 -0400 Received: (Authenticated sender: alex@ghiti.fr) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 5D2F840003; Fri, 23 Jul 2021 13:03:38 +0000 (UTC) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH 2/5] riscv: Get rid of map_size parameter to create_kernel_page_table Date: Fri, 23 Jul 2021 15:01:25 +0200 Message-Id: <20210723130128.47664-3-alex@ghiti.fr> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210723130128.47664-1-alex@ghiti.fr> References: <20210723130128.47664-1-alex@ghiti.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel must always be mapped using PMD_SIZE, and this is already the case, this just simplifies create_kernel_page_table. Signed-off-by: Alexandre Ghiti --- arch/riscv/mm/init.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 9668867e2702..e35df3e1c9a3 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -501,36 +501,35 @@ static __init pgprot_t pgprot_from_va(uintptr_t va) #endif #ifdef CONFIG_XIP_KERNEL -static void __init create_kernel_page_table(pgd_t *pgdir, uintptr_t map_size, +static void __init create_kernel_page_table(pgd_t *pgdir, __always_unused bool early) { uintptr_t va, end_va; /* Map the flash resident part */ end_va = kernel_map.virt_addr + kernel_map.xiprom_sz; - for (va = kernel_map.virt_addr; va < end_va; va += map_size) + for (va = kernel_map.virt_addr; va < end_va; va += PMD_SIZE) create_pgd_mapping(pgdir, va, kernel_map.xiprom + (va - kernel_map.virt_addr), - map_size, PAGE_KERNEL_EXEC); + PMD_SIZE, PAGE_KERNEL_EXEC); /* Map the data in RAM */ end_va = kernel_map.virt_addr + XIP_OFFSET + kernel_map.size; - for (va = kernel_map.virt_addr + XIP_OFFSET; va < end_va; va += map_size) + for (va = kernel_map.virt_addr + XIP_OFFSET; va < end_va; va += PMD_SIZE) create_pgd_mapping(pgdir, va, kernel_map.phys_addr + (va - (kernel_map.virt_addr + XIP_OFFSET)), - map_size, PAGE_KERNEL); + PMD_SIZE, PAGE_KERNEL); } #else -static void __init create_kernel_page_table(pgd_t *pgdir, uintptr_t map_size, - bool early) +static void __init create_kernel_page_table(pgd_t *pgdir, bool early) { uintptr_t va, end_va; end_va = kernel_map.virt_addr + kernel_map.size; - for (va = kernel_map.virt_addr; va < end_va; va += map_size) + for (va = kernel_map.virt_addr; va < end_va; va += PMD_SIZE) create_pgd_mapping(pgdir, va, kernel_map.phys_addr + (va - kernel_map.virt_addr), - map_size, + PMD_SIZE, early ? PAGE_KERNEL_EXEC : pgprot_from_va(va)); } @@ -539,7 +538,6 @@ static void __init create_kernel_page_table(pgd_t *pgdir, uintptr_t map_size, asmlinkage void __init setup_vm(uintptr_t dtb_pa) { uintptr_t __maybe_unused pa; - uintptr_t map_size; #ifndef __PAGETABLE_PMD_FOLDED pmd_t fix_bmap_spmd, fix_bmap_epmd; #endif @@ -564,15 +562,9 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) pfn_base = PFN_DOWN(kernel_map.phys_addr); - /* - * Enforce boot alignment requirements of RV32 and - * RV64 by only allowing PMD or PGD mappings. - */ - map_size = PMD_SIZE; - /* Sanity check alignment and size */ BUG_ON((PAGE_OFFSET % PGDIR_SIZE) != 0); - BUG_ON((kernel_map.phys_addr % map_size) != 0); + BUG_ON((kernel_map.phys_addr % PMD_SIZE) != 0); pt_ops.alloc_pte = alloc_pte_early; pt_ops.get_pte_virt = get_pte_virt_early; @@ -609,7 +601,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) * us to reach paging_init(). We map all memory banks later * in setup_vm_final() below. */ - create_kernel_page_table(early_pg_dir, map_size, true); + create_kernel_page_table(early_pg_dir, true); #ifndef __PAGETABLE_PMD_FOLDED /* Setup early PMD for DTB */ @@ -725,7 +717,7 @@ static void __init setup_vm_final(void) #ifdef CONFIG_64BIT /* Map the kernel */ - create_kernel_page_table(swapper_pg_dir, PMD_SIZE, false); + create_kernel_page_table(swapper_pg_dir, false); #endif /* Clear fixmap PTE and PMD mappings */ -- 2.30.2