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

Re: [Xen-users] use hypercall in kernel module


  • To: xen-users <xen-users@xxxxxxxxxxxxx>
  • From: Big Strong <fangtuo90@xxxxxxxxx>
  • Date: Wed, 25 May 2016 11:47:19 +0800
  • Delivery-date: Wed, 25 May 2016 03:48:46 +0000
  • List-id: Xen user discussion <xen-users.lists.xen.org>

While we can use privcmd_call in hypercall.h to issue the hypercall in kernel module, it is unclear how to set the arguments to adapt it to registers. 


static inline long privcmd_call(unsigned call,
         unsigned long a1, unsigned long a2,
         unsigned long a3, unsigned long a4,
         unsigned long a5)
{
    __HYPERCALL_DECLS;
    __HYPERCALL_5ARG(a1, a2, a3, a4, a5);
    asm volatile("call *%[call]"
             : __HYPERCALL_5PARAM
             : [call] "a" (&hypercall_page[call])
             : __HYPERCALL_CLOBBER5);
    return (long)__res;
}

Take HYPERCALL_hvm_op as an example, the arguments are op and arg, when the op is HVMOP_altp2m, we need to convert arg to xen_hvm_altp2m_op. Now what if I want to directly assign a xen_hvm_altp2m_op as the argument a2 and HVMOP_altp2m as a1 and __HYPERVISOR_hvm_op as call? How can a2 be assigned as it is defined as a uint64 while xen_hvm_altp2m_op is a structure? Should I use (xen_hvm_altp2m_op *) pointer as a2?

Or is there any example on how to use hypercall in LKM (linux loadable kernel module)? I don't know how to convert the arguments to registers.

2016-05-22 20:30 GMT+08:00 Big Strong <fangtuo90@xxxxxxxxx>:
In user-mode, we can use privcmd to issue hypercalls, how about in kernel? There should be simper way to do that, isn't it?

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

 


Rackspace

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