虛擬化技術(shù)xen原理_第1頁
虛擬化技術(shù)xen原理_第2頁
虛擬化技術(shù)xen原理_第3頁
虛擬化技術(shù)xen原理_第4頁
虛擬化技術(shù)xen原理_第5頁
已閱讀5頁,還剩54頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

HowXenPVvs.Pv-VCPUVCPUExitArchitectureofException&SystemArchitectureofTime&Direct-ShadowPageHowtouseHowtodoPCIpass- |?2010CloudExHowXen |--read"Xen-e820RAMmap"from|--

likeLinuxsoftinitializepagecreateaIndentifyCPUtype,initialize |?2010CloudEx ||--||--||--

(create grant|||-- ||||--|||--d->arch.ioport_caps=rangeset_new(d,"I/O|||--d->shared_info=|||--|||--d->arch.pirq_irq=|||--d->arch.irq_pirq=|||-- ||--d->iomem_caps=rangeset_new(d,"I/O||--d- =rangeset_new(d,||-- |?2010CloudEx|--construct_dom0readdom0ELFfile,preparefordom0||--||--||--setupdom0||--setuppage

read||--setupCR3valuefor||-- CopytheOS||--Setupstartinfo Xentorunon |?2010CloudExPVvs.What UPV UPVGuestvirtualmachineisawarethatitdoesnothavedirectaccesstothehardwareandrecognizesthatothervirtualmachinesarerunningonthesameHVMvs.HVMGuestmustinitializeasitwouldonatypicalmachinesosoftwareisaddedto UHVMGuest,Xenvirtualfirmware(hvmloader),tosimulatetheBIOSanoperatingsystemwouldexpectonstartup.PVGuestdoesn‘trequirevirtualizationextensions(In VT,AMD-V)fromthehostPVGuestareawareofthehypervisorandcanrunefficientlywithoutemulationorvirtualemulatedhardware(Qemu-dm).HVMGuestareusuallyslowerthanPVGuest,becauseoftherequiredPVDOMU’sallowPCIpassthrough(howModifyPVDOMUkernel,soitknowthatitisrunningonring- |?2010CloudExPv-grubvs.PygrubenablesyoutostartLinuxDomUwiththekernelsthatlieinthefilesystemoftheDomUinsteadofwithaKernelthatliesinthefilesystemoftheDom0.Pv-grubre cesPygrubtoboot Uimagessafely:itrunstheregulargrubinsidethecreated itselfandusesregularUfacilitiestoreadthedisk/fetchfilesfromnetworketc;iteventuallyloadsthePVkernelandchain-bootsit.Pv-grubisimplementedasastub andprovidedwiththeXen |?2010CloudExWhatisTheguestfirmware(BIOS)providesthebootservicesandrun-timeservicesrequiredbytheOSintheHVM.Thisguestfirmwaredoesnotseeanyrealphysicaldevices.Itoperatesonthevirtualdevicesprovidedbythedevicemodels. |?2010CloudExHvmloader-2(Whendohvmloader (xlflow ||--|||-- |||-- |||--|||--state->store_port=|||--state->console_port=||--|||--||||--||||--|||||-- copyhvmloadertospecial|||--||-- writesomexenstore begintorun |?2010CloudEx?structelf_binary/*elfbinaryconstcharsize_t/*loadedtocharuint64_tuint64_t(1M?createaelfyzetheelf copyelfimageto||--elf->dest=xc_map_foreign_ranges(pages=(elf->pend-elf-||--|||--memcpy(dest,elf->image+offset, |?2010CloudExHvmloader-3(Howit|--|--|--|--

writetables/infotomemoryaslikeBISO|--|-- - |-- |-- |-- |-- |--fadt[offset]= |-- |-- |--|--|-- |?2010CloudExCPU-1(VirtualCPUAvirtualCPU(VCPU)isstandforVM’sphysicvcpu->arch_vcpu-> - |-- |-- |--load“gusetcontext”from |--maxvcpufor umwecansupportwithcurrentvLAPICID .#define vcpu->arch_vcpu-> |?2010CloudEx |?2010CloudEx |?2010CloudEx |?2010CloudExCPU-2(HVMvcpuHVMvcpuVMCS(Virtual-MachineControlStructure),a4KBblockinmemorythatholdsthecompleteCPUstateofboththehostandtheguest(segmentregisters,GDTandIDTpointer,certainMSRsetc.)aswellassomecontrolbits(forexample,whentoexit)VMMcontrolVMCS TheVMCSdataareorganizedintosixlogicalGuest-statearea.Processorstateissavedintotheguest-stateareaonVMexitsandloadedfromthereonVMentries.VM-entrycontrolfields.ThesefieldscontrolVMentries.EventInjection(InterruptorVM-executioncontrolfields.ThesefieldscontrolprocessorbehaviorinVMXnon-rootoperation.TheydetermineinpartthecausesofVMexits.VM-exitcontrolfields.ThesefieldscontrolVMVM-exitinformationfields.ThesefieldsreceiveinformationonVMexitsanddescribethecauseandthenatureofVMexits.Theyareread-only. |?2010CloudExHVM |--|--…GuestOSis64-bitEvent VM-entryinterruption-haveinjectionInterruptiontype(NMI,hardware/softwareinterrupt,hardware/softwareVM-EntryHost-stateareachecksaveHost-stateareafromCPUGuest-stateareacheckloadVMCSGuest-stateareatoCPUinjectsomeevent |?2010CloudExVM-executioncontrolfields(behaviorofVM-Pin-BasedVM-Executionprimaryprocessor-basedVM-synchronousevents(execspecificinstructions)willcauseVM-secondaryprocessor-basedVM-executionEnableEnableExceptionBitmap(whichexceptioncancauseVM-32-bitfieldthatcontainsonebitforeachexception.Whenanexceptionoccurs,itsvectorisusedtoselectabitinthisfield.Ifthebitis1,theexceptioncausesaVMexit.Ifthebitis0,theexceptionisdeliverednormallythroughtheIDT,usingthedescriptorcorrespondingtotheexception’svector64-bitphysicaladdressesofI/ObitmapsAandB(eachofwhichare4KBytesinsize).I/ObitmapAcontainsonebitforeachI/Oportintherange0000Hthrough7FFFH;I/ObitmapBcontainsbitsforportsintherange8000HthroughFFFFH.Virtual-ProcessorIdentifierVM-exitcontrolfields(behaviorofVM-Hostaddressspace |?2010CloudExVM-exitinformationfields(whichreasoncauseVM-ExitReason+ExitGuest-linearInterruptionInformationforVMExitsThatOccurDuringEventInformationforVMExitsDuetoInstructionVM-exitControl |?2010CloudEx三個(gè)(hvm下兩個(gè)子體系)這樣的接口這樣VM切換的基本邏輯為 |?2010CloudExCPU-4(VCPU||--|||--||||--||||--||||--staticstructhvm_function_table read_mostlyvmx_function_table= =

= ===== |?2010CloudEx||--set_bit(_VPF_down,&v-||--v->vcpu_info=shared_info(d,||--||--|||--|||--if( (d)|||--||||--

setpagemode& for||||--hvm_funcs.vcpu_initialise=|||||--v- =|||||||| =||||||||||--arch_vmx->vmcs=|||||||--vmcs= alloconepagefor||||||--||for||;|||--v->arch.ctxt_switch_from=|||--v- =|||--v->arch.guest_context.ctrlreg[4]=VCPUExitAccessprivilegemodifykernelatfirstGuestOSdohypercallVM-exitmodifyVMCS(doextrajobifneed)VM-entryloadGuestOSregisterVIDTtoVMMatfirstsaveitstrapinfotoVCPUinfoGuestOSexceptionVMMcreate“ExceptionStackFrame”forVCPU(accordingtotarp_info)GuestOSdoit’sexceptionjobyes,mustbeoperatedbyVM-exitVMMdoitsjobinjectGuestOSNo,GuestOScancompletethisjobbyitself&virtual)GuestOSregisterIRQrequesttoVMMbyhypercallatfirstsaveitsevtchn_to_IRQVMMdo_IRQsendevtchninfotoGuestGuestOSVM-exitlookupVM-exitinterruptioninformationgetIRQNO.do_IRQinjectGuestOSStopVCPUinjectGuestOSVCPUVCPUInitialization|--vcpu_guest_context_t

||--arch_vmx->vmcs=|||--vmcs=||--

alloconepagefor|||-- vmwrite(xxx,yyy)initializeGuest-statearea,Host-statearea,VM-entrycontrolfields,VM-executioncontrolfields,VM-exitcontrolfields,VM-exitinformationfieldsVCPUVCPU |?2010CloudExVCPUschedule-SametoPVandCreditVCPUqueueforaVCPUstatus:overandunder(ofitsVCPUconsumeitscreditswhenitisXencomputevcpucredits |?2010CloudExVCPUschedule-|-- |-- init_timer(&per_cpu(schedule_data,i).s_timer, |-- |--pickupcredit |--control|-- ==|--next= |?2010CloudExInterruptArchitecture-中斷向量 Xen大部分的物理中斷都是由GuestOS來處理的, GuestOS得到該異 對(duì)于PV來說,GuestOS需要先 |?2010CloudExInterruptArchitecture- |?2010CloudExXenPhysical- |--for(i=0;i<action->nr_guests;i++ |--d=action- |--pirq |--port=d- |--evtchn_set_pending(d->vcpu[chn->notify_vcpu_id], |-- |?2010CloudExGuestOSmechanism-Mechanism|-- |--

GuestOS’sFirstCfunctiontobecalledonXen||||||||--||| |--set_irq_chip_and_handler_name(i,&dynirq_chip,handle_level_irq,||| |--set_irq_chip_and_handler_name(i,&pirq_chip,handle_level_irq,||…|||||||| |--||| |--||| |--||||||||||||||||||||| |?2010CloudExGuestOSmechanism- |--irq= |--irq= |-- |-- |--desc= -

|--HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq,

|--port= |-- |?2010CloudExGuestOSmechanism-|-- |--port=(word_idx*BITS_PER_LONG)+ |--irq= |-- |--desc= - ExampleofIRQinitializationbyGuest|--ms Initializethesharedmemoryringstotalkto |--bind_evtchn_to_irqhandler(xen_store_evtchn,wake_waiting,0,"xenbus",&xb_waitq) |?2010CloudExVirtualInterrupt |?2010CloudExVirtualInterrupt-WhatisXensendVIRQtoGuestGuestOSresponsetothisByVIRQ,xencancontrolGuestOSevenitisVIRQ#defineVIRQ_TIMER

/*V.Timebaseupdate,and/orrequestedtimeout./*V.Requestguesttodumpdebug #define #define #define

/*G.(DOM0)Bytesreceivedonemergencyconsole./*G.(DOM0)Exceptionaleventfor /*G.(DOM0)Tracebufferhasrecordsavailable.#defineVIRQ_CON_RING

/*G.(DOM0)A haspausedfordebugging. 7/*V.XenOprofileinterrupt:newsampleavailable*/8/*G.(DOM0)Bytesreceivedon #defineVIRQ_PCPU_STATE/*G.(DOM0)PCPUstate#defineVIRQ_MEM_EVENT/*G.(DOM0)Amemoryeventhas |?2010CloudExVirtualInterrupt-Virtual|-- |--send_guest_vcpu_virq(v, |--port=v- GuestOS’sFirstCfunctiontobecalledonXen |-- |--…|-- |-- |?2010CloudExVirtualInterrupt-Requestcontrolbind_virq_to_irqhandler(virq,cpu, |-- |--port= = |--evtchn= sameto |?2010CloudExGuestOSregisteritsVIDT.DPL=0toXenwhenitSaveVIDTtovcpu-GuestOSrunitsVIDThandlerstructtrap_info{ /*exception /*0-3:privilegelevel;4:cleareventenable? /*codeselector unsignedlong /*code structtrap_bounce

/*TBF_unsignedlongControlExceptionHappenedVMMtrapdo_trapdo_guest_traphandle_exceptioncreate_bounce_frame(copytrap_bounceinfowhichregisteredbyGuestOSitselftoGuestOS‘s |?2010CloudExGuestOS|--

PVdomU |-- |-- |--

|--trap_info*dst=curr-|--if(trap_table.vector==0x80){} |-- |?2010CloudExControl|--if(guest_mode(regs)){ |--tb=&v- |--ti=&v- |--tb->flags= =ti- |--tb- =ti-}curr-} |?2010CloudExSystemoccurusually,soitbettertodirectsystemcall(ApplicationGuestOSKernel,notpassXen)modifyVIDT[int80].DLP=ring3,whenGuestOSSystemcallring3,yes,IcandoitGuestOSGuestOSdosystemx86_32systemcallinitializationbyvoidinit_int80_direct_trap(structvcpustructtrap_info*ti=&v->arch.guest_context.trap_ctxt[0x80];v->80_desc.a=(ti->cs<<16)|(ti->address&0xffff);v->80_desc.b=(ti->address&0xffff0000)|0x8f00|((TI_GET_DPL(ti)&3)<<13);if(v==current)} |?2010CloudExx86_64systemcallinitializationbyGuest|--

pvdomu|||-- |--|||||| |--||| |--||| |--||||||||--vcpu_guest_context_t||||||||||||||x86_64systemcallcontrol|--HYPERVISOR_IRET =iret_saved.ss|

guestprivilege*/systemcallNO. |?2010CloudExInterrupt |?2010CloudExInterruptArchitecture-ThecontrolflowofsendingirqtoGuest|-- |-- |-- |--|-- |-- |--intack= |--vector= |--return |-- |-- |?2010CloudExThecontrolflowofreading/write|--switch(exit_reason case |--|-- hvm_emulate_ops=}

==|--|-- |-- |?2010CloudExvlapic_mmio_handler= |?2010CloudExHVM |?2010CloudExTimerArchitecture-XenUpdateXenTimebyupdatexentimePeriodicTimerinuseforGuestOS(sendTimerEvent sGuestOSRealSystemVirtual

startuptime=start_time–1970/01/0100:00:00now–start_time

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論