From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932126AbbFQLPF (ORCPT ); Wed, 17 Jun 2015 07:15:05 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:34119 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752887AbbFQLO4 (ORCPT ); Wed, 17 Jun 2015 07:14:56 -0400 Date: Wed, 17 Jun 2015 13:14:51 +0200 From: Ingo Molnar To: Andy Lutomirski Cc: x86@kernel.org, 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: <20150617111451.GA9335@gmail.com> References: <20150617103226.GA30325@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150617103226.GA30325@gmail.com> 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 * Ingo Molnar wrote: > Basically there would be a single C function we'd call, which returns a > condition (or fixes up its return address on the stack directly) to determine > between the SYSRET and IRET return paths. This we could do by returning the syscall result in RAX, and the SYSRET/IRET choice in RDX - that's the natural return parameter for 128-bit return values in the 64-bit C function ABI, and it's clobbered so it's available 'for free'. We could do something similar for the IRQ entry/return code as well: there's no reason why IRQ flag tracking has to be maintained in assembly. We could move all but the IRQ stack switching code to C. We can safely flip around the IRQ stack setting with the enter_from_user_mode call, so that IRQ stack switching becomes part of the register saving and kernel mode preparatory preamble. This would allow further optimizations in the IRQ code as well: for example we could inline enter_from_user_mode() and prepare_exit_to_usermode(). Thanks, Ingo