VMware Player(14.1.1)在 clang 构建的内核和 clang 构建的 VMware 内核模块上出现段错误

VMware Player(14.1.1)在 clang 构建的内核和 clang 构建的 VMware 内核模块上出现段错误

作为我对不同 clang-built 内核版本的 clang/LLVM 实验和探索的一部分,我尝试在 Ubuntu 17.10 x86_64 上使用 clang-built VMware 内核模块(vmmonvmnet)在 clang-built 主机内核 4.16(截至目前的最新稳定版本)上安装 VMware Player 14.1.1(x86_64)。

问题

当我使用 安装 VMware Player 14.1.1 时VMware-Player-14.1.1-7528167.x86_64.bundle。GUI 安装程序显示“安装成功...”。但是,当我尝试vmplayer从命令行运行时,它导致了段错误/崩溃:

Segmentation fault (core dumped)
  "$BINDIR"/vmware-modconfig --appname="VMware Player" --icon="vmware-player"

目前尚不清楚究竟出了什么问题 - 是某些安装程序的内部静默失败而被忽视,还是内核模块未成功构建/安装/加载,或者是 VMware Player 与底层主机 clang 构建的内核(而非 gcc 构建的内核)存在兼容性问题。

因此,我手动构建了vmmonvmnet使用/usr/lib/vmware/modules/source/(vmmon|vmnet).tarclang/LLVM 编译器,因为主机Linux kernel 4.16.0也是用 clang 构建的。成功构建、安装并加载它们并验证它们是否正确加载(lsmod等)后,我重新运行了该vmplayer命令 - 它再次失败,并出现与上面相同的段错误。

$ cat /proc/version 
Linux version 4.16.0 (exp@exp) (clang version 5.0.0-3 (tags/RELEASE_500/final)) #4 SMP Thu Apr 5 02:12:22 PDT 2018

$ lsmod | grep "vmnet\|vmmon"
vmnet                  53248  13 
vmmon                  90112  0 

$ vmplayer --version
.
.
VMware Player 14.1.1 build-7528167

$ vmplayer 
+ /usr/bin/vmware-modconfig '--appname=VMware Player' --icon=vmware-player
/usr/bin/vmplayer: line 109:  1467 Segmentation fault      (core dumped) "$BINDIR"/vmware-modconfig --appname="VMware Player" --icon="vmware-player"
+ exit 1

我之前关于成功提出clang-builtUbuntu 17.10 x86_64 内核以及 clang 构建的 Nvidia 驱动程序(v390.25、v390.42 等)的报告,请参阅:如何在 Ubuntu 17.10 x86_64 上使用 LLVM/clang 和 Nvidia 390.25 x86_64 驱动程序构建 4.15.7 内核?

答案1

阶段1 :我尝试使用gdbinvidually 和 vmware-config/vmplayer 二进制文件来查看其代码中的故障点。gdb在和上运行/usr/bin/vmware-config/usr/bin/vmplayer无用的,因为它们只是脚本,并且直接在二进制对应程序上运行:gdb --args /usr/lib/vmware/bin/vmware-modconfig --appname="VMware Player" --icon="vmware-player"gdb /usr/lib/vmware/bin/vmplayer,也没有导致任何段错误/崩溃。

因此,我必须在 gdb/usr/bin/vmware-config启动时将其作为其自身的一部分来调用/usr/lib/vmware/bin/vmware-modconfig --appname="VMware Player" --icon="vmware-player"。这很有效,我看到ModConf_NewKernelInfo()withinlibvmware-modconfig.so正在尝试获取当前内核版本信息,在执行此操作或获取版本信息后解析版本信息时,它发生了段错误。

$ vmplayer
GNU gdb (Ubuntu 8.0.1-0ubuntu1) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/lib/vmware/bin/vmware-modconfig...(no debugging symbols found)...done.
(gdb) r
Starting program: /usr/lib/vmware/bin/vmware-modconfig --launcher=/usr/bin/vmware-modconfig --appname=VMware Player --icon=vmware-player
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
process 24600 is executing new program: /usr/lib/vmware/bin/appLoader
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe4b15700 (LWP 24633)]
[New Thread 0x7fffdffff700 (LWP 24634)]

Thread 1 "vmware-modconfi" received signal SIGSEGV, Segmentation fault.
0x00007ffff73312e8 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007ffff73312e8 in  () at /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff674d72b in ModConf_NewKernelInfo () at /usr/lib/vmware/lib/libvmware-modconfig.so/libvmware-modconfig.so
#2  0x00007ffff6749540 in main () at /usr/lib/vmware/lib/libvmware-modconfig.so/libvmware-modconfig.so
#3  0x000055555556db6b in  ()
#4  0x0000555555569fd7 in main ()

第二阶段:我使用strace进一步vmware-modconfig了解导致崩溃的内核版本检索/解析。结果发现,上述崩溃很可能与 的内容解析有关/proc/version

$ strace /usr/bin/vmware-modconfig --appname="VMware Player" --icon="vmware-player" 2>&1 | tail
write(10, "2018-04-07T00:16:17.901-07:00| v"..., 89) = 89
openat(AT_FDCWD, "/proc/version", O_RDONLY) = 11
fstat(11, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
fcntl(11, F_GETFL)                      = 0x8000 (flags O_RDONLY|O_LARGEFILE)
fstat(11, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(11, "Linux version 4.16.0 (exp@exp) (clan"..., 4096) = 111
read(11, "", 3072)                      = 0
close(11)                               = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV (core dumped) +++

$ cat /tmp/vmware-g/vmware-17594.log 
2018-04-07T00:16:17.768-07:00| vthread-1| I125: Log for VMware Workstation pid=17594 version=14.1.1 build=build-7528167 option=Release
2018-04-07T00:16:17.768-07:00| vthread-1| I125: The process is 64-bit.
2018-04-07T00:16:17.768-07:00| vthread-1| I125: Host codepage=UTF-8 encoding=UTF-8
2018-04-07T00:16:17.768-07:00| vthread-1| I125: Host is Linux 4.16.0 Ubuntu 17.10
2018-04-07T00:16:17.768-07:00| vthread-1| I125: DictionaryLoad: Cannot open file "/usr/lib/vmware/settings": No such file or directory.
2018-04-07T00:16:17.768-07:00| vthread-1| I125: [msg.dictionary.load.openFailed] Cannot open file "/usr/lib/vmware/settings": No such file or directory.
2018-04-07T00:16:17.768-07:00| vthread-1| I125: PREF Optional preferences file not found at /usr/lib/vmware/settings. Using default values.
2018-04-07T00:16:17.768-07:00| vthread-1| I125: DictionaryLoad: Cannot open file "/home/g/.vmware/config": No such file or directory.
2018-04-07T00:16:17.768-07:00| vthread-1| I125: [msg.dictionary.load.openFailed] Cannot open file "/home/g/.vmware/config": No such file or directory.
2018-04-07T00:16:17.768-07:00| vthread-1| I125: PREF Optional preferences file not found at /home/g/.vmware/config. Using default values.
2018-04-07T00:16:17.813-07:00| vthread-1| W115: Logging to /tmp/vmware-g/vmware-17594.log
2018-04-07T00:16:17.901-07:00| vthread-1| I125: Obtaining info using the running kernel.

第三阶段:在查看了上述阶段的stracegdb具体信息后,我想到运行通常建议的方法vmware-modconfig --console --install-all来修复任何 VMware 内核模块问题,因为我没有的源代码来/usr/lib/vmware/lib/libvmware-modconfig.so/libvmware-modconfig.so进一步调试以查找内核版本信息(/proc/version等)中的确定和解析方法ModConf_NewKernelInfo()libvmware-modconfig.so正如我所料,它发生了段错误,因为它涉及相同的vmware-modconfig*

$ sudo vmware-modconfig --console --install-all
[AppLoader] GLib does not have GSettings support.
Segmentation fault

第四阶段:更进一步,我花了一些时间研究 的输出cat /proc/version- 我注意到的一件事是用于构建内核的编译器的编译器信息。那是一针见血的时刻!我了解到 VMware Player 配置/脚本可能假设底层主机 Linux 内核是使用某个gcc-*版本的编译器构建的,并期望 的输出cat /proc/version有一些gcc ...,如果它没有找到(在这种情况下,这是clang...用于构建主机内核的编译器),它似乎不会报告任何错误/警告,而只是段错误 - 可能是由于NULL(从 的输出substring搜索)取消引用。cat /proc/versiongcc...

以下似乎是在vmware-modconfig和/或内部程序/脚本中发生的事情:

## My visualization of crash(SIGSEGV) case when compiler used to build kernel is clang-*/LLVM :
##
## == Likely a dereferencing of NULL similar to the below case ==

const char *gcc_ver = strstr("Linux version 4.16.0 (exp@exp) (clang version 5.0.0-3 (tags/RELEASE_500/final)) #4 SMP Thu Apr 5 02:12:22 PDT 2018", "gcc...");
if (strcmp(gcc_ver, "gcc...") == 0) { // Here, there's no check on gcc_ver to be
                                       // non-NULL - since it's likely that the compiler used to build the kernel
                       // is *assumed* to be always some gcc and so on. Probably, it's not designed to work
                       // work with clang/LLVM if the compiler used to build kernel is clang/LLVM.
         .
         .
         .
         .
}

##
##  My visualization of working case when compiler used to build kernel is gcc-* :
##

const char *gcc_ver = strstr("Linux version 4.16.0 (exp@exp) (gcc version 7.3.0 (Ubuntu 7.3.0-8ubuntu3)) #4 SMP Thu Apr 5 02:12:22 PDT 2018", "gcc...");
if (strcmp(gcc_ver, "gcc...") == 0) { // Works as always
         .
         .
         .
         .
}

第六阶段:为了检查 VMware Player 配置脚本,修改为基于Linux 编译器(用于构建当前内核)而不是实际用于构建当前内核(4.16)的编译器linux-4.16/fs/proc/version.c进行报告。这导致调用超过了发生段错误的点,否则由于编译器信息GCC 7.3.0*need*4.16clang/LLVMvmplayer/proc/version 不是但特定于gcc-specificclang!这证实了我对 VMware Player 配置/脚本的理解和解释无法将 clang 编译器信息正确地转换为/proc/version用于构建底层主机内核的实际 clang/LLVM 编译器,因此导致意外的SIGSEGV/segfault。

$ eclang /lib/modules/4.16.0/build/vmlinux | head -1
++ strings -a /lib/modules/4.16.0/build/vmlinux
++ grep 'clang version'
Linux version 4.16.0 (exp@exp) (clang version 5.0.0-3 (tags/RELEASE_500/final)) #4 SMP Thu Apr 5 02:12:22 PDT 2018

$ egcc /lib/modules/4.16.0/build/vmlinux 
++ strings -a /lib/modules/4.16.0/build/vmlinux
++ grep 'GCC: ('


###
### [procfs] - version logic updated.
###

$ cat /proc/version 
Linux version 4.16.0 (exp@exp) (gcc version 7.3.0 (Ubuntu 7.3.0-8ubuntu3)) #4 SMP Thu Apr 5 02:12:22 PDT 2018

$ strace /usr/bin/vmware-modconfig --appname="VMware Player" --icon="vmware-player" 2>&1 | grep -A 40 -B 1 "/proc/version"
write(10, "2018-04-07T00:37:09.944-07:00| v"..., 89) = 89
openat(AT_FDCWD, "/proc/version", O_RDONLY) = 11
fstat(11, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
fcntl(11, F_GETFL)                      = 0x8000 (flags O_RDONLY|O_LARGEFILE)
fstat(11, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(11, "Linux version 4.16.0 (exp@exp) (gcc "..., 4096) = 106
read(11, "", 3072)                      = 0
close(11)                               = 0
write(10, "2018-04-07T00:37:09.944-07:00| v"..., 71) = 71
access("/sbin/gcc-7.3", X_OK)           = -1 ENOENT (No such file or directory)
access("/home/g/CodeSourcery/Sourcery_G++_Lite/bin/gcc-7.3", X_OK) = -1 ENOENT (No such file or directory)
access("/home/g/bin/gcc-7.3", X_OK)     = -1 ENOENT (No such file or directory)
access("/home/g/.local/bin/gcc-7.3", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/sbin/gcc-7.3", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/bin/gcc-7.3", X_OK)  = -1 ENOENT (No such file or directory)
access("/usr/sbin/gcc-7.3", X_OK)       = -1 ENOENT (No such file or directory)
access("/usr/bin/gcc-7.3", X_OK)        = -1 ENOENT (No such file or directory)
access("/sbin/gcc-7.3", X_OK)           = -1 ENOENT (No such file or directory)
access("/bin/gcc-7.3", X_OK)            = -1 ENOENT (No such file or directory)
access("/usr/games/gcc-7.3", X_OK)      = -1 ENOENT (No such file or directory)
access("/usr/local/games/gcc-7.3", X_OK) = -1 ENOENT (No such file or directory)
access("/snap/bin/gcc-7.3", X_OK)       = -1 ENOENT (No such file or directory)
access("/usr/lib/jvm/java-8-oracle/bin/gcc-7.3", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/jvm/java-8-oracle/db/bin/gcc-7.3", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/jvm/java-8-oracle/jre/bin/gcc-7.3", X_OK) = -1 ENOENT (No such file or directory)
access("/sbin/gcc-7", X_OK)             = -1 ENOENT (No such file or directory)
access("/home/g/CodeSourcery/Sourcery_G++_Lite/bin/gcc-7", X_OK) = -1 ENOENT (No such file or directory)
access("/home/g/bin/gcc-7", X_OK)       = -1 ENOENT (No such file or directory)
access("/home/g/.local/bin/gcc-7", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/sbin/gcc-7", X_OK)   = -1 ENOENT (No such file or directory)
access("/usr/local/bin/gcc-7", X_OK)    = -1 ENOENT (No such file or directory)
access("/usr/sbin/gcc-7", X_OK)         = -1 ENOENT (No such file or directory)
access("/usr/bin/gcc-7", X_OK)          = 0
getuid()                                = 1000
stat("/usr/bin/gcc-7", {st_mode=S_IFREG|0755, st_size=287, ...}) = 0
access("/usr/bin/gcc-7", X_OK)          = 0
getuid()                                = 1000
write(10, "2018-04-07T00:37:09.944-07:00| v"..., 119) = 119

第六阶段:通过上述更新/proc/versionfs/proc/version.c)以显示 gcc-* *need*vmplayer将不再出现段错误/崩溃 - 但是,正在使用gcc(7.3.0)构建 VMware 内核模块(vmnetvmmon),of course "expected"因为这就是其中的内容/proc/version- 我做到了不是想要这个 - 我想要clang/LLVM它能用于构建 VMware 内核模块,就像我对其他内核模块(Nvidia 驱动程序、VirtualBox 等)所做的一样,这些模块运行正常,没有任何问题。简而言之,我希望底层内核和所有内核模块都由 clang/LLVM 构建,并且不是 gcc

我观察到 VMware 配置脚本使用确定的编译器执行预处理器检查(gcc-7.3.0在本例中)并且该命令如下所示:

/usr/bin/gcc-7 -E -I/lib/modules/4.16.0/build/include - .... 

一旦完成并成功,它就会继续检查是否需要构建VMware kernel modules-vmnet并且vmmon

第七阶段:手动 VMware 内核模块(来自源代码:vmmon.tarvmnet.tar)可以用 clang/LLVM 构建,我已经构建了它们(带有hostif.cvmmon-only)和bridge.cvmnet-only)所需的任何补丁),安装并通过/usr/lib/vmware/bin/vmplayer直接调用使用了它们,没有任何问题。但是,当通过vmplayer或单击应用程序菜单/列表中的 VMware Player 图标来调用 VMware Player 时,vmware-modconfig会对用于构建当前内核的编译器及其版本执行检查,然后检查是否构建和加载了 VMware 内核模块,然后最终启动。如果编译器(如图所示)不是如上所示,vmplayer则编译器检查vmware-modconfig似乎不起作用。/proc/versionclang/LLVMgcc

$ ~/vmware_modules_compiler.sh
++ eclang /lib/modules/4.16.0/misc/vmmon.ko
++ head -1
+++ strings -a /lib/modules/4.16.0/misc/vmmon.ko
+++ grep 'clang version'
clang version 5.0.0-3 (tags/RELEASE_500/final)
++ eclang /lib/modules/4.16.0/misc/vmnet.ko
++ head -1
+++ strings -a /lib/modules/4.16.0/misc/vmnet.ko
+++ grep 'clang version'
clang version 5.0.0-3 (tags/RELEASE_500/final)

$ ~/vmware_modules_metadata.sh 
++ strings -a /lib/modules/4.16.0/misc/vmnet.ko
++ grep VMware
author=VMware, Inc.
description=VMware Virtual Networking Driver.
++ strings -a /lib/modules/4.16.0/misc/vmmon.ko
++ grep VMware
author=VMware, Inc.
description=VMware Virtual Machine Monitor.

$ lsmod | grep "vmnet\|vmmon"
vmnet                  53248  13 
vmmon                  90112  0 

第八阶段:通过以上了解 VMware 配置/脚本如何preprocessor check在确定编译器的情况下执行初始操作gcc-7(.3.0)以及后续调用如何构建内核模块,我通过脚本/程序VMware研究了两个实例的编译器调用逻辑:vmware-modconfig

  1. 首先"preprocessor check"使用实际的 gcc (7.3.0) 编译器本身执行。
  2. 其次,对于所有后续使用 clang/LLVM 而不是 gcc 7.3.0 的编译器调用,让 VMware 内核模块像底层主机内核一样使用 clang/LLVM 本身构建。

第九阶段:这样,我就能使用 clang 构建的(通过安装程序本身)VMware 内核模块在底层主机 clang 构建的 Linux 4.16.0 内核上完全自动化整个 VMware Player 的安装、首次调用、配置和整体设置。

## Compact log of VMware kernel modules built using clang/LLVM instead of gcc, automatically by vmware-* config/scripts
##

## NOTE : Needed to run "vmplayer" as root(sudo) for (only) the first time for building kernel modules and install them.
## Normal user mode didn't go beyond the start of "VMware kernel modules build..." step.

$ sudo vmplayer 
Stopping VMware services:
   VMware Authentication Daemon                                        done
   VM communication interface socket family                            done
   Virtual machine communication interface                             done
   Virtual machine monitor                                             done
   Blocking file system                                                done
make: Entering directory '/tmp/modconfig-sImz9k/vmmon-only'
Using kernel build system.
/usr/bin/make -C /lib/modules/4.16.0/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
  MODULEBUILDDIR= modules
make[1]: Entering directory '/media/exp/ext/linux-4.16'
+ /usr/bin/clang -print-file-name=include
  CC [M]  /tmp/modconfig-sImz9k/vmmon-only/linux/driverLog.o
    .
    .
++ /usr/bin/clang -Wp,-MD,/tmp/modconfig-sImz9k/vmmon-only/linux/.hostif.o.d -nostdinc -isystem /usr/lib/llvm-5.0/lib/clang/5.0.0/include -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -DCONFIG_CC_STACKPROTECTOR -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -mno-80387 -mstack-alignment=8 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -O2 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-const-variable -g -gdwarf-4 -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fno-merge-all-constants -fno-stack-check -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Wall -Wstrict-prototypes -DVMW_USING_KBUILD -DVMMON -DVMCORE -I/tmp/modconfig-sImz9k/vmmon-only/./include -I/tmp/modconfig-sImz9k/vmmon-only/./common -I/tmp/modconfig-sImz9k/vmmon-only/./linux -I/tmp/modconfig-sImz9k/vmmon-only/./vmcore -DMODULE '-DKBUILD_BASENAME="hostif"' '-DKBUILD_MODNAME="vmmon"' -c -o /tmp/modconfig-sImz9k/vmmon-only/linux/.tmp_hostif.o /tmp/modconfig-sImz9k/vmmon-only/linux/hostif.c
    .
    .
    .
    .
    .
    .
 LD [M]  /tmp/modconfig-sImz9k/vmmon-only/vmmon.ko
make[1]: Leaving directory '/media/exp/ext/linux-4.16'
/usr/bin/make -C $PWD SRCROOT=$PWD/. \
  MODULEBUILDDIR= postbuild
make[1]: Entering directory '/tmp/modconfig-sImz9k/vmmon-only'
make[1]: 'postbuild' is up to date.
make[1]: Leaving directory '/tmp/modconfig-sImz9k/vmmon-only'
cp -f vmmon.ko ./../vmmon.o
make: Leaving directory '/tmp/modconfig-sImz9k/vmmon-only'
make: Entering directory '/tmp/modconfig-sImz9k/vmnet-only'
Using kernel build system.
/usr/bin/make -C /lib/modules/4.16.0/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
  MODULEBUILDDIR= modules
make[1]: Entering directory '/media/exp/ext/linux-4.16'
+ /usr/bin/clang -print-file-name=include
  CC [M]  /tmp/modconfig-sImz9k/vmnet-only/driver.o
    .
    .
    .
++ /usr/bin/clang -Wp,-MD,/tmp/modconfig-sImz9k/vmnet-only/.bridge.o.d -nostdinc -isystem /usr/lib/llvm-5.0/lib/clang/5.0.0/include -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -DCONFIG_CC_STACKPROTECTOR -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -mno-80387 -mstack-alignment=8 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -O2 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-const-variable -g -gdwarf-4 -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fno-merge-all-constants -fno-stack-check -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Wall -Wstrict-prototypes -DVMW_USING_KBUILD -I/tmp/modconfig-sImz9k/vmnet-only/. -DVMW_NETIF_TRANS_UPDATE -DMODULE '-DKBUILD_BASENAME="bridge"' '-DKBUILD_MODNAME="vmnet"' -c -o /tmp/modconfig-sImz9k/vmnet-only/.tmp_bridge.o /tmp/modconfig-sImz9k/vmnet-only/bridge.c
    .
    .
    .
    .
    .
    .
  LD [M]  /tmp/modconfig-sImz9k/vmnet-only/vmnet.ko
make[1]: Leaving directory '/media/exp/ext/linux-4.16'
/usr/bin/make -C $PWD SRCROOT=$PWD/. \
  MODULEBUILDDIR= postbuild
make[1]: Entering directory '/tmp/modconfig-sImz9k/vmnet-only'
make[1]: 'postbuild' is up to date.
make[1]: Leaving directory '/tmp/modconfig-sImz9k/vmnet-only'
cp -f vmnet.ko ./../vmnet.o
make: Leaving directory '/tmp/modconfig-sImz9k/vmnet-only'
Starting VMware services:
   Virtual machine monitor                                             done
   Virtual machine communication interface                             done
   VM communication interface socket family                            done
   Blocking file system                                                done
   Virtual ethernet                                                    done
   VMware Authentication Daemon                                        done
   Shared Memory Available                                             done
.
. 


$  ls -lrt /lib/modules/4.16.0/misc/vm*.ko
-rw-r--r-- 1 root root 2597952 Apr  7 01:55 /lib/modules/4.16.0/misc/vmmon.ko
-rw-r--r-- 1 root root 2614432 Apr  7 01:55 /lib/modules/4.16.0/misc/vmnet.ko

$ ~/vmware_modules_compiler.sh 
++ eclang /lib/modules/4.16.0/misc/vmmon.ko
++ head -1
+++ strings -a /lib/modules/4.16.0/misc/vmmon.ko
+++ grep 'clang version'
clang version 5.0.0-3 (tags/RELEASE_500/final)
++ eclang /lib/modules/4.16.0/misc/vmnet.ko
++ head -1
+++ strings -a /lib/modules/4.16.0/misc/vmnet.ko
+++ grep 'clang version'
clang version 5.0.0-3 (tags/RELEASE_500/final)

$ ~/vmware_modules_metadata.sh 
++ strings -a /lib/modules/4.16.0/misc/vmnet.ko
++ grep VMware
author=VMware, Inc.
description=VMware Virtual Networking Driver.
++ strings -a /lib/modules/4.16.0/misc/vmmon.ko
++ grep VMware
author=VMware, Inc.
description=VMware Virtual Machine Monitor.

##
## Subsequent invocation of "vmplayer" as usual(without any root/sudo usage).
##

$ vmplayer 
+ /usr/bin/vmware-modconfig '--appname=VMware Player' --icon=vmware-player
+ vmware_module_exists vmmon
+ modalias=vmmon
+ /sbin/modprobe -n vmmon
+ set +x

$ vmplayer --version
.
.
VMware Player 14.1.1 build-7528167

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 17.10
Release:    17.10
Codename:   artful

完成以上所有步骤后,安装 VMware Player 版本:

VMWare Player 信息

VMware Player 客户机 - Ubuntu 17.10 x86_64 - 在安装的 VMware Player 中成功运行:

终端截图

相关内容