From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757419AbZBKPCE (ORCPT ); Wed, 11 Feb 2009 10:02:04 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755789AbZBKPBx (ORCPT ); Wed, 11 Feb 2009 10:01:53 -0500 Received: from mx2.mail.elte.hu ([157.181.151.9]:37073 "EHLO mx2.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755613AbZBKPBw (ORCPT ); Wed, 11 Feb 2009 10:01:52 -0500 Date: Wed, 11 Feb 2009 16:01:44 +0100 From: Ingo Molnar To: Brian Gerst Cc: Tejun Heo , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] x86: Pass in pt_regs pointer for syscalls that need it Message-ID: <20090211150144.GD10525@elte.hu> References: <1234277507-4987-1-git-send-email-brgerst@gmail.com> <1234277507-4987-3-git-send-email-brgerst@gmail.com> <4992812B.1050800@kernel.org> <73c1f2160902110631j68e58202h3e49288cfe613d66@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <73c1f2160902110631j68e58202h3e49288cfe613d66@mail.gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-ELTE-VirusStatus: clean X-ELTE-SpamScore: -1.5 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-1.5 required=5.9 tests=BAYES_00 autolearn=no SpamAssassin version=3.2.3 -1.5 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Brian Gerst wrote: > On Wed, Feb 11, 2009 at 2:41 AM, Tejun Heo wrote: > > Hello, Brian. > > > > Brian Gerst wrote: > >> Some syscalls need to access the pt_regs structure, either to copy > >> user register state or to modifiy it. This patch adds stubs to load > >> the address of the pt_regs struct into the %eax register, and changes > >> the syscalls to regparm(1) to receive the pt_regs pointer as the > >> first argument. > > > > Heh... neat. Just one question. > > > >> -asmlinkage long sys_iopl(unsigned long regsp) > >> +ptregscall long sys_iopl(struct pt_regs *regs, unsigned int level) > >> { > >> - struct pt_regs *regs = (struct pt_regs *)®sp; > >> - unsigned int level = regs->bx; > > > > Here and at other places where the function takes more than one > > arguments, wouldn't it be better to just take *regs and use other > > parameters from regs? That way we won't have to worry about gcc > > corrupting register frame at all and I think it's cleaner that way. > > Expanding the parameters is good documentation. [...] Well, that way we shuffle the parameter expansion into assembly code, instead of creating it as a local variable in the C function. The latter sure looks better documented, and less error-prone as well, right? The compiler might also be able to optimize it some. (and we save one instruction in any case) Ingo