clock: overriding the clocksource should select the requested clocksource
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Xenial |
Fix Released
|
Medium
|
Matthew Ruffell |
Bug Description
BugLink: https:/
[Impact]
The default clocksource for a KVM VM is kvm-clock, and I happen to need tsc.
$ cat /sys/devices/
kvm-clock
If I edit /etc/default/grub and append "clocksource=tsc" to GRUB_CMDLINE_
$ cat /sys/devices/
kvm-clock
I can work around this by telling the kernel that the tsc clocksource is reliable, before the watchdog has a chance to see for itself that it is reliable:
GRUB_CMDLINE_
$ cat /sys/devices/
tsc
If I override the clocksource, the kernel should respect my wishes and I should receive the requested clocksource.
[Fix]
The fix landed in Linux 4.9 in the below commit:
commit 36374583f9084cd
Author: Kyle Walker <email address hidden>
Date: Sat Aug 6 12:07:30 2016 -0400
Subject: clocksource: Defer override invalidation unless clock is unstable
Link: https:/
The commit ensures the override doesn't get cleared before the watchdog has had an opportunity to check if the clocksource is stable or not. However, if the clocksource is known to be unstable at this point in time, it will clear the override and return to the default.
This is a clean cherry-pick to the Xenial 4.4 kernel.
[Testcase]
Start up a KVM VM, possibly enable invtsc on the QEMU command line.
The default clocksource will be kvm-clock:
$ cat /sys/devices/
kvm-clock
If you set the kernel command line to:
GRUB_CMDLINE_
If you reboot, you will see the incorrect option of kvm-clock:
$ cat /sys/devices/
kvm-clock
There is a test kernel available in the below ppa, with the commit applied:
https:/
If you install the test kernel, and leave the kernel command line as:
GRUB_CMDLINE_
You will get the requested clocksource:
$ cat /sys/devices/
tsc
You will also get the following in dmesg:
$ dmesg | grep defer
[ 1.002599] clocksource: Override clocksource tsc is not currently HRT compatible - deferring
[Regression Potential]
This commit changes how the kernel treats clocksource overrides. If any users have an override set, but the kernel is clearing the override and returning to the default, when they install a patched kernel, they will change over to their requested override, which may come as a surprise.
If there is a regression, it will only affect systems who have clocksource overrides in place, and in the worst case, will revert the system to its default clocksource if the selected clocksource override is found to be unstable.
The commit is well tested, and should not cause any regressions.
CVE References
Changed in linux (Ubuntu Xenial): | |
status: | New → In Progress |
importance: | Undecided → Medium |
assignee: | nobody → Matthew Ruffell (mruffell) |
description: | updated |
tags: | added: sts |
Changed in linux (Ubuntu): | |
status: | New → Fix Released |
description: | updated |
Changed in linux (Ubuntu Xenial): | |
status: | In Progress → Fix Committed |
This bug is awaiting verification that the kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification- needed- xenial' to 'verification- done-xenial' . If the problem still exists, change the tag 'verification- needed- xenial' to 'verification- failed- xenial' .
If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.
See https:/ /wiki.ubuntu. com/Testing/ EnableProposed for documentation how to enable and use -proposed. Thank you!