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)
Apr 3 2024, 1:18 PM
Unknown Object (File)
Mar 7 2024, 12:04 PM
Unknown Object (File)
Mar 7 2024, 12:03 PM
Unknown Object (File)
Mar 7 2024, 11:47 AM
Unknown Object (File)
Mar 7 2024, 11:28 AM
Unknown Object (File)
Jan 14 2024, 3:41 AM
Unknown Object (File)
Dec 21 2023, 6:20 AM
Unknown Object (File)
Dec 20 2023, 7:57 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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.