English 中文(简体)
如何禁用浮点单元(FPU)?
原标题:How to disable floating point unit (FPU)?

我想在x86系统中禁用FPU/MMX/SSE指令,并将为“设备不可用”异常实现一个处理程序。我参考了控制寄存器wiki页面;似乎我必须在cr0寄存器中设置一些标志。如何在cr0中设置这些标志以及在启动时做这项工作?

问题回答

管理FPU状态的Linux内核代码可以在arch/x86/nernel/traps.cdo_device_not_available()。默认情况下,Linux内核为所有进程禁用FPU,并在首次访问时启用它。这允许内核减少不使用FPU的进程的上下文切换开销。然而,这也意味着在启动时设置一次TS是不够的;您必须更改管理TS标志的Linux内核代码才能保持这种状态。

通过在do_device_not_available()中添加禁用标志的早期检查,并发出信号或采取其他操作,可以禁用对FPU的访问。请注意,如果在进程首次使用该特定CPU上的FPU之后再执行此操作,则FPU可能会在一段时间内保持可用,直到FPU寄存器上下文切换,并且FPU被重新禁用。如果您希望避免这种情况,则必须使用stts()显式重新禁用FPU。

请注意,由于Linux ABI假设您有一个FPU(模拟FPU或硬件FPU,如果两者都没有,内核将不会启动),这可能会在应用程序中导致意外行为。此外,任何使用FPU的内部内核代码(不确定是否有)也可能会中断。执行此操作的风险自负。





相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签