ASELSANMicrokernel
S342 · SOURCE-BOUND GATE EVIDENCE

S342 · Fatal-termination production writer guard integration

production acquire → S247 guard modülü → Operations-bound focused test Bu sayfa yalnız S342 kapısına aittir; komşu kapıların kaynakları bu kabulün içine katılmaz.

S342Production writer guardOperations id exactsource SHA exacttest target exact

operation: g8l-s342-fatal-termination-writer-guard-integration-partial

production · S247 guard · focused test · Operations · 4 exact excerpt

sequence-bound=true · implementation-bound=true
01 · Test edilen uygulama/model kodu

Kapının yürüttüğü gerçek kaynak

tam Rust öğesiL5635–L5740
kernel/src/task/scheduler.rs::terminate_current_task_due_to_fatal_error

/// Task'in temiz çıkması için kullanılır. Geri dönmez: `yield_now` Dead state'i
/// görüp başka task'e geçecek; Box bir sonraki scheduler girişinde reap edilir.
/// Mevcut task'i fatal bir hata nedeniyle (stack overflow, page fault, vs.) sonlandırır.
///
/// Bu fonksiyon hem stack guard hem de diğer kritik hatalar için ortak kullanılmak üzere tasarlanmıştır.
/// Mümkün olduğunca fazla debug bilgisi vermeye çalışır (register'lar dahil).
///
/// `ctx` parametresi verilirse daha zengin register dump yapar.
pub unsafe fn terminate_current_task_due_to_fatal_error(
    reason: &str,
    ctx: Option<&crate::arch::aarch64::exceptions::ExceptionContext>,
) -> ! {
    let cpu = crate::percpu::current_cpu_id();
    #[cfg(feature = "board-rpi5")]
    let s256_scheduler_read_access = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s255_task_exit_identity_read_access_guard_expansion::acquire_s256_production_scheduler_read_access()
        .unwrap_or_else(|error| {
            panic!(
                "S256 fatal-task identity scheduler read access failed closed: {:?}",
                error
            )
        });
    let terminating_task = (&*core::ptr::addr_of!(SCHEDULER))
        .current_task
        .as_ref()
        .map(|task| task.id);
    #[cfg(feature = "board-rpi5")]
    drop(s256_scheduler_read_access);
    if let Some(task_id) = terminating_task {
        let teardown = match crate::ui::capability::teardown_task_ipc_lifecycle(task_id) {
            Ok(teardown) => teardown,
            Err(error) => fail_closed_on_ipc_lifecycle(task_id, error),
        };
        crate::kprintln!(
            "[K2-LIFECYCLE] fatal task#{} revoked {} owned endpoint(s), cancelled {} responder reply(s), drained {} call(s), removed {} owned notification(s)/{} grant(s), cancelled {} notification waiter(s), woke {} peer(s)",
            task_id,
            teardown.owned_endpoints,
            teardown.cancelled_responder_calls,
            teardown.drained_calls,
            teardown.owned_notifications,
            teardown.revoked_notification_grants,
            teardown.cancelled_notification_waiters,
            teardown.woken_notification_waiters,
        );
        recover_bound_runtime_oom_supervisor_on_task_exit(task_id);
    }
    #[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
    let s342_irq_guard = crate::arch::aarch64::IrqGuard::new();
    #[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
    let s342_writer_access = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s342_fatal_termination_writer_guard_integration::acquire_s342_production_scheduler_writer_access()
        .unwrap_or_else(|error| {
            panic!(
                "S342 fatal-termination scheduler writer guard failed closed: {:?}",
                error
            )
        });
    let sched = &mut *core::ptr::addr_of_mut!(SCHEDULER);

    if let Some(curr) = &mut sched.current_task {
        crate::kprintln!(
            "\n[FATAL] !!! Terminating task #{} ({}) !!!",
            curr.id,
            curr.name
        );
        crate::kprintln!("  Reason : {}", reason);
        crate::kprintln!("  CPU    : {}", cpu);

        // ExceptionContext varsa en zengin bilgiyi buradan al
        if let Some(c) = ctx {
            crate::kprintln!("  ELR_EL1   : 0x{:016x}", c.elr_el1);
            crate::kprintln!("  SPSR_EL1  : 0x{:016x}", c.spsr_el1);
            // ExceptionContext.gpr = [u64; 30] (x0..x29); x30 ayrı `lr` alanında.
            crate::kprintln!("  x29 (FP)  : 0x{:016x}", c.gpr[29]);
            crate::kprintln!("  x30 (LR)  : 0x{:016x}", c.lr);
            crate::kprintln!("  x0        : 0x{:016x}", c.gpr[0]);
            crate::kprintln!("  x1        : 0x{:016x}", c.gpr[1]);
        } else {
            // Context switch sırasında geldiysek mevcut TaskContext'ten bazı bilgileri logla
            crate::kprintln!("  x29 (FP)  : 0x{:016x}", curr.context.x29);
            crate::kprintln!("  x30 (LR)  : 0x{:016x}", curr.context.x30);
            crate::kprintln!("  SP (ctx)  : 0x{:016x}", curr.context.sp);
        }

        curr.state = TaskState::Dead;
        curr.finished
            .store(true, core::sync::atomic::Ordering::Release);
    }

    #[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
    drop(s342_writer_access);
    #[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
    drop(s342_irq_guard);

    // A fatal EL0 path obeys the same order as sys_exit: switch away and
    // complete the broadcast TLBI here; the later-stack reaper drops the root
    // and publishes the identifier as free only after that teardown.
    retire_current_asid_after_kernel_switch();

    // Scheduler'ın temizlemesi için yield
    yield_now();

    // Bu noktaya dönmemeliyiz
    loop {
        core::arch::asm!("wfi", options(nomem, nostack));
    }
}
snippet sha256: 1cf0285c5cc5file sha256: 838dd474448c
02 · Ortak exclusion üyeliği

S247 production writer guard

tam Rust öğesiL160–L172
kernel/src/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s342_fatal_termination_writer_guard_integration.rs::acquire_s342_production_scheduler_writer_access

#[cfg(all(target_arch = "aarch64", target_os = "none", feature = "board-rpi5"))]
pub fn acquire_s342_production_scheduler_writer_access(
) -> Result<G8lS342ProductionSchedulerWriterAccess, G8lS247WholeSchedulerAccessError> {
    let caller_cpu =
        crate::percpu::try_current_cpu_id().ok_or(G8lS247WholeSchedulerAccessError::InvalidCpu)?;
    if caller_cpu != crate::g8l_runtime_contract::CPU0 {
        return Err(G8lS247WholeSchedulerAccessError::InvalidCpu);
    }
    let access = crate::g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s246_whole_scheduler_read_access_guard::S247_PRODUCTION_WHOLE_SCHEDULER_ACCESS_GATE
        .try_acquire_exclusive_for_valid_cpu(caller_cpu)?;
    Ok(G8lS342ProductionSchedulerWriterAccess { _access: access })
}
snippet sha256: 1045f808b158file sha256: ec6e2d07210f
03 · Doğrulayan test kodu

Operations komutuna bağlı focused test

tam Rust öğesiL221–L238
simulation/tests/g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s342_fatal_termination_writer_guard_integration.rs::target_function_contains_one_mutable_alias_and_one_s342_guard

#[test]
fn target_function_contains_one_mutable_alias_and_one_s342_guard() {
    let target = fatal_boundary();
    assert_eq!(target.matches("addr_of_mut!(SCHEDULER)").count(), 1);
    assert_eq!(
        target
            .matches("acquire_s342_production_scheduler_writer_access()")
            .count(),
        1
    );
    assert_eq!(
        target
            .matches("if let Some(curr) = &mut sched.current_task")
            .count(),
        1
    );
}
snippet sha256: 783d359b5308file sha256: 75504d1cea77
04 · Kapı kimlik kaydı

Operations sıra, kimlik ve başlık bağı

tam Operations kaydıL13741–L13820
website/src/lib/operations.ts::g8l-s342-fatal-termination-writer-guard-integration-partial
  {
    id: "g8l-s342-fatal-termination-writer-guard-integration-partial",
    date: "2026-08-27",
    sequence: 342,
    status: "passed",
    umbrella_status: "partial",
    title: "S342 · Fatal-termination production writer guard integration",
    summary:
      "S342, terminate_current_task_due_to_fatal_error içindeki tek mutable SCHEDULER fatal-state publication sınırını S341 ve 44 production reader'ın kullandığı aynı S247 state word'e bağlar. Tarihsel S256 reader current task id'sini owned scalar'a kopyalayıp düşer; IPC lifecycle teardown ile bound runtime-OOM recovery tamamlandıktan sonra local IRQ guard ve CPU0-only S342 writer alınır. Writer exact fatal diagnostic'i, curr.state = TaskState::Dead ve curr.finished.store(true, Ordering::Release) tarihsel sırasını kapsar; writer ile IRQ guard ayrı S341 ASID retirement, S334 yield_now ve terminal WFI'dan önce bırakılır. Guarded writer 15/69, açık writer 54 ve provider authority 0'dır. Production kaynakta iki direct callsite vardır fakat supported-profile S342 runtime observation=0'dır; downstream execute_runtime_oom_teardown writer'ı S343 için ayrı açık kalır.",
    evidence: [
      "Focused fatal-termination writer-integration kapısı 31/31 PASS verdi. Önceki S341 31/31, tarihsel S256 task-exit identity read 11/11, task-lifecycle source 5/5, deferred current-runtime-OOM 5/5, runtime-OOM lifecycle recovery 7/7 ve lower-EL fault recovery 7/7 regresyonları ayrıca geçti.",
      "Aynı S247 state word üzerinde CPU0-only writer membership, non-CPU0 pre-commit rejection, reader→writer ve writer→reader exclusion, exact-once success/error release ve S341→S342 token monotonluğu doğrulandı.",
      "Production kaynak sırası S256 reader acquire → current task id owned copy → reader drop → IPC lifecycle teardown → bound runtime-OOM recovery → IRQ guard → acquire_s342 writer → tek mutable alias → exact fatal diagnostic → TaskState::Dead → finished=true Release store → writer drop → IRQ restore → ayrı S341 retirement → ayrı S334 yield_now → WFI olarak kilitlendi.",
      "S342 writer sınırı S256 reader'ı, teardown/recovery etkilerini, ASID retirement'ı, yield/context-switch'i veya terminal WFI'ı kapsamaz. Writer ve IRQ üyeliği downstream fonksiyonlara taşınmaz; historical missing-current davranışı ve fatal log sırası korunur.",
      "arch/aarch64/exceptions.rs içindeki iki production terminate_current_task_due_to_fatal_error çağrı noktası kaynakta sayıldı. Bu source-wiring envanteridir; QEMU/RPi supported-profile invocation veya cihaz gözlemi değildir.",
      "Fresh izole AArch64 profilleri 4/4 exit 0 verdi: board-qemu 112340 B / 0f19f418…de56 / 293 warning header; board-rpi4 151064 B / 2be04ac7…9c2d / 391; board-rpi5 531909 B / 3e4d6e37…2377 / 1180; board-rpi5+smp check 531903 B / 90016afe…e6f / 1180. Zero-warning iddiası yoktur.",
      "S238–S342 dependency matrisi iki bağımsız seri koşuda 106 grup / 1667/1667 PASS verdi; 13961 B süre-normalize özetler aynı c3a46929…bada SHA-256 ile byte-eşittir. Ham koşular 13855 B ve cbcca685…d8d4c / e2c95002…fa23'tür.",
      "Exact yedi tarihsel assertion adı dışlanıp --test-threads=1 kabulü kullanıldığında workspace 304 sonuç grubu / 3497 PASS / 0 fail / 7 filtered verdi; 67195 B log 1e7b1980…0c27'dir.",
      "Filtresiz workspace exit 101 ile yalnız frozen S96 wiring_does_not_mutate_timer_gic_boot_or_expand_runtime_scope source-identity reddinde durdu; 62417 B log 775aac1f…c89f'dir ve global workspace GREEN iddia edilmez.",
      "make verify-qemu ortak regresyonu 116447 B / ca6a60b9…2ca7 ile strict ELF W^X 31/31, S130–S154, IPC 20/20, scheduler SEC5 ve kernel fault marker 0 PASS verdi. Bu S342 fatal-termination writer invocation kanıtı değildir.",
      "S245 request ve S244 admission dokunulmadan kalır; production provider authority=0, whole-scheduler exclusion=false ve toplam 54 production writer açık kalır.",
      "Website 532/532 test ile PASS; lint, boş çıktılı TypeScript kontrolü ve 23/23 static route ayrıca geçti. İlk Cloudflare Pages production/main S342 içerik yayını daff6ae7 ile tamamlandı; çıktı 193 statik dosyadır.",
      "Cache-busted custom-domain /operations/ ve /timeline/ rotaları HTTP 200 döndü ve dağıtım sonrası yerel out ile byte-exact eşleşti. Operations 10529492 B / 7681e276…0ec, Timeline 2724325 B / a2a917e5…fd3d'dir.",
      "Timeline'da 181 ayrı data-gate-policy kartı vardır; S342, S341, S340, S339, S338, S337, S325, S324 ve S323 tam birer kez bulunur. S342 policy 4127 karakter, S324–S342 minimum yoğunluğu 1055 karakterdir ve birleşik gate-policy kutusu yoktur.",
      "Immutable https://daff6ae7.aselsan-microkernel.pages.dev/timeline/ erişimi bu doğrulama ortamından 10 saniyede curl exit 28 / HTTP 000 verdi; custom-domain byte-exact PASS'i bu sonucu gizlemez.",
      "Fiziksel/device işlem yapılmadı: physical/device operations=0 ve RUNBOOK_EXECUTED_IN_S342=NO.",
    ],
    commands: [
      "cargo test -p aselsan_microkernel_simulation --test g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s342_fatal_termination_writer_guard_integration -- --nocapture",
      "cargo build -p aselsan_kernel --target aarch64-unknown-none --no-default-features --features board-rpi5",
      "cargo check -p aselsan_kernel --target aarch64-unknown-none --no-default-features --features board-rpi5,smp",
      "cargo test --workspace --quiet -- --test-threads=1 [seven exact historical --skip filters]",
      "make verify-qemu",
      "npm run deploy",
    ],
    terminalSessions: [
      {
        id: "g8l-s342-fatal-termination-writer-guard-integration",
        title: "G8l S342 fatal-termination writer guard integration",
        commandLines: [
          "cargo test -p aselsan_microkernel_simulation --test g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s342_fatal_termination_writer_guard_integration -- --nocapture",
        ],
        outputLines: [
          "test result: ok; S342 focused 1 group / 31 passed; 0 failed",
          "shared S247 gate: 44 guarded readers + 15/69 guarded writers; 54 writers open",
          "S256 copy/drop < teardown/recovery < IRQ < S342 writer < fatal log < Dead < finished Release < writer drop < IRQ restore < S341 < S334 < WFI",
          "production source callsites=2; supported-profile runtime observations=0",
        ],
        exitCode: 0,
        outputMode: "complete",
      },
      {
        id: "g8l-s342-operations-timeline-production-publication",
        title: "S342 Operations/Timeline production publication",
        commandLines: [
          "npm run deploy",
          "curl --cache-busted https://aselsan.kerege.net/{operations,timeline}/ and compare with local out",
        ],
        outputLines: [
          "website 532/532; lint PASS; TypeScript PASS; static routes 23/23; files=193",
          "Cloudflare Pages production/main initial content deployment: daff6ae7 · https://daff6ae7.aselsan-microkernel.pages.dev",
          "custom-domain operations HTTP 200 · 10529492 B · SHA-256 7681e276ff8382e3176229cbe74330c430f5a648552dd7094a92ee01219930ec · byte-exact PASS",
          "custom-domain timeline HTTP 200 · 2724325 B · SHA-256 a2a917e5297121aa5bf1c990658e51ff03c2f1e39f3eac7598e6434fbf3afd3d · byte-exact PASS",
          "timeline cards=181; S342/S341/S340/S339/S338/S337/S325/S324/S323 exact-once; S342 policy=4127 chars; S324-S342 minimum=1055 chars",
          "immutable deployment URL probe: curl exit 28 after 10 s · HTTP 000; custom-domain evidence remains authoritative",
        ],
        exitCode: 0,
        outputMode: "complete",
      },
    ],
    terminalSessionsNote:
      "S342 on beşinci production writer'ın kaynak entegrasyonudur. İki source callsite bulunur, fakat supported-profile runtime/cihaz gözlemi yoktur; global exclusion ya da provider authority oluşmadı.",
    limitations: [
      "54 production writer aynı shared gate dışında kaldığı için whole-scheduler exclusion ve provider authority açık kalır.",
      "İki production source callsite wiring kanıtıdır; supported-profile S342 invocation/observation kanıtı yoktur.",
      "Downstream execute_runtime_oom_teardown writer entegrasyonu S343 için açık bırakılmıştır.",
      "Default-parallel PTY determinism S331'den açık taşınır; kayıtlı seri kabul matrisi kullanılır.",
      "Transient-contention liveness/soak, Generic SMP ve fiziksel RPi kabulü açık kalır.",
    ],
  },
snippet sha256: 65c162929b86file sha256: 9726dbf00f84
Focused test komutu
cargo test -p aselsan_microkernel_simulation --test g8l_target_dispatch_scheduler_owner_scheduler_mutation_production_migration_lifecycle_s342_fatal_termination_writer_guard_integration -- --test-threads=1
proof: docs/M8.1-RPi5-G8l-S342-Fatal-Termination-Writer-Guard-Integration-Proof.md
Registry schema v5 · generator website/scripts/generate-code-gates.mjs · Tam SHA-256: 3050638b71a684d8f8f947a8a6faa237a17fa8db5dc0db04fb207b668b462af9