[PR #33] [MERGED] drivers: clamp elapsed-time differences against backward clock steps #89

Closed
opened 2026-11-03 22:04:34 -07:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/RhapsodiOS/RhapsodiOS/pull/33
Author: @raynorpat
Created: 9/26/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @raynorpat

Base: master ← Head: claude/hopeful-pasteur-r3wqxx


📝 Commits (1)

  • 3304607 drivers: clamp elapsed-time deltas against backward clock steps

📊 Changes

12 files changed (+67 additions, -12 deletions)

View changed files

📝 src/drivers-i386/ide/drvEIDE/EIDE.drvproj/EIDE.lksproj/IdeDiskInternal.m (+1 -1)
📝 src/drivers-i386/ide/drvPCFloppy/Floppy.drvproj/Floppy.lksproj/FloppyDriveInt2.m (+4 -3)
📝 src/drivers-i386/ide/drvPCFloppy/reconstruction/divergences.md (+15 -0)
📝 src/drivers-i386/scsi/drvAMDPCSCSIDriver/AMDPCSCSIDriver.drvproj/AMDPCSCSIDriver.lksproj/AMD_SCSI.m (+4 -3)
📝 src/drivers-i386/scsi/drvAMDPCSCSIDriver/AMDPCSCSIDriver.drvproj/AMDPCSCSIDriver.lksproj/AMD_x86.m (+2 -1)
📝 src/drivers-i386/scsi/drvAdaptec1542B/Adaptec1542B.drvproj/Adaptec1542B.lksproj/AHAThread.m (+1 -1)
📝 src/drivers-i386/scsi/drvAdaptec1542B/reconstruction/divergences.md (+13 -0)
📝 src/drivers-i386/scsi/drvAdaptec6X60/Adaptec6X60.drvproj/Adaptec6X60.lksproj/AIC6X60Thread.m (+1 -1)
📝 src/drivers-i386/scsi/drvAdaptec6X60/reconstruction/divergences.md (+12 -0)
📝 src/drivers-i386/scsi/drvBusLogic/BusLogic.drvproj/BusLogic.lksproj/BusLogicThread.m (+1 -1)
📝 src/drivers-i386/scsi/drvDPT2000/DPT2000.drvproj/DPT2000.lksproj/EATAControllerThread.m (+1 -1)
📝 src/drivers-i386/scsi/drvDPT2000/reconstruction/divergences.md (+12 -0)

📄 Description

Summary

Follow-up to #26. Clamps the remaining now - then elapsed-time computations on the unsigned 64-bit ns_time_t (from IOGetTimestamp()) that could wrap to ~1.8e19 ns if a backward clock step occurs (possible under heavy TCG load when IRQ0 is serviced more than one PIT period late).

Sites fixed, all changed from end - start to (end > start) ? end - start : 0 (or equivalent):

Transfer statistics (totalTime / latentTime):

  • drvEIDE/IdeDiskInternal.m — delta = end_time - start_time
  • drvPCFloppy/FloppyDriveInt2.m — endTime - startTime (both read/write branches)
  • drvBusLogic/BusLogicThread.m — scsiReq->totalTime
  • drvAdaptec1542B/AHAThread.m — scsiReq->totalTime
  • drvAdaptec6X60/AIC6X60Thread.m — scsiReq->totalTime
  • drvDPT2000/EATAControllerThread.m — scsiReq->totalTime
  • drvAMDPCSCSIDriver/AMD_SCSI.m — scsiReq->latentTime += currentTime - disconnectTime

Debug-only timing (DDM builds):

  • drvAMDPCSCSIDriver/AMD_SCSI.m — interrupt elapsed time
  • drvAMDPCSCSIDriver/AMD_x86.m — IPL test usTime computation

The other sites the issue identified as already safe (timeout scans comparing absolute deadlines, IODelay, etc.) were left untouched.

Recorded the four statistics-path fixes with a reconstruction/divergences.md (drvPCFloppy, drvAdaptec1542B, drvAdaptec6X60, drvDPT2000) as intentional divergences from the reference binary, per the issue's guidance.

Test plan

  • i386 kernel with the #26 clock fix has been built but not yet boot-tested (carried over as still-open from #26; out of scope here)
  • Manual review of each changed site against the issue's file/line references
  • Verified no other callers of the changed expressions were missed

Fixes #28

🤖 Generated with Claude Code

https://claude.ai/code/session_015XptfxXQbyzUsRG1LkNicw


Generated by Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/RhapsodiOS/RhapsodiOS/pull/33 **Author:** [@raynorpat](https://github.com/raynorpat) **Created:** 9/26/2026 **Status:** ✅ Merged **Merged:** 9/26/2026 **Merged by:** [@raynorpat](https://github.com/raynorpat) **Base:** `master` ← **Head:** `claude/hopeful-pasteur-r3wqxx` --- ### 📝 Commits (1) - [`3304607`](https://github.com/RhapsodiOS/RhapsodiOS/commit/3304607ff059b700fdc7d123cee99e0f8c9bd6b6) drivers: clamp elapsed-time deltas against backward clock steps ### 📊 Changes **12 files changed** (+67 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `src/drivers-i386/ide/drvEIDE/EIDE.drvproj/EIDE.lksproj/IdeDiskInternal.m` (+1 -1) 📝 `src/drivers-i386/ide/drvPCFloppy/Floppy.drvproj/Floppy.lksproj/FloppyDriveInt2.m` (+4 -3) 📝 `src/drivers-i386/ide/drvPCFloppy/reconstruction/divergences.md` (+15 -0) 📝 `src/drivers-i386/scsi/drvAMDPCSCSIDriver/AMDPCSCSIDriver.drvproj/AMDPCSCSIDriver.lksproj/AMD_SCSI.m` (+4 -3) 📝 `src/drivers-i386/scsi/drvAMDPCSCSIDriver/AMDPCSCSIDriver.drvproj/AMDPCSCSIDriver.lksproj/AMD_x86.m` (+2 -1) 📝 `src/drivers-i386/scsi/drvAdaptec1542B/Adaptec1542B.drvproj/Adaptec1542B.lksproj/AHAThread.m` (+1 -1) 📝 `src/drivers-i386/scsi/drvAdaptec1542B/reconstruction/divergences.md` (+13 -0) 📝 `src/drivers-i386/scsi/drvAdaptec6X60/Adaptec6X60.drvproj/Adaptec6X60.lksproj/AIC6X60Thread.m` (+1 -1) 📝 `src/drivers-i386/scsi/drvAdaptec6X60/reconstruction/divergences.md` (+12 -0) 📝 `src/drivers-i386/scsi/drvBusLogic/BusLogic.drvproj/BusLogic.lksproj/BusLogicThread.m` (+1 -1) 📝 `src/drivers-i386/scsi/drvDPT2000/DPT2000.drvproj/DPT2000.lksproj/EATAControllerThread.m` (+1 -1) 📝 `src/drivers-i386/scsi/drvDPT2000/reconstruction/divergences.md` (+12 -0) </details> ### 📄 Description ## Summary Follow-up to #26. Clamps the remaining `now - then` elapsed-time computations on the unsigned 64-bit `ns_time_t` (from `IOGetTimestamp()`) that could wrap to ~1.8e19 ns if a backward clock step occurs (possible under heavy TCG load when IRQ0 is serviced more than one PIT period late). Sites fixed, all changed from `end - start` to `(end > start) ? end - start : 0` (or equivalent): **Transfer statistics** (`totalTime` / `latentTime`): - `drvEIDE/IdeDiskInternal.m` — `delta = end_time - start_time` - `drvPCFloppy/FloppyDriveInt2.m` — `endTime - startTime` (both read/write branches) - `drvBusLogic/BusLogicThread.m` — `scsiReq->totalTime` - `drvAdaptec1542B/AHAThread.m` — `scsiReq->totalTime` - `drvAdaptec6X60/AIC6X60Thread.m` — `scsiReq->totalTime` - `drvDPT2000/EATAControllerThread.m` — `scsiReq->totalTime` - `drvAMDPCSCSIDriver/AMD_SCSI.m` — `scsiReq->latentTime += currentTime - disconnectTime` **Debug-only timing (DDM builds)**: - `drvAMDPCSCSIDriver/AMD_SCSI.m` — interrupt elapsed time - `drvAMDPCSCSIDriver/AMD_x86.m` — IPL test `usTime` computation The other sites the issue identified as already safe (timeout scans comparing absolute deadlines, `IODelay`, etc.) were left untouched. Recorded the four statistics-path fixes with a `reconstruction/divergences.md` (drvPCFloppy, drvAdaptec1542B, drvAdaptec6X60, drvDPT2000) as intentional divergences from the reference binary, per the issue's guidance. ## Test plan - [ ] i386 kernel with the #26 clock fix has been built but not yet boot-tested (carried over as still-open from #26; out of scope here) - [x] Manual review of each changed site against the issue's file/line references - [x] Verified no other callers of the changed expressions were missed Fixes #28 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015XptfxXQbyzUsRG1LkNicw --- _Generated by [Claude Code](https://claude.ai/code/session_015XptfxXQbyzUsRG1LkNicw)_ --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-11-03 22:04:34 -07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github-starred/RhapsodiOS#89
No description provided.