From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932631AbbFRLGt (ORCPT ); Thu, 18 Jun 2015 07:06:49 -0400 Received: from mail-lb0-f182.google.com ([209.85.217.182]:36521 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755056AbbFRLGp (ORCPT ); Thu, 18 Jun 2015 07:06:45 -0400 MIME-Version: 1.0 In-Reply-To: <20150618101110.GA5100@gmail.com> References: <20150617103226.GA30325@gmail.com> <20150618101110.GA5100@gmail.com> From: Andy Lutomirski Date: Thu, 18 Jun 2015 04:06:22 -0700 Message-ID: Subject: Re: [RFC/INCOMPLETE 00/13] x86: Rewrite exit-to-userspace code To: Ingo Molnar Cc: Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , =?UTF-8?B?RnLDqWTDqXJpYyBXZWlzYmVja2Vy?= , Rik van Riel , Oleg Nesterov , Denys Vlasenko , Borislav Petkov , Kees Cook , Brian Gerst 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 Thu, Jun 18, 2015 at 3:11 AM, Ingo Molnar wrote: > > * Andy Lutomirski wrote: > >> > The only low level bits remaining in assembly will be low level hardware ABI >> > details: saving registers and restoring registers to the expected format - no >> > 'active' code whatsoever. >> >> I think this is true for syscalls. Getting the weird special cases (IRET and GS >> fault) for error_entry to work correctly in C could be tricky. > > Correct, and I double checked the IRET fault path yesterday (fixup_bad_iret), and > it looks like a straightforward exception handler with limited control flow. It > can stay in asm just fine, it seems mostly orthogonal to the rest. > > I didn't check the GS fault path, but that only affects 32-bit, as we use SWAPGS > on 64-bit, right? In any case, that code too (32-bit RESTORE_REGS) belongs into > the natural 'hardware ABI preparation code' that should stay in assembly. (Unless > I missed some other code that might cause trouble.) Look for "gs_change". To change the gs selector, we do swapgs, then load gs, then swapgs again. If the gs load fails, then we trigger a special fixup. --Andy