Skip to content

Metal: mark by-reference kernel arguments read-only#853

Merged
maleadt merged 1 commit into
mainfrom
tb/metal-readonly
Jun 19, 2026
Merged

Metal: mark by-reference kernel arguments read-only#853
maleadt merged 1 commit into
mainfrom
tb/metal-readonly

Conversation

@maleadt

@maleadt maleadt commented Jun 19, 2026

Copy link
Copy Markdown
Member

add_argument_metadata! tagged every buffer argument air.read_write, but by-reference arguments (the kernel state, bitstype objects passed by pointer) are loaded into a stack slot at function entry and never written back through the argument pointer -- any device pointers they contain address separate, independently-bound buffers. Tagging them air.read lets a host bind them with read-only data (Metal's setBytes:) without API validation rejecting read-only bytes bound to a write-accessible argument. Genuine pointer-to-data arguments (Ptr/LLVMPtr bound to a real buffer) stay read-write.

`add_argument_metadata!` tagged every buffer argument `air.read_write`, but
by-reference arguments (the kernel state, bitstype objects passed by pointer)
are loaded into a stack slot at function entry and never written back through
the argument pointer -- any device pointers they contain address separate,
independently-bound buffers. Tagging them `air.read` lets a host bind them with
read-only data (Metal's `setBytes:`) without API validation rejecting read-only
bytes bound to a write-accessible argument. Genuine pointer-to-data arguments
(`Ptr`/`LLVMPtr` bound to a real buffer) stay read-write.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@maleadt maleadt merged commit e107287 into main Jun 19, 2026
36 of 37 checks passed
@maleadt maleadt deleted the tb/metal-readonly branch June 19, 2026 16:08
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.49%. Comparing base (0d5bdc4) to head (6a5db03).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #853   +/-   ##
=======================================
  Coverage   79.48%   79.49%           
=======================================
  Files          25       25           
  Lines        4767     4769    +2     
=======================================
+ Hits         3789     3791    +2     
  Misses        978      978           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant