[dev][kernel][kexec]

delewer

Senior Member
Aug 20, 2011
186
233
0
Paris
I have create the "atags" file in "/data/atags" for now (by kexec-zImage-arm.c modification)

I create modules to load the custom kernel.
- "kexec_load"

And another to open rw the /proc folder

but, a can't load bc this :
insmod: init_module (...) failed (Exec format error)

i have a wrong signature :
dmesg | grep
(...) disagrees about version of symbol module_layout

Of course, i am on stock kernel (no choice)...
so, my uname -r give me :
3.4.0-perf-g66807d4-02450-g9a218f1

If someone give me the way to change the version in module ?
May be in .config
May be in Makefile
May be in symvers
May be in module.h => __attribute( (...) __version)
May be in other way ?

Thx to help me.


Edit 1 :
I have try with modprobe too, with same error
the "-f" to force don't exist

Edit 2 :
Ok, i have found
But the issu occurs.

If someone know how to edit the magicver of module to force module to load by insmod ?
Thx
 
Last edited:

delewer

Senior Member
Aug 20, 2011
186
233
0
Paris
I don't anderstand

I have exactly the same vermagic

This module load correctly : /system/lib/module/mii.ko
This module don't : /system/lib/kexec_load.ko

strings mii.ko | grep vermagic
vermagic=3.4.0-perf-g66807d4-02450-g9a218f1 SMP preempt mod_unload modversions ARMv7

strings kexec_load.ko | grep vermagic
vermagic=3.4.0-perf-g66807d4-02450-g9a218f1 SMP preempt mod_unload modversions ARMv7
__mod_vermagic5
__mod_vermagic5

Any help please... Thx
 
  • Like
Reactions: mirhl

bobthecooldad

Senior Member
May 14, 2010
212
22
0
I don't anderstand

I have exactly the same vermagic

This module load correctly : /system/lib/module/mii.ko
This module don't : /system/lib/kexec_load.ko

strings mii.ko | grep vermagic
vermagic=3.4.0-perf-g66807d4-02450-g9a218f1 SMP preempt mod_unload modversions ARMv7

strings kexec_load.ko | grep vermagic
vermagic=3.4.0-perf-g66807d4-02450-g9a218f1 SMP preempt mod_unload modversions ARMv7
__mod_vermagic5
__mod_vermagic5

Any help please... Thx
Would this help.
http://forum.xda-developers.com/showthread.php?t=2399714&highlight=kexec&page=4
he made it fully working so you could use the files
https://github.com/munjeni/android_kernel_xperiago
 
  • Like
Reactions: Knucklessg1

delewer

Senior Member
Aug 20, 2011
186
233
0
Paris
I have succesfully load one of two needed modules by hacking modules loading process.

First module work :
Code:
# lsmod
procfs_rw 12455 0 - Live 0x00000000 (O)
It's not a vermagic issu, because vermagic is not a "key" to have a synchronisation between kernel and modules, but a signature to be sure the sources used are equals

The keys used are in module himself for each external modules include in kernel... it's "symbols" keys.
I have hack these keys to load module in closed stock kernel.

But i have this last issu to have a fully working kexec :
Code:
kexec_load: Unknown symbol init_mm (err 0)
This dmesg seem that i use a old kexec_load source for 2.6 kernel.

Yougest kernel have a lot of non exported vars, and non exported function.
init_mm is no longuer exported.

I must change the init_mm system.

Here the source :
Code:
void setup_mm_for_reboot(char mode)
{
        unsigned long base_pmdval;
        pgd_t *pgd;
        int i;

        if (current->mm && current->mm->pgd)
                pgd = current->mm->pgd;
        else
                pgd = init_mm.pgd;

        base_pmdval = PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT;

        for (i = 0; i < FIRST_USER_PGD_NR + USER_PTRS_PER_PGD; i++, pgd++) {
                unsigned long pmdval = (i << PGDIR_SHIFT) | base_pmdval;
                pmd_t *pmd;

                pmd = pmd_off(pgd, i << PGDIR_SHIFT);
                pmd[0] = __pmd(pmdval);
                pmd[1] = __pmd(pmdval + (1 << (PGDIR_SHIFT - 1)));
                flush_pmd_entry(pmd);
        }
}
Please, help me to replace "init_mm", or include declaration for this function

My compil speak a lot :
Code:
make
(...)
WARNING: "init_mm" [/home/kernel/kexec-module/kexec_load.ko] undefined!
(...)
I have found how declare struct in DooMLoRD Kernel, but i don't know how use it in a module.

Thx for help. :good:
 
  • Like
Reactions: mirhl

onlyolli

Member
Jan 12, 2012
43
14
0
Hey guys,

i havent done any kernel compiling for android, but i did enough c development and kernel-module compiling on linux to know a bit about it. so i'd like to know, why isn't it just possible to use the original kernel-source provided by sony to compile the required modules and tools against those sources+headers? there shouldn't really be any hacking required, should it?

have a nice weekend, olli
 
  • Like
Reactions: king960

onlyolli

Member
Jan 12, 2012
43
14
0
No I didn't meant to compile and replace the kernel, that wouldn't work,obviously.. I meant, why isn't it possible to use the environment provided by those kernels headers and config to compile the required modules and tools? Or would any other problems arise from doing so?
Modifying source and header files sounds like compiling modules and tools against the wrong kernel version and ssources.
 

delewer

Senior Member
Aug 20, 2011
186
233
0
Paris
No I didn't meant to compile and replace the kernel, that wouldn't work,obviously.. I meant, why isn't it possible to use the environment provided by those kernels headers and config to compile the required modules and tools? Or would any other problems arise from doing so?
Modifying source and header files sounds like compiling modules and tools against the wrong kernel version and ssources.
Because this change anything for modules.

The new compil will have news kallsyms adresses, and modules won't load in memory.

So, Sony kernel or DooMLoRD kernel is the same way for me, except this, i only one kernel to maintain for now. It's a easy way.

The only way to have a loading module in a kernel, is the kernel is compil with option witch grant external module.
It's the same issu that stock kernel won't grant, and won't kexec, because stock kernel don't have any option to be open to community (on locked bootloader of course)
Sony gives sources for unlocked only...

Nota :
"kexec_load.ko" is loaded in memory now. Now i try to converse with.

Edit : "procfs_rw.ko" work
I have a "/proc/atags" now
 

delewer

Senior Member
Aug 20, 2011
186
233
0
Paris
Attempts on Xperia P (sorry IF i noob-ed with this post)

http://forum.xda-developers.com/showthread.php?t=2053466

Sent from my LT22i using xda app-developers app
It's a dead thread.
Because, it's a epic failed (for now).

********

Status of my attempts :

Modules loads : OK for two modules (kexec_load and procfs_rw)
- procfs_rw.ko => create "/proc/atags" => ok, but bad buf... it must be fix (easy part)
- kexec_load.ko => Loaded => ok but, the way to use is "syscall" add for kexec_load function => failed
why ? Because after 2.6 kernel (Z1 have 3.4.0 kernel), syscall_table is read only and had fixed size. So if i attempt to add value (kexec_load in our case), we have kernel panic.

But i have a solution to add function in LKM, is to add a "real" module call.

I have add a "kexec_driver" in "/dev" structure by :
Code:
insmod kexec_load.ko
mknod /dev/kexec_driver c 254 0
(...)
crw-rw-rw- root     root     254,   0 2013-11-11 15:26 kexec_driver
Driver is in alpha stage and highty experimental

To be continue...
 

delewer

Senior Member
Aug 20, 2011
186
233
0
Paris
It would be great, IF this kexec method would be successful :D

Sent from my LT22i using xda app-developers app


I don't know IF... but, kexec tool work..

I have kernel panic at load

