Indirect hypercalls through a hypercall transfer page.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 24 Jan 2006 17:05:45 +0000 (18:05 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 24 Jan 2006 17:05:45 +0000 (18:05 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
16 files changed:
linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S
linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/entry.S
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head.S
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h
linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h
tools/libxc/xc_linux_build.c
tools/libxc/xc_load_elf.c
tools/libxc/xg_private.h
xen/arch/x86/dom0_ops.c
xen/arch/x86/domain_build.c
xen/arch/x86/x86_32/traps.c
xen/arch/x86/x86_64/traps.c
xen/include/asm-x86/domain.h
xen/include/public/dom0_ops.h

index ef23e7ca3c7f0487c04e737fc4e472c5dc29e95b..6c43b26aab5f6456c1a85b8b72bb8826ebed665e 100644 (file)
@@ -333,10 +333,8 @@ iret_exc:
 hypervisor_iret:
        andl $~NMI_MASK, EFLAGS(%esp)
        RESTORE_REGS
-       movl %eax,(%esp)
-       movl $__HYPERVISOR_iret,%eax
-       int $0x82
-       ud2
+       addl $4, %esp
+       jmp  hypercall_page + (__HYPERVISOR_iret * 32)
 
 #if 0 /* XEN */
 ldt_ss:
index 220cf8fd7a5b0dbb2bc18c3bfa4afdfba5761e06..b59c54210161ac6eeaffe7d21a688d7b2977c8f4 100644 (file)
@@ -5,6 +5,7 @@
        .ascii  "GUEST_OS=linux,GUEST_VER=2.6"
        .ascii  ",XEN_VER=xen-3.0"
        .ascii  ",VIRT_BASE=0xC0000000"
+       .ascii  ",HYPERCALL_PAGE=0x104" /* __pa(hypercall_page) >> 12 */
 #ifdef CONFIG_X86_PAE
        .ascii  ",PAE=yes"
 #else
@@ -187,6 +188,9 @@ ENTRY(cpu_gdt_table)
 ENTRY(default_ldt)
 
 .org 0x4000
+ENTRY(hypercall_page)
+
+.org 0x5000
 /*
  * Real beginning of normal "text" segment
  */
index 2fbe90706cd8247632bb11335f7f49caf99fea4c..0e280671654bcc4afd836de64e08fb81f7dd1acb 100644 (file)
          *     };
          * #define VGCF_IN_SYSCALL (1<<8) 
          */
-        .macro HYPERVISOR_IRET flag
-        subq $8*4,%rsp                   # reuse rip, cs, rflags, rsp, ss in the stack
-        movq %rax,(%rsp)
-        movq %r11,1*8(%rsp)
-        movq %rcx,2*8(%rsp)              # we saved %rcx upon exceptions
-        movq $\flag,3*8(%rsp)
-        movq $__HYPERVISOR_iret,%rax
-        syscall
-        .endm
+       .macro HYPERVISOR_IRET flag
+       pushq $\flag
+       jmp  hypercall_page + (__HYPERVISOR_iret * 32)
+       .endm
 
         .macro SWITCH_TO_KERNEL ssoff,adjust=0
        jc  1f
index c22996e8e4e1b774733bd0c8942bcd0412905d41..12f96941e3125d62340f5d3628213bd7fe72de34 100644 (file)
 #include <linux/linkage.h>
 
 .section __xen_guest
-       .ascii  "GUEST_OS=linux,GUEST_VER=2.6,XEN_VER=xen-3.0,VIRT_BASE=0xffffffff80000000"
+       .ascii  "GUEST_OS=linux,GUEST_VER=2.6"
+       .ascii  ",XEN_VER=xen-3.0"
+       .ascii  ",VIRT_BASE=0xffffffff80000000"
+       .ascii  ",HYPERCALL_PAGE=0x10d" /* __pa(hypercall_page) >> 12 */
        .ascii  ",LOADER=generic"
-/*     .ascii  ",PT_MODE_WRITABLE" */
        .byte   0
                 
       
@@ -227,8 +229,10 @@ ENTRY(empty_bad_pmd_table)
 ENTRY(level3_physmem_pgt)
        .quad   0x0000000000105007              /* -> level2_kernel_pgt (so that __va works even before pagetable_init) */
 
-       
-       .org 0xd000
+.org 0xd000
+ENTRY(hypercall_page)
+
+.org 0xe000
 #ifdef CONFIG_ACPI_SLEEP
 ENTRY(wakeup_level4_pgt)
        .quad   0x0000000000102007              /* -> level3_ident_pgt */
index 107f3e8bef2b1290faeb01dce45e8578e3f5791a..a4a533aa6b3f379474e70c945b8bd347a32ad691 100644 (file)
@@ -58,7 +58,9 @@ static int privcmd_ioctl(struct inode *inode, struct file *file,
                        "movl 16(%%eax),%%esi ;"
                        "movl 20(%%eax),%%edi ;"
                        "movl   (%%eax),%%eax ;"
-                       TRAP_INSTR "; "
+                       "shll $5,%%eax ;"
+                       "addl $hypercall_page,%%eax ;"
+                       "call *%%eax ;"
                        "popl %%edi; popl %%esi; popl %%edx; "
                        "popl %%ecx; popl %%ebx"
                        : "=a" (ret) : "0" (&hypercall) : "memory" );
@@ -66,7 +68,10 @@ static int privcmd_ioctl(struct inode *inode, struct file *file,
                {
                        long ign1, ign2, ign3;
                        __asm__ __volatile__ (
-                               "movq %8,%%r10; movq %9,%%r8;" TRAP_INSTR
+                               "movq %8,%%r10; movq %9,%%r8;"
+                               "shlq $5,%%rax ;"
+                               "addq $hypercall_page,%%rax ;"
+                               "call *%%rax"
                                : "=a" (ret), "=D" (ign1),
                                  "=S" (ign2), "=d" (ign3)
                                : "0" ((unsigned long)hypercall.op), 
@@ -75,7 +80,7 @@ static int privcmd_ioctl(struct inode *inode, struct file *file,
                                "3" ((unsigned long)hypercall.arg[2]), 
                                "g" ((unsigned long)hypercall.arg[3]),
                                "g" ((unsigned long)hypercall.arg[4])
-                               : "r11","rcx","r8","r10","memory");
+                               : "r8", "r10", "memory" );
                }
 #elif defined (__ia64__)
                __asm__ __volatile__ (
index 04edbd3741507d8125e35029484f5a38767c29d3..b81ea36cb401a3f1276e73b472b1f61cf4197762 100644 (file)
 #include <asm-xen/xen-public/sched.h>
 #include <asm-xen/xen-public/nmi.h>
 
+#define __STR(x) #x
+#define STR(x) __STR(x)
+
 #define _hypercall0(type, name)                        \
 ({                                             \
        long __res;                             \
        asm volatile (                          \
-               TRAP_INSTR                      \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res)                  \
-               : "0" (__HYPERVISOR_##name)     \
                : "memory" );                   \
        (type)__res;                            \
 })
@@ -49,9 +51,9 @@
 ({                                                             \
        long __res, __ign1;                                     \
        asm volatile (                                          \
-               TRAP_INSTR                                      \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res), "=b" (__ign1)                   \
-               : "0" (__HYPERVISOR_##name), "1" ((long)(a1))   \
+               : "1" ((long)(a1))                              \
                : "memory" );                                   \
        (type)__res;                                            \
 })
 ({                                                             \
        long __res, __ign1, __ign2;                             \
        asm volatile (                                          \
-               TRAP_INSTR                                      \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2)    \
-               : "0" (__HYPERVISOR_##name), "1" ((long)(a1)),  \
-               "2" ((long)(a2))                                \
+               : "1" ((long)(a1)), "2" ((long)(a2))            \
                : "memory" );                                   \
        (type)__res;                                            \
 })
 ({                                                             \
        long __res, __ign1, __ign2, __ign3;                     \
        asm volatile (                                          \
-               TRAP_INSTR                                      \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
                "=d" (__ign3)                                   \
-               : "0" (__HYPERVISOR_##name), "1" ((long)(a1)),  \
-               "2" ((long)(a2)), "3" ((long)(a3))              \
+               : "1" ((long)(a1)), "2" ((long)(a2)),           \
+               "3" ((long)(a3))                                \
                : "memory" );                                   \
        (type)__res;                                            \
 })
 ({                                                             \
        long __res, __ign1, __ign2, __ign3, __ign4;             \
        asm volatile (                                          \
-               TRAP_INSTR                                      \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
                "=d" (__ign3), "=S" (__ign4)                    \
-               : "0" (__HYPERVISOR_##name), "1" ((long)(a1)),  \
-               "2" ((long)(a2)), "3" ((long)(a3)),             \
-               "4" ((long)(a4))                                \
+               : "1" ((long)(a1)), "2" ((long)(a2)),           \
+               "3" ((long)(a3)), "4" ((long)(a4))              \
                : "memory" );                                   \
        (type)__res;                                            \
 })
 ({                                                             \
        long __res, __ign1, __ign2, __ign3, __ign4, __ign5;     \
        asm volatile (                                          \
-               TRAP_INSTR                                      \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
                "=d" (__ign3), "=S" (__ign4), "=D" (__ign5)     \
-               : "0" (__HYPERVISOR_##name), "1" ((long)(a1)),  \
-               "2" ((long)(a2)), "3" ((long)(a3)),             \
-               "4" ((long)(a4)), "5" ((long)(a5))              \
+               : "1" ((long)(a1)), "2" ((long)(a2)),           \
+               "3" ((long)(a3)), "4" ((long)(a4)),             \
+               "5" ((long)(a5))                                \
                : "memory" );                                   \
        (type)__res;                                            \
 })
index 521f004c000e510522acb9c11950bbbb83dcf205..840cdb8f7a4c200d35402bc19524f5629d8ea42c 100644 (file)
 #include <asm-xen/xen-public/xen.h>
 #include <asm-xen/xen-public/sched.h>
 
-#define __syscall_clobber "r11","rcx","memory"
+#define __STR(x) #x
+#define STR(x) __STR(x)
 
 #define _hypercall0(type, name)                        \
 ({                                             \
        long __res;                             \
        asm volatile (                          \
-               TRAP_INSTR                      \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res)                  \
-               : "0" (__HYPERVISOR_##name)     \
-               : __syscall_clobber );          \
+               : "memory" );                   \
        (type)__res;                            \
 })
 
 ({                                                             \
        long __res, __ign1;                                     \
        asm volatile (                                          \
-               TRAP_INSTR                                      \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res), "=D" (__ign1)                   \
-               : "0" (__HYPERVISOR_##name), "1" ((long)(a1))   \
-               : __syscall_clobber );                          \
+               : "1" ((long)(a1))                              \
+               : "memory" );                                   \
        (type)__res;                                            \
 })
 
 ({                                                             \
        long __res, __ign1, __ign2;                             \
        asm volatile (                                          \
-               TRAP_INSTR                                      \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2)    \
-               : "0" (__HYPERVISOR_##name), "1" ((long)(a1)),  \
-               "2" ((long)(a2))                                \
-               : __syscall_clobber );                          \
+               : "1" ((long)(a1)), "2" ((long)(a2))            \
+               : "memory" );                                   \
        (type)__res;                                            \
 })
 
 ({                                                             \
        long __res, __ign1, __ign2, __ign3;                     \
        asm volatile (                                          \
-               TRAP_INSTR                                      \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
                "=d" (__ign3)                                   \
-               : "0" (__HYPERVISOR_##name), "1" ((long)(a1)),  \
-               "2" ((long)(a2)), "3" ((long)(a3))              \
-               : __syscall_clobber );                          \
+               : "1" ((long)(a1)), "2" ((long)(a2)),           \
+               "3" ((long)(a3))                                \
+               : "memory" );                                   \
        (type)__res;                                            \
 })
 
 ({                                                             \
        long __res, __ign1, __ign2, __ign3;                     \
        asm volatile (                                          \
-               "movq %8,%%r10; " TRAP_INSTR                    \
+               "movq %8,%%r10; "                               \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
                "=d" (__ign3)                                   \
-               : "0" (__HYPERVISOR_##name), "1" ((long)(a1)),  \
-               "2" ((long)(a2)), "3" ((long)(a3)),             \
-               "g" ((long)(a4))                                \
-               : __syscall_clobber, "r10" );                   \
+               : "1" ((long)(a1)), "2" ((long)(a2)),           \
+               "3" ((long)(a3)), "g" ((long)(a4))              \
+               : "memory", "r10" );                            \
        (type)__res;                                            \
 })
 
 ({                                                             \
        long __res, __ign1, __ign2, __ign3;                     \
        asm volatile (                                          \
-               "movq %8,%%r10; movq %9,%%r8; " TRAP_INSTR      \
+               "movq %8,%%r10; movq %9,%%r8; "                 \
+               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
                "=d" (__ign3)                                   \
-               : "0" (__HYPERVISOR_##name), "1" ((long)(a1)),  \
-               "2" ((long)(a2)), "3" ((long)(a3)),             \
-               "g" ((long)(a4)), "g" ((long)(a5))              \
-               : __syscall_clobber, "r10", "r8" );             \
+               : "1" ((long)(a1)), "2" ((long)(a2)),           \
+               "3" ((long)(a3)), "g" ((long)(a4)),             \
+               "g" ((long)(a5))                                \
+               : "memory", "r10", "r8" );                      \
        (type)__res;                                            \
 })
 
index 23fc456554b9b91ee123fd04066d7d0c6947293b..6e189945307924b68245dfa61664feab546438ca 100644 (file)
@@ -429,10 +429,12 @@ static int setup_guest(int xc_handle,
                        unsigned int console_evtchn, unsigned long *console_mfn)
 {
     unsigned long *page_array = NULL;
-    unsigned long count, i;
+    unsigned long count, i, hypercall_pfn;
     start_info_t *start_info;
     shared_info_t *shared_info;
     xc_mmu_t *mmu = NULL;
+    char *p;
+    DECLARE_DOM0_OP;
     int rc;
 
     unsigned long nr_pt_pages;
@@ -715,6 +717,20 @@ static int setup_guest(int xc_handle,
     if ( xc_finish_mmu_updates(xc_handle, mmu) )
         goto error_out;
 
+    p = strstr(dsi.xen_guest_string, "HYPERCALL_PAGE=");
+    if ( p != NULL )
+    {
+        p += strlen("HYPERCALL_PAGE=");
+        hypercall_pfn = strtoul(p, NULL, 16);
+        if ( hypercall_pfn >= nr_pages )
+            goto error_out;
+        op.u.hypercall_init.domain = (domid_t)dom;
+        op.u.hypercall_init.mfn    = page_array[hypercall_pfn];
+        op.cmd = DOM0_HYPERCALL_INIT;
+        if ( xc_dom0_op(xc_handle, &op) )
+            goto error_out;
+    }
+
     free(mmu);
     free(page_array);
 
index ac8fb81ccc9032437eae56bc34d8fe984f47349f..b1fc2af4c0bd903ac5cf71f7281543f009a0c524 100644 (file)
@@ -120,6 +120,7 @@ static int parseelfimage(char *image,
 
         break;
     }
+
     if ( guestinfo == NULL )
     {
 #ifdef __ia64__
@@ -130,6 +131,8 @@ static int parseelfimage(char *image,
 #endif
     }
 
+    dsi->xen_guest_string = guestinfo;
+
     for ( h = 0; h < ehdr->e_phnum; h++ ) 
     {
         phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
index f96c187d954d31ff77f1d972137c38ead8019f0c..755c682896e203636422cfd74d41c9fdaf72c0bb 100644 (file)
@@ -136,6 +136,9 @@ struct domain_setup_info
     unsigned int  pae_kernel;
     unsigned long symtab_addr;
     unsigned long symtab_len;
+
+    /* __xen_guest info string for convenient loader parsing. */
+    char *xen_guest_string;
 };
 
 typedef int (*parseimagefunc)(char *image, unsigned long image_size,
index 1ee7efd37b45949885d48d41765b13e9c9b5260e..848d7f000eee0d5e706f9307c8e64da598f66067 100644 (file)
@@ -50,9 +50,6 @@ long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op)
 {
     long ret = 0;
 
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
-
     switch ( op->cmd )
     {
 
@@ -409,6 +406,35 @@ long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op)
     }
     break;
 
+    case DOM0_HYPERCALL_INIT:
+    {
+        struct domain *d; 
+        unsigned long mfn = op->u.hypercall_init.mfn;
+        void *hypercall_page;
+
+        ret = -ESRCH;
+        if ( unlikely((d = find_domain_by_id(
+            op->u.hypercall_init.domain)) == NULL) )
+            break;
+
+        ret = -EACCES;
+        if ( !pfn_valid(mfn) ||
+             !get_page_and_type(pfn_to_page(mfn), d, PGT_writable_page) )
+        {
+            put_domain(d);
+            break;
+        }
+
+        ret = 0;
+
+        hypercall_page = map_domain_page(mfn);
+        hypercall_page_initialise(hypercall_page);
+        unmap_domain_page(hypercall_page);
+
+        put_domain(d);
+    }
+    break;
+
     default:
         ret = -ENOSYS;
         break;
index 84d84a66cf4214074f20cf335f6b8073abeb1b5d..bf394416a8b180f2c3bb77af29708afd309de1f1 100644 (file)
@@ -146,6 +146,8 @@ int construct_dom0(struct domain *d,
     struct pfn_info *page = NULL;
     start_info_t *si;
     struct vcpu *v = d->vcpu[0];
+    char *p;
+    unsigned long hypercall_page;
 #if defined(__i386__)
     char *image_start  = (char *)_image_start;  /* use lowmem mappings */
     char *initrd_start = (char *)_initrd_start; /* use lowmem mappings */
@@ -239,7 +241,8 @@ int construct_dom0(struct domain *d,
                xen_pae ? "yes" : "no", dom0_pae ? "yes" : "no");
         return -EINVAL;
     }
-    if (strstr(dsi.xen_section_string, "SHADOW=translate"))
+
+    if ( strstr(dsi.xen_section_string, "SHADOW=translate") )
         opt_dom0_translate = 1;
 
     /* Align load address to 4MB boundary. */
@@ -604,6 +607,23 @@ int construct_dom0(struct domain *d,
     /* Copy the OS image and free temporary buffer. */
     (void)loadelfimage(&dsi);
 
+    p = strstr(dsi.xen_section_string, "HYPERCALL_PAGE=");
+    if ( p != NULL )
+    {
+        p += strlen("HYPERCALL_PAGE=");
+        hypercall_page = simple_strtoul(p, NULL, 16);
+        hypercall_page = dsi.v_start + (hypercall_page << PAGE_SHIFT);
+        if ( (hypercall_page < dsi.v_start) || (hypercall_page >= v_end) )
+        {
+            write_ptbase(current);
+            local_irq_enable();
+            printk("Invalid HYPERCALL_PAGE field in guest header.\n");
+            return -1;
+        }
+
+        hypercall_page_initialise((void *)hypercall_page);
+    }
+
     init_domheap_pages(
         _image_start, (_image_start+image_len+PAGE_SIZE-1) & PAGE_MASK);
 
index 95b69a14bdced0f12fd1f5a5006d873d2b5ef9bc..587287d0bbaf470517dd7872711ae8fb82ade8fb 100644 (file)
@@ -298,6 +298,33 @@ long do_set_callbacks(unsigned long event_selector,
     return 0;
 }
 
+void hypercall_page_initialise(void *hypercall_page)
+{
+    char *p;
+    int i;
+
+    /* Fill in all the transfer points with template machine code. */
+    for ( i = 0; i < (PAGE_SIZE / 32); i++ )
+    {
+        p = (char *)(hypercall_page + (i * 32));
+        *(u8  *)(p+ 0) = 0xb8;    /* mov  $<i>,%eax */
+        *(u32 *)(p+ 1) = i;
+        *(u16 *)(p+ 5) = 0x82cd;  /* int  $0x82 */
+        *(u8  *)(p+ 7) = 0xc3;    /* ret */
+    }
+
+    /*
+     * HYPERVISOR_iret is special because it doesn't return and expects a 
+     * special stack frame. Guests jump at this transfer point instead of 
+     * calling it.
+     */
+    p = (char *)(hypercall_page + (__HYPERVISOR_iret * 32));
+    *(u8  *)(p+ 0) = 0x50;    /* push %eax */
+    *(u8  *)(p+ 1) = 0xb8;    /* mov  $__HYPERVISOR_iret,%eax */
+    *(u32 *)(p+ 2) = __HYPERVISOR_iret;
+    *(u16 *)(p+ 6) = 0x82cd;  /* int  $0x82 */
+}
+
 /*
  * Local variables:
  * mode: C
index 9756c545891cddead59c741ef766e9c982ba8c81..ebf364cf8c741e7f1c1cf782562771feca90a538 100644 (file)
@@ -268,6 +268,39 @@ long do_set_callbacks(unsigned long event_address,
     return 0;
 }
 
+void hypercall_page_initialise(void *hypercall_page)
+{
+    char *p;
+    int i;
+
+    /* Fill in all the transfer points with template machine code. */
+    for ( i = 0; i < (PAGE_SIZE / 32); i++ )
+    {
+        p = (char *)(hypercall_page + (i * 32));
+        *(u8  *)(p+ 0) = 0x51;    /* push %rcx */
+        *(u16 *)(p+ 1) = 0x5341;  /* push %r11 */
+        *(u8  *)(p+ 3) = 0xb8;    /* mov  $<i>,%eax */
+        *(u32 *)(p+ 4) = i;
+        *(u16 *)(p+ 8) = 0x050f;  /* syscall */
+        *(u16 *)(p+10) = 0x5b41;  /* pop  %r11 */
+        *(u8  *)(p+12) = 0x59;    /* pop  %rcx */
+        *(u8  *)(p+13) = 0xc3;    /* ret */
+    }
+
+    /*
+     * HYPERVISOR_iret is special because it doesn't return and expects a 
+     * special stack frame. Guests jump at this transfer point instead of 
+     * calling it.
+     */
+    p = (char *)(hypercall_page + (__HYPERVISOR_iret * 32));
+    *(u8  *)(p+ 0) = 0x50;    /* push %rax */
+    *(u8  *)(p+ 1) = 0x51;    /* push %rcx */
+    *(u16 *)(p+ 2) = 0x5341;  /* push %r11 */
+    *(u8  *)(p+ 4) = 0xb8;    /* mov  $__HYPERVISOR_iret,%eax */
+    *(u32 *)(p+ 5) = __HYPERVISOR_iret;
+    *(u16 *)(p+ 9) = 0x050f;  /* syscall */
+}
+
 /*
  * Local variables:
  * mode: C
index 6438757d67c3ee53c1bacda4b762472a08c0c846..687dce5a3007f14a8346df0f1b690989c0f5924b 100644 (file)
@@ -51,6 +51,12 @@ extern void mapcache_init(struct domain *);
 /* x86/64: toggle guest between kernel and user modes. */
 extern void toggle_guest_mode(struct vcpu *);
 
+/*
+ * Initialise a hypercall-transfer page. The given pointer must be mapped
+ * in Xen virtual address space (accesses are not validated or checked).
+ */
+extern void hypercall_page_initialise(void *);
+
 struct arch_domain
 {
     l1_pgentry_t *mm_perdomain_pt;
index 9e59e771b1a7831e3a2456479f50f6ac89721437..4a70a77e490a13da118c4af99e32b1be81488db8 100644 (file)
@@ -425,6 +425,12 @@ typedef struct {
     uint8_t allow_access;     /* allow (!0) or deny (0) access to range? */
 } dom0_iomem_permission_t;
  
+#define DOM0_HYPERCALL_INIT   48
+typedef struct {
+    domid_t  domain;          /* domain to be affected */
+    unsigned long mfn;        /* machine frame to be initialised */
+} dom0_hypercall_init_t;
 typedef struct {
     uint32_t cmd;
     uint32_t interface_version; /* DOM0_INTERFACE_VERSION */
@@ -465,6 +471,7 @@ typedef struct {
         dom0_setdebugging_t      setdebugging;
         dom0_irq_permission_t    irq_permission;
         dom0_iomem_permission_t  iomem_permission;
+        dom0_hypercall_init_t    hypercall_init;
         uint8_t                  pad[128];
     } u;
 } dom0_op_t;