Edd*_*ett 6 c linux system-calls linux-kernel
我正在摆弄系统调用.我添加了两个新的,并验证它们使用调用工作syscall.
我希望系统调用号位于标题中,以便用户空间不必明确知道系统调用号.
在arch/x86/syscalls/syscall_64.tbl我有:
317 64 krun_read_msrs sys_krun_read_msrs
318 64 krun_reset_msrs sys_krun_reset_msrs
Run Code Online (Sandbox Code Playgroud)
并且一些grepping表明kbuild已经为新的系统调用自动生成了宏:
$ ag __NR_krun *
arch/x86/include/generated/uapi/asm/unistd_64.h
321:#define __NR_krun_read_msrs 317
322:#define __NR_krun_reset_msrs 318
Run Code Online (Sandbox Code Playgroud)
文件名表明我不需要手动添加条目,但这与Linux内核文档所说的相反:
Some architectures (e.g. x86) have their own architecture-specific syscall tables, but several other architectures share a generic syscall table. Add your new system call to the generic list by adding an entry to the list in include/uapi/asm-generic/unistd.h:
#define __NR_xyzzy 292
__SYSCALL(__NR_xyzzy, sys_xyzzy)
Run Code Online (Sandbox Code Playgroud)
好吧,我的系统调用是特定于x86_64的,因为它们只读取和写入仅在英特尔芯片中发现的MSR.所以在此之后,我开始挖掘,看看能否为amd64系统找到特定于拱形的标题.
你可以期待它在arch/x86_64那里,但在那里根本没有包括.所以我假设x86_64继承自x86.在这种情况下,特定于arch的标头应该是:
arch/x86/include/uapi/asm/unistd.h
Run Code Online (Sandbox Code Playgroud)
如果你打开它,它只是一个基于arch发送的小包装器:
# ifdef __i386__
# include <asm/unistd_32.h>
# elif defined(__ILP32__)
# include <asm/unistd_x32.h>
# else
# include <asm/unistd_64.h>
# endif
Run Code Online (Sandbox Code Playgroud)
所以这可能是为了获取/usr/include/x86_64-linux-gnu/asm/unistd.h,但这还不包括我的新系统调用号码.
我希望headers_install目标安装新的标头(也许),但它没有.
我糊涂了.我应该手动将新的系统调用添加到文件中吗?如果是这样的文件?如果没有,我如何将自动生成的__NR_*宏公开给标准位置的用户空间?
谢谢
嗯,我有一个部分答案。部分的,因为它是 Debian 特定的。
如果您make deb-pkg在内核源代码中使用目标,则会.deb在父目录中创建包。如果您随后安装了这些文件,那么您的标头就会安装到系统中。
对我的内核执行上述操作后:
$ grep krun /usr/include
/usr/include/asm/unistd_64.h:#define __NR_krun_read_msrs 317
/usr/include/asm/unistd_64.h:#define __NR_krun_reset_msrs 318
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
604 次 |
| 最近记录: |