VMWare 工作站和 x86 平台

VMWare Workstation and x86 platform

我正在学习 Tanenbaum 的书 ("Modern Operating Systems") 中的虚拟化。我对虚拟化的所有基本概念都清楚,但我无法更好地理解 VMWare Workstation 的工作原理。

首先,VMWare Workstation 有两个组件:

VMM 在每次 (?) 执行之前使用 "decision algorithm" 来确定是否可以使用 "Direct Execution"(陷阱和模拟)或 "Binary Translation" 来执行它。

Tanenbaum 说一个明智的指令只在几种情况下生成 "trap"(在这种情况下 VMM 可以使用直接执行,提高性能)。

我不清楚的是,为什么在 x86 平台上一条合理的指令并非一直都合理(在 x86 平台上),以及在什么情况下是正确的?

我没读过Tanenbaum的书,这是我对作者文字的解读。


根据维基百科,不能直接 运行 的 18 条敏感指令是:

sgdt (Read the GDT of the host, not of the guest)
sidt (As above, but for the IDT)
sldt (As above, but for the LDT)
smsw (Read the control register 0 of the host, not the guest one)
pushf (Read the flags, particularly , of the host, not of the guest)
popf (As above, but write, only some, of the flags)
lar (Read the access right from the descriptors tables of the host, not of the guest)
lsl (Read the segment limit from the descriptors tables of the host, not of the guest)
verr, verw (Check for read/write access using the host descriptors tables, not the guest ones)
pop/push (Use the host segment descriptors for the size of the operands and the stack pointer)
call FAR, jump FAR, int, retf (Transfer control according to the host descriptors tables)
str (Set the task register of the host)
mov <segment registers> (use the host descriptors tables, not the guests ones)

敏感性背后的原理是我的作品

None 这条指令总是陷阱。

有些,不算内存访问异常,从不做:pushfpopflarlslverrverw, push, pop

某些陷阱仅当主机已将它们配置为这样做时:smswsgdtsidtsldtstr.
不过,这很可能不是 Tanenbaum 的本意。

几乎肯定有一些陷阱,但一些值可以使它们起作用:call FARjmp FARretfint。 这大概就是塔嫩鲍姆的意思。

简单来说,像jmp FAR 08h:00h这样的指令正在尝试访问"code labelled by the number 08h"。
这可能会或可能不会成功,具体取决于主机对 "label" 08h 施加的限制。
大多数标签不可访问,它们会陷入困境,但有些标签可以工作。
callretf也是如此。
int 通常不会陷阱,但这又取决于 OS 配置。

一般来说,取决于主机系统结构的指令可以捕获某些值,但不能捕获其他值。
没有什么坏处,即使指令结果执行成功,但它不能直接在虚拟化上下文中执行。