Xiaofeng Ling
2005-Sep-05 10:41 UTC
[Xen-devel] [PATCH][4/6] Add to virtual device operations
Add two virtual device operations: 1.set the callback irq for event channel 2.setup the hypercall paramerter share page. Signed-off-by: Ke Yu <ke.yu@intel.com> Signed-off-by: Xiaofeng Ling <xiaofeng.ling@intel.com> Signed-off-by: Arun Sharma <arun.sharma@intel.com> diff -r 287d36b46fa3 xen/arch/x86/vmx.c --- a/xen/arch/x86/vmx.c Tue Aug 30 20:36:49 2005 +++ b/xen/arch/x86/vmx.c Fri Sep 2 22:46:13 2005 @@ -1752,6 +1803,81 @@ asm volatile("movq %0,%%cr2": :"r" (d->arch.arch_vmx.cpu_cr2)); #endif } + + +/* map hypercall parameter share page address in monitor pagetable + * map guest virtual address <--> hypervisor virtual address + * the hypervisor virtual address should below HYPERVISOR_VIRT_START, + * so that share page can be treated as a guest page + */ +int map_param_share_page(unsigned long gva, unsigned long hva){ + + unsigned long mfn; + l2_pgentry_t *mpl2e; /* monitor page table l2 */ + l1_pgentry_t *mpl1e; /* monitor page table l1 */ + struct pfn_info *l1_mfn_info; + unsigned long l1_mfn; + struct vcpu* v = current; + struct domain *d = v->domain; + + mfn = __gpfn_to_mfn(d, gva >> PAGE_SHIFT); + mpl2e = current->arch.monitor_vtable; + if ( mpl2e[l2_table_offset(hva)].l2 ){ + printk("map of hva 0x%lx already exists\n",hva); + return -1; + } + + /* alloc l1 page table */ + d->max_pages++; + l1_mfn_info = alloc_domheap_page(d); + if (!l1_mfn_info){ + printk("alloc_domheap_page failed\n"); + return -1; + } + l1_mfn = page_to_pfn(l1_mfn_info); + printk("map_param_share_page: alloc page at 0x%lx\n", l1_mfn); + + /* set l2 page table entry */ + mpl2e[l2_table_offset(hva)] + l2e_from_pfn (l1_mfn, __PAGE_HYPERVISOR); + printk("map_param_share_page: set l2 page table entry\n"); + + /* set l1 page table */ + mpl1e = (l1_pgentry_t *)map_domain_page(l1_mfn); + memset(mpl1e, 0, PAGE_SIZE); + mpl1e[l1_table_offset(hva)] + l1e_from_pfn(mfn, __PAGE_HYPERVISOR); + unmap_domain_page(mpl1e); + printk("map_param_share_page: set l1 page table entry\n"); + + return 0; +} + +asmlinkage unsigned long do_virtual_device_op(unsigned long op, + unsigned long arg1, + unsigned arg2) +{ + switch (op) + { + case SET_CALLBACK_IRQ: + { + if(arg1) + current->domain->arch.vmx_platform.callback_irq = arg1; + else + current->domain->arch.vmx_platform.callback_irq = 0; + return 0; + } + case SET_SHARE_PARAM_MAP: + { + int rc = map_param_share_page(arg1, arg2); + DPRINTK("SET_SHAER_PARAM_MAP: gva=%lx\n",arg1); + return rc; + } + + } + return 0L; +} +#endif /* CONFIG_VMX */ #ifdef TRACE_BUFFER asmlinkage void trace_vmentry (void) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel