Created attachment 266838 [details] vfp.c.patch When trying to reproduce bug 292177 on 16-CURRENT I unexpectedly encountered a kernel panic. It looks like the panic was unique to coredumping in SVE code. The coredump logic calls get_arm64_sve twice: once to get the note size, and once to get the data. The note size calculation depended on the volatile PCB_FP_SVEVALID flag. If this flag was cleared between the two calls (e.g., due to a context switch clearing the flag to comply with the ABI), the second call would expect a smaller buffer size than the first, triggering the KASSERT panic ("invalid size"). Fix this by: 1. Using pcb->pcb_svesaved != NULL (a stable indicator of SVE usage) to determine the note size. 2. Calling vfp_to_sve_sync() if SVE is not currently valid but SVE state is saved, ensuring the SVE buffer in the core dump contains the most up-to-date register values.
As this is a patch can you post it either via https://reviews.freebsd.org/ or as a GitHub pull request.
Got phabricator activated and submitted for review as https://reviews.freebsd.org/D54532
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=93d3ac1daa0ef3ac54ffcd5cc64a14638d04bd60 commit 93d3ac1daa0ef3ac54ffcd5cc64a14638d04bd60 Author: Andy Carrel <william.a@carrel.org> AuthorDate: 2026-01-05 07:50:27 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2026-01-30 17:01:49 +0000 arm64: Fix kernel panic in get_arm64_sve during core dump The coredump logic calls get_arm64_sve twice: once to get the note size, and once to get the data. The note size calculation depended on the volatile `PCB_FP_SVEVALID` flag. If this flag was cleared between the two calls (e.g., due to a context switch clearing the flag to comply with the ABI), the second call would expect a smaller buffer size than the first, triggering a KASSERT panic ("invalid size"). Fix this by ensuring the SVE state is saved to the PCB before we decide whether to use SVE or VFP. PR: 292195 Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D54532 sys/arm64/arm64/vfp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=c70a68bbdbf67e10a8cd8d46857cc6d4533096a9 commit c70a68bbdbf67e10a8cd8d46857cc6d4533096a9 Author: Andy Carrel <william.a@carrel.org> AuthorDate: 2026-01-05 07:50:27 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2026-02-09 14:51:59 +0000 arm64: Fix kernel panic in get_arm64_sve during core dump The coredump logic calls get_arm64_sve twice: once to get the note size, and once to get the data. The note size calculation depended on the volatile `PCB_FP_SVEVALID` flag. If this flag was cleared between the two calls (e.g., due to a context switch clearing the flag to comply with the ABI), the second call would expect a smaller buffer size than the first, triggering a KASSERT panic ("invalid size"). Fix this by ensuring the SVE state is saved to the PCB before we decide whether to use SVE or VFP. PR: 292195 Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D54532 (cherry picked from commit 93d3ac1daa0ef3ac54ffcd5cc64a14638d04bd60) sys/arm64/arm64/vfp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
A commit in branch releng/15.0 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=539bbdbd3b0c3c235d441024cf28cef3afd6329e commit 539bbdbd3b0c3c235d441024cf28cef3afd6329e Author: Andy Carrel <william.a@carrel.org> AuthorDate: 2026-01-05 07:50:27 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-02-09 16:39:50 +0000 arm64: Fix kernel panic in get_arm64_sve during core dump The coredump logic calls get_arm64_sve twice: once to get the note size, and once to get the data. The note size calculation depended on the volatile `PCB_FP_SVEVALID` flag. If this flag was cleared between the two calls (e.g., due to a context switch clearing the flag to comply with the ABI), the second call would expect a smaller buffer size than the first, triggering a KASSERT panic ("invalid size"). Fix this by ensuring the SVE state is saved to the PCB before we decide whether to use SVE or VFP. Approved by: so Security: FreeBSD-EN-26:04.arm64 PR: 292195 Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D54532 (cherry picked from commit 93d3ac1daa0ef3ac54ffcd5cc64a14638d04bd60) (cherry picked from commit c70a68bbdbf67e10a8cd8d46857cc6d4533096a9) sys/arm64/arm64/vfp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)