aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-03-04 06:59:30 -0500
committerAvi Kivity <avi@qumranet.com>2007-05-03 03:52:24 -0400
commitb4e63f560beb187cffdaf706e534a1e2f9effb66 (patch)
tree1fe1a640530af04d1d722e0c99c8086b0e13f1e7
parent5d308f4550d9dc4c236e08b0377b610b9578577b (diff)
KVM: Allow userspace to process hypercalls which have no kernel handler
This is useful for paravirtualized graphics devices, for example. Signed-off-by: Avi Kivity <avi@qumranet.com>
-rw-r--r--drivers/kvm/kvm_main.c18
-rw-r--r--include/linux/kvm.h10
2 files changed, 26 insertions, 2 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 39cf8fd343a3..de93117f1e97 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)
1203 } 1203 }
1204 switch (nr) { 1204 switch (nr) {
1205 default: 1205 default:
1206 ; 1206 run->hypercall.args[0] = a0;
1207 run->hypercall.args[1] = a1;
1208 run->hypercall.args[2] = a2;
1209 run->hypercall.args[3] = a3;
1210 run->hypercall.args[4] = a4;
1211 run->hypercall.args[5] = a5;
1212 run->hypercall.ret = ret;
1213 run->hypercall.longmode = is_long_mode(vcpu);
1214 kvm_arch_ops->decache_regs(vcpu);
1215 return 0;
1207 } 1216 }
1208 vcpu->regs[VCPU_REGS_RAX] = ret; 1217 vcpu->regs[VCPU_REGS_RAX] = ret;
1209 kvm_arch_ops->decache_regs(vcpu); 1218 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)
1599 1608
1600 vcpu->mmio_needed = 0; 1609 vcpu->mmio_needed = 0;
1601 1610
1611 if (kvm_run->exit_type == KVM_EXIT_TYPE_VM_EXIT
1612 && kvm_run->exit_reason == KVM_EXIT_HYPERCALL) {
1613 kvm_arch_ops->cache_regs(vcpu);
1614 vcpu->regs[VCPU_REGS_RAX] = kvm_run->hypercall.ret;
1615 kvm_arch_ops->decache_regs(vcpu);
1616 }
1617
1602 r = kvm_arch_ops->run(vcpu, kvm_run); 1618 r = kvm_arch_ops->run(vcpu, kvm_run);
1603 1619
1604 vcpu_put(vcpu); 1620 vcpu_put(vcpu);
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index c93cf53953af..9151ebfa22e9 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -11,7 +11,7 @@
11#include <asm/types.h> 11#include <asm/types.h>
12#include <linux/ioctl.h> 12#include <linux/ioctl.h>
13 13
14#define KVM_API_VERSION 6 14#define KVM_API_VERSION 7
15 15
16/* 16/*
17 * Architectural interrupt line count, and the size of the bitmap needed 17 * Architectural interrupt line count, and the size of the bitmap needed
@@ -41,6 +41,7 @@ enum kvm_exit_reason {
41 KVM_EXIT_UNKNOWN = 0, 41 KVM_EXIT_UNKNOWN = 0,
42 KVM_EXIT_EXCEPTION = 1, 42 KVM_EXIT_EXCEPTION = 1,
43 KVM_EXIT_IO = 2, 43 KVM_EXIT_IO = 2,
44 KVM_EXIT_HYPERCALL = 3,
44 KVM_EXIT_DEBUG = 4, 45 KVM_EXIT_DEBUG = 4,
45 KVM_EXIT_HLT = 5, 46 KVM_EXIT_HLT = 5,
46 KVM_EXIT_MMIO = 6, 47 KVM_EXIT_MMIO = 6,
@@ -103,6 +104,13 @@ struct kvm_run {
103 __u32 len; 104 __u32 len;
104 __u8 is_write; 105 __u8 is_write;
105 } mmio; 106 } mmio;
107 /* KVM_EXIT_HYPERCALL */
108 struct {
109 __u64 args[6];
110 __u64 ret;
111 __u32 longmode;
112 __u32 pad;
113 } hypercall;
106 }; 114 };
107}; 115};
108 116