lkml.org 
[lkml]   [2020]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: RISC-V nommu support v6
Paul Walmsley <paul.walmsley@sifive.com> 於 2019年11月23日 週六 上午10:24寫道:
>
> On Thu, 31 Oct 2019, Christoph Hellwig wrote:
>
> > On Wed, Oct 30, 2019 at 01:21:21PM -0700, Paul Walmsley wrote:
> > > I tried building this series from your git branch mentioned above, and
> > > booted it with a buildroot userspace built from your custom buildroot
> > > tree. Am seeing some segmentation faults from userspace (below).
> > >
> > > Am still planning to merge your patches.
> > >
> > > But I'm wondering whether you are seeing these segmentation faults also?
> > > Or is it something that might be specific to my test setup?
> >
> > I just built a fresh image using make -j4 with that report and it works
> > perfectly fine with my tree.
>
> Another colleague just gave this a quick test, following your instructions
> as I did. He encountered the same segmentation faulting issue. Might be
> worth taking a look at this once v5.5-rc1 is released. Could be a
> userspace issue, though.
>

Hi all,

I have the same symptom too.

[ 0.389983] Run /init as init process
[ 0.457294] mount[24]: unhandled signal 11 code 0x2 at 0x00000000834000e8
[ 0.458057] CPU: 0 PID: 24 Comm: mount Not tainted
5.4.0-rc5-00021-g1a87b1010118 #44
[ 0.458477] epc: 00000000834000e8 ra : 000000008341c140 sp :
000000008348add0
[ 0.458803] gp : 0000000083471300 tp : 0000000000000000 t0 :
0000000000000032
[ 0.459319] t1 : 8101010101010100 t2 : 0000000000000007 s0 :
0000000000000001
[ 0.459678] s1 : 0000000000000001 a0 : 0000000000000000 a1 :
000000008348afb8
[ 0.460027] a2 : 000000008348afa6 a3 : 0000000000008000 a4 :
0000000000000000
[ 0.460370] a5 : 0000000000084000 a6 : 70f8fefcf8fef0fc a7 :
0000000000000028
[ 0.460829] s2 : 0000000083483fd0 s3 : fffffffffffffff8 s4 :
0000000083425dcc
[ 0.461200] s5 : 0000000000000001 s6 : 0000000000000001 s7 :
0000000000000001
[ 0.461592] s8 : 0000000000000000 s9 : 00000000838ccbd0 s10:
0000000000000000
[ 0.461912] s11: 0000000000000000 t3 : 000000000000003d t4 :
000000000000002b
[ 0.462283] t5 : 0000000000000002 t6 : 0000000000000001
[ 0.462562] status: 0000000000004080 badaddr: 0000000000084010
cause: 0000000000000005
SEGV

This failure is because of it tries access the absolute address. This
address is generated by gcc. It tries to access __bss_start in a non-PIC
way. The code sequence will be looked like this.
00000000000000a4 <__do_global_dtors_aux>:
a4: 000847b7 lui a5,0x84
a8: 0107c703 lbu a4,16(a5) # 84010
<__bss_start>

However this is a user program and it will be loaded to any
address of RAM by kernel loader
so that it could not use the absolute address.

In this case, we have to enable PIC when compiling these codes and it is in
gcc so we have to set the correct configuration options for gcc in
buildroot.

-BR2_EXTRA_GCC_CONFIG_OPTIONS=""
+BR2_EXTRA_GCC_CONFIG_OPTIONS="CFLAGS_FOR_TARGET='-O2 -fPIC'
CXXFLAGS_FOR_TARGET='-O2 -fPIC'"

After applying this fix, the code will be looked like this.
00000000000000a0 <__do_global_dtors_aux>:
a0: 00085797 auipc a5,0x85
a4: bf07c783 lbu a5,-1040(a5) #
84c90 <__bss_start>

It could boot to shell without any segmentation fault.

Hi Christoph,
Would you like to upstream the buildroot porting for nommu support?
Then I can upstream this fix. :)

\
 
 \ /
  Last update: 2020-02-12 13:20    [W:0.130 / U:0.592 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site