Intel内存虚拟化技术分析

VPID

    类似ASID, ASID用以区分不同进程的地址空间,切换时不用刷新TLB。VPID用来区分不同的虚拟处理器地址空间,虚拟机切换时不用刷新TLB。VMM为每个VMCS分配一个唯一的VPID,在VMCS中将Enable VPID置1就可以启用该功能。


Extended page table(EPT) 页表遍历方式

        硬件支持的情况下,当VMENTRY (optionally)时,EPT被激活。EPT模式CPU同时控制两个页表,一个是Guest常规意义上的页表,该页表维护 logical page numbers(LPNs) to physical page numbers (PPNs)的映射。另一个是VMM maintains a mapping of PPNs to machine page numbers (MPNs),称为extended page tables。When EPT active, EPT base pointer(loaded on VM entry from VMCS) points to extended page tables。当VM exit事件发生时,EPT deactivated。

见Performance Evaluation of Intel EPT Hardware Assist - VMware:

http://blog.csdn.net/gudujianjsk/article/details/7776747

实际情况要复杂一些,因为guest page table(GPT)和EPT可能是多层的,每遍历GPT的一层都可能要遍历一次EPT,所以GPT是m层,EPT是n层,遍历最大次数大约是m*n(假定TLB MISS)。下面是来自2009 虚拟化技术全国高校师资研讨班的详细示意图:


这也就是为什么huge page对VM的作用更加明显的原因,可以参看下面的链接: Transparent Hugepage


TLB

EPT模式下TLB的管理相对复杂,详见INTEL Manual 25.3  CACHING TRANSLATION INFORMATION。分为三类Cache:

Linear mappings(LPN->PPN),
Guest-physical mappings(PPN->MFN),
Combined mappings(LPN->MFN)后两者的内容(部分)来自EPT。
可以是使用指令INVEPT/INVVPID来 invalidates entries in the TLBs and paging-structure caches that were derived from extended page tables (EPT), or based on a Virtual-Processor Identifier (VPID).


EPT-Induced VM Exits  
    见Intel Manual,Accesses using guest-physical addresses may cause VM exits due to EPT misconfigurations and EPT violations. An EPT misconfiguration occurs when, in the course of translation a guest-physical address, the logical processor encounters an EPT paging-structure entry that contains an unsupported value. An EPT violation occurs when there is no EPT misconfiguration but the EPT paging-structure entries disallow an access using the guest-physical address. 其中EPT violations发生的一个情况就是Translation of the guest-physical address encounters an EPT paging-structure entry that is not present,基于此可以动态创建EPT.
   此外,guest的 page faults 应该先于对应的EPT violations发生,因为EPT是根据guest的page table建立起来的。


EPT in Kvm
EPT的设置在vmx_set_cr3函数中。EPT是动态创建的,利用 EPT Violation VM Exit,见tdp_page_fault函数。




原文链接:

http://blog.chinaunix.net/uid-1858380-id-3205061.html



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值