[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH][2/6] add call entry for vmx guest



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@xxxxxxxxx>
Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>

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(&regs);
         __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@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.