2020.10.15

A Comparison of Software and Hardware Techniques for x86 Virtualization

1. Introduction

当时(2006)x86刚刚推出虚拟化的硬件支持,vmware尝试比较有硬件支持的虚拟化纯软件的虚拟化的性能差别。他们发现第一代(之所以加粗“第一代”,是希望提醒我自己要有意识去改良框架,要有勇气去改良一个框架,要去学习如何低开销地高效率地去改良一个框架,而不是一味想着推翻重做)有硬件支持的虚拟化的性能低。他们找的原因和我们目前在xqm的遇到的瓶颈简直一模一样,

We ascribe this situation to high VMM/guest transition costs and a rigid programming model that leaves little room for software flexibility in managing either the frequency or cost of these transitions.

用我们的话来说,上下文切换次数太多了。

vmware的VMM开发者对硬件开发者的希望,

While the first round of hardware support has been locked down, future rounds can still be influenced, and should be guided by an understanding of the trade-offs between today’s software and hardware virtualization techniques. We hope our results encourage hardware designers to support the proven software techniques rather than seeking to replace them; we believe the benefits of software flexibility to virtual machine performance and functionality are compelling.

我也希望能够多交流互相学习,目前最想学习的是听一听汪文翔老师讲一讲他设计新指令集的思路,如果这个问题太大了的话那就改成,为了二进制翻译和虚拟化提供了哪些指令,为什么要选这些指令,设计时希望二进制翻译器和虚拟化软件如何利用这些指令。


2&3. Classical/Software virtualization

提出了2种虚拟化的方法,一种是流行的方法(classiscal),一种是文章新提出的方法(software):

  • classically virtualizable (trap-and-emulate)
    • 这势必会让被模拟的操作系统运行在非特权态(原文用词deprevileged),会产生很多问题,第3.1章节提到了两个:段寄存器会存储特权态,特权态指令含义略微变化如popf。因此称x86是还不能使用传统方法(not classically virtualizable)。
  • (software) virtualizable (binary translate)
2020.10.20

4. Hardware virtualization

x86的虚拟化扩展

  • VMCB:控制位和guest CPU状态的子集存在内存里;
  • 新的权限状态:guest mode,特权态和用户态被称作host mode;
  • 新指令:vmrun,从host mode转到guest mode。当遇到某些状况时从guest mode回到host mode(文中称为一次exit操作)。

exit操作次数决定虚拟化的性能,0次则为原生性能。

5. 简单比较software和hardware virtualization

6. Experiments

Current Intel CPUs lack support for segment limits in 64 bit mode, leaving us without our preferred method for protecting the software VMM. So we caution that in the measured hardware environment the software VMM fails Popek and Goldberg’s Safety requirement. However, the VMM exhibits similar performance on AMD’s Opteron processor where 64-bit segment limits are supported, so we are confident that these measurements accurately represent the performance of the software VMM.

~~提到了vmware用的是segment limits来保护VMM的数据&代码。这个就非常有意思了,看起来它是不用Software MMU的!~~要用的,见第7.4章节。

ABORTED:有必要研究虚拟化里如何解决Host、Guest内存空间冲突的问题。

2021.1.4:虚拟化里用的是guest页表,能够完全给guest提供完整的内存空间,所以不存在内存空间冲突的问题。

文章里介绍了那个时代诸多流行的测试方法(包括各种自己写的小测试和通用的测试集)

7. Software and hardware opportunities

  • 微结构改进
  • 算法改进
  • 软硬结合
  • 硬件MMU支持