Matias Zabaljauregui | 23 Oct 00:28

[PATCH 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             |   49 ++++++++++++++++++
 include/asm-x86/lguest_hcall.h        |   24 ++--------
 6 files changed, 114 insertions(+), 61 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 | 23 Oct 17:53

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

On Thursday 23 October 2008 09:32:06 Matias Zabaljauregui wrote:
> This patch allows us to use KVM hypercalls.

Thanks!

A few minor comments....

> +static void rewrite_hypercall(struct lg_cpu *cpu)
> +{
> +	unsigned long physaddr = guest_pa(cpu, cpu->regs->eip);
> +
> +	/* This are the opcodes we use to patch the guest.
> +	 * The opcode for "int $ox1f"  is  0xcd 0x1f
> +	 * but vmcall instruction is 3 bytes long, so we complete
> +	 * the sequence with a NOP (0x90). */
> +	u8 insn[3] = {0xcd, 0x1f, 0x90};
> +
> +	lgwrite(cpu, physaddr, u8, insn[0]);
> +	lgwrite(cpu, physaddr + 1, u8, insn[1]);
> +	lgwrite(cpu, physaddr + 2, u8, insn[2]);

I think this is a good opportunity to use __lgwrite().

Also, above this function there should be a longer explanation, showing
your benchmarks as to why it's worth having this second hcall method.
(I know, but it's good reading for new hackers!).

> +	/* The eip contains the *virtual* address of the Guest's instruction:
> +	 * guest_pa just subtracts the Guest's page_offset. */
> +	unsigned long physaddr = guest_pa(cpu, cpu->regs->eip);
(Continue reading)


Gmane