All of lore.kernel.org
 help / color / mirror / Atom feed
* Using Xen's hypercall interface?
@ 2014-07-06 22:23 Rig Gel
  2014-07-06 23:26 ` Andrew Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Rig Gel @ 2014-07-06 22:23 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 915 bytes --]

Hi all,

- I'm sorry if this is a repost, I was informed that this is the correct
mailing list only after sending a msg to xen-users -

I would like to compile a simple ELF which would make a simple a hypercall
from a guest in order to
learn a bit more about the Xen Hypercall interface.
I tried including the hypervisor.h and -I'ing the ./extras/mini-os/ dir but
it seems that I'm missing a few flags or paths in order ot make it fully
compile correctly

Can anyone hint or explain a bit what is the appropriate way to link
against Xen's header files ?
I only need hypervisor.h in order to call some hypercalls

Attached below a sample of my code -

#include <hypervisor.h>

...
snip
...

void test_xen_version(int vers) {
    HYPERVISOR_xen_version(vers);
}

( using the xe_version hypercall is just a mere example, I would like to
just know how to link/compile correctly against the required header
files/libs )

[-- Attachment #1.2: Type: text/html, Size: 2577 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using Xen's hypercall interface?
  2014-07-06 22:23 Using Xen's hypercall interface? Rig Gel
@ 2014-07-06 23:26 ` Andrew Cooper
       [not found]   ` <CABUdxx7cynbosFFmids7==kLY1kAj8utS8jfWgr3O-UhUrS2dA@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2014-07-06 23:26 UTC (permalink / raw)
  To: Rig Gel, xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1796 bytes --]

On 06/07/2014 23:23, Rig Gel wrote:
> Hi all,
>
> - I'm sorry if this is a repost, I was informed that this is the
> correct mailing list only after sending a msg to xen-users - 
>
> I would like to compile a simple ELF which would make a simple a
> hypercall from a guest in order to
> learn a bit more about the Xen Hypercall interface.
> I tried including the hypervisor.h and -I'ing the ./extras/mini-os/
> dir but it seems that I'm missing a few flags or paths in order ot
> make it fully compile correctly 
>
> Can anyone hint or explain a bit what is the appropriate way to link
> against Xen's header files ? 
> I only need hypervisor.h in order to call some hypercalls 
>
> Attached below a sample of my code -
>
> #include <hypervisor.h>
>
> ...
> snip 
> ...
>
> void test_xen_version(int vers) {
>     HYPERVISOR_xen_version(vers);
> }
>
> ( using the xe_version hypercall is just a mere example, I would like
> to just know how to link/compile correctly against the required header
> files/libs )

It is not possible to make hypercalls from userspace directly.  Allowing
such would cause all kinds of security problems.  Linux and other
operating systems a kernel driver which allow hypercalls via ioctl()s on
/dev/xen/privcmd.

You are best starting with libxenctrl which is a thin userspace library
including OS abstraction to make hypercalls.

>From memory, something like:

#include <stdio.h>
#include <xenctrl.h>

int main(void)
{
    xc_interface *xch = xc_interface_open(NULL, NULL, 0);
    int ver = xc_version(xch, XENVER_version, NULL);

    printf("Xen version %d.%d\n", ver >> 16, ver & 0xffff);
    xc_interface_close(xch);
    return 0;
}

and compiled with `gcc foo.c -o foo -I/path/to/xenctrl.h
-L/path/to/libxenctrl.so -lxenctrl`

ought to get you started.

~Andrew

[-- Attachment #1.2: Type: text/html, Size: 4605 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using Xen's hypercall interface?
       [not found]   ` <CABUdxx7cynbosFFmids7==kLY1kAj8utS8jfWgr3O-UhUrS2dA@mail.gmail.com>
@ 2014-07-07 17:31     ` Rig Gel
  2014-07-08 15:03       ` Ian Campbell
  0 siblings, 1 reply; 4+ messages in thread
From: Rig Gel @ 2014-07-07 17:31 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 2167 bytes --]

> Hi
>
> /proc/xen/privcmd seem to exist only from dom0,
> is there any extension or ko i should load in order to find it on other
> kernels ?
>
>
>
>
> On Mon, Jul 7, 2014 at 2:26 AM, Andrew Cooper <andrew.cooper3@citrix.com>
> wrote:
>
>>  On 06/07/2014 23:23, Rig Gel wrote:
>>
>>  Hi all,
>>
>>  - I'm sorry if this is a repost, I was informed that this is the
>> correct mailing list only after sending a msg to xen-users -
>>
>>  I would like to compile a simple ELF which would make a simple a
>> hypercall from a guest in order to
>> learn a bit more about the Xen Hypercall interface.
>> I tried including the hypervisor.h and -I'ing the ./extras/mini-os/ dir
>> but it seems that I'm missing a few flags or paths in order ot make it
>> fully compile correctly
>>
>>  Can anyone hint or explain a bit what is the appropriate way to link
>> against Xen's header files ?
>> I only need hypervisor.h in order to call some hypercalls
>>
>>  Attached below a sample of my code -
>>
>>  #include <hypervisor.h>
>>
>>  ...
>> snip
>> ...
>>
>>  void test_xen_version(int vers) {
>>     HYPERVISOR_xen_version(vers);
>>  }
>>
>>  ( using the xe_version hypercall is just a mere example, I would like
>> to just know how to link/compile correctly against the required header
>> files/libs )
>>
>>
>> It is not possible to make hypercalls from userspace directly.  Allowing
>> such would cause all kinds of security problems.  Linux and other operating
>> systems a kernel driver which allow hypercalls via ioctl()s on
>> /dev/xen/privcmd.
>>
>> You are best starting with libxenctrl which is a thin userspace library
>> including OS abstraction to make hypercalls.
>>
>> From memory, something like:
>>
>> #include <stdio.h>
>> #include <xenctrl.h>
>>
>> int main(void)
>> {
>>     xc_interface *xch = xc_interface_open(NULL, NULL, 0);
>>     int ver = xc_version(xch, XENVER_version, NULL);
>>
>>     printf("Xen version %d.%d\n", ver >> 16, ver & 0xffff);
>>     xc_interface_close(xch);
>>     return 0;
>> }
>>
>> and compiled with `gcc foo.c -o foo -I/path/to/xenctrl.h
>> -L/path/to/libxenctrl.so -lxenctrl`
>>
>> ought to get you started.
>>
>> ~Andrew
>>
>
>

[-- Attachment #1.2: Type: text/html, Size: 5270 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using Xen's hypercall interface?
  2014-07-07 17:31     ` Rig Gel
@ 2014-07-08 15:03       ` Ian Campbell
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2014-07-08 15:03 UTC (permalink / raw)
  To: Rig Gel; +Cc: xen-devel

On Mon, 2014-07-07 at 20:31 +0300, Rig Gel wrote:

Please avoid top posting and HTML emails on xen-devel.

>         /proc/xen/privcmd seem to exist only from dom0, 
>         
>         is there any extension or ko i should load in order to find it
>         on other
>         kernels ? 

If you mount xenfs on /proc/xen then privcmd should be usable from a
guest, although only up to the privilege of that guest.

Ian.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-08 15:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-06 22:23 Using Xen's hypercall interface? Rig Gel
2014-07-06 23:26 ` Andrew Cooper
     [not found]   ` <CABUdxx7cynbosFFmids7==kLY1kAj8utS8jfWgr3O-UhUrS2dA@mail.gmail.com>
2014-07-07 17:31     ` Rig Gel
2014-07-08 15:03       ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.