Professional Documents
Culture Documents
VMware, Inc.
VMware, Inc.
Execution Modes
TheVMMimplementsthevirtualhardwareonwhichthevirtualmachineruns.Thishardwareincludesa virtualCPU,virtualI/Odevices,timers,andotherdevices.ThevirtualCPUhasthreefeaturesofinterest:the virtualinstructionset,thevirtualmemorymanagementunit(MMU),andthevirtualinterruptcontroller(PIC orAPIC).TheVMMcanimplementeachoftheseaspectsusingeithersoftwaretechniquesorhardware techniques. Thecombinationoftechniquesusedtovirtualizetheinstructionsetandmemorydeterminesanexecutionmode. Fordiagramsillustratingthetechniquesdescribedinthissection,seePerformanceAspectsofx86 Virtualization(seeReferencesonpage 9foralink).
VMware, Inc.
Becausemostmodernoperatingsystems,includingWindows,Linux,andSolaris,makeonlylightuseof segmentation,itispossiblefortheVMMtousesegmentationtoenforcetheboundarybetweenvirtual machineandVMM.InrarecaseswhentheusesofsegmentationbythevirtualmachineandtheVMMconflict, theVMMcanresorttosoftwaresegmentationchecks,albeitataslightlossofperformance. In2003,whenAMDextendedthex86architecturefrom32to64bits,iteliminatedsegmentlimitchecksfor 64bitcode(32bitcodestillretainedsegmentlimitchecksforbackwardscompatibility).Thischangemeant thataBTbasedVMMcouldnotusesegmentationtoprotecttheVMMfroma64bitvirtualmachine.Inother words,BT32couldvirtualizethe32bitx86architectureefficiently,butBT64couldnotvirtualizethe64bit architectureefficiently. Whenthisarchitecturaldeficiencybecameapparent,AMDaddedsegmentlimitsbackinto64bitcode.This additionmissedtheinitialOpteronRevCprocessor(whichshippedinlimitedquantitiesonly)butwas presentbeginningwiththenextrevision,RevD,andhasremainedpresentinAMD64bitCPUseversince. Thus,all64bitAMDCPUs,withtheexceptionoftheoriginalOpteronRevC,canrunvirtualmachineswith BT64. TheIntel64bitextensionstothex86architecturealsoomittedsupportforsegmentlimitchecksfor64bitcode. UnlikeAMD,however,Intelhasnotaddedsupportforsegmentlimitchecksinsubsequentprocessors.This limitationmakesitinefficienttorun64bitvirtualmachinesusingBT64onIntelCPUs. Table 2summarizestheformsofbinarytranslationthatdifferentversionsofESXcanuseonIntelandAMD CPUs. Table 2. Supported Uses of Binary Translation
ESX 1.0-2.5 AMD Intel BT32 BT32 ESX 3.0 BT32,BT64 BT32 ESX 3.5 BT32,BT64 BT32 ESX 4.0 BT32,BT64 BT32
VMware, Inc.
Table 3showswhichversionsofESXcanuseVTxorAMDVtorun32and64bitvirtualmachines.Thetable assumesanAMDBarcelonaCPUornewer,becausetheinitialAMDVimplementationinOpteronRevFis affectedbyanissuethatVMwarehaschosennottoworkaround.InESX3.5,AMDVcanbeusedonlyin combinationwithrapidvirtualizationindexing(RVI)(seeMemoryandMMUVirtualizationonpage 5), whereasinESX4.0,AMDVcanbeusedwithorwithoutRVI. AsshowninTable 2andTable 3,thenumberofsupportedwaystovirtualizethex86instructionsethas increasedovertime,asnewversionsofESXandnewCPUshavebecomeavailable.
VMware, Inc.
AlthoughRVIandEPThavecompellingadvantages,thereisonepotentialdownside:aTLBmissisnowmore expensivebecauseitmustbeservicedbyatwolevelpagewalker. Formostworkloads,RVIorEPTprovidesanoverallperformancewinovershadowpagetables,butthereare exceptionstothisrule:workloadsthatsufferfrequentTLBmissesorthatperformfewcontextswitchesorpage tableupdates.Formoreinformation,seethepapersPerformanceEvaluationofAMDRVIHardwareAssist andPerformanceEvaluationofIntelEPTHardwareAssist(seeReferencesonpage 9forlinks). Table 4showswhichversionsofESXcanuseRVIorEPT.Whensuchsupportisnotpresent,eitherinthe versionofESXorinthephysicalCPU,thefallbackisshadowpagetables.
Monitor Modes
Thisguidedescribesatwowaychoicebetweensoftwareandhardwaretechniquesforinstructionset virtualization(BTononehandandAMDVorVTxontheotherhand).Similarly,itdescribesatwowaychoice betweensoftwareandhardwaretechniquesformemoryvirtualization(shadowpagetablesononehandand RVIorEPTontheotherhand). Unfortunately,thetwoformsofhardwaresupportarenotorthogonalfeatures.RVIisinseparablefrom AMDVandEPTisinseparablefromVTx.Thisleavesonlythreevalidcombinations:
VMware, Inc.
ESX3.5onanAMDShanghaiCPUanda64bitvirtualmachineTheallowedmodesareBTswMMUand HVhwMMU(AMDVwithRVI).Thepreferredoptionfora64bitvirtualmachineisHVhwMMU,sothe VMMchoosesthismodeatpowerontime. ESX3.5onanIntelNehalemCPUanda64bitvirtualmachineRunwithHVswMMU(becauseESX3.5 doesnotsupportEPT). ESX4.0onanAMDShanghaiCPUanda64bitvirtualmachineThechoiceisamongBTswMMU, HVswMMU,andHVhwMMU.HVhwMMUwins. ESX4.0onanolderOpteronRevFCPUanda64bitvirtualmachineOnlyoneoptionisavailable: BTswMMU(becauseESXcannotuseAMDVonthisCPU). ESX4.0onanIntelNehalemCPUanda64bitvirtualmachineTheallowedmodesareHVswMMUand HVhwMMU(BTisnotallowedfor64bitvirtualmachinesonIntelCPUsbecausesegmentlimitchecks aremissing).TheVMMchoosesHVhwMMU.
ForESX3.5,theonlycaseinwhichthereisachoiceisonAMDCPUsonwhichBTswMMUand HVhwMMUmightbothbeavailable.Thedefaultchoicefor32bitvirtualmachinesisBTswMMU.For 64bitvirtualmachines,itisHWhwMMU,althoughOS/2,UnixWare,andOpenServerdefaultto HWhwMMU.(Thechoicesfor32and64bitvirtualmachinesdifferbecausemany32bitguestoperating systemssufferhighoverheadsonAPICvirtualizationwhenrunningwithhardwarevirtualization becausetheymakefrequentaccesstoamemorymappedTPRregister.) ForESX4.0,manymoresituationscanresultinmultipleallowableexecutionmodes.Thegeneralpriority orderforCPUsthathavehardwaresupportforAPICvirtualization(mostnewerIntelCPUsfrom Penrynonwards)is:HVhwMMU,followedbyHVswMMU,followedbyBTswMMU.ForCPUs withouthardwaresupportforAPICvirtualization,theorderfor32bitWindowsguestoperatingsystems is:HVhwMMU,followedbyBTswMMU,followedbyHVswMMU.Forcertainunusualguestoperating systems,includingOS/2,UnixWare,andOpenServer,BTisdiscouragedordisallowed.
VMware, Inc.
Chooseoneofsoftware,hardware,orautomaticforeachvariable.BothESX3.5andESX4.0recognizethe monitor.virtual_mmusetting.OnlyESX4.0recognizesmonitor.virtual_exec.Youcanexpressall possibleESX3.5modechoiceswiththemonitor.virtual_mmuoptionalone. Ifasettingisnotspecified,theeffectisthesameasautomatic.Ifitissettohardware,itforcestheuseofthe givenformofhardwaresupportifthefeatureisavailableandsupported.Likewise,ifthesettingissoftware, theVMMattemptstorunthevirtualmachinewithoutthegivenformofhardwaresupport,ifallowed. Althoughtheconfigurationfilesettingsareflexibleenoughtoexpressallofthe22possiblecombinations, onlythreeofthefourcombinationsarevalid.Validcombinationsareusedtoselectoneofthethreeexecution modes.IftheCPUdoesnotsupporttherequestedexecutionmode,thesettingsareignored.Inaddition,the settingsareignorediftheCPUimplementstheexecutionmodebuttheversionofESXdoesnotsupportit. ThevSphereClientuserinterfacepresentsathreewaychoice.ThechoiceyoumakeinthevSphereClientis mappedtotheabove(monitor.virtual_mmuandmonitor.virtual_exec)settingsbeforethevirtual machinepowerson. Thesettingsarealwaystreatedashints.IfyouuseVMotiontomoveavirtualmachinefromonehostwhere thesettingshadaneffecttoanotherhostwheretheyareatoddswiththephysicalCPUortheversionofESX, thesettingsareignored.IfyouuseVMotiontomovethevirtualmachinebacktothefirsthost,thesettingstake effectagain.
Conclusions
Virtualizationusedtobesimple:allCPUswere32bit,andtheVMMalwaysusedbinarytranslationand shadowpagetablestorunthevirtualmachine.Thelandscapetodayisirregularandchanging.Althoughthis mightseemlikeanunwelcomedifficulty,VMwarepreferstoviewitasanopportunity:havinghardware vendorscompetetooptimizetheirhardwareforvirtualizationmightcreatediversity,butitalsodelivers efficiencygains.Atthesametime,thecomplexitycanbedifficultforusersofvirtualizationsoftware,anditis notviableforeveryonetospendthetimetobecomeexperts. Thisguide,althoughitisricherindetailthanthetypicalfactsheet,makesanefforttostrikeausefulbalance, allowingyoutounderstandthestateofvirtualizationwithcurrenthardwareandsoftwareandalsoto understandwherevirtualizationmightbegoing.
VMware, Inc. 8
References
K.AdamsandO.Agesen,Acomparisonofsoftwareandhardwaretechniquesforx86virtualizationin ASPLOSXII:Proceedingsofthe12thinternationalconferenceonArchitecturalsupportforprogramming languagesandoperatingsystems(SanJose,California,USA,2006),ACM,pp.213. http://www.vmware.com/pdf/asplos235_adams.pdf R.Bhargava,B.Serebrin,F.Spadini,andS.Manne,Acceleratingtwodimensionalpagewalksfor virtualizedsystemsinASPLOSXIII:Proceedingsofthe13thinternationalconferenceonArchitectural supportforprogramminglanguagesandoperatingsystems(Seattle,Washington,USA,2008),ACM,pp. 2635. http://www.amd64.org/fileadmin/user_upload/pub/p26bhargava.pdf T.Cramer,R.Friedman,T.Miller,D.Seberger,R.Wilson,andM.Wolczko,CompilingJavajustintime. IEEEMicro17,3(1997),3643. OleAgesen,PerformanceAspectsofx86Virtualization http://www.vmworld.com/docs/DOC2476 NikhilBhatia,PerformanceEvaluationofAMDRVIHardwareAssist http://www.vmware.com/resources/techresources/1079 NikhilBhatia,PerformanceEvaluationofIntelEPTHardwareAssist http://www.vmware.com/resources/techresources/10006
Acknowledgments
Theauthorthanksthosewhocontributedtothisguide.HenrikMnsterfirstpointedouttheneedforsucha guide.JimMattsonandJeffreySheldonprovidedmanycommentsthatimprovedthetechnicalaccuracy.Sean Bormanassistedtogreatlyimprovetheclarityandfocus.
If you have comments about this documentation, submit your feedback to: docfeedback@vmware.com VMware, Inc. 3401 Hillview Ave., Palo Alto, CA 94304 www.vmware.com Copyright 2009 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and intellectual property laws. VMware products are covered by one or more patents listed at http://www.vmware.com/go/patents. VMware, the VMware boxes logo and design, Virtual SMP, and VMotion are registered trademarks or trademarks of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies. Revision: 20090622 Item: EN-000240-00