-
Notifications
You must be signed in to change notification settings - Fork 729
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
[41] ARM kernel support #86
Conversation
… to do The kernel knows its configuration, and will pick the correct unistd.h
This is a valid assumption for x86, but not for many other arches (per-EABI ARM, MIPS, etc).
Previously we were looking at __x86_64__ to see if we had that system call. Now I directly look at __NR_socketcall, which is more portable
This is described in syscall(2). Some syscalls take 64-bit arguments. On arches that have 64-bit registers, these arguments are shipped in a register. On 32-bit arches, however, these are split between two consecutive registers, with some alignment requirements. Some require an odd/even pair while some others require even/odd. For now I assume they all do what x86_32 does, and we can handle the rest when we port those.
…scalls There were some __x86_64__ checks whose purpose wasn't entirely clear. Mostly I THINK they were meant to separate the syscalls that existed on each architecture, but this wasn't done perfectly: there were syscalls that existed, but were masked out by the #ifdef. This patch removes the check for x86_64, and checks each syscall for existence individually. It may be a good idea to do this across the board for ALL the syscalls. The C preprocessor can't quite do that I don't think, but we can generate the header we want.
The kernel driver was making sure that mmap( "/dev/sysdig0" ) was getting userspace memory with the (vma->vm_flags & VM_EXEC) flag clear. For whatever reason this is not true on ARM: VM_EXEC is set there. I can't tell why yet, but things work fine after removing this check, and it seems benign enough.
The sysdig kernel driver is mostly useless without syscall tracepoints. On ARM these were added relatively recently: in Linux 3.7. This patch explicitly checks this support exists, and refuses to build if it isn't
Bug: #41 |
Wow, awesome! We'll review the code asap. Meanwhile, can someone try this on a real Raspberry Pi? If it works (just a basic live capture smoke test) then we'll buy one in Draios and hook it up to Jenkins so we can have apt-get builds and run against our thorough test suite. Thanks! |
I have tried this on a real raspberry and it works. It compiles and i can do, without problems, a basic live capture |
[41] ARM kernel support
It looks good, thanks a lot for this! I'll run this on our jenkins server overnight that tests a bunch of different kernels and see if something broke, but I doubt. Hopefully we'll find the time to setup a raspberry where we can run the full build & test cycle on it at every commit. |
Ah yes, that makes sense. I did make sure that x86_32 builds (which it does for me, actually), but haven't tried to run it. |
@gianlucaborello actually this issue you've found would affect x86_32 AND arm. I don't see build issues for either (building the v3.14 tag), and the arm code does generally work. But your patch is 100% right, so I'm wondering if we haven't tested the syscalls that specifically would use the split 64-bit parameters. I did test it, but this bug indicates that I clearly didn't do it right. I'll try again in a bit. In the meantime, any particular methods yall used to test that? |
@dkogan Yeah, the driver compiles (wrong word in my previous comment), but, as you guessed, some system calls won't work. pwrite(fd, "buffer", sizeof("buffer") - 1, 4);
pwrite(fd, "buffer", sizeof("buffer") - 1, 987654321987654); And then, the test framework waits until the two events come back, and checks wether the arguments captured by the driver are the same as the ones passed. I totally understand that this kind of things are a pain to find, that's why we have this nice test framework that tests every system call on a bunch of different kernels, both x86 and x86_64. Unfortunately we can't release it yet (it will definitely happen asap), but in the meantime I'll promptly report if something breaks (all these tests are run nightly against the master branch). |
Gianluca Borello notifications@github.com writes:
I checked those, but clearly didn't do it right. Sorry about that.
OK. Since you have a tests suite, I'll wait for you to report any |
@dkogan I managed to run a Raspbian under QEMU (which was a big pain in the ass) and started running our regression tests on arm as well. There are a bunch of issues but I think the majority are in the tests themselves and not a porting issues, will go through them slowly every time I have a few spare minutes. To start, I believe the order of registers in pwrite(fd, "test", sizeof("test") - 1, 4); Note that the code as it is now works fine on x86. I was very short of time so I didn't dig into this too much, but since your knowledge seems far ahead of mine, let me know what you think. Thanks! |
Gianluca Borello notifications@github.com writes:
I wrote up basic qemu instructions some days ago: http://notes.secretsauce.net/notes/2014/04/07_running-qemu-with-a-custom-kernel-on-arm.html Probably should have shared those earlier; sorry.
Right. I was going to test it to tell me if the order is backwards or
Yep. Give me a day or two. dima |
On Mon, Apr 14, 2014 at 7:00 PM, Dima Kogan notifications@github.comwrote:
|
Gianluca Borello notifications@github.com writes:
OK. I looked at it, and there's a patch in the same branch as before. My test file:
This needs to be compiled with -D_FILE_OFFSET_BITS=64 to have the 64-bit |
Wow, thanks a lot for finding this, just merged the patch, I confirm it worked. pwritev(fd, wv, wv_count, 132456789012345LL);
|
Gianluca Borello notifications@github.com writes:
Thanks much for testing. I did what I should've done before, and wrote a
This tests pread, pwrite, preadv and pwritev. I also changed the patch dima |
Oh, and strace apparently has this bug too. If I strace that test program, I see this:
The 45824... values are what you get if you DO align the arguments. Something is odd. |
Awesome, that worked, just merged. Now I see a bunch of errors with some esoteric |
Gianluca Borello notifications@github.com writes:
I figured out why the alignment wasn't required for preadv/pwritev. http://notes.secretsauce.net/notes/2014/04/16_argument-alignment-in-linux-system-calls.html |
On Wed, Apr 16, 2014 at 2:38 AM, Dima Kogan notifications@github.comwrote:
|
These patches allow sysdig to work on ARM.