Skip to content

net: derive socket timeval from target ABI - #459

Open
xuchang-vivo wants to merge 3 commits into
vivoblueos:mainfrom
xuchang-vivo:xc/fix-socket-timeval-abi
Open

net: derive socket timeval from target ABI#459
xuchang-vivo wants to merge 3 commits into
vivoblueos:mainfrom
xuchang-vivo:xc/fix-socket-timeval-abi

Conversation

@xuchang-vivo

@xuchang-vivo xuchang-vivo commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Define the socket timeval syscall layout directly from the BlueOS target data model.
  • Use two i32 fields on ILP32 targets and two i64 fields on LP64 targets.
  • Normalize ABI values into an internal fixed-width representation without depending on libc time_t, suseconds_t, or timeval definitions.
  • Reject pointers, lengths, and field values that do not match the active target ABI.
  • Correct the conversion from microseconds to Rust Duration nanoseconds.
  • Add unit coverage for target layout parsing, writing, width validation, field validation, and duration conversion.

Motivation

Socket options cross a syscall ABI boundary. Their binary layout must be determined by the supported BlueOS target ABI, not inferred from libc Rust type aliases that can change independently or disagree with the prebuilt Rust standard library.

BlueOS currently supports ILP32 and LP64 target data models:

  • ILP32: timeval { i32 tv_sec; i32 tv_usec; }
  • LP64: timeval { i64 tv_sec; i64 tv_usec; }

The kernel now accepts only the layout for the active target and converts it into an internal i64 seconds/microseconds representation. This keeps the syscall ABI explicit and independent of libc implementation details.

References

Testing

  • Added unit tests for the supported target ABI layouts and conversions.
  • rustfmt --check kernel/src/net/types.rs kernel/src/net/syscalls.rs
  • git diff --check
  • No board build was run.

@xuchang-vivo

Copy link
Copy Markdown
Contributor Author

build_prs

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/32939596118.

@xuchang-vivo

Copy link
Copy Markdown
Contributor Author

build_prs

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/32942264528.

@xuchang-vivo xuchang-vivo changed the title net: support 32-bit timeval socket ABI net: derive socket timeval from target ABI Aug 26, 2026
@xuchang-vivo

Copy link
Copy Markdown
Contributor Author

build_prs

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/32949206198.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant