Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753189AbbDFMAp (ORCPT ); Mon, 6 Apr 2015 08:00:45 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:37691 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752679AbbDFMAl (ORCPT ); Mon, 6 Apr 2015 08:00:41 -0400 MIME-Version: 1.0 In-Reply-To: <20150406070329.GA30088@gmail.com> References: <1428152303-17154-1-git-send-email-brgerst@gmail.com> <20150404141434.GC22756@gmail.com> <20150406070329.GA30088@gmail.com> Date: Mon, 6 Apr 2015 08:00:40 -0400 Message-ID: Subject: Re: [PATCH] x86/signal: Remove pax argument from restore_sigcontext From: Brian Gerst To: Ingo Molnar Cc: "H. Peter Anvin" , Andy Lutomirski , Denys Vlasenko , Linus Torvalds , Borislav Petkov , "the arch/x86 maintainers" , Linux Kernel Mailing List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1941 Lines: 48 On Mon, Apr 6, 2015 at 3:03 AM, Ingo Molnar wrote: > > * Brian Gerst wrote: > >> > I'm wondering what the original reason for adding the extra >> > handling of regs->ax was. Maybe something changed regs->ax - but I >> > cannot find such code path anymore. >> > >> > It would be nice to try to do a bit of Git archeology to figure >> > out the origins of this complication - maybe it's something subtle >> > - or it's something that has changed meanwhile. >> >> It goes all the way back to 2.1.106pre1, when restore_sigcontext() >> was changed to return an error code instead of EAX directly. >> >> https://git.kernel.org/cgit/linux/kernel/git/history/history.git/diff/arch/i386/kernel/signal.c?id=9a8f8b7ca3f319bd668298d447bdf32730e51174 > > Indeed: restore_sigcontext() used to return eax as a return value, > without copying it into regs->ax. > > Then in 2007 Version 2.1.106 was released on Jun 13, 1998. > sigaltstack syscall support was added, where the return > value of restore_sigcontext() was changed to carry the memory-copying > failure code. But instead of putting 'ax' into regs->ax, it was > carried in via a pointer and then returned, where the generic syscall > return code copied it to regs->ax. > > So there was never any deeper reason for this suboptimal pattern, it > was simply never noticed after being introduced. > > (Btw., the regs->ax we return will be copied back to regs->ax after > the syscall straight away once again - but I guess this cannot be > helped.) The 64-bit stub could skip saving it back to regs. However 32-bit does not have a special stub so sys_rt_sigreturn() still needs to return regs->ax. -- Brian Gerst -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/