[PATCH] x86/entry/64: Fix native_load_gs_index() SWAPGS handling with IRQ state tracing enabled

From: Ingo Molnar
Date: Wed Nov 29 2017 - 02:10:19 EST



* Jarkko Nikula <jarkko.nikula@xxxxxxxxxxxxxxx> wrote:

> Hi
>
> Suspend-to-ram and resume stopped working on v4.15-rc1 and I bisected it to
> commit ca37e57bbe0c ("x86/entry/64: Add missing irqflags tracing to
> native_load_gs_index()").
>
> I noticed it on Intel Kabylake (core) and Apollolake (atom) based prototype
> machines. Symptoms are that machine appears to enter into suspend but
> resumes instantly and hangs. Unfortunately no logs.
>
> If I revert ca37e57bbe0c on v4.15-rc1 it works as expected.

Hm, that commit looks broken with irq-tracing enabled.
Does the patch below fix it?

In fact the exception handler itself appears to have broken GS handling as well -
I suspect it never triggers in practice, because it was broken forever.

Andy, do you concur?

On a related note, we should definitely extend the 'intended GS state' annotation
comments I did in this patch to all SWAPGS instances - this way code review has a
much higher chance of finding discrepancies between intent and actual code.

Thanks,

Ingo

=================>