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

[Xen-devel] Attempted to call hypercall from userspace failed



Hi ALL:
  I am a novice,I have attempted to call hypercall from userspace.It's
failed.
  My OS is Fedora 16(64bit) .
  First,I have created a new hypercall. 
  *xen/include/public*
  #define __HYPERVISOR_tmem_op              38
  #define __HYPERVISOR_print_string           39/*new addition*/
  
  *xen/arch/x86/x86_64*
  ENTRY(hypercall_table)
â
    .quad  do_tmem_op
    .quad  do_print_string
â
  ENTRY(hypercall_args_table)
    .byte 1 /* do_tmem_op  */
    .byte 1 /* do_print_string  */

  *Xen/include/asm-x86/hypercall.h*
  #ifdef  __x86_64__
  â
  extern int
  do_print_string(
         char* message);
  #else

  *xen/arch/x86/mm.c*
  int do_print_string(char *message)
{
  #ifdef __x86_64__
  if(message)
    printk(âMESSAGE(x86_64:%s\n)â,message);
  else
    printk(âMESSAGE(x86_64):Nothing Output!â);
  #endif
    if(message)
    Printk(âMESSAGE(x86_32:%s\n)â,message);
  else
    printk(âMESSAGE(x86_32):Nothing Output!â);
    return 1;
}

hypercall.c
int main(int argc, char *argv[])  
{  
    int fd, ret;  
   char * message;  
    if (argc != 2) {  
        printf("please put one parameter!/n");  
        return -1;  
    }  
   message = (char *) malloc(sizeof(char) * (strlen(argv[1])+1));  
   strcpy(message, argv[1]);  
    privcmd_hypercall_t hcall = {  
        __HYPERVISOR_print_string,  
        {message, 0, 0, 0, 0}  
    };  
    fd = open("/proc/xen/privcmd", O_RDWR);  
    if (fd < 0) {  
        perror("open");  
        exit(1);  
    } else  
        printf("fd = %d/n", fd);  
    ret = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, &hcall);  
    printf("ret = %d/n", ret);  
}  
When I executed ./a.out Hello_world,fd=3 and ret=-1.It's failed.Of course
the command xm dmesg printed nothing.Please tell me where is wrong.Thanks.

--
View this message in context: 
http://xen.1045712.n5.nabble.com/Attempted-to-call-hypercall-from-userspace-failed-tp5521071p5521071.html
Sent from the Xen - Dev mailing list archive at Nabble.com.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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