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
F102713535: D38474.diff
Sat, Nov 16, 5:58 AM
Unknown Object (File)
Fri, Nov 15, 12:04 AM
Unknown Object (File)
Thu, Nov 14, 6:47 AM
Unknown Object (File)
Wed, Nov 6, 2:11 PM
Unknown Object (File)
Tue, Nov 5, 8:13 PM
Unknown Object (File)
Thu, Oct 17, 4:54 PM
Unknown Object (File)
Oct 17 2024, 12:56 AM
Unknown Object (File)
Oct 16 2024, 3:07 PM

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.