Matias Zabaljauregui | 23 Oct 23:13

[PATCH resend v2] lguest: Change over to using KVM hypercalls mechanism

This patch allows us to use KVM hypercalls.

Signed-off-by: Matias Zabaljauregui <zabaljauregui@...>
---
 arch/x86/lguest/boot.c                |   87 ++++++++++++++++++++-------------
 arch/x86/lguest/i386_head.S           |    4 +-
 drivers/lguest/interrupts_and_traps.c |    7 ++-
 drivers/lguest/lguest_device.c        |    4 +-
 drivers/lguest/x86/core.c             |   54 ++++++++++++++++++++-
 include/asm-x86/lguest_hcall.h        |   24 ++--------
 6 files changed, 118 insertions(+), 62 deletions(-)

diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index c6a6b75..f6ae1cb 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -106,7 +106,7 @@ static void async_hcall(unsigned long call, unsigned long arg1,
 	local_irq_save(flags);
 	if (lguest_data.hcall_status[next_call] != 0xFF) {
 		/* Table full, so do normal hcall which will flush table. */
-		hcall(call, arg1, arg2, arg3);
+		kvm_hypercall3(call, arg1, arg2, arg3);
 	} else {
 		lguest_data.hcalls[next_call].arg0 = call;
 		lguest_data.hcalls[next_call].arg1 = arg1;
@@ -133,13 +133,31 @@ static void async_hcall(unsigned long call, unsigned long arg1,
  *
  * So, when we're in lazy mode, we call async_hcall() to store the call for
  * future processing: */
-static void lazy_hcall(unsigned long call,
(Continue reading)

Rusty Russell | 24 Oct 04:50

Re: [PATCH resend v2] lguest: Change over to using KVM hypercalls mechanism

On Friday 24 October 2008 08:17:13 Matias Zabaljauregui wrote:
> This patch allows us to use KVM hypercalls.
>
> Signed-off-by: Matias Zabaljauregui <zabaljauregui@...>

Thanks, this is excellent!

I inserted some paragraph breaks in your prose, and expanded the wording a
little at the start and end.  I hope that's ok, here's the change.

Thanks!
Rusty.

diff -r 71fc5b444eea drivers/lguest/x86/core.c
--- a/drivers/lguest/x86/core.c	Fri Oct 24 13:35:43 2008 +1100
+++ b/drivers/lguest/x86/core.c	Fri Oct 24 13:49:38 2008 +1100
@@ -291,28 +291,36 @@ static int emulate_insn(struct lg_cpu *c
 }

 /* Our hypercalls mechanism used to be based on direct software interrupts.
- * After Anthony's "Refactor hypercall infrastructure" kvm patch,
- * we decided to change over to using kvm hypercalls.
- * KVM_HYPERCALL generates an invalid opcode fault (fault 6) on non-VT cpus, so
- * the easiest solution seemed to be an *emulation approach*: if the fault was
- * really produced by an hypercall (is_hypercall() does exactly this check), we
- * just call the corresponding hypercall host implementation function.
- * But invalid opcode faults are notably slower than software interrupts.
- * So we implemented the *patching (or rewriting) approach*: every time we find
- * the KVM_HYPERCALL opcode in guest code, we patch it to int 0x1f opcode, so
- * next time the guest calls this hypercall, it will use the faster
(Continue reading)


Gmane