datto / dattobd

kernel module for taking block-level snapshots and incremental backups of Linux block devices
GNU General Public License v2.0
573 stars 122 forks source link

X86 specific code failes building on ARM #248

Open bruzzz opened 3 years ago

bruzzz commented 3 years ago

Hi,

I tried to build on an ARM system, but it failed compiling on this line: https://github.com/datto/dattobd/blob/2f2d160d44a7e14337adf7a53ed1133709c45dee/src/dattobd.c#L4879

make[2]: Verzeichnis „/usr/src/linux-headers-4.9.241-arm64“ wird betreten CC [M] dattobd-master/src/dattobd.o dattobd-master/src/dattobd.c: In function 'disable_page_protection': dattobd-master/src/dattobd.c:4879:9: error: implicit declaration of function 'read_cr0'; did you mean 'readsq'? [-Werror=implicit-function-declaration] *cr0 = read_cr0(); ^~~~~~~~ readsq dattobd-master/src/dattobd.c:4880:2: error: implicit declaration of function 'write_cr0'; did you mean 'writesq'? [-Werror=implicit-function-declaration] write_cr0(*cr0 & ~X86_CR0_WP); ^~~~~~~~~ writesq It looks like this code is only intended for x86 systems. Is that right or did I miss installing any libs?

nixomose commented 3 years ago

nope, that's right. I got dattobd working on a raspberry pi a few years ago, and all I had to do was remove that x86 specific stuff. do that and you should be good.

bruzzz commented 3 years ago

Thanks for the hint! But what exactly do you mean by

remove that x86 specific stuff

