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

cmd/compile: nacl/arm is broken #19884

Closed
davecheney opened this issue Apr 7, 2017 · 5 comments
Closed

cmd/compile: nacl/arm is broken #19884

davecheney opened this issue Apr 7, 2017 · 5 comments
Milestone

Comments

@davecheney
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

$ go version
go version devel +03d1aa6 Fri Apr 7 04:46:42 2017 +0000 linux/arm

What operating system and processor architecture are you using (go env)?

linux/arm

What did you do?

pi@raspberrypi:~/go/src $ /home/pi/bin/sel_ldr_arm --reserved_at_zero=0x0000000040002000  -S -e -v ./bytes.test -test.v
sel_ldr argument list:
/home/pi/bin/sel_ldr_arm --reserved_at_zero=0x0000000040002000 -S -e -v ./bytes.test -test.v
[32594,1996328960:23:03:27.124074] NaClPerfCounterInterval(NaClAppLoadFile __start__:PreAllocAddrSpace): 78 microsecs
[32594,1996328960:23:03:27.124361] Native Client module will be loaded at base address 0x0000000000000000
[32594,1996328960:23:03:27.124449] NaClPerfCounterInterval(NaClAppLoadFile PreAllocAddrSpace:*AllocAddrSpace): 377 microsecs
[32594,1996328960:23:03:27.132401] NaClPerfCounterInterval(NaClAppLoadFile *AllocAddrSpace:*NaClElfImageLoad): 7947 microsecs
[32594,1996328960:23:03:27.132620] NaClPerfCounterInterval(NaClAppLoadFile *NaClElfImageLoad:*MakeDynText): 224 microsecs
[32594,1996328960:23:03:27.208303] VALIDATION FAILED.
[32594,1996328960:23:03:27.208363] Run sel_ldr in debug mode to ignore validation failure.
[32594,1996328960:23:03:27.208383] Run ncval <module-name> for validation error details.
[32594,1996328960:23:03:27.208401] NaClPerfCounterInterval(NaClAppLoadFile *MakeDynText:*ValidateImg): 75782 microsecs
[32594,1996328960:23:03:27.208423] NaClPerfCounterInterval(NaClAppLoadFile __start__:EndLoadFile): 84430 microsecs
[32594,1996328960:23:03:27.208462] Error while loading "./bytes.test": Validation failure. File violates Native Client safety rules.
Using the wrong type of nexe (nacl-x86-32 on an x86-64 or vice versa)
or a corrupt nexe file may be responsible for this error.
[32594,1996328960:23:03:27.208488] NaClPerfCounterInterval(SelMain __start__:AppLoadEnd): 93567 microsecs
[32594,1996328960:23:03:27.208506] NACL: Application output follows
[32594,1996328960:23:03:27.208525] NaClAppStartModule: error loading module
Dumping vmmap.
In PrintVmmap
Done.

What did you expect to see?

test complete successfully

What did you see instead?

echo code 1

@davecheney davecheney added this to the Go1.9 milestone Apr 7, 2017
@davecheney
Copy link
Contributor Author

bytes.test.gz

^ failing nacl binary

@davecheney
Copy link
Contributor Author

(gdb) disassemble 0xa96ac
Dump of assembler code for function runtime.save_g:
   0x000a96a0 <+0>:     mov     r0, r10
   0x000a96a4 <+4>:     bic     lr, lr, #-1073741809    ; 0xc000000f
   0x000a96a8 <+8>:     bx      lr
   0x000a96ac <+12>:    mrc     15, 0, r0, cr13, cr0, {3}               <<<<<<<<<<<<<<
   0x000a96b0 <+16>:    bic     r0, r0, #3
   0x000a96b4 <+20>:    ldr     r11, [pc, #40]  ; 0xa96e4 <runtime.save_g+68>
   0x000a96b8 <+24>:    add     r0, r0, r11
   0x000a96bc <+28>:    nop                     ; (mov r0, r0)
   0x000a96c0 <+32>:    bic     r0, r0, #-1073741824    ; 0xc0000000
   0x000a96c4 <+36>:    str     r10, [r0]
   0x000a96c8 <+40>:    mov     r0, r10
   0x000a96cc <+44>:    nop                     ; (mov r0, r0)
   0x000a96d0 <+48>:    bic     lr, lr, #-1073741809    ; 0xc000000f
   0x000a96d4 <+52>:    bx      lr
   0x000a96d8 <+56>:    b       0xa96d8 <runtime.save_g+56>
   0x000a96dc <+60>:    nop                     ; (mov r0, r0)
   0x000a96e0 <+64>:    bkpt    0x5be0
   0x000a96e4 <+68>:    andeq   r0, r0, r8
   0x000a96e8 <+72>:    nop                     ; (mov r0, r0)
   0x000a96ec <+76>:    nop                     ; (mov r0, r0)
End of assembler dump.
(gdb) disassemble 0xa96f8
Dump of assembler code for function runtime.load_g:
   0x000a96f0 <+0>:     bic     lr, lr, #-1073741809    ; 0xc000000f
   0x000a96f4 <+4>:     bx      lr
   0x000a96f8 <+8>:     mrc     15, 0, r0, cr13, cr0, {3} <<<<<<<<<<<<
   0x000a96fc <+12>:    bic     r0, r0, #3
   0x000a9700 <+16>:    ldr     r11, [pc, #28]  ; 0xa9724 <runtime.load_g+52>
   0x000a9704 <+20>:    add     r0, r0, r11
   0x000a9708 <+24>:    bic     r0, r0, #-1073741824    ; 0xc0000000
   0x000a970c <+28>:    ldr     r10, [r0]
   0x000a9710 <+32>:    bic     lr, lr, #-1073741809    ; 0xc000000f
   0x000a9714 <+36>:    bx      lr
   0x000a9718 <+40>:    b       0xa9718 <runtime.load_g+40>
   0x000a971c <+44>:    nop                     ; (mov r0, r0)
   0x000a9720 <+48>:    bkpt    0x5be0
   0x000a9724 <+52>:    andeq   r0, r0, r8
   0x000a9728 <+56>:    nop                     ; (mov r0, r0)
   0x000a972c <+60>:    nop                     ; (mov r0, r0)

Are the offending instructions. mrc is not permitted by nacl.

@davecheney
Copy link
Contributor Author

davecheney commented Apr 7, 2017

That's odd

TEXT runtime·save_g(SB),NOSPLIT,$-4
#ifdef GOOS_nacl
        // nothing to do as nacl/arm does not use TLS at all.
        MOVW    g, R0 // preserve R0 across call to setg<>
        RET
#endif

Should have avoided fetching the tls register.

@josharian
Copy link
Contributor

Bisect?

@gopherbot
Copy link

CL https://golang.org/cl/40111 mentions this issue.

@cherrymui cherrymui self-assigned this Apr 8, 2017
lparth pushed a commit to lparth/go that referenced this issue Apr 13, 2017
…Cl/ARM

They are dead code already, but the verifier is still not happy.
Don't assemble them at all.

Looks like it has been like that for long. I don't know why it
was ok. Maybe the verifier is now more picky?

Fixes golang#19884.

Change-Id: Ib806fb73ca469789dec56f52d484cf8baf7a245c
Reviewed-on: https://go-review.googlesource.com/40111
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
@golang golang locked and limited conversation to collaborators Apr 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants