Skip to content

nvx-rs: print zero MSR values in nvx-time-probe clock --msr as C's %#x does #589

Closed

Description

Summary

nvx-time-probe clock --msr prints each MSR's value with Rust's {:#x}, which prints zero as 0x0. The C program printed it with %#" PRIx64, whose alternate form prefixes 0x to nonzero values only, so a zero MSR prints = 0x0 (0) where C printed = 0 (0). CPU 0's HV_X64_MSR_VP_INDEX, which the probe reads, is always zero, so every clock --msr run that can read the MSRs 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. #590 is the same difference in the CPUID fields.

Proposal

Add a helper for C's %#x, which prints zero without the prefix, as alternate_hex_width_10 in nvx-rs/src/guest/time_probe/clock.rs already does for %#010x, and print the MSR values with it. #590 can use the same helper.

Tasks

  • Print zero MSR values as 0 in print_msrs, keeping 0x before nonzero values.
  • Add a regression that formats zero and nonzero MSR values, with the C program's output as the expected result.

Activity

  1. gezerui888 commented on Oct 20, 2026

    @gezerui888

    I'd like to fix this together with #590 and add regression tests. I'll open a PR shortly.

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