justincormack / ljsyscall

LuaJIT Unix syscall FFI
http://www.myriabit.com/ljsyscall/
Other
440 stars 53 forks source link

Port to PPC64 #183

Closed gut closed 9 years ago

gut commented 9 years ago

Hello Justin,

Just like discussed on luajit's mailing list, here is the port I manage to do on ljsyscall to ppc64le.

As the official LuaJIT didn't merge our patches to ppc64, please use this fork: https://github.com/PPC64/LuaJIT-PPC64/

If you want to test on a virtualized POWER8 machine, you can subscribe to this program: http://openpower.ic.unicamp.br/minicloud/

Thanks

justincormack commented 9 years ago

Hi, I am getting a lot of errors on the test suite, eg:

luajit test/test.lua
test_processes
  [test_processes:test_execve]  Ok
  [test_processes:test_fork_wait]   [test_processes:test_fork_wait]     Ok
  [test_processes:test_fork_wait3]   [test_processes:test_fork_wait3]   Ok
  [test_processes:test_fork_wait4]   [test_processes:test_fork_wait4]   Ok
  [test_processes:test_fork_waitid]   [test_processes:test_fork_waitid]     Ok
  [test_processes:test_fork_waitpid]   [test_processes:test_fork_waitpid]   Ok
  [test_processes:test_nice]    Ok
  [test_processes:test_setpgid]     Ok
  [test_processes:test_setsid]   [test_processes:test_setsid]   Ok
test_signals_linux
  [test_processes:test_setsid]   [test_signals_linux:test_itimer]   Failed
Alarm clock

luajit test/test.lua test_file_operations
test_file_operations
  [test_file_operations:test_chdir]     Ok
  [test_file_operations:test_chmod]     Ok
  [test_file_operations:test_chown]     Ok
  [test_file_operations:test_dup]   Ok
  [test_file_operations:test_dup2]  Ok
  [test_file_operations:test_dup3]  Ok
Segmentation fault (core dumped)

At a guess some of the structs are not laid out correctly for ppc64. Unfortunately the automated tests for these all require a working ffi-reflect - will take a look and see if I can see what is going on.

(testing on Ubuntu 15.04 ppc64le POWER8).

gut commented 9 years ago

I'm investigating that. I'll reply soon with the fixes.

justincormack commented 9 years ago

Cool. This test suite was quite good for finding bugs when LuaJIT was younger, so its probably good for testing your port.

justincormack commented 9 years ago

It may be improved now, will test later, I am fixing arm64 issues, which does not support many legacy syscalls, this may help ppc64 too.

gut commented 9 years ago

I found already some issues on my port to ppc64 of ljsyscall and also from our LuaJIT. I'm fixing them all before resend it to you. Thanks for the hint that the master branch is updated. Please wait for my response

gut commented 9 years ago

Updating the kernel also helped :-). I'll post results marking down which one I tested

gut commented 9 years ago

Improvements done, but I still have one bug left:

=========================================================`
Failed tests:
-------------
>>> test_netlink:test_interface_set_macaddr_fail failed
./syscall/helpers.lua:22: should not be able to change macaddr on lo
stack traceback:
        ./include/luaunit/luaunit.lua:479: in function <./include/luaunit/luaunit.lua:478>
        [C]: in function 'error'
        ./syscall/helpers.lua:22: in function 'assert'
        ./test/linux.lua:573: in function 'test_interface_set_macaddr_fail'
        [string "test_netlink:test_interface_set_macaddr_fail()"]:1: in main chunk
        [C]: in function 'xpcall'
        ./include/luaunit/luaunit.lua:482: in function 'runTestMethod'
        ./include/luaunit/luaunit.lua:507: in function 'runTestMethodName'
        ./include/luaunit/luaunit.lua:536: in function 'runTestClassByName'
        ./include/luaunit/luaunit.lua:570: in function <./include/luaunit/luaunit.lua:542>
        test/test.lua:2505: in main chunk
        [C]: at 0x100061e4
Success : 99% - 321 / 322 (total of 325 tests, 3 skipped)

I'm unsure if the issue really relies on the kernel or on our LuaJIT port. I'd say that the buffer that nl.read returns misses a return code because inside of the buf contents of nlmsg_data_decode[C.NLMSG.ERROR] called function. It misses the first 4 negative bytes that I see on x86_64.

These tests ran on the latest Debian 8.1 jessie with the kernel release 3.16.0-4-powerpc64le.

Please remember to also update your LuaJIT as a bug was found during ljsyscall porting and it is already fixed on our LuaJIT repository: https://github.com/PPC64/LuaJIT-PPC64/

Please comment if any input from my side is needed.

justincormack commented 9 years ago

I think there may well be an issue on that netlink test - I also got the same error when testing it on Solaris Linux emulation yesterday.

gut commented 9 years ago

No problem. Tested on x64 and ppc64le. If LuaJIT on x64 is compiled with make XCFLAGS=-DLUAJIT_ENABLE_GC64 it sends signal SIGSEGV as expected.

justincormack commented 9 years ago

Cool, thanks very much!

I will look at the remaining issues and do a release soon.