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)
Thu, Oct 31, 6:07 AM
Unknown Object (File)
Thu, Oct 17, 6:21 PM
Unknown Object (File)
Tue, Oct 15, 8:47 PM
Unknown Object (File)
Mon, Oct 14, 8:58 PM
Unknown Object (File)
Sun, Oct 13, 5:10 PM
Unknown Object (File)
Sun, Oct 13, 12:57 AM
Unknown Object (File)
Fri, Oct 11, 8:16 PM
Unknown Object (File)
Wed, Oct 9, 8:10 AM
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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 44815
Build 41703: arc lint + arc unit

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