minosproject / minos

Flexible Virtualization Solution for Embedded System
http://minosproject.org
GNU General Public License v2.0
247 stars 92 forks source link

How to build minos driver to kernel #59

Closed InfluencerNGZK closed 2 years ago

InfluencerNGZK commented 2 years ago

请问如何完成这一步,我使用的是树莓派3B+

The Minos kernel driver is under ${MINOS_SRC}/generic/minos-linux-driver, copy or link this folder to your kernel source tree and build this driver to kernel.

linux kernel源码从这里获得 目前将其添加到/linux-1.20210805/driver目录下编译会报如下的错误

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image -j8
  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      drivers/minos-linux-driver/minos.o
  CC      drivers/minos-linux-driver/vmbox/vmbox_veth.o
drivers/minos-linux-driver/vmbox/vmbox_veth.c:203:21: error: initialization of ‘void (*)(struct net_device *, unsigned int)’ from incompatible pointer type ‘void (*)(struct net_device *)’ [-Werror=incompatible-pointer-types]
  203 |  .ndo_tx_timeout  = vmbox_veth_timeout,
      |                     ^~~~~~~~~~~~~~~~~~
drivers/minos-linux-driver/vmbox/vmbox_veth.c:203:21: note: (near initialization for ‘vmbox_netdev_ops.ndo_tx_timeout’)
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:280: drivers/minos-linux-driver/vmbox/vmbox_veth.o] Error 1
make[2]: *** [scripts/Makefile.build:497: drivers/minos-linux-driver/vmbox] Error 2
make[2]: *** Waiting for unfinished jobs....
drivers/minos-linux-driver/minos.c: In function ‘vm_dev_free’:
drivers/minos-linux-driver/minos.c:208:3: error: implicit declaration of function ‘mmu_notifier_unregister’; did you mean ‘fib_notifier_ops_unregister’? [-Werror=implicit-function-declaration]
  208 |   mmu_notifier_unregister(&vm->mmu_notifier, vm->mm);
      |   ^~~~~~~~~~~~~~~~~~~~~~~
      |   fib_notifier_ops_unregister
drivers/minos-linux-driver/minos.c: In function ‘mvm_zap_pud_range’:
drivers/minos-linux-driver/minos.c:854:19: error: passing argument 1 of ‘pud_offset’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  854 |  pud = pud_offset(pgd, addr);
      |                   ^~~
      |                   |
      |                   pgd_t *
In file included from ./arch/arm64/include/asm/pgtable-types.h:50,
                 from ./arch/arm64/include/asm/kasan.h:9,
                 from ./arch/arm64/include/asm/processor.h:36,
                 from ./include/linux/rcupdate.h:30,
                 from ./include/linux/rculist.h:11,
                 from ./include/linux/pid.h:5,
                 from ./include/linux/sched.h:14,
                 from ./arch/arm64/include/asm/compat.h:16,
                 from ./arch/arm64/include/asm/stat.h:13,
                 from ./include/linux/stat.h:6,
                 from ./include/linux/module.h:13,
                 from drivers/minos-linux-driver/minos.c:17:
./include/asm-generic/pgtable-nopud.h:42:40: note: expected ‘p4d_t *’ but argument is of type ‘pgd_t *’
   42 | static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
      |                                 ~~~~~~~^~~
drivers/minos-linux-driver/minos.c: At top level:
drivers/minos-linux-driver/minos.c:947:28: error: initialization of ‘int (*)(struct mmu_notifier *, const struct mmu_notifier_range *)’ from incompatible pointer type ‘int (*)(struct mmu_notifier *, struct mm_struct *, long unsigned int,  long unsigned int,  bool)’ {aka ‘int (*)(struct mmu_notifier *, struct mm_struct *, long unsigned int,  long unsigned int,  _Bool)’} [-Werror=incompatible-pointer-types]
  947 |  .invalidate_range_start = mvm_invalidate_range_start,
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/minos-linux-driver/minos.c:947:28: note: (near initialization for ‘mvm_mmu_notifier_ops.invalidate_range_start’)
drivers/minos-linux-driver/minos.c: In function ‘create_new_vm’:
drivers/minos-linux-driver/minos.c:979:2: error: implicit declaration of function ‘mmu_notifier_register’; did you mean ‘mmu_notifier_release’? [-Werror=implicit-function-declaration]
  979 |  mmu_notifier_register(&vm->mmu_notifier, vm->mm);
      |  ^~~~~~~~~~~~~~~~~~~~~
      |  mmu_notifier_release
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:280: drivers/minos-linux-driver/minos.o] Error 1
make[1]: *** [scripts/Makefile.build:497: drivers/minos-linux-driver] Error 2
make: *** [Makefile:1824: drivers] Error 2
lemin9538 commented 2 years ago

当前linux驱动驱动只测试过 linux-4.19.238 这个内核版本。用这个内核试试。 其他内核需要移植。

InfluencerNGZK commented 2 years ago

感谢您的回复,请问您测试的这个版本的Linux源码是从哪里获取的,可否提供链接。 另外将minos-linux-driverbuild到linux kernel中这一步可否提供具体的步骤。

InfluencerNGZK commented 2 years ago

感谢您的回复,请问您测试的这个版本的Linux源码是从哪里获取的,可否提供链接。 另外将minos-linux-driverbuild到linux kernel中这一步可否提供具体的步骤。

目前我是将minos-linux-driver目录拷贝到/linux/drivers目录下并修改/linux目录下的Makefile和Kconfig文件执行编译,不知是否正确

lemin9538 commented 2 years ago

这种方法没有问题。但是这个版本的minos代码没有在rpi-b上测试过, 你要用之前的版本,或者自己调试。

https://www.linuxcompatible.org/story/linux-kernel-419238-released/

InfluencerNGZK commented 2 years ago

再次请教您,要使用之前版本的话文档里提到的minos-linux-driver链接目前处于失效状态,请问该链接对应的目录与v0.4版本的minos-linux-driver是一样的么,若不是可否方便提供旧版的链接

lemin9538 commented 2 years ago

https://github.com/minosproject/linux-raspberry.git minos-rpi3分支

InfluencerNGZK commented 2 years ago

感谢您的解答:)