目的与范围
用途与范围
本单元实现 PTO v0 对已保存陷阱上下文的验证与恢复。恢复是经过检查且只能使用一次的状态转换:无效封装返回假,并且不恢复执行状态。
PTO-ARCH-PROFILE-TRAP-CONTEXT-RECOVERY下面直接显示完整的 ASL 所有者。
// PTO-UNIT: {"id":"PTO-ARCH-PROFILE-TRAP-CONTEXT-RECOVERY","surface":"arch","classification":["profile","trap-context-recovery"],"depends_on":["PTO-ARCH-PROFILE-REFERENCE-PROFILE"]}implementation func TrapContextRecoverable(target: AccessControlRing) => booleanbegin let control = PTOv0ReadContextRegister(target, 0x0f40); let ecstate = PTOv0ReadContextRegister(target, 0x0f00); let recovered_bpc = PTOv0ReadContextRegister(target, 0x0f41); let recovered_tpc = PTOv0ReadContextRegister(target, 0x0f43); return _TrapContexts[[target]].valid && control[4] == '1' && PTOv0EBARGControlLegal(control) && control[3:0] == ecstate[3:0] && recovered_bpc[0] == '0' && recovered_tpc[0] == '0';end;
implementation func RecoverTrapContext(target: AccessControlRing) => booleanbegin if !TrapContextRecoverable(target) then return FALSE; end; var control = PTOv0ReadContextRegister(target, 0x0f40); let ecstate = PTOv0ReadContextRegister(target, 0x0f00); let recovered_bpc = PTOv0ReadContextRegister(target, 0x0f41); let recovered_tpc = PTOv0ReadContextRegister(target, 0x0f43); WriteTPC(recovered_tpc); WriteBPC(recovered_bpc); _SystemRegisters.core_state = ecstate; _BundleArgument = _TrapContexts[[target]].bundle_argument; _CommitArgument = _TrapContexts[[target]].commit_argument; _BundleActive = control[5] == '1'; _BundleBodyActive = control[6] == '1'; _BundleCommitTargetSet = _TrapContexts[[target]].bundle_commit_target_set; _BundleConditionSet = _TrapContexts[[target]].bundle_condition_set; _SystemBlockTerminalPending = _TrapContexts[[target]].system_block_terminal_pending; _BARG.block_type = PTOv0BundleKindOf(control[10:7]); _BARG.transfer_type = PTOv0BundleTransferOf(control[13:11]); _BARG.taken = control[14] == '1'; _BARG.bpcn = PTOv0ReadContextRegister(target, 0x0f42); _FrameStackReturnTarget = _TrapContexts[[target]].frame_stack_return_target; _ReturnAddress = PTOv0ReadContextRegister(target, 0x0f44); _BundleArgumentKind = _TrapContexts[[target]].bundle_argument_kind; _BundleSequentialPC = _TrapContexts[[target]].bundle_sequential_pc; _BundleOperation = _TrapContexts[[target]].bundle_operation; _BundleDimensions = _TrapContexts[[target]].bundle_dimensions; _BundleDimensionPresent = _TrapContexts[[target]].bundle_dimension_present; _BundleScalarBindings = _TrapContexts[[target]].bundle_scalar_bindings; _BundleTileBindings = _TrapContexts[[target]].bundle_tile_bindings; _BundleSharedBindings = _TrapContexts[[target]].bundle_shared_bindings; _BundleRangeGroup = _TrapContexts[[target]].bundle_range_group; _BundleZeroParticipationSeen = _TrapContexts[[target]].bundle_zero_participation_seen; _BundleControlAttributes = _TrapContexts[[target]].bundle_control_attributes; _BundleDataAttributes = _TrapContexts[[target]].bundle_data_attributes; _BundleDataAttributesPresent = _TrapContexts[[target]].bundle_data_attributes_present; _BundleHint = _TrapContexts[[target]].bundle_hint; _BundleFixedPointAttributes = _TrapContexts[[target]].bundle_fixed_point_attributes; _LocalGenerations = _TrapContexts[[target]].local_generations; _SharedGenerations = _TrapContexts[[target]].shared_generations; _BundleExecutionDomainToken = _TrapContexts[[target]].bundle_execution_domain_token; _MemoryCopyTemplate = _TrapContexts[[target]].memory_copy_template; _FrameTemplate = _TrapContexts[[target]].frame_template; for index = 0 to PTO_TEMPORARY_QUEUE_DEPTH - 1 do _TQueue[[index]] = PTOv0ReadContextRegister(target, 0x0f45 + index); _UQueue[[index]] = PTOv0ReadContextRegister(target, 0x0f49 + index); end; _TQueueValid = _TrapContexts[[target]].t_queue_valid; _UQueueValid = _TrapContexts[[target]].u_queue_valid; _PredicateRegisters = _TrapContexts[[target]].predicates; _CurrentACR = UInt(ecstate[3:0]) as AccessControlRing; control[4] = '0'; PTOv0WriteContextRegister(target, 0x0f40, control); _TrapContexts[[target]].valid = FALSE; return TRUE;end;
本单元实现 PTO v0 对已保存陷阱上下文的验证与恢复。恢复是经过检查且只能使用一次的状态转换:无效封装返回假,并且不恢复执行状态。
TrapContextRecoverable 要求保存的上下文有效、控制位 4 已设置、EBARG 控制合法、控制值与 ECSTATE 的低 4 位 ACR 相匹配,并且恢复出的 BPC 与 TPC 都是偶数。它读取上下文寄存器 0x0f40、0x0f00、0x0f41 与 0x0f43。
RecoverTrapContext 首先再次执行可恢复性检查。成功后,它从保存的上下文与上下文寄存器恢复 TPC、BPC、核心状态、指令束参数与活动状态、指令束描述符与绑定、代次状态、模板、队列、谓词、返回地址以及当前 ACR。
验证失败会在恢复前返回假。成功恢复会清除控制位 4,写回更新后的控制寄存器,把保存的上下文置为无效,并返回真。因此第二次恢复需要重新保存的有效上下文。
本示例块只用于帮助阅读:先应用上文规则,再到规范 ASL 所有者中确认结果。它不会增加任何架构契约。
正文来自 owning ASL。拖拽或按钮只临时改变当前页面显示顺序。
No NDF clause is attached to this unit.
8 matching entries
PTO-AVS-ARCH-PROFILE-TRAP-CONTEXT-RECOVERY-STATIC-001tests/asl/arch/profile/trap-context-recovery/arch-static-trap-context-recovery-contract-001.asl11dd4c20522e3d9795355802c04340394d768c55cb872bdfc12dbad8956550bePTO-EVIDENCE-RELEASE-TRACEABILITYPTO-EVIDENCE-RELEASE-TRACEABILITYspec/evidence/release-traceability-readiness.jsonc7327021d39dc67ac5564bc55073b3870a397d79ac8d9648284d56e33bc14a3ePTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREPTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREspec/evidence/instruction-contract-closure.json3ef2bb62421c79dff8fa77a1c7983923b523244b8090812883ef81286ca8106aPTO-EVIDENCE-ARCHITECTURE-READINESSPTO-EVIDENCE-ARCHITECTURE-READINESSspec/evidence/architecture-readiness.json4b0b85199101251bea744e0f3591cc31906909dc80d5ab651c417a936036a004PTO-EVIDENCE-RELEASE-GATE-READINESSPTO-EVIDENCE-RELEASE-GATE-READINESSspec/evidence/release-gate-readiness.jsona0f4d2b6920c08981ea55fd8ef820708a40d4feb5402c5150e8e9ab532d84ce0PTO-EVIDENCE-RELEASE-MANIFESTPTO-EVIDENCE-RELEASE-MANIFESTspec/release-manifest.json1a64c109ed7a90351c41e2a418b3c0ebaf8ad975838986d2101385186b85c0d8Loading ADR-0005…
ADR-0005docs/status/decisions/0005-pto-v0-concrete-reference-profile.mda83528c2fc744cc120c2a0a32c82410059638ea88936fa65ac0eb36a0274d87cLoading ADR-0098…
ADR-0098docs/status/decisions/0098-b-range-modifiers.mde194ccc6b6922fd4b65066b533f5e4b0eba094e099970059bca8e25b4e466fba{
"classification": [
"profile",
"trap-context-recovery"
],
"documentation": "docs/arch/profile/trap-context-recovery.md",
"id": "PTO-ARCH-PROFILE-TRAP-CONTEXT-RECOVERY",
"mnemonic": null,
"readiness_subjects": [
"ADR-0005",
"ADR-0098"
],
"semantic_tests": [],
"source": "asl/arch/profile/trap-context-recovery.asl",
"surface": "arch",
"tests": [
"PTO-AVS-ARCH-PROFILE-TRAP-CONTEXT-RECOVERY-STATIC-001"
]
}0.58.5 · 候选发布7dc8b7e5b121d2b2499a2273bebff29e2cd868126c87ee4d53ed316f6ad72768ac84f67bcdf19c3af52dd96f3eb97eddc07c1357db504decb18c482a88869599526eed6ab80d0033928c29ba532b3f7718659991asl/arch/profile/trap-context-recovery.asl