lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 06 Jul 2009 15:28:02 -0400
From:	Masami Hiramatsu <mhiramat@...hat.com>
To:	Andi Kleen <andi@...stfloor.org>
CC:	Ingo Molnar <mingo@...e.hu>, Steven Rostedt <rostedt@...dmis.org>,
	lkml <linux-kernel@...r.kernel.org>,
	systemtap <systemtap@...rces.redhat.com>,
	kvm <kvm@...r.kernel.org>,
	DLE <dle-develop@...ts.sourceforge.net>,
	Christoph Hellwig <hch@...radead.org>,
	Ananth N Mavinakayanahalli <ananth@...ibm.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Roland McGrath <roland@...hat.com>,
	Srikar Dronamraju <srikar@...ux.vnet.ibm.com>,
	linux-arch@...r.kernel.org
Subject: Re: [PATCH -tip -v10 5/7] x86: add pt_regs register and stack access
 APIs

Andi Kleen wrote:
> Masami Hiramatsu <mhiramat@...hat.com> writes:
> 
>> Add following APIs for accessing registers and stack entries from pt_regs.
> 
> You forgot to state who calls these functions/why are they added?
> Who only has strings for registers?

Oh, yes. This patch is needed for kprobes based event tracer on ftrace.
Some other debugging tools might be able to use it.

> I can see the point of having a function for nth argument though,
> that's useful.
> 
>> +static inline unsigned long regs_get_argument_nth(struct pt_regs *regs,
>> +						  unsigned n)
>> +{
>> +	if (n < NR_REGPARMS) {
>> +		switch (n) {
>> +		case 0:
>> +			return regs->ax;
>> +		case 1:
>> +			return regs->dx;
>> +		case 2:
>> +			return regs->cx;
> 
> 
> [....]
> 
> That could be done shorter with a offsetof table.
> 
>> +	if (n < NR_REGPARMS) {
>> +		switch (n) {
>> +		case 0:
>> +			return regs->di;
>> +		case 1:
>> +			return regs->si;
>> +		case 2:
>> +			return regs->dx;
>> +		case 3:
>> +			return regs->cx;
>> +		case 4:
>> +			return regs->r8;
>> +		case 5:
>> +			return regs->r9;
> 
> and that too.

I'm not so sure about your idea.
Would you mean below code?

int offs_table[NR_REGPARMS] = {
	[0] = offsetof(struct pt_regs, di),
	...
};
if (n < NR_REGPARMS)
	return *((unsigned long *)regs + offs_table[n]);


Thank you,

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@...hat.com

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