Code:
<1>[  264.484778] Unable to handle kernel NULL pointer dereference at virtual address 00000000
<1>[  264.484796] pgd = da184000
<1>[  264.484803] [00000000] *pgd=29353831, *pte=00000000, *ppte=00000000
<0>[  264.484820] Internal error: Oops: 817 [#1] PREEMPT SMP ARM
<4>[  264.484829] Modules linked in: kexec_load(O) wlan(O) adsprpc adsp_loader cfg80211 texfat(PO) hid_sony(O)
<4>[  264.484857] CPU: 0    Tainted: P           O  (3.4.0-perf-g66807d4-02450-g9a218f1 #1)
<4>[  264.484873] PC is at __copy_from_user+0x70/0x3b8
<4>[  264.484881] LR is at 0x0
<4>[  264.484888] pc : [<c0355fd8>]    lr : [<00000000>]    psr: 20000013
<4>[  264.484890] sp : df0fff2c  ip : 00000000  fp : 00000000
<4>[  264.484901] r10: 00000000  r9 : df0fe000  r8 : 00000000
<4>[  264.484909] r7 : 00208000  r6 : 00000002  r5 : 000a8630  r4 : 00000003
<4>[  264.484917] r3 : 00b29858  r2 : 00000660  r1 : b6139020  r0 : 00000000
<4>[  264.484927] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
<4>[  264.484937] Control: 10c5787d  Table: 2258406a  DAC: 00000015
(...)
<0>[  264.485704] Kernel panic - not syncing: Fatal exception
<2>[  264.485715] CPU1: stopping
<4>[  264.485733] [<c010c12c>] (unwind_backtrace+0x0/0x11c) from [<c010abcc>] (handle_IPI+0x110/0x224)
<4>[  264.485749] [<c010abcc>] (handle_IPI+0x110/0x224) from [<c0100574>] (gic_handle_irq+0x104/0x110)
<4>[  264.485768] [<c0100574>] (gic_handle_irq+0x104/0x110) from [<c0857bc0>] (__irq_svc+0x40/0x70)
<4>[  264.485780] Exception stack(0xe1e35e68 to 0xe1e35eb0)
<4>[  264.485789] 5e60:                   e1e35ed4 bf2a047c c0ea6568 00000000 bf2a047c e1e35ed4
<4>[  264.485802] 5e80: e248d780 e50cdbac 00000001 000001ff bf264bac e2b98360 e248da40 e1e35eb0
<4>[  264.485813] 5ea0: bf083ba8 bf1cba08 60000013 ffffffff
<4>[  264.485951] [<c0857bc0>] (__irq_svc+0x40/0x70) from [<bf1cba08>] (wpalIteratorInit+0x98/0xc4 [wlan])
<4>[  264.486066] [<bf1cba08>] (wpalIteratorInit+0x98/0xc4 [wlan]) from [<bf083ba8>] (dxeTXEventHandler+0x4e4/0x6fc [wlan])
<4>[  264.486175] [<bf083ba8>] (dxeTXEventHandler+0x4e4/0x6fc [wlan]) from [<bf083c40>] (dxeTXEventHandler+0x57c/0x6fc [wlan])
<4>[  264.486282] [<bf083c40>] (dxeTXEventHandler+0x57c/0x6fc [wlan]) from [<bf083d3c>] (dxeTXEventHandler+0x678/0x6fc [wlan])
<4>[  264.486390] [<bf083d3c>] (dxeTXEventHandler+0x678/0x6fc [wlan]) from [<bf08458c>] (dxeChannelAllDescDump+0x138/0x3a8 [wlan])
<4>[  264.486499] [<bf08458c>] (dxeChannelAllDescDump+0x138/0x3a8 [wlan]) from [<bf084abc>] (dxeRXEventHandler+0x2c0/0x44c [wlan])
<4>[  264.486617] [<bf084abc>] (dxeRXEventHandler+0x2c0/0x44c [wlan]) from [<bf1977bc>] (VosRXThread+0x344/0x408 [wlan])
<4>[  264.486693] [<bf1977bc>] (VosRXThread+0x344/0x408 [wlan]) from [<c01a9c70>] (kthread+0x84/0x90)
<4>[  264.486712] [<c01a9c70>] (kthread+0x84/0x90) from [<c0106908>] (kernel_thread_exit+0x0/0x8)
<3>[  264.486725] &@[email protected]:*RX_Thread*
<3>[  265.490223] wcnss crash shutdown 0
I thing i have a desynchr with my custom kernel send, and i have a load adress to "null"
 
Last edited:

Olivier

Recognized Developer / Retired Forum Moderator
Nov 6, 2011
2,657
6,885
203
Hi,
I've been monitoring this thread for a few days now and I'm surprised how fast progress is going on. Respect!
One question though: Will this patch make AOSP-based ROMs on LB possible or not?

Gesendet von meinem LT26i mit Tapatalk