linux 内核 4.9安装vmware12报错的解决方案
Tofloor
poster avatar
mmseh
deepin
2017-05-18 22:35
Author
本帖最后由 mmseh 于 2017-5-18 16:20 编辑

deepin内核升到了4.9
安装vmware,启动时提示异常
提示查看日志文件
/tmp/vmware-root/vmware-19482.log
发现是编译vmnet.o模块时出错,错误信息如下
  1. /tmp/modconfig-4UP6CG/vmnet-only/userif.c:117:43:
  2. error: passing argument 5 of ‘get_user_pages’
  3. from incompatible pointer type [-Werror=incompatible-pointer-types]retval = get_user_pages(addr, 1, 1, 0, &page, NULL);^In file included
  4. from /usr/src/linux-headers-4.9.0-deepin4-common/include/linux/highmem.h:7:0,
  5. from /tmp/modconfig-4UP6CG/vmnet-only/userif.c:26:
Copy the Code


查看userif.c文件
发现错误位置代码如下
  1. #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
  2. retval = get_user_pages(addr, 1, 1, 0, &page, NULL);
  3. #else
  4. retval = get_user_pages(current, current->mm, addr,
  5. 1, 1, 0, &page, NULL);
Copy the Code


在/usr/src/linux-headers-4.9.0-deepin4-common/include/linux/mm.h
中找到get_user_pages的定义
  1. long get_user_pages(unsigned long start, unsigned long nr_pages,unsigned int gup_flags, struct page **pages,struct vm_area_struct **vmas);
Copy the Code

参数个数果然和userif.c里面的不一致
难道是linux内核修改了?
根据userif.c里语法的意思,下载了4.6的头文件查看mm.h
发现其定义如下
  1. long get_user_pages(unsigned long start, unsigned long nr_pages,int write, int force, struct page **pages,struct vm_area_struct **vmas);
Copy the Code

果然是改了函数定义
上github看了下变更信息,发现是在4.9中将write与force合并成一个参数了
增加了宏
#define FOLL_WRITE        0x01
#define FOLL_FORCE        0x10
来用与运算得到这两个参数
所以修改userif.c中的相关语句为
  1. #if   LINUX_VERSION_CODE>= KERNEL_VERSION(4, 9, 0)
  2.    retval = get_user_pages(addr, 1, 1, &page, NULL);
  3. #elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
  4.    retval = get_user_pages(addr, 1, 1, 0, &page, NULL);
  5. #else
  6.    retval = get_user_pages(current, current->mm, addr,
  7.                            1, 1, 0, &page, NULL);
  8. #endif
Copy the Code


再次编译后执行vmware
成功执行!





Reply Favorite View the author
All Replies
avatar
comzhong
deepin
2017-05-18 22:56
#1
活捉大神一枚
Reply View the author
avatar
泳衡
deepin
2017-05-18 23:27
#2
羡慕。。。。。。。能折腾。
Reply View the author
avatar
要讲武德
deepin
2017-05-19 01:02
#3
我只能 666
Reply View the author
avatar
139******41
deepin
2017-05-19 01:02
#4
好像没问题呀
我的
Reply View the author