From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932411AbdJ0SFV (ORCPT ); Fri, 27 Oct 2017 14:05:21 -0400 Received: from mga09.intel.com ([134.134.136.24]:8164 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932383AbdJ0SFU (ORCPT ); Fri, 27 Oct 2017 14:05:20 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,304,1505804400"; d="scan'208";a="1236253699" Subject: Re: [PATCH 02/18] x86/asm/64: Split the iret-to-user and iret-to-kernel paths To: Andy Lutomirski , X86 ML References: <8042a4bd5882599dd8e3f9b17f1f40a2fdda0450.1509006199.git.luto@kernel.org> Cc: Borislav Petkov , "linux-kernel@vger.kernel.org" , Brian Gerst , Linus Torvalds From: Dave Hansen Message-ID: <1acdc314-6568-bada-6bea-4fa6ca21fb91@intel.com> Date: Fri, 27 Oct 2017 11:05:17 -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: <8042a4bd5882599dd8e3f9b17f1f40a2fdda0450.1509006199.git.luto@kernel.org> 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 01:26 AM, Andy Lutomirski wrote: > +GLOBAL(restore_regs_and_return_to_usermode) > +#ifdef CONFIG_DEBUG_ENTRY > + testl $3, CS(%rsp) > + jnz 1f > + ud2 A nit from the mere mortals in the audience: Could we start commenting or make a constant for the user segment bits in CS? Also, it would be nice to explain what's going on here. Maybe: /* * We think we are returning to the kernel. Check the * registers we are about to restore and if we appear to * be returning to userspace, do something that will cause * a fault and hopefully an oops report. */ Otherwise, I really like this change. It's really hard to figure out what the context is in the entry assembly in a lot of cases. It's a place where code reuse actually makes things harder to follow.