public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* VMCALL to KVM userspace?
@ 2013-08-13 14:33 Florian Pester
  2013-08-13 15:43 ` Paolo Bonzini
  2013-08-14 19:55 ` Muli Ben-Yehuda
  0 siblings, 2 replies; 3+ messages in thread
From: Florian Pester @ 2013-08-13 14:33 UTC (permalink / raw)
  To: kvm-devel

Hi,

for a uni project I'm trying to write a userspace for KVM that can run
ELF binaries without a full blown OS in the guest. The idea is to handle
any syscalls made by the binary running inside the guest in the
userspace of the host. In the simplest case you could forward them to
the host Linux kernel.

In any case, I've gotten pretty far, setting up IDTs, the VCPU, Page
Tables and whatnot, but right now I'm stuck. I setup my syscall handler
to do a VMCALL, which according to the Intel manual is supposed to
return control to the host. However this seems to be handled by KVM
without an exit into userspace?

If this is correct, is there any way to make a call to the host VMM,
that will be transfered to userspace by KVM?

Thanks
Florian


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

* Re: VMCALL to KVM userspace?
  2013-08-13 14:33 VMCALL to KVM userspace? Florian Pester
@ 2013-08-13 15:43 ` Paolo Bonzini
  2013-08-14 19:55 ` Muli Ben-Yehuda
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2013-08-13 15:43 UTC (permalink / raw)
  To: Florian Pester; +Cc: kvm-devel

Il 13/08/2013 16:33, Florian Pester ha scritto:
> Hi,
> 
> for a uni project I'm trying to write a userspace for KVM that can run
> ELF binaries without a full blown OS in the guest. The idea is to handle
> any syscalls made by the binary running inside the guest in the
> userspace of the host. In the simplest case you could forward them to
> the host Linux kernel.
> 
> In any case, I've gotten pretty far, setting up IDTs, the VCPU, Page
> Tables and whatnot, but right now I'm stuck. I setup my syscall handler
> to do a VMCALL, which according to the Intel manual is supposed to
> return control to the host. However this seems to be handled by KVM
> without an exit into userspace?

Yes, this is correct.

> If this is correct, is there any way to make a call to the host VMM,
> that will be transfered to userspace by KVM?

You could patch kvm_emulate_hypercall to return to userspace on an
unknown VMCALL.  The simplest implementation could be something like

	vcpu->run->exit_reason = KVM_EXIT_HYPERCALL;
	return 0;

in vmx.c's handle_vmcall and similarly for svm.c's vmmcall_interception.
 If you want to make a patch for upstream, it is a bit more complicated
because of backwards-compatibility.  You will need a new capability and
you will need to enable it with KVM_ENABLE_CAP, which right now is only
used by PowerPC KVM.

However, this "hypercall to userspace" functionality used to be there
and was removed, so it is unlikely to resurrect...  I suggest you use
simply an "out" to an otherwise unused port.

Paolo

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

* Re: VMCALL to KVM userspace?
  2013-08-13 14:33 VMCALL to KVM userspace? Florian Pester
  2013-08-13 15:43 ` Paolo Bonzini
@ 2013-08-14 19:55 ` Muli Ben-Yehuda
  1 sibling, 0 replies; 3+ messages in thread
From: Muli Ben-Yehuda @ 2013-08-14 19:55 UTC (permalink / raw)
  To: Florian Pester; +Cc: kvm-devel

On Tue, Aug 13, 2013 at 04:33:49PM +0200, Florian Pester wrote:

> for a uni project I'm trying to write a userspace for KVM that can
> run ELF binaries without a full blown OS in the guest. The idea is
> to handle any syscalls made by the binary running inside the guest
> in the userspace of the host. In the simplest case you could forward
> them to the host Linux kernel.

Sounds a lot like Dune,
http://www.scs.stanford.edu/~dm/home/papers/belay:dune.pdf.

> If this is correct, is there any way to make a call to the host VMM,
> that will be transfered to userspace by KVM?

(Paolo already answered)

Cheers,
Muli

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

end of thread, other threads:[~2013-08-14 19:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-13 14:33 VMCALL to KVM userspace? Florian Pester
2013-08-13 15:43 ` Paolo Bonzini
2013-08-14 19:55 ` Muli Ben-Yehuda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox