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)
Tue, Sep 10, 12:23 PM
Unknown Object (File)
Sun, Sep 8, 3:15 AM
Unknown Object (File)
Fri, Sep 6, 9:46 PM
Unknown Object (File)
Fri, Sep 6, 9:46 PM
Unknown Object (File)
Fri, Sep 6, 9:46 PM
Unknown Object (File)
Fri, Sep 6, 9:46 PM
Unknown Object (File)
Fri, Sep 6, 9:39 PM
Unknown Object (File)
Thu, Sep 5, 5:25 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
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