FXSAVE 能否在 FXRSTOR 之前执行两次?

标签 c assembly linux-kernel x86 x86-64

在破解 Linux 内核时,我注意到它会在执行 FPU 相关任务之前执行 FXSAVE 指令。据我所知,FXSAVE 指令会将 FPU 状态保存到内存中的目标,可以通过 FXRSTOR 指令恢复。我的问题是我是否可以在执行 FXRSTOR 指令之前执行 FXSAVE 两次。

例如:

char fxsave_region1[512] __attribute__((aligned(16)));
char fxsave_region2[512] __attribute__((aligned(16)));

asm volatile(" fxsave; "::"m"(fxsave_region1));

/* miscellaneous floating point operations */

asm volatile(" fxsave; "::"m"(fxsave_region2)); /* will this work? */

/* some more miscellaneous floating point operations */

asm volatile(" fxrstor; "::"m"(fxsave_region2));

/* even more miscellaneous floating point operations */

asm volatile(" fxrstor; "::"m"(fxsave_region1));

或者只支持一级保存?

最佳答案

F(N)SAVE不同,FXSAVE不会更改FPU/MMX和SSE寄存器的状态,因此您可以重复多次。

关于FXSAVE 能否在 FXRSTOR 之前执行两次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16021529/

相关文章:

c - 在调用者的返回序列中跳过函数

c - 大输入程序运行太慢 - C

assembly - 常量非不变 tsc 可以跨 cpu 状态改变频率吗?

android - 如何修改 AOSP 以允许特定应用程序获得 root 访问权限?

linux - Linux 上 VMA 的开销

linux-kernel - 了解函数系统调用的汇编代码

c - linux中应用程序的自动打包

c - 在 GCC 进行的每次优化后获取汇编代码?

assembly - 如何在6502汇编中将16位数字除以2?

c - curses 中的 halfdelay 函数有什么作用?