|
|
Created:
8 years, 3 months ago by petarj Modified:
8 years, 3 months ago CC:
chromium-reviews, Markus (顧孟勤) Visibility:
Public. |
Description[MIPS] Ignoring 4th parameter in a3 for pread64 system calls on MIPS.
Similar to ARM, MIPS also requires 64-bit parameters to be passed in even-odd
register pairs. For pread64, MIPS ignores 4th argument and looks on stack for
it. Issue discovered in NaCl development for MIPS.
Committed on behalf of petarj@mips.com.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2275
TEST= used by nacl_helper_bootstrap
Committed: https://code.google.com/p/linux-syscall-support/source/detail?r=13
Patch Set 1 #
Messages
Total messages: 14 (0 generated)
Small change to lss to fix pread64 system calls on MIPS.
LGTM, though I don't know enough about MIPS to confirm whether this is correct. :-) Do you want me to commit this for you?
On 2012/09/13 18:13:27, Mark Seaborn wrote: > LGTM, though I don't know enough about MIPS to confirm whether this is correct. > :-) > > Do you want me to commit this for you? Sure, commit it for me, thanks. Does CQ works for ssl?
On 2012/09/13 18:40:18, petarj wrote: > On 2012/09/13 18:13:27, Mark Seaborn wrote: > > LGTM, though I don't know enough about MIPS to confirm whether this > > is correct. :-) > > > > Do you want me to commit this for you? > > Sure, commit it for me, thanks. I've committed it. > Does CQ works for ssl? No, unfortunately not. But we haven't had many changes to this repo so far, so it's not a big problem. :-) Cheers, Mark
On 13 September 2012 03:59, <petarj@mips.com> wrote: > Reviewers: Markus (顧孟勤), Mark Seaborn, > > Message: > Small change to lss to fix pread64 system calls on MIPS. > > Description: > [MIPS] Ignoring 4th parameter in a3 for pread64 system calls on MIPS. > > Similar to ARM, MIPS also requires 64-bit parameters to be passed in > even-odd > register pairs. For pread64, MIPS ignores 4th argument and looks on stack > for > it. Issue discovered in NaCl development for MIPS. > Did you test this change on qemu-mips or on a full Linux kernel or both? It doesn't work for me with the qemu-mips that's currently included in NaCl's MIPS toolchain. With the change applied, I get the following traces from nacl_bootstrap: $ strace ./toolchain/linux_mips-trusted/qemu-mips32 scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... open("scons-out/opt-linux-mips32/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@f\0p4\0\0\0"..., 52, 0) = 52 pread64(3, "", 384, 0) = 0 writev(2, [{"bootstrap_helper: ", 18}, {"scons-out/opt-linux-mips32/stagi"..., 42}, {": ", 2}, {"Failed to read program headers f"..., 47}, {"read count", 10}, {"=", 1}, {"0", 1}, {NULL, 0}, {NULL, 0}, {NULL, 0}, {NULL, 0}, {"\n", 1}], 12bootstrap_helper: scons-out/opt-linux-mips32/staging/sel_ldr: Failed to read program headers from ELF file! read count=0 ) = 122 exit_group(2) = ? $ ./toolchain/linux_mips-trusted/qemu-mips32 -strace scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... 19851 open("scons-out/opt-linux-mips32/staging/sel_ldr",O_RDONLY) = 3 19851 pread64(3,1074263784,52,0,0,0) = 52 19851 pread64(3,1074263400,384,0,52,0) = 0 19851 writev(2,0x4007f468,0xc)bootstrap_helper: scons-out/opt-linux-mips32/staging/sel_ldr: Failed to read program headers from ELF file! read count=0 = 122 19851 exit_group(2) After reverting the change, the pread64() call succeeds: $ strace ./toolchain/linux_mips-trusted/qemu-mips32 scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... open("scons-out/opt-linux-mips32/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@f\0p4\0\0\0"..., 52, 0) = 52 pread64(3, "\6\0\0\0004\0\0\0004\0\0p4\0\0p\200\1\0\0\200\1\0\0\5\0\0\0\4\0\0\0"..., 384, 52) = 384 ... (it gets further) $ ./toolchain/linux_mips-trusted/qemu-mips32 -strace scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... 19956 open("scons-out/opt-linux-mips32/staging/sel_ldr",O_RDONLY) = 3 19956 pread64(3,1074263784,52,0,0,0) = 52 19956 pread64(3,1074263400,384,52,0,0) = 384 ... (it gets further) Maybe qemu-mips doesn't emulate Linux correctly here? Do we need to fix QEMU? Mark -- You received this message because you are subscribed to the Google Groups "Native-Client-Reviews" group. To post to this group, send email to native-client-reviews@googlegroups.com. To unsubscribe from this group, send email to native-client-reviews+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/native-client-reviews?hl=en.
On 13 September 2012 03:59, <petarj@mips.com> wrote: > Reviewers: Markus (顧孟勤), Mark Seaborn, > > Message: > Small change to lss to fix pread64 system calls on MIPS. > > Description: > [MIPS] Ignoring 4th parameter in a3 for pread64 system calls on MIPS. > > Similar to ARM, MIPS also requires 64-bit parameters to be passed in > even-odd > register pairs. For pread64, MIPS ignores 4th argument and looks on stack > for > it. Issue discovered in NaCl development for MIPS. > Did you test this change on qemu-mips or on a full Linux kernel or both? It doesn't work for me with the qemu-mips that's currently included in NaCl's MIPS toolchain. With the change applied, I get the following traces from nacl_bootstrap: $ strace ./toolchain/linux_mips-trusted/qemu-mips32 scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... open("scons-out/opt-linux-mips32/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@f\0p4\0\0\0"..., 52, 0) = 52 pread64(3, "", 384, 0) = 0 writev(2, [{"bootstrap_helper: ", 18}, {"scons-out/opt-linux-mips32/stagi"..., 42}, {": ", 2}, {"Failed to read program headers f"..., 47}, {"read count", 10}, {"=", 1}, {"0", 1}, {NULL, 0}, {NULL, 0}, {NULL, 0}, {NULL, 0}, {"\n", 1}], 12bootstrap_helper: scons-out/opt-linux-mips32/staging/sel_ldr: Failed to read program headers from ELF file! read count=0 ) = 122 exit_group(2) = ? $ ./toolchain/linux_mips-trusted/qemu-mips32 -strace scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... 19851 open("scons-out/opt-linux-mips32/staging/sel_ldr",O_RDONLY) = 3 19851 pread64(3,1074263784,52,0,0,0) = 52 19851 pread64(3,1074263400,384,0,52,0) = 0 19851 writev(2,0x4007f468,0xc)bootstrap_helper: scons-out/opt-linux-mips32/staging/sel_ldr: Failed to read program headers from ELF file! read count=0 = 122 19851 exit_group(2) After reverting the change, the pread64() call succeeds: $ strace ./toolchain/linux_mips-trusted/qemu-mips32 scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... open("scons-out/opt-linux-mips32/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@f\0p4\0\0\0"..., 52, 0) = 52 pread64(3, "\6\0\0\0004\0\0\0004\0\0p4\0\0p\200\1\0\0\200\1\0\0\5\0\0\0\4\0\0\0"..., 384, 52) = 384 ... (it gets further) $ ./toolchain/linux_mips-trusted/qemu-mips32 -strace scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... 19956 open("scons-out/opt-linux-mips32/staging/sel_ldr",O_RDONLY) = 3 19956 pread64(3,1074263784,52,0,0,0) = 52 19956 pread64(3,1074263400,384,52,0,0) = 384 ... (it gets further) Maybe qemu-mips doesn't emulate Linux correctly here? Do we need to fix QEMU? Mark
Hey Mark, How exactly does your environment look like? Note that you need at least one of the changes I have not yet upstream but provided to you (the toolchain.diff) on the top of the trunk. If you apply the toolchain.diff, run the toolchain script again, and then run: $ ./toolchain/linux_mips-trusted/qemu-mips32 -L ./toolchain/linux_mips-trusted/sysroot scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr No nacl file specified it should work. Petar ________________________________ From: mseaborn@google.com [mseaborn@google.com] on behalf of Mark Seaborn [mseaborn@chromium.org] Sent: Thursday, November 15, 2012 6:10 PM To: Jovanovic, Petar; markus@chromium.org; chromium-reviews@chromium.org Cc: native-client-reviews@googlegroups.com Subject: Re: [MIPS] Ignoring 4th parameter in a3 for pread64 system calls on MIPS. (issue 10910222) On 13 September 2012 03:59, <petarj@mips.com<mailto:petarj@mips.com>> wrote: Reviewers: Markus (顧孟勤), Mark Seaborn, Message: Small change to lss to fix pread64 system calls on MIPS. Description: [MIPS] Ignoring 4th parameter in a3 for pread64 system calls on MIPS. Similar to ARM, MIPS also requires 64-bit parameters to be passed in even-odd register pairs. For pread64, MIPS ignores 4th argument and looks on stack for it. Issue discovered in NaCl development for MIPS. Did you test this change on qemu-mips or on a full Linux kernel or both? It doesn't work for me with the qemu-mips that's currently included in NaCl's MIPS toolchain. With the change applied, I get the following traces from nacl_bootstrap: $ strace ./toolchain/linux_mips-trusted/qemu-mips32 scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... open("scons-out/opt-linux-mips32/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@f\0p4\0\0\0"..., 52, 0) = 52 pread64(3, "", 384, 0) = 0 writev(2, [{"bootstrap_helper: ", 18}, {"scons-out/opt-linux-mips32/stagi"..., 42}, {": ", 2}, {"Failed to read program headers f"..., 47}, {"read count", 10}, {"=", 1}, {"0", 1}, {NULL, 0}, {NULL, 0}, {NULL, 0}, {NULL, 0}, {"\n", 1}], 12bootstrap_helper: scons-out/opt-linux-mips32/staging/sel_ldr: Failed to read program headers from ELF file! read count=0 ) = 122 exit_group(2) = ? $ ./toolchain/linux_mips-trusted/qemu-mips32 -strace scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... 19851 open("scons-out/opt-linux-mips32/staging/sel_ldr",O_RDONLY) = 3 19851 pread64(3,1074263784,52,0,0,0) = 52 19851 pread64(3,1074263400,384,0,52,0) = 0 19851 writev(2,0x4007f468,0xc)bootstrap_helper: scons-out/opt-linux-mips32/staging/sel_ldr: Failed to read program headers from ELF file! read count=0 = 122 19851 exit_group(2) After reverting the change, the pread64() call succeeds: $ strace ./toolchain/linux_mips-trusted/qemu-mips32 scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... open("scons-out/opt-linux-mips32/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@f\0p4\0\0\0"..., 52, 0) = 52 pread64(3, "\6\0\0\0004\0\0\0004\0\0p4\0\0p\200\1\0\0\200\1\0\0\5\0\0\0\4\0\0\0"..., 384, 52) = 384 ... (it gets further) $ ./toolchain/linux_mips-trusted/qemu-mips32 -strace scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... 19956 open("scons-out/opt-linux-mips32/staging/sel_ldr",O_RDONLY) = 3 19956 pread64(3,1074263784,52,0,0,0) = 52 19956 pread64(3,1074263400,384,52,0,0) = 384 ... (it gets further) Maybe qemu-mips doesn't emulate Linux correctly here? Do we need to fix QEMU? Mark -- You received this message because you are subscribed to the Google Groups "Native-Client-Reviews" group. To post to this group, send email to native-client-reviews@googlegroups.com. To unsubscribe from this group, send email to native-client-reviews+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/native-client-reviews?hl=en.
Hey Mark, How exactly does your environment look like? Note that you need at least one of the changes I have not yet upstream but provided to you (the toolchain.diff) on the top of the trunk. If you apply the toolchain.diff, run the toolchain script again, and then run: $ ./toolchain/linux_mips-trusted/qemu-mips32 -L ./toolchain/linux_mips-trusted/sysroot scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr No nacl file specified it should work. Petar ________________________________ From: mseaborn@google.com [mseaborn@google.com] on behalf of Mark Seaborn [mseaborn@chromium.org] Sent: Thursday, November 15, 2012 6:10 PM To: Jovanovic, Petar; markus@chromium.org; chromium-reviews@chromium.org Cc: native-client-reviews@googlegroups.com Subject: Re: [MIPS] Ignoring 4th parameter in a3 for pread64 system calls on MIPS. (issue 10910222) On 13 September 2012 03:59, <petarj@mips.com<mailto:petarj@mips.com>> wrote: Reviewers: Markus (顧孟勤), Mark Seaborn, Message: Small change to lss to fix pread64 system calls on MIPS. Description: [MIPS] Ignoring 4th parameter in a3 for pread64 system calls on MIPS. Similar to ARM, MIPS also requires 64-bit parameters to be passed in even-odd register pairs. For pread64, MIPS ignores 4th argument and looks on stack for it. Issue discovered in NaCl development for MIPS. Did you test this change on qemu-mips or on a full Linux kernel or both? It doesn't work for me with the qemu-mips that's currently included in NaCl's MIPS toolchain. With the change applied, I get the following traces from nacl_bootstrap: $ strace ./toolchain/linux_mips-trusted/qemu-mips32 scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... open("scons-out/opt-linux-mips32/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@f\0p4\0\0\0"..., 52, 0) = 52 pread64(3, "", 384, 0) = 0 writev(2, [{"bootstrap_helper: ", 18}, {"scons-out/opt-linux-mips32/stagi"..., 42}, {": ", 2}, {"Failed to read program headers f"..., 47}, {"read count", 10}, {"=", 1}, {"0", 1}, {NULL, 0}, {NULL, 0}, {NULL, 0}, {NULL, 0}, {"\n", 1}], 12bootstrap_helper: scons-out/opt-linux-mips32/staging/sel_ldr: Failed to read program headers from ELF file! read count=0 ) = 122 exit_group(2) = ? $ ./toolchain/linux_mips-trusted/qemu-mips32 -strace scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... 19851 open("scons-out/opt-linux-mips32/staging/sel_ldr",O_RDONLY) = 3 19851 pread64(3,1074263784,52,0,0,0) = 52 19851 pread64(3,1074263400,384,0,52,0) = 0 19851 writev(2,0x4007f468,0xc)bootstrap_helper: scons-out/opt-linux-mips32/staging/sel_ldr: Failed to read program headers from ELF file! read count=0 = 122 19851 exit_group(2) After reverting the change, the pread64() call succeeds: $ strace ./toolchain/linux_mips-trusted/qemu-mips32 scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... open("scons-out/opt-linux-mips32/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@f\0p4\0\0\0"..., 52, 0) = 52 pread64(3, "\6\0\0\0004\0\0\0004\0\0p4\0\0p\200\1\0\0\200\1\0\0\5\0\0\0\4\0\0\0"..., 384, 52) = 384 ... (it gets further) $ ./toolchain/linux_mips-trusted/qemu-mips32 -strace scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr ... 19956 open("scons-out/opt-linux-mips32/staging/sel_ldr",O_RDONLY) = 3 19956 pread64(3,1074263784,52,0,0,0) = 52 19956 pread64(3,1074263400,384,52,0,0) = 384 ... (it gets further) Maybe qemu-mips doesn't emulate Linux correctly here? Do we need to fix QEMU? Mark
On 15 November 2012 10:19, Jovanovic, Petar <petarj@mips.com> wrote: > Hey Mark, > > How exactly does your environment look like? > Note that you need at least one of the changes I have not yet upstream but > provided to you (the toolchain.diff) on the top of the trunk. > If you apply the toolchain.diff, run the toolchain script again, and then > run: > > $ ./toolchain/linux_mips-trusted/qemu-mips32 -L > ./toolchain/linux_mips-trusted/sysroot > scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap > scons-out/opt-linux-mips32/staging/sel_ldr > No nacl file specified > > it should work. > Your toolchain.diff (attached for reference) isn't going to help because it only fixes problems that occur after nacl_helper_bootstrap opens sel_ldr and calls pread64() to read sel_ldr's ELF Program Headers. Did you test your pread64 change on qemu-mips or MIPS hardware or both? What output do you get for pread64 from strace and qemu-arm's "-strace"? Cheers, Mark
On 15 November 2012 10:19, Jovanovic, Petar <petarj@mips.com> wrote: > Hey Mark, > > How exactly does your environment look like? > Note that you need at least one of the changes I have not yet upstream but > provided to you (the toolchain.diff) on the top of the trunk. > If you apply the toolchain.diff, run the toolchain script again, and then > run: > > $ ./toolchain/linux_mips-trusted/qemu-mips32 -L > ./toolchain/linux_mips-trusted/sysroot > scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap > scons-out/opt-linux-mips32/staging/sel_ldr > No nacl file specified > > it should work. > Your toolchain.diff (attached for reference) isn't going to help because it only fixes problems that occur after nacl_helper_bootstrap opens sel_ldr and calls pread64() to read sel_ldr's ELF Program Headers. Did you test your pread64 change on qemu-mips or MIPS hardware or both? What output do you get for pread64 from strace and qemu-arm's "-strace"? Cheers, Mark -- You received this message because you are subscribed to the Google Groups "Native-Client-Reviews" group. To post to this group, send email to native-client-reviews@googlegroups.com. To unsubscribe from this group, send email to native-client-reviews+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/native-client-reviews?hl=en.
I do not understand how you invoked the error. I have mentioned to you for your reference what I do on the top of the trunk and see no error. The fix for the pread64 has been tested both on QEMU and hardware itself. It was tested both with an example unrelated to PNaCl, and obviously, PNaCl was failing too. QEMU for MIPS still has some issues that we are working on, but I am not aware of any pread64 related issue at the moment (though they may exist). I would appreciate if you could give me detailed instructions how you reproduce the failure. Here is part of the strace log with pread64 calls for MIPS: open("scons-out/opt-linux-mips32/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@f\0p4\0\0\0"..., 52, 0) = 52 pread64(3, "\6\0\0\0004\0\0\0004\0\0p4\0\0p\200\1\0\0\200\1\0\0\5\0\0\0\4\0\0\0"..., 384, 52) = 384 mmap2(0x70000000, 573440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x70000000 mmap2(0x70000000, 573440, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x70000000 mmap2(0x70000000, 573440, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x70000000 mmap2(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff4f5d000 mprotect(0x7005f000, 65536, PROT_NONE) = 0 mmap2(0x7006f000, 118784, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x5f) = 0x7006f000 mmap2(0x70073000, 102400, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x70073000 close(3) = 0 open("//home/pjovanovic/radni/pnacl/pnacl_submit/native_client/./toolchain/linux_mips-trusted/sysroot/lib/ld.so.1", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0000\17\0\0004\0\0\0"..., 52, 0) = 52 pread64(3, "\0\0\0p\24\1\0\0\24\1\0\0\24\1\0\0\30\0\0\0\30\0\0\0\4\0\0\0\4\0\0\0"..., 224, 52) = 224 mmap2(0x40501000, 204800, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x40501000 mmap2(0x40501000, 204800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40501000 mmap2(0x40501000, 204800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x40501000 mprotect(0x40522000, 61440, PROT_NONE) = 0 mmap2(0x40531000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x20) = 0x40531000 close(3) = 0 and here it is for ARM: open("scons-out/opt-linux-arm/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\321\327\0\0004\0\0\0"..., 52, 0) = 52 pread64(3, "\1\0\0p\230\342\5\0\230\342\5\0\230\342\5\0@\7\0\0@\7\0\0\4\0\0\0\4\0\0\0"..., 320, 52) = 320 mmap2(0xf4e04000, 552960, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0xfffffffff45 70000 mmap2(0xf4570000, 552960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xfffff ffff4570000 mmap2(0xf4570000, 552960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xfffffffff4570000 mprotect(0xf45cf000, 32768, PROT_NONE) = 0 mmap2(0xf45d7000, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x5f) = 0xfffffffff45d7000 mmap2(0xf45de000, 102400, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffff fffff45de000 close(3) = 0 open("//home/pjovanovic/radni/pnacl/pnacl_submit/native_client/./toolchain/linux_arm-trusted//lib/ld -linux.so.3", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\341\7\0\0004\0\0\0"..., 52, 0) = 52 pread64(3, "\1\0\0p\314S\1\0\314S\1\0\314S\1\0\220\0\0\0\220\0\0\0\4\0\0\0\4\0\0\0"..., 224, 52) = 224 mmap2(0xf45f7000, 126976, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0xfffffffff4551000 mmap2(0xf4551000, 126976, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xfffffffff4551000 mmap2(0xf4551000, 126976, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xfffffffff4551000 mprotect(0xf4567000, 28672, PROT_NONE) = 0 mmap2(0xf456e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x15) = 0xfffffffff456e000 close(3) = 0 Do you get the same? Petar ________________________________ From: mseaborn@google.com [mseaborn@google.com] on behalf of Mark Seaborn [mseaborn@chromium.org] Sent: Friday, November 16, 2012 1:36 AM To: Jovanovic, Petar Cc: markus@chromium.org; chromium-reviews@chromium.org; native-client-reviews@googlegroups.com Subject: Re: [MIPS] Ignoring 4th parameter in a3 for pread64 system calls on MIPS. (issue 10910222) On 15 November 2012 10:19, Jovanovic, Petar <petarj@mips.com<mailto:petarj@mips.com>> wrote: Hey Mark, How exactly does your environment look like? Note that you need at least one of the changes I have not yet upstream but provided to you (the toolchain.diff) on the top of the trunk. If you apply the toolchain.diff, run the toolchain script again, and then run: $ ./toolchain/linux_mips-trusted/qemu-mips32 -L ./toolchain/linux_mips-trusted/sysroot scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr No nacl file specified it should work. Your toolchain.diff (attached for reference) isn't going to help because it only fixes problems that occur after nacl_helper_bootstrap opens sel_ldr and calls pread64() to read sel_ldr's ELF Program Headers. Did you test your pread64 change on qemu-mips or MIPS hardware or both? What output do you get for pread64 from strace and qemu-arm's "-strace"? Cheers, Mark -- You received this message because you are subscribed to the Google Groups "Native-Client-Reviews" group. To post to this group, send email to native-client-reviews@googlegroups.com. To unsubscribe from this group, send email to native-client-reviews+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/native-client-reviews?hl=en.
I do not understand how you invoked the error. I have mentioned to you for your reference what I do on the top of the trunk and see no error. The fix for the pread64 has been tested both on QEMU and hardware itself. It was tested both with an example unrelated to PNaCl, and obviously, PNaCl was failing too. QEMU for MIPS still has some issues that we are working on, but I am not aware of any pread64 related issue at the moment (though they may exist). I would appreciate if you could give me detailed instructions how you reproduce the failure. Here is part of the strace log with pread64 calls for MIPS: open("scons-out/opt-linux-mips32/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@f\0p4\0\0\0"..., 52, 0) = 52 pread64(3, "\6\0\0\0004\0\0\0004\0\0p4\0\0p\200\1\0\0\200\1\0\0\5\0\0\0\4\0\0\0"..., 384, 52) = 384 mmap2(0x70000000, 573440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x70000000 mmap2(0x70000000, 573440, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x70000000 mmap2(0x70000000, 573440, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x70000000 mmap2(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff4f5d000 mprotect(0x7005f000, 65536, PROT_NONE) = 0 mmap2(0x7006f000, 118784, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x5f) = 0x7006f000 mmap2(0x70073000, 102400, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x70073000 close(3) = 0 open("//home/pjovanovic/radni/pnacl/pnacl_submit/native_client/./toolchain/linux_mips-trusted/sysroot/lib/ld.so.1", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0000\17\0\0004\0\0\0"..., 52, 0) = 52 pread64(3, "\0\0\0p\24\1\0\0\24\1\0\0\24\1\0\0\30\0\0\0\30\0\0\0\4\0\0\0\4\0\0\0"..., 224, 52) = 224 mmap2(0x40501000, 204800, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x40501000 mmap2(0x40501000, 204800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40501000 mmap2(0x40501000, 204800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x40501000 mprotect(0x40522000, 61440, PROT_NONE) = 0 mmap2(0x40531000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x20) = 0x40531000 close(3) = 0 and here it is for ARM: open("scons-out/opt-linux-arm/staging/sel_ldr", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\321\327\0\0004\0\0\0"..., 52, 0) = 52 pread64(3, "\1\0\0p\230\342\5\0\230\342\5\0\230\342\5\0@\7\0\0@\7\0\0\4\0\0\0\4\0\0\0"..., 320, 52) = 320 mmap2(0xf4e04000, 552960, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0xfffffffff45 70000 mmap2(0xf4570000, 552960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xfffff ffff4570000 mmap2(0xf4570000, 552960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xfffffffff4570000 mprotect(0xf45cf000, 32768, PROT_NONE) = 0 mmap2(0xf45d7000, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x5f) = 0xfffffffff45d7000 mmap2(0xf45de000, 102400, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffff fffff45de000 close(3) = 0 open("//home/pjovanovic/radni/pnacl/pnacl_submit/native_client/./toolchain/linux_arm-trusted//lib/ld -linux.so.3", O_RDONLY|O_LARGEFILE) = 3 pread64(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\341\7\0\0004\0\0\0"..., 52, 0) = 52 pread64(3, "\1\0\0p\314S\1\0\314S\1\0\314S\1\0\220\0\0\0\220\0\0\0\4\0\0\0\4\0\0\0"..., 224, 52) = 224 mmap2(0xf45f7000, 126976, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0xfffffffff4551000 mmap2(0xf4551000, 126976, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xfffffffff4551000 mmap2(0xf4551000, 126976, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xfffffffff4551000 mprotect(0xf4567000, 28672, PROT_NONE) = 0 mmap2(0xf456e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x15) = 0xfffffffff456e000 close(3) = 0 Do you get the same? Petar ________________________________ From: mseaborn@google.com [mseaborn@google.com] on behalf of Mark Seaborn [mseaborn@chromium.org] Sent: Friday, November 16, 2012 1:36 AM To: Jovanovic, Petar Cc: markus@chromium.org; chromium-reviews@chromium.org; native-client-reviews@googlegroups.com Subject: Re: [MIPS] Ignoring 4th parameter in a3 for pread64 system calls on MIPS. (issue 10910222) On 15 November 2012 10:19, Jovanovic, Petar <petarj@mips.com<mailto:petarj@mips.com>> wrote: Hey Mark, How exactly does your environment look like? Note that you need at least one of the changes I have not yet upstream but provided to you (the toolchain.diff) on the top of the trunk. If you apply the toolchain.diff, run the toolchain script again, and then run: $ ./toolchain/linux_mips-trusted/qemu-mips32 -L ./toolchain/linux_mips-trusted/sysroot scons-out/opt-linux-mips32/staging/nacl_helper_bootstrap scons-out/opt-linux-mips32/staging/sel_ldr No nacl file specified it should work. Your toolchain.diff (attached for reference) isn't going to help because it only fixes problems that occur after nacl_helper_bootstrap opens sel_ldr and calls pread64() to read sel_ldr's ELF Program Headers. Did you test your pread64 change on qemu-mips or MIPS hardware or both? What output do you get for pread64 from strace and qemu-arm's "-strace"? Cheers, Mark
On 15 November 2012 17:13, Jovanovic, Petar <petarj@mips.com> wrote: > I do not understand how you invoked the error. I have mentioned to you > for your > reference what I do on the top of the trunk and see no error. > Sorry, I was being stupid -- your reply obviously indicated you had tested with the qemu-mips from the trusted toolchain build. I realised what had happened was that I built the MIPS toolchain from a checkout where I hadn't run "gclient sync" recently, so the MIPS QEMU patch wasn't checked out, but the toolchain build didn't give an error about that. Here's a change to make it stricter: http://codereview.chromium.org/11299042/ I looked at the kernel code and it's clear that it skips an argument: SYSCALL_DEFINE6(32_pread, unsigned long, fd, char __user *, buf, size_t, count, unsigned long, unused, unsigned long, a4, unsigned long, a5) { return sys_pread64(fd, buf, count, merge_64(a4, a5)); } (from arch/mips/kernel/linux32.c) It's also clear that this is because syscalls follow the userland calling convention that the first 4 args are in registers, and other args are on the stack, and 64-bit arguments are not split between registers and stack. Mark -- You received this message because you are subscribed to the Google Groups "Native-Client-Reviews" group. To post to this group, send email to native-client-reviews@googlegroups.com. To unsubscribe from this group, send email to native-client-reviews+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/native-client-reviews?hl=en.
On 15 November 2012 17:13, Jovanovic, Petar <petarj@mips.com> wrote: > I do not understand how you invoked the error. I have mentioned to you > for your > reference what I do on the top of the trunk and see no error. > Sorry, I was being stupid -- your reply obviously indicated you had tested with the qemu-mips from the trusted toolchain build. I realised what had happened was that I built the MIPS toolchain from a checkout where I hadn't run "gclient sync" recently, so the MIPS QEMU patch wasn't checked out, but the toolchain build didn't give an error about that. Here's a change to make it stricter: http://codereview.chromium.org/11299042/ I looked at the kernel code and it's clear that it skips an argument: SYSCALL_DEFINE6(32_pread, unsigned long, fd, char __user *, buf, size_t, count, unsigned long, unused, unsigned long, a4, unsigned long, a5) { return sys_pread64(fd, buf, count, merge_64(a4, a5)); } (from arch/mips/kernel/linux32.c) It's also clear that this is because syscalls follow the userland calling convention that the first 4 args are in registers, and other args are on the stack, and 64-bit arguments are not split between registers and stack. Mark |