Add the register and notify hypercalls handlers.
The register hypercall turns the guests pfn into the mapped memory
address.
Signed-off-by: Dor Laor <[EMAIL PROTECTED]>
---
user/kvmctl.c | 41 +++++++++++++++++++++++++++++++++++++++++
user/kvmctl.h | 4 ++++
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/user/kvmctl.c b/user/kvmctl.c
index 846aac9..831774f 100644
--- a/user/kvmctl.c
+++ b/user/kvmctl.c
@@ -19,6 +19,7 @@
#endif
#include <linux/kvm.h>
+#include <linux/kvm_para.h>
#define EXPECTED_KVM_API_VERSION 12
@@ -846,6 +847,44 @@ static int handle_shutdown(kvm_context_t kvm, int
vcpu)
return kvm->callbacks->shutdown(kvm->opaque, vcpu);
}
+static int handle_pv_notify(kvm_context_t kvm, unsigned long key,
unsigned long iotype)
+{
+ return kvm->callbacks->pv_notify(key, iotype);
+}
+
+static int handle_pv_register(kvm_context_t kvm, unsigned long key,
unsigned long out_pfn, unsigned long in_pfn)
+{
+ return kvm->callbacks->pv_register(kvm->physical_memory, key,
+ (unsigned long)kvm->physical_memory +
(out_pfn*getpagesize()),
+ (unsigned long)kvm->physical_memory +
(in_pfn*getpagesize()));
+}
+
+static int handle_hypercall(kvm_context_t kvm, struct kvm_run *kvm_run,
+ int vcpu)
+{
+ int r = 0;
+
+ switch(kvm->run[vcpu]->hypercall.nr) {
+ case __NR_hypercall_register:
+ kvm->run[vcpu]->hypercall.ret = handle_pv_register(kvm,
+
kvm->run[vcpu]->hypercall.args[0],
+
kvm->run[vcpu]->hypercall.args[1],
+
kvm->run[vcpu]->hypercall.args[2]);
+ break;
+ case __NR_hypercall_notify:
+ kvm->run[vcpu]->hypercall.ret = handle_pv_notify(kvm,
+ kvm->run[vcpu]->hypercall.args[0],
+ kvm->run[vcpu]->hypercall.args[1]);
+ break;
+ default:
+ fprintf(stderr, "%s:no such nr=%llx hypercall
handling\n",
+ __FUNCTION__, kvm->run[vcpu]->hypercall.nr);
+ kvm->run[vcpu]->hypercall.ret = -EINVAL;
+ }
+
+ return r;
+}
+
int try_push_interrupts(kvm_context_t kvm)
{
return kvm->callbacks->try_push_interrupts(kvm->opaque);
@@ -1043,6 +1082,8 @@ again:
case KVM_EXIT_SHUTDOWN:
r = handle_shutdown(kvm, vcpu);
break;
+ case KVM_EXIT_HYPERCALL:
+ r = handle_hypercall(kvm, run, vcpu);
case KVM_EXIT_SET_TPR:
break;
default:
diff --git a/user/kvmctl.h b/user/kvmctl.h
index ff0bca6..09f40f4 100644
--- a/user/kvmctl.h
+++ b/user/kvmctl.h
@@ -66,6 +66,10 @@ struct kvm_callbacks {
int (*try_push_interrupts)(void *opaque);
void (*post_kvm_run)(void *opaque, int vcpu);
int (*pre_kvm_run)(void *opaque, int vcpu);
+
+ // pv device callbacks
+ int (*pv_register)(unsigned long memstart, unsigned long key,
unsigned long out, unsigned long in);
+ int (*pv_notify)(unsigned long key, unsigned long iotype);
};
/*!
-----
In simplicity there is elegance.
Dor Laor ;)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel