为什么SGX会多次调用ioctl?

huangapple go评论51阅读模式
英文:

Why does SGX calling ioctl so many times?

问题

当我使用strace分析sgx进程时,在mmap函数之后调用了ioctl函数很多次,如下所示。

1424  11:18:56 mmap(NULL, 4194304, PROT_NONE, MAP_SHARED, 4, 0) = 0x7f7e6a800000
1424  11:18:56 ioctl(4, _IOC(_IOC_WRITE, 0xa4, 0x00, 0x08), 0x7ffdadb760b0) = 0
1424  11:18:56 ioctl(4, _IOC(_IOC_WRITE, 0xa4, 0x01, 0x1a), 0x7ffdadb76f00) = 0
1424  11:18:56 ioctl(4, _IOC(_IOC_WRITE, 0xa4, 0x01, 0x1a), 0x7ffdadb76f00) = 0
1424  11:18:56 ioctl(4, _IOC(_IOC_WRITE, 0xa4, 0x01, 0x1a), 0x7ffdadb76f00) = 0
1424  11:18:56 ioctl(4, _IOC(_IOC_WRITE, 0xa4, 0x01, 0x1a), 0x7ffdadb76f00) = 0

有谁知道为什么会调用这么多次这个函数吗?

这个函数是什么意思?

英文:

When I analysis sgx process by using strace, ioctl function is called so many times after mmap function like below.

1424  11:18:56 mmap(NULL, 4194304, PROT_NONE, MAP_SHARED, 4, 0) = 0x7f7e6a800000
1424  11:18:56 ioctl(4, _IOC(_IOC_WRITE, 0xa4, 0x00, 0x08), 0x7ffdadb760b0) = 0
1424  11:18:56 ioctl(4, _IOC(_IOC_WRITE, 0xa4, 0x01, 0x1a), 0x7ffdadb76f00) = 0
1424  11:18:56 ioctl(4, _IOC(_IOC_WRITE, 0xa4, 0x01, 0x1a), 0x7ffdadb76f00) = 0
1424  11:18:56 ioctl(4, _IOC(_IOC_WRITE, 0xa4, 0x01, 0x1a), 0x7ffdadb76f00) = 0
1424  11:18:56 ioctl(4, _IOC(_IOC_WRITE, 0xa4, 0x01, 0x1a), 0x7ffdadb76f00) = 0

Is there anyone who knows why this function is called so many times?

What means this function?

答案1

得分: 0

代替添加自定义系统调用,许多事情使用ioctl在"设备"文件描述符上,作为用户空间与内核通信的一种方式。将其视为特定设备的系统调用。

在SGX的这个具体情况下,我不知道它具体在做什么,但看到大量的ioctl并不罕见。例如,声卡驱动程序也使用大量的ioctl

最初,ioctl主要用于TTY文件描述符上的终端I/O设置,比如规范模式与原始模式,以及特殊字符的功能,以及串口速度。但正如我所说,其他类型的设备驱动程序已将其用作替代添加新系统调用的方法。

英文:

Instead of adding a custom system call, a lot of things use ioctl on a "device" FD as a way for user-space to communicate with the kernel. Think of it as a device-specific system call.

In this specific case of SGX I don't know specifically what it's doing, but it's not rare to see lots of ioctls. e.g. sound card drivers use a lot of ioctl, too.

Originally ioctl was mostly for terminal I/O settings on TTY file descriptors, like canonical vs. raw, and which special characters did what, and serial port speeds. But as I said, other kinds of device drivers have used it as an alternative to adding new system calls.

huangapple
  • 本文由 发表于 2020年1月3日 14:21:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/59574046.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定