public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: Andrew Morton <akpm-3NddpPZAyC0@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 09/15] KVM: Allow userspace to process hypercalls which have no kernel handler
Date: Sun, 11 Mar 2007 15:53:21 +0200	[thread overview]
Message-ID: <11736212073905-git-send-email-avi@qumranet.com> (raw)
In-Reply-To: <11736212072915-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>

This is useful for paravirtualized graphics devices, for example.

Signed-off-by: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
---
 drivers/kvm/kvm_main.c |   18 +++++++++++++++++-
 include/linux/kvm.h    |   10 +++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 376538c..2220e49 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1203,7 +1203,16 @@ int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run)
 	}
 	switch (nr) {
 	default:
-		;
+		run->hypercall.args[0] = a0;
+		run->hypercall.args[1] = a1;
+		run->hypercall.args[2] = a2;
+		run->hypercall.args[3] = a3;
+		run->hypercall.args[4] = a4;
+		run->hypercall.args[5] = a5;
+		run->hypercall.ret = ret;
+		run->hypercall.longmode = is_long_mode(vcpu);
+		kvm_arch_ops->decache_regs(vcpu);
+		return 0;
 	}
 	vcpu->regs[VCPU_REGS_RAX] = ret;
 	kvm_arch_ops->decache_regs(vcpu);
@@ -1599,6 +1608,13 @@ static int kvm_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 
 	vcpu->mmio_needed = 0;
 
+	if (kvm_run->exit_type == KVM_EXIT_TYPE_VM_EXIT
+	    && kvm_run->exit_type == KVM_EXIT_HYPERCALL) {
+		kvm_arch_ops->cache_regs(vcpu);
+		vcpu->regs[VCPU_REGS_RAX] = kvm_run->hypercall.ret;
+		kvm_arch_ops->decache_regs(vcpu);
+	}
+
 	r = kvm_arch_ops->run(vcpu, kvm_run);
 
 	vcpu_put(vcpu);
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index c93cf53..9151ebf 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -11,7 +11,7 @@
 #include <asm/types.h>
 #include <linux/ioctl.h>
 
-#define KVM_API_VERSION 6
+#define KVM_API_VERSION 7
 
 /*
  * Architectural interrupt line count, and the size of the bitmap needed
@@ -41,6 +41,7 @@ enum kvm_exit_reason {
 	KVM_EXIT_UNKNOWN          = 0,
 	KVM_EXIT_EXCEPTION        = 1,
 	KVM_EXIT_IO               = 2,
+	KVM_EXIT_HYPERCALL        = 3,
 	KVM_EXIT_DEBUG            = 4,
 	KVM_EXIT_HLT              = 5,
 	KVM_EXIT_MMIO             = 6,
@@ -103,6 +104,13 @@ struct kvm_run {
 			__u32 len;
 			__u8  is_write;
 		} mmio;
+		/* KVM_EXIT_HYPERCALL */
+		struct {
+			__u64 args[6];
+			__u64 ret;
+			__u32 longmode;
+			__u32 pad;
+		} hypercall;
 	};
 };
 
-- 
1.5.0.2


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

  parent reply	other threads:[~2007-03-11 13:53 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-11 13:53 [PATCH 0/15] KVM userspace interface updates Avi Kivity
     [not found] ` <11736212072915-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-03-11 13:53   ` [PATCH 01/15] KVM: Use a shared page for kernel/user communication when runing a vcpu Avi Kivity
     [not found]     ` <1173621207773-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-03-15  2:38       ` Hollis Blanchard
2007-03-15  3:09         ` [kvm-devel] " Hollis Blanchard
2007-03-11 13:53   ` [PATCH 02/15] KVM: Do not communicate to userspace through cpu registers during PIO Avi Kivity
2007-03-11 13:53   ` [PATCH 03/15] KVM: Initialize PIO I/O count Avi Kivity
2007-03-11 13:53   ` [PATCH 04/15] KVM: Handle cpuid in the kernel instead of punting to userspace Avi Kivity
2007-03-11 13:53   ` [PATCH 05/15] KVM: Remove the 'emulated' field from the userspace interface Avi Kivity
2007-03-11 13:53   ` [PATCH 06/15] KVM: Remove minor wart from KVM_CREATE_VCPU ioctl Avi Kivity
2007-03-11 13:53   ` [PATCH 07/15] KVM: Renumber ioctls Avi Kivity
2007-03-11 13:53   ` [PATCH 08/15] KVM: Add method to check for backwards-compatible API extensions Avi Kivity
2007-03-16 15:06     ` [kvm-devel] " Heiko Carstens
     [not found]       ` <20070316150622.GC8525-Pmgahw53EmNLmI7Nx2oIsGnsbthNF6/HVpNB7YpNyf8@public.gmane.org>
2007-03-18  8:20         ` Avi Kivity
2007-03-11 13:53   ` Avi Kivity [this message]
2007-03-11 13:53   ` [PATCH 10/15] KVM: Fold kvm_run::exit_type into kvm_run::exit_reason Avi Kivity
2007-03-11 13:53   ` [PATCH 11/15] KVM: Add a special exit reason when exiting due to an interrupt Avi Kivity
2007-03-11 13:53   ` [PATCH 12/15] KVM: Initialize the apic_base msr on svm too Avi Kivity
2007-03-11 13:53   ` [PATCH 13/15] KVM: Add guest mode signal mask Avi Kivity
2007-03-11 13:53   ` [PATCH 14/15] KVM: Allow kernel to select size of mmap() buffer Avi Kivity
2007-03-11 13:53   ` [PATCH 15/15] KVM: Future-proof argument-less ioctls Avi Kivity
2007-03-16  8:36   ` [PATCH 0/15] KVM userspace interface updates Heiko Carstens
2007-03-16 14:03     ` [kvm-devel] " Anthony Liguori
2007-03-16 15:01       ` Heiko Carstens
2007-03-18 10:42         ` Avi Kivity
     [not found]           ` <45FD1778.6030602-7k6+44Jx4zn6gbPvEgmw2w@public.gmane.org>
2007-03-19 15:43             ` Heiko Carstens
     [not found]               ` <20070319154311.GB8331-Pmgahw53EmNLmI7Nx2oIsGnsbthNF6/HVpNB7YpNyf8@public.gmane.org>
2007-03-19 16:02                 ` Avi Kivity
2007-03-19 16:37                   ` [kvm-devel] " Heiko Carstens
     [not found]                   ` <45FEB431.8030504-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-03-19 17:49                     ` Avi Kivity
     [not found]     ` <20070316083650.GA8525-Pmgahw53EmNLmI7Nx2oIsGnsbthNF6/HVpNB7YpNyf8@public.gmane.org>
2007-03-18  5:20       ` Avi Kivity
     [not found]         ` <45FCCC39.7090104-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-03-18 10:22           ` Heiko Carstens
2007-03-18 10:32             ` [kvm-devel] " Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11736212073905-git-send-email-avi@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=akpm-3NddpPZAyC0@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox