编译外部模块,对正在运行的内核 [英] Build external modules against a running kernel

查看:676
本文介绍了编译外部模块,对正在运行的内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立一个Ubuntu的服务器最新的Linux加密驱动程序。 Ubuntu的服务器已安装运行的内核,演员和头文件。但是,源$ C ​​$ C的加密模块从托伐的GitHub上(而不是Ubuntu的)来了。<​​/ P>

我也从内核文档大厦外部模块工作。
我克隆了最新的内核:

  git的克隆--depth = 1 https://github.com/torvalds/linux.git

然后:

 光盘的Linux

下一页:

  $做出-C /usr/src/linux-headers-4.2.0-34 M = $ PWD加密
令:进入目录/usr/src/linux-headers-4.2.0-34  错误:内核配置无效。
         包括/生成/ autoconf.h或包含/配置/ auto.conf失踪。
         运行'使oldconfig这个&放大器;&安培;使内核SRC prepare来修复它。令:为加密做什么也没有。
使:离开目录/usr/src/linux-headers-4.2.0-34

  $查找/ usr / src目录-nameautoconf.h
/usr/src/linux-headers-4.2.0-34-generic/include/generated/autoconf.h
$查找/ usr / src目录-name'auto.conf
/usr/src/linux-headers-4.2.0-34-generic/include/config/auto.conf

和这样的:

  $查找/ usr / src目录型ð-name'打造'
/usr/src/linux-headers-4.2.0-34/tool​​s/build
/usr/src/linux-headers-4.2.0-34-generic/include/config/build

尝试使用构建目录结果如下:

  $做出-C /usr/src/linux-headers-4.2.0-34/tool​​s/build M = $ PWD加密
令:进入目录/usr/src/linux-headers-4.2.0-34/tool​​s/build
使:***没有规则,使目标加密。停止。
使:离开目录/usr/src/linux-headers-4.2.0-34/tool​​s/build

我显然缺少明显的东西。这并不奇怪,因为我知道接下来一无所知的kbuild。我在 / usr / src目录一个现有的配置和来源,以及我在 $ PWD /加密新文件。它不清楚我为什么我生成现有配置的新配置。

如何更新内核加密模块对他人提供的正在运行的内核?


解决方案

其实这里有两件事是有关心:

是正在运行的内核版本是相同的是,我们正在使用的来源。
结果,由于previously编译的内核可以不含有可在最新版本中使用的所有相关性,同时与最新的内核源外部模块的编译可能依赖于code的任何部分,这是唯一的present的最新版本。因此建议使用与我们所使用的外部模块的最新版本的内核。

二,编译内核的config文件
结果您可以从的/ boot / config中(当前版本)* 文件系统复制到的.config 在内核源​​码的顶层目录。目前的版本我们可以从使用uname -r

得到它

所以程序将无法运行,如果版本(与uname -r命令检查)不等于下载源代码,那么你需要编译和使用新的内核或以其他方式下载内核相同版本的正在运行的内核。对于内核编译使用boot目录下的配置文件present,复制如上所述。

然后就可以使用编译外部模块的正常方式进行,并没有任何问题,运行的内核加载它。

I'm trying to build the latest linux crypto drivers for a Ubuntu server. Ubuntu server has a running kernel, extras and headers installed. However, the source code for the crypto modules are coming from Torvald's GitHub (and not Ubuntu).

I'm also working from the kernel doc Building External Modules. I cloned the latest kernel with:

git clone --depth=1 https://github.com/torvalds/linux.git 

Then:

cd linux

Next:

$ make -C /usr/src/linux-headers-4.2.0-34 M=$PWD crypto
make: Entering directory '/usr/src/linux-headers-4.2.0-34'

  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.

make: Nothing to be done for 'crypto'.
make: Leaving directory '/usr/src/linux-headers-4.2.0-34'

And:

$ find /usr/src -name 'autoconf.h'
/usr/src/linux-headers-4.2.0-34-generic/include/generated/autoconf.h
$ find /usr/src -name 'auto.conf'
/usr/src/linux-headers-4.2.0-34-generic/include/config/auto.conf

And this:

$ find /usr/src -type d -name 'build'
/usr/src/linux-headers-4.2.0-34/tools/build
/usr/src/linux-headers-4.2.0-34-generic/include/config/build

Trying to use the build directory results in the following:

$ make -C /usr/src/linux-headers-4.2.0-34/tools/build M=$PWD crypto
make: Entering directory '/usr/src/linux-headers-4.2.0-34/tools/build'
make: *** No rule to make target 'crypto'.  Stop.
make: Leaving directory '/usr/src/linux-headers-4.2.0-34/tools/build'

I'm obviously missing something obvious. That's not surprising since I know next to nothing about kbuild. I have an exiting configuration and sources at /usr/src, and I have new files at $PWD/crypto. Its not clear to me why I am generating a new configuration for an existing configuration.

How do I update kernel crypto modules against a running kernel provided by someone else?

解决方案

Actually here two things are there to care about:

Is the running kernel version is same are of the source we are using.
As previously compiled kernel may not be having all the dependencies which may be used in latest version, while compilation of external module with latest kernel source may be dependent on any part of the code, which is only present in latest version. So it is recommended to use the latest version kernel with which we are using the external module.

Second, the .config file for kernel compilation
You can copy it from /boot/config(current-version)* of your file system to .config in kernel source top directory. Current version we can get it from uname -r

So procedure will be if running version (check with command uname -r) is not equal to downloaded source, then you need to compile and use new kernel or otherwise download same version of kernel as of running kernel. For kernel compilation use the config file present in boot directory, copy it as stated above.

Then you can proceed with a normal way of compiling the external module and load it with running kernel without any issue.

这篇关于编译外部模块,对正在运行的内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