summaryrefslogtreecommitdiff
path: root/arch/arm64
AgeCommit message (Collapse)Author
101 min.Merge tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpfHEADmasterLinus Torvalds
Pull bpf fixes from Alexei Starovoitov: "Mostly sockmap fixes as promised, plus uprobe ctx rewrite via bpf and cgroup-bpf fixes. - Reject writable map iterators on read-only maps (Adethya Srinivasan) - Various sockmap fixes (Alexei Starovoitov): - Clear the redirect target before the sk_msg prog runs - Check that the redirected message is the cork - Leave sk_stream_wait_memory() once the socket is dead - Keep the rest of the cork after a redirect - Don't let an SK_PASS verdict cover the next message - Subtract all dropped bytes from the return value of sendmsg() - Clear the end mark of elements added by bpf_msg_push_data() and bpf_msg_pop_data() - Fix ring capacity invariant break in bpf_msg_push_data() (Bo Cao) - Report RCU-tasks quiescent states in do_check() to fix rcu_tasks stalls during a long verification (Breno Leitao) - Various sockmap fixes (Chris Mason): - Give no progs to a TCP listener - Check the target of an egress redirect before each send - Check the TCP state in recvmsg() - Reset the copy position when corking - Don't copy 0 bytes into a full cork - Use a dedicated workqueue for freeing BPF programs to fix a deadlock between pack_mutex waiters and the vmalloc purge work (Emil Tsalapatis) - Fix verifier model mismatch on a narrow read of __sk_buff.remote_port (Henry Martin) - Fix bpf-gcc CO-RE relocation in verifier_sockmap_mutate selftest (Jiayuan Chen) - Restrict uprobe ctx writes to the registers that ptrace can set (Jiri Olsa) - Various sockmap fixes (Josef Bacik): - Write sg.start when recvmsg() faults - Don't let an SK_DROP verdict stick - Clear the resume state of a stopped psock - Various fixes (Michal Luczaj): - Fix "unresolved symbol tcp_request_sock" build error with CONFIG_INET=n - Restrict iter-context sockmap updates to iter/sockmap - Restrict bpf_sock_destroy() to iter/{tcp,udp} - Mark bpf_iter__sockmap::sk as PTR_TRUSTED - Mark backing_file_alloc/free LSM hooks as untrusted (Sergei Nizovtsev) - Various cgroup-bpf fixes (Shakeel Butt): - Don't read freed effective arrays in BPF_PROG_QUERY - Don't attach to a removed cgroup - Protect cgroup_bpf state with its own mutex, so that queries and the release work don't wait for cgroup_mutex - Don't lose errors in effective BPF_LSM_CGROUP queries - Check variable-offset accesses against special fields (Shihuang Liu)" * tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf: (38 commits) selftests/bpf: Test which ctx registers a uprobe prog can write bpf: Restrict uprobe ctx writes to the registers ptrace can set selftests/bpf: Fix bpf-gcc CO-RE relocation in verifier_sockmap_mutate bpf, cgroup: Don't lose errors in effective BPF_LSM_CGROUP queries bpf, cgroup: Protect cgroup_bpf state with its own mutex bpf, cgroup: Don't attach to a removed cgroup bpf, cgroup: Don't read freed effective arrays in BPF_PROG_QUERY bpf: Fix verifier model mismatch on __sk_buff.remote_port narrow read bpf: Fix "unresolved symbol tcp_request_sock" build error selftests/bpf: Add iter/sockmap bpf_sock_destroy() negative test bpf: Mark bpf_iter__sockmap::sk as PTR_TRUSTED bpf: Restrict bpf_sock_destroy() to iter/{tcp,udp} bpf, docs: Document BPF_ITER_NOSLEEP selftests/bpf: Add negative test for sockmap update from non-sockmap iter bpf, sockmap: Restrict iter-context sockmap updates to iter/sockmap selftests/bpf: Remove sockmap update from bpf_iter_unix bpf, lsm: Mark backing_file_alloc/free LSM hooks as untrusted bpf: Report RCU-tasks quiescent states in do_check() bpf: Check variable-offset accesses against special fields bpf: Use dedicated workqueue for freeing BPF programs ...
11 hoursMerge tag 'arm64-fixes' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux Pull arm64 fixes from Catalin Marinas: "BBML3 allow-list corrections for Cortex-X4 and Neoverse-V3/V3AE following updated errata, a kCFI oops during kexec relocation and NEON intrinsics type mismatches causing CRC64 and XOR build failures with tip-of-tree Clang: - Remove Cortex-X4 and Neoverse-V3/V3AE from the BBML3 allow list Updated errata documents show that revisions previously reported as fixed remain affected by load/store livelocks when changing mapping sizes without break-before-make - Fix a kCFI oops during kexec image relocation. Give the relocation routine a type hash and enter the copied code at the correct offset - Fix the build with recent Clang versions by removing the stdint.h type overrides for NEON intrinsics. The CRC64 and XOR intrinsics code no longer includes the kernel's type header" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: Drop stdint.h type overrides from asm/neon-intrinsics.h xor: arm/arm64: Move NEON xor_gen() dispatch into the glue code lib/crc: Don't include <linux/types.h> in NEON intrinsics code arm64: kexec: use a typed entry to fix kCFI oops arm64: cpufeature: Remove Cortex-X4 from the BBML3 allow list arm64: cpufeature: Remove Neoverse-V3/AE from the BBML3 allow list
25 hoursbpf: Restrict uprobe ctx writes to the registers ptrace can setJiri Olsa
Since commit 7384893d970e ("bpf: Allow uprobe program to change context registers") a uprobe program can write any field of struct pt_regs. Some of those fields are not plain user registers. The exit to user space loads them into the CPU: arch field exit path ptrace ------ ------ ------------------------------- ------------------ riscv status csrw CSR_STATUS, a0 not in the regset arm64 pstate msr spsr_el1, x22 valid_user_regs() x86-64 cs, ss (cs & 3) == 0: iretq to ring 0 set_segment_reg() x86-64 flags iretq loads IF and IOPL set_flags() On riscv a program that sets sstatus.SPP in pt_regs.status makes ret_from_exception return to user code in supervisor mode. On x86-64 a program that writes a kernel selector to cs makes iretq return to ring 0. ptrace guards these fields, but the bpf verifier does not. Add arch_uprobe_regs_writable(). Each arch lists the registers that ptrace can set to any value, and kprobe_prog_is_valid_access() rejects writes to any other offset when the program is loaded: arm64: x0 to x30, sp, pc riscv: epc, ra to t6 x86-64: r15 to di, ip, sp The default is no writes, so arches without a list (and 32-bit x86) lose ctx writes for uprobe programs. Reads are not affected. flags on x86-64 and pstate on arm64 become read-only, including the condition bits that ptrace would let a debugger change. orig_ax is read-only too. Kprobe programs that write ctx were already rejected when they were attached. Those that write one of these fields now fail to load. Fixes: 7384893d970e ("bpf: Allow uprobe program to change context registers") Reported-by: rtm@csail.mit.edu Suggested-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261118084451.12590-2-jolsa@kernel.org Closes: https://lore.kernel.org/bpf/30318.1794850523@30-11-166.wireless.csail.mit.edu/
2 daysarm64: Drop stdint.h type overrides from asm/neon-intrinsics.hArd Biesheuvel
None of the users of NEON intrinsics include <linux/types.h> anymore, and so there is no longer a need to override __INT64_TYPE__ and __UINT64_TYPE__ in order to make the definitions of int64_t and uint64_t provided by the compiler's freestanding <stdint.h> compatible with the kernel's. So drop the overrides. This also means that uint64_t now matches the type that Clang uses for 64-bit quantities in the prototypes of its NEON builtins, and so the -Wincompatible-pointer-types warnings that are currently being disabled for all NEON intrinsics code will no longer occur. So drop the pragma that disables them as well. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Eric Biggers <ebiggers@kernel.org> Cc: <stable@vger.kernel.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2 daysarm64: kexec: use a typed entry to fix kCFI oopsBen Cressey
An arm64 Linux kernel built with CONFIG_CFI=y oopses after "Bye!" on every kexec that relocates the image. Crash images load in place and are not affected. The oops reproduces under QEMU: Unable to handle kernel paging request at virtual address 00000000544bfffc pc : machine_kexec+0x104/0x274 Code: d5182008 d5033fdf aa1303e0 f9418a68 (b85fc110) b85fc110 is "ldur w16, [x8, #-4]", the kCFI check's load of the type hash in front of the callee. Commit efc2d0f20a9d ("arm64: kexec: keep MMU enabled during kexec relocation") made machine_kexec() call the control page's copy of arm64_relocate_new_kernel() indirectly, while TTBR0 maps only that page. The copy starts at the page's first byte, so the load faults. SYM_CODE_START() also gives the routine no hash. SYM_TYPED_FUNC_START() emits the hash inside .kexec_relocate.text, and machine_kexec_post_load() already copies that whole section, at most 4 KiB, to the page's start, so the mapped page holds both hash and entry. The ASSERT from commit dc4824faa265 ("arm64: avoid executing padding bytes during kexec / hibernation") kept the entry first, since C branched to the page's start. Relax it, so the entry need only be in the section. Fix by typing the routine with SYM_TYPED_FUNC_START() and a C prototype, and entering the copy at the symbol's offset in the section. The code is Kees Cook's, as posted in review, with two comments and the ASSERT message reworded. An LLM diagnosed the oops. Fixes: efc2d0f20a9d ("arm64: kexec: keep MMU enabled during kexec relocation") Cc: stable@vger.kernel.org Suggested-by: Kees Cook <kees@kernel.org> Link: https://lore.kernel.org/linux-arm-kernel/202609241804.BB23BF10@keescook/ Signed-off-by: Ben Cressey <ben@cressey.dev> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2 daysarm64: cpufeature: Remove Cortex-X4 from the BBML3 allow listRyan Roberts
Cortex-X4 erratum 3043263 can cause a load or store to livelock when mapping size changes without break-before-make or when contiguous hints are programmed inconsistently. The erratum was previously reported as fixed in r0p3. On that basis, commit 5aa4b625762e ("arm64: Add BBM Level 2 cpu feature") added Cortex-X4 from r0p3. The updated Cortex-X4 SDEN v13, dated 18 June 2026, lists r0p0, r0p1, r0p2 and r0p3 as affected and the erratum as open. Remove the entry so Cortex-X4 observes break-before-make, and record the workaround in the silicon errata registry. Fixes: 5aa4b625762e ("arm64: Add BBM Level 2 cpu feature") Cc: stable@vger.kernel.org Link: https://support.arm.com/documentation/109148/13-0/?lang=en Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2 daysarm64: cpufeature: Remove Neoverse-V3/AE from the BBML3 allow listRyan Roberts
Neoverse-V3 and Neoverse-V3AE erratum 3053180 can cause a load or store to livelock when mapping size changes without break-before-make or when contiguous hints are programmed inconsistently. The erratum was previously reported as fixed in r0p2. On that basis, commit 5aa4b625762e ("arm64: Add BBM Level 2 cpu feature") allowed Neoverse-V3 from r0p2, and commit 8fca3852e33d ("arm64: cpufeature: add Neoverse-V3AE to BBML2 allow list") did the same for Neoverse-V3AE. The updated SDENs, MP168 v11 for Neoverse-V3 and MP172 v12 for Neoverse-V3AE, dated 9 June 2026, list r0p0, r0p1 and r0p2 as affected and the erratum as open. There is no fixed revision on which to base either allow-list entry. Remove both entries so these CPUs observe break-before-make, and record the workaround in the silicon errata registry. Fixes: 5aa4b625762e ("arm64: Add BBM Level 2 cpu feature") Fixes: 8fca3852e33d ("arm64: cpufeature: add Neoverse-V3AE to BBML2 allow list") Cc: stable@vger.kernel.org Link: https://support.arm.com/documentation/109231/11-0/?lang=en Link: https://support.arm.com/documentation/109704/12-0/?lang=en Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2 daysMerge tag 'mm-hotfixes-stable-2026-11-17-19-55' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Pull MM fixes from Andrew Morton: - "maple_tree fixes for 7.3" (Liam R. Howlett): Fix an RCU reader NULL dereference when the tree is emptied during a walk, including /proc/PID/maps racing with munmap(). Add tests and make debug WARN and BUG checks report failures properly - "mm/kasan: Detect double-free involving kfree_rcu_sheaf()" (Kuniyuki Iwashima): Detect double-free when an object enters an RCU sheaf. KASAN could previously miss it until the object was reused, leading to a later free of a live object. Add KUnit tests for the different free orders - "mm: Fix page-table teardown during memory hot-remove" (Muchun Song): Balance page-table constructors and destructors when hot-remove frees tables on x86-64, RISC-V and arm64. This fixes NR_PAGETABLE accounting for tables with and without constructors - "mm/damon: fix watermark state, kunit pid leak and selftest fake pass" (SJ Park): Recompute watermark wait state when DAMON schemes are removed, so kdamond resumes monitoring. Fix a pid reference leak in KUnit and a selftest that reports a skipped run as a pass - An XArray iterator could step backwards when a large page-cache entry was split, sending filemap_map_pages() outside the PTE page it locked. The XArray correction and a filemap bound check prevent out-of-bounds accesses and use-after-free. Another XArray fix prevents lockless walkers from following a parent pointer into a freed node - Userfaultfd now validates the whole write-protection range before changing any VMA, avoiding partial unprotect without waking blocked faults. Failed unmaps now abort queued UFFD_EVENT_UNMAPs; previously they could report a nonexistent unmap, leak the userfaultfd context and leave later operations returning -EAGAIN. A fork fix clears stale uffd PTE bits if the new context is released before its event is read - Moving the hugetlbfs inode trace event before RCU freeing avoids a use-after-free of its superblock. Shmem swapin no longer retries forever on reused swap slots containing a mismatched large swap-cache folio. Swapoff also avoids a cluster-list loop that can soft-lock reclaim and leave swapoff hung - Weighted interleave recalculation now uses one node set throughout, avoiding a divide-by-zero during memory hotplug. Hwpoison holds the folio lock when inspecting its mapping and no longer leaks a folio reference; it also updates poison statistics before notifying rasdaemon through a trace event - Cross-node migration now moves NR_FILE_THPS and NR_KERNEL_FILE_PAGES with page-cache folios, preventing per-node and memcg-node accounting from retaining stale counts or underflowing after the folios are freed * tag 'mm-hotfixes-stable-2026-11-17-19-55' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (27 commits) xarray: fix index jumping backwards in xas_find() userfaultfd: validate the whole range before changing write protection maple_tree: update internal warning and bug_on code maple_tree: test emptying tree while RCU reading maple_tree: fix rcu reader NULL dereference after the tree is emptied mm/vma: read anon_vma carefully in validate_mm() hugetlbfs: move hugetlbfs_free_inode tracepoint to ->destroy_inode() selftests/damon/sysfs_memcg_path_leak: define ksft_skip mm/damon/tests/sysfs-kunit: fix leaked pid reference in add_targets test mm/damon/core: reset watermark wait state on each iteration mm/filemap: stop fault-around when the walk steps back mm: memory-failure: update statistics before emitting the trace event mm/vma: undo userfaultfd unmap preparation when unmapping fails userfaultfd: clear uffd state in child PTEs if uffd is released during fork mm/memory-failure: fix folio refcount leak and min_order_for_split() locking mm/shmem: fix swapin livelock on a mismatched large swap cache folio mm/mempolicy: use one node set for interleave weights xarray: clear the new head's parent before freeing the old head arm64/mm: fix destructor for unconstructed hotplug page tables riscv/mm: fix missing destructor for hotplug PUD tables ...
7 daysMerge tag 'arm64-fixes' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux Pull arm64 fixes from Catalin Marinas: "Fix hugetlb write fault livelock, permission overlay and GCS state preservation across CPU suspend, cpuidle context tracking during system suspend, GCS mode handling on signal return, AMU counter errata workarounds, kexec loading of images with a non-zero text_offset and a spurious ptrace warning: - Fix hugetlb write fault livelocks caused by stale read-only TLB entries after another CPU makes the page writable and only performs a local invalidate. Unlike the generic fault path, hugetlb has no fix_spurious_fault() fallback - Save and restore POR_EL0, GCSPR_EL0 and GCSCRE0_EL1 across CPU suspend - Restrict cpuidle context tracking in cpu_suspend() to idle tasks, avoiding context tracking warnings during system suspend - Ignore attempts to change GCS mode through signal return, which updated the software state without updating the hardware. Changes made through prctl() in the signal handler are preserved. This changes the documented ABI but no known userspace relies on it. Allowing mode changes through both prctl() and signal return also creates confusing interactions, with signal return potentially undoing changes deliberately made by the handler - Extend the AMU constant counter workaround to additional CPUs and add a core cycle counter workaround for Cortex-A715/A720, treating the affected counters as unavailable - Avoid CMA allocations when loading a kexec Image with a non-zero text_offset, fixing an incorrect entry point and a memory leak when freeing the image - Remove a spurious ptrace warning when setting the syscall number of a task in a non-seized group-stop without siginfo" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: suspend: Only track cpuidle context for idle tasks arm64: ptrace: don't warn on missing siginfo in a group-stop arm64: kexec_file: Do not use CMA for images with a non-zero text_offset arm64: errata: Add Cortex-A715/A720 AMU core counter workaround arm64: errata: Extend the workaround for broken AMEVCNTR01 counter arm64/gcs: Ignore attempts to change GCS mode during signal return arm64: hugetlb: Prevent write fault livelocks on stale TLB entries arm64: suspend: Save GCS state over suspend arm64: suspend: Save POR_EL0 over suspend
7 daysarm64: suspend: Only track cpuidle context for idle tasksUladzislau Zhauniarovich
Commit 19235e472798 ("cpuidle, arm64: Fix the ARM64 cpuidle logic") moved the calls to ct_cpuidle_enter() and ct_cpuidle_exit() into cpu_suspend() so that arm64 cpuidle could keep RCU watching longer and manage context tracking internally. However, cpu_suspend() is called not only by cpuidle via psci_cpu_suspend_enter() (which runs in the context of the idle task), but also during system suspend via psci_system_suspend_enter() (which runs in the context of the task initiating suspend, such as a process writing to /sys/power/state). When entering system suspend, current is a non-idle task. Calling ct_cpuidle_enter() invokes ct_kernel_exit() from kernel space (!user) on a non-idle task. With CONFIG_RCU_EQS_DEBUG enabled, this violates context tracking invariants and triggers a warning: WARNING: kernel/context_tracking.c:120 at ct_kernel_exit+0x1b4/0x1f4 kernel/context_tracking.c:118 Call trace: ct_kernel_exit+0x1b4/0x1f4 kernel/context_tracking.c:118 ct_idle_enter+0x20/0x34 kernel/context_tracking.c:299 ct_cpuidle_enter include/linux/cpuidle.h:134 [inline] cpu_suspend+0x264/0x474 arch/arm64/kernel/suspend.c:136 psci_system_suspend_enter+0x4c/0x80 drivers/firmware/psci/psci.c:544 suspend_enter kernel/power/suspend.c:468 [inline] suspend_devices_and_enter+0x88c/0xd0c kernel/power/suspend.c:533 enter_state kernel/power/suspend.c:618 [inline] pm_suspend+0x498/0x698 kernel/power/suspend.c:644 state_store+0x14c/0x1fc kernel/power/main.c:819 kobj_attr_store+0x6c/0x90 lib/kobject.c:842 sysfs_kf_write+0xe0/0x108 fs/sysfs/file.c:145 kernfs_fop_write_iter+0x260/0x3b8 fs/kernfs/file.c:345 vfs_write+0x51c/0xa0c fs/read_write.c:687 ksys_write+0x12c/0x228 fs/read_write.c:739 A corresponding warning is subsequently triggered in ct_kernel_enter() via ct_cpuidle_exit() upon resume. Fix this by checking is_idle_task(current) in cpu_suspend() and only invoking ct_cpuidle_enter() and ct_cpuidle_exit() when executing in the context of an idle task. Fixes: 19235e472798 ("cpuidle, arm64: Fix the ARM64 cpuidle logic") Cc: <stable@vger.kernel.org> Assisted-by: Gemini:gemini-3.8-flash Gemini:gemini-3.1-pro-preview syzbot Reported-by: syzbot+79883955da3a62652a80@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=79883955da3a62652a80 Link: https://syzkaller.appspot.com/ai_job?id=5359e16f-013b-4850-9cbc-ddfb3bac95e5 Signed-off-by: Uladzislau Zhauniarovich <uladzislau.zhauniarovich@gmail.com> Tested-by: Uladzislau Zhauniarovich <uladzislau.zhauniarovich@gmail.com> Link: https://lore.kernel.org/r/3e92ccb0-2952-4317-af4c-45457c15efae@gmail.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
8 daysarm64: ptrace: don't warn on missing siginfo in a group-stopZhao Gongyi
PTRACE_ATTACH to a group-stopped child can enter do_jobctl_trap(), which calls ptrace_stop() without siginfo. If the tracer writes NT_ARM_SYSTEM_CALL, system_call_set() can change syscallno from NO_SYSCALL before update_syscall_orig_x0_after_ptrace() checks last_siginfo. WARN_ON_ONCE(!info) then fires for a valid ptrace stop. Keep the early return when siginfo is absent, but remove the warning. This leaves orig_x0 untouched at a non-seized group-stop and preserves the existing syscall-exit-stop handling. Fixes: 88b839ce497c ("arm64: ptrace: Keep 'orig_x0' in-sync with x0 on syscall entry") Cc: stable@vger.kernel.org Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com> Acked-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Will Deacon <will@kernel.org> [catalin.marinas@arm.com: modified comment as per Will's suggestion] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
8 daysarm64: kexec_file: Do not use CMA for images with a non-zero text_offsetJinjie Ruan
image_load() adds text_offset to kernel_segment->mem and subtracts it from kernel_segment->memsz. For CMA backed segments this breaks the load path: the payload is copied to page_address(cma), which is the CMA base, while image->start is set to the adjusted address, so kexec jumps into the middle of the kernel. kimage_map_segment() has the same mismatch when a segment has been moved. The adjusted memsz also breaks the release path: the CMA pages are freed using segment->memsz >> PAGE_SHIFT, which is fewer than were allocated, leaking the tail of the allocation. Both problems are specific to CMA segments, which are accessed through page_address(cma) and ignore segment->mem. The normal load path uses segment->mem, so the text_offset adjustment stays consistent there. Keep honoring text_offset, but load such images from regular memory by setting image->no_cma: they lose the CMA contiguous allocation, but keep working. Fixes: 07d24902977e ("kexec: enable CMA based contiguous allocation") Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Cc: Will Deacon <will@kernel.org> Cc: Mike Rapoport <rppt@kernel.org> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/20260921090450.807575-2-ruanjinjie@huawei.com/ Link: https://lore.kernel.org/all/20260921090450.807575-3-ruanjinjie@huawei.com/ Link: https://lore.kernel.org/all/au4JOjnQlx2aSpiE@arm.com/ Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
8 daysarm64: errata: Add Cortex-A715/A720 AMU core counter workaroundBeata Michalska
On Cortex-A715 (erratum 2738462) and Cortex-A720 (erratum 2738461), the AMEVCNTR00 counter may continue incrementing while the core remains in WFE with the clocks being enabled. The resulting core cycle count may become unreliable. Add a workaround that effectively treats the AMU counter as unavailable. Cc: <stable@vger.kernel.org> Signed-off-by: Beata Michalska <beata.michalska@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
8 daysarm64: errata: Extend the workaround for broken AMEVCNTR01 counterBeata Michalska
The erratum causing significant inaccuracies in the AMU CNT_CYCLES counter due to WFI/WFE has been identified in additional microarchitectures. Extend the existing workaround to cover these implementations, which are affected by the following errata: - ARM Cortex-A725 erratum 3821522 (SDEN-2832921) - ARM Cortex-A720 erratum 4689339 (SDEN-2439421) - ARM Cortex-A720AE erratum 4689340 (SDEN-3090091) - ARM Neoverse N3 erratum 4689341 (SDEN-3050973) - ARM C1-Pro erratum 4689344 (SDEN-3273080) Cc: <stable@vger.kernel.org> Signed-off-by: Beata Michalska <beata.michalska@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
8 daysarm64/gcs: Ignore attempts to change GCS mode during signal returnMark Brown
If userspace tries to update the GCS mode as part of signal return then we update the thread state but don't update GCSCRE0_EL1, meaning the change does not take effect. We may also get issues for other tasks on context switch since we suppress writes of the register if the two tasks have the same mode. Since no currently known userspace tries to use this functionality close this by ignoring any attempt to change the mode through signal return. The GCS mode for the current thread can be changed using the prctl() interface and will be preserved on signal return, allowing updates to the mode from the signal handler. Reported-by: Catalin Marinas <catalin.marinas@arm.com> Link: https://lore.kernel.org/r/as-8IqsbMbOBo5Oq@arm.com Suggested-by: Catalin Marinas <catalin.marinas@arm.com> Fixes: 16f47bb9ac8a ("arm64/signal: Expose GCS state in signal frames") Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
9 daysarm64: hugetlb: Prevent write fault livelocks on stale TLB entriesChris Down
In Meta production, we have had tasks get stuck in a fault loop while using hugetlb on arm64. During my investigations I found that affected tasks share a private hugetlb page. Looking at the stuck task states, I found the following ordering: CPU0 CPU1 ---- ---- read page [read only entry cached in TLB] write page hugetlb_fault() hugetlb_wp() [reuse folio] set_huge_ptep_maybe_writable() set_huge_ptep_writable() [flush local TLB only] write page using stale entry hugetlb_fault() huge_ptep_set_access_flags() [entry already writable, no flush] retry write using stale entry [fault indefinitely. well, that's not ideal!] The reason is that when a write fault makes a non-contiguous hugetlb entry writable, it only invalidates the local TLB. However, another CPU can keep the old read-only entry, so its write will fault even though the page table already permits it. hugetlb_fault() then finds nothing to change and leaves the stale entry in place, so the same write keeps going round in circles. This is particularly bad because, if the kernel is copying to user memory, the retry stays inside the kernel and the task can't act on the pending signal. It can even remain unkillable while holding locks across the copy, resulting in further failures. For example, a read into a hugetlb buffer can hold the pipe mutex and block other users of the pipe until the loop ends, causing cascading lockups across the machine. To fix this, when a write fault finds nothing to change in a non-contiguous hugetlb entry, let's invalidate the local entry. Fixes: cb1fa2e99955 ("arm64, tlbflush: don't TLBI broadcast if page reused in write fault") Cc: stable@vger.kernel.org Signed-off-by: Chris Down <chris@chrisdown.name> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
9 daysarm64: suspend: Save GCS state over suspendMark Brown
GCSCRE0_EL1 and GCSPR_EL0 are live registers for EL0 on systems with GCS but are not saved and restored by cpu_do_suspend()/cpu_do_resume(). This means that the task that initiated suspend can return to userspace with UNKNOWN or incorrect values for GCSPR_EL0 and GCSCRE0_EL1 (many fields in GCSCRE0_EL1 reset to 0). This will in turn lead to ongoing corruption, including not restoring mode until a task with a different GCS mode is run. Fix this by saving and restoring the values over suspend. This increases the size of struct cpu_suspend_ctx by 16 bytes. Fixes: 5d8b172e7005 ("arm64: Add Kconfig for Guarded Control Stack (GCS)") Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
9 daysarm64: suspend: Save POR_EL0 over suspendMark Brown
POR_EL0 is a live EL0 register on systems with S1POE but it is not saved and restored by cpu_do_suspend()/cpu_do_resume(). This means that the task that initiated suspend can return to userspace with an UNKNOWN value. Fix this by saving and restoring the value over suspend. This increases the size of struct cpu_suspend_ctx. Fixes: bf83dae90fbc ("arm64: enable the Permission Overlay Extension for EL0") Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
11 daysarm64/mm: fix destructor for unconstructed hotplug page tablesMuchun Song
Commit c594b83457cc ("arm64: mm: call pagetable dtor when freeing hot-removed page tables") made free_hotplug_pgtable_page() unconditionally run the page-table destructor. This matches page tables allocated by the arm64 mapping code, which runs the corresponding constructors. However, arm64 also uses the generic sparse-vmemmap population code. Runtime intermediate page tables allocated by that code do not run a page-table constructor. Freeing one during memory hot-remove therefore runs a destructor without a matching constructor and corrupts NR_PAGETABLE accounting. Free intermediate page-table pages through pagetable_free(). It runs the destructor only for constructor-backed pages and then releases the page through the page-table freeing path. Link: https://lore.kernel.org/20261023063428.3658761-5-songmuchun@bytedance.com Fixes: c594b83457cc ("arm64: mm: call pagetable dtor when freeing hot-removed page tables") Signed-off-by: Muchun Song <muchun.song@linux.dev> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Paul Walmsley <pjw@kernel.org> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Björn Töpel <bjorn@rivosinc.com> Cc: Will Deacon <will@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Alistair Popple <apopple@nvidia.com> Cc: <stable@vger.kernel.org>
12 daysMerge tag 'devm_kmalloc_obj-v7.4-rc2' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux Pull devm_kmalloc_obj conversion from Kees Cook: - treewide refresh of kmalloc_obj() conversions - devm_kmalloc_obj conversion rules added to Coccinelle scripting - treewide conversion of devm_kmalloc() family to devm_kmalloc_obj() * tag 'devm_kmalloc_obj-v7.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: treewide: Convert devm_kmalloc() family to the devm_kmalloc_obj() family coccinelle: kmalloc_obj: Include devm_kmalloc_obj conversion rules treewide: refresh kmalloc_obj() conversions
2026-11-06Merge tag 'arm64-fixes' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux Pull arm64 fixes from Catalin Marinas: "Fix SDEI (software delegated exception interface) handlers taking nested exceptions (looping on the KPTI trampoline vectors and clobbering the interrupted context's exception registers), TPIDR2_EL0 preservation across CPU suspend, a kexec_file_load() memory leak and an overflow in the /dev/mem valid_mmap_phys_addr_range() check: - Fix nested exceptions taken by SDEI event handlers. With KPTI, an event interrupting user space left the trampoline vectors installed and any exception in the handler looped forever. Also save and restore ELR/SPSR/ESR/FAR around the handler since an event can interrupt exception entry or return where these registers are live - Save and restore TPIDR2_EL0 across CPU suspend. Its value is UNKNOWN after a warm reset and the task initiating suspend could return to user space with a corrupted value - Fix an overflow in valid_mmap_phys_addr_range() allowing /dev/mem to map out-of-range PFNs - Fix an elf_headers memory leak in the kexec_file segment placement retry loop" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: sdei: Preserve the interrupted context's exception registers arm64: sdei: Run the event handler on the kernel vectors arm64: kexec_file: Fix elf_headers memory leak in retry loop arm64: mm: validate /dev/mem mmap ranges without overflow arm64: suspend: Save and restore TPIDR2_EL0 across CPU suspend
2026-11-06arm64: sdei: Preserve the interrupted context's exception registersKiryl Shutsemau (Meta)
An SDEI event is dispatched by firmware regardless of PSTATE.DAIF, so it can interrupt the kernel where the exception registers are live: - exception entry, before kernel_entry has saved ELR_EL1/SPSR_EL1 and before the C handler has read ESR_EL1/FAR_EL1; - exception return, after kernel_exit has loaded ELR_EL1/SPSR_EL1 and before the ERET. An IRQ or pseudo-NMI cannot arrive there with PSTATE.I set. Firmware saves only x0-x17, PC and PSTATE around an SDEI event, so a synchronous exception taken by the handler overwrites the interrupted context's ELR, SPSR, ESR and FAR. do_sdei_event() only notices that ELR changed, and warns. The interrupted context then carries on with the handler's state. A task interrupted on its way into the kernel can be sent SIGILL for the handler's kernel data abort. A task interrupted on its way back to user space ERETs to EL1, at the handler's fixup address, with user registers loaded. With SDEI delivering NMI backtraces, this happens in normal operation. The handler runs show_regs(), which reads through possibly-NULL pointers with the _nofault() accessors. print_worker_info() faults this way for a kworker that is not running a work item, and a single sysrq-l warned once per such kworker. Save ELR, SPSR, ESR and FAR in __sdei_handler() before irqentry_nmi_enter(), which can take an exception too, and restore them after irqentry_nmi_exit(). Once they are restored, a nested exception is harmless if its handler is safe in NMI context. That holds for EL1 data aborts on translation, permission and access-flag faults, which never take the mmap lock in NMI context, and for BRK. Warn once, with the syndrome, about any other exception class. Fixes: f5df26961853 ("arm64: kernel: Add arch-specific SDEI entry code and CPU masking") Cc: stable@vger.kernel.org Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org> Tested-by: Breno Leitao <leitao@debian.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2026-11-06arm64: sdei: Run the event handler on the kernel vectorsKiryl Shutsemau (Meta)
With KPTI, VBAR_EL1 holds the trampoline vectors from the return to EL0 until the next exception from EL0 maps the kernel and installs the kernel vectors. The trampoline vectors only handle exceptions from EL0; their current-EL half is zero-filled. An SDEI event is dispatched regardless of PSTATE.DAIF, so it lands there whenever the CPU is in user space. The SDEI entry trampoline maps the kernel but leaves VBAR_EL1 alone. An exception taken by the handler then executes the zeros, takes an undefined instruction exception to the same vector, and loops there forever. The event never completes and the CPU is lost; RCU stall reports are the first sign of it. RAS notifications land in user space whenever a task consumes the error, and NMI backtraces land wherever the CPU happens to be. The GHES handler takes no exception on its own, but any exception in the handler path does it: a WARN, a kprobe hit, or a fault fixed up by a _nofault() accessor. Install the kernel vectors in __sdei_handler() when VBAR_EL1 holds the trampoline vectors, and restore it before returning to firmware. The switch covers irqentry_nmi_enter() and irqentry_nmi_exit() too, as Usama Arif pointed out: their tracepoints and context tracking WARNs can take an exception as well. The IRQ-like resume into user space must still go through the trampoline to map the kernel. do_sdei_event() takes the interrupted VBAR_EL1 and keeps basing the resume address on it. Fixes: 79e9aa59dc29 ("arm64: sdei: Add trampoline code for remapping the kernel") Cc: stable@vger.kernel.org Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Tested-by: Breno Leitao <leitao@debian.org> [catalin.marinas@arm.com: use raw_cpu_read() for this_cpu_vector] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2026-11-06arm64: kexec_file: Fix elf_headers memory leak in retry loopJinjie Ruan
A retry allocates new elf headers and overwrites image->elf_headers, leaking the previous buffer. Free it before assigning. Cc: Will Deacon <will@kernel.org> Cc: Thomas Huth <thuth@redhat.com> Cc: Breno Leitao <leitao@debian.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Yeoreum Yun <yeoreum.yun@arm.com> Cc: Baoquan He <bhe@redhat.com> Cc: stable@vger.kernel.org Fixes: 108aa503657e ("arm64: kexec_file: try more regions if loading segments fails") Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> [catalin.marinas@arm.com: drop the redundant NULL check before vfree()] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2026-11-05treewide: refresh kmalloc_obj() conversionsKees Cook
Refresh the tree with run of the existing Coccinelle rules in scripts/coccinelle/api/kmalloc_objs.cocci, now that they also convert arrays of multi-byte integers. The conversions break down as: 435 kzalloc_objs() 169 kmalloc_objs() 52 kvzalloc_objs() 47 kzalloc_obj() 42 kvmalloc_objs() 8 kmalloc_obj() 2 kzalloc_flex() 2 kvmalloc_flex() and 37 existing kmalloc_obj() family calls drop a redundant GFP_KERNEL. Build tested with allmodconfig on x86_64 with GCC 16.2.0, and, together with the devm_kmalloc_obj() conversion that follows, on x86_64, arm64, i386, arm, riscv, s390, m68k, mips, parisc, sparc, loongarch, arc, xtensa, and openrisc with GCC 16.2.0 with no new warnings. Signed-off-by: Kees Cook <kees+treewide@kernel.org>
2026-11-04arm64: mm: validate /dev/mem mmap ranges without overflowZhao Gongyi
An arm64 syzkaller reproducer creates a FUSE character device with major:minor 1:1, so opening it uses the /dev/mem file operations. It maps one page from offset 0xfffffffffffff000 at user address zero. The next openat() with a NULL pathname triggers a synchronous external abort (SEA, ESR 0x96000010) in strncpy_from_user() via do_getname(), panicking the kernel. valid_mmap_phys_addr_range() checks the exclusive end by adding the mapping size to the starting address. For this offset, the sum wraps to zero and passes the PHYS_MASK test, allowing an out-of-range PFN to reach remap_pfn_range(). The inclusive-end overflow check in mmap_mem_prepare() does not catch it because the end is ULONG_MAX. Reject starting PFNs outside PHYS_MASK and compare the inclusive length against the remaining physical range without overflowing. This also allows mappings that end exactly at PHYS_MASK, which the old check incorrectly rejects. Fixes: 1d18c47c735e ("arm64: MMU fault handling and page table management") Cc: stable@vger.kernel.org Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com> [catalin.marinas@arm.com: changed the check to look more like __access_ok()] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2026-11-04arm64: suspend: Save and restore TPIDR2_EL0 across CPU suspendWei Wang
TPIDR2_EL0 is a live EL0 register on systems with SME, but cpu_do_suspend()/cpu_do_resume() don't preserve it. Its value is UNKNOWN after a warm reset, so the task that initiates suspend can return to userspace with a corrupted TPIDR2_EL0. Save and restore it alongside TPIDR_EL0 and TPIDRRO_EL0. The new slot fits in existing padding, so sizeof(struct cpu_suspend_ctx) is unchanged. Fixes: a9d691585950 ("arm64/sme: Implement support for TPIDR2") Cc: stable@vger.kernel.org Acked-by: Will Deacon <will@kernel.org> Reviewed-by: Mark Brown <broonie@kernel.org> Signed-off-by: Wei Wang <wvw@google.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2026-11-02Merge tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpfLinus Torvalds
Pull bpf fixes from Alexei Starovoitov: "Fix various bugs in bpf core and bpf-lwt. Looks like the speed of us fixing bugs is higher than the number of new bugs found. Not out of the woods yet. sockmap fixes will come later. - Various fixes (Alexei Starovoitov): - Use one may_goto time slice per prog invocation instead of one per stack frame to fix a soft lockup in loops that nest across calls - Fix use-after-free in btf__add_type() in libbpf - Invalidate a dynptr slice when its stack buffer is written or when the frame of the buffer returns - Fix the tracking of pointers to the stack in SCEV - Keep the valid bytes of a packet pointer in SCEV - Fix bpf_throw() in a prog with a private stack in x86 JIT - Compare the arguments of an extension prog with those of its target - Don't accept memory of the prog for struct arguments of KF_ACQUIRE kfuncs and for arguments of an empty struct type - Fix mmap() of an arena: refuse address 0 and a length above max_entries pages, etc. - Don't let bpf_skb_adjust_room() raise gso_size to GSO_BY_FRAGS - Fix lwt progs: reset skb->cb and don't leave a stale MAC header after a prog pushes an IP header, require BPF_LWT_REROUTE when an lwt_in prog changes the protocol, don't call into IPv6 when it is disabled, don't look for the SRH again in the End.BPF helpers, and set a dst for test runs of lwt_in progs - Fix bpf_dynptr_copy() for overlapping ranges in one packet (Ayushman Rout) - Various fixes (Chris Mason): - Reject memory of the prog for kfunc projection type arguments - Require prog fd or capability for cgroup prog detach - Keep the skb network offset signed in cgroup skb progs - Reject non-IPv6 packets in BPF_LWT_ENCAP_SEG6 - Limit the SRH length and move the MAC header in bpf_lwt_seg6_adjust_srh() - Move the transport header together with the headers that bpf_skb_adjust_room() and bpf_lwt_seg6_adjust_srh() move, and use the inner transport header after a decap - Check the offset in bpf_skb_generic_{push,pop}() - Mark jmp mode of ftrace direct trampolines on x86 by clearing bit 63 of the address instead of setting bit 0, since an ftrace callback can start at an odd address (Daniel Borkmann) - Fix psock update-side data races on sk->sk_prot and progs in sockmap (Jakub Sitnicki) - Fix skb_pull() BUG in __bpf_redirect_neigh(): make sure that the MAC and IP headers are there and are linear (Jamal Hadi Salim) - Fix jited line info that is off by the CFI preamble on x86-64, arm64 and riscv64 (Jose Fernandez) - Clamp the trace length in __bpf_get_stack() to fix a write after the end of the buffer (Josef Bacik) - Drop percpu_counter from the htab element count, since its lock can deadlock with NMI and tracing progs that update the same map (Puranjay Mohan) - Propagate scalar precision through stack arguments (Xu Yunxiang) - Fix callback recursion selftest with llvm24 (Yonghong Song) - Free the skb when bpf_xmit() fails to expand the headroom (Yuqiang Sun)" * tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf: (61 commits) libbpf: Fix use-after-free in btf__add_type selftests/bpf: Exercise stack argument precision on state reuse bpf: Propagate scalar precision through stack arguments selftests/bpf: Fix callback recursion test with noipa global func selftests/bpf: Test one may_goto time slice per prog invocation bpf: End bpf_loop() when the time of may_goto is up bpf: One may_goto time slice per prog invocation bpf: Pass a pointer to arch_bpf_timed_may_goto() s390/bpf: Support internal-only MOV instruction to resolve per-CPU addrs selftests/bpf: End the loop of parallel_test_bitmap after 50 ms selftests/bpf: Give the first loop of cond_break5 an end selftests/bpf: Don't cast a pointer to .bss in arena_htab_asm bpf: Emit timed may_goto for JITed progs only selftests/bpf: Test writes to the buffer of bpf_dynptr_slice_rdwr() bpf: Invalidate a dynptr slice when its stack buffer is written selftests/bpf: Test a callee that overwrites a spilled pointer of its caller bpf: Don't trust pointers spilled in slots that a callee can write selftests/bpf: Test the join of fp+0 with a value that is not a pointer to stack bpf: Fix the join of fp+0 with a value that is not a pointer to stack selftests/bpf: Run arena_mmap serially and test MAP_FIXED addresses ...
2026-11-02bpf: Pass a pointer to arch_bpf_timed_may_goto()Alexei Starovoitov
arch_bpf_timed_may_goto() gets the offset of count and timestamp in the stack frame in BPF_REG_AX. Arch code adds the frame pointer to it, and calls bpf_check_timed_may_goto() with the result. On arm64, riscv, loongarch, powerpc and s390 the asm function does it. On x86-64 the JIT does it, because the frame pointer is in another register when the prog has a private stack. The next patch moves count and timestamp out of the stack frame. So pass the pointer in BPF_REG_AX, and let the verifier emit the addition: before after r12 = -16 r12 = r10 call arch_bpf_timed_may_goto r12 += -16 call arch_bpf_timed_may_goto The JITs know which register r10 is. The asm functions have a move in place of the addition, and the special case in the x86-64 JIT goes away. These insns run when the count is used up: in each 65535th iteration. The cost of an iteration does not change. Three tests have the insns of may_goto in them. Update them. Tested on x86-64, and on arm64 and s390 in QEMU. riscv, loongarch and powerpc are compile tested only. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261031215543.682284-7-alexei.starovoitov@gmail.com
2026-10-30Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvmLinus Torvalds
Pull more KVM updates from Paolo Bonzini: "ARM64: - Fix a couple of embarrassing merge mistakes in kvmarm-7.4 - Cleanup the HCR_EL2 bit fields to exclusively use the generated definitions, fixings a nasty regression introduced in 6.16, where barriers were not upgraded from NSH to ISH anymore - Fix publication of state when a vcpu is forced out of the guest - Let vcpu pausing nest correctly - Sanitise ID_AA64MMFR3_EL1.S1P[IO]E to follow the rules of the architecture - Don't warn on SMCCC filter reserved range allocation failure - Prevent GICv5 and TLBI hypercalls to be used from the host when pKVM is active - Enforce that only GICv3 guests are supported for pKVM - Don't try to access GICv5 EL2 sysregs from EL1 - Compute architectrally correct values for ID_AA64MMFR3_EL1.S1P[IO]E by checking the feature dependencies - Require matching VGIC and ITS model - Cleanup TRACE_REMOTE dependencies - Fix random comments ARM64 selftests: - selftests: Skip unwritable ID fields in the failed-run test - Move pkvm_selftests() after all CPUs have initialized EL2 RISC-V: - Allow Zicclsm, Ziccamoa, Ziccif, Za64rs for KVM guest - Implement KVM_PRE_FAULT_MEMORY ioctl() - Replace imsic switch-case macros with range checks RISC-V fixes: - Avoid redundant interrupt check for pending timers - Reject vCPU creation after AIA initialization - Fix build with vector support disabled - Fix IPI delivery for out-of-order vcpu_id - Use a raw lock for IMSIC wakeup state - Reject vCPU creation after AIA initialization RISC-V selftests: - Lazy V-extension enablement for KVM selftests - Show sepc/scause/stval CSRs in KVM selftests vcpu dump" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (42 commits) KVM: selftests: Reject GICv3 ITS with a GICv5 VGIC KVM: arm64: vgic: Require matching VGIC and ITS models KVM: arm64: gic-v5: Drop unused addr variable KVM: arm64: Sanitise ID_AA64MMFR3_EL1.S1P[IO]E KVM: arm64: selftests: Skip unwritable ID fields in the failed-run test tracing/remotes: Fix TRACE_REMOTE build when TRACING=n KVM: arm64: Move pkvm_selftests() after all CPUs have initialized EL2 KVM: arm64: Get rid of compatibility HCR_EL2 aliases KVM: arm64: Convert HCR_xyz to HCR_EL2_xyz KVM: arm64: Set HCR_EL2.BSU to Inner Shareable for guests KVM: arm64: Fix stale VGICv3 comments in the nVHE world switch KVM: arm64: vgic: Do not access the GICv5 CPU interface from EL1 KVM: arm64: Validate the host-provided vgic model in pKVM KVM: arm64: Reject the stage-2 flush hypercalls under pKVM KVM: arm64: Return on kvm_gmem_get_pfn() failure in gmem_abort() KVM: riscv: selftest: add Zicclsm, Ziccamoa, Ziccif, Za64rs RISC-V: KVM: Allow Zicclsm, Ziccamoa, Ziccif, Za64rs in guest MAINTAINERS: name the kvm-riscv/linux riscv_kvm_next branch RISC-V: KVM: Don't write MMIO load result to x0 RISC-V: KVM: Use a raw lock for IMSIC wakeup state ...
2026-10-30Merge tag 'arm64-fixes' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux Pull arm64 fixes from Catalin Marinas: "Three fixes that turned up during the merging window: shadow stack not freed during a failed fork or it is unmapped from parent when a worker thread exits (same commit covers both); PTE_CONT set on PROT_NONE entries but subsequently ignored by the unfolding code since pte_valid() is false (pte_present() is true); an MPAM lock not released on the error path. Summary: - Release the GCS on a failed fork. copy_thread() can allocate a GCS for CLONE_VM threads but a later copy_process() failure left the VMA in the parent's mm. Implement exit_thread() to free it and stop kernel threads and user workers inheriting the parent's GCS base/size. Add a kselftest for the clone3() failure case - Do not set PTE_CONT on invalid PTEs in contpte_set_ptes(). Batched set_ptes() of present-invalid entries (e.g. PROT_NONE) created contpte groups that the single-PTE helpers did not unfold, corrupting a neighbouring guard marker via test_and_clear_young_ptes() - Release the MPAM mon_sel lock on the mpam_save_mbwu_state() error paths" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: selftests/arm64: GCS must not leak on a failed clone3 arm64/gcs: release GCS on failed fork arm64/mm: restrict transparent contpte mappings to valid PTEs arm_mpam: Release the mon_sel lock on mpam_save_mbwu_state() errors
2026-10-29arm64/gcs: release GCS on failed forkIván Ezequiel Rodriguez
copy_thread() can map a CLONE_VM GCS and still return 0. A later copy_process() failure calls exit_thread(), but arm64 did not implement it, so the VMA stayed in the parent's mm. Wire HAVE_EXIT_THREAD to gcs_free(). Kernel threads created with CLONE_VM (io_uring and vhost workers) inherit the parent's gcs_base/gcs_size from arch_dup_task_struct() without allocating their own GCS. When such a thread exits, exit_mm() -> mm_release() -> deactivate_mm() -> gcs_free() unmaps the parent's GCS. With the new exit_thread(), a failed copy_process() for one of these threads would do the same. Clear these fields in copy_thread(). Fixes: 506496bcbb42 ("arm64/gcs: Ensure that new threads have a GCS") Cc: stable@vger.kernel.org Cc: Mark Brown <broonie@kernel.org> Assisted-by: LLM Signed-off-by: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com> Reviewed-by: Mark Brown <broonie@kernel.org> Tested-by: Mark Brown <broonie@kernel.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2026-10-29Merge tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpfLinus Torvalds
Pull bpf fixes from Alexei Starovoitov: - Remove BPF_F_ARENA_SCALAR flag and .arena.data section in libbpf that were added for rust-bpf in this merge window. We found a cleaner approach that does it on compiler side instead of kernel/libbpf. No released kernel has them (Alexei Starovoitov) - Fix bpf_send_signal_task() returning -EPERM when it is called from a kernel thread (Aditya Sharma) - Various fixes (Alexei Starovoitov): - Use emit_rsb_call() to call bpf_unwind_target() in x86 JIT to fix objtool warning during the build - Fix scalar evolution: clear delta of a widened register, don't widen a pointer to a buffer, don't clamp a register whose type changed in the loop, and reset the range of a clamped packet pointer - Finish the insn in the state that maybe_fork_scalars() splits off, so that pruning doesn't drop it at the head of a counted loop - Preserve the registers that carry stack arguments across arch_bpf_timed_may_goto() on x86-64, arm64 and riscv64 - Don't re-sort subprog_info[] for every new subprogram - Fix flaky map_kptr and rcu_reentry selftests - Use memmove() in bpf_skb_load_bytes(), bpf_skb_load_bytes_relative() and bpf_xdp_load_bytes(), since the destination can be a slice of the same packet (Ayushman Rout) - Fixes and follow-ups for scalar evolution: reject pointer operands in 32-bit recurrences and latches, don't intersect with the current register range on clamp to avoid a false 'verifier bug', avoid false infinite loop reports, and recognize a 32-bit copy of the induction variable (Eduard Zingerman) - Fix out-of-bounds write to btf->types[] for split BTF and propagate btf_add_type() errors in btf_check_all_metas() (Feng Yang) - Fix use-after-free in bpf_timer callback that fires after its inner map was freed (Mani Tofigh) - Fix x86 JIT stopping before jumps converge: size backward jumps by the insns they jump over (Mykyta Yatsenko) - Fix use-after-free of struct_ops trampoline: dissociate struct_ops progs before the grace period of the map (Qiliang Yuan) - Validate stack argument reads against the caller state to fix out-of-bounds read in the verifier, and reject callbacks with stack arguments (Weiming Shi) - Tie borrowed iterator results and pointers loaded from trusted fields to the lifetime of their source, so that iterator next, destroy and reference release invalidate them (Xu Yunxiang) * tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf: (48 commits) bpf: Don't re-sort subprog_info[] for every new subprogram bpf: Fix out-of-bounds btf->types write for split BTF selftests/bpf: Test stack arguments across may_goto bpf: Keep stack arguments in arch_bpf_timed_may_goto() selftests/bpf: Test maybe_fork_scalars() at the head of a counted loop bpf: Finish the insn in the state that maybe_fork_scalars() splits off selftests/bpf: Test the clamp of pointers in scalar evolution bpf: Reset the range of a packet pointer that scalar evolution clamps bpf: Don't clamp a register whose type changed in the loop selftests/bpf: Test a loop that moves a pointer to a buffer bpf: Don't widen a pointer to a buffer in scalar evolution selftests/bpf: Avoid a page fault in rcu_reentry while the handler is armed selftests/bpf: Wait for the last maps of map_kptr to be freed selftests/bpf: Test that a widened register is not linked bpf: Clear delta of a register that scalar evolution widens bpf, x86: Remove r0_on_stack from fetching atomics in arena bpf: Remove BPF_F_ARENA_SCALAR selftests/bpf: Remove tests for arena access through numbers libbpf: Keep format strings of bpf_printk() in .rodata libbpf: Remove .arena.data ...
2026-10-28Merge tag 'rproc-v7.4' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux Pull remoteproc updates from Bjorn Andersson: - Add Qualcomm QMI Thermal Mitigation Device support for PAS-managed remote processors, with cooling device bindings and configurations for Hamoa, Kodiak, Lemans, Talos, Monaco, and Shikra CDSP and modem subsystems as applicable. - Add per-power-domain proxy performance states for Hawi CDSP and update Hawi, Maili, and SDX75 PAS compatible bindings and the SDX75 device tree. Correct the Qualcomm ADSP startup timeout. - Fetch auto-boot firmware only once and synchronize boot work with device removal. Bound ELF section header accesses, improve trace diagnostics, and update coredump configuration documentation. - Set 48-bit DMA masks for TI K3 DSP and R5 remote processors, correct mailbox message types, and enable compile testing for more TI drivers. Fix i.MX address range boundary checks and DSP runtime PM ordering, and simplify mailbox notification handling. - Harden Xilinx mailbox setup and teardown and avoid sending notifications when the transmit queue is full. Propagate STM32 optional IRQ lookup errors and correct the MediaTek MT8188 SCP register binding. * tag 'rproc-v7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux: (33 commits) remoteproc: qcom_q6v5_pas: Add QMI TMD cooling support for Shikra remoteproc: virtio: Remove stray white space remoteproc: virtio: Replace kmemdup with kmemdup_array remoteproc: virtio: Add vdev_to_rsc() helper remoteproc: core: Fetch the auto-boot firmware only once remoteproc: xlnx: fix typecast warnings remoteproc: qcom_q6v5_pas: enable QMI TMD cooling support remoteproc: qcom: pas: add support for TMD thermal cooling devices soc: qcom: Add QMI TMD support for remote thermal mitigation dt-bindings: remoteproc: qcom,pas: add #cooling-cells property remoteproc: qcom_q6v5_pas: add per-PD proxy performance states for Hawi CDSP dt-bindings: remoteproc: qcom,sm8550-pas: make qcom,hawi-cdsp-pas standalone arm64: dts: qcom: sdx75: Use SM8650 MPSS as fallback compatible dt-bindings: remoteproc: qcom,sm8550-pas: Make SDX75 MPSS fallback to SM8650 dt-bindings: remoteproc: qcom,sm8550-pas: Add Hawi and Maili MPSS as SM8650 fallback dt-bindings: remoteproc: Fix MT8188 SCP regs remoteproc: Use %p for pointer formatting remoteproc: Add compile testing for additional TI drivers remoteproc: k3-dsp: Fix usage of omap_mbox_message and mbox_msg_t remoteproc: k3: Include what we need and only what we need ...
2026-10-28bpf: Keep stack arguments in arch_bpf_timed_may_goto()Alexei Starovoitov
The JITs pass the first stack arguments of a call in registers: x86-64 r9 argument 6 arm64 x5-x7 arguments 6-8 riscv64 a5-a7 arguments 6-8 '*(u64 *)(r11 - 8) = rX' writes such a register in the caller. 'rX = *(u64 *)(r11 + 8)' reads it in the callee. A call changes these registers. Thus the verifier accepts no call between the write and the call of the callee, and no call in the callee before the read. may_goto is not a call for the verifier. But one time in 65535 iterations it calls arch_bpf_timed_may_goto(), and this function calls C code. It saves R0-R5 only. *(u64 *)(r11 - 8) = 0 ; the verifier: argument 6 is 0 call sub sub: 1: may_goto 2f ; C code changes r9 goto 1b 2: r2 = *(u64 *)(r11 + 8) ; r2 is a kernel address r1 = map_value r1 += r2 *(u64 *)(r1 + 0) = 0 On x86-64 the C code changes r9 when the time of may_goto is up. With the hpet clocksource a look at the clock changes r9 too. The prog above crashes the kernel. LLVM does not emit such code: it reads stack arguments at the entry of a function, and it writes them immediately before the call. Save and restore these registers too. The cost is 2 insns on x86-64, 4 on arm64 and 6 on riscv64, one time in 65535 iterations. Fixes: 324c3ca6eed6 ("bpf,x86: Implement JIT support for stack arguments") Fixes: 235b2fe772f5 ("bpf, arm64: Add JIT support for stack arguments") Fixes: ba754185f902 ("riscv, bpf: Add BPF stack arguments support for RV64 JIT") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-19-alexei.starovoitov@gmail.com
2026-10-28bpf: Remove BPF_F_ARENA_SCALARAlexei Starovoitov
Rust has no address spaces. Thus a prog in Rust accesses arena through scalars. With BPF_F_ARENA_SCALAR the verifier accepts each load and each store through a scalar as an access to arena. The verifier rewrites one insn at a time. Thus it must add one insn to each access. The compiler knows the source of each pointer. It can emit one addr_space_cast for each pointer, as it does for the __arena pointers of C. flag: one move for each access cast: one cast for each pointer ax = (u32)r1 r1 = addr_space_cast(r1, 0, 1) r2 = *(u64 *)(ax + 0) r2 = *(u64 *)(r1 + 0) ax = (u32)r1 r3 = *(u64 *)(r1 + 8) r3 = *(u64 *)(ax + 8) 20 progs of rust-bpf, with the flag and with the casts that a prototype of an LLVM pass emits: flag casts moves or casts 1568 571 insns 14864 13938 jited bytes 72351 69111 No released kernel has the flag. LLVM does not emit the casts for Rust at this time. Until it does, Rust progs that access arena do not load. scx_mavd and scx_nitosis set the flag too. They are experimental schedulers in C in sched-ext/scx, and they use the flag to omit __arena. They must use __arena again. This reverts commit 4c651a91bdfc ("bpf: Treat load and store through a number as arena access"). One part stays: BPF_REG_AX in reg2pt_regs[] of the x86 JIT. The fetching AND/OR/XOR atomics in arena use it now. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261027190314.1440199-6-alexei.starovoitov@gmail.com
2026-10-27Merge tag 'mm-stable-2026-10-25-19-27' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Pull more MM updates from Andrew Morton: - "mm: make VMA flag semantics explicit, eliminate VM_SPECIAL" (Lorenzo Stoakes): Replace VM_SPECIAL with helpers describing mapping ownership and behavior. Enforce the mmap flag rules and convert affected drivers, removing ambiguous tests shared by driver mappings and ordinary memory. - "support kselftest on nommu platform" (Hajime Tazaki): Add opt-in mmap and mremap tests for NOMMU systems. Teach the runner to avoid its fork-dependent timeout command and document the build and runtime requirements. - "mm/collapse: separate a collapse from its callers" (Kiryl Shutsemau): Separate huge-page collapse from caller policy. Replace khugepaged identity checks with explicit permissions, and separate scanning from collapse with the mmap_lock drop in one place. - "mm: implement and use vma_has_anon_rmap(), silence KCSAN" (Lorenzo Stoakes): Provide a common helper for testing whether a VMA has anonymous reverse mappings. Document the locking rules, annotate intentional concurrent reads for KCSAN, and convert the core MM callers. - "mm/sparse: remove SECTION_MARKED_PRESENT and further cleanups" (David Hildenbrand): Remove SECTION_MARKED_PRESENT in favor of the early-section flag. Simplify sparse memory initialization, section metadata handling and related PFN validity checks. - "sh: remove NUMA and SPARSEMEM support" (Mike Rapoport): Remove SuperH NUMA and SPARSEMEM support. The extra memory banks have been unusable since the NO_BOOTMEM conversion, leaving only the code and data overhead. - "mm: Unify device DAX and HugeTLB vmemmap population paths" (Muchun Song): Unify the generic device DAX and HugeTLB vmemmap population paths and shared tail-page handling. Remove the duplicate DAX machinery while retaining the powerpc radix implementation. - "kselftest: mm: fix some failure of split_huge_page_test" (Yeoreum Yun): Fix huge-page split tests racing with khugepaged recollapse. Use pagemap and page flags instead of VMA-boundary assumptions which fail when glibc has already enabled THP. - "memcg: move memcgid refcount to objcg to unpin dying memcgs" (Bingfang Guo): Let dying memcgs be freed while swapped-out shmem still holds their IDs. Move ID references to reparentable objcgs, with the necessary swap accounting and RCU lifetime changes. - "mm/truncate: fix data loss when truncating straddling large folios" (Zhang Yi): Preserve out-of-range data when truncating straddling large folios. Fix a lookup race and split-failure handling, and handle minimum folio orders for the forthcoming ext4 iomap buffered I/O path. - "mm/damon: introduce damos quota goal target metric complement flag" (SJ Park): Let DAMOS quota goals use a metric's complement, so utilization can also express free-memory goals without adding separate metrics. Add the sysfs interface, documentation and tests. - "arm64/mm: Standardize printing for pgtable entries" (Anshuman Khandual): Use the generic formatter for arm64 page-table entries, ready for future wider entries. Move the safe-PTE-update check out of the header to avoid an include cycle. - "mm: kmsan: fix iounmap metadata teardown" (Dima Koziuk): Fix KMSAN metadata leaks on iounmap and failed ioremap allocations. Free backing pages before removing their mappings, and share the teardown with partial-allocation cleanup. - "mm/damon/core: preserve quota state when constructing schemes" (Karl Mehltretter): Preserve running DAMOS quota state while validating parameter updates. Even rejected updates could reset accounting and exceed the quota window; add tests for both accepted and rejected updates. - "mm/vmalloc: fix vmalloc_dump_obj VA lookup" (Ye Liu): Fix vmalloc_dump_obj() lookups for last-page addresses and allocations spanning vmap zones. These allocations were being missed in diagnostic output. - "mm: various (urgent?) fixes" (David Hildenbrand): Fix mmap charge leaks and hugetlb use-after-free, wrong-address unmapping, stuck locks and endless faults. Also preserve reservations on failed mremap and handle stale userfaultfd bits. - "maple_tree: fix maple_range_64 crashes in RCU mode" (Dimitris Charisis): Fix pointer and metadata confusion during RCU destruction of maple_range_64 nodes, avoiding double frees and invalid accesses. Add a regression test; no in-tree user currently uses this combination. - "mm: fix hugetlb NR_HUGETLB accounting on folio migration" (Hongfu Li): Fix hugetlb migration and preallocation accounting so /proc/vmstat retains the correct count and memory.numa_stat follows the folio to its new node. - "mm/damon: fix a minor bug, clean code, and add a test" (SJ Park): Fix 32-bit DAMON age overflow which made old regions look young. Share hugetlb folio acquisition code and add a regression test for the previously fixed last-region skipping bug. - "mm/damon/core: cleanup code, reduce stack usage, and add kunit" (SJ Park): Reduce kdamond stack usage and remove unused enums. Add deterministic PSI quota-goal tests which do not depend on the machine's current memory pressure. - "mm/damon: fix the temporal goal tuner's size quota conversion" (Donggeun Yoo): Bound the temporal tuner's quota conversion to prevent overflow and zero effective quotas, which could stop schemes making progress. Add boundary tests. - "Don't use GFP_DMA when calling dma_alloc_coherent" (Baoquan He): Remove redundant GFP_DMA flags from coherent DMA allocation calls. The DMA API already selects the zone from device limits and ignores the caller's flag. - "kselftest: mm: fix intermittent failure khugepaged test" (Yeoreum Yun): Propagate child-process failures in the khugepaged tests and prevent background collapse from racing their checks. This removes false passes and intermittent failures. - "MAINTAINERS: cover all hugetlb headers under HUGETLB SUBSYSTEM" (Enze Li): Cover all hugetlb headers in MAINTAINERS so get_maintainer.pl finds the right maintainers. Also label the closing hugetlb_cgroup.h include guard. Summary of the 65 singletons in this merge: The singletons include a few worthwhile performance fixes. Avoiding unnecessary reverse-map tree updates gave a reported 15.9% improvement in UnixBench's execl test on a 192-core x86 system. A reclaim retry fix stops defrag_mode from spinning under memory.low protection; a reported file-creation stress test ran 5.7 times faster, with far less memory pressure. Narrower hugetlb invalidations also spare KVM guests needless refaults: the reported Redis-in-VM P99 QPS penalty while punching holes fell from 7.09% to 1.45%. Several fixes prevent lost data or corrupted memory. Lazyfree huge-page races with mremap()/munmap() could lose data or access freed memory, and MADV_COLD could lose a concurrent write's dirty bit. Another fix prevents stale migration entries from outliving large folios. On filesystems with blocks smaller than a page, extending a file by 4 GiB or more could expose bytes written past the old EOF through mmap instead of zeroes. That is fixed, along with use-after-free races in PAGEMAP_SCAN during process exit and in memory-cgroup accounting on PREEMPT_RT kernels. Other fixes stop UFFDIO_MOVE spinning forever on pinned large folios, which could wedge other memory operations, and stop mremap() leaking commit charges until allocations fail under strict overcommit. A further fix keeps userfaultfd tracking intact on neighboring mappings. NUMA binding no longer prevents long-term pins when the chosen node has only movable memory, fixing QEMU/VFIO startup and io_uring buffer registration failures. MGLRU also gets a fix for early-boot crashes with memory cgroups disabled at boot, notably in small crash kernels. * tag 'mm-stable-2026-10-25-19-27' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (213 commits) mm: multi-gen LRU: fix NULL lruvec->pgdat deref with memcg disabled on cmdline mm/page_counter: use WRITE_ONCE() for emin/elow when parent is the root mm/memcontrol: publish null pointer before dropping css reference test_maple_tree: test maple_range_64 node in RCU mode maple_tree: fix maple_range_64 crashes in RCU mode mm/vma: avoid broken uffd merge on mremap tools/testing/shared: catch a failed posix_memalign() mm/damon/core: remove unreachable damos charge_{target,addr}_from mm/shrinker: allocate shrinker_info_unit from a dedicated kmem_cache riscv: mm: exclude invalid THP PMDs from page table check mm/damon/core: filter out damos address filter-split failed region fs/proc/task_mmu: pin mm_users in do_pagemap_scan() mm/mempolicy: apply bind policies against the scoped allocation zone mm/vmscan: reclaim every zone in per-node proactive reclaim mm/mremap: correctly uncharge accountable VMAs in error path mm/mremap: populate calculated fields in vrm state correctly MAINTAINERS: add an entry for MEMORY MANAGEMENT - MEMORY MAP mm: bdi: reset min_ratio after the sysfs attributes are gone mm/page_vma_mapped: continue past nonmatching huge PMDs selftests/mm: skip hugetlb cgroup v2 tests without the needed controllers ...
2026-10-27arm64/mm: restrict transparent contpte mappings to valid PTEsZhao Gongyi
The transparent contpte layer treats PTE_CONT as software grouping state. When a valid PTE has PTE_CONT set, the contpte helpers may align an operation to a CONT_PTE_SIZE block and operate on the whole block. The current single-PTE helpers use pte_valid_cont() to identify such groups; this is a helper contract, not an architectural restriction on using PTE_CONT with present-invalid descriptors. Explicit users such as hugetlb manage their contiguous encodings separately. contpte_set_ptes() currently sets PTE_CONT from alignment alone. Batched set_ptes() users can therefore install present-invalid PTEs with PTE_CONT set, for example mprotect(PROT_NONE), NUMA hinting through modify_prot_commit_ptes(), fork() copying a PROT_NONE large folio, or a PMD split installing PAGE_NONE PTEs. This is not a hardware programming problem: invalid descriptors are not translated, so the hardware ignores descriptor bits such as PTE_CONT. It is a software-state problem. Some arm64 fast paths, such as test_and_clear_young_ptes(), test pte_cont() directly instead of pte_valid_cont(). In the observed failure, mprotect(PROT_NONE) installed a full CONT_PTE_SIZE range of present-invalid PTEs with PTE_CONT set. MADV_GUARD_INSTALL then zapped one PTE. The nr == 1 clear_full_ptes() path only unfolds pte_valid_cont() entries, so the neighbouring present-invalid entries kept PTE_CONT while the target entry became a guard marker. clear_refs_pte_range() then reached the marker through: ptep_test_and_clear_young() test_and_clear_young_ptes() contpte_test_and_clear_young_ptes() contpte_align_addr_ptep() __ptep_test_and_clear_young() The marker changed from old_pte=0x00000000000047c0 to new_pte=0x00000000000043c0 by clearing PTE_AF. For swap PTEs, bit 10 is part of the swap type field, bits 6-10: 0x47c0 is SWP_PTE_MARKER with offset 4, while 0x43c0 has type 15 and is decoded as an ordinary swap entry. Zap later warned in swap_put_entries_direct() with a bad swap entry. Present-invalid PTEs could retain PTE_CONT as software grouping state, but their single-PTE modification paths would then need to recognize and unfold those groups consistently. Since current helpers mostly use pte_valid_cont() for membership, avoid creating present-invalid transparent contpte groups in contpte_set_ptes(). They bring no hardware benefit while invalid, and eligible valid ranges can be grouped again when they are installed. The public set_ptes() wrapper already clears PTE_CONT before calling contpte_set_ptes(). Return invalid PTEs through __set_ptes() directly, and warn if a future direct caller unexpectedly passes an invalid PTE with PTE_CONT set. This is triggerable by a user process against its own address space. On systems running with panic_on_warn, the warning becomes a denial of service. Fixes: 4602e5757bcc ("arm64/mm: wire up PTE_CONT for user mappings") Cc: stable@vger.kernel.org Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> Tested-by: Lance Yang <lance.yang@linux.dev> Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2026-10-26Merge branch kvm-arm64/misc-fixes-7.4-1 into kvmarm-master/fixesMarc Zyngier
* kvm-arm64/misc-fixes-7.4-1: : \ : Misc fixes: : : - Don't warn on SMCCC filter reserved range allocation failure : : - Correctly prevent GICv5 and some TLBI hypercalls to be used from : the host when pKVM is active : : - Enforce that only GICv3 guests are supported for pKVM : : - Don't try to access GICv5 EL2 sysregs from EL1 : : - Cleanup TRACE_REMOTE dependencies : : - Compute architectrally correct values for ID_AA64MMFR3_EL1.S1P[IO]E : by checking the feature dependencies : : - Fix random comments : / KVM: arm64: Sanitise ID_AA64MMFR3_EL1.S1P[IO]E tracing/remotes: Fix TRACE_REMOTE build when TRACING=n KVM: arm64: Fix stale VGICv3 comments in the nVHE world switch KVM: arm64: vgic: Do not access the GICv5 CPU interface from EL1 KVM: arm64: Validate the host-provided vgic model in pKVM KVM: arm64: Reject the stage-2 flush hypercalls under pKVM KVM: arm64: Reject the GICv5 CPU interface hypercalls under pKVM KVM: arm64: Don't WARN on SMCCC filter reserved range allocation failure Signed-off-by: Marc Zyngier <maz@kernel.org>
2026-10-26Merge branch kvm-arm64/cross-vcpu-sync into kvmarm-master/fixesMarc Zyngier
* kvm-arm64/cross-vcpu-sync: : \ : Fix a number of issues related to publication of state when a vcpu : is forced out of the guest, address other problems related to the : nesting and overhead of pausing the VM, and apply all of that to : some of the nasty corners of the VGIC handling. : : This eventually simplifies the handling of operations that are : inherently racy by pausing the involved vcpus. : / KVM: arm64: vgic-its: Remove the pending state of a discarded LPI KVM: arm64: vgic-its: Don't map an LPI from more than one event KVM: arm64: vgic-its: Stop the VM when handling MOVALL KVM: arm64: vgic: Stop the target vcpu when disabling LPIs KVM: arm64: Add helpers to halt a vCPU KVM: arm64: Turn vcpu->arch.pause into a counter KVM: arm64: Move IN_GUEST_MODE ahead of state being loaded KVM: arm64: Move OUTSIDE_GUEST_MODE publication past context being saved KVM: arm64: nv: Move L2->L1 switch on interrupt early Signed-off-by: Marc Zyngier <maz@kernel.org>
2026-10-26Merge branch kvm-arm64/hcr-cleanup into kvmarm-master/fixesMarc Zyngier
* kvm-arm64/hcr-cleanup: : \ : Cleanup the HCR_EL2 bit fields to exclusively use the generated : definitions. This also fixes a nasty regression introduced in : 6.16, where barriers were not upgraded from NSH to ISH anymore. : / KVM: arm64: Get rid of compatibility HCR_EL2 aliases KVM: arm64: Convert HCR_xyz to HCR_EL2_xyz KVM: arm64: Set HCR_EL2.BSU to Inner Shareable for guests Signed-off-by: Marc Zyngier <maz@kernel.org>
2026-10-26KVM: arm64: vgic: Require matching VGIC and ITS modelsSascha Bischoff
On a GICv5 host with legacy support, KVM registers both VGICv3 and VGICv5 devices. Without a model check, a VM can create a GICv3 ITS alongside an incompatible VGIC, regardless of creation order. The same problem exists for GICv2 on hosts that support a GICv3 ITS. KVM used to allow userspace to create both devices in either order, then ignored the ITS. Record the VGIC model required by an ITS. Reject an ITS if the VM already has an incompatible VGIC, and reject a VGIC if an existing ITS requires a different model. These checks apply on every host: a GICv2 VGIC and a GICv3 ITS now fail with -ENODEV in either order. Allow either creation order when the models match. Have vgic_has_its() require matching VGIC and ITS models, and drop the separate has_its flag. As part of this change, swap the type of vgic_model from u32 to enum kvm_device_type. This requires updating the switch cases in kvm_vgic_vcpu_init() and kvm_vgic_dist_destroy() to include default cases, which we mark as unreachable(). Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261020163923.1407856-2-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
2026-10-26KVM: arm64: gic-v5: Drop unused addr variableSascha Bischoff
vgic_v5_has_attr_regs() assigns reg_attr.addr to addr, but never uses addr. Drop the unused local and assignment to avoid a W=1 warning. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202610210232.uzFGXnjw-lkp@intel.com/ Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20261021082204.1494581-1-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
2026-10-26KVM: arm64: Sanitise ID_AA64MMFR3_EL1.S1P[IO]EMarc Zyngier
KVM uses the VM's ID registers as the source of truth for what the guest has, but userspace can expose S1PIE or S1POE without the features they imply. As per the architecture, both imply TCR2 and ATS1A, and S1POE also implies HPDS. With TCR2 hidden, the world switch skips PIR_EL1, PIRE0_EL1 and POR_EL1 while KVM doesn't trap them, so the guest accesses registers that are neither trapped nor switched. Under VHE, that leaks values between guests. On nVHE and hVHE, pKVM included, the host kernel resumes with the guest's PIR_EL1 and PIRE0_EL1. On first run, clear S1PIE and S1POE from the VM's ID registers when the features they imply are missing, before anything derives state from them. The guest and userspace then see neither feature, and the guest's accesses to their registers UNDEF. Fixes: 70ed7238297fb ("KVM: arm64: Sanitise ID_AA64MMFR3_EL1") Fixes: d4a89e5aee23e ("KVM: arm64: Expose S1PIE to guests") Reported-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20260930-arm64-gcs-v21-2-3556644cd927@kernel.org Link: https://lore.kernel.org/r/8633u229lq.wl-maz@kernel.org Cc: stable@vger.kernel.org Co-developed-by: Fuad Tabba <fuad.tabba@linux.dev> Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev> Reviewed-by: Mark Brown <broonie@kernel.org> Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org> Link: https://patch.msgid.link/20261020064306.1542865-1-fuad.tabba@linux.dev Signed-off-by: Marc Zyngier <maz@kernel.org>
2026-10-26tracing/remotes: Fix TRACE_REMOTE build when TRACING=nVincent Donnefort
TRACE_REMOTE relies on tracefs, eventfs and ring-buffer which are only built and declared when TRACING is enabled. It is however possible for a config to have FTRACE=y TRACING=n and TRACE_REMOTE=y. To fix this configuration, have TRACE_REMOTE select TRACING directly, just like other FTRACE options do and drop the TRACING dependency from NVHE_EL2_TRACING to avoid a circular Kconfig dependency. Cc: stable@vger.kernel.org Fixes: ea908a2b79c8 ("tracing: Add a trace remote module for testing") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202610142301.GBepPVmS-lkp@intel.com/ Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> Link: https://patch.msgid.link/20261015112814.332084-1-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
2026-10-26KVM: arm64: Move pkvm_selftests() after all CPUs have initialized EL2Vincent Donnefort
init_subsystems() installs the hyp vector on all CPUs. By running pkvm_selftests() in init_hyp_mode(), there's a risk for a migration to a CPU where the hyp stub is still in place which would fail to run one of the HVCs necessary for the selftest. While init_subsystems() is the earliest we can call pkvm_selftests(), move it to finalize_pkvm() to avoid having to export the selftest function out of pkvm.c. Fixes: bd93068340e9 ("KVM: arm64: Add selftests for the pKVM heap allocator") Reported-by: Fuad Tabba <fuad.tabba@linux.dev> Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261019094258.1582756-1-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
2026-10-26KVM: arm64: Get rid of compatibility HCR_EL2 aliasesMarc Zyngier
Now that we dropped out reliance on the old HCR_EL2 aliases, do the right thing and purge the kernel of the compatibility definitions. Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Itaru Kitayama <itaru.kitayama@fujitsu.com> Link: https://patch.msgid.link/20261015173605.1072963-3-maz@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
2026-10-26KVM: arm64: Convert HCR_xyz to HCR_EL2_xyzMarc Zyngier
Bulk convert all usages of HCR_xyz to HCR_EL2_xyz (the autogenerated version) using the following proof that I can't write shell scripts: awk 'match($3, /__HCR.*/) { print $2}' arch/arm64/include/asm/kvm_arm.h | while read i; do j=$(echo $i | sed -e "s/HCR_\(.*\)/\1/"); git grep -lw $i arch/arm64/ | xargs sed -i -e "s/\b$i\b/HCR_EL2_$j/g"; done ... and fixup the result. Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Itaru Kitayama <itaru.kitayama@fujitsu.com> Link: https://patch.msgid.link/20261015173605.1072963-2-maz@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
2026-10-26KVM: arm64: Set HCR_EL2.BSU to Inner Shareable for guestsFuad Tabba
KVM sets HCR_EL2.BSU to Inner Shareable for guests, so that a guest's barriers cover the TLB and I-cache invalidations that HCR_EL2.FB broadcasts. However, since HCR_BSU_IS became an alias of the generated HCR_EL2_BSU_IS, it is the unshifted field value 0b01, which sets bit 0 (VM, already set) and leaves BSU at 0b00. A guest's DSB NSH is then not required to wait for a broadcast TLBI to complete on other CPUs. Build the field with SYS_FIELD_PREP_ENUM(). Fixes: d0f39259eff4 ("arm64: sysreg: Add layout for HCR_EL2") Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261016081558.805411-1-fuad.tabba@linux.dev Signed-off-by: Marc Zyngier <maz@kernel.org> Cc: stable@vger.kernel.org
2026-10-26KVM: arm64: Fix stale VGICv3 comments in the nVHE world switchFuad Tabba
__hyp_vgic_save_state() and __hyp_vgic_restore_state() handle GICv5 as well as GICv3, but their comments name VGICv3 only. Reviewed-by: Sascha Bischoff <sascha.bischoff@arm.com> Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev> Link: https://patch.msgid.link/20261012161524.4016464-6-fuad.tabba@linux.dev Signed-off-by: Marc Zyngier <maz@kernel.org>