From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932275AbdJZOOF (ORCPT ); Thu, 26 Oct 2017 10:14:05 -0400 Received: from mga14.intel.com ([192.55.52.115]:44522 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932291AbdJZOOC (ORCPT ); Thu, 26 Oct 2017 10:14:02 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,434,1503385200"; d="scan'208";a="914037294" Subject: Re: [PATCH 03/18] x86/asm/64: Move SWAPGS into the common iret-to-usermode path To: Brian Gerst , Andy Lutomirski References: Cc: X86 ML , Borislav Petkov , "linux-kernel@vger.kernel.org" , Linus Torvalds From: Dave Hansen Message-ID: Date: Thu, 26 Oct 2017 07:13:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/26/2017 06:52 AM, Brian Gerst wrote: > On Thu, Oct 26, 2017 at 4:26 AM, Andy Lutomirski wrote: >> All of the code paths that ended up doing IRET to usermode did >> SWAPGS immediately beforehand. Move the SWAPGS into the common >> code. >> >> Signed-off-by: Andy Lutomirski > >> +GLOBAL(swapgs_restore_regs_and_return_to_usermode) > > Is adding swapgs to the label really necessary? It's redundant with > the usermode part. I'm noticing a trend towards absurdly verbose > labels lately. I kinda appreciate the verbosity. When I see a jump to such a label, I know explicitly what the jumper has to do. While it's possible that every "return to usermode" spot in the kernel does a swapgs, it's not patently obvious to me that every last one does that in every last situation. There are also places where we do register restoring after swapgs and then return to userspace. It's nice to know what mode we are in and what we are supposed to to just from the label.