Page MenuHomeFreeBSD

aarch64: Fix get_fpcontext32() to work on non-curthread.
ClosedPublic

Authored by jhb on Mar 11 2022, 1:15 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 10, 10:13 PM
Unknown Object (File)
Thu, Nov 7, 5:30 PM
Unknown Object (File)
Thu, Nov 7, 3:28 AM
Unknown Object (File)
Tue, Nov 5, 11:57 AM
Unknown Object (File)
Tue, Nov 5, 8:35 AM
Unknown Object (File)
Tue, Nov 5, 6:04 AM
Unknown Object (File)
Thu, Oct 31, 6:07 AM
Unknown Object (File)
Oct 17 2024, 6:21 PM
Subscribers

Details

Summary

Similar to fill_fpregs(), only invoke vfp_save_state() for curthread.

While here, zero the buffer if FP hasn't been started to avoid leaking
kernel stack memory.

Sponsored by: University of Cambridge, Google, Inc.

Diff Detail

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

Event Timeline

jhb requested review of this revision.Mar 11 2022, 1:15 AM

Tripped over issues here while testing gcore on a 32-bit ARM process for D34448.

This revision is now accepted and ready to land.Mar 14 2022, 2:51 PM
sys/arm64/arm64/freebsd32_machdep.c
135–136

We only really need to disable preemption if td == curthread, right? I think it's fine to do so unconditionally, but can we assert something about the state of td when td != curthread, like TD_IS_SUSPENDED(td)?

It might pay to update the native get_fpcontext while here.

sys/arm64/arm64/freebsd32_machdep.c
135–136

I don't think the the critical section is needed. vfp_save_state will enter one when saving the vfp registers and nothing else appears to require us to enter one.

The native get_fpcontext is only used for curthread since the debugger case is handled by fill_dbregs() instead.

sys/arm64/arm64/freebsd32_machdep.c
135–136

I had just left the critical section as it was easy to leave it. I can drop it.

Note that if we want to assert something we should probably be asserting that same thing in many other places (e.g. fill_*regs()). (We don't currently assert anything in get_fpcontext() on RISC-V for example).

sys/arm64/arm64/freebsd32_machdep.c
135–136

Since I spent several minutes staring at it, I'd rather remove the critical section either in this diff or some follow up.

I do note that fill_fpregs() on amd64 provides an assertion along the lines that I was looking for here.

  • Remove critical section.
  • Add assertion similar to fill_fpregs in amd64.
This revision now requires review to proceed.Mar 17 2022, 10:33 PM
This revision is now accepted and ready to land.Mar 17 2022, 10:36 PM