No arm64 support in klibc

Bug #1081162 reported by Wookey
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro AArch64 cross-distro work
Fix Released
Medium
Anil Ranjan Roy Samanta Singhar
Linaro OpenEmbedded
Fix Released
Medium
koen
Debian
Fix Released
Unknown

Bug Description

klibc is used by initramfs boot in distros (which is pretty-much a requirement these days) so is needed for standard distro bootable images. No arm64 work has been done on this yet.

Revision history for this message
Riku Voipio (riku-voipio) wrote :
Revision history for this message
Neil Williams (codehelp) wrote :

See also Debian bug http://bugs.debian.org/698018 and my github repo of the work in progress.

https://github.com/codehelp/klibc-aarch64

Have a crt0.S and a setjmp.S, now working on the syscall and moving on, hopefully to something which I can start testing inside the model.

Revision history for this message
Neil Williams (codehelp) wrote :

I now have a sufficient patch to allow a complete build of klibc 2.0.1 - it's completely untested and likely to have issues. (Use the debian branch of the github linked above).

Revision history for this message
Riku Voipio (riku-voipio) wrote :

Neil, can you attach the latest patch?

Changed in linaro-aarch64:
status: New → In Progress
Changed in debian:
status: Unknown → New
Changed in linaro-aarch64:
importance: Undecided → Medium
Revision history for this message
Neil Williams (codehelp) wrote :

I haven't been able to do much with this recently. I've tried various tests of crt0.s but I haven't been able to get useful debug.

https://github.com/codehelp/klibc-aarch64/blob/master/usr/klibc/arch/aarch64/crt0.S

Last time I ran it, it looked like it was seg faulting in the exit handling.

Ilias Biris (ibiris)
Changed in linaro-oe:
assignee: nobody → Anil Ranjan Roy Samanta Singhar (anil-singhar)
Revision history for this message
Anil Ranjan Roy Samanta Singhar (anil-singhar) wrote :

Current Status:

Started off from where Neil had left and now klibc is in mostly working condition. However, out of the 34 tests that are included in the package, there are still two tests that are failing, namely sig-nodefer and fstat. The problem seems to be either in fork system call or the pause system call. I am still debugging it, but last I ran into some problem with linaro gdb where it gives the error "Unexpected error setting hardware debug registers".

Trying to get past this issue to continue debugging.

Revision history for this message
Anil Ranjan Roy Samanta Singhar (anil-singhar) wrote :

Sorry, missed the link in the last comment.

Here is where I am putting the partially working code (that is still being debugged).

git clone git://git.linaro.org/people/anil.singhar/klibc-aarch64.git

Revision history for this message
Anil Ranjan Roy Samanta Singhar (anil-singhar) wrote :

Currently, I am debugging dash, which is crashing on exit. The code is some what cleaned up and out of the 34 tests, all seem to pass except statfs. Here is a short list of pending activities in order of priority:

1. debug crash on exit of dash - Could be something to do with longjmp
2. debug why gzip is not compressing - possibly due to lstat
3. debug why statfs returns bad address for perfectly valid file paths.
4. Have the right value of KLIBCSHAREDFLAGS definition in arch/aarch64/MCONFIG - any help..?
5. debug why select is not correctly modifying user's timeout struct

I hope after this the code will be ready for upstream review..

Revision history for this message
Andrew McDermott (frobware) wrote : Re: [Bug 1081162] Re: No arm64 support in klibc

Does gzip exhibit failures when uncompressing as well?

