Changes between Version 1 and Version 2 of GSoC/2014/ParavirtualizationOfRTEMS

Aug 17, 2014, 4:53:21 PM (6 years ago)
Youren Shen


  • GSoC/2014/ParavirtualizationOfRTEMS

    v1 v2  
    25 The POK initialize the GDT and IDT in this two function.  For more details, please see this two blogs.[ POK Startup Flow] and [ The syscall system in POK]=  The POK context switch function.  =
     25The POK initialize the GDT and IDT in this two function.  For more details, please see this two blogs.[ POK Startup Flow] and [ The syscall system in POK]=  The POK context switch function  =
    2727This function is interesting because it’s different with other operating system. It will used the structure context_t to emulate the interrupt and interrupt return behavior.
    2929For more detail please see this [ blog].
     30=  The separation between POK kernel and virtualization  =
     32To separate the POK BSP to x86-qemu and x86-qemu-vmm will benefit to the paravirtualization, on the point that the change of x86-qemu-vmm will not influence the normal x86-qemu, and also the change of x86-qemu-vmm will be more clear.   
     33Where to change: There are two situations. Firstly , on some files there are only some of lines which are for virtualization only. In this situation, we use the macro POK_NEEDS_X86_VMM to control compiler. Secondly, if one file is for virtualization only, then using macro in Makefile. Here are two example:=  Separate in one source file  =
     35In arch.c, the function pok_arch_event_register derive to types, one is for x86-qemu, the other, of course is for x86-qemu-vmm.   
     37diff --git a/kernel/arch/x86/arch.c b/kernel/arch/x86/arch.c
     38index 917f3f3..1d54dda 100644
     39--- a/kernel/arch/x86/arch.c
     40+++ b/kernel/arch/x86/arch.c
     41@@ -58,6 +58,7 @@ pok_ret_t pok_arch_idle()
     42 }
     45+#ifdef POK_NEEDS_X86_VMM
     46 extern void pok_irq_prologue_0(void);
     47 extern void pok_irq_prologue_1(void);
     48 extern void pok_irq_prologue_2(void);
     49@@ -119,6 +120,20 @@ pok_ret_t pok_arch_event_register  (uint8_t vector,
     50   }
     51 }
     54+pok_ret_t pok_arch_event_register  (uint8_t vector,
     55+                                    void (*handler)(void))
     57+  pok_idt_set_gate (vector,
     58+                   GDT_CORE_CODE_SEGMENT << 3,
     59+               (uint32_t) handler,
     60+                   IDTE_TRAP,
     61+                   3);
     63+  return (POK_ERRNO_OK);
     65+#endif /* POK_NEEDS_X86_VMM */
     66}}}=  Separate in Makefile  =
     68If one whole file is for virtualization only, we can change the Makefile to separate it. Here is an example:
     70diff --git a/kernel/arch/x86/Makefile b/kernel/arch/x86/Makefile
     71index c486d47..f9cba01 100644
     72--- a/kernel/arch/x86/Makefile
     73+++ b/kernel/arch/x86/Makefile
     74@@ -13,10 +13,14 @@ LO_OBJS=   arch.o      \
     75            space.o     \
     76            syscalls.o  \
     77            interrupt.o \
     78-          interrupt_prologue.o    \
     79            pci.o       \
     80            exceptions.o
     82+ifeq ($(BSP),x86-qemu-vmm)
     84+LO_OBJS+= interrupt_prologue.o
     87 LO_DEPS=   $(BSP)/$(BSP).lo
     89 all: $(LO_TARGET)
     91Now I hope it's clear enough, and the change will be used in the next steps.
     92=  Hypercall  =
     94The hypercall, as a mechanism imitate from syscall, is an way to using the hypervisor’s resources or notify hypervisor some events.
     95Here is the change make in POK kernel.
     97# Add a pok_hypercall_init in pok_event_init, also should add POK_NEES_X86_VMM to guard this function.   
     98#. Add the two head file, kernel/include/core/hypercall.h and libpok/include/core/hypercall.h, and build the corresponding structure and declaration.   
     99#. implement the corresponding functions in corresponding .c files. That is:   
     100#. kernel/arch/x86/hypercall.c, using this file to build the hypercall_gate.
     101#. kernel/core/hypercall.c, in this file, the pok_core_hypercall will deal with the hypercall.
     102#. modify the kernel/include/arch/x86/interrupt.h, add the support of hypercall handler.
     103#. add libpok/arch/x86/hypercall.c, in this file, we implement the pok_do_hypercall, which will invoke the soft interrupt.
     104#. modified interrelated Makefile to assure those file will work when the BSP is x86-qemu-vmm, also will not influence the normal POK, when the BSP is not x86-qemu-vmm.
     106For more details please see this [ blog].=  vCPU in partition  =
     109The vcpu is part of schedule in VMM, to manage the processor, and the arch-dependent structure (arch-vcpu) is relevant with current partition.   
     110As a result, first, the whole structure of vcpu is part of processor management, should be placed in kernel.   
     112I build a new file vcpu.h in kernel/include, and put the vcpu structure definition in it. Then build a arch_vcpu.h in kernel/arch/x86, and put the arch_vcpu in it. in this file, I use the context_t in this structure to contain user_regs.   
     113Also in the arch_vcpu, I put a irq_desc struct, to store interrupt information.   
     114Then I builds a new file vcpu.c in kernel/core, and implement the alloc_vcpu function in this file. This function relies on some arch-dependent functions, like alloc_vcpu_struct and vcpu_initialize function. So I build a new file arch_vcpu.c in pok_kernel/arch/x86, and put the arch-dependent functions in.
     116Also, I modify some file, like pok/kernel/include/core/partition.h. In this file, I planed to add a vcpu list head in partitions. Another file modified is kernel/core/sched.c, In this file, I add some empty function, because the schedule for vcpu is not necessary.
     118Finally, I add the alloc_vcpu in partition_init.
     119All the function will be test in this week.
     121There are something should be noted:
     122#The space alloced by alloc_vcpu_struct can not be free. So once the vcpu has been alloced, it can't be destroyed. As a result, the vcpu can be dynamic. So maybe we can alloc it in aadl file in the future.
     123#In the function vcpu_initialize, we planed to alloc schedule function, but as for now, the schedule for vcpu is not essential, so the function is empty for now.
     124#The function declarations in head files is omited in this blog.
     125New files
     130Modified files
     133Reused structure
     134#The context_t is reused in arch_vcpu, to put the user_regs.
     135#The interrupt_frame is reused in arch_vcpu, to put the interrupt information.
     137For more details please see this [ blog].
     138=  Register interrupt handler for vCPU  =
     141The Guest OS should register interrupt handler first, we should replace all native interrupt function in RTEMS as this Register function for vCPU in paravirtualization layer.
     143This function is implement by Hypercall. We add a new Hypercall, and implement the core function.
     144=  Add a new hypercall  =
     146New hypercall number
     148POK_HYPERCALL_IRQ_REGISTER_VCPU          =  30,
     151New case in pok_core_hypercall
     153pok_ret_t pok_core_hypercall (const pok_hypercall_id_t       hypercall_id,
     154                            const pok_hypercall_args_t*    args,
     155                            const pok_hypercall_info_t*    infos)
     158  /* register interrupt delivery to vcpu */
     160       return pok_bsp_irq_register_vcpu(args->arg1,(void(*)(uint8_t)) ((args->arg2 + infos->base_addr)));
     161       break;
     162   /* unregister interrupt delivery to vcpu */
     164       return pok_bsp_irq_unregister_vcpu(args->arg1);
     165       break;
     170For more details please see this [ blog].