版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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三个(hvm下两个子体系)这样的接口这样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得到该异 对于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等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 河北邢台地区2023-2024学年上学期期末考试九年级理综试卷-初中化学
- 领导家电行业的品牌发展计划
- 2025年河南省八省联考高考地理模拟试卷
- 2022年安徽省安庆市公开招聘警务辅助人员辅警笔试自考题2卷含答案
- 2024年河南省平顶山市公开招聘警务辅助人员辅警笔试自考题1卷含答案
- 2023年湖南省岳阳市公开招聘警务辅助人员辅警笔试自考题1卷含答案
- 2022年山西省朔州市公开招聘警务辅助人员辅警笔试自考题1卷含答案
- 英文商务邀请函范本
- 福建省宁德市(2024年-2025年小学六年级语文)部编版阶段练习(上学期)试卷及答案
- 2024年免疫抗疲劳保健品项目项目投资申请报告代可行性研究报告
- 高职院校油层物理说课
- 计算机课件:计算机安全
- SCH壁厚等级对照表
- 道路减速带减速模型分析
- 35kv及以下架空线路施工及验收规范
- 身体健康状况自测表
- PID控制原理与调整方法
- 山东昌乐二中“271高效课堂”解读
- 配电工程竣工资料
- 花键强度校核程序
- 毗尼日用切要20140619最终版
评论
0/150
提交评论