英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论