x86_64: 我可以更改 EFLAGS 寄存器中的 VM 标志吗?
x86_64: Can I change the VM flag in the EFLAGS register?
我可以更改 EFLAGS 寄存器中的 VM 标志吗?如果可以,怎么做?
请注意,我不能只使用 pushf
,操作堆栈上的值,然后 popf
。根据 Intel manual:
第 2 卷,第 4.3 章 PUSHF:
"When copying the entire EFLAGS register to the stack, the VM and RF
flags (bits 16 and 17) are not copied; instead, the values for these
flags are cleared in the EFLAGS image stored on the stack."
第 2 卷,第 4.3 章 POPF:
"When operating in protected, compatibility, or 64-bit mode at
privilege level 0 (or in real-address mode, the equiv- alent to
privilege level 0), all non-reserved flags in the EFLAGS register
except RF1, VIP, VIF, and VM may be modi- fied. VIP, VIF and VM remain
unaffected."
没有
可由用户模式程序更改的标志
用户应用程序(CF、PF、AF ZF、SF、TF、DF OF)只能设置 12 个最低有效位中的 8 个,您不能在这 12 个位中设置保留位,只留下 9 个和其中之一(IF
) 享有特权。
大多数标志可以使用普通指令更改,用户应用程序只需要 POPF
设置 TF
标志。
较高的标志是特权或只读的,只能由环 0 中的 运行ning 进程更改。
参见:http://www.felixcloutier.com/x86/POPF:POPFD:POPFQ.html
All non-reserved bits except IF, IOPL, VIP, VIF, VM and RF can be modified;
IF, IOPL, VIP, VIF, VM and all reserved bits are unaffected; RF is cleared.
If a POPF/POPFD instruction is executed with insufficient privilege, an exception does not occur but privileged bits do not change.
参见:https://en.wikipedia.org/wiki/FLAGS_register
如何做 我更改 VM 标志,它到底是什么?
VM
标志与虚拟机无关,但显示处理器是否在 16-bit virtual 8086 mode.
中 运行ning
为了设置 VM 标志,您需要进入虚拟 8086 模式。
See here 例如代码。
许多需要的指令都是特权指令,只能在 Ring 0 中执行。
此外,您只能从 32 位模式进入实模式,而不能从 64 位模式进入。
从虚拟 8086 模式退出回到保护模式是 even more convoluted affair (scroll down a bit for working code)。
同样,您需要 运行 in privileged VME mode 才能执行此操作。
我可以更改 EFLAGS 寄存器中的 VM 标志吗?如果可以,怎么做?
请注意,我不能只使用 pushf
,操作堆栈上的值,然后 popf
。根据 Intel manual:
第 2 卷,第 4.3 章 PUSHF:
"When copying the entire EFLAGS register to the stack, the VM and RF flags (bits 16 and 17) are not copied; instead, the values for these flags are cleared in the EFLAGS image stored on the stack."
第 2 卷,第 4.3 章 POPF:
"When operating in protected, compatibility, or 64-bit mode at privilege level 0 (or in real-address mode, the equiv- alent to privilege level 0), all non-reserved flags in the EFLAGS register except RF1, VIP, VIF, and VM may be modi- fied. VIP, VIF and VM remain unaffected."
没有
可由用户模式程序更改的标志
用户应用程序(CF、PF、AF ZF、SF、TF、DF OF)只能设置 12 个最低有效位中的 8 个,您不能在这 12 个位中设置保留位,只留下 9 个和其中之一(IF
) 享有特权。
大多数标志可以使用普通指令更改,用户应用程序只需要 POPF
设置 TF
标志。
较高的标志是特权或只读的,只能由环 0 中的 运行ning 进程更改。
参见:http://www.felixcloutier.com/x86/POPF:POPFD:POPFQ.html
All non-reserved bits except IF, IOPL, VIP, VIF, VM and RF can be modified; IF, IOPL, VIP, VIF, VM and all reserved bits are unaffected; RF is cleared.
If a POPF/POPFD instruction is executed with insufficient privilege, an exception does not occur but privileged bits do not change.
参见:https://en.wikipedia.org/wiki/FLAGS_register
如何做 我更改 VM 标志,它到底是什么?
VM
标志与虚拟机无关,但显示处理器是否在 16-bit virtual 8086 mode.
中 运行ning
为了设置 VM 标志,您需要进入虚拟 8086 模式。
See here 例如代码。
许多需要的指令都是特权指令,只能在 Ring 0 中执行。
此外,您只能从 32 位模式进入实模式,而不能从 64 位模式进入。
从虚拟 8086 模式退出回到保护模式是 even more convoluted affair (scroll down a bit for working code)。
同样,您需要 运行 in privileged VME mode 才能执行此操作。