[Lguest] [patch] cleanup hypercall code

Rusty Russell rusty at rustcorp.com.au
Mon Aug 20 11:47:43 EST 2007


On Fri, 2007-08-17 at 16:37 +0200, Jes Sorensen wrote:
> Hi,
> 
> Rusty asked us to be nice and not break anything over the weekend  ....
> bzzzzt, wrong thing to ask for :-)
> 
> This one cleans up the hypercall code and introduces a two level
> processing of calls so we first go through the generic ones and then
> handle the architecture specific ones.
> 
> It also changes struct hcall_ring to hcall_args and make that the
> standard argument pass to do_hcall - this makes it a lot easier to
> implement hcalls on non x86.
> 
> I put the i386 stuff into i386_core.c rather than introduce yet another
> i386_hypercalls.c file. We can do that, but I think it's better not to
> clubber the hierachy with too many files.

Absolutely agree with all this; great stuff!

Couple of minor comments:

>  #define LHCALL_RING_SIZE 64
> -struct hcall_ring
> +struct hcall_args
>  {
> -	u32 eax, edx, ebx, ecx;
> +	/* These map directly onto eax, ebx, ecx, edx in struct lguest_regs */
> +	u32 arg0, arg1, arg2, arg3;
>  };

arg0 can probably be generically called "hcall_num" or something.
Actually, it's also often the return, so you're right arg0 is better.

> +#define LG_GET_HCALL_ARGS(lg)	(struct hcall_args *)&lg->regs->eax

Prefer a union in regs, and less SHOUTING: 

static inline struct hcall_args *lg_hcall_args(struct lguest *lg)
{
	return &lg->regs->hcall_args;
}

> +
> +/*
> + * Determine whether the hypercall code was entered because of a real
> + * hypercall or if it was for some other reason, interrupt, different
> + * trap .....
> + */
> +#define LG_IN_REAL_HCALL(lg)	(lg->regs->trapnum == LGUEST_TRAP_ENTRY)

lguest_wants_hcall(lg) maybe?

Thanks!
Rusty.




More information about the Lguest mailing list