Page MenuHomeFreeBSD

vmm: TSC offset is broken for resume after a7db532e3a6f 'vmm: Simplify saving ...'
ClosedPublic

Authored by gusev.vitaliy_gmail.com on Feb 9 2023, 10:56 PM.
Tags
Referenced Files
F86789517: D38474.diff
Tue, Jun 25, 2:30 PM
Unknown Object (File)
Sun, Jun 23, 4:52 PM
Unknown Object (File)
Tue, Jun 18, 3:14 AM
Unknown Object (File)
Jan 22 2024, 11:39 PM
Unknown Object (File)
Dec 23 2023, 1:32 AM
Unknown Object (File)
Dec 12 2023, 6:06 PM
Unknown Object (File)
Nov 27 2023, 8:51 AM
Unknown Object (File)
Nov 25 2023, 12:17 AM

Details

Summary

After suspend/resume Ubuntu 20.04 and 22.04 installer can hang if tsc-early clocksource has a big skew. To find this issue, change tsc-early clocksource to hpet after resume and this message appears in dmesg:

[18446727039.410568] clocksource: Switched to clocksource hpet
[18446727039.570729] clocksource: timekeeping watchdog on CPU0: Marking clocksource 'tsc-early' as unstable because the skew is too large:
[18446727039.570732] clocksource:                       'hpet' wd_nsec: 124858194947 wd_now: c0ee5043 wd_last: 44129d99 mask: ffffffff
[18446727039.570733] clocksource:                       'tsc-early' cs_nsec: 0 cs_now: 3a81e22c60 cs_last: 2e09e7b0fff4 mask: ffffffffffffffff
[18446727039.570735] clocksource:                       'hpet' (not 'tsc-early') is current clocksource.
[18446727039.570844] tsc: Marking TSC unstable due to clocksource watchdog
[18446727039.572080] TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'.
[18446727039.572081] sched_clock: Marking unstable (324545876781, 150757976)<-(-17034119974990, -17528862)

Sponsored by: vStack

Test Plan

Resume with fixed module. VM Ubuntu 22.04

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/amd64/vmm/vmm.c
2865

Shouldn't we fix it in vm_restore_time?

gusev.vitaliy_gmail.com added inline comments.
sys/amd64/vmm/vmm.c
2865

No, This right place to do it.

sys/amd64/vmm/vmm.c
2865

Why?

gusev.vitaliy_gmail.com added inline comments.
sys/amd64/vmm/vmm.c
2865

Becase this is how snapshot code is used and it is impossible to do it from vm_restore_time(). During RESTORE after

SNAPSHOT_VAR_OR_LEAVE(tsc, meta, ret, done);

tsc contains value from a snapshot image and that value should be assigned to vcpu->tsc_offset. Otherwise it is lost. That caused the issue.

This revision is now accepted and ready to land.Feb 10 2023, 6:27 PM

A more concise description for the log message might be "actually restore vcpu->tsc_offset".

In D38474#875991, @jhb wrote:

A more concise description for the log message might be "actually restore vcpu->tsc_offset".

@jhb Do you want me replace all message with that line or add the line at the end ?

This revision was automatically updated to reflect the committed changes.