Re: [PATCH 22/43] x86/mm/kaiser: Prepare assembly for entry/exit CR3 switching

From: Thomas Gleixner
Date: Fri Nov 24 2017 - 19:03:02 EST


On Fri, 24 Nov 2017, Ingo Molnar wrote:
> @@ -1288,6 +1308,8 @@ ENTRY(error_entry)
> * from user mode due to an IRET fault.
> */
> SWAPGS
> + /* We have user CR3. Change to kernel CR3. */
> + SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
>
> .Lerror_entry_from_usermode_after_swapgs:
> /* Put us onto the real thread stack. */
> @@ -1333,6 +1355,7 @@ ENTRY(error_entry)
> * gsbase and proceed. We'll fix up the exception and land in
> * .Lgs_change's error handler with kernel gsbase.
> */
> + SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
> SWAPGS

This is wrong. SWAPGS needs to come first.

Thanks,

tglx