Skip to contentSkip to conversation

Is it possible to make hypercall from user application directly?

DISCUSSION weiming 2 participants 4 messages Mar 11, 2008 – Mar 12, 2008

lore
Share & tools
lore

weiming

author
#0 lore raw

Hi,

I implemented my own Hypercall in xen.

Now I wish my application under dom0 could talk to Xen via my hypercall. Currently, I make a stub in dom0's kernel, which works as a proxy to forward the request. So, my application first makes a system call to dom0, which then makes hypercall to xen.

Is this design necessary? May I call hypercalls from user application under dom0 directly?

Thanks,
Weiming

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 4 lines · weiming

Hi,

I implemented my own Hypercall in xen.

Quoted 8 lines

Now I wish my application under dom0 could talk to Xen via my hypercall.
Currently, I make a stub in dom0's kernel, which works as a proxy to forward the request. So, my application first makes a system call to dom0, which then makes hypercall to xen.

Is this design necessary? May I call hypercalls from user application under dom0 directly?

No, not directly (didn't we have that syscall conversation recently? ;).

But for dom0-only privileged operations there's /proc/xen/privcmd to rule them all. See e.g. do_xen_hypercall() in tools/libxc/.

regards,
Daniel

Signature · 5 lines
Daniel Stodden
LRR     -      Lehrstuhl für Rechnertechnik und Rechnerorganisation
Institut für Informatik der TU München             D-85748 Garching
http://www.lrr.in.tum.de/~stodden         mailto:[email protected]
PGP Fingerprint: F5A4 1575 4C56 E26A 0B33  3D80 457E 82AE B0D8 735B
author
#2 lore raw

After some study, I got the following understanding. Please correct me if I'm wrong; otherwise, you can just say "correct".

1. In x86_64 mode, xen sets the LSTAR (the EIP of syscall target), and this value keeps constant. This value is code of "syscall_enter" defined in xen/arch/x86/x86_64/entry.S

2.
In ENTRY(syscall_enter)
...
...
testb $TF_kernel_mode, VCPU_thread_flag(%rbx)
jz switch_to_kernel

/*hypercall*/
...

so whenever a syscall is issued, "syscall_enter" checks the context. If it decides that the context is "kernel mode", it will treat the syscall as a plain "system call" from user applications. So it goes to "jz switch_to_kernel". Otherwise, it will think it's a hypercall issued from guest domains.

3. So an application can't make "hypercalls" directly because it's context is "kernel mode", so it will always be treated as a system call to the guest OS.

Am I right?

Thanks,
Weiming

Quoted 22 lines · Daniel Stodden
Quoted 4 lines · weiming

Hi,

I implemented my own Hypercall in xen.

Quoted 8 lines

Now I wish my application under dom0 could talk to Xen via my hypercall.
Currently, I make a stub in dom0's kernel, which works as a proxy to forward the request. So, my application first makes a system call to dom0, which then makes hypercall to xen.

Is this design necessary? May I call hypercalls from user application under dom0 directly?

No, not directly (didn't we have that syscall conversation recently? ;).

But for dom0-only privileged operations there's /proc/xen/privcmd to rule them all. See e.g. do_xen_hypercall() in tools/libxc/.

regards,
Daniel

Quoted 10 lines

--
Daniel Stodden
LRR - Lehrstuhl für Rechnertechnik und Rechnerorganisation
Institut für Informatik der TU München D-85748 Garching
http://www.lrr.in.tum.de/~stodden <http://www.lrr.in.tum.de/%7Estodden>
mailto:[email protected]
PGP Fingerprint: F5A4 1575 4C56 E26A 0B33 3D80 457E 82AE B0D8 735B

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 6 lines · weiming

After some study, I got the following understanding. Please correct me if I'm wrong; otherwise, you can just say "correct".

1. In x86_64 mode, xen sets the LSTAR (the EIP of syscall target), and this value keeps constant. This value is code of "syscall_enter" defined in xen/arch/x86/x86_64/entry.S

correct.

Quoted 7 lines

2.
In ENTRY(syscall_enter)
...
...
testb $TF_kernel_mode, VCPU_thread_flag(%rbx)
jz switch_to_kernel

Quoted 8 lines

/*hypercall*/
...

so whenever a syscall is issued, "syscall_enter" checks the context. If it decides that the context is "kernel mode", it will treat the syscall as a plain "system call" from user applications. So it goes to "jz switch_to_kernel". Otherwise, it will think it's a hypercall issued from guest domains.

correct. PT switching is then done in
create_bounce_frame/toggle_guest_mode.

Quoted 3 lines

3. So an application can't make "hypercalls" directly because it's context is "kernel mode", so it will always be treated as a system call to the guest OS.

believe you mean "user mode", but otherwise correct.

best,
daniel

Signature · 5 lines
Daniel Stodden
LRR     -      Lehrstuhl für Rechnertechnik und Rechnerorganisation
Institut für Informatik der TU München             D-85748 Garching
http://www.lrr.in.tum.de/~stodden         mailto:[email protected]
PGP Fingerprint: F5A4 1575 4C56 E26A 0B33  3D80 457E 82AE B0D8 735B