Re: PANIC: double fault, error_code: 0x0 in 4.0.0-rc3-2, kvm related?

From: Stefan Seyfried
Date: Mon Mar 23 2015 - 14:54:48 EST

Am 23.03.2015 um 19:38 schrieb Andy Lutomirski:
> I bet I see it. I have the advantage of having stared at KVM code and
> cursed at it more recently than you, I suspect. KVM does awful, awful
> things to CPU state, and, as an optimization, it allows kernel code to
> run with CPU state that would be totally invalid in user mode. This
> happens through a bunch of hooks, including this bit in __switch_to:
> /*
> * Now maybe reload the debug registers and handle I/O bitmaps
> */
> if (unlikely(task_thread_info(next_p)->flags & _TIF_WORK_CTXSW_NEXT ||
> task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV))
> __switch_to_xtra(prev_p, next_p, tss);
> IOW, we *change* tif during context switches.
> The race looks like this:
> jnz int_ret_from_sys_call_fixup /* Go the the slow path */
> --- preempted here, switch to KVM guest ---
> KVM guest enters and screws up, say, MSR_SYSCALL_MASK. This wouldn't
> happen to be a *32-bit* KVM guest, perhaps?

not in my case (penryn CPU), there it was 64bit guests.

> Now KVM schedules, calling __switch_to. __switch_to sets
> _TIF_USER_RETURN_NOTIFY. We IRET back to the syscall exit code, turn
> off interrupts, and do sysret. We are now screwed.
> I don't know why this manifests in this particular failure, but any
> number of terrible things could happen now.
> FWIW, this will affect things other than KVM. For example, SIGKILL
> sent while a process is sleeping in that two-instruction window won't
> work.
> Takashi, can you re-send your patch so we can review it for real in
> light of this race?
Stefan Seyfried
Linux Consultant & Developer -- GPG Key: 0x731B665B

B1 Systems GmbH
OsterfeldstraÃe 7 / 85088 Vohburg /
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at