Page MenuHomeFreeBSD

arm: Unbreak debugging programs that use FP instructions
ClosedPublic

Authored by kd on Feb 20 2023, 3:02 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 1 2024, 3:16 PM
Unknown Object (File)
Sep 26 2024, 3:32 PM
Unknown Object (File)
Sep 26 2024, 3:32 PM
Unknown Object (File)
Sep 26 2024, 3:32 PM
Unknown Object (File)
Sep 26 2024, 3:29 PM
Unknown Object (File)
Sep 25 2024, 7:02 PM
Unknown Object (File)
Sep 18 2024, 7:22 PM
Unknown Object (File)
Sep 18 2024, 2:57 PM
Subscribers

Details

Summary

Contrary to arm64, on armv7 get_vfpcontext/set_vfpcontext can be called from cpu_ptrace.
This can be triggered when gdb hits a breakpoint in a userspace program.
Relax td == currthread assertion to account for that situation.
While here improve the copying of VFP context.
Instead of copying fpscr in a separate assignment instruction, extend memcopy to cover it.

Reported by: Mark Millard <marklmi@yahoo.com>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kd requested review of this revision.Feb 20 2023, 3:02 PM
kd created this revision.

Do not take the following as indicating anything is necessarily wrong. It is more about my ignorance in the subjects involved.

Why does get_vfpcontext only need critical_enter/critical_exit to span so little but set_vfpcontext to span so much?

An implication is that no variation in context from the likes of, say, a cpu migration would mess up an already partially completed memcpy in get_vfpcontext. So the pcb_vfpstate storage used would apparently be unchanged over the whole memcpy operation.

With the savectx blne -> bl change, D38696.diff, and D38698.diff all applied, all
the activities with all 3 of my small example programs for the armv7 floating
point related problems look to be working just fine: no KASSERT's ( simple_dbl.c
and dbl_and_ull_via_async.cpp activities) and no odd values showing up in a
thread ( dbl_and_ull_multithread.cpp runs for minutes at a time).

sys/arm/arm/exec_machdep.c
134

Why do you need to expand the critical section?

Do not take the following as indicating anything is necessarily wrong. It is more about my ignorance in the subjects involved.

Why does get_vfpcontext only need critical_enter/critical_exit to span so little but set_vfpcontext to span so much?

An implication is that no variation in context from the likes of, say, a cpu migration would mess up an already partially completed memcpy in get_vfpcontext. So the pcb_vfpstate storage used would apparently be unchanged over the whole memcpy operation.

Sorry, I've missed your comment.
As mentioned inline the critical section was a bit too wide.
I've fixed that in the latest version of this patch.

sys/arm/arm/exec_machdep.c
134

I suppose that there is no need to do that.
I just wanted to be safe, but after examinng the code I've changed this to only have vfp_discard inside the critical section.

This revision was not accepted when it landed; it landed in state Needs Review.Feb 23 2023, 4:51 PM
This revision was automatically updated to reflect the committed changes.

I did the 3 tests via booting an installed FreeBSD-14.0-CURRENT-arm-armv7-GENERICSD-20230302-005cca8361a4-261233.img.xz (from today) and they all worked fine.