diff --git a/Guide/src/reference/devices/virtio/rtc.md b/Guide/src/reference/devices/virtio/rtc.md index 1fe84bc7eae..4b001423538 100644 --- a/Guide/src/reference/devices/virtio/rtc.md +++ b/Guide/src/reference/devices/virtio/rtc.md @@ -5,11 +5,11 @@ the [Virtio 1.4 RTC protocol][spec] (device ID 17). ## Clock and requests -The device exposes clock ID 0 with type `UTC_MAYBE_SMEARED`. Readings use -host `SystemTime` and are returned as little-endian 64-bit nanoseconds since -the Unix epoch. The host's leap-second policy is unspecified. Nanosecond -units do not imply nanosecond accuracy, and host clock adjustments can move -the reported time forward or backward. +The device exposes clock ID 0 with type `UTC_SMEARED` and an unspecified +smearing variant. Readings use host `SystemTime` and are returned as +little-endian 64-bit nanoseconds since the Unix epoch. No device-side +smearing is applied. Nanosecond units do not imply nanosecond accuracy, and +host clock adjustments can move the reported time forward or backward. Supported requests discover the clock count, query clock capabilities, and read the clock. Cross-timestamp capability queries succeed with no supported @@ -42,11 +42,12 @@ topology requirements. ## Guest support -The guest needs a Virtio RTC driver. Linux requires `CONFIG_VIRTIO_RTC` and -`CONFIG_VIRTIO_RTC_PTP` for this clock, together with the PTP subsystem. -Linux exposes it through the associated `/dev/ptpN` clock, read using -`clock_gettime()` with the device's dynamic clock ID, not through a legacy -CMOS RTC or the guest's system clock. Providing the device does not -automatically synchronize guest system time. +Linux can register an RTC-class device with `CONFIG_VIRTIO_RTC_CLASS`. +For kernel boot-time wall-clock initialization, build in the driver with +`CONFIG_VIRTIO_RTC=y`, enable `CONFIG_RTC_HCTOSYS`, and set +`CONFIG_RTC_HCTOSYS_DEVICE` to the assigned RTC name (for example, `rtc0`). +With `CONFIG_VIRTIO_RTC_PTP` and the PTP subsystem, Linux also exposes the +clock through `/dev/ptpN`, read using `clock_gettime()` with the device's +dynamic clock ID. [spec]: https://docs.oasis-open.org/virtio/virtio/v1.4/virtio-v1.4.html diff --git a/Guide/src/reference/openvmm/management/cli.md b/Guide/src/reference/openvmm/management/cli.md index f51ad2a3ee8..62035a283c5 100644 --- a/Guide/src/reference/openvmm/management/cli.md +++ b/Guide/src/reference/openvmm/management/cli.md @@ -285,7 +285,7 @@ describes the source definitions. values are `auto`, `mmio`, `pci`, `pcie:PORT`, and `vpci`. Defaults to `auto`. `--virtio-rng-pcie-port` overrides this option. * `--virtio-rtc [bus=BUS]`: Add a Virtio 1.4 RTC device with one read-only - `UTC_MAYBE_SMEARED` clock backed by host wall time. Readings use nanosecond + `UTC_SMEARED` clock backed by host wall time. Readings use nanosecond units; cross-timestamping and alarms are not supported. The guest needs a Virtio RTC driver. The optional `bus` accepts `auto`, `mmio`, `pci`, `pcie:PORT`, or `vpci`; bare `--virtio-rtc` uses `auto`. No device is added diff --git a/vm/devices/virtio/virtio_rtc/src/lib.rs b/vm/devices/virtio/virtio_rtc/src/lib.rs index 7026bb93952..f33e4ba68b9 100644 --- a/vm/devices/virtio/virtio_rtc/src/lib.rs +++ b/vm/devices/virtio/virtio_rtc/src/lib.rs @@ -222,7 +222,7 @@ fn handle_request(mem: &GuestMemory, work: &VirtioQueueCallbackWork) -> u32 { } let response = spec::RespClockCap { head: ok_head(), - clock_type: spec::CLOCK_UTC_MAYBE_SMEARED, + clock_type: spec::CLOCK_UTC_SMEARED, leap_second_smearing: spec::SMEAR_UNSPECIFIED, flags: 0, reserved: [0; 5], diff --git a/vm/devices/virtio/virtio_rtc/src/spec.rs b/vm/devices/virtio/virtio_rtc/src/spec.rs index 7442c2ee716..44af2c164c3 100644 --- a/vm/devices/virtio/virtio_rtc/src/spec.rs +++ b/vm/devices/virtio/virtio_rtc/src/spec.rs @@ -25,7 +25,7 @@ pub const S_ENODEV: u8 = 3; pub const S_EINVAL: u8 = 4; pub const S_EIO: u8 = 5; -pub const CLOCK_UTC_MAYBE_SMEARED: u8 = 4; +pub const CLOCK_UTC_SMEARED: u8 = 3; pub const SMEAR_UNSPECIFIED: u8 = 0; pub const COUNTER_ARM_VCT: u8 = 0; diff --git a/vm/devices/virtio/virtio_rtc/src/tests.rs b/vm/devices/virtio/virtio_rtc/src/tests.rs index 9c71c7a5059..344fff4d41f 100644 --- a/vm/devices/virtio/virtio_rtc/src/tests.rs +++ b/vm/devices/virtio/virtio_rtc/src/tests.rs @@ -218,7 +218,7 @@ async fn rtc_reports_clock_capabilities(driver: DefaultDriver) { assert_eq!(written, size_of::() as u32); let response = spec::RespClockCap::read_from_bytes(&response).unwrap(); assert_eq!(response.head.status, spec::S_OK); - assert_eq!(response.clock_type, spec::CLOCK_UTC_MAYBE_SMEARED); + assert_eq!(response.clock_type, spec::CLOCK_UTC_SMEARED); assert_eq!(response.leap_second_smearing, spec::SMEAR_UNSPECIFIED); assert_eq!(response.flags, 0); assert_eq!(response.reserved, [0; 5]);