Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIPS strace.stp compilation errors #1

Open
rep opened this issue Jun 25, 2015 · 6 comments
Open

MIPS strace.stp compilation errors #1

rep opened this issue Jun 25, 2015 · 6 comments

Comments

@rep
Copy link

rep commented Jun 25, 2015

Hi,

I've tried your repository / branches on a mipsel qemu (debian jessie).

I'm running into some issues when translating / compiling the "strace.stp" - these are the first errors encountered:

Pass 4: compilation failed.  [man error::pass4]
/usr/local/share/systemtap/runtime/linux/../linux/regs.c:381:36: error: ‘MIPS_CPU_ISA_I’ undeclared (first use in this function)
   if (current_cpu_data.isa_level == MIPS_CPU_ISA_I) {
/tmp/stapgiChGG/stap_d36030395a17bc1456104978be25fb00_508740_src.c:42955:14: error: ‘struct context’ has no member named ‘regs’
   if (!CONTEXT->regs) {

Could you briefly let me know what the status of the MIPS tapset files is and what I can expect from your branches? I'd love to get systemcall monitoring to work on MIPS but right now I wouldn't know which remaining parts need to be implemented.

Thanks and cheers!

@cdleonard
Copy link
Owner

Hello,

It seems that MIPS_CPU_ISA_I was removed in upstream commit
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=1990e5429c2149a30a81ff634215c1aa76560a89,
after 3.10 branched. It just so happens that I only tested this with linux
2.6.32 and 3.10 because that's what's running on my target hardware. I did
not test in a debian VM.

Looking at the upstream commit message and systemtap code the stap code is
obviously wrong. Checks for isa_level should mostly be of the form
"isa_level & MIPS_CPU_ISA_XXX" to ignore unknown flags.

I think you can replace the check for MIPS_CPU_ISA_I with "if (false)". It
seems that _stp_print_regs is only used to implement the "print_regs" stap
function, it has nothing to do with implementing actual probes.

Ralf Baechle contacted me and mentioned he is working on getting a better
supported version of the mips port into systemtap upstream. I don't know if
he made anything public yet.

Regards,
Leonard

On Thu, Jun 25, 2015 at 11:44 AM, Mark Schloesser notifications@github.com
wrote:

Hi,

I've tried your repository / branches on a mipsel qemu (debian jessie).

I'm running into some issues when translating / compiling the "strace.stp"

  • these are the first errors encountered:

Pass 4: compilation failed. [man error::pass4]
/usr/local/share/systemtap/runtime/linux/../linux/regs.c:381:36: error: ‘MIPS_CPU_ISA_I’ undeclared (first use in this function)
if (current_cpu_data.isa_level == MIPS_CPU_ISA_I) {
/tmp/stapgiChGG/stap_d36030395a17bc1456104978be25fb00_508740_src.c:42955:14: error: ‘struct context’ has no member named ‘regs’
if (!CONTEXT->regs) {

Could you briefly let me know what the status of the MIPS tapset files is
and what I can expect from your branches? I'd love to get systemcall
monitoring to work on MIPS but right now I don't feel comfortable
pinpointing the remaining things that need to be implemented.

Thanks and cheers!


Reply to this email directly or view it on GitHub
#1.

Regards,
Leonard

@rep
Copy link
Author

rep commented Jun 30, 2015

Thanks for the hint, makes sense and took care of that one.

For the other issues related to CONTEXT->regs I had to make more changes:

diff -r systemtap-mips-2.7/tapset/mips/registers.stp systemtap-mips-2.7-modified/tapset/mips/registers.stp
112c112,114
<         THIS->__retvalue = _stp_probing_app_with_32bit_regs(CONTEXT->regs);
---
>       struct pt_regs *regs;
>       regs = (CONTEXT->user_mode_p ? CONTEXT->uregs : CONTEXT->kregs);
>         STAP_RETVALUE = _stp_probing_app_with_32bit_regs(regs);
117c119,122
<       if (!CONTEXT->regs) {
---
>       struct pt_regs *regs;
>       regs = (CONTEXT->user_mode_p ? CONTEXT->uregs : CONTEXT->kregs);
>
>       if (!regs) {
121c126
<       if (THIS->offset < 0 || THIS->offset > sizeof(struct pt_regs) - sizeof(long)) {
---
>       if (STAP_ARG_offset < 0 || STAP_ARG_offset > sizeof(struct pt_regs) - sizeof(long)) {
123,124c128
<                               "Bad register offset: %lld",
<                               (long long)THIS->offset);
---
>                               "Bad register offset: %lld", STAP_ARG_offset);
128,129c132,133
<       memcpy(&value, ((char *)CONTEXT->regs) + THIS->offset, sizeof(value));
<       THIS->__retvalue = value;
---
>       memcpy(&value, ((char *)regs) + STAP_ARG_offset, sizeof(value));
>       STAP_RETVALUE = value;

That's basically the reason I was asking - it doesn't seem like it's handled by fixing the one constant, there seem to be inconsistencies within the systemtap tree itself. Almost feels like the mips tapset is not the "latest" one. Are you sure you committed/pushed all local changes to the branch?

I got all these errors resolved and now running into the next errors:

/usr/local/share/systemtap/runtime/linux/arith.c: In function ‘_stp_udivmoddi4’:
/usr/local/share/systemtap/runtime/linux/arith.c:256:3: error: impossible constraint in ‘asm’
   __asm__ ("multu %2,%3"                                               \

Regarding the "better supported version" that sounds great, looking forward to it. In the meantime it would be lovely to get this one to work - even if it's only partially working :)

Cheers and thanks

@rep
Copy link
Author

rep commented Jun 30, 2015

Seems like this is related to some soft-float/hard-float issue with binutils. sigh

@rep
Copy link
Author

rep commented Jun 30, 2015

Was able to get that fixed by using a modified implementation of that umul_ppmm function (

Sadly while running now there are more issues:

Pass 5: starting run.
ERROR: Unknown register: a4

@cdleonard
Copy link
Owner

Hello,

This seems like an ABI mismatch? The MIPS o32 names registers differently
and only has a0-a3. Debian defaults to compiling for the o32 ABI but I only
used n32/n64 and 64bit kernels.

So for some reason some asm code is being compiled with the wrong ABI. Can
you please show me more of the error messages, or increase verbosity?

Regards,
Leonard

On Tue, Jun 30, 2015 at 8:16 PM, Mark Schloesser notifications@github.com
wrote:

Was able to get that fixed by using a modified implementation of that
umul_ppmm function (

Sadly while running now there are more issues:

Pass 5: starting run.
ERROR: Unknown register: a4


Reply to this email directly or view it on GitHub
#1 (comment).

Regards,
Leonard

@rep
Copy link
Author

rep commented Jul 3, 2015

Running with qemu mipsel on:

Linux debian-mipsel 3.16.0-4-4kc-malta #1 Debian 3.16.7-ckt11-1 (2015-05-24) mips GNU/Linux

Checked the more verbose stderr output for details but couldn't really find anything related to the message - it loads up the mips tapset

I guess I should just try with the mips / 5kc combination maybe? I'm not super familiar with MIPS the compatibility between the combinations here. Just FYI, trying to run malware samples, so I basically need to run all sorts of 32/64 LSB/MSB binaries :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants