Skip to content

Legacy GetTime syscall returns three different units across its three implementations (live aarch64 path answers in nanoseconds) #817

Description

@ryanbreen

The legacy GetTime syscall has three implementations in this tree and they do
not agree on what they return.

  • kernel/src/arch_impl/aarch64/syscall_entry.rs sys_get_time() -- monotonic
    nanoseconds (get_monotonic_time_ns() folded to a single u64). This is the
    one EL0 reaches: dispatch_syscall_enum routes SyscallNumber::GetTime here.
  • kernel/src/arch_impl/aarch64/exception.rs, the syscall_nums::GET_TIME arm of
    handle_syscall -- milliseconds. Reached only for an SVC issued from EL1;
    the EL0 path takes rust_syscall_handler_aarch64 instead.
  • kernel/src/syscall/handlers.rs sys_get_time() -- milliseconds. Not
    reachable from userspace at all: x86 answers SyscallNumber::GetTime with
    NoSys in syscall/handler.rs, and the function's only caller in the tree is
    an in-kernel diagnostic in main.rs.

So the same syscall number answers in nanoseconds on the live aarch64 path, in
milliseconds on two paths userspace cannot take, and ENOSYS on x86.

Until this round the live implementation also carried the comment "returns ticks
directly" over a body returning nanoseconds -- a third unit, in prose. That
comment is now corrected, which is why this is a divergence rather than a
falsehood, but the divergence itself is untouched.

Nothing decides it from inside the tree: a grep of userspace/ and
libs/libbreenix/ finds no caller of this syscall.
userspace/programs/src/timer_test.rs builds its own get_time_ms() on
clock_gettime. So there is no consumer whose expectation picks the unit, and
changing the returned value is an ABI decision rather than a repair.

Options, roughly:

  1. Pick milliseconds (matches the syscall's name and both sibling
    implementations), change the aarch64 EL0 path, and delete or redirect the EL1
    arm so one implementation serves both.
  2. Pick nanoseconds and correct the siblings.
  3. Retire GetTime outright in favour of clock_gettime, which is what the one
    in-tree userspace timing program already uses, and make every path answer
    NoSys as x86 already does.

Option 3 is probably right -- the arm is already marked deprecated at
exception.rs's GET_TIME constant -- but it is a decision, not a cleanup.

Filed from the #767 review round (finding B5).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions