Skip to content

nvx-rs: print zero CPUID fields in nvx-time-probe clock as C's %#x does #590

Closed

Description

Summary

nvx-time-probe clock prints the hypervisor's CPUID fields with Rust's {:#x}, which prints zero as 0x0, where the C program's %#x printed 0. The summary line's hv_max_leaf, hv_features_eax, and hv_features_edx are all zero when the hypervisor bit is clear, and its feature fields are zero under a hypervisor whose leaves end before 0x40000003. The cpuid.0x40000000 line's eax.max_leaf is likewise zero for a hypervisor whose leaf reads zero. Each such valid run differs from the C program's byte-exact output.

Found in the #550 review. The port has differed since its first revision, and #550 leaves the fix to this issue. #589 is the same difference in the MSR values.

Proposal

Print these fields with the helper for C's %#x that #589 proposes, which prints zero without the prefix, as alternate_hex_width_10 already does for %#010x.

Tasks

  • Print zero as 0 in the summary line's hv_max_leaf, hv_features_eax, and hv_features_edx, and in the eax.max_leaf that print_cpuid prints, keeping 0x before nonzero values.
  • Add a regression for the zero-valued summary of a CPU without the hypervisor bit, with the C program's output as the expected result.

Activity

  1. gezerui888 commented on Oct 20, 2026

    @gezerui888

    I'll include this in my fix for #589, with regression tests.

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

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions