linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Alexandre Ghiti <alex@ghiti.fr>,
	Dmitry Vyukov <dvyukov@google.com>,
	Palmer Dabbelt <palmerdabbelt@google.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 5.11 45/52] riscv: Get rid of MAX_EARLY_MAPPING_SIZE
Date: Tue,  2 Mar 2021 06:55:26 -0500	[thread overview]
Message-ID: <20210302115534.61800-45-sashal@kernel.org> (raw)
In-Reply-To: <20210302115534.61800-1-sashal@kernel.org>

From: Alexandre Ghiti <alex@ghiti.fr>

[ Upstream commit 0f02de4481da684aad6589aed0ea47bd1ab391c9 ]

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 <dvyukov@google.com>
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/riscv/mm/init.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index f9f9568d689e..f81f813b9603 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -226,8 +226,6 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
 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)
@@ -302,13 +300,7 @@ static void __init create_pte_mapping(pte_t *ptep,
 
 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)
@@ -330,11 +322,9 @@ static pmd_t *get_pmd_virt_late(phys_addr_t pa)
 
 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)
@@ -452,7 +442,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
 	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
@@ -464,12 +454,11 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
 	 * 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;
-- 
2.30.1


  parent reply	other threads:[~2021-03-02 14:11 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 11:54 [PATCH AUTOSEL 5.11 01/52] i2c: rcar: faster irq code to minimize HW race condition Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 02/52] i2c: rcar: optimize cacheline " Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 03/52] scsi: ufs: Add a quirk to permit overriding UniPro defaults Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 04/52] scsi: pm80xx: Fix missing tag_free in NVMD DATA req Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 05/52] scsi: ufs: WB is only available on LUN #0 to #7 Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 06/52] scsi: ufs: Introduce a quirk to allow only page-aligned sg entries Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 07/52] scsi: ufs: Protect some contexts from unexpected clock scaling Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 08/52] udf: fix silent AED tagLocation corruption Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 09/52] iommu/vt-d: Clear PRQ overflow only when PRQ is empty Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 10/52] mmc: mxs-mmc: Fix a resource leak in an error handling path in 'mxs_mmc_probe()' Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 11/52] mmc: sdhci-of-dwcmshc: set SDHCI_QUIRK2_PRESET_VALUE_BROKEN Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 12/52] mmc: mediatek: fix race condition between msdc_request_timeout and irq Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 13/52] mmc: sdhci-iproc: Add ACPI bindings for the RPi Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 14/52] platform/x86: amd-pmc: put device on error paths Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 15/52] Platform: OLPC: Fix probe error handling Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 16/52] powerpc/pci: Add ppc_md.discover_phbs() Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 17/52] HID: i2c-hid: Add I2C_HID_QUIRK_NO_IRQ_AFTER_RESET for ITE8568 EC on Voyo Winpad A15 Sasha Levin
2021-03-02 11:54 ` [PATCH AUTOSEL 5.11 18/52] spi: stm32: make spurious and overrun interrupts visible Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 19/52] powerpc: improve handling of unrecoverable system reset Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 20/52] powerpc/perf: Record counter overflow always if SAMPLE_IP is unset Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 21/52] kunit: tool: fix unit test cleanup handling Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 22/52] HID: logitech-dj: add support for the new lightspeed connection iteration Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 23/52] HID: ite: Enable QUIRK_TOUCHPAD_ON_OFF_REPORT on Acer Aspire Switch 10E Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 24/52] powerpc/64: Fix stack trace not displaying final frame Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 25/52] iommu/amd: Fix performance counter initialization Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 26/52] clk: qcom: gdsc: Implement NO_RET_PERIPH flag Sasha Levin
2021-03-02 23:02   ` Stephen Boyd
2021-03-04 21:30     ` Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 27/52] sparc32: Limit memblock allocation to low memory Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 28/52] sparc64: Use arch_validate_flags() to validate ADI flag Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 29/52] ACPICA: Fix race in generic_serial_bus (I2C) and GPIO op_region parameter handling Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 30/52] Input: applespi - don't wait for responses to commands indefinitely Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 31/52] x86, build: use objtool mcount Sasha Levin
2021-03-02 18:42   ` Kees Cook
2021-03-12 22:10     ` Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 32/52] PCI: xgene-msi: Fix race in installing chained irq handler Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 33/52] misc: eeprom_93xx46: Add quirk to support Microchip 93LC46B eeprom Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 34/52] PCI: mediatek: Add missing of_node_put() to fix reference leak Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 35/52] drivers/base: build kunit tests without structleak plugin Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 36/52] drm/msm/a5xx: Remove overwriting A5XX_PC_DBG_ECO_CNTL register Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 37/52] PCI/LINK: Remove bandwidth notification Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 38/52] ext4: don't try to processed freed blocks until mballoc is initialized Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 39/52] PCI: cadence: Retrain Link to work around Gen2 training defect Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 40/52] kbuild: clamp SUBLEVEL to 255 Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 41/52] PCI: Fix pci_register_io_range() memory leak Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 42/52] i40e: Fix memory leak in i40e_probe Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 43/52] PCI/ERR: Retain status from error notification Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 44/52] kasan: fix memory corruption in kasan_bitops_tags test Sasha Levin
2021-03-02 11:55 ` Sasha Levin [this message]
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 46/52] s390/smp: __smp_rescan_cpus() - move cpumask away from stack Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 47/52] drivers/base/memory: don't store phys_device in memory blocks Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 48/52] sysctl.c: fix underflow value setting risk in vm_table Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 49/52] scsi: libiscsi: Fix iscsi_prep_scsi_cmd_pdu() error handling Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 50/52] nbd: handle device refs for DESTROY_ON_DISCONNECT properly Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 51/52] scsi: target: core: Add cmd length set before cmd complete Sasha Levin
2021-03-02 11:55 ` [PATCH AUTOSEL 5.11 52/52] scsi: target: core: Prevent underflow for service actions Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210302115534.61800-45-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=alex@ghiti.fr \
    --cc=dvyukov@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=palmerdabbelt@google.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).