From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 716FC38331D for ; Wed, 1 Jul 2026 04:11:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782879074; cv=none; b=aBOR748ynfKTpTidF6NITuqic2TFNKIR86zd5Mz2zz/+zlWbIPXQBL1KEJv8mldKmddOVJ5lw6VTrfXFd0mrYaVY8QRjCEGCkSLhpIPtn2j2rEH6deAukeK7aJqkiJ11jghomJsYg1MWb5qA7OxNOKNGSx8h3rAcihNs6TBcpQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782879074; c=relaxed/simple; bh=RIqZcZ9zyrRPZJqgmdqdEAT57VY3wOGOHOhQhWHzfuU=; h=Date:To:From:Subject:Message-Id; b=nlyZCcTaN4rJWJjCo1cuuQReQu4rLAqTqocyD6RiO7CzSS/uX6O9bntilmdUUwGLk+yA9MVfYzyTdyKumSSQqj4O+09hXP6qdJZxiAacr8UWg6DjU2MJPWQ6uUrg5uUGkO4WSBJSj8LEvvv++EcoAhrnMECd0Gcco3wl9kNs7S8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=sRJq8+qY; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="sRJq8+qY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B77681F00A3A; Wed, 1 Jul 2026 04:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1782879065; bh=zmc7CKOzWoLPyIz1hE1787NC2SNn2inaJ2UI/NuPQrg=; h=Date:To:From:Subject; b=sRJq8+qY0t+o5I2xYsd1+VFo8Yo5S6lcBl5pw+TY3+rKyZhy7B+L5Y0WowhJYN+K8 HmRUUcBEhDKAJQ6B2rStbaX8ieJJqhREjoVroAQIZXe9RuMOiAspUkYKV+jH0p6XSs cqhR65oyPOxA9n33H+Cydrdl4r2CO9KYSmB4MjTk= Date: Tue, 30 Jun 2026 21:11:05 -0700 To: mm-commits@vger.kernel.org,vbabka@kernel.org,surenb@google.com,rppt@kernel.org,palmer@dabbelt.com,mhocko@suse.com,ljs@kernel.org,liam@infradead.org,david@kernel.org,alex@ghiti.fr,wangruikang@iscas.ac.cn,akpm@linux-foundation.org From: Andrew Morton Subject: + riscv-mm-avoid-spurious-fault-after-hotplugging-vmemmap.patch added to mm-nonmm-unstable branch Message-Id: <20260701041105.B77681F00A3A@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: riscv: mm: avoid spurious fault after hotplugging vmemmap has been added to the -mm mm-nonmm-unstable branch. Its filename is riscv-mm-avoid-spurious-fault-after-hotplugging-vmemmap.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/riscv-mm-avoid-spurious-fault-after-hotplugging-vmemmap.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Vivian Wang Subject: riscv: mm: avoid spurious fault after hotplugging vmemmap Date: Tue, 30 Jun 2026 15:51:59 +0800 section_activate() does not flush TLB after populating new vmemmap pages. On most architectures, this is okay. However it is a problem on RISC-V since there the TLB caching non-present entries is permitted, which causes spurious faults on some hardwares. This seems to be most easily reproduced with DEBUG_VM=y and PAGE_POISONING=y, which causes these newly mapped struct pages to be poisoned i.e. written to immediately after mapping. Add a hook vmemmap_populate_finalize() in __populate_section_memmap() after population, to allow architectures to handle such situations as needed. Then implement it on RISC-V to arrange for the existing exception handler code to deal with these faults if they happen. Link: https://lore.kernel.org/20260630-mark-after-vmemmap-populate-v4-1-febbc15da028@iscas.ac.cn Signed-off-by: Vivian Wang Cc: Alexandre Ghiti Cc: David Hildenbrand Cc: Liam R. Howlett Cc: Lorenzo Stoakes Cc: Michal Hocko Cc: Mike Rapoport Cc: Palmer Dabbelt Cc: Suren Baghdasaryan Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- arch/riscv/include/asm/pgtable.h | 4 ++++ arch/riscv/mm/init.c | 6 ++++++ mm/sparse-vmemmap.c | 8 ++++++++ 3 files changed, 18 insertions(+) --- a/arch/riscv/include/asm/pgtable.h~riscv-mm-avoid-spurious-fault-after-hotplugging-vmemmap +++ a/arch/riscv/include/asm/pgtable.h @@ -1260,6 +1260,10 @@ static inline pte_t pte_swp_clear_exclus #define TASK_SIZE FIXADDR_START #endif +/* Needed on SPARSEMEM_VMEMMAP */ +#define vmemmap_populate_finalize vmemmap_populate_finalize +void __meminit vmemmap_populate_finalize(void); + #else /* CONFIG_MMU */ #define PAGE_SHARED __pgprot(0) --- a/arch/riscv/mm/init.c~riscv-mm-avoid-spurious-fault-after-hotplugging-vmemmap +++ a/arch/riscv/mm/init.c @@ -1372,6 +1372,12 @@ int __meminit vmemmap_populate(unsigned */ return vmemmap_populate_hugepages(start, end, node, altmap); } + +void __meminit vmemmap_populate_finalize(void) +{ + /* Avoid faults on cached non-present TLB entries. */ + mark_new_valid_map(); +} #endif #if defined(CONFIG_MMU) && defined(CONFIG_64BIT) --- a/mm/sparse-vmemmap.c~riscv-mm-avoid-spurious-fault-after-hotplugging-vmemmap +++ a/mm/sparse-vmemmap.c @@ -544,6 +544,12 @@ static int __meminit vmemmap_populate_co #endif +#ifndef vmemmap_populate_finalize +static void __meminit vmemmap_populate_finalize(void) +{ +} +#endif + struct page * __meminit __populate_section_memmap(unsigned long pfn, unsigned long nr_pages, int nid, struct vmem_altmap *altmap, struct dev_pagemap *pgmap) @@ -564,6 +570,8 @@ struct page * __meminit __populate_secti if (r < 0) return NULL; + vmemmap_populate_finalize(); + return pfn_to_page(pfn); } _ Patches currently in -mm which might be from wangruikang@iscas.ac.cn are riscv-mm-avoid-spurious-fault-after-hotplugging-vmemmap.patch