> On 27 Sep 2013, at 08:42, Anil Ranjan Roy Samanta Singhar <email address hidden> wrote:
>
> Currently, I am debugging dash, which is crashing on exit. The code is
> some what cleaned up and out of the 34 tests, all seem to pass except
> statfs. Here is a short list of pending activities in order of priority:
>
> 1. debug crash on exit of dash - Could be something to do with longjmp
> 2. debug why gzip is not compressing - possibly due to lstat
> 3. debug why statfs returns bad address for perfectly valid file paths.
> 4. Have the right value of KLIBCSHAREDFLAGS definition in arch/aarch64/MCONFIG - any help..?
> 5. debug why select is not correctly modifying user's timeout struct
>
> I hope after this the code will be ready for upstream review..
>
> --
> You received this bug notification because you are subscribed to Linaro
> OpenEmbedded.
> Matching subscriptions: <email address hidden>
> https://bugs.launchpad.net/bugs/1081162
>
> Title:
> No arm64 support in klibc
>
> Status in Linaro AArch64 cross-distro work:
> In Progress
> Status in Linaro OpenEmbedded:
> New
> Status in Debian GNU/Linux:
> New
>
> Bug description:
> klibc is used by initramfs boot in distros (which is pretty-much a
> requirement these days) so is needed for standard distro bootable
> images. No arm64 work has been done on this yet.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/linaro-aarch64/+bug/1081162/+subscriptions

Revision history for this message
Anil Ranjan Roy Samanta Singhar (anil-singhar) wrote :
Download full text (11.8 KiB)

I was debugging the problem with exit crashing in dash and found that this is happening because the setjmp buffers are getting corrupt because the buffers are allocated from the call stack itself. Here is what I found. There are 3 consecutive setjmp calls made before the first call to longjmp. The 2nd and 3rd setjmp calls are made from two different functions (redirectsafe and evalbltin) both of which are called from evalcommand. Since the buffer is made available from the call stack, when the call returns the stack is unwound and then again another call is made the stack is used up, the buffer is corrupted.

Dont know if there are fixes for this..or I am missing somthing really subtle. Here is the info:

