This patch add the entry to hypercall for vmx guest. vmx guest use vmcall to invoke hypercall. This patch use the original hypercall table with a permit check. If you think use a seperate table it better, I''ll send another patch later. 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 @@ -1463,9 +1463,12 @@ char print_buf[BUF_SIZ]; static int index; -static void vmx_print_line(const char c, struct vcpu *d) -{ - +asmlinkage unsigned long do_vmx_print_line(unsigned long ch) +{ + +#if VMX_DEBUG + char c = (char)ch; + struct vcpu *d = current; if (index == MAX_LINE || c == ''\n'') { if (index == MAX_LINE) { print_buf[index++] = c; @@ -1476,7 +1479,55 @@ } else print_buf[index++] = c; -} + return 0; +#endif + return -ENOSYS; +} + +unsigned char vmx_hypercall_permit[NR_hypercalls/sizeof(unsigned char)] +{ + 0x2, /* do_mmu_update */ + 0x78, /* do_dom_mem_op 12 + do_multicall 13 + do_update_va_mapping 14 + */ + 0x13, /* do_event_channel_op 16 + do_xen_version 17 + do_grant_table_op 20 + */ + 0x10 /* do_virtual_device_op 28*/ +}; +#if defined(__i386__) +void vmx_do_hypercall(struct cpu_user_regs *pregs) +{ + unsigned long retcode; + + /* Check whether this hypercall is permited from vmx domain*/ + if(unlikely(!test_bit(pregs->eax, &vmx_hypercall_permit[0]))){ + printk("not permit hypercall, %d\n", pregs->eax); + return; + } + __asm__ __volatile__( + "pushl %6\n\t" + "pushl %5\n\t" + "pushl %4\n\t" + "pushl %3\n\t" + "pushl %2\n\t" + "call *(hypercall_table)(,%0,4)\n\t" + "addl $20, %%esp\n\t" + :"=&a"(retcode) + :"0"(pregs->eax), "r"(pregs->ebx), "r"(pregs->ecx), + "r"(pregs->edx), "r"(pregs->esi), "r"(pregs->edi) + ); + pregs->eax = retcode; + return; +} +#else +void vmx_do_hypercall(struct cpu_user_regs *pregs) +{ + printk("not supported yet!\n"); +} +#endif void save_vmx_cpu_user_regs(struct cpu_user_regs *ctxt) { @@ -1691,7 +1742,7 @@ __vmread(GUEST_RIP, &eip); __vmread(EXIT_QUALIFICATION, &exit_qualification); - vmx_print_line(regs.eax, v); /* provides the current domain */ + vmx_do_hypercall(®s); __update_guest_eip(inst_len); break; case EXIT_REASON_CR_ACCESS: @@ -1772,7 +1898,6 @@ return; } #endif -#endif /* CONFIG_VMX */ /* * Local variables: diff -r 287d36b46fa3 xen/include/public/arch-x86_32.h --- a/xen/include/public/arch-x86_32.h Tue Aug 30 20:36:49 2005 +++ b/xen/include/public/arch-x86_32.h Fri Sep 2 22:46:13 2005 @@ -42,7 +42,12 @@ #define FLAT_USER_SS FLAT_RING3_SS /* And the trap vector is... */ +#if defined (CONFIG_VMX_GUEST) +/*for VMX paravirtualized driver*/ +#define TRAP_INSTR ".byte 0x0f,0x01,0xc1\n" +#else #define TRAP_INSTR "int $0x82" +#endif /* _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ling, Xiaofeng
2005-Sep-05 14:36 UTC
RE: [Xen-devel] [PATCH][2/6] add call entry for vmx guest
Attach is the alternative patch to use a separate hypercall table for vmx guest. Xiaofeng Ling <> wrote:> This patch add the entry to hypercall for vmx guest. > vmx guest use vmcall to invoke hypercall. > This patch use the original hypercall table with a permit check. > If you think use a seperate table it better, I''ll send another patch > later._______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ling, Xiaofeng
2005-Sep-07 03:14 UTC
RE: [Xen-devel] [PATCH][2/6] add call entry for vmx guest
Ian and Keir Do you have more suggestion beside the seperate hypercall table for para-driver? some other possible alternative: 1. move the change to grant_table.c to vmx.c, and use a virtual_device_op to setup up the grant table share page so that grant_table.c don''t need change. 2. move the logic of copying hypercall paramter to share page to hypervisor instead of in guest. then share page is not needed. but the copy overhead maybe bigger because each copy need to map. Ling, Xiaofeng <> wrote:> Attach is the alternative patch to use a separate hypercall table for > vmx guest. > > Xiaofeng Ling <> wrote: >> This patch add the entry to hypercall for vmx guest. >> vmx guest use vmcall to invoke hypercall. >> This patch use the original hypercall table with a permit check. >> If you think use a seperate table it better, I''ll send another patch >> later._______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel