Fork me on GitHub

Virtualization and Performance: Understanding VM Exits

翻译自:Virtualization and Performance: Understanding VM Exits

出于对特定指令 或 特定事件(eg.  page fault)的响应而导致的VM Exit(虚拟机退出)是造成虚拟化系统性能下降的主要原因。但是你有没有想过,为什么会这样?无论出于什么原因,VM Exit的背后究竟发生了什么?

VM Exit意味着从当前运行的VM 到 VMM之间存在一个转换点,而VMM出于特定原因必须执行系统控制。通常,处理器必须保存VM退出时运行状态的快照。对于英特尔架构,大概有如下几步:

  1. 在VM-exit information fields 处记录导致VM Eixt的信息(包括exit reason, exit qualification, guest address),并更新VM-entry control fields.
  2. 保存处于Guest Mode状态下的CPU状态,包括control registers(控制寄存器), debug registers(调试寄存器), MSRs  segment registers(段寄存器), descriptor-table registers, RIP, RSP, and RFLAGS, 以及非状态寄存器。
  3. MSRs  用于控制报告处理器性能,将MSRs  保存到VM-exit MSR-store area
  4. 根据host-state area和一些VM-exit controls加载processor state,包括control registers, debug registers, MSRs, host table and descriptor-table registers, RIP, RSP, and RFLAGS, page-directory pointer table entries, as well as non-register state.
  5. 从VM-exit MSR-store area加载MSRs

哦,不要忘记在VMM执行了系统管理功能之后,将执行相应的VM entry,将处理器控制从VMM转移到VM!

现在,您可以看到为什么VM退出会产生相当大的开销,为单个转换(VM到VMM)浪费数百或数千个CPU周期。 顺便说一下,为了缓解这个问题,Intel付出了相当大的努力减少了单个转换(VM到VMM)所需的时钟周期数。

posted @ 2018-12-13 17:13  克拉默与矩阵  阅读(1231)  评论(0编辑  收藏  举报