Page MenuHomeFreeBSD

STACKALIGN: Reimplement in terms of __align_down
ClosedPublic

Authored by jhb on Jan 27 2026, 10:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 11, 11:34 PM
Unknown Object (File)
Wed, Mar 11, 9:13 AM
Unknown Object (File)
Wed, Mar 11, 8:31 AM
Unknown Object (File)
Wed, Mar 11, 8:25 AM
Unknown Object (File)
Wed, Mar 11, 5:59 AM
Unknown Object (File)
Wed, Mar 11, 4:34 AM
Unknown Object (File)
Wed, Mar 11, 4:22 AM
Unknown Object (File)
Mon, Mar 9, 3:44 PM

Details

Summary

This changes STACKALIGN to be type-preserving when operating on
pointers.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 70173
Build 67056: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Jan 27 2026, 10:29 PM
sys/arm/include/param.h
50

Why STACKALIGN needs to be MD then? It is enough to have STACKALIGNBYTES defined in machine/param.h.
And please add a comment that it is type-preserving.

Effort: CHERI upstreaming or whatever it is seems like it would apply?

brooks added inline comments.
sys/arm/include/param.h
50

It's only defined on arm/riscv.

STACKALIGNBYTES should surely be STACKALIGN_MASK or the like, but that's a different change.

This revision is now accepted and ready to land.Jan 28 2026, 10:12 AM
sys/arm/include/param.h
50

It's only defined on arm/riscv.

Yes, this is why I said that it is enough to have STACKALIGNBYTES in machine/param.h.
sys/param.h could then do

#ifdef STACKALIGNBYTES
#define STACKALIGN ...
#endif

and it would be immediately have uses at least on amd64 where we align stack after the signal frame.
Might be for i386 too, but I do not remember.

sys/arm/include/param.h
50

I would be happy to move it. I do think it would be nicer on other arches as well. I do wish the STACKALIGNBYTES wasn't the biased value. I'm not sure if we expose this to userland though. :( Let me see if it's feasible to change that to the unbiased value.

Centralize STACKALIGN and pass tinderbox

This revision now requires review to proceed.Feb 5 2026, 6:38 PM

There are opportunities with amd64 at least, but I can do it myself after this patch lands. Thanks.

This revision is now accepted and ready to land.Feb 5 2026, 6:42 PM
This revision was automatically updated to reflect the committed changes.