All of lore.kernel.org
 help / color / mirror / Atom feed
* Passing pointers to hypercalls
@ 2014-11-09 19:16 Amaro, Emmanuel
  2014-11-09 19:27 ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Amaro, Emmanuel @ 2014-11-09 19:16 UTC (permalink / raw)
  To: xen-devel@lists.xen.org


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

Hello,

I am trying to pass a pointer to an hyper call in the simplest possible way, set it’s value, an return it to the guest.

I have tried 2 different ways:
- Directly with simple pointers (I read somewhere this would work on x86), but the pointer address is set to 0x0000deadbeef, so dereferencing it causes a panic.
- With XEN_GUEST_HANDLE:
long do_dummy(XEN_GUEST_HANDLE(uint64_t) ptr)
{
    uint64_t tmp = 1;

    if (copy_to_guest(ptr, &tmp, 1) != 0)
        return 2;

    return 0;
}

But in this case copy_to_guest() does not return 0, so this fails as well. I call the hyper call from this Linux system call:

asmlinkage long sys_dummy(void)
{
    uint64_t p = 0;
    int rc = 0;
    rc = HYPERVISOR_dummy(&p);

    if (rc != 0)
        printk("ERROR, hypercall returned: %d\n", rc);

    return 0;
}

I am sure I am missing something super easy, but I can’t see what.

Thank you for your help,
Emmanuel

[-- Attachment #1.2: Type: text/html, Size: 4408 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] 3+ messages in thread

* Re: Passing pointers to hypercalls
  2014-11-09 19:16 Passing pointers to hypercalls Amaro, Emmanuel
@ 2014-11-09 19:27 ` Andrew Cooper
  2014-11-09 19:50   ` Amaro, Emmanuel
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2014-11-09 19:27 UTC (permalink / raw)
  To: Amaro, Emmanuel, xen-devel@lists.xen.org


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

On 09/11/14 19:16, Amaro, Emmanuel wrote:
> Hello,
>
> I am trying to pass a pointer to an hyper call in the simplest
> possible way, set it's value, an return it to the guest.
>
> I have tried 2 different ways:
> - Directly with simple pointers (I read somewhere this would work on
> x86), but the pointer address is set to 0x0000deadbeef, so
> dereferencing it causes a panic.
> - With XEN_GUEST_HANDLE:
>
>         long do_dummy(XEN_GUEST_HANDLE(uint64_t) ptr)
>
>         {
>

It looks like you have introduced a new hypercall called dummy.

I presume from this code that you have filled in a new handler in the
hypercall_table, but have you set the expected number of args in the
hypercall_args_table?

The default number of args is 0, which cases a debug Xen to deliberately
clobber all the registers to 0xdeadbeef

~Andrew

[-- Attachment #1.2: Type: text/html, Size: 2162 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] 3+ messages in thread

* Re: Passing pointers to hypercalls
  2014-11-09 19:27 ` Andrew Cooper
@ 2014-11-09 19:50   ` Amaro, Emmanuel
  0 siblings, 0 replies; 3+ messages in thread
From: Amaro, Emmanuel @ 2014-11-09 19:50 UTC (permalink / raw)
  To: xen-devel@lists.xen.org


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

Of course. Agh, I forgot to change it to 1.

If someone else looks at this, in my case it means this file: xen/arch/x86/x86_64/entry.S

Thanks!


On Nov 9, 2014, at 2:27 PM, Andrew Cooper <andrew.cooper3@citrix.com<mailto:andrew.cooper3@citrix.com>> wrote:

On 09/11/14 19:16, Amaro, Emmanuel wrote:
Hello,

I am trying to pass a pointer to an hyper call in the simplest possible way, set it’s value, an return it to the guest.

I have tried 2 different ways:
- Directly with simple pointers (I read somewhere this would work on x86), but the pointer address is set to 0x0000deadbeef, so dereferencing it causes a panic.
- With XEN_GUEST_HANDLE:
long do_dummy(XEN_GUEST_HANDLE(uint64_t) ptr)
{

It looks like you have introduced a new hypercall called dummy.

I presume from this code that you have filled in a new handler in the hypercall_table, but have you set the expected number of args in the hypercall_args_table?

The default number of args is 0, which cases a debug Xen to deliberately clobber all the registers to 0xdeadbeef

~Andrew


[-- Attachment #1.2: Type: text/html, Size: 2686 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] 3+ messages in thread

end of thread, other threads:[~2014-11-09 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-09 19:16 Passing pointers to hypercalls Amaro, Emmanuel
2014-11-09 19:27 ` Andrew Cooper
2014-11-09 19:50   ` Amaro, Emmanuel

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.