aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lguest/lguest_user.c
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2008-01-07 08:05:32 -0500
committerRusty Russell <rusty@rustcorp.com.au>2008-01-30 06:50:11 -0500
commita53a35a8b485b9c16b73e5177bddaa4321971199 (patch)
tree8ed96838cb47d1263f63aba6dd6921b3c811f46c /drivers/lguest/lguest_user.c
parenta3863f68b0d7fe2073c0f4efe534ec87a685c4fa (diff)
lguest: make registers per-vcpu
This is the most obvious per-vcpu field: registers. So this patch moves it from struct lguest to struct vcpu, and patch the places in which they are used, accordingly Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/lguest/lguest_user.c')
-rw-r--r--drivers/lguest/lguest_user.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 605db5c49e7f..d21d95b2b1fc 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -106,6 +106,19 @@ static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
106 cpu->lg->nr_cpus++; 106 cpu->lg->nr_cpus++;
107 init_clockdev(cpu); 107 init_clockdev(cpu);
108 108
109 /* We need a complete page for the Guest registers: they are accessible
110 * to the Guest and we can only grant it access to whole pages. */
111 cpu->regs_page = get_zeroed_page(GFP_KERNEL);
112 if (!cpu->regs_page)
113 return -ENOMEM;
114
115 /* We actually put the registers at the bottom of the page. */
116 cpu->regs = (void *)cpu->regs_page + PAGE_SIZE - sizeof(*cpu->regs);
117
118 /* Now we initialize the Guest's registers, handing it the start
119 * address. */
120 lguest_arch_setup_regs(cpu, start_ip);
121
109 return 0; 122 return 0;
110} 123}
111 124
@@ -160,16 +173,6 @@ static int initialize(struct file *file, const unsigned long __user *input)
160 if (err) 173 if (err)
161 goto release_guest; 174 goto release_guest;
162 175
163 /* We need a complete page for the Guest registers: they are accessible
164 * to the Guest and we can only grant it access to whole pages. */
165 lg->regs_page = get_zeroed_page(GFP_KERNEL);
166 if (!lg->regs_page) {
167 err = -ENOMEM;
168 goto release_guest;
169 }
170 /* We actually put the registers at the bottom of the page. */
171 lg->regs = (void *)lg->regs_page + PAGE_SIZE - sizeof(*lg->regs);
172
173 /* Initialize the Guest's shadow page tables, using the toplevel 176 /* Initialize the Guest's shadow page tables, using the toplevel
174 * address the Launcher gave us. This allocates memory, so can 177 * address the Launcher gave us. This allocates memory, so can
175 * fail. */ 178 * fail. */
@@ -177,10 +180,6 @@ static int initialize(struct file *file, const unsigned long __user *input)
177 if (err) 180 if (err)
178 goto free_regs; 181 goto free_regs;
179 182
180 /* Now we initialize the Guest's registers, handing it the start
181 * address. */
182 lguest_arch_setup_regs(lg, args[3]);
183
184 /* We keep a pointer to the Launcher task (ie. current task) for when 183 /* We keep a pointer to the Launcher task (ie. current task) for when
185 * other Guests want to wake this one (inter-Guest I/O). */ 184 * other Guests want to wake this one (inter-Guest I/O). */
186 lg->tsk = current; 185 lg->tsk = current;
@@ -205,7 +204,8 @@ static int initialize(struct file *file, const unsigned long __user *input)
205 return sizeof(args); 204 return sizeof(args);
206 205
207free_regs: 206free_regs:
208 free_page(lg->regs_page); 207 /* FIXME: This should be in free_vcpu */
208 free_page(lg->cpus[0].regs_page);
209release_guest: 209release_guest:
210 kfree(lg); 210 kfree(lg);
211unlock: 211unlock:
@@ -280,9 +280,12 @@ static int close(struct inode *inode, struct file *file)
280 /* We need the big lock, to protect from inter-guest I/O and other 280 /* We need the big lock, to protect from inter-guest I/O and other
281 * Launchers initializing guests. */ 281 * Launchers initializing guests. */
282 mutex_lock(&lguest_lock); 282 mutex_lock(&lguest_lock);
283 for (i = 0; i < lg->nr_cpus; i++) 283 for (i = 0; i < lg->nr_cpus; i++) {
284 /* Cancels the hrtimer set via LHCALL_SET_CLOCKEVENT. */ 284 /* Cancels the hrtimer set via LHCALL_SET_CLOCKEVENT. */
285 hrtimer_cancel(&lg->cpus[i].hrt); 285 hrtimer_cancel(&lg->cpus[i].hrt);
286 /* We can free up the register page we allocated. */
287 free_page(lg->cpus[i].regs_page);
288 }
286 /* Free up the shadow page tables for the Guest. */ 289 /* Free up the shadow page tables for the Guest. */
287 free_guest_pagetable(lg); 290 free_guest_pagetable(lg);
288 /* Now all the memory cleanups are done, it's safe to release the 291 /* Now all the memory cleanups are done, it's safe to release the
@@ -292,8 +295,6 @@ static int close(struct inode *inode, struct file *file)
292 * kmalloc()ed string, either of which is ok to hand to kfree(). */ 295 * kmalloc()ed string, either of which is ok to hand to kfree(). */
293 if (!IS_ERR(lg->dead)) 296 if (!IS_ERR(lg->dead))
294 kfree(lg->dead); 297 kfree(lg->dead);
295 /* We can free up the register page we allocated. */
296 free_page(lg->regs_page);
297 /* We clear the entire structure, which also marks it as free for the 298 /* We clear the entire structure, which also marks it as free for the
298 * next user. */ 299 * next user. */
299 memset(lg, 0, sizeof(*lg)); 300 memset(lg, 0, sizeof(*lg));