Skip to content

Fix build on i386 due to the latest tsc changes

Avi Kivity kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: Fix 64-bit division in kvm_set_tsc_khz()arch/x86/kvm/x86.c+9 -20 replies
2/2KVM: Fix 64-bit division in kvm_write_tsc()arch/x86/kvm/x86.c+7 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Fix build on i386 due to the latest tsc changes

The code fixed by the second patch looks suspect though:

  nsdiff = data - kvm->arch.last_tsc_write;
  nsdiff = (nsdiff * 1000) / vcpu->arch.virtual_tsc_khz;

before the division, nsdiff is in tsc units. Dividing it by tsc_khz/1000 is equivalent to multiplying it by 1000000 and dividing it by tsc_hz, so the result is in units of mega-seconds. I expect we want

  nsdiff /= (u64)tsc_khz * 1000;

(which is somewhat hard on i386)

Avi Kivity (2):
KVM: Fix 64-bit division in kvm_set_tsc_khz()
KVM: Fix 64-bit division in kvm_write_tsc()

 arch/x86/kvm/x86.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.9