CMPE 283 Lab 1 Submitted By Meghadarshini Umaranganatha 009635899 Ruchira Das 009877387 Saranya Mohan Shruthi Narayanan Spoorthy B Vatsala 1 Identify the function and file containing the following The exit handler hint there are two of them Ans There are two exit handler present in kvm source code and they are contained in the following function and file Exit Handler 1 File vmx c Folder usr scr linux 3 13 8 arch x86 kvm Function kvm vmx exit handlers Exit Handler 2 File svm c Folder usr scr linux 3 13 8 arch x86 kvm Function svm exit handlers The function functions responsible for handling exit on HLT instructions Ans The function responsible for handling exit on HLT instructions are vmx c file nested vmx exit handled struct kvm vcpu vcpu which forwards the control to the nested cpu has struct vmcs12 vmcs12 u32 bit function by using switch case for EXIT REASON HLT and handle halt struct kvm vcpu vcpu function is responsible for emulating the condition svm c file halt interception struct vcpu svm svm is responsible for handlig exit on HLT instruction 2 What is the general workflow of each of the specific instruction causing exit handler functions Eg what must each do in a general sense for each instruction being exited on Ans The general workflow of an exit instruction is as follows I Have to pass the exit reason to the vmx handle exit struct kvm vcpu vcpu II This then passes th value to the kvm vmx exit handlers exit reason which then directs it to the function which would emulate the exit reason III Kvm then enters the switch case with the exit reason once it has emulated the exit IV Then the right appropriate case and its corresponding CPU function is selected 3 Describe the general layout of the KVM source What parts of KVM live in architectural specific subdirectories and what parts of KVM are common Ans The KVM code has been distributed throughout the Kernel code in different ways When the code is common to all architectures then the code is placed separately When it is specific to different architectures then they are clearly distributed in folders that are assigned to said architectures The following files are architecture specific Linux 3 13 8 arch x86 kvm v cpuid c v cpuid h v emulate c v i8254 c v i8254 h v i8259 c v irq c v irq h v Kconfig v kvm cache regs h v lapic c v lapic h v Makefile v mmu c v mmu h v mmu audit c v mmutrace h v paging tmpl h v pmu c v svm c v trace h v tss h v vmx c v x86 c v x86 h include linux v kvm h v kvm host h v kvm para h v kvm x86 emulate h include asm x86 v kvm h v kvm host h v kvm para h v kvm x86 emulate h The common parts of KVM which is at location linux 3 13 8 virt kvm are v ioapic c v ioapic h v iodev h v kvm main c 4 What other architectures contain KVM related architectural specific code Ans Following are the architectures which contain KVM related architectural specific code arm arm64 ia64 mips powerpc s390 tile 5 How does KVM emulate guest instructions when exits occur Ans KVM emulate guest instructions when exit occurs as below v KVM first copies the guest OS i e the virtual OS instructions and puts them in the guest memory v Then its copies the instructions set in the host memory on the processor v Then based on the exit reason the right case is called and action is taken v Now once the execution is done the control of the processor is given back to the guest process using the VM enter command v As the control is now with guest OS it resumes from where I had stopped by copying the instructions in the guest memory back to the processor v This guest OS executes till it comes across some other exit causing instruction 1 For each member in your team provide 1 paragraph detailing what parts of the lab that member implemented researched Megha Worked on KVM hypercall implementation Researched the hypervisor KVM and understood how hypercall is implemented in KVM Created host OS and compiled it after making changes in kernel source code and also created guest OS Figured how the control from guest OS transfers to hypervisor Collected details where to add hypercall in hypervisor where to declare define it and how to use the value passed from guest OS to execute the statements appropriately for that value Finalized the code for hypercall in guest OS and its compilation and also to obtain kernel message in host when control reaches it when hypercall is made Understood answers for lab questions Ruchira Worked on research on the Xen hypervisor tried to find the differences between the two hypervisors Xen and kVM Wrote answers for the questions asked to complete the lab and understood the lab implementation Saranya Shruthi Spoorthy 2 Describe in detail the steps you used to complete the lab Consider your reader to be someone skilled in software development but otherwise unfamiliar with the lab assignment Good answers to this question will be recipes that someone can follow to reproduce your development steps Note I may randomly decide to follow these instructions for random lab assignments so you should make sure they are accurate We used the Ubuntu 14 04 3 LTS Desktop distribution to complete this lab Please find below the complete steps followed to perform the lab Host Setup Installed Ubuntu 14 04 3 LTS on a 32GB usb drive The kernel version that was running before adding the hyper call was 3 19 0 25 generic Installed the dpkg dev package sudo apt get install dpkg dev Downloaded and installed the kernel source code for the presently running version of the kernel cd usr src sudo apt get source linux image uname r This command downloads the tar file and untars the package After this a new folder is added in the location The folder name is linux lts vivid 3 19 0 Hypercall Implementation To implement the new Hypercall changes were added to files vmx c x86 c kvm host h and kvm para h In x86 c file add a new function execute user based hypercall struct kvm vcpu vcpu as follows In vmx c file inside handle vmcall method we add a call to the above created function as follows Also add a declaration for execute user based hypercall struct kvm vcpu vcpu in the kvm host h file In kvm para h file declare the hypercall define KVM HC USER BASED SUPERCALL1 define KVM HC USER BASED SUPERCALL2 6 7 After making the above changes we need to build the new kernel and install the build and modules Move to linux version folder cd linux lts vivid 3 19 0 Install the ncurses dev package sudo apt get install ncurses dev Configure the kernel source make menuconfig
View Full Document
Unlocking...