]> err.no Git - linux-2.6/blobdiff - drivers/lguest/core.c
de2104x: remove BUG_ON() when changing media type
[linux-2.6] / drivers / lguest / core.c
index 0ea67cb0cc0b6a2482584400c91ef0e3e76bbbcd..7743d73768df273c008b700f8165ec5dafd668ec 100644 (file)
@@ -151,23 +151,23 @@ int lguest_address_ok(const struct lguest *lg,
 /* This routine copies memory from the Guest.  Here we can see how useful the
  * kill_lguest() routine we met in the Launcher can be: we return a random
  * value (all zeroes) instead of needing to return an error. */
-void __lgread(struct lguest *lg, void *b, unsigned long addr, unsigned bytes)
+void __lgread(struct lg_cpu *cpu, void *b, unsigned long addr, unsigned bytes)
 {
-       if (!lguest_address_ok(lg, addr, bytes)
-           || copy_from_user(b, lg->mem_base + addr, bytes) != 0) {
+       if (!lguest_address_ok(cpu->lg, addr, bytes)
+           || copy_from_user(b, cpu->lg->mem_base + addr, bytes) != 0) {
                /* copy_from_user should do this, but as we rely on it... */
                memset(b, 0, bytes);
-               kill_guest(lg, "bad read address %#lx len %u", addr, bytes);
+               kill_guest(cpu, "bad read address %#lx len %u", addr, bytes);
        }
 }
 
 /* This is the write (copy into guest) version. */
-void __lgwrite(struct lguest *lg, unsigned long addr, const void *b,
+void __lgwrite(struct lg_cpu *cpu, unsigned long addr, const void *b,
               unsigned bytes)
 {
-       if (!lguest_address_ok(lg, addr, bytes)
-           || copy_to_user(lg->mem_base + addr, b, bytes) != 0)
-               kill_guest(lg, "bad write address %#lx len %u", addr, bytes);
+       if (!lguest_address_ok(cpu->lg, addr, bytes)
+           || copy_to_user(cpu->lg->mem_base + addr, b, bytes) != 0)
+               kill_guest(cpu, "bad write address %#lx len %u", addr, bytes);
 }
 /*:*/
 
@@ -176,20 +176,18 @@ void __lgwrite(struct lguest *lg, unsigned long addr, const void *b,
  * going around and around until something interesting happens. */
 int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
 {
-       struct lguest *lg = cpu->lg;
-
        /* We stop running once the Guest is dead. */
-       while (!lg->dead) {
+       while (!cpu->lg->dead) {
                /* First we run any hypercalls the Guest wants done. */
                if (cpu->hcall)
                        do_hypercalls(cpu);
 
                /* It's possible the Guest did a NOTIFY hypercall to the
                 * Launcher, in which case we return from the read() now. */
-               if (lg->pending_notify) {
-                       if (put_user(lg->pending_notify, user))
+               if (cpu->pending_notify) {
+                       if (put_user(cpu->pending_notify, user))
                                return -EFAULT;
-                       return sizeof(lg->pending_notify);
+                       return sizeof(cpu->pending_notify);
                }
 
                /* Check for signals */
@@ -197,13 +195,13 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
                        return -ERESTARTSYS;
 
                /* If Waker set break_out, return to Launcher. */
-               if (lg->break_out)
+               if (cpu->break_out)
                        return -EAGAIN;
 
                /* Check if there are any interrupts which can be delivered
                 * now: if so, this sets up the hander to be executed when we
                 * next run the Guest. */
-               maybe_do_interrupt(lg);
+               maybe_do_interrupt(cpu);
 
                /* All long-lived kernel loops need to check with this horrible
                 * thing called the freezer.  If the Host is trying to suspend,
@@ -212,12 +210,12 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
 
                /* Just make absolutely sure the Guest is still alive.  One of
                 * those hypercalls could have been fatal, for example. */
-               if (lg->dead)
+               if (cpu->lg->dead)
                        break;
 
                /* If the Guest asked to be stopped, we sleep.  The Guest's
                 * clock timer or LHCALL_BREAK from the Waker will wake us. */
-               if (lg->halted) {
+               if (cpu->halted) {
                        set_current_state(TASK_INTERRUPTIBLE);
                        schedule();
                        continue;
@@ -237,7 +235,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
                lguest_arch_handle_trap(cpu);
        }
 
-       if (lg->dead == ERR_PTR(-ERESTART))
+       if (cpu->lg->dead == ERR_PTR(-ERESTART))
                return -ERESTART;
        /* The Guest is dead => "No such file or directory" */
        return -ENOENT;