From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932835AbdKALe2 (ORCPT ); Wed, 1 Nov 2017 07:34:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:38572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932501AbdKALe1 (ORCPT ); Wed, 1 Nov 2017 07:34:27 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D91C21921 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=luto@kernel.org X-Google-Smtp-Source: ABhQp+S+1nP9SiYWyP41CVYYeJ1ZW273rkG8egYi7a/C9kq+CnPFCR7DcSlx9279kv4ZOzUlyIWbK2XUUD0TQpeCzSE= MIME-Version: 1.0 In-Reply-To: <1acdc314-6568-bada-6bea-4fa6ca21fb91@intel.com> References: <8042a4bd5882599dd8e3f9b17f1f40a2fdda0450.1509006199.git.luto@kernel.org> <1acdc314-6568-bada-6bea-4fa6ca21fb91@intel.com> From: Andy Lutomirski Date: Wed, 1 Nov 2017 04:34:05 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 02/18] x86/asm/64: Split the iret-to-user and iret-to-kernel paths To: Dave Hansen Cc: Andy Lutomirski , X86 ML , Borislav Petkov , "linux-kernel@vger.kernel.org" , Brian Gerst , Linus Torvalds Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 27, 2017 at 11:05 AM, Dave Hansen wrote: > 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? Yeah. We have such a define, but it's not currently usable from asm. Also, we can't do the obvious: testl $SEGMENT_RPL_MASK, ... jump_if_not_equal_to_KERNEL_RPL because that makes no sense in asm :( > > 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.