Fix KVM divide by zero error (rhbz 969644)
This commit is contained in:
parent
972606b895
commit
1e99e37726
45
KVM-x86-handle-idiv-overflow-at-kvm_write_tsc.patch
Normal file
45
KVM-x86-handle-idiv-overflow-at-kvm_write_tsc.patch
Normal file
@ -0,0 +1,45 @@
|
||||
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
|
||||
index 094b5d9..64a4b03 100644
|
||||
--- a/arch/x86/kvm/x86.c
|
||||
+++ b/arch/x86/kvm/x86.c
|
||||
@@ -1194,20 +1194,37 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr)
|
||||
elapsed = ns - kvm->arch.last_tsc_nsec;
|
||||
|
||||
if (vcpu->arch.virtual_tsc_khz) {
|
||||
+ int faulted = 0;
|
||||
+
|
||||
/* n.b - signed multiplication and division required */
|
||||
usdiff = data - kvm->arch.last_tsc_write;
|
||||
#ifdef CONFIG_X86_64
|
||||
usdiff = (usdiff * 1000) / vcpu->arch.virtual_tsc_khz;
|
||||
#else
|
||||
/* do_div() only does unsigned */
|
||||
- asm("idivl %2; xor %%edx, %%edx"
|
||||
- : "=A"(usdiff)
|
||||
- : "A"(usdiff * 1000), "rm"(vcpu->arch.virtual_tsc_khz));
|
||||
+ asm("1: idivl %[divisor]\n"
|
||||
+ "2: xor %%edx, %%edx\n"
|
||||
+ " movl $0, %[faulted]\n"
|
||||
+ "3:\n"
|
||||
+ ".section .fixup,\"ax\"\n"
|
||||
+ "4: movl $1, %[faulted]\n"
|
||||
+ " jmp 3b\n"
|
||||
+ ".previous\n"
|
||||
+
|
||||
+ _ASM_EXTABLE(1b, 4b)
|
||||
+
|
||||
+ : "=A"(usdiff), [faulted] "=r" (faulted)
|
||||
+ : "A"(usdiff * 1000), [divisor] "rm"(vcpu->arch.virtual_tsc_khz));
|
||||
+
|
||||
#endif
|
||||
do_div(elapsed, 1000);
|
||||
usdiff -= elapsed;
|
||||
if (usdiff < 0)
|
||||
usdiff = -usdiff;
|
||||
+
|
||||
+ /* idivl overflow => difference is larger than USEC_PER_SEC */
|
||||
+ if (faulted)
|
||||
+ usdiff = USEC_PER_SEC;
|
||||
} else
|
||||
usdiff = USEC_PER_SEC; /* disable TSC match window below */
|
||||
|
@ -770,6 +770,9 @@ Patch25042: x86-range-make-add_range-use-blank-slot.patch
|
||||
#rhbz 950735
|
||||
Patch25045: rt2800-fix-RT5390-RT3290-TX-power-settings-regression.patch
|
||||
|
||||
#rhbz 969644
|
||||
Patch25046: KVM-x86-handle-idiv-overflow-at-kvm_write_tsc.patch
|
||||
|
||||
# END OF PATCH DEFINITIONS
|
||||
|
||||
%endif
|
||||
@ -1484,6 +1487,9 @@ ApplyPatch x86-range-make-add_range-use-blank-slot.patch
|
||||
#rhbz 950735
|
||||
ApplyPatch rt2800-fix-RT5390-RT3290-TX-power-settings-regression.patch
|
||||
|
||||
#rhbz 969644
|
||||
ApplyPatch KVM-x86-handle-idiv-overflow-at-kvm_write_tsc.patch
|
||||
|
||||
# END OF PATCH APPLICATIONS
|
||||
|
||||
%endif
|
||||
@ -2290,6 +2296,7 @@ fi
|
||||
# || ||
|
||||
%changelog
|
||||
* Wed Jun 12 2013 Josh Boyer <jwboyer@redhat.com>
|
||||
- Fix KVM divide by zero error (rhbz 969644)
|
||||
- Add fix for rt5390/rt3290 regression (rhbz 950735)
|
||||
|
||||
* Tue Jun 11 2013 Dave Jones <davej@redhat.com>
|
||||
|
Loading…
Reference in New Issue
Block a user