From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752788AbdKXNEw (ORCPT ); Fri, 24 Nov 2017 08:04:52 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:47132 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750825AbdKXNEv (ORCPT ); Fri, 24 Nov 2017 08:04:51 -0500 Date: Fri, 24 Nov 2017 14:04:45 +0100 (CET) From: Thomas Gleixner To: Peter Zijlstra cc: Ingo Molnar , linux-kernel@vger.kernel.org, Dave Hansen , Andy Lutomirski , "H . Peter Anvin" , Borislav Petkov , Linus Torvalds Subject: Re: [PATCH 22/43] x86/mm/kaiser: Prepare assembly for entry/exit CR3 switching In-Reply-To: <20171124124521.lywhutnt6ax3t2do@hirez.programming.kicks-ass.net> Message-ID: References: <20171124091448.7649-1-mingo@kernel.org> <20171124091448.7649-23-mingo@kernel.org> <20171124120516.wacb2zdbczk4tafv@hirez.programming.kicks-ass.net> <20171124121706.ldrmycmmquenhap7@gmail.com> <20171124124521.lywhutnt6ax3t2do@hirez.programming.kicks-ass.net> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 24 Nov 2017, Peter Zijlstra wrote: > On Fri, Nov 24, 2017 at 01:17:06PM +0100, Ingo Molnar wrote: > > > > * Peter Zijlstra wrote: > > > > > On Fri, Nov 24, 2017 at 10:14:27AM +0100, Ingo Molnar wrote: > > > > @@ -1343,9 +1373,10 @@ ENTRY(error_entry) > > > > > > > > .Lerror_bad_iret: > > > > /* > > > > + * We came from an IRET to user mode, so we have user > > > > + * gsbase and CR3. Switch to kernel gsbase and CR3: > > > > */ > > > > + SWITCH_TO_KERNEL_CR3 scratch_reg=%rax > > > > SWAPGS > > > > > > > > /* > > > > > > The Changelog states SWAPGS must be done before, yet the code does > > > after. > > > > Yes, so this is the SWAPGS that is done before we go back to user-space. > > The comment there clearly states we have user gs and we need to switch > to kernel gs. The Changelog states we should switch gs before cr3. > > So either the comment or the code needs fixing. The code :)