Page MenuHomeFreeBSD

STACKALIGN: Reimplement in terms of __align_down
ClosedPublic

Authored by jhb on Jan 27 2026, 10:29 PM.
Tags
None
Referenced Files
F162634547: D54920.diff
Wed, Jul 15, 7:04 AM
F162634546: D54920.diff
Wed, Jul 15, 7:04 AM
Unknown Object (File)
Sun, Jul 5, 6:13 AM
Unknown Object (File)
Fri, Jul 3, 8:10 AM
Unknown Object (File)
Jun 13 2026, 8:42 PM
Unknown Object (File)
Jun 6 2026, 9:31 AM
Unknown Object (File)
Jun 6 2026, 12:43 AM
Unknown Object (File)
Jun 5 2026, 10:41 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.