Simply comment out / delete those lines which the compiler complains about (I think it's 3 in total) or is there anything more?

I actually tried that and the build succeded. I was also able to load the kernel module but looking at dmesg I noticed theese lines:

[ 6.940973] dattobd: loading out-of-tree module taints kernel. [ 6.943974] Unable to handle kernel paging request at virtual address ffffff8009bd2138 :question: [ 6.950544] pgd = ffffff800a891000 [ 6.954103] [ffffff8009bd2138] pgd=00000000cf3fe003, pud=00000000cf3fe003, pmd=00000000cf3fc003, pte=00e0000001bd2793 [ 6.965176] Internal error: Oops: 9600004f [#1] PREEMPT SMP :question: [ 6.970895] Modules linked in: dattobd(O+) sunrpc ip_tables x_tables ipv6 spidev spi_meson_spicc

So I'm wondering if it's something I should worry about?

nixomose commented 3 years ago

okay, so yeah, just comment out the x86 specific lines. that's basically all I did if I remember right, once I got it to compile, it was happy. yes, that's something you should worry about. can you show me which lines you removed, maybe there's something else going on that I don't remember. any time you see oops or BUG!, that's bad. your kernel is probably not stable anymore.

also I did it on a raspi which was 32 bit, so I can't say 100% it will work on 64 bit arm, I never tried it.

bruzzz commented 3 years ago

Only this three lines (4879, 4880 and 4884):

4878 static inline void disable_page_protection(unsigned long cr0) { 4879 // cr0 = read_cr0(); 4880 // write_cr0(cr0 & ~X86_CR0_WP); 4881 } 4882 4883 static inline void reenable_page_protection(unsigned long cr0) { 4884 // write_cr0(*cr0); 4885 }

bruzzz commented 3 years ago

As already mentioned, I was able to build it with these three lines commented out. But it doesn't seem to work on my system (ARMv8). I keep seeing the dmesg messages as mentioned aboth.

I also tried to load the module manually which resulted with the following messages and an unexpected reboot:

# modprobe dattobd

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  767.169269@0] Internal error: Oops: 9600004f [#1] PREEMPT SMP

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  767.934966@0] Process modprobe (pid: 21682, stack limit = 0xffffffc0c85ac000)

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  767.942073@0] Stack: (0xffffffc0c85afc20 to 0xffffffc0c85b0000)

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  767.947968@0] fc20: ffffffc0c85afc50 ffffff8009083944 ffffff8001f6d000 ffffffc0af5d8000

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  767.955941@0] fc40: 0000000000000000 ffffffc0b65fb640 ffffffc0c85afcc0 ffffff80091b976c

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  767.963914@0] fc60: ffffff8001f67080 ffffff800a5a3000 ffffffc0b8a74580 ffffffc0b88a5500

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  767.971887@0] fc80: ffffffc0b8a745c8 0000000000000001 ffffff8001f670d0 ffffff800913f7d8

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  767.979861@0] fca0: ffffff800f71c000 0000000000000124 ffffff800f71c000 0000000000000001

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  767.987834@0] fcc0: ffffffc0c85afcf0 ffffff800914357c ffffffc0c85afe58 0000000000000001

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  767.995807@0] fce0: ffffffc0b8a74580 ffffff8001f67080 ffffffc0c85afe10 ffffff8009143fb0

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.003780@0] fd00: 0000000000000000 0000000000000003 0000005576244640 0000007f7f10ce74

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.011754@0] fd20: 0000000040000000 0000000000000015 0000000000000123 0000000000000111

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.019727@0] fd40: ffffff8009bd2000 ffffffc0af5d8000 00000000fffffffb ffffff8009ef6260

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.027701@0] fd60: ffffff8009ef6250 ffffff800f7d9110 0000000000000064 ffffffc00000006e

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.035674@0] fd80: ffffffc00000003f ffffff800000feff ffffff800a5a38f0 ffffffc0af459988

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.043647@0] fda0: ffffff8009bdb738 ffffff80024000c0 000000007fffffff 0000000000000003

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.051621@0] fdc0: 0000000000000123 ffffff80090b1664 ffffffc0c85afe10 0000000000000000

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.059594@0] fde0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.067567@0] fe00: 0000000000000000 0000000000000000 0000000000000000 ffffff8009083740

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.075541@0] fe20: fffffffffffffeee 00000040c518c000 ffffffffffffffff 0000000000000000

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.083514@0] fe40: ffffffc0c85afe80 00000000000bd1d0 ffffff800f71c000 ffffff800f71c000

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.091487@0] fe60: 00000000000bd1d0 ffffff800f7d8550 ffffff800f7d8380 ffffff800f77b638

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.099460@0] fe80: 000000000000e000 0000000000010e08 0000000000000000 0000000000000000

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.107434@0] fea0: 0000000000005f20 000000300000002f 000000190000001d 0000000000000011

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.115407@0] fec0: 0000000000000003 0000005576244640 0000000000000000 0000000000000003

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.123380@0] fee0: 0000000000000000 0000000000000b81 0000000000000001 0000000000000001

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.131354@0] ff00: 0000000000000111 0000000000000000 0000000000000000 0000000000000000

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.139327@0] ff20: 000000558ee80d10 0000000000000000 0000000000000000 0000000000000002

Message from syslogd@as at Feb  8 15:54:56 ...
 kernel:[  768.147301@0] ff40: 000000557625bdb0 0000007f7f10ce50 000000000000002f 000000558ee80b60

The first message looks to me identical to what I see in dmesg.

Any further ideas?

When performing dbdctl I'm getting the following:

# dbdctl setup-snapshot /dev/mmcblk0 /mnt/backups/datto/.datto 0
driver returned an error performing specified action. check dmesg for more info: Invalid argument

dmesg:

[ 1301.551833] fuse init (API version 7.26)
[ 2201.582784] datto: illegal to perform setup while unmounted: -22
[ 2201.583326] datto: error during setup ioctl handler: -22
nixomose commented 3 years ago

trying commenting out all references to preempt_disable(); and preempt_enable();

oracleloyall commented 3 years ago

If you want to solve some problems of the ARM platform, please contact me at oracleloyal@gmail.com.