From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754597AbbFRKLX (ORCPT ); Thu, 18 Jun 2015 06:11:23 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:33386 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753178AbbFRKLP (ORCPT ); Thu, 18 Jun 2015 06:11:15 -0400 Date: Thu, 18 Jun 2015 12:11:10 +0200 From: Ingo Molnar To: Andy Lutomirski Cc: Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , =?iso-8859-1?Q?Fr=E9d=E9ric?= Weisbecker , Rik van Riel , Oleg Nesterov , Denys Vlasenko , Borislav Petkov , Kees Cook , Brian Gerst Subject: Re: [RFC/INCOMPLETE 00/13] x86: Rewrite exit-to-userspace code Message-ID: <20150618101110.GA5100@gmail.com> References: <20150617103226.GA30325@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * 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.) The most deadly complexity in our asm code are IMHO the intertwined threads of control flow - all of that should go into C, where it's much easier to see what's going on, because we have named variables, established code patterns and a compiler checking for common mistakes and such. The other big area of complexity are our partial save/restore tricks, which makes tracking of what is saved (and what is not) tricky and fragile. Thanks, Ingo