Skip to content

remove nomem, add fences - #699

Merged
adamgreig merged 4 commits into
rust-embedded:masterfrom
quartiq:asm-nomem
Oct 17, 2026
Merged

adamgreig merged 4 commits into
rust-embedded:masterfrom
quartiq:asm-nomem

Conversation

@jordens

@jordens jordens commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

This PR applies the changes proposed in #697

Declare asm memory effects and retain existing compiler fences.
Add Release before and Acquire after BASEPRI writes, and Acquire after
BASEPRI_MAX, to work around rust-lang/rust#144351.
The host can access memory through the argument pointer. Remove nomem
so those accesses are visible to the compiler.
Remove nomem from the CONTROL write and ISB, and from bootstrap.
Memory accesses must use the intended execution context, and the
bootstrap destination can read the initialized stack.
Cortex-M33 TRM B6.6 permits memory-mapped coprocessor state accessed
through loads and stores.
@jordens

jordens commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

cc #698

@jonathanpallant

Copy link
Copy Markdown
Contributor

#698 puts a fence on both sides of the CPSID I, which I think is important, because there are operations that you want occur before interrupts are disabled (like checking if interrupts are disabled).

But otherwise this seems more complete so I'll close mine.

@jonathanpallant jonathanpallant mentioned this pull request Oct 17, 2026
@jordens

jordens commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

there are operations that you want occur before interrupts are disabled (like checking if interrupts are disabled).

ACK. I don't expect any harm from the added fence. But then again, I see these fences around memory clobbering asm!() only as a workaround to rust-lang/rust#144351

@jordens

jordens commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

And your case specifically (read CPSR) should not hit that compiler bug.

@jonathanpallant

Copy link
Copy Markdown
Contributor

We discussed on Zulip and seem to prefer more fences rather than fewer, given the insidious nature of the failure mode.

@jordens

jordens commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

I probably wont be able to work on this for the next couple days. My suggestion would be to merge and then add the changes you want afterwards. Or edit/hijack.

@adamgreig
adamgreig added this pull request to the merge queue Oct 17, 2026
@adamgreig

Copy link
Copy Markdown
Member

Thanks for letting us know. I'll merge this now and we can have a second PR with the additional fences around interrupt enable/disable if we want, before the new release.

Merged via the queue into rust-embedded:master with commit 8a82ef3 Oct 17, 2026
11 checks passed
@jordens
jordens deleted the asm-nomem branch October 18, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants