c - UML 中的用户模式内核如何与主机上的底层内核接口(interface)

标签 c linux linux-kernel user-mode-linux

在用户模式 ​​linux (UML) 中,跟踪线程取消用户空间进程进行的系统调用,并将它们重定向到在用户空间中运行的内核。现在在某个时候这个用户空间内核需要主机操作系统的帮助。用户态内核如何调用底层宿主机内核,是否只是普通的系统调用?或者它是否使用某种 IOCTL 机制或其他方式?

最佳答案

我找到了一个非常简单的 UML 设计解释 here .它可能对您有用。

UML constructs it using ptrace system call tracing mechanism.

  1. When a process in user space, its system called are intercepted by ptrace.
  2. When it is in the kernel, no interception. When a process executes a system call or receives signal, the tracing thread forces the process to run in the kernel.
  3. After the transition, the process state is restored and it continues.

System call virtualization

  1. By switching the user and kernel and system calls interception
  2. Note: the system call must be annulled in the host kernel.
  3. The process state is preserved.
  4. When the system call is complete, the process obtains the returned value in its saved registers and returned to user mode.

另外,这篇文章解释了 System call virtualization using ptrace如下图。

http://www.csee.wvu.edu/~katta/uml/graphics/vsyscall.jpg .红线代表正常的系统调用过程。

关于c - UML 中的用户模式内核如何与主机上的底层内核接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32303095/

相关文章:

linux - 修改Linux文件内容

linux - GDB - 从外部 ".sym"文件加载调试信息

linux - 运行 Linux 内核模块 (Hello World)

linux-kernel - 无需系统调用修改Linux进程页表以访问物理内存

java - 如何从java调用C lib文件函数

c - 字符串数组上的基本 qsort 在 qsort() 中崩溃

linux - 删除文件名中的前 4 个字母和后 4 个字母

C 在函数中分配指针,不会改变原始指针(void *)

c - 使用异步套接字在 C 应用程序中实现加密

c - 从 perf 获取用户空间堆栈信息