m68k 54418 fails to execute user space

Jean-Michel Hautbois jeanmichel.hautbois at yoseli.org
Mon Jun 24 01:56:01 PDT 2024


Hi all,

I keep going with my investigations, hoping that someone will have an 
idea to help :-) !

I think I found something, but not sure:

On 19/06/2024 14:29, Jean-Michel Hautbois wrote:
> Hello !
> 
> I am (still :-)) trying to make an upstream kernel work on my mcf54418 
> custom board. The kernel boots nicely now, but I have an issue when 
> executing binaries.
> 
> I tried uclibc-ng and glibc, with similar results.
> 
> First, I need a patch to change the ELF_ET_DYN_BASE value [1].
> Next, I switched from jffs2 to ubifs, but the behavior is the same, with 
> one or the other (just that jffs2 needs an extra patch to use 
> dirty_folio callback) [2].
> 
> Now, I wrote a very dumb and classical program:
> 
> $> cat hello.c
> #include <stdio.h>
> 
> int main()
> {
>      printf("Hello World on coldfire\n");
> }
> 
> And I linked it statically, and dynamically (later called hello-stat and 
> hello-dyn).
> 
> -- I added another patch to help debug the issue:
> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index a1f46919934c..d01bd3276204 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -1474,6 +1474,7 @@ static bool ubifs_dirty_folio(struct address_space 
> *mapping,
>           * An attempt to dirty a page without budgeting for it - should 
> not
>           * happen.
>           */
> +       VM_BUG_ON_FOLIO(ret != false, folio);
>          ubifs_assert(c, ret == false);
>          return ret;
>   }
> 
> Now comes the (fun ?) part.
> 
> When I execute /bin/bash as my init, and I launch the hello-dyn, I get:
> [    4.140000] Run /bin/bash as init process
> [    4.150000]   with arguments:
> [    4.150000]     /bin/bash
> [    4.150000]   with environment:
> [    4.160000]     HOME=/
> [    4.160000]     TERM=linux
> bash: cannot set terminal process group (-1): Inappropriate ioctl for 
> device
> bash: no job control in this shell
> bash-5.2# [  166.510000] random: crng init done
> 
> bash-5.2# /bin/hello-dyn
> Hello World on coldfir[  382.450000] page: refcount:2 mapcount:1 
> mapping:4206dc84 index:0x94 pfn:0x20ac9
> e
> [  382.460000] aops:0x413b1470 ino:9f dentry name:"libc.so.6"
> [  382.460000] flags: 0x38(uptodate|dirty|lru|zone=0)
> [  382.470000] raw: 00000038 4fed43dc 4fed4544 4206dc84 00000094 
> 00000000 00000000 00000002
> [  382.480000] raw: 41592000
> [  382.480000] page dumped because: VM_BUG_ON_FOLIO(ret != false)
> [  382.490000] kernel BUG at fs/ubifs/file.c:1477!
> [  382.490000] *** TRAP #7 ***   FORMAT=4
> [  382.490000] Current process id is 26
> [  382.490000] BAD KERNEL TRAP: 00000000
> [  382.490000] PC: [<410fba84>] ubifs_dirty_folio+0x3e/0x42
> [  382.490000] SR: 2010  SP: 4286bda4  a2: 41f24510
> [  382.490000] d0: 00000023    d1: 000000b9    d2: 4fed4444    d3: 6014c000
> [  382.490000] d4: 41593419    d5: 60150000    a0: 4286bce8    a1: 414d5180
> [  382.490000] Process hello-dyn (pid: 26, task=41f24510)
> [  382.490000] Frame format=4 eff addr=41450e8d pc=414674a3
> [  382.490000] Stack from 4286bde0:
> [  382.490000]         000005c5 4145aeed 41467485 4fed4444 410586de 
> 4206dc84 4fed4444 41593419
> [  382.490000]         4286bf1a 41074196 4fed4444 00000000 ffffffff 
> fffffffe 4286be9e 60150000
> [  382.490000]         00000001 41387c58 41073de0 4107797c 00000001 
> 4283f184 ffffffff 42884600
> [  382.490000]         60150000 42884600 4283a3d0 4286a000 4283a3fc 
> 00000000 00000000 00000000
> [  382.490000]         00000000 4286bf5c 41074456 4286bf1a 4283f184 
> 6014c000 60150000 4286be9e
> [  382.490000]         4283a3fc 4286bef6 4286bf1a 4102a05a 4283a3d4 
> 4283f344 4283a3d0 42830000
> [  382.490000] Call Trace: [<410586de>] folio_mark_dirty+0x44/0x58
> [  382.490000]  [<41074196>] unmap_page_range+0x3b6/0x602
> [  382.490000]  [<41387c58>] mas_find+0x0/0xfa
> [  382.490000]  [<41073de0>] unmap_page_range+0x0/0x602
> [  382.490000]  [<4107797c>] vma_next+0x0/0x14
> [  382.490000]  [<41074456>] unmap_vmas+0x74/0x98
> [  382.490000]  [<4102a05a>] up_read+0x0/0x36
> [  382.490000]  [<41079ab2>] exit_mmap+0xd4/0x1c0
> [  382.490000]  [<41009300>] arch_local_irq_enable+0x0/0xc
> [  382.490000]  [<410092f4>] arch_local_irq_disable+0x0/0xc
> [  382.490000]  [<41006b76>] __mmput+0x2e/0x86
> [  382.490000]  [<4100a080>] do_exit+0x21e/0x6e8
> [  382.490000]  [<4100a6c8>] sys_exit_group+0x0/0x14
> [  382.490000]  [<4100a686>] do_group_exit+0x22/0x64
> [  382.490000]  [<4100a6dc>] pid_child_should_wake+0x0/0x56
> [  382.490000]  [<41005848>] system_call+0x54/0xa8
> [  382.490000]
> [  382.490000] Code: 74a3 4879 4145 0e8d 4eb9 4139 adb8 4e47 <241f> 4e75 
> 91c8 f4e8 5288 f4e8 5288 f4e8 5288 f4e8 41e8 000d b1fc 0000 07f0 63e6
> [  382.490000] Disabling lock debugging due to kernel taint
> [  382.490000] note: hello-dyn[26] exited with irqs disabled
> [  382.500000] Fixing recursive fault but reboot is needed!
> [  387.520000] UBIFS error (ubi0:0 pid 24): ubifs_assert_failed: UBIFS 
> assert failed: folio->private != NULL, in fs/ubifs/file.c:1016
> [  387.530000] UBIFS warning (ubi0:0 pid 24): ubifs_ro_mode: switched to 
> read-only mode, error -22
> [  387.540000] CPU: 0 PID: 24 Comm: kworker/u4:1 Tainted: G      D      
> 6.10.0-rc4-00050-g21c7ef993c85 #491
> [  387.540000] Workqueue: writeback wb_workfn (flush-ubifs_0_0)
> [  387.540000] Stack from 41c7fc1c:
> [  387.540000]         41c7fc1c 4145ed0d 4145ed0d 00000000 0012d0a0 
> 41e4d000 413a271a 4145ed0d
> [  387.540000]         410fbf84 41e4d000 ffffffea 414674a3 000003f8 
> 4fed4444 41c7fd72 41c7fcea
> [  387.540000]         41c7fce6 41c7fd72 00002230 41058b72 41051efc 
> 41c7fd72 41051efc 41c7fd72
> [  387.540000]         41058e74 4fed4444 41c7fd72 00000000 00000064 
> 00000400 4281c200 4206dc84
> [  387.540000]         00000000 410fb9dc 4206dc84 41c7fd72 410fbf00 
> 00000000 41059f34 4206dc84
> [  387.540000]         41c7fd72 4206dbac 00000400 00000000 00000004 
> 41c7fd72 4206dbac 41c7fd72
> [  387.540000] Call Trace: [<413a271a>] dump_stack+0xc/0x10
> [  387.540000]  [<410fbf84>] ubifs_writepage+0x84/0x1e0
> [  387.540000]  [<41058b72>] writeback_iter+0x0/0x2b0
> [  387.540000]  [<41051efc>] folio_unlock+0x0/0x5c
> [  387.540000]  [<41051efc>] folio_unlock+0x0/0x5c
> [  387.540000]  [<41058e74>] write_cache_pages+0x52/0x6e
> [  387.540000]  [<410fb9dc>] ubifs_writepages+0x14/0x1a
> [  387.540000]  [<410fbf00>] ubifs_writepage+0x0/0x1e0
> [  387.540000]  [<41059f34>] do_writepages+0x76/0x192
> [  387.540000]  [<41024378>] vruntime_eligible+0x70/0x8c
> [  387.540000]  [<410b7b06>] __writeback_single_inode+0x46/0x182
> [  387.540000]  [<410b7e9a>] writeback_sb_inodes+0x2c/0x31a
> [  387.540000]  [<410b7ffc>] writeback_sb_inodes+0x18e/0x31a
> [  387.540000]  [<4109784a>] super_trylock_shared+0x0/0x40
> [  387.540000]  [<410b7e6e>] writeback_sb_inodes+0x0/0x31a
> [  387.540000]  [<4102a05a>] up_read+0x0/0x36
> [  387.540000]  [<41020000>] devm_register_sys_off_handler+0x18/0x64
> [  387.540000]  [<410b81f4>] __writeback_inodes_wb+0x6c/0x9e
> [  387.540000]  [<41059ce8>] wb_over_bg_thresh+0x0/0x7c
> [  387.540000]  [<410b8332>] queue_io+0x0/0xaa
> [  387.540000]  [<410b8484>] wb_writeback.isra.0+0xa8/0x132
> [  387.540000]  [<410b84ea>] wb_writeback.isra.0+0x10e/0x132
> [  387.540000]  [<410b72d8>] arch_local_irq_enable+0x0/0xc
> [  387.540000]  [<410b72cc>] arch_local_irq_disable+0x0/0xc
> [  387.540000]  [<410b740a>] finish_writeback_work+0x0/0x44
> [  387.540000]  [<410b83dc>] wb_writeback.isra.0+0x0/0x132
> [  387.540000]  [<410b8ac4>] wb_workfn+0x188/0x286
> [  387.540000]  [<41393fba>] sized_strscpy+0x0/0x13e
> [  387.540000]  [<41016312>] list_del_init+0x0/0x18
> [  387.540000]  [<41021ccc>] arch_local_irq_disable+0x0/0x12
> [  387.540000]  [<41018382>] process_scheduled_works+0x172/0x220
> [  387.540000]  [<410162e8>] arch_local_irq_disable+0x0/0xc
> [  387.540000]  [<41017b8c>] assign_work+0x0/0x54
> [  387.540000]  [<41018afa>] worker_thread+0x0/0x212
> [  387.540000]  [<41018cd2>] worker_thread+0x1d8/0x212
> [  387.540000]  [<4101d3f4>] kthread_exit+0x0/0x14
> [  387.540000]  [<41018afa>] worker_thread+0x0/0x212
> [  387.540000]  [<4101d6ac>] kthread+0x9a/0xa4
> [  387.540000]  [<4101d612>] kthread+0x0/0xa4
> [  387.540000]  [<410033d0>] ret_from_kernel_thread+0xc/0x14
> [  387.540000]
> [  387.550000] UBIFS error (ubi0:0 pid 24): ubifs_assert_failed: UBIFS 
> assert failed: !c->ro_media && !c->ro_mount, in fs/ubifs/journal.c:108
> [  387.570000] UBIFS error (ubi0:0 pid 24): make_reservation: cannot 
> reserve 4144 bytes in jhead 2, error -30
> [  387.580000] UBIFS error (ubi0:0 pid 24): do_writepage: cannot write 
> folio 148 of inode 159, error -30
> [  387.590000] UBIFS error (ubi0:0 pid 24): ubifs_assert_failed: UBIFS 
> assert failed: folio->private != NULL, in fs/ubifs/file.c:944
> [  387.600000] UBIFS error (ubi0:0 pid 24): ubifs_assert_failed: UBIFS 
> assert failed: c->bi.dd_growth >= 0, in fs/ubifs/budget.c:550
> 
> If I reboot, and launch hello-stat from bash, I get:
> [    4.140000] Run /bin/bash as init process
> [    4.150000]   with arguments:
> [    4.150000]     /bin/bash
> [    4.150000]   with environment:
> [    4.160000]     HOME=/
> [    4.160000]     TERM=linux
> bash: cannot set terminal process group (-1): Inappropriate ioctl for 
> device
> bash: no job control in this shell
> bash-5.2# /bin/hello-stat
> 
> I don't have a printf() printed, and a second launch results in:
> bash-5.2# /bin/hello-stat
> [   18.540000] page: refcount:2 mapcount:1 mapping:4207134c index:0x29 
> pfn:0x27f23
> [   18.550000] aops:0x413b1470 ino:8f dentry name:"hello-stat"
> [   18.560000] flags: 0x38(uptodate|dirty|lru|zone=0)
> [   18.560000] raw: 00000038 4fed5a14 414f3fdc 4207134c 00000029 
> 00000000 00000000 00000002
> [   18.570000] raw: 4fe46000
> [   18.570000] page dumped because: VM_BUG_ON_FOLIO(ret != false)
> [   18.580000] kernel BUG at fs/ubifs/file.c:1477!
> [   18.580000] *** TRAP #7 ***   FORMAT=4
> [   18.580000] Current process id is 28
> [   18.580000] BAD KERNEL TRAP: 00000000
> [   18.580000] PC: [<410fba84>] ubifs_dirty_folio+0x3e/0x42
> [   18.580000] SR: 2010  SP: 4288bc9c  a2: 41f24a10
> [   18.580000] d0: 00000023    d1: 000000b8    d2: 4ffda0ec    d3: 80054000
> [   18.580000] d4: 4fe47419    d5: 8005a000    a0: 4288bbe0    a1: 414d5180
> [   18.580000] Process hello-stat (pid: 28, task=41f24a10)
> [   18.580000] Frame format=4 eff addr=41450e8d pc=414674a3
> [   18.580000] Stack from 4288bcd8:
> [   18.580000]         000005c5 4145aeed 41467485 4ffda0ec 410586de 
> 4207134c 4ffda0ec 4fe47419
> [   18.580000]         4288be12 41074196 4ffda0ec 00000000 ffffffff 
> fffffffe 4288bd96 8005a000
> [   18.580000]         00000001 41387c58 41073de0 4107797c 00000001 
> 4283eb64 ffffffff 42890800
> [   18.580000]         8005a000 42890800 4283a1f0 4288a000 4283a21c 
> 00000000 00000000 00000000
> [   18.580000]         00000000 4288be54 41074456 4288be12 4283eb64 
> 80052000 8005a000 4288bd96
> [   18.580000]         4283a21c 4288bdee 4288be12 4102a05a 4283a1f4 
> 4283eaf4 4283a1f0 42830000
> [   18.580000] Call Trace: [<410586de>] folio_mark_dirty+0x44/0x58
> [   18.580000]  [<41074196>] unmap_page_range+0x3b6/0x602
> [   18.580000]  [<41387c58>] mas_find+0x0/0xfa
> [   18.580000]  [<41073de0>] unmap_page_range+0x0/0x602
> [   18.580000]  [<4107797c>] vma_next+0x0/0x14
> [   18.580000]  [<41074456>] unmap_vmas+0x74/0x98
> [   18.580000]  [<4102a05a>] up_read+0x0/0x36
> [   18.580000]  [<41079ab2>] exit_mmap+0xd4/0x1c0
> [   18.580000]  [<41009300>] arch_local_irq_enable+0x0/0xc
> [   18.580000]  [<410092f4>] arch_local_irq_disable+0x0/0xc
> [   18.580000]  [<41014283>] __sys_setreuid+0x99/0x138
> [   18.580000]  [<41006b76>] __mmput+0x2e/0x86
> [   18.580000]  [<4100a080>] do_exit+0x21e/0x6e8
> [   18.580000]  [<4100a686>] do_group_exit+0x22/0x64
> [   18.580000]  [<4101276e>] get_signal+0x420/0x502
> [   18.580000]  [<41003d68>] test_ti_thread_flag+0x0/0x14
> [   18.580000]  [<41004444>] do_notify_resume+0x4a/0x4e2
> [   18.580000]  [<41011cac>] force_sig_fault_to_task+0x40/0x4c
> [   18.580000]  [<410058fe>] Lsignal_return+0x14/0x26
> [   18.580000]
> [   18.580000] Code: 74a3 4879 4145 0e8d 4eb9 4139 adb8 4e47 <241f> 4e75 
> 91c8 f4e8 5288 f4e8 5288 f4e8 5288 f4e8 41e8 000d b1fc 0000 07f0 63e6
> [   18.580000] Disabling lock debugging due to kernel taint
> [   18.580000] note: hello-stat[28] exited with irqs disabled
> [   18.590000] Fixing recursive fault but reboot is needed!
> [   23.600000] UBIFS error (ubi0:0 pid 24): ubifs_assert_failed: UBIFS 
> assert failed: folio->private != NULL, in fs/ubifs/file.c:1016
> [   23.610000] UBIFS warning (ubi0:0 pid 24): ubifs_ro_mode: switched to 
> read-only mode, error -22
> [   23.620000] CPU: 0 PID: 24 Comm: kworker/u4:1 Tainted: G      D      
> 6.10.0-rc4-00050-g21c7ef993c85 #491
> [   23.620000] Workqueue: writeback wb_workfn (flush-ubifs_0_0)
> [   23.620000] Stack from 41c7fc1c:
> [   23.620000]         41c7fc1c 4145ed0d 4145ed0d 00000000 00233cf8 
> 41e4d000 413a271a 4145ed0d
> [   23.620000]         410fbf84 41e4d000 ffffffea 414674a3 000003f8 
> 4ffda0ec 41c7fd72 41c7fcea
> [   23.620000]         41c7fce6 41c7fd72 ffff9408 41058b72 41051efc 
> 41c7fd72 41051efc 41c7fd72
> [   23.620000]         41058e74 4ffda0ec 41c7fd72 00000000 00000064 
> 00000400 4281c200 4207134c
> [   23.620000]         00000000 410fb9dc 4207134c 41c7fd72 410fbf00 
> 00000000 41059f34 4207134c
> [   23.620000]         41c7fd72 42071274 00000400 00000000 00000004 
> 41c7fd72 42071274 41c7fd72
> [   23.620000] Call Trace: [<413a271a>] dump_stack+0xc/0x10
> [   23.620000]  [<410fbf84>] ubifs_writepage+0x84/0x1e0
> [   23.620000]  [<41058b72>] writeback_iter+0x0/0x2b0
> [   23.620000]  [<41051efc>] folio_unlock+0x0/0x5c
> [   23.620000]  [<41051efc>] folio_unlock+0x0/0x5c
> [   23.620000]  [<41058e74>] write_cache_pages+0x52/0x6e
> [   23.620000]  [<410fb9dc>] ubifs_writepages+0x14/0x1a
> [   23.620000]  [<410fbf00>] ubifs_writepage+0x0/0x1e0
> [   23.620000]  [<41059f34>] do_writepages+0x76/0x192
> [   23.620000]  [<41024378>] vruntime_eligible+0x70/0x8c
> [   23.620000]  [<410b7b06>] __writeback_single_inode+0x46/0x182
> [   23.620000]  [<410b7e9a>] writeback_sb_inodes+0x2c/0x31a
> [   23.620000]  [<410b7ffc>] writeback_sb_inodes+0x18e/0x31a
> [   23.620000]  [<4109784a>] super_trylock_shared+0x0/0x40
> [   23.620000]  [<410b7e6e>] writeback_sb_inodes+0x0/0x31a
> [   23.620000]  [<4102a05a>] up_read+0x0/0x36
> [   23.620000]  [<41020000>] devm_register_sys_off_handler+0x18/0x64
> [   23.620000]  [<410b81f4>] __writeback_inodes_wb+0x6c/0x9e
> [   23.620000]  [<41059ce8>] wb_over_bg_thresh+0x0/0x7c
> [   23.620000]  [<410b8332>] queue_io+0x0/0xaa
> [   23.620000]  [<410b8484>] wb_writeback.isra.0+0xa8/0x132
> [   23.620000]  [<410b84ea>] wb_writeback.isra.0+0x10e/0x132
> [   23.620000]  [<410b72d8>] arch_local_irq_enable+0x0/0xc
> [   23.620000]  [<410b72cc>] arch_local_irq_disable+0x0/0xc
> [   23.620000]  [<410b740a>] finish_writeback_work+0x0/0x44
> [   23.620000]  [<410b83dc>] wb_writeback.isra.0+0x0/0x132
> [   23.620000]  [<410b8ac4>] wb_workfn+0x188/0x286
> [   23.620000]  [<41393fba>] sized_strscpy+0x0/0x13e
> [   23.620000]  [<41016312>] list_del_init+0x0/0x18
> [   23.620000]  [<41021ccc>] arch_local_irq_disable+0x0/0x12
> [   23.620000]  [<41018382>] process_scheduled_works+0x172/0x220
> [   23.620000]  [<410162e8>] arch_local_irq_disable+0x0/0xc
> [   23.620000]  [<41017b8c>] assign_work+0x0/0x54
> [   23.620000]  [<41018afa>] worker_thread+0x0/0x212
> [   23.620000]  [<41018cd2>] worker_thread+0x1d8/0x212
> [   23.620000]  [<4101d3f4>] kthread_exit+0x0/0x14
> [   23.620000]  [<41018afa>] worker_thread+0x0/0x212
> [   23.620000]  [<4101d6ac>] kthread+0x9a/0xa4
> [   23.620000]  [<4101d612>] kthread+0x0/0xa4
> [   23.620000]  [<410033d0>] ret_from_kernel_thread+0xc/0x14
> [   23.620000]
> [   23.630000] UBIFS error (ubi0:0 pid 24): ubifs_assert_failed: UBIFS 
> assert failed: !c->ro_media && !c->ro_mount, in fs/ubifs/journal.c:108
> [   23.650000] UBIFS error (ubi0:0 pid 24): make_reservation: cannot 
> reserve 4144 bytes in jhead 2, error -30
> [   23.660000] UBIFS error (ubi0:0 pid 24): do_writepage: cannot write 
> folio 41 of inode 143, error -30
> [   23.670000] UBIFS error (ubi0:0 pid 24): ubifs_assert_failed: UBIFS 
> assert failed: folio->private != NULL, in fs/ubifs/file.c:944
> [   23.680000] UBIFS error (ubi0:0 pid 24): ubifs_assert_failed: UBIFS 
> assert failed: c->bi.dd_growth >= 0, in fs/ubifs/budget.c:550
> 
> Now, if I change the init process, and call /bin/hello-dyn instead:
> [    4.140000] Run /bin/hello-dyn as init process
> [    4.150000]   with arguments:
> [    4.150000]     /bin/hello-dyn
> [    4.150000]   with environment:
> [    4.160000]     HOME=/
> [    4.160000]     TERM=linux
> Hello World on coldfire
> [    4.470000] Kernel panic - not syncing: Attempted to kill init! 
> exitcode=0x00000000
> [    4.470000] CPU: 0 PID: 1 Comm: hello-dyn Not tainted 
> 6.10.0-rc4-00050-g21c7ef993c85 #491
> [    4.470000] Stack from 4186df2c:
> [    4.470000]         4186df2c 4145ed0d 4145ed0d 41009300 00000001 
> 000000ff 413a271a 4145ed0d
> [    4.470000]         4139a532 41009300 00000000 000000ff 00000001 
> 418a0010 00000000 410092f4
> [    4.470000]         4186dfac 41009fd4 41452c80 00000000 00000000 
> 4100a6c8 00000000 00000001
> [    4.470000]         00000000 00000001 41872010 6014f468 6014c000 
> 41872010 6014f468 6014c000
> [    4.470000]         601501cc 4100a686 00000000 4186c000 00000000 
> 4100a6dc 00000000 41005848
> [    4.470000]         00000000 00000001 000000f7 00000000 00000001 
> 60161700 60161700 601501d4
> [    4.470000] Call Trace: [<41009300>] arch_local_irq_enable+0x0/0xc
> [    4.470000]  [<413a271a>] dump_stack+0xc/0x10
> [    4.470000]  [<4139a532>] panic+0xc6/0x25c
> [    4.470000]  [<41009300>] arch_local_irq_enable+0x0/0xc
> [    4.470000]  [<410092f4>] arch_local_irq_disable+0x0/0xc
> [    4.470000]  [<41009fd4>] do_exit+0x172/0x6e8
> [    4.470000]  [<4100a6c8>] sys_exit_group+0x0/0x14
> [    4.470000]  [<4100a686>] do_group_exit+0x22/0x64
> [    4.470000]  [<4100a6dc>] pid_child_should_wake+0x0/0x56
> [    4.470000]  [<41005848>] system_call+0x54/0xa8
> [    4.470000]
> [    4.470000] ---[ end Kernel panic - not syncing: Attempted to kill 
> init! exitcode=0x00000000 ]---
> 
> Which is expected. So, I modified hello-dyn a bit:
> $> cat hello.c
> #include <stdlib.h>
> #include <stdio.h>
> #include <unistd.h>
> 
> int main()
> {
>      printf("Hello World on coldfire, execute bash !\n");
>      /* Let's now execute /bin/bash with execve */
>      char *args[] = {"/bin/bash", NULL};
>      execve(args[0], args, NULL);
>      /* If we reach here, it means execve failed */
>      perror("execve");
>      exit(EXIT_FAILURE);
> }
> 
> And now, I get:
> Hello World on coldfire, execute bash !
> bash: cannot set terminal process group (-1): Inappropriate ioctl for 
> device
> bash: no job control in this shell
> bash-5.2# ls
> [  122.030000] page: refcount:3 mapcount:2 mapping:4206cdc4 index:0x94 
> pfn:0x20ab2
> [  122.030000] aops:0x413b1470 ino:9f dentry name:"libc.so.6"
> [  122.040000] flags: 0x38(uptodate|dirty|lru|zone=0)
> [  122.040000] raw: 00000038 4fed3fec 4fed4208 4206cdc4 00000094 
> 00000000 00000001 00000003
> [  122.050000] raw: 41564000
> [  122.050000] page dumped because: VM_BUG_ON_FOLIO(ret != false)
> [  122.060000] kernel BUG at fs/ubifs/file.c:1477!
> [  122.060000] *** TRAP #7 ***   FORMAT=4
> [  122.060000] Current process id is 26
> [  122.060000] BAD KERNEL TRAP: 00000000
> [  122.060000] PC: [<410fba84>] ubifs_dirty_folio+0x3e/0x42
> [  122.060000] SR: 2010  SP: 42871cec  a2: 41f24510
> [  122.060000] d0: 00000023    d1: 000000b9    d2: 4fed4108    d3: 601ce000
> [  122.060000] d4: 41565411    d5: 601d2000    a0: 42871c30    a1: 414d5180
> [  122.060000] Process bash (pid: 26, task=41f24510)
> [  122.060000] Frame format=4 eff addr=41450e8d pc=414674a3
> <snip>

When I printk the do_page_fault first debug, I get for the first call to ls:
bash-5.2# ls
[   14.700000] do page fault:
[   14.700000] regs->sr=0x0, regs->pc=0x70069ee6, address=0x70069ee6, 0, 
(ptrval)

This call works almost fine (I still have the assert failed: 
folio->private != NULL issue).

And when I call it a second time, I get:
bash-5.2# ls
[   19.820000] do page fault:
[   19.820000] regs->sr=0x0, regs->pc=0x6011d65a, address=0x700e2004, 2, 
(ptrval)

The address corresponds to the defined zone ELF_ET_DYN_BASE as I set it 
to 0x70000000.

regs->pc is not the same as the address. It might be unrelevant, but any 
help is appreciated to understand the process behind :-).

I keep digging, and I am in the asm part which fears me a bit !

Thanks !
JM



More information about the linux-mtd mailing list