lkml.org 
[lkml]   [2009]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] score: add regsets support for score
Date
> The code you add looks ok to me, but it appears you forgot to hook
> it up to the ptrace logic. Some architectures use it only for
> PTRACE_{GET,SET}REGS, others also use it in PTRACE_{PEEK,POKE}USR,
> I'm not sure what the right approach is for new architectures.
> Should a new architecture actually implement both of those
> interfaces?

I would not recommend adding PTRACE_{PEEK,POKE}USR to an ABI that
doesn't have it already. It only exists on other arch's for past
compatibility; it's the poorest interface for this.

If you are starting from scratch, then you should define your arch's
user_regset layouts so that everything is nicely represented in one
regset or another. Then for ptrace, define a PTRACE_{GET,SET}REGS
that exactly matches your regset 0, plus a *FPREGS for your FP regset
or one each such pair of ptrace requests for each extra user_regset
you have (if any). arch_ptrace in arch/x86/kernel/ptrace.c shows an
example where *REGS are implemented in this trivial way.

> > + ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
> > + regs->regs,
> > + offsetof(struct pt_regs, regs),
> > + end_pos);

This looks odd to me. The last two arguments here are offsets into
the userland ABI format defined by the user_regset layout. Unless
offsetof(struct pt_regs, regs) is zero, then you need to precede
this call with one that fills in the initial stretch of the userland
format layout from its 0 up to offsetof(struct pt_regs, regs). If
in fact offsetof(struct pt_regs, regs) is zero, then it would be far
less confusing to just write 0 there IMHO. Using offsetof on
pt_regs at all here is very confusing to me unless pt_regs describes
the userland ABI layout (in which case the use here still doesn't
make sense).

If what's instead the case is that the userland ABI format matches
just the pt_regs.regs field and nothing more, then what you want is:

ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
regs->regs, 0, sizeof(regs->regs));

I gather that you then have some reserved zero-fill words at the end
of the userland format (preparation for future use I presume). So it's:

ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
regs->regs, 0, sizeof(regs->regs));
if (!ret)
ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
sizeof(regs->regs), -1);

Et voila.

But I may be misunderstanding what the intended userland ABI format is
here. I'd advise you to make sure that everything that can affect
user-mode instructions (condition codes, etc.) is exposed via some
user_regset layouts, or else you'll eventually have userland debugger
folks coming back to have you cram them in somehow later (and it won't
wind up as pretty).


Thanks,
Roland


\
 
 \ /
  Last update: 2009-07-09 23:07    [W:0.063 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site