Skip to contentSkip to conversation

New: kernel 5.2.1: "floating point exception" in qemu with kvm enabled

Bug 204209 [email protected] 1 participant 5 messages Jul 17, 2019 – Jul 31, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=204209

            Bug ID: 204209
           Summary: kernel 5.2.1: "floating point exception" in qemu with
                    kvm enabled
           Product: Virtualization
           Version: unspecified
    Kernel Version: 5.2.1
          Hardware: x86-64
                OS: Linux
              Tree: Mainline
            Status: NEW
          Severity: high
          Priority: P1
         Component: kvm
          Assignee: [email protected]
          Reporter: [email protected]
        Regression: No

After updating the kernel from 5.1.17 to 5.2.1, when I use the g++ compiler in qemu with kvm enabled, often the compiler launched in the guest for compile my sources ends with this error: "exception in floating point".

Moreever it is not possible to update the bsd system because the process (that use g++ compiler) exits with the same error.

Same thing for some system utilities, like "pkg update".

But if I boot the system with the previous 5.1.17 kernel and launch qemu, as indicated above, everything works fine and I don't detect errors.

Command line is:

/usr/bin/qemu-system-x86_64 -k it -machine accel=kvm -m 4096 -no-fd-bootchk -show-cursor -drive file="vmdragon.img",if=ide,media=disk -boot once=c,menu=off -net none -rtc base=localtime -name "vmdragon" -smp 8 -vga std -device qemu-xhci,id=xhci

I can't test without kvm because the process is very slow, but I think the problem could be in some changes made to the kvm module.

Thanks,
Antonio

Signature · 2 lines
You are receiving this mail because:
You are watching the assignee of the bug.
#1 lore raw

[Bug 204209] kernel 5.2.1: "floating point exception" in qemu with kvm enabled

https://bugzilla.kernel.org/show_bug.cgi?id=204209

Thomas Lambertz ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]

--- Comment #1 from Thomas Lambertz ([email protected]) ---
I can confirm this issue. It occurs since 5.2, when the FPU state changes were introduced. I send an e-mail about this yesterday, seems I should have included the kvm mailing list:

https://lkml.org/lkml/2019/7/17/758

- Thomas

Signature · 2 lines
You are receiving this mail because:
You are watching the assignee of the bug.
#2 lore raw

[Bug 204209] kernel 5.2.1: "floating point exception" in qemu with kvm enabled

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=204209

--- Comment #2 from anthony ([email protected]) ---
I tested the patch indicated on https://lkml.org/lkml/2019/7/19/644 with simple row position adjustments for the kernel 5.2.1 and it seems to work.

arch/x86/kvm/x86.c 2019-07-19 20:17:17.956692942 +0200 renamed from arch/x86/kvm/x86.c 2019-07-19 20:17:35.358848175 +0200 +11 -3
@@ -3264,6 +3264,12 @@
 
    kvm_x86_ops->vcpu_load(vcpu, cpu);
 
+
+   // fix floating point error kvm guest
+   if (test_thread_flag(TIF_NEED_FPU_LOAD))
+       switch_fpu_return();
+
+
    /* Apply any externally detected TSC adjustments (due to suspend) */
    if (unlikely(vcpu->arch.tsc_offset_adjustment)) {
        adjust_tsc_offset_host(vcpu, vcpu->arch.tsc_offset_adjustment);
@@ -7955,9 +7961,11 @@
        wait_lapic_expire(vcpu);
    guest_enter_irqoff();
 
-   fpregs_assert_state_consistent();
-   if (test_thread_flag(TIF_NEED_FPU_LOAD))
-       switch_fpu_return();
+// fix floating point error kvm guest
+//
+//     fpregs_assert_state_consistent();
+//     if (test_thread_flag(TIF_NEED_FPU_LOAD))
+//         switch_fpu_return();
 
    if (unlikely(vcpu->arch.switch_db_regs)) {
        set_debugreg(0, 7);
Signature · 2 lines
You are receiving this mail because:
You are watching the assignee of the bug.
#3 lore raw

[Bug 204209] kernel 5.2.1: "floating point exception" in qemu with kvm enabled

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=204209

--- Comment #3 from anthony ([email protected]) --- Today I saw the following commit:

Quoted 9 lines

Revert "kvm: x86: Use task structs fpu field for user" commit ec269475cba7bcdd1eb8fdf8e87f4c6c81a376fe upstream.

This reverts commit 240c35a3783ab9b3a0afaba0dde7291295680a6b ("kvm: x86: Use task structs fpu field for user", 2018-11-06). The commit is broken and causes QEMU's FPU state to be destroyed when KVM_RUN is preempted.

Fixes 240c35a3783a ("kvm: x86: Use task structs fpu field for user")

applied to the 5.2.4 kernel and I thought it could relate to the reported bug, but recompiling the kernel without previous indicated patch, the guest report "fpu exception" error again: it was necessary to re-include the patch and recompile the kernel for it to work.

Signature · 2 lines
You are receiving this mail because:
You are watching the assignee of the bug.
#4 lore raw

[Bug 204209] kernel 5.2.1: "floating point exception" in qemu with kvm enabled

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=204209

anthony ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------

             Status|NEW                         |RESOLVED
         Resolution|---                         |CODE_FIX

--- Comment #4 from anthony ([email protected]) --- Tested with Kernel 5.2.5: problem solved.

Thanks,
Antonio

Signature · 2 lines
You are receiving this mail because:
You are watching the assignee of the bug.