v4 ACL: the countdown at call, as v3 -- the call hook may redirect
Captain Bob ruled "As v3: add at call", "Engine: call redirects" and "Build it". - The engine's call hook returns where P goes. - The kernel checks every call from code defined at run time. A TTL is counted down at the call. At a TTL of 0, or a denied word, the call is sent to (ACL-CALL), with the target on the data stack, which rechecks or refuses it by the word's own name, then goes on to it. - A word being compiled is no longer checked, as in v3. Two things were added while building, both from v3: - (ACL-BUSY) turns the check off while the policy rechecks. Without it the recheck recursed. - (ACL-CALL) does its own refusal and leaves WORD's buffer alone. A first version broke POST's CONVERT.digits. Test first: test_mesh_boot's five new checks failed before; now 120 pass and POST is 990/990. test_exec tests the redirect. test_host_quit's two v4-only expectations now follow v3: a denied word compiles. All 52 tests, test-32 and ASan/UBSan pass. An amd64 session passes 18/18. Five alternating host boots: +1.4% median, inside the noise. DECOMPOSITION.md 5.20 is updated, and the FPGA's call opcode is recorded as owing the same redirect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -81,3 +81,25 @@ set HDR-NFA here ", ACL-HEAT@ #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LIN
|
||||
\ ( xt -- n ) a number for the word that never changes: its address
|
||||
set HDR-NFA here ", ACL-WORD-ID #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: ACL-WORD-ID (ACL-XT) ;
|
||||
|
||||
\ ( xt -- ) a call from code defined at run time that the kernel sent here
|
||||
\ (v4/system/mesh.c, on_call) because the word's TTL is 0 or it is denied.
|
||||
\ As v3's inner interpreter, and as (ACL?): the recheck, or the TTL counted
|
||||
\ down; then a denied word refused with v3's line -- by its own name, from
|
||||
\ its entry (WORD's buffer is the running code's, not this) -- the stack
|
||||
\ emptied and the line ended; an allowed word is jumped to, so it returns to
|
||||
\ the caller as the call would have (docs/v4.0.0/plans/2026-11-19-acl-at-call.md).
|
||||
: (ACL-CALL)
|
||||
dup -3 + a! @ \ xt flags
|
||||
dup $FFFF0000 and if ZERO
|
||||
drop -65536 + ! jump TEST \ one use fewer
|
||||
ZERO: drop drop dup (ACL-RECHECK)
|
||||
TEST: dup -3 + a! @ 32 and if OK
|
||||
drop
|
||||
$33335B1B (EMIT4) $6D (EMIT4) $4E524157 (EMIT4) $203A (EMIT4) $6D305B1B (EMIT4) \ v3's line: WARN: in yellow
|
||||
$3A4C4341 (EMIT4) $6E656420 (EMIT4) $20646569 (EMIT4) $27 (EMIT4)
|
||||
-2 + a! @ 4* COUNT TYPE 39 EMIT CR \ the word's own name
|
||||
DSTACK-DEPTH b! a !b \ as v3, the stack is emptied
|
||||
pop drop jump (ABANDON)
|
||||
OK: drop push ; \ on to the word
|
||||
|
||||
|
||||
+16
-13
@@ -113,22 +113,25 @@ macro ROT push SWAP pop SWAP endmacro
|
||||
\ bits 16 .. 31 the TTL, a count of uses left before the next recheck
|
||||
\ A new entry has all of them zero: allowed, not pinned, TTL mode, TTL 0.
|
||||
\
|
||||
\ (ACL?) is run by INTERPRET for every word it is about to execute or
|
||||
\ compile. As v3: if the TTL is 0 the word is rechecked, otherwise the TTL
|
||||
\ is counted down; then a denied word is refused. The recheck is the word
|
||||
\ whose address is in (ACL-HOOK) -- ACL-RECHECK, once ACL.fth has loaded --
|
||||
\ and with none there the word is allowed and given the longest TTL.
|
||||
\ (ACL?) is run by INTERPRET for every word it is about to execute. As v3:
|
||||
\ if the TTL is 0 the word is rechecked, otherwise the TTL is counted down;
|
||||
\ then a denied word is refused. The recheck is the word whose address is in
|
||||
\ (ACL-HOOK) -- ACL-RECHECK, once ACL.4th has loaded -- and with none there the
|
||||
\ word is allowed and given the longest TTL.
|
||||
\
|
||||
\ v3 checks every execution, inside definitions too. v4 code is native: a
|
||||
\ compiled call goes straight to its word. So v4 checks a word when it is
|
||||
\ compiled as well as when it is interpreted -- a denied word cannot be
|
||||
\ built into anything new -- but a call compiled while the word was allowed
|
||||
\ is not checked again.
|
||||
\ As v3, every execution is checked, inside definitions too (2026-11-19,
|
||||
\ docs/v4.0.0/plans/2026-11-19-acl-at-call.md): a call from code defined at
|
||||
\ run time is checked by the kernel at the call -- counted down there, or,
|
||||
\ at a TTL of 0 or a denied word, sent to (ACL-CALL) (acl.f18), which runs
|
||||
\ (ACL?). A word being compiled is not checked, as in v3. While the policy
|
||||
\ rechecks a word, (ACL-BUSY) is 1 and the kernel checks nothing, as v3 runs
|
||||
\ its policy with the check off.
|
||||
|
||||
\ ( xt -- ) recheck
|
||||
: (ACL-RECHECK)
|
||||
(ACL-HOOK) a! @ if NONE push ex \ call it with the xt
|
||||
;
|
||||
(ACL-HOOK) a! @ if NONE
|
||||
1 (ACL-BUSY) a! ! push ex \ call it with the xt, the kernel's check off
|
||||
0 (ACL-BUSY) a! ! ;
|
||||
NONE: drop -3 + a! @ 65535 and -33 and $FFFF0000 + ! ;
|
||||
|
||||
\ ( xt -- xt ) as above; a denied word ends the line
|
||||
@@ -202,7 +205,7 @@ set HDR-NFA here ", INTERPRET #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LIN
|
||||
STATE a! @ if INTERP
|
||||
drop 1 and if COMP \ compiling: immediate words still run
|
||||
drop (ACL?) jump (GO)
|
||||
COMP: drop (ACL?) (COMPILE,) jump (IL)
|
||||
COMP: drop (COMPILE,) jump (IL) \ compiled, not checked: the call is, when it runs (as v3)
|
||||
INTERP: drop 16 and if RUN
|
||||
drop drop (.WORD) \ ": compile-only"
|
||||
$6F63203A (EMIT4) $6C69706D (EMIT4) $6E6F2D65 (EMIT4) $796C (EMIT4) CR
|
||||
|
||||
@@ -35,5 +35,9 @@ store (IMG) &(IDLE)
|
||||
store (IMG)+1 &(FAULTS)
|
||||
store (IMG)+2 &KEY
|
||||
store (IMG)+3 &CR
|
||||
\ the ACL's check at call: where the kernel sends a call to be checked; and the
|
||||
\ policy not running
|
||||
store (ACL-CALLX) &(ACL-CALL)
|
||||
store (ACL-BUSY) 0
|
||||
|
||||
start (IDLE)
|
||||
|
||||
@@ -120,6 +120,8 @@ constant RSTACK-DEPTH 32752
|
||||
constant HEAT-OP 29216
|
||||
constant (EXEC) 30047
|
||||
constant (RUNX) 29954
|
||||
constant (ACL-CALLX) 29956
|
||||
constant (ACL-BUSY) 29925
|
||||
constant ANTICLOCK 29248
|
||||
constant CFBASE 32672
|
||||
constant CFEND 32704
|
||||
|
||||
@@ -120,6 +120,8 @@ constant RSTACK-DEPTH 32752
|
||||
constant HEAT-OP 29216
|
||||
constant (EXEC) 30047
|
||||
constant (RUNX) 29954
|
||||
constant (ACL-CALLX) 29956
|
||||
constant (ACL-BUSY) 29925
|
||||
constant ANTICLOCK 29248
|
||||
constant CFBASE 32672
|
||||
constant CFEND 32704
|
||||
|
||||
Reference in New Issue
Block a user