Bug 292195 - arm64: panic on coredump with sve instructions
Summary: arm64: panic on coredump with sve instructions
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: 16.0-CURRENT
Hardware: arm64 Any
: --- Affects Some People
Assignee: Mark Johnston
URL:
Keywords: crash
Depends on:
Blocks:
 
Reported: 2026-01-05 08:39 UTC by William Carrel
Modified: 2026-06-12 01:10 UTC (History)
1 user (show)

See Also:
linimon: mfc-stable14?


Attachments
vfp.c.patch (1.22 KB, text/plain)
2026-01-05 08:39 UTC, William Carrel
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description William Carrel 2026-01-05 08:39:29 UTC
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.
Comment 1 Andrew Turner freebsd_committer freebsd_triage 2026-01-05 12:41:34 UTC
As this is a patch can you post it either via https://reviews.freebsd.org/ or as a GitHub pull request.
Comment 2 William Carrel 2026-01-05 18:19:23 UTC
Got phabricator activated and submitted for review as https://reviews.freebsd.org/D54532
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-01-30 17:20:35 UTC
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(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2026-02-09 16:29:05 UTC
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(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2026-02-10 17:56:54 UTC
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(-)