pr5.4
This commit is contained in:
parent
b9ac2a98ee
commit
155be962b7
@ -225,6 +225,50 @@ fn golden_err_invalid_syscall_id() {
|
||||
assert_eq!(res, Err(VerifierError::InvalidSyscallId { pc: 0, id: 0xDEADBEEF }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn golden_err_syscall_too_few_args() {
|
||||
// Choose a syscall that requires 2 arg slots and returns 0: LogWrite (0x5001)
|
||||
// Program: SYSCALL 0x5001; RET
|
||||
// No arguments are pushed before the syscall, so verifier must catch underflow at the syscall.
|
||||
let mut code = Vec::new();
|
||||
code.extend_from_slice(&enc_op(OpCode::Syscall));
|
||||
code.extend_from_slice(&0x5001u32.to_le_bytes());
|
||||
code.extend_from_slice(&enc_op(OpCode::Ret));
|
||||
|
||||
let functions = func(FunctionMeta { code_offset: 0, code_len: code.len() as u32, return_slots: 0, ..Default::default() });
|
||||
let res = Verifier::verify(&code, &functions);
|
||||
assert_eq!(res, Err(VerifierError::StackUnderflow { pc: 0, opcode: OpCode::Syscall }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn golden_ok_syscall_args_and_returns() {
|
||||
// Case A: Syscall with 2 args, 0 returns (LogWrite): push 2; syscall; ret (ret_slots = 0)
|
||||
let mut code_a = Vec::new();
|
||||
code_a.extend_from_slice(&enc_op(OpCode::PushI32));
|
||||
code_a.extend_from_slice(&1i32.to_le_bytes());
|
||||
code_a.extend_from_slice(&enc_op(OpCode::PushI32));
|
||||
code_a.extend_from_slice(&2i32.to_le_bytes());
|
||||
code_a.extend_from_slice(&enc_op(OpCode::Syscall));
|
||||
code_a.extend_from_slice(&0x5001u32.to_le_bytes()); // LogWrite: 2 args, 0 returns
|
||||
code_a.extend_from_slice(&enc_op(OpCode::Ret));
|
||||
|
||||
let functions_a = func(FunctionMeta { code_offset: 0, code_len: code_a.len() as u32, return_slots: 0, ..Default::default() });
|
||||
let res_a = Verifier::verify(&code_a, &functions_a).unwrap();
|
||||
// Max stack height reaches 2 after two pushes
|
||||
assert!(res_a[0] >= 2);
|
||||
|
||||
// Case B: Syscall with 0 args, 1 return (TouchGetX: 0x2101): syscall; ret (ret_slots = 1)
|
||||
let mut code_b = Vec::new();
|
||||
code_b.extend_from_slice(&enc_op(OpCode::Syscall));
|
||||
code_b.extend_from_slice(&0x2101u32.to_le_bytes()); // TouchGetX: 0 args, 1 return
|
||||
code_b.extend_from_slice(&enc_op(OpCode::Ret));
|
||||
|
||||
let functions_b = func(FunctionMeta { code_offset: 0, code_len: code_b.len() as u32, return_slots: 1, ..Default::default() });
|
||||
let res_b = Verifier::verify(&code_b, &functions_b).unwrap();
|
||||
// Max stack height should be at least 1 due to the return value
|
||||
assert!(res_b[0] >= 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn golden_err_invalid_func_id() {
|
||||
// Encode a Call with invalid function id (beyond functions.len())
|
||||
|
||||
@ -1,47 +1,3 @@
|
||||
# PR-5.5 — Remove Legacy Syscall Entry Paths
|
||||
|
||||
### Briefing
|
||||
|
||||
Any old or experimental syscall entry paths must be removed so that the slot-based ABI is the only supported mechanism.
|
||||
|
||||
### Target
|
||||
|
||||
* Ensure only the new unified syscall dispatch path exists.
|
||||
|
||||
### Work items
|
||||
|
||||
* Search for legacy or alternate syscall invocation logic.
|
||||
* Remove or refactor them to use the canonical dispatch.
|
||||
* Update modules and exports accordingly.
|
||||
|
||||
### Acceptance checklist
|
||||
|
||||
* [ ] Only one syscall dispatch path remains.
|
||||
* [ ] No legacy syscall logic is present.
|
||||
* [ ] `cargo test` passes.
|
||||
|
||||
### Tests
|
||||
|
||||
* Existing tests only.
|
||||
|
||||
### Junie instructions
|
||||
|
||||
**You MAY:**
|
||||
|
||||
* Remove legacy syscall code paths.
|
||||
* Refactor callers to use the unified dispatch.
|
||||
|
||||
**You MUST NOT:**
|
||||
|
||||
* Introduce new syscall semantics.
|
||||
* Keep compatibility shims.
|
||||
|
||||
**If unclear:**
|
||||
|
||||
* Ask before deleting anything that looks externally visible.
|
||||
|
||||
---
|
||||
|
||||
# PR-5.6 — Syscall Multi-Return Tests
|
||||
|
||||
### Briefing
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user