[PATCH 06/16] make hypercalls use the vcpu struct
this patch changes do_hcall() and do_async_hcall() interfaces (and obviously their callers) to get a vcpu struct. Again, a vcpu services the hypercall, not the whole guest Signed-off-by: Glauber de Oliveira Costa <[EMAIL PROTECTED]> --- drivers/lguest/core.c |6 +++--- drivers/lguest/hypercalls.c | 42 +++--- drivers/lguest/lg.h | 16 drivers/lguest/x86/core.c | 16 ++-- 4 files changed, 44 insertions(+), 36 deletions(-) diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c index 07a4c22..99f65f9 100644 --- a/drivers/lguest/core.c +++ b/drivers/lguest/core.c @@ -181,8 +181,8 @@ int run_guest(struct lg_vcpu *vcpu, unsigned long __user *user) /* We stop running once the Guest is dead. */ while (!lg->dead) { /* First we run any hypercalls the Guest wants done. */ - if (lg->hcall) - do_hypercalls(lg); + if (vcpu->hcall) + do_hypercalls(vcpu); /* It's possible the Guest did a NOTIFY hypercall to the * Launcher, in which case we return from the read() now. */ @@ -234,7 +234,7 @@ int run_guest(struct lg_vcpu *vcpu, unsigned long __user *user) local_irq_enable(); /* Now we deal with whatever happened to the Guest. */ - lguest_arch_handle_trap(lg); + lguest_arch_handle_trap(vcpu); } /* The Guest is dead => "No such file or directory" */ diff --git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c index b478aff..9417601 100644 --- a/drivers/lguest/hypercalls.c +++ b/drivers/lguest/hypercalls.c @@ -29,8 +29,10 @@ /*H:120 This is the core hypercall routine: where the Guest gets what it wants. * Or gets killed. Or, in the case of LHCALL_CRASH, both. */ -static void do_hcall(struct lguest *lg, struct hcall_args *args) +static void do_hcall(struct lg_vcpu *vcpu, struct hcall_args *args) { + struct lguest *lg = vcpu->lg; + switch (args->arg0) { case LHCALL_FLUSH_ASYNC: /* This call does nothing, except by breaking out of the Guest @@ -91,7 +93,7 @@ static void do_hcall(struct lguest *lg, struct hcall_args *args) break; default: /* It should be an architecture-specific hypercall. */ - if (lguest_arch_do_hcall(lg, args)) + if (lguest_arch_do_hcall(vcpu, args)) kill_guest(lg, "Bad hypercall %li\n", args->arg0); } } @@ -104,10 +106,11 @@ static void do_hcall(struct lguest *lg, struct hcall_args *args) * Guest put them in the ring, but we also promise the Guest that they will * happen before any normal hypercall (which is why we check this before * checking for a normal hcall). */ -static void do_async_hcalls(struct lguest *lg) +static void do_async_hcalls(struct lg_vcpu *vcpu) { unsigned int i; u8 st[LHCALL_RING_SIZE]; + struct lguest *lg = vcpu->lg; /* For simplicity, we copy the entire call status array in at once. */ if (copy_from_user(&st, &lg->lguest_data->hcall_status, sizeof(st))) @@ -119,7 +122,7 @@ static void do_async_hcalls(struct lguest *lg) /* We remember where we were up to from last time. This makes * sure that the hypercalls are done in the order the Guest * places them in the ring. */ - unsigned int n = lg->next_hcall; + unsigned int n = vcpu->next_hcall; /* 0xFF means there's no call here (yet). */ if (st[n] == 0xFF) @@ -127,8 +130,8 @@ static void do_async_hcalls(struct lguest *lg) /* OK, we have hypercall. Increment the "next_hcall" cursor, * and wrap back to 0 if we reach the end. */ - if (++lg->next_hcall == LHCALL_RING_SIZE) - lg->next_hcall = 0; + if (++vcpu->next_hcall == LHCALL_RING_SIZE) + vcpu->next_hcall = 0; /* Copy the hypercall arguments into a local copy of * the hcall_args struct. */ @@ -139,7 +142,7 @@ static void do_async_hcalls(struct lguest *lg) } /* Do the hypercall, same as a normal one. */ - do_hcall(lg, &args); + do_hcall(vcpu, &args); /* Mark the hypercall done. */ if (put_user(0xFF, &lg->lguest_data->hcall_status[n])) { @@ -156,16 +159,17 @@ static void do_async_hcalls(struct lguest *lg) /* Last of all, we look at what happens first of all. The very first time the * Guest makes a hypercall, we end up here to set things up: */ -static void initialize(struct lguest *lg) +static void initialize(struct lg_vcpu *vcpu) { + struct lguest *lg = vcpu->lg; /* You can't do anything until you're initialized. Th
[PATCH 06/16] make hypercalls use the vcpu struct
this patch changes do_hcall() and do_async_hcall() interfaces (and obviously their callers) to get a vcpu struct. Again, a vcpu services the hypercall, not the whole guest Signed-off-by: Glauber de Oliveira Costa <[EMAIL PROTECTED]> --- drivers/lguest/core.c |6 +++--- drivers/lguest/hypercalls.c | 42 +++--- drivers/lguest/lg.h | 16 drivers/lguest/x86/core.c | 16 ++-- 4 files changed, 44 insertions(+), 36 deletions(-) diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c index 70fc65e..ef35e02 100644 --- a/drivers/lguest/core.c +++ b/drivers/lguest/core.c @@ -181,8 +181,8 @@ int run_guest(struct lguest_vcpu *vcpu, unsigned long __user *user) /* We stop running once the Guest is dead. */ while (!lg->dead) { /* First we run any hypercalls the Guest wants done. */ - if (lg->hcall) - do_hypercalls(lg); + if (vcpu->hcall) + do_hypercalls(vcpu); /* It's possible the Guest did a NOTIFY hypercall to the * Launcher, in which case we return from the read() now. */ @@ -234,7 +234,7 @@ int run_guest(struct lguest_vcpu *vcpu, unsigned long __user *user) local_irq_enable(); /* Now we deal with whatever happened to the Guest. */ - lguest_arch_handle_trap(lg); + lguest_arch_handle_trap(vcpu); } /* The Guest is dead => "No such file or directory" */ diff --git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c index b478aff..62da355 100644 --- a/drivers/lguest/hypercalls.c +++ b/drivers/lguest/hypercalls.c @@ -29,8 +29,10 @@ /*H:120 This is the core hypercall routine: where the Guest gets what it wants. * Or gets killed. Or, in the case of LHCALL_CRASH, both. */ -static void do_hcall(struct lguest *lg, struct hcall_args *args) +static void do_hcall(struct lguest_vcpu *vcpu, struct hcall_args *args) { + struct lguest *lg = vcpu->lg; + switch (args->arg0) { case LHCALL_FLUSH_ASYNC: /* This call does nothing, except by breaking out of the Guest @@ -91,7 +93,7 @@ static void do_hcall(struct lguest *lg, struct hcall_args *args) break; default: /* It should be an architecture-specific hypercall. */ - if (lguest_arch_do_hcall(lg, args)) + if (lguest_arch_do_hcall(vcpu, args)) kill_guest(lg, "Bad hypercall %li\n", args->arg0); } } @@ -104,10 +106,11 @@ static void do_hcall(struct lguest *lg, struct hcall_args *args) * Guest put them in the ring, but we also promise the Guest that they will * happen before any normal hypercall (which is why we check this before * checking for a normal hcall). */ -static void do_async_hcalls(struct lguest *lg) +static void do_async_hcalls(struct lguest_vcpu *vcpu) { unsigned int i; u8 st[LHCALL_RING_SIZE]; + struct lguest *lg = vcpu->lg; /* For simplicity, we copy the entire call status array in at once. */ if (copy_from_user(&st, &lg->lguest_data->hcall_status, sizeof(st))) @@ -119,7 +122,7 @@ static void do_async_hcalls(struct lguest *lg) /* We remember where we were up to from last time. This makes * sure that the hypercalls are done in the order the Guest * places them in the ring. */ - unsigned int n = lg->next_hcall; + unsigned int n = vcpu->next_hcall; /* 0xFF means there's no call here (yet). */ if (st[n] == 0xFF) @@ -127,8 +130,8 @@ static void do_async_hcalls(struct lguest *lg) /* OK, we have hypercall. Increment the "next_hcall" cursor, * and wrap back to 0 if we reach the end. */ - if (++lg->next_hcall == LHCALL_RING_SIZE) - lg->next_hcall = 0; + if (++vcpu->next_hcall == LHCALL_RING_SIZE) + vcpu->next_hcall = 0; /* Copy the hypercall arguments into a local copy of * the hcall_args struct. */ @@ -139,7 +142,7 @@ static void do_async_hcalls(struct lguest *lg) } /* Do the hypercall, same as a normal one. */ - do_hcall(lg, &args); + do_hcall(vcpu, &args); /* Mark the hypercall done. */ if (put_user(0xFF, &lg->lguest_data->hcall_status[n])) { @@ -156,16 +159,17 @@ static void do_async_hcalls(struct lguest *lg) /* Last of all, we look at what happens first of all. The very first time the * Guest makes a hypercall, we end up here to set things up: */ -static void initialize(struct lguest *lg) +static void initialize(struct lguest_vcpu *vcpu) { + struct lguest *lg = vcpu->lg; /* You can't do anything until you