1st setjmp from main:
------------------------------------
Breakpoint 2, 0x0000000000410720 in setjmp ()
(gdb) backtrace
#0 0x0000000000410720 in setjmp ()
#1 0x000000000040010c in main ()
(gdb) info registers
x0 0x7ffffffb30 549755812656
x1 0x7ffffffc88 549755813000
x2 0x7ffffffc98 549755813016
x3 0x4060 16480
x4 0x424200 4342272
x5 0x424200 4342272
x6 0x3e80 16000
x7 0x1 1
x8 0x1d 29
x9 0x0 0
x10 0x0 0
x11 0x0 0
x12 0x0 0
x13 0x0 0
x14 0x0 0
x15 0x0 0
x16 0x0 0
x17 0x0 0
x18 0x0 0
x19 0x1 1
x20 0x0 0
x21 0x0 0
x22 0x0 0
x23 0x0 0
x24 0x0 0
x25 0x0 0
x26 0x0 0
x27 0x0 0
x28 0x0 0
x29 0x7ffffffb10 549755812624
x30 0x40010c 4194572
sp 0x7ffffffb10 0x7ffffffb10
pc 0x410720 0x410720 <setjmp>
cpsr 0x20000000 536870912
fpsr 0x0 0
fpcr 0x0 0
(gdb)
(gdb) disassem
Dump of assembler code for function main:
   0x00000000004000ec <+0>: stp x29, x30, [sp,#-320]!
   0x00000000004000f0 <+4>: mov x29, sp
   0x00000000004000f4 <+8>: str w0, [x29,#304]
   0x00000000004000f8 <+12>: add x0, x29, #0x20
   0x00000000004000fc <+16>: str x19, [sp,#16]
   0x0000000000400100 <+20>: str x1, [x29,#312]
   0x0000000000400104 <+24>: str wzr, [x29,#296]
   0x0000000000400108 <+28>: bl 0x410720 <setjmp>
=> 0x000000000040010c <+32>: cbz w0, 0x4001a0 <main+180>
   0x0000000000400110 <+36>: bl 0x40e47c <reset>
   0x0000000000400114 <+40>: adrp x0, 0x424000 <curdir>
   0x0000000000400118 <+44>: ldr w0, [x0,#2520]
   0x000000000040011c <+48>: ldr w19, [x29,#296]
   0x0000000000400120 <+52>: cmp w0, #0x4
   0x0000000000400124 <+56>: b.eq 0x400144 <main+88>
   0x0000000000400128 <+60>: cbz w19, 0x400144 <main+88>
   0x000000000040012c <+64>: adrp x1, 0x428000 <basebuf+13808>
   0x0000000000400130 <+68>: ldrb w1, [x1,#3227]
   0x0000000000400134 <+72>: cbz w1, 0x400144 <main+88>
   0x0000000000400138 <...

Revision history for this message
Anil Ranjan Roy Samanta Singhar (anil-singhar) wrote :

Hi Andrew,
I have not tried debugging gzip yet..
Will try gunzip and let u know.

Thanks,
Anil

On 27 September 2013 17:19, Andrew McDermott <email address hidden>wrote:

> Does gzip exhibit failures when uncompressing as well?
>
> > On 27 Sep 2013, at 08:42, Anil Ranjan Roy Samanta Singhar <
> <email address hidden>> wrote:
> >
> > Currently, I am debugging dash, which is crashing on exit. The code is
> > some what cleaned up and out of the 34 tests, all seem to pass except
> > statfs. Here is a short list of pending activities in order of priority:
> >
> > 1. debug crash on exit of dash - Could be something to do with longjmp
> > 2. debug why gzip is not compressing - possibly due to lstat
> > 3. debug why statfs returns bad address for perfectly valid file paths.
> > 4. Have the right value of KLIBCSHAREDFLAGS definition in
> arch/aarch64/MCONFIG - any help..?
> > 5. debug why select is not correctly modifying user's timeout struct
> >
> > I hope after this the code will be ready for upstream review..
> >
> > --
> > You received this bug notification because you are subscribed to Linaro
> > OpenEmbedded.
> > Matching subscriptions: <email address hidden>
> > https://bugs.launchpad.net/bugs/1081162
> >
> > Title:
> > No arm64 support in klibc
> >
> > Status in Linaro AArch64 cross-distro work:
> > In Progress
> > Status in Linaro OpenEmbedded:
> > New
> > Status in Debian GNU/Linux:
> > New
> >
> > Bug description:
> > klibc is used by initramfs boot in distros (which is pretty-much a
> > requirement these days) so is needed for standard distro bootable
> > images. No arm64 work has been done on this yet.
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/linaro-aarch64/+bug/1081162/+subscriptions
>
> --
> You received this bug notification because you are a bug assignee.
> https://bugs.launchpad.net/bugs/1081162
>
> Title:
> No arm64 support in klibc
>
> Status in Linaro AArch64 cross-distro work:
> In Progress
> Status in Linaro OpenEmbedded:
> New
> Status in Debian GNU/Linux:
> New
>
> Bug description:
> klibc is used by initramfs boot in distros (which is pretty-much a
> requirement these days) so is needed for standard distro bootable
> images. No arm64 work has been done on this yet.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/linaro-aarch64/+bug/1081162/+subscriptions
>

Revision history for this message
Anil Ranjan Roy Samanta Singhar (anil-singhar) wrote :

Fixed dash crash on exit issue. The issue was that the jmp_buf was still left at 22+8 bytes which didn't take sp into account. Currently working on making lstat work.

Revision history for this message
Anil Ranjan Roy Samanta Singhar (anil-singhar) wrote :
Download full text (6.0 KiB)

Fixed stat, statfs, symlinkat issues and set up the mksh test shell. Now manual testing passes for all, dash and gzip seems to be working fine but there are 5 failures out of the 436 mksh tests. So I am debugging them one by one.

I noticed compilation errors while building mksh for klibc, but dont know if I am OK with them or not. Now I am just assuming that they are probably OK and debugging the failures. The 5 mksh test failures are as follows. If anyone has any idea, please share. Thanks.
----------------------------------------------------------------------------------------------------------------
root@genericarmv8:~/anilss/AArch64/mksh# ./mksh test.sh -p $PWD/mksh
Testing mksh for conformance:
# $MirOS: src/bin/mksh/check.t,v 1.599 2013/02/24 14:22:41 tg Exp $
        @(#)MIRBSD KSH R44 2013/02/24
This shell is actually:
        @(#)MIRBSD KSH R44 2013/02/24
test.sh built for mksh R44 2013/02/24
Trying Perl interpreter 'perl5'...
test.sh[70]: perl5: not found
Errorlevel 127, running on ''
=> not using
Trying Perl interpreter 'perl'...
Errorlevel 0, running on 'linux, Perl version 5.014003'
=> using it
+ perl ./check.pl -p /home/root/anilss/AArch64/mksh/mksh -C shell:legacy-no,int:32 -v -s ./check.t
pass ./check.t:KSH_VERSION
pass ./check.t:selftest-1
pass ./check.t:selftest-2
. . .
pass ./check.t:cd-history
FAIL ./check.t:cd-pe (ignored)
        Description:
                Check package for cd -Pe
        unexpected stdout - first difference: line 2, char 5 (wanted 'n', got 'l'
        wanted:
                0=0
                1=0,noread/target
                2=0,noread/target/subdir
                now with -e:
                0=0
                1=0,noread/target
                2=1,noread/target/subdir
        got:
                0=0
                1=0,link/target
                2=0,link/target/subdir
                now with -e:
                0=0
                1=0,link/target
                2=1,link/target/subdir
pass ./check.t:env-prompt
pass ./check.t:expand-ugly
. . .
pass ./check.t:glob-bad-1
FAIL ./check.t:glob-bad-2
        Description:
                Check that symbolic links aren't stat()'d
        unexpected stdout - first difference: line 2, char 2 (wanted 'i', got '*'
        wanted:
                dir/abc
                dir/abc
        got:
                dir/abc
                d*/abc
pass ./check.t:glob-range-1
pass ./check.t:glob-range-2
. . .
pass ./check.t:history-subst-4
pass ./check.t:history-subst-5
FAIL ./check.t:history-ed-1 (ignored)
        Description:
                Basic (ed) editing works (assumes you have generic ed editor
                that prints no prompts). This is for newish ed(1) and stderr.
        unexpected exit status 32512 (exit-code 127), expected 0
        unexpected stdout - got too little output
        wanted:
                abc def
                FOOBAR def
        got:
                abc def
        unexpected stderr - wanted pattern:
                /^X*13\n16\necho FOOBAR def\nX*$/
        got:
                XX/home/root/anilss/AArch64/mksh/mksh: /bin/ed: not found
                X/home/root/anilss/AArch64/mksh/mksh: <stdin>[3]: s/abc/FOOBAR/: not found
     ...

Read more...

Revision history for this message
Fathi Boudra (fboudra) wrote :
Changed in linaro-aarch64:
assignee: nobody → Anil Ranjan Roy Samanta Singhar (anil-singhar)
Changed in linaro-oe:
assignee: Anil Ranjan Roy Samanta Singhar (anil-singhar) → nobody
Changed in linaro-aarch64:
status: In Progress → Fix Committed
Changed in linaro-oe:
milestone: none → 13.12
Revision history for this message
Fathi Boudra (fboudra) wrote :

it's now released as part of klibc 2.0.3

Changed in linaro-oe:
assignee: nobody → koen (koenkooi)
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
koen (koenkooi) wrote :
Fathi Boudra (fboudra)
Changed in linaro-oe:
milestone: 13.12 → 14.01
Fathi Boudra (fboudra)
Changed in linaro-oe:
status: Triaged → Fix Released
Changed in debian:
status: New → Fix Released
Revision history for this message
Riku Voipio (riku-voipio) wrote :

Fixed upstream in 2.0.3

Changed in linaro-aarch64:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.