tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH v2 1/2] compat32: translate userland PT_* request values into kernel



On May 30,  7:29pm, mgorny%gentoo.org@localhost (=?UTF-8?q?Micha=C5=82=20G=C3=B3rny?=) wrote:
-- Subject: [PATCH v2 1/2] compat32: translate userland PT_* request values i

| Currently, the compat32 passes PT_* request values to kernel functions
| without translation.  This works fine for low PT_* requests that happen
| to have the same values both on i386 and amd64.  However, for requests
| higher than PT_SETFPREGS, the value passed from userland (matching i386
| const) does not match the correct kernel (amd64) request.  As a result,
| e.g. when compat32 process calls PT_GETDBREGS, kernel actually processes
| it as PT_SETSTEP.
| 
| To resolve this, introduce support for compat32 PT_* request
| translation.  The interface is based on PTRACE_TRANSLATE_REQUEST32 macro
| that is defined to a mapping function on architectures needing it.
| In case of amd64, this function maps userland i386 PT_* values into
| appropriate amd64 PT_* values.
| 
| For the time being, the two additional PT_GETXMMREGS and PT_SETXMMREGS
| requests are unsupported due to lack of matching free amd64 constant.
| ---
|  sys/arch/amd64/amd64/netbsd32_machdep.c   | 37 +++++++++++++++++++++++
|  sys/arch/amd64/include/netbsd32_machdep.h |  3 ++
|  sys/arch/amd64/include/ptrace.h           |  2 ++
|  sys/compat/netbsd32/netbsd32_ptrace.c     | 12 +++++++-
|  4 files changed, 53 insertions(+), 1 deletion(-)
| 
| Changed in v2:
| - PTRACE_TRANSLATE_REQUEST32(x) fallback definition has been moved
|   from ptrace.h to netbsd32_ptrace.c

I am fine with both the patches since this is the best we can do with
the current state of the machine dependent ptrace calls. Having said
that, even if we get ptrace() to work perfectly for netbsd32, there
is a lot of work that needs to be done to make debugging work for
those binaries (even using a compat32 built debugger), because of the
magic that happens with the shared linker paths and libraries. Perhaps
we need to re-think that to make things work more naturally for all
the binaries instead of intercepting things in the debugger/dynamic
linker and doing path mangling. This (having machine-specific paths)
would help also with cross-compiling pkgsrc...

christos


Home | Main Index | Thread Index | Old Index