Page MenuHomeFreeBSD

aarch64: Add static asssert for context size
ClosedPublic

Authored by imp on Nov 12 2021, 6:38 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 7, 9:06 PM
Unknown Object (File)
Fri, Dec 6, 12:35 PM
Unknown Object (File)
Thu, Dec 5, 6:36 PM
Unknown Object (File)
Wed, Nov 27, 11:40 PM
Unknown Object (File)
Tue, Nov 26, 9:01 PM
Unknown Object (File)
Fri, Nov 22, 12:44 AM
Unknown Object (File)
Fri, Nov 22, 12:44 AM
Unknown Object (File)
Nov 15 2024, 7:11 AM
Subscribers

Details

Summary

Add a static assert for the mcontext{,32}_t and ucontext32_t
sizes. These are de-factor ABI options and cannot change size ever.

Sponsored by: Netflix

Test Plan

Found issues with mcontext size in qemu bsd-user, so thought I'd add asserts here to ensure the size doesn't change, and to document said size.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 44356
Build 41244: arc lint + arc unit

Event Timeline

imp requested review of this revision.Nov 12 2021, 6:38 AM
imp added a reviewer: jhb.

These should also be true in CheriBSD running FreeBSD/arm64 binaries. I'll have to look how we could handle the new extensions where userspace may have access to larger register files, e.g. SVE has 32 registers that could be up to 2048 bytes each. In this case I expect we'll store them in their own variable sized structure that one of the spare fields point to.

This revision is now accepted and ready to land.Nov 12 2021, 11:20 AM

I believe that the general preference is to put this kind of asserts into .c file and not in .h. It is enough to get single error from the build, instead of 40+ from each instance of compiler in the parallel build.

Andrew, WRT to new extensions, please look how Intel extensions are handled on x86, in particular getcontextx(3). Indeed we store a pointer to extended part of XSAVE area into existing mcontext(32).

I would be fine with moving the assertions to a C file (probably arm64/arm64/machdep.c next to get_mcontext? The 32-bit assertion could perhaps be next to get_mcontext32)

In D32958#744229, @jhb wrote:

I would be fine with moving the assertions to a C file (probably arm64/arm64/machdep.c next to get_mcontext? The 32-bit assertion could perhaps be next to get_mcontext32)

I was going to add several more. My plan was just to add them all to the top of exec_machdep.c on all the architectures, with appropriate ifdefs for 32-bit compat stuff since I was also going to assert on ucontext_t size and sigframe as well.

This revision now requires review to proceed.Feb 8 2022, 9:23 PM

exec_machdep.c seems to be the place that has all the MS signal handling on all the platforms, so it seems like the right place for these. I did one as an example, but will do the others in a similar manner once this gets signed off on.
I can also add an assert for the UCONTEXT too. bsd-user just cares about mcontext at compile time (though arguably it should care about both).

sys/arm64/arm64/exec_machdep.c
65

As John suggested, I agree that arm64/arm64/freebsd32_machdep.c is the better place for COMPAT32 asserts.

This revision is now accepted and ready to land.Feb 9 2022, 12:40 AM
sys/arm64/arm64/exec_machdep.c
64

Shouldn't this message be ucontext_t ...?

This revision now requires review to proceed.Feb 10 2022, 7:30 PM
This revision was not accepted when it landed; it landed in state Needs Review.Feb 10 2022, 9:34 PM
This revision was automatically updated to reflect the committed changes.