[PATCH 0/2] time: fix time accounting for x86 HVM guests

Roger Pau Monne posted 2 patches 2 weeks, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20260414103327.7420-1-roger.pau@citrix.com
xen/arch/arm/time.c   |  4 ++--
xen/arch/riscv/time.c |  2 +-
xen/arch/x86/time.c   | 20 ++++++++++++++------
3 files changed, 17 insertions(+), 9 deletions(-)
[PATCH 0/2] time: fix time accounting for x86 HVM guests
Posted by Roger Pau Monne 2 weeks, 3 days ago
Hello,

When not emulating the TSC the guest time value calculated by using the
vCPU time info page in HVM mode would drift between time synchronization
intervals.  First patch fixes the drift, second patch makes the
calculation of cpu_khz round up the value for better accuracy.

Thanks, Roger.

Roger Pau Monne (2):
  x86/time: use native TSC scaling factors when TSC is not scaled
  xen/cpu: round up cpu_khz calculations

 xen/arch/arm/time.c   |  4 ++--
 xen/arch/riscv/time.c |  2 +-
 xen/arch/x86/time.c   | 20 ++++++++++++++------
 3 files changed, 17 insertions(+), 9 deletions(-)

-- 
2.53.0
Re: [PATCH 0/2] time: fix time accounting for x86 HVM guests
Posted by Marek Marczykowski-Górecki 2 weeks, 2 days ago
On Tue, Apr 14, 2026 at 12:33:25PM +0200, Roger Pau Monne wrote:
> Hello,
> 
> When not emulating the TSC the guest time value calculated by using the
> vCPU time info page in HVM mode would drift between time synchronization
> intervals.  First patch fixes the drift, second patch makes the
> calculation of cpu_khz round up the value for better accuracy.

I confirm with with those patches, and without the other fix ("x86/time:
do not kill calibration timer on suspend") the post-S3 issue is also
gone!

Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
Re: [PATCH 0/2] time: fix time accounting for x86 HVM guests
Posted by Stefano Stabellini 2 weeks, 3 days ago
On Tue, 14 Apr 2026, Roger Pau Monne wrote:
> Hello,
> 
> When not emulating the TSC the guest time value calculated by using the
> vCPU time info page in HVM mode would drift between time synchronization
> intervals.  First patch fixes the drift, second patch makes the
> calculation of cpu_khz round up the value for better accuracy.
> 
> Thanks, Roger.
> 
> Roger Pau Monne (2):
>   x86/time: use native TSC scaling factors when TSC is not scaled
>   xen/cpu: round up cpu_khz calculations

Thanks Roger, this fixed an outstanding bug I was seeing!

Tested-by: Stefano Stabellini <sstabellini@kernel.org>